summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <[email protected]>2012-06-13 00:25:29 +0200
committerraveit65 <[email protected]>2018-03-21 06:56:34 +0100
commit2f89fccf54a858495101cd57bac66ffca657ff62 (patch)
tree3d499f08c0d5b8da3245ecb6136a29616b9d2ec8
parent15073fb029c8fc78d7184be7bc0e70d4cbe5ac1b (diff)
downloadatril-2f89fccf54a858495101cd57bac66ffca657ff62.tar.bz2
atril-2f89fccf54a858495101cd57bac66ffca657ff62.tar.xz
shell: Use GtkApplication to inhibit the screensaver
Remove TotemScrsaver copy, and use GtkApplication inhibition instead. origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-6&id=612701f
-rw-r--r--configure.ac1
-rw-r--r--cut-n-paste/Makefile.am2
-rw-r--r--cut-n-paste/totem-screensaver/Makefile.am16
-rw-r--r--cut-n-paste/totem-screensaver/README3
-rw-r--r--cut-n-paste/totem-screensaver/totem-scrsaver.c544
-rw-r--r--cut-n-paste/totem-screensaver/totem-scrsaver.h57
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/ev-application.c24
-rw-r--r--shell/ev-application.h2
-rw-r--r--shell/ev-window.c40
10 files changed, 37 insertions, 654 deletions
diff --git a/configure.ac b/configure.ac
index 45836282..608c7bc1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -688,7 +688,6 @@ cut-n-paste/Makefile
cut-n-paste/smclient/Makefile
cut-n-paste/toolbar-editor/Makefile
cut-n-paste/zoom-control/Makefile
-cut-n-paste/totem-screensaver/Makefile
cut-n-paste/synctex/Makefile
data/atril.desktop.in
data/Makefile
diff --git a/cut-n-paste/Makefile.am b/cut-n-paste/Makefile.am
index bd953d76..b765ee9a 100644
--- a/cut-n-paste/Makefile.am
+++ b/cut-n-paste/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = zoom-control toolbar-editor totem-screensaver smclient synctex
+SUBDIRS = zoom-control toolbar-editor smclient synctex
-include $(top_srcdir)/git.mk
diff --git a/cut-n-paste/totem-screensaver/Makefile.am b/cut-n-paste/totem-screensaver/Makefile.am
deleted file mode 100644
index 1304c8d4..00000000
--- a/cut-n-paste/totem-screensaver/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-noinst_LTLIBRARIES = libtotemscrsaver.la
-libtotemscrsaver_la_SOURCES = \
- totem-scrsaver.h \
- totem-scrsaver.c
-
-libtotemscrsaver_la_CPPFLAGS = \
- $(AM_CPPFLAGS)
-
-libtotemscrsaver_la_CFLAGS = \
- $(SHELL_CORE_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(WARNING_CFLAGS) \
- $(DISABLE_DEPRECATED) \
- $(AM_CFLAGS)
-
--include $(top_srcdir)/git.mk
diff --git a/cut-n-paste/totem-screensaver/README b/cut-n-paste/totem-screensaver/README
deleted file mode 100644
index a5be11b2..00000000
--- a/cut-n-paste/totem-screensaver/README
+++ /dev/null
@@ -1,3 +0,0 @@
-The sources for the screensaver enabling/disabling code are copied from Totem.
-A simple replacement (s/WITH_DBUS/ENABLE_DBUS/g) was needed. The hardcoded
-"reason for inhibiting" string was also modified.
diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.c b/cut-n-paste/totem-screensaver/totem-scrsaver.c
deleted file mode 100644
index 78a81b5f..00000000
--- a/cut-n-paste/totem-screensaver/totem-scrsaver.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
-
- Copyright (C) 2004-2006 Bastien Nocera <[email protected]>
- Copyright © 2010 Christian Persch
- Copyright © 2010 Carlos Garcia Campos
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301 USA.
-
- Authors: Bastien Nocera <[email protected]>
- Christian Persch
- Carlos Garcia Campos
- */
-
-#include "config.h"
-
-#include <glib/gi18n.h>
-
-#include <gdk/gdk.h>
-
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-#include <X11/keysym.h>
-
-#ifdef HAVE_XTEST
-#include <X11/extensions/XTest.h>
-#endif /* HAVE_XTEST */
-#endif /* GDK_WINDOWING_X11 */
-
-#include "totem-scrsaver.h"
-
-#define GS_SERVICE "org.gnome.SessionManager"
-#define GS_PATH "/org/gnome/SessionManager"
-#define GS_INTERFACE "org.gnome.SessionManager"
-
-#define GSM_INHIBITOR_FLAG_IDLE 1 << 3
-#define XSCREENSAVER_MIN_TIMEOUT 60
-
-enum {
- PROP_0,
- PROP_REASON
-};
-
-static void totem_scrsaver_finalize (GObject *object);
-
-struct TotemScrsaverPrivate {
- /* Whether the screensaver is disabled */
- gboolean disabled;
- /* The reason for the inhibition */
- char *reason;
-
- GDBusProxy *gs_proxy;
- gboolean have_session_dbus;
- guint32 cookie;
-
- /* To save the screensaver info */
- int timeout;
- int interval;
- int prefer_blanking;
- int allow_exposures;
-
- /* For use with XTest */
- int keycode1, keycode2;
- int *keycode;
- gboolean have_xtest;
-};
-
-G_DEFINE_TYPE(TotemScrsaver, totem_scrsaver, G_TYPE_OBJECT)
-
-static gboolean
-screensaver_is_running_dbus (TotemScrsaver *scr)
-{
- return scr->priv->have_session_dbus;
-}
-
-static void
-on_inhibit_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GDBusProxy *proxy = G_DBUS_PROXY (source_object);
- TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
- GVariant *value;
- GError *error = NULL;
-
- value = g_dbus_proxy_call_finish (proxy, res, &error);
- if (!value) {
- g_warning ("Problem inhibiting the screensaver: %s", error->message);
- g_object_unref (scr);
- g_error_free (error);
-
- return;
- }
-
- /* save the cookie */
- if (g_variant_is_of_type (value, G_VARIANT_TYPE ("(u)")))
- g_variant_get (value, "(u)", &scr->priv->cookie);
- else
- scr->priv->cookie = 0;
- g_variant_unref (value);
- g_object_unref (scr);
-}
-
-static void
-on_uninhibit_cb (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GDBusProxy *proxy = G_DBUS_PROXY (source_object);
- TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
- GVariant *value;
- GError *error = NULL;
-
- value = g_dbus_proxy_call_finish (proxy, res, &error);
- if (!value) {
- g_warning ("Problem uninhibiting the screensaver: %s", error->message);
- g_object_unref (scr);
- g_error_free (error);
-
- return;
- }
-
- /* clear the cookie */
- scr->priv->cookie = 0;
- g_variant_unref (value);
-
- g_object_unref (scr);
-}
-
-static void
-screensaver_inhibit_dbus (TotemScrsaver *scr,
- gboolean inhibit)
-{
- TotemScrsaverPrivate *priv = scr->priv;
-
- if (!priv->have_session_dbus)
- return;
-
- g_object_ref (scr);
-
- if (inhibit) {
- g_return_if_fail (scr->priv->reason != NULL);
- g_dbus_proxy_call (priv->gs_proxy,
- "Inhibit",
- g_variant_new ("(susu)",
- g_get_application_name (),
- 0,
- scr->priv->reason,
- GSM_INHIBITOR_FLAG_IDLE),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- -1,
- NULL,
- on_inhibit_cb,
- scr);
- } else {
- g_dbus_proxy_call (priv->gs_proxy,
- "Uninhibit",
- g_variant_new ("(u)", priv->cookie),
- G_DBUS_CALL_FLAGS_NO_AUTO_START,
- -1,
- NULL,
- on_uninhibit_cb,
- scr);
- }
-}
-
-static void
-screensaver_enable_dbus (TotemScrsaver *scr)
-{
- screensaver_inhibit_dbus (scr, FALSE);
-}
-
-static void
-screensaver_disable_dbus (TotemScrsaver *scr)
-{
- screensaver_inhibit_dbus (scr, TRUE);
-}
-
-static void
-screensaver_update_dbus_presence (TotemScrsaver *scr)
-{
- TotemScrsaverPrivate *priv = scr->priv;
- gchar *name_owner;
-
- name_owner = g_dbus_proxy_get_name_owner (priv->gs_proxy);
- if (name_owner) {
- priv->have_session_dbus = TRUE;
- g_free (name_owner);
- } else {
- priv->have_session_dbus = FALSE;
- }
-}
-
-static void
-screensaver_dbus_owner_changed_cb (GObject *object,
- GParamSpec *pspec,
- gpointer user_data)
-{
- TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
-
- screensaver_update_dbus_presence (scr);
-}
-
-static void
-screensaver_dbus_proxy_new_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- TotemScrsaver *scr = TOTEM_SCRSAVER (user_data);
- TotemScrsaverPrivate *priv = scr->priv;
-
- priv->gs_proxy = g_dbus_proxy_new_for_bus_finish (result, NULL);
- if (!priv->gs_proxy)
- return;
-
- screensaver_update_dbus_presence (scr);
-
- g_signal_connect (priv->gs_proxy, "notify::g-name-owner",
- G_CALLBACK (screensaver_dbus_owner_changed_cb),
- scr);
-}
-
-static void
-screensaver_init_dbus (TotemScrsaver *scr)
-{
- g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
- NULL,
- GS_SERVICE,
- GS_PATH,
- GS_INTERFACE,
- NULL,
- screensaver_dbus_proxy_new_cb,
- scr);
-}
-
-static void
-screensaver_finalize_dbus (TotemScrsaver *scr)
-{
- if (scr->priv->gs_proxy) {
- g_object_unref (scr->priv->gs_proxy);
- }
-}
-
-#ifdef GDK_WINDOWING_X11
-static void
-screensaver_enable_x11 (TotemScrsaver *scr)
-{
- Display *display;
-
-#ifdef HAVE_XTEST
- if (scr->priv->have_xtest != FALSE)
- {
- g_source_remove_by_user_data (scr);
- return;
- }
-#endif /* HAVE_XTEST */
-
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- XLockDisplay (display);
- XSetScreenSaver (display,
- scr->priv->timeout,
- scr->priv->interval,
- scr->priv->prefer_blanking,
- scr->priv->allow_exposures);
- XUnlockDisplay (display);
-}
-
-#ifdef HAVE_XTEST
-static gboolean
-fake_event (TotemScrsaver *scr)
-{
- if (scr->priv->disabled)
- {
- Display *display;
-
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- XLockDisplay (display);
- XTestFakeKeyEvent (display, *scr->priv->keycode,
- True, CurrentTime);
- XTestFakeKeyEvent (display, *scr->priv->keycode,
- False, CurrentTime);
- XUnlockDisplay (display);
- /* Swap the keycode */
- if (scr->priv->keycode == &scr->priv->keycode1)
- scr->priv->keycode = &scr->priv->keycode2;
- else
- scr->priv->keycode = &scr->priv->keycode1;
- }
-
- return TRUE;
-}
-#endif /* HAVE_XTEST */
-
-static void
-screensaver_disable_x11 (TotemScrsaver *scr)
-{
- Display *display;
-
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
-#ifdef HAVE_XTEST
- if (scr->priv->have_xtest != FALSE)
- {
- XLockDisplay (display);
- XGetScreenSaver(display, &scr->priv->timeout,
- &scr->priv->interval,
- &scr->priv->prefer_blanking,
- &scr->priv->allow_exposures);
- XUnlockDisplay (display);
-
- if (scr->priv->timeout != 0) {
- g_timeout_add_seconds (scr->priv->timeout / 2,
- (GSourceFunc) fake_event, scr);
- } else {
- g_timeout_add_seconds (XSCREENSAVER_MIN_TIMEOUT / 2,
- (GSourceFunc) fake_event, scr);
- }
-
- return;
- }
-#endif /* HAVE_XTEST */
-
- XLockDisplay (display);
- XGetScreenSaver(display, &scr->priv->timeout,
- &scr->priv->interval,
- &scr->priv->prefer_blanking,
- &scr->priv->allow_exposures);
- XSetScreenSaver(display, 0, 0,
- DontPreferBlanking, DontAllowExposures);
- XUnlockDisplay (display);
-}
-
-static void
-screensaver_init_x11 (TotemScrsaver *scr)
-{
-#ifdef HAVE_XTEST
- int a, b, c, d;
- Display *display;
-
- display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
- XLockDisplay (display);
- scr->priv->have_xtest = (XTestQueryExtension (display, &a, &b, &c, &d) == True);
- if (scr->priv->have_xtest != FALSE)
- {
- scr->priv->keycode1 = XKeysymToKeycode (display, XK_Alt_L);
- if (scr->priv->keycode1 == 0) {
- g_warning ("scr->priv->keycode1 not existent");
- }
- scr->priv->keycode2 = XKeysymToKeycode (display, XK_Alt_R);
- if (scr->priv->keycode2 == 0) {
- scr->priv->keycode2 = XKeysymToKeycode (display, XK_Alt_L);
- if (scr->priv->keycode2 == 0) {
- g_warning ("scr->priv->keycode2 not existent");
- }
- }
- scr->priv->keycode = &scr->priv->keycode1;
- }
- XUnlockDisplay (display);
-#endif /* HAVE_XTEST */
-}
-
-static void
-screensaver_finalize_x11 (TotemScrsaver *scr)
-{
- g_source_remove_by_user_data (scr);
-}
-#endif
-
-static void
-totem_scrsaver_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- TotemScrsaver *scr;
-
- scr = TOTEM_SCRSAVER (object);
-
- switch (property_id)
- {
- case PROP_REASON:
- g_value_set_string (value, scr->priv->reason);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-totem_scrsaver_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- TotemScrsaver *scr;
-
- scr = TOTEM_SCRSAVER (object);
-
- switch (property_id)
- {
- case PROP_REASON:
- g_free (scr->priv->reason);
- scr->priv->reason = g_value_dup_string (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
-}
-
-static void
-totem_scrsaver_class_init (TotemScrsaverClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (TotemScrsaverPrivate));
-
- object_class->set_property = totem_scrsaver_set_property;
- object_class->get_property = totem_scrsaver_get_property;
- object_class->finalize = totem_scrsaver_finalize;
-
- g_object_class_install_property (object_class, PROP_REASON,
- g_param_spec_string ("reason", NULL, NULL,
- NULL, G_PARAM_READWRITE));
-
-}
-
-/**
- * totem_scrsaver_new:
- *
- * Creates a #TotemScrsaver object.
- * If the MATE screen saver is running, it uses its DBUS interface to
- * inhibit the screensaver; otherwise it falls back to using the X
- * screensaver functionality for this.
- *
- * Returns: a newly created #TotemScrsaver
- */
-TotemScrsaver *
-totem_scrsaver_new (void)
-{
- return TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL));
-}
-
-static void
-totem_scrsaver_init (TotemScrsaver *scr)
-{
- scr->priv = G_TYPE_INSTANCE_GET_PRIVATE (scr,
- TOTEM_TYPE_SCRSAVER,
- TotemScrsaverPrivate);
-
- screensaver_init_dbus (scr);
-#ifdef GDK_WINDOWING_X11
- screensaver_init_x11 (scr);
-#else
-#warning Unimplemented
-#endif
-}
-
-void
-totem_scrsaver_disable (TotemScrsaver *scr)
-{
- g_return_if_fail (TOTEM_IS_SCRSAVER (scr));
-
- if (scr->priv->disabled != FALSE)
- return;
-
- scr->priv->disabled = TRUE;
-
- if (screensaver_is_running_dbus (scr) != FALSE)
- screensaver_disable_dbus (scr);
- else
-#ifdef GDK_WINDOWING_X11
- screensaver_disable_x11 (scr);
-#else
-#warning Unimplemented
- {}
-#endif
-}
-
-void
-totem_scrsaver_enable (TotemScrsaver *scr)
-{
- g_return_if_fail (TOTEM_IS_SCRSAVER (scr));
-
- if (scr->priv->disabled == FALSE)
- return;
-
- scr->priv->disabled = FALSE;
-
- if (screensaver_is_running_dbus (scr) != FALSE)
- screensaver_enable_dbus (scr);
- else
-#ifdef GDK_WINDOWING_X11
- screensaver_enable_x11 (scr);
-#else
-#warning Unimplemented
- {}
-#endif
-}
-
-void
-totem_scrsaver_set_state (TotemScrsaver *scr, gboolean enable)
-{
- g_return_if_fail (TOTEM_IS_SCRSAVER (scr));
-
- if (scr->priv->disabled == !enable)
- return;
-
- if (enable == FALSE)
- totem_scrsaver_disable (scr);
- else
- totem_scrsaver_enable (scr);
-}
-
-static void
-totem_scrsaver_finalize (GObject *object)
-{
- TotemScrsaver *scr = TOTEM_SCRSAVER (object);
-
- g_free (scr->priv->reason);
-
- screensaver_finalize_dbus (scr);
-#ifdef GDK_WINDOWING_X11
- screensaver_finalize_x11 (scr);
-#else
-#warning Unimplemented
- {}
-#endif
-
- G_OBJECT_CLASS (totem_scrsaver_parent_class)->finalize (object);
-}
diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.h b/cut-n-paste/totem-screensaver/totem-scrsaver.h
deleted file mode 100644
index bb95174d..00000000
--- a/cut-n-paste/totem-screensaver/totem-scrsaver.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (C) 2004, Bastien Nocera <[email protected]>
-
- The Mate Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Mate Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Mate Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301 USA.
-
- Author: Bastien Nocera <[email protected]>
- */
-
-#ifndef TOTEM_SCRSAVER_H
-#define TOTEM_SCRSAVER_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define TOTEM_TYPE_SCRSAVER (totem_scrsaver_get_type ())
-#define TOTEM_SCRSAVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOTEM_TYPE_SCRSAVER, TotemScrsaver))
-#define TOTEM_SCRSAVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_SCRSAVER, TotemScrsaverClass))
-#define TOTEM_IS_SCRSAVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOTEM_TYPE_SCRSAVER))
-#define TOTEM_IS_SCRSAVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOTEM_TYPE_SCRSAVER))
-
-typedef struct TotemScrsaver TotemScrsaver;
-typedef struct TotemScrsaverClass TotemScrsaverClass;
-typedef struct TotemScrsaverPrivate TotemScrsaverPrivate;
-
-struct TotemScrsaver {
- GObject parent;
- TotemScrsaverPrivate *priv;
-};
-
-struct TotemScrsaverClass {
- GObjectClass parent_class;
-};
-
-GType totem_scrsaver_get_type (void) G_GNUC_CONST;
-TotemScrsaver *totem_scrsaver_new (void);
-void totem_scrsaver_enable (TotemScrsaver *scr);
-void totem_scrsaver_disable (TotemScrsaver *scr);
-void totem_scrsaver_set_state (TotemScrsaver *scr,
- gboolean enable);
-
-G_END_DECLS
-
-#endif /* !TOTEM_SCRSAVER_H */
diff --git a/shell/Makefile.am b/shell/Makefile.am
index a8d40f10..ab91afee 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -5,7 +5,6 @@ AM_CPPFLAGS= \
-I$(top_builddir) \
-I$(top_srcdir)/cut-n-paste/zoom-control/ \
-I$(top_srcdir)/cut-n-paste/toolbar-editor/ \
- -I$(top_srcdir)/cut-n-paste/totem-screensaver/ \
-I$(top_srcdir)/cut-n-paste/smclient/ \
-I$(top_srcdir)/libdocument \
-I$(top_builddir)/libdocument \
@@ -109,7 +108,6 @@ atril_LDFLAGS = $(AM_LDFLAGS)
atril_LDADD= \
$(top_builddir)/cut-n-paste/zoom-control/libephyzoom.la \
$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la \
- $(top_builddir)/cut-n-paste/totem-screensaver/libtotemscrsaver.la \
$(top_builddir)/cut-n-paste/smclient/libsmclient.la \
$(top_builddir)/properties/libevproperties.la \
$(top_builddir)/libdocument/libatrildocument.la \
diff --git a/shell/ev-application.c b/shell/ev-application.c
index a64a0568..601a09a6 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -32,8 +32,6 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#include "totem-scrsaver.h"
-
#include "eggsmclient.h"
#include "ev-application.h"
@@ -59,8 +57,6 @@ struct _EvApplication {
gboolean doc_registered;
#endif
- TotemScrsaver *scr_saver;
-
EggSMClient *smclient;
};
@@ -885,9 +881,6 @@ ev_application_shutdown (GApplication *gapplication)
ev_application_accel_map_save (application);
- g_object_unref (application->scr_saver);
- application->scr_saver = NULL;
-
g_free (application->dot_dir);
application->dot_dir = NULL;
@@ -1002,11 +995,6 @@ static void ev_application_init(EvApplication* ev_application)
ev_application_init_session (ev_application);
ev_application_accel_map_load (ev_application);
-
- ev_application->scr_saver = totem_scrsaver_new ();
- g_object_set (ev_application->scr_saver,
- "reason", _("Running in presentation mode"),
- NULL);
}
gboolean
@@ -1066,18 +1054,6 @@ ev_application_get_media_keys (EvApplication *application)
#endif /* ENABLE_DBUS */
}
-void
-ev_application_screensaver_enable (EvApplication *application)
-{
- totem_scrsaver_enable (application->scr_saver);
-}
-
-void
-ev_application_screensaver_disable (EvApplication *application)
-{
- totem_scrsaver_disable (application->scr_saver);
-}
-
const gchar *
ev_application_get_dot_dir (EvApplication *application,
gboolean create)
diff --git a/shell/ev-application.h b/shell/ev-application.h
index f0561b55..d8d9cff1 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -68,8 +68,6 @@ gboolean ev_application_has_window (EvApplication *application);
guint ev_application_get_n_windows (EvApplication *application);
const gchar * ev_application_get_uri (EvApplication *application);
GObject *ev_application_get_media_keys (EvApplication *application);
-void ev_application_screensaver_enable (EvApplication *application);
-void ev_application_screensaver_disable (EvApplication *application);
const gchar *ev_application_get_dot_dir (EvApplication *application,
gboolean create);
const gchar *ev_application_get_data_dir (EvApplication *application);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 0c8e1298..820b9f32 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -230,6 +230,8 @@ struct _EvWindowPrivate {
gchar *dbus_object_path;
#endif
+ guint presentation_mode_inhibit_id;
+
/* Caret navigation */
GtkWidget *ask_caret_navigation_check;
};
@@ -4263,6 +4265,35 @@ ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
}
static void
+ev_window_inhibit_screensaver (EvWindow *window)
+{
+ EvWindowPrivate *priv = window->priv;
+
+ if (priv->presentation_mode_inhibit_id != 0)
+ return;
+
+ priv->presentation_mode_inhibit_id =
+ gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
+ GTK_WINDOW (window),
+ GTK_APPLICATION_INHIBIT_IDLE,
+ _("Running in presentation mode"));
+}
+
+
+static void
+ev_window_uninhibit_screensaver (EvWindow *window)
+{
+ EvWindowPrivate *priv = window->priv;
+
+ if (priv->presentation_mode_inhibit_id == 0)
+ return;
+
+ gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
+ priv->presentation_mode_inhibit_id);
+ priv->presentation_mode_inhibit_id = 0;
+}
+
+static void
ev_window_update_presentation_action (EvWindow *window)
{
GtkAction *action;
@@ -4285,7 +4316,7 @@ ev_window_view_presentation_finished (EvWindow *window)
static gboolean
ev_window_view_presentation_focus_in (EvWindow *window)
{
- ev_application_screensaver_disable (EV_APP);
+ ev_window_uninhibit_screensaver (window);
return FALSE;
}
@@ -4293,7 +4324,7 @@ ev_window_view_presentation_focus_in (EvWindow *window)
static gboolean
ev_window_view_presentation_focus_out (EvWindow *window)
{
- ev_application_screensaver_enable (EV_APP);
+ ev_window_uninhibit_screensaver (window);
return FALSE;
}
@@ -4353,7 +4384,7 @@ ev_window_run_presentation (EvWindow *window)
gtk_widget_show (window->priv->presentation_view);
- ev_application_screensaver_disable (EV_APP);
+ ev_window_inhibit_screensaver (window);
if (window->priv->metadata && !ev_window_is_empty (window))
ev_metadata_set_boolean (window->priv->metadata, "presentation", TRUE);
@@ -4392,7 +4423,7 @@ ev_window_stop_presentation (EvWindow *window,
gtk_widget_grab_focus (window->priv->webview);
}
#endif
- ev_application_screensaver_enable (EV_APP);
+ ev_window_uninhibit_screensaver (window);
if (window->priv->metadata && !ev_window_is_empty (window))
ev_metadata_set_boolean (window->priv->metadata, "presentation", FALSE);
@@ -7625,6 +7656,7 @@ ev_window_init (EvWindow *ev_window)
ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
ev_window->priv->chrome = EV_CHROME_NORMAL;
+ ev_window->priv->presentation_mode_inhibit_id = 0;
ev_window->priv->title = ev_window_title_new (ev_window);
GtkStyleContext *context;