0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

x11: never enable DPMS if we didn't disable it

Enabling DPMS even though you disabled it globally is pretty unfriendly,
so don't do it. Instead, we only disable DPMS if it was enabled, and
only enable it if we disabled it ourselves.

The other way should never happen (disabling DPMS permanently), unless
mpv crashes during playback.
This commit is contained in:
wm4 2014-05-18 22:16:53 +02:00
parent 42a51310c1
commit d9bd5bacc1
2 changed files with 4 additions and 0 deletions

View File

@ -1562,12 +1562,15 @@ static void set_screensaver(struct vo_x11_state *x11, bool enabled)
BOOL onoff = 0; BOOL onoff = 0;
CARD16 state; CARD16 state;
DPMSInfo(mDisplay, &state, &onoff); DPMSInfo(mDisplay, &state, &onoff);
if (!x11->dpms_touched && enabled)
return; // enable DPMS only we we disabled it before
if (enabled != !!onoff) { if (enabled != !!onoff) {
MP_VERBOSE(x11, "Setting DMPS: %s.\n", enabled ? "on" : "off"); MP_VERBOSE(x11, "Setting DMPS: %s.\n", enabled ? "on" : "off");
if (enabled) { if (enabled) {
DPMSEnable(mDisplay); DPMSEnable(mDisplay);
} else { } else {
DPMSDisable(mDisplay); DPMSDisable(mDisplay);
x11->dpms_touched = true;
} }
DPMSInfo(mDisplay, &state, &onoff); DPMSInfo(mDisplay, &state, &onoff);
if (enabled != !!onoff) if (enabled != !!onoff)

View File

@ -41,6 +41,7 @@ struct vo_x11_state {
struct mp_rect screenrc; struct mp_rect screenrc;
bool screensaver_enabled; bool screensaver_enabled;
bool dpms_touched;
double screensaver_time_last; double screensaver_time_last;
XIM xim; XIM xim;