From d9bd5bacc109aae0b70e879bf2c8dcc93d34bc2b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 18 May 2014 22:16:53 +0200 Subject: 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. --- video/out/x11_common.c | 3 +++ video/out/x11_common.h | 1 + 2 files changed, 4 insertions(+) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 89cded6b5d..911fea3ddc 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -1562,12 +1562,15 @@ static void set_screensaver(struct vo_x11_state *x11, bool enabled) BOOL onoff = 0; CARD16 state; DPMSInfo(mDisplay, &state, &onoff); + if (!x11->dpms_touched && enabled) + return; // enable DPMS only we we disabled it before if (enabled != !!onoff) { MP_VERBOSE(x11, "Setting DMPS: %s.\n", enabled ? "on" : "off"); if (enabled) { DPMSEnable(mDisplay); } else { DPMSDisable(mDisplay); + x11->dpms_touched = true; } DPMSInfo(mDisplay, &state, &onoff); if (enabled != !!onoff) diff --git a/video/out/x11_common.h b/video/out/x11_common.h index 0b4a58325f..15a86978ec 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -41,6 +41,7 @@ struct vo_x11_state { struct mp_rect screenrc; bool screensaver_enabled; + bool dpms_touched; double screensaver_time_last; XIM xim; -- cgit v1.2.3