From b5c563a400bede34ae58e0f72a206432d0452b3b Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Sun, 26 Jan 2020 23:56:00 +0200 Subject: [PATCH] * Source/x11/XGServerWindow.m (boundsForScreen:): use `screen` variable to identify output in RandR screen resources. Use `boundsRect` local variable as return vaalue storage. Cleanup. --- ChangeLog | 4 ++++ Source/x11/XGServerWindow.m | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c97f0e..a86c2ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2020-01-26 Sergii Stoian + * Source/x11/XGServerWindow.m (boundsForScreen:): use `screen` variable + to identify output in RandR screen resources. Use `boundsRect` local + variable as return vaalue storage. Cleanup. + * Source/x11/XGServerEvent.m (processEvent:), * Source/x11/XGServer.m (_initXContext): catch and process RandR event on default screen. diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index cb3dd87..0d5138f 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -4512,32 +4512,33 @@ _computeDepth(int class, int bpp) - (NSRect) boundsForScreen: (int)screen { + NSRect boundsRect = {{0,0},{0,0}}; + if (screen < 0 || screen >= ScreenCount(dpy)) { NSLog(@"Invalidparam: no screen %d", screen); return NSZeroRect; } + #ifdef HAVE_XRANDR XRRScreenResources *screen_res; XRROutputInfo *output_info; - NSRect boundsRect = {{0,0},{0,0}}; screen_res = XRRGetScreenResources(dpy, RootWindow(dpy, screen)); - output_info = XRRGetOutputInfo(dpy, screen_res, screen_res->outputs[0]); + output_info = XRRGetOutputInfo(dpy, screen_res, screen_res->outputs[screen]); if (output_info->crtc) { 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); boundsRect = NSMakeRect(crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); } XRRFreeScreenResources(screen_res); - return boundsRect; #else - return NSMakeRect(0, 0, DisplayWidth(dpy, screen), - DisplayHeight(dpy, screen)); + boundsRect = NSMakeRect(0, 0, DisplayWidth(dpy, screen), + DisplayHeight(dpy, screen)); #endif + + return boundsRect; } - (NSImage *) iconTileImage