* Headers/x11/XGServer.h (GSDisplayServer): RandR event and error base

ivars were added.
* Source/x11/XGServer.m (_initXContext): get RandR event and error base.
* Source/x11/XGServerEvent.m (processEvent:): pack several RandR events
  into one notification post.
This commit is contained in:
Sergii Stoian 2020-01-23 19:03:34 +02:00
parent 501c6eb018
commit 64335397b5
4 changed files with 12 additions and 5 deletions

View file

@ -1,11 +1,12 @@
2020-01-23 Sergii Stoian <stoyan255@gmail.com>
* Headers/x11/XGServer.h (GSDisplayServer): RandR event and error base
ivars were added.
* Source/x11/XGServer.m (_initXContext): get RandR event and error base.
* Source/x11/XGServerWindow.m (boundsForScreen:): if Xrandr support
enabled get screen dimensions using Xrandr objects.
* Source/x11/XGServerEvent.m (processEvent:): process Xrandr event and
send NSApplicationDidChangeScreenParametersNotification.
* Source/x11/XGServer.m (_initXContext): subscribe to the Xrandr event.
2020-01-22 Sergii Stoian <stoyan255@gmail.com>

View file

@ -60,6 +60,7 @@ typedef enum {
Window grabWindow;
struct XGGeneric generic;
id inputServer;
int randrEventBase, randrErrorBase;
}
+ (Display*) currentXDisplay;

View file

@ -475,6 +475,7 @@ _parse_display_name(NSString *name, int *dn, int *sn)
int i;
for (i = 0; i < count; i++)
{
XRRQueryExtension(dpy, &randrEventBase, &randrErrorBase);
XRRSelectInput(dpy, RootWindow(dpy, i), RRScreenChangeNotifyMask);
}
#endif

View file

@ -1899,16 +1899,20 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
}
#endif
#ifdef HAVE_XRANDR
if (xEvent.type & RRScreenChangeNotifyMask)
int randr_event_type = randrEventBase + RRScreenChangeNotify;
if (xEvent.type == randr_event_type)
{
int count = ScreenCount(dpy);
int i;
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)) {;}
XRRUpdateConfiguration(event);
[[NSNotificationCenter defaultCenter]
postNotificationName: NSApplicationDidChangeScreenParametersNotification