From f9d3dd7f96e4e9b7d7a43d7a67cdad03a207d1b1 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Sat, 8 Feb 2020 13:35:43 +0100 Subject: [PATCH 1/2] * Source/x11/XGServerWindow.m (screenList): Clean up implementation. --- ChangeLog | 4 +++ Source/x11/XGServerWindow.m | 57 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index e85f614..5d5857a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-02-08 Fred Kiefer + + * Source/x11/XGServerWindow.m (screenList): Clean up implementation. + 2020-02-07 Sergii Stoian * Source/x11/XGServerWindow.m (_XFrameToOSFrame:for:): use Xlib diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 3a18c1b..bca4123 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -4448,10 +4448,6 @@ _computeDepth(int class, int bpp) We map XRandR monitors (outputs) to NSScreen. */ - (NSArray *)screenList { - NSArray *screens; - NSMutableArray *tmpScreens; - int i; - monitorsCount = 0; if (monitors != NULL) { NSZoneFree([self zone], monitors); @@ -4460,24 +4456,30 @@ _computeDepth(int class, int bpp) #ifdef HAVE_XRANDR XRRScreenResources *screen_res; - RROutput primary_output; - XRROutputInfo *output_info; - XRRCrtcInfo *crtc_info; - int mi; + Window root = [self xDisplayRootWindow]; - screen_res = XRRGetScreenResources(dpy, RootWindow(dpy, defScreen)); + screen_res = XRRGetScreenResources(dpy, root); if (screen_res != NULL) { + RROutput primary_output; + NSMutableArray *tmpScreens; + int i; + int mi; + monitorsCount = screen_res->noutput; tmpScreens = [NSMutableArray arrayWithCapacity: monitorsCount]; monitors = NSZoneMalloc([self zone], monitorsCount * sizeof(MonitorDevice)); + primary_output = XRRGetOutputPrimary(dpy, root); - primary_output = XRRGetOutputPrimary(dpy, [self xDisplayRootWindow]); for (i = 0, mi = 0; i < screen_res->noutput; i++) { + XRROutputInfo *output_info; + output_info = XRRGetOutputInfo(dpy, screen_res, screen_res->outputs[i]); if (output_info->crtc) { + XRRCrtcInfo *crtc_info; + crtc_info = XRRGetCrtcInfo(dpy, screen_res, output_info->crtc); monitors[mi].screen_id = defScreen; @@ -4486,7 +4488,7 @@ _computeDepth(int class, int bpp) monitors[mi].frame = NSMakeRect(crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); /* Add monitor ID (index in monitors array). - Put primary monitor ID 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. */ if (screen_res->outputs[i] == primary_output) { @@ -4496,31 +4498,28 @@ _computeDepth(int class, int bpp) { [tmpScreens addObject: [NSNumber numberWithInt: mi]]; } + XRRFreeCrtcInfo(crtc_info); mi++; } + XRRFreeOutputInfo(output_info); } XRRFreeScreenResources(screen_res); - screens = [NSArray arrayWithArray: tmpScreens]; + return [NSArray arrayWithArray: tmpScreens]; } #endif - if (monitorsCount == 0) - { - /* It is assumed that there is always only one screen per application. - We only need to know its number and it was saved in _initXContext as - `defScreen`. */ - monitorsCount = 1; - monitors = NSZoneMalloc([self zone], sizeof(MonitorDevice)); - monitors[0].screen_id = defScreen; - monitors[0].depth = [self windowDepthForScreen: 0]; - monitors[0].resolution = [self resolutionForScreen: defScreen]; - monitors[0].frame = NSMakeRect(0, 0, - DisplayWidth(dpy, defScreen), - DisplayHeight(dpy, defScreen)); - screens = [NSArray arrayWithObject: [NSNumber numberWithInt: defScreen]]; - } - - return screens; + /* It is assumed that there is always only one screen per application. + We only need to know its number and it was saved in _initXContext as + `defScreen`. */ + monitorsCount = 1; + monitors = NSZoneMalloc([self zone], sizeof(MonitorDevice)); + monitors[0].screen_id = defScreen; + monitors[0].depth = [self windowDepthForScreen: 0]; + monitors[0].resolution = [self resolutionForScreen: defScreen]; + monitors[0].frame = NSMakeRect(0, 0, + DisplayWidth(dpy, defScreen), + DisplayHeight(dpy, defScreen)); + return [NSArray arrayWithObject: [NSNumber numberWithInt: 0]]; } // `screen` is a monitor index not X11 screen From 2c99cfc73052e5d88e5806f31233a4a6705130cf Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Sat, 8 Feb 2020 21:30:54 +0100 Subject: [PATCH 2/2] Fixes after Xrandr change to get xlib backend to compile again. --- ChangeLog | 10 ++++++++++ Source/xlib/GSXftFontInfo.m | 20 ++++++++++---------- Source/xlib/XGFont.m | 4 ++-- Source/xlib/XGFontManager.m | 2 +- Source/xlib/XGFontSetFontInfo.m | 2 +- Source/xlib/XGGState.m | 4 ++-- Source/xlib/XGGeometry.m | 2 +- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d5857a..f14eb8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2020-02-08 Fred Kiefer + + * Source/xlib/GSXftFontInfo.m, + * Source/xlib/XGFont.m, + * Source/xlib/XGFontManager.m, + * Source/xlib/XGFontSetFontInfo.m, + * Source/xlib/XGGState.m, + * Source/xlib/XGGeometry.m : Fixes after Xrandr change to get xlib + backend to compile again. + 2020-02-08 Fred Kiefer * Source/x11/XGServerWindow.m (screenList): Clean up implementation. diff --git a/Source/xlib/GSXftFontInfo.m b/Source/xlib/GSXftFontInfo.m index 8253fce..fe88d65 100644 --- a/Source/xlib/GSXftFontInfo.m +++ b/Source/xlib/GSXftFontInfo.m @@ -102,7 +102,7 @@ - (void) dealloc { if (font_info != NULL) - XftFontClose([XGServer currentXDisplay], (XftFont *)font_info); + XftFontClose([XGServer xDisplay], (XftFont *)font_info); [super dealloc]; } @@ -113,7 +113,7 @@ XftChar16 str[len]; [string getCharacters: (unichar*)str]; - XftTextExtents16 ([XGServer currentXDisplay], + XftTextExtents16 ([XGServer xDisplay], font_info, str, len, @@ -133,7 +133,7 @@ buf[i] = glyphs[i]; } - XftTextExtents16 ([XGServer currentXDisplay], + XftTextExtents16 ([XGServer xDisplay], font_info, buf, len, @@ -193,7 +193,7 @@ - (BOOL) glyphIsEncoded: (NSGlyph)glyph { - return XftGlyphExists([XGServer currentXDisplay], + return XftGlyphExists([XGServer xDisplay], (XftFont *)font_info, glyph); } @@ -229,7 +229,7 @@ /* - (CGFloat) pointSize { - Display *xdpy = [XGServer currentXDisplay]; + Display *xdpy = [XGServer xDisplay]; return XGFontPointSize(xdpy, font_info); } @@ -302,14 +302,14 @@ #ifdef HAVE_UTF8 if (mostCompatibleStringEncoding == NSUTF8StringEncoding) - XftTextExtentsUtf8([XGServer currentXDisplay], + XftTextExtentsUtf8([XGServer xDisplay], font_info, (XftChar8 *)s, len, &extents); else #endif - XftTextExtents8([XGServer currentXDisplay], + XftTextExtents8([XGServer xDisplay], font_info, (XftChar8*)s, len, @@ -438,7 +438,7 @@ static FT_Outline_Funcs bezierpath_funcs = { glyph = glyphs[i]; // FIXME: Should do this conversion in the glyph creation! - glyph = XftCharIndex([XGServer currentXDisplay], + glyph = XftCharIndex([XGServer xDisplay], (XftFont *)font_info, glyph); if (FT_Load_Glyph(face, glyph, load_flags)) @@ -477,7 +477,7 @@ static FT_Outline_Funcs bezierpath_funcs = { - (BOOL) setupAttributes { - Display *xdpy = [XGServer currentXDisplay]; + Display *xdpy = [XGServer xDisplay]; int defaultScreen = DefaultScreen(xdpy); GSXftFaceInfo *realFont = [GSXftFontEnumerator fontWithName: fontName]; @@ -547,7 +547,7 @@ static FT_Outline_Funcs bezierpath_funcs = { { static XGlyphInfo glyphInfo; - XftTextExtents32 ([XGServer currentXDisplay], + XftTextExtents32 ([XGServer xDisplay], (XftFont *)font_info, &glyph, 1, diff --git a/Source/xlib/XGFont.m b/Source/xlib/XGFont.m index 6af8da3..728781b 100644 --- a/Source/xlib/XGFont.m +++ b/Source/xlib/XGFont.m @@ -129,7 +129,7 @@ static BOOL XGInitAtoms(Display *dpy) { if (font_info != NULL) { - XFreeFont([XGServer currentXDisplay], font_info); + XFreeFont([XGServer xDisplay], font_info); } [super dealloc]; } @@ -272,7 +272,7 @@ static BOOL XGInitAtoms(Display *dpy) - (BOOL) setupAttributes { - Display *xdpy = [XGServer currentXDisplay]; + Display *xdpy = [XGServer xDisplay]; NSString *reg; long height; NSString *xfontname; diff --git a/Source/xlib/XGFontManager.m b/Source/xlib/XGFontManager.m index 4b0fee6..1b23875 100644 --- a/Source/xlib/XGFontManager.m +++ b/Source/xlib/XGFontManager.m @@ -80,7 +80,7 @@ cache_name() { NSFileManager *mgr; BOOL flag; - Display *dpy = [XGServer currentXDisplay]; + Display *dpy = [XGServer xDisplay]; NSString *file_name; NSArray *paths; NSString *path = nil; diff --git a/Source/xlib/XGFontSetFontInfo.m b/Source/xlib/XGFontSetFontInfo.m index cb25eeb..39522cb 100644 --- a/Source/xlib/XGFontSetFontInfo.m +++ b/Source/xlib/XGFontSetFontInfo.m @@ -32,7 +32,7 @@ #ifdef X_HAVE_UTF8_STRING -#define XSERVER [XGServer currentXDisplay] +#define XSERVER [XGServer xDisplay] typedef struct _UTF8Str { char *data; diff --git a/Source/xlib/XGGState.m b/Source/xlib/XGGState.m index 33d7159..b646b7a 100644 --- a/Source/xlib/XGGState.m +++ b/Source/xlib/XGGState.m @@ -186,8 +186,8 @@ static Region emptyRegion; /* We know the current server sent us this */ srv = (XGServer *)GSCurrentServer(); - context = [srv xrContextForScreen: gs_win->screen]; - drawMechanism = [srv drawMechanismForScreen: gs_win->screen]; + context = [srv screenRContext]; + drawMechanism = [srv screenDrawMechanism]; if (gs_win != NULL && gs_win->alpha_buffer != 0) { diff --git a/Source/xlib/XGGeometry.m b/Source/xlib/XGGeometry.m index 47a1a28..055154b 100644 --- a/Source/xlib/XGGeometry.m +++ b/Source/xlib/XGGeometry.m @@ -46,7 +46,7 @@ XRectangle accessibleRectForWindow (gswindow_device_t* win) { - Display* xdpy = [XGServer currentXDisplay]; + Display* xdpy = [XGServer xDisplay]; Window root; Window ignoreWindow; int x, y;