mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-24 12:21:34 +00:00
* Source/x11/XGServerWindow.m (screenList): Clean up implementation.
This commit is contained in:
parent
74bab329ba
commit
f9d3dd7f96
2 changed files with 32 additions and 29 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2020-02-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/x11/XGServerWindow.m (screenList): Clean up implementation.
|
||||||
|
|
||||||
2020-02-07 Sergii Stoian <stoyan255@gmail.com>
|
2020-02-07 Sergii Stoian <stoyan255@gmail.com>
|
||||||
|
|
||||||
* Source/x11/XGServerWindow.m (_XFrameToOSFrame:for:): use Xlib
|
* Source/x11/XGServerWindow.m (_XFrameToOSFrame:for:): use Xlib
|
||||||
|
|
|
@ -4448,10 +4448,6 @@ _computeDepth(int class, int bpp)
|
||||||
We map XRandR monitors (outputs) to NSScreen. */
|
We map XRandR monitors (outputs) to NSScreen. */
|
||||||
- (NSArray *)screenList
|
- (NSArray *)screenList
|
||||||
{
|
{
|
||||||
NSArray *screens;
|
|
||||||
NSMutableArray *tmpScreens;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
monitorsCount = 0;
|
monitorsCount = 0;
|
||||||
if (monitors != NULL) {
|
if (monitors != NULL) {
|
||||||
NSZoneFree([self zone], monitors);
|
NSZoneFree([self zone], monitors);
|
||||||
|
@ -4460,24 +4456,30 @@ _computeDepth(int class, int bpp)
|
||||||
|
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
XRRScreenResources *screen_res;
|
XRRScreenResources *screen_res;
|
||||||
RROutput primary_output;
|
Window root = [self xDisplayRootWindow];
|
||||||
XRROutputInfo *output_info;
|
|
||||||
XRRCrtcInfo *crtc_info;
|
|
||||||
int mi;
|
|
||||||
|
|
||||||
screen_res = XRRGetScreenResources(dpy, RootWindow(dpy, defScreen));
|
screen_res = XRRGetScreenResources(dpy, root);
|
||||||
if (screen_res != NULL)
|
if (screen_res != NULL)
|
||||||
{
|
{
|
||||||
|
RROutput primary_output;
|
||||||
|
NSMutableArray *tmpScreens;
|
||||||
|
int i;
|
||||||
|
int mi;
|
||||||
|
|
||||||
monitorsCount = screen_res->noutput;
|
monitorsCount = screen_res->noutput;
|
||||||
tmpScreens = [NSMutableArray arrayWithCapacity: monitorsCount];
|
tmpScreens = [NSMutableArray arrayWithCapacity: monitorsCount];
|
||||||
monitors = NSZoneMalloc([self zone], monitorsCount * sizeof(MonitorDevice));
|
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++)
|
for (i = 0, mi = 0; i < screen_res->noutput; i++)
|
||||||
{
|
{
|
||||||
|
XRROutputInfo *output_info;
|
||||||
|
|
||||||
output_info = XRRGetOutputInfo(dpy, screen_res, screen_res->outputs[i]);
|
output_info = XRRGetOutputInfo(dpy, screen_res, screen_res->outputs[i]);
|
||||||
if (output_info->crtc)
|
if (output_info->crtc)
|
||||||
{
|
{
|
||||||
|
XRRCrtcInfo *crtc_info;
|
||||||
|
|
||||||
crtc_info = XRRGetCrtcInfo(dpy, screen_res, output_info->crtc);
|
crtc_info = XRRGetCrtcInfo(dpy, screen_res, output_info->crtc);
|
||||||
|
|
||||||
monitors[mi].screen_id = defScreen;
|
monitors[mi].screen_id = defScreen;
|
||||||
|
@ -4486,7 +4488,7 @@ _computeDepth(int class, int bpp)
|
||||||
monitors[mi].frame = NSMakeRect(crtc_info->x, crtc_info->y,
|
monitors[mi].frame = NSMakeRect(crtc_info->x, crtc_info->y,
|
||||||
crtc_info->width, crtc_info->height);
|
crtc_info->width, crtc_info->height);
|
||||||
/* Add monitor ID (index in monitors array).
|
/* 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. */
|
screen if application has no key window. */
|
||||||
if (screen_res->outputs[i] == primary_output)
|
if (screen_res->outputs[i] == primary_output)
|
||||||
{
|
{
|
||||||
|
@ -4496,16 +4498,16 @@ _computeDepth(int class, int bpp)
|
||||||
{
|
{
|
||||||
[tmpScreens addObject: [NSNumber numberWithInt: mi]];
|
[tmpScreens addObject: [NSNumber numberWithInt: mi]];
|
||||||
}
|
}
|
||||||
|
XRRFreeCrtcInfo(crtc_info);
|
||||||
mi++;
|
mi++;
|
||||||
}
|
}
|
||||||
|
XRRFreeOutputInfo(output_info);
|
||||||
}
|
}
|
||||||
XRRFreeScreenResources(screen_res);
|
XRRFreeScreenResources(screen_res);
|
||||||
screens = [NSArray arrayWithArray: tmpScreens];
|
return [NSArray arrayWithArray: tmpScreens];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (monitorsCount == 0)
|
|
||||||
{
|
|
||||||
/* 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`. */
|
||||||
|
@ -4517,10 +4519,7 @@ _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));
|
||||||
screens = [NSArray arrayWithObject: [NSNumber numberWithInt: defScreen]];
|
return [NSArray arrayWithObject: [NSNumber numberWithInt: 0]];
|
||||||
}
|
|
||||||
|
|
||||||
return screens;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// `screen` is a monitor index not X11 screen
|
// `screen` is a monitor index not X11 screen
|
||||||
|
|
Loading…
Reference in a new issue