* Source/x11/XGServerWindow.m (screenList): revert back to old code

logic: if XRandR available but can't get screens info for some reasons,
  return array with one element (Xlib screen info).
This commit is contained in:
Sergii Stoian 2020-02-12 00:35:45 +02:00
parent 6923a62820
commit 00a79638cf

View file

@ -4448,6 +4448,9 @@ _computeDepth(int class, int bpp)
We map XRandR monitors (outputs) to NSScreen. */ We map XRandR monitors (outputs) to NSScreen. */
- (NSArray *)screenList - (NSArray *)screenList
{ {
NSMutableArray *tmpScreens;
NSArray *screens;
monitorsCount = 0; monitorsCount = 0;
if (monitors != NULL) { if (monitors != NULL) {
NSZoneFree([self zone], monitors); NSZoneFree([self zone], monitors);
@ -4462,7 +4465,6 @@ _computeDepth(int class, int bpp)
if (screen_res != NULL) if (screen_res != NULL)
{ {
RROutput primary_output; RROutput primary_output;
NSMutableArray *tmpScreens;
int i; int i;
int mi; int mi;
int xScreenHeight = DisplayHeight(dpy, defScreen); int xScreenHeight = DisplayHeight(dpy, defScreen);
@ -4509,22 +4511,27 @@ _computeDepth(int class, int bpp)
XRRFreeOutputInfo(output_info); XRRFreeOutputInfo(output_info);
} }
XRRFreeScreenResources(screen_res); XRRFreeScreenResources(screen_res);
return [NSArray arrayWithArray: tmpScreens]; screens = [NSArray arrayWithArray: tmpScreens];
} }
#endif #endif
/* It is assumed that there is always only one screen per application. /* 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 We only need to know its number and it was saved in _initXContext as
`defScreen`. */ `defScreen`. */
monitorsCount = 1; if (monitorsCount == 0)
monitors = NSZoneMalloc([self zone], sizeof(MonitorDevice)); {
monitors[0].screen_id = defScreen; monitorsCount = 1;
monitors[0].depth = [self windowDepthForScreen: 0]; monitors = NSZoneMalloc([self zone], sizeof(MonitorDevice));
monitors[0].resolution = [self resolutionForScreen: defScreen]; monitors[0].screen_id = defScreen;
monitors[0].frame = NSMakeRect(0, 0, monitors[0].depth = [self windowDepthForScreen: 0];
DisplayWidth(dpy, defScreen), monitors[0].resolution = [self resolutionForScreen: defScreen];
DisplayHeight(dpy, defScreen)); monitors[0].frame = NSMakeRect(0, 0,
return [NSArray arrayWithObject: [NSNumber numberWithInt: 0]]; DisplayWidth(dpy, defScreen),
DisplayHeight(dpy, defScreen));
screens = [NSArray arrayWithObject: [NSNumber numberWithInt: defScreen]];
}
return screens;
} }
// `screen` is a monitor index not X11 screen // `screen` is a monitor index not X11 screen