mirror of
https://github.com/mpv-player/mpv
synced 2025-01-03 13:32:16 +00:00
x11: listen to xrandr events
If the Xrandr configuration changes, re-read it. So if you change display modes or screen configuration, it will update the framedrop refresh rate accordingly. This passes the rootwin to XRRSelectInput(), which may or may not be allowed. But it works, and the documentation (which is worse than used toilet paper, great job Xorg) doesn't forbid it, or in fact say anything about what the window parameter is even used for.
This commit is contained in:
parent
b36ed6d9f9
commit
1e04c474ab
@ -634,7 +634,7 @@ fi
|
|||||||
|
|
||||||
check_pkg_config "Xinerama" $_xinerama XINERAMA 'xinerama'
|
check_pkg_config "Xinerama" $_xinerama XINERAMA 'xinerama'
|
||||||
|
|
||||||
check_pkg_config "Xrandr" $_xrandr XRANDR 'xrandr'
|
check_pkg_config "Xrandr" $_xrandr XRANDR 'xrandr >= 1.2.0'
|
||||||
|
|
||||||
check_pkg_config "CACA" $_caca CACA 'caca >= 0.99.beta18'
|
check_pkg_config "CACA" $_caca CACA 'caca >= 0.99.beta18'
|
||||||
|
|
||||||
|
@ -327,6 +327,17 @@ static void xrandr_read(struct vo_x11_state *x11)
|
|||||||
#if HAVE_XRANDR
|
#if HAVE_XRANDR
|
||||||
x11->num_displays = 0;
|
x11->num_displays = 0;
|
||||||
|
|
||||||
|
if (x11->xrandr_event < 0) {
|
||||||
|
int event_base, error_base;
|
||||||
|
if (!XRRQueryExtension(x11->display, &event_base, &error_base)) {
|
||||||
|
MP_VERBOSE(x11, "Couldn't init Xrandr.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
x11->xrandr_event = event_base + RRNotify;
|
||||||
|
XRRSelectInput(x11->display, x11->rootwin, RRScreenChangeNotifyMask |
|
||||||
|
RRCrtcChangeNotifyMask | RROutputChangeNotifyMask);
|
||||||
|
}
|
||||||
|
|
||||||
XRRScreenResources *r = XRRGetScreenResources(x11->display, x11->rootwin);
|
XRRScreenResources *r = XRRGetScreenResources(x11->display, x11->rootwin);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
MP_VERBOSE(x11, "Xrandr doesn't work.\n");
|
MP_VERBOSE(x11, "Xrandr doesn't work.\n");
|
||||||
@ -452,6 +463,7 @@ int vo_x11_init(struct vo *vo)
|
|||||||
*x11 = (struct vo_x11_state){
|
*x11 = (struct vo_x11_state){
|
||||||
.log = mp_log_new(x11, vo->log, "x11"),
|
.log = mp_log_new(x11, vo->log, "x11"),
|
||||||
.screensaver_enabled = true,
|
.screensaver_enabled = true,
|
||||||
|
.xrandr_event = -1,
|
||||||
};
|
};
|
||||||
vo->x11 = x11;
|
vo->x11 = x11;
|
||||||
|
|
||||||
@ -932,6 +944,10 @@ int vo_x11_check_events(struct vo *vo)
|
|||||||
if (x11->ShmCompletionWaitCount > 0)
|
if (x11->ShmCompletionWaitCount > 0)
|
||||||
x11->ShmCompletionWaitCount--;
|
x11->ShmCompletionWaitCount--;
|
||||||
}
|
}
|
||||||
|
if (Event.type == x11->xrandr_event) {
|
||||||
|
xrandr_read(x11);
|
||||||
|
vo_x11_update_geometry(vo);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ struct vo_x11_state {
|
|||||||
struct xrandr_display displays[MAX_DISPLAYS];
|
struct xrandr_display displays[MAX_DISPLAYS];
|
||||||
int num_displays;
|
int num_displays;
|
||||||
|
|
||||||
|
int xrandr_event;
|
||||||
|
|
||||||
bool screensaver_enabled;
|
bool screensaver_enabled;
|
||||||
bool dpms_touched;
|
bool dpms_touched;
|
||||||
double screensaver_time_last;
|
double screensaver_time_last;
|
||||||
|
2
wscript
2
wscript
@ -569,7 +569,7 @@ video_output_features = [
|
|||||||
'name': '--xrandr',
|
'name': '--xrandr',
|
||||||
'desc': 'Xrandr',
|
'desc': 'Xrandr',
|
||||||
'deps': [ 'x11' ],
|
'deps': [ 'x11' ],
|
||||||
'func': check_pkg_config('xrandr'),
|
'func': check_pkg_config('xrandr', '>= 1.2.0'),
|
||||||
} , {
|
} , {
|
||||||
'name': '--gl-cocoa',
|
'name': '--gl-cocoa',
|
||||||
'desc': 'OpenGL Cocoa Backend',
|
'desc': 'OpenGL Cocoa Backend',
|
||||||
|
Loading…
Reference in New Issue
Block a user