summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-07-08 22:25:08 +0200
committerwm4 <wm4@nowhere>2020-07-08 22:45:07 +0200
commitc498b2846af0ee8835b9144c9f6893568a4e49c6 (patch)
tree0be6b06d2d7ec678a97f9e953d6472ccc3d33f29
parentb93f142011381a9ad753a246ea112115f262e7a1 (diff)
downloadmpv-c498b2846af0ee8835b9144c9f6893568a4e49c6.tar.bz2
mpv-c498b2846af0ee8835b9144c9f6893568a4e49c6.tar.xz
x11: remove terrible xdg-screensaver hack
I'm tired of dealing with this frequent spawning of xdg-screensaver when debugging and what not. xdg-screensaver was never a serious tool anyway, it's more like some self-deprecating joke by FDO folks. This will affect X11 on GNOME and other DEs. I'm singling out GNOME though, because they are the ones actively sabotaging any sane technical solutions and community cooperation. I have been accused of taking it out on innocent GNOME users, while none of this will reach GNOME developers. Of course that is not the intention.
-rw-r--r--DOCS/man/mpv.rst44
-rw-r--r--DOCS/man/options.rst3
-rw-r--r--video/out/x11_common.c39
-rw-r--r--video/out/x11_common.h9
4 files changed, 47 insertions, 48 deletions
diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst
index 92c0052c55..dbd700cc9e 100644
--- a/DOCS/man/mpv.rst
+++ b/DOCS/man/mpv.rst
@@ -1057,6 +1057,50 @@ works like in older mpv releases:
change, and not apply your additional settings, and/or use a different
profile name.
+Linux desktop issues
+====================
+
+This subsection describes common problems on the Linux desktop. None of these
+problems exist on systems like Windows or OSX.
+
+Disabling Screensaver
+---------------------
+
+By default, mpv tries to disable the OS screensaver during playback (only if
+a VO using the OS GUI API is active). ``--stop-screensaver=no`` disables this.
+
+A common problem is that Linux desktop environments ignore the standard
+screensaver APIs on which mpv relies. In particular, mpv uses the Screen Saver
+extension (XSS) on X11, and the idle-inhibit on Wayland.
+
+GNOME is one of the worst offenders, and ignores even the now widely supported
+idle-inhibit protocol. (This is either due to a combination of malice and
+incompetence, but since implementing this protocol would only take a few lines
+of code, it is most likely the former. You will also notice how GNOME advocates
+react offended whenever their sabotage is pointed out, which indicates either
+hypocrisy, or even worse ignorance.)
+
+Such incompatible desktop environments (i.e. which ignore standards) typically
+require using a DBus API. This is ridiculous in several ways. The immediate
+practical problem is that it would require adding a quite unwieldy dependency
+for a DBus library, somehow integrating its mainloop into mpv, and other
+generally unacceptable things.
+
+However, since mpv does not officially support GNOME, this is not much of a
+problem. If you are one of those miserable users who want to use mpv on GNOME,
+report a bug on the GNOME issue tracker:
+https://gitlab.gnome.org/groups/GNOME/-/issues
+
+Alternatively, you may be able to write a Lua script that calls the
+``xdg-screensaver`` command line program. (By the way, this a command line
+program is an utterly horrible kludge that tries to identify your DE, and then
+tries to send the correct DBus command via a DBus CLI tool.) If you find the
+idea of having to write a script just so your screensaver doesn't kick in
+ridiculous, do not use GNOME, or use GNOME video software instead of mpv (good
+luck).
+
+Before mpv 0.33.0, the X11 backend ran ``xdg-screensaver reset`` in 10 second
+intervals when not paused. This hack was removed in 0.33.0.
.. include:: options.rst
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index ce0f19e113..f554186f04 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3147,7 +3147,8 @@ Window
always re-enabled when the player is paused.
This is not supported on all video outputs or platforms. Sometimes it is
- implemented, but does not work (especially with Linux "desktops").
+ implemented, but does not work (especially with Linux "desktops"). Read the
+ `Disabling Screensaver`_ section very carefully.
``--wid=<ID>``
This tells mpv to attach to an existing window. If a VO is selected that
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 9b326674dc..40228903b9 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -527,30 +527,6 @@ static void vo_x11_get_bounding_monitors(struct vo_x11_state *x11, long b[4])
XFree(screens);
}
-static void *screensaver_thread(void *arg)
-{
- struct vo_x11_state *x11 = arg;
-
- for (;;) {
- sem_wait(&x11->screensaver_sem);
- // don't queue multiple wakeups
- while (!sem_trywait(&x11->screensaver_sem)) {}
-
- if (atomic_load(&x11->screensaver_terminate))
- break;
-
- char *args[] = {"xdg-screensaver", "reset", NULL};
- int status = mp_subprocess(args, NULL, NULL, mp_devnull, mp_devnull, &(char*){0});
- if (status) {
- MP_VERBOSE(x11, "Disabling screensaver failed (%d). Make sure the "
- "xdg-screensaver script is installed.\n", status);
- break;
- }
- }
-
- return NULL;
-}
-
int vo_x11_init(struct vo *vo)
{
char *dispName;
@@ -572,13 +548,6 @@ int vo_x11_init(struct vo *vo)
x11->opts = x11->opts_cache->opts;
vo->x11 = x11;
- sem_init(&x11->screensaver_sem, 0, 0);
- if (pthread_create(&x11->screensaver_thread, NULL, screensaver_thread, x11)) {
- sem_destroy(&x11->screensaver_sem);
- goto error;
- }
- x11->screensaver_thread_running = true;
-
x11_error_output = x11->log;
XSetErrorHandler(x11_errorhandler);
@@ -808,13 +777,6 @@ void vo_x11_uninit(struct vo *vo)
XCloseDisplay(x11->display);
}
- if (x11->screensaver_thread_running) {
- atomic_store(&x11->screensaver_terminate, true);
- sem_post(&x11->screensaver_sem);
- pthread_join(x11->screensaver_thread, NULL);
- sem_destroy(&x11->screensaver_sem);
- }
-
if (x11->wakeup_pipe[0] >= 0) {
close(x11->wakeup_pipe[0]);
close(x11->wakeup_pipe[1]);
@@ -2013,7 +1975,6 @@ static void xscreensaver_heartbeat(struct vo_x11_state *x11)
(time - x11->screensaver_time_last) >= 10)
{
x11->screensaver_time_last = time;
- sem_post(&x11->screensaver_sem);
XResetScreenSaver(x11->display);
}
}
diff --git a/video/out/x11_common.h b/video/out/x11_common.h
index fffc5be294..774a76afbe 100644
--- a/video/out/x11_common.h
+++ b/video/out/x11_common.h
@@ -20,14 +20,11 @@
#include <stdint.h>
#include <stdbool.h>
-#include <pthread.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include "osdep/atomic.h"
-#include "osdep/semaphore.h"
-
#include "common/common.h"
+#include "osdep/atomic.h"
#include "config.h"
#if !HAVE_GPL
@@ -75,10 +72,6 @@ struct vo_x11_state {
bool screensaver_enabled;
bool dpms_touched;
double screensaver_time_last;
- pthread_t screensaver_thread;
- bool screensaver_thread_running;
- sem_t screensaver_sem;
- atomic_bool screensaver_terminate;
XIM xim;
XIC xic;