[gnome-session] gnome-session-check-accelerated: Set X property _GNOME_SESSION_ACCELERATED
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] gnome-session-check-accelerated: Set X property _GNOME_SESSION_ACCELERATED
- Date: Thu, 3 Mar 2011 21:55:37 +0000 (UTC)
commit ffe98dd102abd4b39732cae69fc35ed3b0522604
Author: Colin Walters <walters verbum org>
Date: Mon Feb 28 10:03:13 2011 -0500
gnome-session-check-accelerated: Set X property _GNOME_SESSION_ACCELERATED
It would make sense to run gnome-session-is-accelerated in
GDM, in parallel with the user is typing their password. A
good way to pass that knowledge through to gnome-session
so it knows it can avoid repeating the same check is via
an X property.
So create a new tool "gnome-session-check-accelerated", which takes
the name of the old one (now renamed "gnome-session-check-accelerated-helper")
and stores that status as an X property. gnome-session will then
itself run it again, but it should pick up the property and reuse that
value.
https://bugzilla.gnome.org/show_bug.cgi?id=641992
configure.ac | 4 +
data/gnome.session.desktop.in.in | 2 +-
tools/Makefile.am | 21 +++-
....c => gnome-session-check-accelerated-helper.c} | 2 +-
tools/gnome-session-check-accelerated.c | 103 ++++++++++++++++++++
5 files changed, 125 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index adef19b..6f690bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,10 @@ dnl Dependency Checks
dnl ====================================================================
PKG_PROG_PKG_CONFIG()
+dnl Standard vertical stacks
+PKG_CHECK_MODULES(GIO, gio-2.0)
+PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= $GTK3_REQUIRED)
+
PKG_CHECK_MODULES(GNOME_SESSION,
glib-2.0 >= $GLIB_REQUIRED
gio-2.0 >= $GLIB_REQUIRED
diff --git a/data/gnome.session.desktop.in.in b/data/gnome.session.desktop.in.in
index 49260cb..654c7de 100644
--- a/data/gnome.session.desktop.in.in
+++ b/data/gnome.session.desktop.in.in
@@ -4,5 +4,5 @@ Required=windowmanager;panel;
Required-windowmanager=gnome-shell
Required-panel=gnome-shell
DefaultApps=gnome-settings-daemon;
-IsRunnableHelper= LIBEXECDIR@/gnome-session-is-accelerated
+IsRunnableHelper= LIBEXECDIR@/gnome-session-check-accelerated
FallbackSession=gnome-fallback
diff --git a/tools/Makefile.am b/tools/Makefile.am
index f53a012..12454d1 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,5 +1,5 @@
bin_PROGRAMS = gnome-session-quit
-libexec_PROGRAMS = gnome-session-is-accelerated
+libexec_PROGRAMS = gnome-session-check-accelerated gnome-session-check-accelerated-helper
AM_CPPFLAGS =
@@ -23,14 +23,25 @@ gnome_session_quit_LDADD = \
$(DBUS_GLIB_LIBS) \
$(GCONF_LIBS)
-gnome_session_is_accelerated_SOURCES = \
- gnome-session-is-accelerated.c
+gnome_session_check_accelerated_helper_SOURCES = \
+ gnome-session-check-accelerated-helper.c
-gnome_session_is_accelerated_CPPFLAGS = \
+gnome_session_check_accelerated_helper_CPPFLAGS = \
$(GL_TEST_CFLAGS)
-gnome_session_is_accelerated_LDADD = \
+gnome_session_check_accelerated_helper_LDADD = \
$(GL_TEST_LIBS) \
$(X_LIBS)
+gnome_session_check_accelerated_SOURCES = \
+ gnome-session-check-accelerated.c
+
+gnome_session_check_accelerated_CPPFLAGS = \
+ -DLIBEXECDIR=\""$(libexecdir)"\" \
+ $(AM_CPPFLAGS) \
+ $(GTK3_CFLAGS)
+
+gnome_session_check_accelerated_LDADD = \
+ $(GTK3_LIBS)
+
-include $(top_srcdir)/git.mk
diff --git a/tools/gnome-session-is-accelerated.c b/tools/gnome-session-check-accelerated-helper.c
similarity index 99%
rename from tools/gnome-session-is-accelerated.c
rename to tools/gnome-session-check-accelerated-helper.c
index 0729c14..3bb0dcf 100644
--- a/tools/gnome-session-is-accelerated.c
+++ b/tools/gnome-session-check-accelerated-helper.c
@@ -83,7 +83,7 @@ static int max_texture_size = 0;
static inline void
_print_error (const char *str)
{
- fprintf (stderr, "%s\n", str);
+ fprintf (stderr, "gnome-session-is-accelerated: %s\n", str);
}
static int
diff --git a/tools/gnome-session-check-accelerated.c b/tools/gnome-session-check-accelerated.c
new file mode 100644
index 0000000..7b1cb5f
--- /dev/null
+++ b/tools/gnome-session-check-accelerated.c
@@ -0,0 +1,103 @@
+/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */
+/* Tool to set the property _GNOME_SESSION_ACCELERATED on the root window */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author:
+ * Colin Walters <walters verbum org>
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <X11/Xatom.h>
+
+static void
+exit_1_message (const char *msg) G_GNUC_NORETURN;
+
+static void
+exit_1_message (const char *msg)
+{
+ g_printerr ("%s", msg);
+ exit (1);
+}
+
+int
+main (int argc, char **argv)
+{
+ GdkDisplay *display = NULL;
+ int estatus;
+ Atom is_accelerated_atom;
+ char *child_argv[] = {LIBEXECDIR "/gnome-session-check-accelerated-helper"};
+ Window rootwin;
+ glong is_accelerated;
+ GError *error = NULL;
+
+ gtk_init (NULL, NULL);
+
+ display = gdk_display_get_default ();
+ rootwin = gdk_x11_get_default_root_xwindow ();
+
+ is_accelerated_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_SESSION_ACCELERATED");
+
+ {
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+ guchar *data;
+
+ gdk_x11_display_error_trap_push (display);
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), rootwin,
+ is_accelerated_atom,
+ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+ &bytes_after, &data);
+ gdk_x11_display_error_trap_pop_ignored (display);
+
+ if (type == XA_CARDINAL) {
+ glong *is_accelerated_ptr = (glong*) data;
+ /* Exit 1 if the property is 0 (false) */
+ return (*is_accelerated_ptr == 0) ? 1 : 0;
+ }
+ }
+
+ /* We don't have the property or it's the wrong type. Try to compute it now. */
+
+ estatus = 1;
+ if (!g_spawn_sync (NULL, (char**)child_argv, NULL, 0,
+ NULL, NULL, NULL, NULL, &estatus, &error)) {
+ is_accelerated = FALSE;
+ g_printerr ("gnome-session-check-accelerated: Failed to run helper: %s\n", error->message);
+ g_clear_error (&error);
+ } else {
+ is_accelerated = (estatus == 0);
+ if (!is_accelerated)
+ g_printerr ("gnome-session-check-accelerated: Helper exited with code %d\n", estatus);
+ }
+
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ rootwin,
+ is_accelerated_atom,
+ XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_accelerated, 1);
+
+ gdk_display_sync (display);
+
+ return is_accelerated;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]