* 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,13 +4511,15 @@ _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`. */
if (monitorsCount == 0)
{
monitorsCount = 1; monitorsCount = 1;
monitors = NSZoneMalloc([self zone], sizeof(MonitorDevice)); monitors = NSZoneMalloc([self zone], sizeof(MonitorDevice));
monitors[0].screen_id = defScreen; monitors[0].screen_id = defScreen;
@ -4524,7 +4528,10 @@ _computeDepth(int class, int bpp)
monitors[0].frame = NSMakeRect(0, 0, monitors[0].frame = NSMakeRect(0, 0,
DisplayWidth(dpy, defScreen), DisplayWidth(dpy, defScreen),
DisplayHeight(dpy, defScreen)); DisplayHeight(dpy, defScreen));
return [NSArray arrayWithObject: [NSNumber numberWithInt: 0]]; screens = [NSArray arrayWithObject: [NSNumber numberWithInt: defScreen]];
}
return screens;
} }
// `screen` is a monitor index not X11 screen // `screen` is a monitor index not X11 screen