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

x11: reload dpi on PropertyChangeEvent #2874

Closed
wants to merge 1 commit into from

Conversation

frebib
Copy link

@frebib frebib commented Jun 11, 2023

This change allows X11 windows to receive ScaleFactorChanged events when using Xft.dpi via the root window PropertyChange event.

Subscribe to PropertyChange events on the root window, and reload all available monitors when an XA_RESOURCE_MANAGER change is received. This is a very heavy handed approach to this problem, but it was the least intrustive way I could find to make it work with my limited skill. Load XResources directly via XGetTextProperty on every get_xft_dpi call as XResourceManagerString returns stale cached data and does not reload for the lifetime of the window (?)

Fixes: #1228

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

Full disclosure- I have no idea what I'm doing. This has worked for me for the past few years with no issues, but the code is probably bad. I've never written Rust in my life, but I figured this was a starting point

@frebib frebib requested a review from kchibisov as a code owner June 11, 2023 20:48
@frebib frebib force-pushed the x11-dpi-reload branch 4 times, most recently from 95b5d9a to 7f5df6f Compare July 18, 2023 22:02
This change allows X11 windows to receive ScaleFactorChanged events when
using Xft.dpi via the root window PropertyChange event.

Subscribe to PropertyChange events on the root window, and reload all
available monitors when an XA_RESOURCE_MANAGER change is received. This
is a very heavy handed approach to this problem, but it was the least
intrustive way I could find to make it work with my limited skill. Load
XResources directly via XGetTextProperty on every get_xft_dpi call as
XResourceManagerString returns stale cached data and does not reload for
the lifetime of the window (?)

Fixes: rust-windowing#1228
Signed-off-by: Joe Groocock <[email protected]>
@notgull
Copy link
Member

notgull commented Jul 19, 2023

I can rewrite this for the new XCB backend if needed.

@frebib
Copy link
Author

frebib commented Jul 19, 2023

@notgull that would be amazing if you could 😍 this was only ever a hack anyway

@kchibisov
Copy link
Member

@notgull beep

@notgull notgull mentioned this pull request Nov 12, 2023
5 tasks
notgull added a commit that referenced this pull request Nov 12, 2023
Supersedes #2874, fixes #1228

Signed-off-by: John Nunley <[email protected]>
@frebib frebib requested a review from notgull as a code owner February 27, 2024 19:28
@notgull
Copy link
Member

notgull commented Feb 28, 2024

My bad, I forgot to close this after I merged #3222

@notgull notgull closed this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Allow changing X11 DPI at runtime
4 participants