Merge pull request #364 from SteveJones/master
Fix handling of non V1.5 XRandr.
This commit is contained in:
commit
fd81bd1908
@ -22,7 +22,7 @@ pkg_config_packs := dbus-1 \
|
|||||||
pangocairo \
|
pangocairo \
|
||||||
x11 \
|
x11 \
|
||||||
xinerama \
|
xinerama \
|
||||||
xrandr \
|
"xrandr >= 1.5" \
|
||||||
xscrnsaver
|
xscrnsaver
|
||||||
|
|
||||||
# check if we need libxdg-basedir
|
# check if we need libxdg-basedir
|
||||||
|
@ -23,6 +23,11 @@ int screens_len;
|
|||||||
|
|
||||||
bool dunst_follow_errored = false;
|
bool dunst_follow_errored = false;
|
||||||
|
|
||||||
|
int randr_event_base = 0;
|
||||||
|
|
||||||
|
static int randr_major_version = 0;
|
||||||
|
static int randr_minor_version = 0;
|
||||||
|
|
||||||
void randr_init();
|
void randr_init();
|
||||||
void randr_update();
|
void randr_update();
|
||||||
void xinerama_update();
|
void xinerama_update();
|
||||||
@ -80,8 +85,6 @@ void alloc_screen_ar(int n)
|
|||||||
screens_len = n;
|
screens_len = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int randr_event_base = 0;
|
|
||||||
|
|
||||||
void randr_init()
|
void randr_init()
|
||||||
{
|
{
|
||||||
int randr_error_base = 0;
|
int randr_error_base = 0;
|
||||||
@ -89,20 +92,32 @@ void randr_init()
|
|||||||
fprintf(stderr, "Could not initialize the RandR extension, falling back to single monitor mode.\n");
|
fprintf(stderr, "Could not initialize the RandR extension, falling back to single monitor mode.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
XRRQueryVersion(xctx.dpy, &randr_major_version, &randr_minor_version);
|
||||||
XRRSelectInput(xctx.dpy, RootWindow(xctx.dpy, DefaultScreen(xctx.dpy)), RRScreenChangeNotifyMask);
|
XRRSelectInput(xctx.dpy, RootWindow(xctx.dpy, DefaultScreen(xctx.dpy)), RRScreenChangeNotifyMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void randr_update()
|
void randr_update()
|
||||||
{
|
{
|
||||||
int n;
|
if (randr_major_version < 1
|
||||||
XRRMonitorInfo *m = XRRGetMonitors(xctx.dpy, RootWindow(xctx.dpy, DefaultScreen(xctx.dpy)), true, &n);
|
|| (randr_major_version == 1 && randr_minor_version < 5)) {
|
||||||
|
fprintf(stderr, "Server RandR version too low (%i.%i). Falling back to single monitor mode\n",
|
||||||
if (m == NULL || n == -1) {
|
randr_major_version,
|
||||||
fprintf(stderr, "(RandR) Could not get screen info, falling back to single monitor mode\n");
|
randr_minor_version);
|
||||||
screen_update_fallback();
|
screen_update_fallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int n = 0;
|
||||||
|
XRRMonitorInfo *m = XRRGetMonitors(xctx.dpy, RootWindow(xctx.dpy, DefaultScreen(xctx.dpy)), true, &n);
|
||||||
|
|
||||||
|
if (n < 1) {
|
||||||
|
fprintf(stderr, "Get monitors reported %i monitors, falling back to single monitor mode\n", n);
|
||||||
|
screen_update_fallback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(m);
|
||||||
|
|
||||||
alloc_screen_ar(n);
|
alloc_screen_ar(n);
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user