Skip to content

Conversation

@german-one
Copy link
Contributor

Make the app DPI aware to avoid blurry window content.
closes #10

Fix encoding and translation values in the resource script.
related #11

@german-one
Copy link
Contributor Author

german-one commented Apr 18, 2025

Probably I should've added some screenshots 😄 (HiDPI display, 150% scaling)

FWIW In the below table, images are resized to fit into the cells. If you open them in separate browser tabs you'll see that the switcher window is rendered smaller when it is DPI aware.

new before
icons_new icons_old
msg_new msg_old
name_new name_old

Last line is the encoding thing.

EDIT: Thanks to the screenshots, I realized that I forgot to add the visual styles to the manifest.

src/cmdtab.c Outdated
}

textRect.bottom -= ICON_PAD; // *** this lifts the app text up a little ***
textRect.bottom -= ICON_PAD / 2; // *** this lifts the app text up a little ***
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's been too much now. The text touched the selection rectangle.

@stianhoiland
Copy link
Owner

After your explanation in #10, I think I prefer the SetProcessDPIAware()-route. I've yet to test it myself, but have implemented changes locally like yours in #11 to enable my new toolchain, test this change, and eventually pick up another release.

I'm unhappy about the text padding. I will have to inspect how Microsoft's Alt-Tab scales the window title, window preview, and paddings, and go for something equivalent. The way it looks in your screenshot is no good, although I will accept it temporarily.

I will accept this pull request with these changes: go from using the manifest file to using SetProcessDPIAware().

Thanks for the contribution :)

@german-one
Copy link
Contributor Author

I'm unhappy about the text padding.

I failed to calculate it based on the text measuring performed a few lines above. Let me try again. The reason why it was necessary to update the padding is that the text size appears still the same as before, while DPI awareness makes that the window is rendered smaller.

@german-one german-one marked this pull request as draft April 22, 2025 16:05
@german-one
Copy link
Contributor Author

Now the text is vertically centered in the gap between icon and window bottom. It looks like being closer to the icon because the selection rectangle is bigger than the icon. What do you think?
Screenshot 2025-04-22 184242

@german-one german-one marked this pull request as ready for review April 22, 2025 16:56

// Avoid blurry window content (#10)
SetProcessDPIAware();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this was after the AlreadyRunning clause (as I initially planned), the message box in AskAutorun() would have been still blurry. So I had to move it up.

stianhoiland added a commit that referenced this pull request Sep 29, 2025
Highlights

- Mouse support! (#6)
- Now using a new technique to fix stuck keys and match Windows Alt-Tab behaviours (#4, #9)
- Fix wrong window selection after using Alt-Q
- If switching to window fails play unintrusive sound instead of show error message box (#21)
- First step towards DPI awareness by adding manifest (#10, #13)
- Dev: better support for non-MSVC and non-CMake envs (i.e. mingw-w64)

Changelog

- various code style changes (include style, conditionals, whitespace, comments, var names, return over break in case statements)
- some newlines and file encoding changes
- when switching fails play sound instead of show error message box
- remove redundant Debug function
- support stdout and attached debuggers for debug output (mingw gcc vs MSVC)
- use GetLastActivePopup when calling SetForegroundWindow (hmm, why exactly?)
- move ReceiveLastInputEvent down to cmdtab impl.
- new config option for "askAutorun"
- remove near-useless config option "restoreOnCancel" and RestorableWindow
- add some more debug printing and don't key repeat debug hotkeys
- split SelectNextWindow & SelectFirstWindow into *Window and *App variants
- use new technique to avoid stuck mod keys and match Windows Alt-Tab behavior
  - new SendModKeysUp function called on (mod1Up || mod2Up)
  - skip injected mod keys up kbd hook messages
  - consume (mod1Up || mod2Up) kbd hook messages
  - call ReceiveLastInputEvent only on ShowSwitcher
- fix selection bug after using Alt-Q
- don't ReleaseDC in in OnWindowPaint (hmm, why?)
- rename WindowProcedure to SwitcherWindowProcedure
- rename "OnWindowEvent" functions to "OnSwitcherEvent"
- mouse support!
- fix hourglass mouse cursor
- switch fallthrough in EventHookProcedure
- remove WM_DESTROY
- use build type Debug -> MinSizeRel in CMakeLists.txt
- reword "run automatically as administrator" to "autorun as admin" in README.md
- reword "run automatically on login" to "autorun on login" in README.md
- fix locale info in .rc -- Thanks to @german-one for spotting this and contributing fixes! (#11, #13)
- use .manifest: Currently implements UAC, Visual Styles, and DPI awareness
  - The manifest is required for updated visual styles on non-MSVC compilers
- add a simple Makefile to support non-CMake builds
stianhoiland added a commit that referenced this pull request Oct 4, 2025
- scale switcher and icons
- (TODO) respond to WM_DPICHANGED
- closes #10 and #13

Thanks to @german-one for initial work on DPI (#13)
@stianhoiland
Copy link
Owner

stianhoiland commented Oct 4, 2025

Proper DPI scaling support added in a7972f9. Thanks for kicking things off and documenting issues that needed addressing. Finally closing this now :)

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.

Very blurry with screen scaling

2 participants