mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-24 04:11:28 +00:00
* Source/x11/XGServerWindow.m (boundsForScreen:): if Xrandr support
enabled get screen dimensions using Xrandr objects. * Source/x11/XGServerEvent.m (processEvent:): process Xrandr event and send NSApplicationDidChangeScreenParametersNotification. * Source/x11/XGServer.m (_initXContext): subscribe to the Xrandr event.
This commit is contained in:
parent
2085ea4a9a
commit
501c6eb018
4 changed files with 76 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2020-01-23 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* Source/x11/XGServerWindow.m (boundsForScreen:): if Xrandr support
|
||||
enabled get screen dimensions using Xrandr objects.
|
||||
|
||||
* Source/x11/XGServerEvent.m (processEvent:): process Xrandr event and
|
||||
send NSApplicationDidChangeScreenParametersNotification.
|
||||
|
||||
* Source/x11/XGServer.m (_initXContext): subscribe to the Xrandr event.
|
||||
|
||||
2020-01-22 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* configure.ac: check for availability of Xrandr library.
|
||||
|
|
|
@ -69,6 +69,10 @@ terminate(int sig)
|
|||
#include "x11/XGOpenGL.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XRANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
|
@ -465,6 +469,15 @@ _parse_display_name(NSString *name, int *dn, int *sn)
|
|||
[self _setupRootWindow];
|
||||
inputServer = [[XIMInputServer allocWithZone: [self zone]]
|
||||
initWithDelegate: nil display: dpy name: @"XIM"];
|
||||
|
||||
#ifdef HAVE_XRANDR
|
||||
int count = ScreenCount(dpy);
|
||||
int i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
XRRSelectInput(dpy, RootWindow(dpy, i), RRScreenChangeNotifyMask);
|
||||
}
|
||||
#endif
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@
|
|||
#else
|
||||
#include "x11/wraster.h"
|
||||
#endif
|
||||
#ifdef HAVE_XRANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
||||
#include "math.h"
|
||||
#include <X11/keysym.h>
|
||||
|
@ -1894,6 +1897,27 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
|
|||
((XShmCompletionEvent *)&xEvent)->drawable];
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_XRANDR
|
||||
if (xEvent.type & RRScreenChangeNotifyMask)
|
||||
{
|
||||
int count = ScreenCount(dpy);
|
||||
int i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (xEvent.xconfigure.window == RootWindow(dpy, i))
|
||||
{
|
||||
NSLog(@"[XGServerEvent] RRScreenChangeNotify for screen %i/%i",
|
||||
i, count);
|
||||
XRRUpdateConfiguration(event);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSApplicationDidChangeScreenParametersNotification
|
||||
object: NSApp];
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
NSLog(@"Received an untrapped event\n");
|
||||
break;
|
||||
|
|
|
@ -66,6 +66,9 @@
|
|||
#if HAVE_XFIXES
|
||||
#include <X11/extensions/Xfixes.h>
|
||||
#endif
|
||||
#ifdef HAVE_XRANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
||||
#include "x11/XGDragView.h"
|
||||
#include "x11/XGInputServer.h"
|
||||
|
@ -4509,13 +4512,32 @@ _computeDepth(int class, int bpp)
|
|||
|
||||
- (NSRect) boundsForScreen: (int)screen
|
||||
{
|
||||
if (screen < 0 || screen >= ScreenCount(dpy))
|
||||
{
|
||||
NSLog(@"Invalidparam: no screen %d", screen);
|
||||
return NSZeroRect;
|
||||
}
|
||||
return NSMakeRect(0, 0, DisplayWidth(dpy, screen),
|
||||
DisplayHeight(dpy, screen));
|
||||
if (screen < 0 || screen >= ScreenCount(dpy))
|
||||
{
|
||||
NSLog(@"Invalidparam: no screen %d", screen);
|
||||
return NSZeroRect;
|
||||
}
|
||||
#ifdef HAVE_XRANDR
|
||||
XRRScreenResources *screen_res;
|
||||
XRROutputInfo *output_info;
|
||||
NSRect boundsRect = {{0,0},{0,0}};
|
||||
screen_res = XRRGetScreenResources(dpy, RootWindow(dpy, screen));
|
||||
output_info = XRRGetOutputInfo(dpy, screen_res, screen_res->outputs[0]);
|
||||
if (output_info->crtc)
|
||||
{
|
||||
XRRCrtcInfo *crtc_info;
|
||||
crtc_info = XRRGetCrtcInfo(dpy, screen_res, output_info->crtc);
|
||||
NSLog(@"Screen bounds: %i,%i %ux%u",
|
||||
crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height);
|
||||
boundsRect = NSMakeRect(crtc_info->x, crtc_info->y,
|
||||
crtc_info->width, crtc_info->height);
|
||||
}
|
||||
XRRFreeScreenResources(screen_res);
|
||||
return boundsRect;
|
||||
#else
|
||||
return NSMakeRect(0, 0, DisplayWidth(dpy, screen),
|
||||
DisplayHeight(dpy, screen));
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSImage *) iconTileImage
|
||||
|
|
Loading…
Reference in a new issue