Handle video key
This commit is contained in:
parent
08ee65418e
commit
2946d2f3dc
@ -1,6 +1,6 @@
|
||||
diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c
|
||||
--- gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 2007-12-24 06:18:48.000000000 -0500
|
||||
+++ gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c 2008-02-12 14:42:57.000000000 -0500
|
||||
+++ gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c 2008-03-02 17:26:08.000000000 -0500
|
||||
@@ -36,6 +36,10 @@
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
@ -12,7 +12,23 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
#ifdef HAVE_RANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
@@ -61,258 +65,60 @@ G_DEFINE_TYPE (GsdXrandrManager, gsd_xra
|
||||
@@ -44,9 +48,14 @@
|
||||
|
||||
#define GSD_XRANDR_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_XRANDR_MANAGER, GsdXrandrManagerPrivate))
|
||||
|
||||
+#define VIDEO_KEYSYM "XF86Display"
|
||||
+
|
||||
struct GsdXrandrManagerPrivate
|
||||
{
|
||||
- gboolean dummy;
|
||||
+ /* Key code of the fn-F7 video key (XF86Display) */
|
||||
+ guint keycode;
|
||||
+ RWScreen *rw_screen;
|
||||
+ gboolean running;
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -61,248 +70,74 @@ G_DEFINE_TYPE (GsdXrandrManager, gsd_xra
|
||||
|
||||
static gpointer manager_object = NULL;
|
||||
|
||||
@ -38,8 +54,12 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- g_error_free (error);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
+static GdkAtom
|
||||
+gnome_randr_atom (void)
|
||||
+{
|
||||
+ return gdk_atom_intern ("_GNOME_RANDR_ATOM", FALSE);
|
||||
}
|
||||
|
||||
-static int
|
||||
-get_resolution (GConfClient *client,
|
||||
- int screen,
|
||||
@ -67,11 +87,30 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- if (val == NULL) {
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
+static Atom
|
||||
+gnome_randr_xatom (void)
|
||||
+{
|
||||
+ return gdk_x11_atom_to_xatom (gnome_randr_atom());
|
||||
+}
|
||||
|
||||
- if (sscanf (val, "%dx%d", &w, &h) != 2) {
|
||||
- g_free (val);
|
||||
- return -1;
|
||||
- }
|
||||
+static GdkFilterReturn
|
||||
+on_client_message (GdkXEvent *xevent,
|
||||
+ GdkEvent *event,
|
||||
+ gpointer data)
|
||||
+{
|
||||
+ RWScreen *screen = data;
|
||||
+ XEvent *ev = (XEvent *)xevent;
|
||||
+
|
||||
+ if (ev->type == ClientMessage &&
|
||||
+ ev->xclient.message_type == gnome_randr_xatom()) {
|
||||
+
|
||||
+ configuration_apply_stored (screen);
|
||||
+
|
||||
+ return GDK_FILTER_REMOVE;
|
||||
}
|
||||
-
|
||||
- g_free (val);
|
||||
-
|
||||
@ -79,18 +118,19 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- *height = h;
|
||||
-
|
||||
- return i;
|
||||
+static GdkAtom
|
||||
+gnome_randr_atom (void)
|
||||
+{
|
||||
+ return gdk_atom_intern ("_GNOME_RANDR_ATOM", FALSE);
|
||||
+
|
||||
+ /* Pass the event on to GTK+ */
|
||||
+ return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
-static int
|
||||
-get_rate (GConfClient *client,
|
||||
- char *display,
|
||||
- int screen)
|
||||
+static Atom
|
||||
+gnome_randr_xatom (void)
|
||||
+static GdkFilterReturn
|
||||
+event_filter (GdkXEvent *xevent,
|
||||
+ GdkEvent *event,
|
||||
+ gpointer data)
|
||||
{
|
||||
- char *key;
|
||||
- int val;
|
||||
@ -100,16 +140,22 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- error = NULL;
|
||||
- val = gconf_client_get_int (client, key, &error);
|
||||
- g_free (key);
|
||||
-
|
||||
+ GsdXrandrManager *manager = data;
|
||||
+ XEvent *xev = (XEvent *) xevent;
|
||||
|
||||
- if (error == NULL) {
|
||||
- return val;
|
||||
- }
|
||||
-
|
||||
+ if (!manager->priv->running)
|
||||
+ return GDK_FILTER_CONTINUE;
|
||||
|
||||
- g_error_free (error);
|
||||
-
|
||||
- return 0;
|
||||
+ return gdk_x11_atom_to_xatom (gnome_randr_atom());
|
||||
}
|
||||
-}
|
||||
+ /* verify we have a key event */
|
||||
+ if (xev->xany.type != KeyPress && xev->xany.type != KeyRelease)
|
||||
+ return GDK_FILTER_CONTINUE;
|
||||
|
||||
-static int
|
||||
-find_closest_size (XRRScreenSize *sizes,
|
||||
@ -133,25 +179,16 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- closest_width = sizes[i].width;
|
||||
- closest_height = sizes[i].height;
|
||||
- }
|
||||
+static GdkFilterReturn
|
||||
+on_client_message (GdkXEvent *xevent,
|
||||
+ GdkEvent *event,
|
||||
+ gpointer data)
|
||||
+{
|
||||
+ RWScreen *screen = data;
|
||||
+ XEvent *ev = (XEvent *)xevent;
|
||||
+
|
||||
+ if (ev->type == ClientMessage &&
|
||||
+ ev->xclient.message_type == gnome_randr_xatom()) {
|
||||
+ if (xev->xkey.keycode == manager->priv->keycode) {
|
||||
+ /* FIXME: here we should cycle between valid
|
||||
+ * configurations, and save them
|
||||
+ */
|
||||
+ configuration_apply_stored (manager->priv->rw_screen);
|
||||
+
|
||||
+ configuration_apply_stored (screen);
|
||||
+
|
||||
+ return GDK_FILTER_REMOVE;
|
||||
+ return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
-
|
||||
|
||||
- return closest;
|
||||
+
|
||||
+ /* Pass the event on to GTK+ */
|
||||
+ return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
-#endif /* HAVE_RANDR */
|
||||
@ -193,10 +230,12 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- || XRRQueryVersion (xdisplay, &major, &minor) == 0) {
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
+ GsdXrandrManager *manager = data;
|
||||
|
||||
- if (major != 1 || minor < 1) {
|
||||
- g_message ("Display has unsupported version of XRandR (%d.%d), not setting resolution.", major, minor);
|
||||
- return;
|
||||
+ if (!manager->priv->running)
|
||||
return;
|
||||
- }
|
||||
-
|
||||
- client = gconf_client_get_default ();
|
||||
@ -283,27 +322,65 @@ diff -up gnome-settings-daemon-2.21.91/plugins/xrandr/gsd-xrandr-manager.c.add-r
|
||||
- }
|
||||
-
|
||||
-#endif /* HAVE_RANDR */
|
||||
+
|
||||
+ /* FIXME: Set up any new screens here */
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsd_xrandr_manager_start (GsdXrandrManager *manager,
|
||||
GError **error)
|
||||
@@ -311,8 +146,25 @@ gsd_xrandr_manager_start (GsdXrandrManag
|
||||
{
|
||||
+ RWScreen *rw_screen;
|
||||
+
|
||||
g_debug ("Starting xrandr manager");
|
||||
+
|
||||
+ rw_screen = rw_screen_new (gdk_screen_get_default(), on_randr_event, NULL);
|
||||
|
||||
- apply_settings (manager);
|
||||
-
|
||||
+ configuration_apply_stored (rw_screen);
|
||||
+ manager->priv->running = TRUE;
|
||||
+
|
||||
+ if (manager->priv->keycode) {
|
||||
+ XGrabKey (gdk_x11_get_default_xdisplay(),
|
||||
+ manager->priv->keycode, AnyModifier,
|
||||
+ gdk_x11_get_default_root_xwindow(),
|
||||
+ True, GrabModeAsync, GrabModeAsync);
|
||||
+ }
|
||||
+
|
||||
+ configuration_apply_stored (manager->priv->rw_screen);
|
||||
+
|
||||
+ gdk_window_add_filter (gdk_get_default_root_window(),
|
||||
+ (GdkFilterFunc)event_filter,
|
||||
+ manager);
|
||||
+
|
||||
+ gdk_add_client_message_filter (gnome_randr_atom(),
|
||||
+ on_client_message,
|
||||
+ rw_screen);
|
||||
+ manager->priv->rw_screen);
|
||||
+
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -320,6 +172,12 @@ void
|
||||
gsd_xrandr_manager_stop (GsdXrandrManager *manager)
|
||||
{
|
||||
g_debug ("Stopping xrandr manager");
|
||||
+
|
||||
+ manager->priv->running = FALSE;
|
||||
+
|
||||
+ XUngrabKey (gdk_x11_get_default_xdisplay(),
|
||||
+ manager->priv->keycode, AnyModifier,
|
||||
+ gdk_x11_get_default_root_xwindow());
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -400,8 +258,15 @@ gsd_xrandr_manager_class_init (GsdXrandr
|
||||
static void
|
||||
gsd_xrandr_manager_init (GsdXrandrManager *manager)
|
||||
{
|
||||
+ Display *dpy = gdk_x11_get_default_xdisplay ();
|
||||
+ guint keyval = gdk_keyval_from_name (VIDEO_KEYSYM);
|
||||
+ guint keycode = XKeysymToKeycode (dpy, keyval);
|
||||
+
|
||||
manager->priv = GSD_XRANDR_MANAGER_GET_PRIVATE (manager);
|
||||
|
||||
+ manager->priv->keycode = keycode;
|
||||
+ manager->priv->rw_screen = rw_screen_new (
|
||||
+ gdk_screen_get_default(), on_randr_event, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name: gnome-settings-daemon
|
||||
Version: 2.21.92
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
|
||||
|
||||
Group: System Environment/Daemons
|
||||
@ -123,6 +123,9 @@ fi
|
||||
%{_libdir}/pkgconfig/gnome-settings-daemon.pc
|
||||
|
||||
%changelog
|
||||
* Sun Mar 2 2008 Soren Sandmann <sandmann@redhat.com> - 2.21.92-2
|
||||
- Update randr patch to handle video key
|
||||
|
||||
* Fri Feb 29 2008 Jon McCann <jmccann@redhat.com> - 2.21.92-1
|
||||
- Update to 2.21.92
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user