diff --git a/ChangeLog b/ChangeLog index ac4b3bd..45a94d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2020-01-24 Sergii Stoian + + * Source/x11/XGServerWindow.m (_OSFrameToXFrame:for:): use + -boundsForScreen: to get correct screen dimensions if RandR is supported. + (_OSFrameToXHints:for:): ditto. + (_XFrameToOSFrame:for:): ditto. + (movewindow::): ditto. + (windowbounds:): ditto. + (setMouseLocation:onScreen:): ditto. + * Source/x11/XGDragView.m: ditto. + + * Source/x11/XGServerEvent.m (processEvent:): destroy NSScreen screens + list to be regenereated on next call. This change updates ivars of + NSScreen (_frame, _depth) by recreating NSScreen instances. + (mouseLocationOnScreen:window:): use -boundsForScreen: to get correct + screen dimensions if RandR is supported. + 2020-01-23 Sergii Stoian * Headers/x11/XGServer.h (GSDisplayServer): RandR event and error base diff --git a/Source/x11/XGDragView.m b/Source/x11/XGDragView.m index 2e6fd2b..ffe44aa 100644 --- a/Source/x11/XGDragView.m +++ b/Source/x11/XGDragView.m @@ -54,7 +54,7 @@ #define DRAGWINDEV [XGServer _windowWithTag: [_window windowNumber]] #define XX(P) (P.x) -#define XY(P) (DisplayHeight(XDPY, DRAGWINDEV->screen) - P.y) +#define XY(P) ([GSCurrentServer() boundsForScreen: DRAGWINDEV->screen].size.height - P.y) @interface XGRawWindow : NSWindow @end diff --git a/Source/x11/XGServerEvent.m b/Source/x11/XGServerEvent.m index 9ee706d..2584dd2 100644 --- a/Source/x11/XGServerEvent.m +++ b/Source/x11/XGServerEvent.m @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1914,6 +1915,9 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor while (XCheckTypedEvent(dpy, randr_event_type, &xEvent)) {;} XRRUpdateConfiguration(event); + // Regenerate NSScreens + [NSScreen resetScreens]; + // Notify application about screen parameters change [[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationDidChangeScreenParametersNotification object: NSApp]; @@ -2697,7 +2701,7 @@ process_modifier_flags(unsigned int state) height = attribs.height; } else - height = DisplayHeight(dpy, screen_number); + height = [self boundsForScreen: screen_number].size.height; p = NSMakePoint(currentX, height - currentY); if (win) { diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 4991df2..cb3dd87 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -509,7 +509,7 @@ BOOL AtomPresentAndPointsToItself(Display *dpy, Atom atom, Atom type) x.size.height = o.size.height - t - b; x.origin.x = o.origin.x + l; x.origin.y = o.origin.y + o.size.height - t; - x.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y; + x.origin.y = [self boundsForScreen: win->screen].size.height - x.origin.y; NSDebugLLog(@"Frame", @"O2X %lu, %x, %@, %@", win->number, style, NSStringFromRect(o), NSStringFromRect(x)); return x; @@ -534,7 +534,7 @@ BOOL AtomPresentAndPointsToItself(Display *dpy, Atom atom, Atom type) x.size.height = o.size.height - t - b; x.origin.x = o.origin.x; x.origin.y = o.origin.y + o.size.height; - x.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y; + x.origin.y = [self boundsForScreen: win->screen].size.height - x.origin.y; NSDebugLLog(@"Frame", @"O2H %lu, %x, %@, %@", win->number, style, NSStringFromRect(o), NSStringFromRect(x)); return x; @@ -576,7 +576,7 @@ BOOL AtomPresentAndPointsToItself(Display *dpy, Atom atom, Atom type) [self styleoffsets: &l : &r : &t : &b : style : win->ident]; o = x; - o.origin.y = DisplayHeight(dpy, win->screen) - x.origin.y; + o.origin.y = [self boundsForScreen: win->screen].size.height - x.origin.y; o.origin.y = o.origin.y - x.size.height - b; o.origin.x -= l; o.size.width += l + r; @@ -3165,7 +3165,7 @@ swapColors(unsigned char *image_data, int width, int height, } window->siz_hints.x = (int)loc.x; - window->siz_hints.y = (int)(DisplayHeight(dpy, window->screen) - + window->siz_hints.y = (int)([self boundsForScreen: window->screen].size.height - loc.y - window->siz_hints.height); XMoveWindow (dpy, window->ident, window->siz_hints.x, window->siz_hints.y); setNormalHints(dpy, window); @@ -3299,7 +3299,7 @@ swapColors(unsigned char *image_data, int width, int height, &x, &y, &width, &height, &window->border, &window->depth); window->xframe = NSMakeRect(x, y, width, height); - screenHeight = DisplayHeight(dpy, window->screen); + screenHeight = [self boundsForScreen: window->screen].size.height; rect = window->xframe; rect.origin.y = screenHeight - NSMaxY(window->xframe); return rect; @@ -3806,7 +3806,7 @@ swapColors(unsigned char *image_data, int width, int height, int height; int destX, destY; - height = DisplayHeight(dpy, aScreen); + height = [self boundsForScreen: aScreen].size.height; destY = height - mouseLocation.y; destX = mouseLocation.x; @@ -4527,8 +4527,8 @@ _computeDepth(int class, int bpp) { XRRCrtcInfo *crtc_info; crtc_info = XRRGetCrtcInfo(dpy, screen_res, output_info->crtc); - NSLog(@"Screen bounds: %i,%i %ux%u", - crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); + // NSLog(@"Screen bounds: %i,%i %ux%u", + // crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); boundsRect = NSMakeRect(crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); }