Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): wait for Qt before getting bounds #5478

Merged
merged 6 commits into from
Jun 23, 2024

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Jun 22, 2024

Since we don't use the bounds provided by WM_SIZE itself to account for Qt's High-DPI scaling, we need to wait for Qt to have processed the message before saving our bounds. Technically, this could use the bounds we get from GetClientRect and emulate Qt's scaling, but I don't think that's smart (because Qt might change stuff, etc...).

postToThread isn't the best name for this use-case, because we're only interested in queuing an event after Qt has processed the native message. It's more like nextTick or rather endOfThisTick or beforeNextTickButAfterAllCurrentEvents.

The same is done for WM_MOVE which needs to be processed by Qt.

Things to test

  • Snap 1
    1. Open Chatterino
    2. Resize the window
    3. Snap the window to one side of the monitor
    4. Close Chatterino
    5. Open it again [it should open at the same position & size]
  • Snap 2
    1. Open Chatterino [the window must not be the same size as after the snap - in that case, resize and reopen]
    2. Snap the window
    3. Close Chatterino
    4. Reopen [it should open at the same position & size]
  • Snap 3
    1. Open Chatterino
    2. Snap the window
    3. Close Chatterino
    4. Reopen [it should open at the same position & size]
    5. Close Chatterino
    6. Reopen [it should open at the same position & size]
    7. Drag the window
    8. Close Chatterino
    9. Reopen [it should open at the same position & size]
    10. Snap the window to the same side as in step 2
    11. Reopen [it should open at the same position & size]
  • Maxi 1 [regression test]
    1. Open Chatterino
    2. Resize the window
    3. Maximize the window
    4. Restore the window [it should have the same geometry as after step 2]
    5. Maximize the window
    6. Close Chatterino
    7. Reopen [it should open maximized]
    8. Restore it [no constraint - compare to e.g. explorer]
  • Maxi 2
    1. Open Chatterino
    2. Resize the window
    3. Snap the window
    4. Maximize the window
    5. Restore the window [it should have the same geometry as after step 3]
    6. Maximize the window
    7. Close Chatterino
    8. Reopen [it should open maximized]
  • Maxi 3
    1. Open Chatterino
    2. Resize the window
    3. Snap the window
    4. Maximize the window
    5. Restore the window [it should have the same geometry as after step 3]
    6. Close Chatterino
    7. Reopen [it should open at the same position & size]
  • Mini 1
    1. Open Chatterino
    2. Resize the window
    3. Snap the window
    4. Minimize the window
    5. Close Chatterino (through the taskbar)
    6. Reopen [it should open at the same position & size; minimized]
  • Mini 2 [regression test]
    1. Open Chatterino
    2. Resize the window
    3. Move the window
    4. Minimize the window
    5. Close Chatterino (through the taskbar)
    6. Reopen [it should open at the same position & size; minimized]
  • Minimax [regression test]
    1. Open Chatterino
    2. Maximize the window
    3. Minimize the window
    4. Close Chatterino (through the taskbar)
    5. Reopen [it should open maximized but minimized]

Fixes #5477.

@8thony
Copy link
Contributor

8thony commented Jun 22, 2024

Copy link
Contributor

@8thony 8thony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My issue is fixed. Thank you

@pajlada pajlada enabled auto-merge (squash) June 23, 2024 11:01
@pajlada pajlada merged commit 4421b6c into Chatterino:master Jun 23, 2024
17 checks passed
@Nerixyz Nerixyz deleted the fix/windows-drag-thing branch June 23, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Main window Position not correctly saved
3 participants