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
Add an event to detect the screen changes #15637
Labels
Comments
Thank you. This feature is exactly what I need and look forward to adding it. |
Before we get the framework support, we can use this work-around: using var display = XDisplay.Open(0);
var window = XDefaultRootWindow(display);
XSelectInput(display, window, (nint)(ExposureMask | StructureNotifyMask));
while (_isRunning)
{
XNextEvent(display, out var e);
if (e.type is XEventName.ConfigureNotify)
{
var configureEvent = e.ConfigureEvent;
var bounds = new PixelRect(configureEvent.x, configureEvent.y, configureEvent.width, configureEvent.height);
if (bounds != _lastScreenBounds)
{
_lastScreenBounds = bounds;
RaiseScreenChanged(bounds);
}
}
} We'are trying to know the changes of the root window and we assume that the position and the size of it equals to the screen position and size. Just run this code above on a long-running task and we'll get the screen resolution changed event. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
Supposed that we are developing such an app:
Avalonia 11.1.0 now only provide an event of
Window.ScalingChanged
that will be raised when the screen scaling is changed. But if the screen resolution is changed, it provide nothing. So our desktop icon doesn't know when to reposition it.For example, the desktop icon is position at the top-right corner of the screen displaying in 3840x2160 and now the user changes the resolution to 1920x1080, the icon will be out of the screen. (Note: If the window is an override redirect window, the desktop window manager will not reposition it.)
Describe the solution you'd like
Changed
toAvalonia.Controls.Screens
classDescribe alternatives you've considered
X11Properties
class, which is the same as what in theWin32Properties
class.Additional context
The text was updated successfully, but these errors were encountered: