* Headers/x11/XGServer.h (GSDisplayServer): added new ivar xScreenSize

to hold Xlib screen size dimensions.

* Source/x11/XGServerWindow.m: 
  (_OSFrameToXFrame:for:): use xScreenSize instead of DisplayHeight.
  (_OSFrameToXHints:for:): ditto.
  (_XFrameToOSFrame:for:): ditto.
  (movewindow::): ditto.
  (_screenSize): new static function to get dimensions of Xlib screen from
  root window.
  (screenList): use xScreenSize instead of DisplayHeight/DisplayWidth.
This commit is contained in:
Sergii Stoian 2020-02-20 19:13:06 +02:00
parent bf2b88f16e
commit 638940fb28
3 changed files with 49 additions and 15 deletions

View file

@ -1,3 +1,17 @@
2020-02-20 Sergii Stoian <stoyan255@gmail.com>
* Headers/x11/XGServer.h (GSDisplayServer): added new ivar xScreenSize
to hold Xlib screen size dimensions.
* Source/x11/XGServerWindow.m:
(_OSFrameToXFrame:for:): use xScreenSize instead of DisplayHeight.
(_OSFrameToXHints:for:): ditto.
(_XFrameToOSFrame:for:): ditto.
(movewindow::): ditto.
(_screenSize): new static function to get dimensions of Xlib screen from
root window.
(screenList): use xScreenSize instead of DisplayHeight/DisplayWidth.
2020-02-14 Fred Kiefer <FredKiefer@gmx.de> 2020-02-14 Fred Kiefer <FredKiefer@gmx.de>
* Source/x11/XGServerWindow.m (screenList): Clean up * Source/x11/XGServerWindow.m (screenList): Clean up

View file

@ -63,6 +63,7 @@ typedef struct MonitorDevice {
{ {
Display *dpy; Display *dpy;
int defScreen; int defScreen;
NSSize xScreenSize;
NSMapTable *screenList; NSMapTable *screenList;
Window grabWindow; Window grabWindow;
struct XGGeneric generic; struct XGGeneric generic;

View file

@ -92,7 +92,6 @@ static NSMapTable *windowtags = NULL;
/* Track used window numbers */ /* Track used window numbers */
static int last_win_num = 0; static int last_win_num = 0;
@interface NSCursor (BackendPrivate) @interface NSCursor (BackendPrivate)
- (void *)_cid; - (void *)_cid;
@end @end
@ -509,7 +508,7 @@ BOOL AtomPresentAndPointsToItself(Display *dpy, Atom atom, Atom type)
x.size.height = o.size.height - t - b; x.size.height = o.size.height - t - b;
x.origin.x = o.origin.x + l; x.origin.x = o.origin.x + l;
x.origin.y = o.origin.y + o.size.height - t; x.origin.y = o.origin.y + o.size.height - t;
x.origin.y = DisplayHeight(dpy, defScreen) - x.origin.y; x.origin.y = xScreenSize.height - x.origin.y;
NSDebugLLog(@"Frame", @"O2X %lu, %x, %@, %@", win->number, style, NSDebugLLog(@"Frame", @"O2X %lu, %x, %@, %@", win->number, style,
NSStringFromRect(o), NSStringFromRect(x)); NSStringFromRect(o), NSStringFromRect(x));
return x; return x;
@ -534,7 +533,7 @@ BOOL AtomPresentAndPointsToItself(Display *dpy, Atom atom, Atom type)
x.size.height = o.size.height - t - b; x.size.height = o.size.height - t - b;
x.origin.x = o.origin.x; x.origin.x = o.origin.x;
x.origin.y = o.origin.y + o.size.height; x.origin.y = o.origin.y + o.size.height;
x.origin.y = DisplayHeight(dpy, defScreen) - x.origin.y; x.origin.y = xScreenSize.height - x.origin.y;
NSDebugLLog(@"Frame", @"O2H %lu, %x, %@, %@", win->number, style, NSDebugLLog(@"Frame", @"O2H %lu, %x, %@, %@", win->number, style,
NSStringFromRect(o), NSStringFromRect(x)); NSStringFromRect(o), NSStringFromRect(x));
return x; return x;
@ -576,7 +575,7 @@ BOOL AtomPresentAndPointsToItself(Display *dpy, Atom atom, Atom type)
[self styleoffsets: &l : &r : &t : &b : style : win->ident]; [self styleoffsets: &l : &r : &t : &b : style : win->ident];
o = x; o = x;
o.origin.y = DisplayHeight(dpy, defScreen) - x.origin.y; o.origin.y = xScreenSize.height - x.origin.y;
o.origin.y = o.origin.y - x.size.height - b; o.origin.y = o.origin.y - x.size.height - b;
o.origin.x -= l; o.origin.x -= l;
o.size.width += l + r; o.size.width += l + r;
@ -3192,8 +3191,8 @@ swapColors(unsigned char *image_data, NSBitmapImageRep *rep)
} }
window->siz_hints.x = (int)loc.x; window->siz_hints.x = (int)loc.x;
window->siz_hints.y = (int)(DisplayHeight(dpy, defScreen) - window->siz_hints.y = (int)(xScreenSize.height
loc.y - window->siz_hints.height); - loc.y - window->siz_hints.height);
XMoveWindow (dpy, window->ident, window->siz_hints.x, window->siz_hints.y); XMoveWindow (dpy, window->ident, window->siz_hints.x, window->siz_hints.y);
setNormalHints(dpy, window); setNormalHints(dpy, window);
} }
@ -4436,6 +4435,27 @@ _computeDepth(int class, int bpp)
return depth; return depth;
} }
static NSSize
_screenSize(Display *dpy, int screen)
{
int x, y;
unsigned int width, height, border_width, depth;
Window root_window;
NSSize scrSize;
XGetGeometry(dpy, RootWindow(dpy, screen), &root_window,
&x, &y, &width, &height, &border_width, &depth);
scrSize = NSMakeSize(width, height);
if (scrSize.height == 0)
scrSize.height = DisplayHeight(dpy, screen);
if (scrSize.width == 0)
scrSize.width = DisplayWidth(dpy, screen);
return scrSize;
}
/* This method assumes that we deal with one X11 screen - `defScreen`. /* This method assumes that we deal with one X11 screen - `defScreen`.
Basically it means that we have DISPLAY variable set to `:0.0`. Basically it means that we have DISPLAY variable set to `:0.0`.
Where both digits have artbitrary values, but it defines once on Where both digits have artbitrary values, but it defines once on
@ -4448,8 +4468,8 @@ _computeDepth(int class, int bpp)
We map XRandR monitors (outputs) to NSScreen. */ We map XRandR monitors (outputs) to NSScreen. */
- (NSArray *)screenList - (NSArray *)screenList
{ {
int xScreenHeight = DisplayHeight(dpy, defScreen); xScreenSize = _screenSize(dpy, defScreen);
monitorsCount = 0; monitorsCount = 0;
if (monitors != NULL) { if (monitors != NULL) {
NSZoneFree([self zone], monitors); NSZoneFree([self zone], monitors);
@ -4488,10 +4508,11 @@ _computeDepth(int class, int bpp)
monitors[mi].resolution = [self resolutionForScreen: defScreen]; monitors[mi].resolution = [self resolutionForScreen: defScreen];
/* Transform coordinates from Xlib (flipped) to OpenStep (unflippped). /* Transform coordinates from Xlib (flipped) to OpenStep (unflippped).
Windows and screens should have the same coordinate system. */ Windows and screens should have the same coordinate system. */
monitors[mi].frame = NSMakeRect(crtc_info->x, monitors[mi].frame =
xScreenHeight - crtc_info->height - crtc_info->y, NSMakeRect(crtc_info->x,
crtc_info->width, xScreenSize.height - crtc_info->height - crtc_info->y,
crtc_info->height); crtc_info->width,
crtc_info->height);
/* Add monitor ID (index in monitors array). /* Add monitor ID (index in monitors array).
Put primary monitor ID at index 0 since NSScreen get this as main Put primary monitor ID at index 0 since NSScreen get this as main
screen if application has no key window. */ screen if application has no key window. */
@ -4533,9 +4554,7 @@ _computeDepth(int class, int bpp)
monitors[0].screen_id = defScreen; monitors[0].screen_id = defScreen;
monitors[0].depth = [self windowDepthForScreen: 0]; monitors[0].depth = [self windowDepthForScreen: 0];
monitors[0].resolution = [self resolutionForScreen: defScreen]; monitors[0].resolution = [self resolutionForScreen: defScreen];
monitors[0].frame = NSMakeRect(0, 0, monitors[0].frame = NSMakeRect(0, 0, xScreenSize.width, xScreenSize.height);
DisplayWidth(dpy, defScreen),
xScreenHeight);
return [NSArray arrayWithObject: [NSNumber numberWithInt: defScreen]]; return [NSArray arrayWithObject: [NSNumber numberWithInt: defScreen]];
} }