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

Win32: Refactor, split off and fix resize logic and DPI changes handling #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

prokopyl
Copy link
Member

This PR refactors and splits off the logic that handles re-sizing and discovering/updating the window's DPI.

Some of that logic is split off into a new, low-level Win32Window type, which only handles translating baseview types and assumptions into Win32 calls, separately from managing events or the window handler.

This is part of the effort to split up #174 into smaller pieces.

This PR actually changes the logic, mainly by also splitting the internal window_info into two separate components, current_size (physical) and current_scale_factor, which are instead updated independently during their respective events.

Incidentally, this PR also fixes a few bugs:

  • Fix the window handler not being notified of the new scaling factor that's discovered right after the window is created.
  • Fix a WM_DPICHANGE event triggering a window resize but not triggering a resize event in the window handler. This supersedes the work done in Fix WM_DPICHANGED not triggering Resized event #140.
  • Fix handling of the WM_DPICHANGE event to use the OS-provided window dimensions and position, instead of computing our own dimensions and leaving the position as-is. This avoids a DPI-change loop due to the window constantly switching between two monitors as it's being dragged across them using the mouse.

This has all been tested on my Windows 10 machine and works as expected.

@prokopyl prokopyl requested a review from glowcoil March 27, 2024 00:09
@prokopyl prokopyl changed the title Win32; Refactor, split off and fix resize logic and DPI changes handling Win32: Refactor, split off and fix resize logic and DPI changes handling Mar 27, 2024
@prokopyl prokopyl force-pushed the split-win32-resize-logic branch 2 times, most recently from 25e486d to 0188f83 Compare March 29, 2024 23:25
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.

1 participant