* 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. */
- (NSArray *)screenList
{
NSMutableArray *tmpScreens;
NSArray *screens;
monitorsCount = 0;
if (monitors != NULL) {
NSZoneFree([self zone], monitors);
@ -4462,7 +4465,6 @@ _computeDepth(int class, int bpp)
if (screen_res != NULL)
{
RROutput primary_output;
NSMutableArray *tmpScreens;
int i;
int mi;
int xScreenHeight = DisplayHeight(dpy, defScreen);
@ -4509,22 +4511,27 @@ _computeDepth(int class, int bpp)
XRRFreeOutputInfo(output_info);
}
XRRFreeScreenResources(screen_res);
return [NSArray arrayWithArray: tmpScreens];
screens = [NSArray arrayWithArray: tmpScreens];
}
#endif
/* 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]];
if (monitorsCount == 0)
{
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;
}
// `screen` is a monitor index not X11 screen