* 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🪟): use -boundsForScreen: to get correct
screen dimensions if RandR is supported.
This commit is contained in:
Sergii Stoian 2020-01-24 19:43:09 +02:00
parent 64335397b5
commit 7f24ad7d89
4 changed files with 31 additions and 10 deletions

View file

@ -1,3 +1,20 @@
2020-01-24 Sergii Stoian <stoyan255@gmail.com>
* 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 <stoyan255@gmail.com>
* Headers/x11/XGServer.h (GSDisplayServer): RandR event and error base

View file

@ -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

View file

@ -32,6 +32,7 @@
#include <AppKit/NSMenu.h>
#include <AppKit/NSPasteboard.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSScreen.h>
#include <Foundation/NSException.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
@ -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)
{

View file

@ -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);
}