* Source/x11/XGServerEvent.m (processEvent:),

* Source/x11/XGServer.m (_initXContext): catch and process RandR event
  on default screen.
This commit is contained in:
Sergii Stoian 2020-01-26 02:55:34 +02:00
parent 7f24ad7d89
commit 78a5f6a380
3 changed files with 19 additions and 27 deletions

View file

@ -1,3 +1,9 @@
2020-01-26 Sergii Stoian <stoyan255@gmail.com>
* Source/x11/XGServerEvent.m (processEvent:),
* Source/x11/XGServer.m (_initXContext): catch and process RandR event
on default screen.
2020-01-24 Sergii Stoian <stoyan255@gmail.com>
* Source/x11/XGServerWindow.m (_OSFrameToXFrame:for:): use

View file

@ -471,13 +471,8 @@ _parse_display_name(NSString *name, int *dn, int *sn)
initWithDelegate: nil display: dpy name: @"XIM"];
#ifdef HAVE_XRANDR
int count = ScreenCount(dpy);
int i;
for (i = 0; i < count; i++)
{
XRRQueryExtension(dpy, &randrEventBase, &randrErrorBase);
XRRSelectInput(dpy, RootWindow(dpy, i), RRScreenChangeNotifyMask);
}
XRRQueryExtension(dpy, &randrEventBase, &randrErrorBase);
XRRSelectInput(dpy, RootWindow(dpy, defScreen), RRScreenChangeNotifyMask);
#endif
return self;
}

View file

@ -1901,31 +1901,22 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
#endif
#ifdef HAVE_XRANDR
int randr_event_type = randrEventBase + RRScreenChangeNotify;
if (xEvent.type == randr_event_type)
if (xEvent.type == randr_event_type
&& (xEvent.xconfigure.window == RootWindow(dpy, defScreen)))
{
int count = ScreenCount(dpy), i;
for (i = 0; i < count; i++)
{
if (xEvent.xconfigure.window == RootWindow(dpy, i))
{
NSLog(@"[XGServerEvent] RRScreenChangeNotify for screen %i/%i",
i, count);
// Check if other RandR events are waiting in the queue.
XSync(dpy,0);
while (XCheckTypedEvent(dpy, randr_event_type, &xEvent)) {;}
// Check if other RandR events are waiting in the queue.
XSync(dpy,0);
while (XCheckTypedEvent(dpy, randr_event_type, &xEvent)) {;}
XRRUpdateConfiguration(event);
// Regenerate NSScreens
[NSScreen resetScreens];
// Notify application about screen parameters change
[[NSNotificationCenter defaultCenter]
XRRUpdateConfiguration(event);
// Regenerate NSScreens
[NSScreen resetScreens];
// Notify application about screen parameters change
[[NSNotificationCenter defaultCenter]
postNotificationName: NSApplicationDidChangeScreenParametersNotification
object: NSApp];
break;
}
}
break;
}
break;
#endif
NSLog(@"Received an untrapped event\n");
break;