This commit is contained in:
Matthias Clasen 2008-04-26 19:00:43 +00:00
parent 9191d90fc5
commit 338db4d78e

View File

@ -1,7 +1,7 @@
diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c diff -up gnome-settings-daemon-2.23.1.1/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 gnome-settings-daemon-2.23.1.1/plugins/xrandr/gsd-xrandr-manager.c
--- gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 2008-03-24 17:21:50.000000000 -0400 --- gnome-settings-daemon-2.23.1.1/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 2008-04-23 06:38:37.000000000 -0400
+++ gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c 2008-04-05 12:42:41.000000000 -0400 +++ gnome-settings-daemon-2.23.1.1/plugins/xrandr/gsd-xrandr-manager.c 2008-04-26 14:57:00.000000000 -0400
@@ -35,15 +35,33 @@ @@ -35,7 +35,10 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk/gdkx.h> #include <gdk/gdkx.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -13,31 +13,30 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
#ifdef HAVE_RANDR #ifdef HAVE_RANDR
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
@@ -48,6 +51,22 @@
#define HOST_NAME_MAX 255
#endif #endif
-#include "gnome-settings-profile.h"
#include "gsd-xrandr-manager.h"
+#define GSD_XRANDR_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_XRANDR_MANAGER, GsdXrandrManagerPrivate)) +#define GSD_XRANDR_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_XRANDR_MANAGER, GsdXrandrManagerPrivate))
+ +
+#define VIDEO_KEYSYM "XF86Display" +#define VIDEO_KEYSYM "XF86Display"
+ +
+struct GsdXrandrManagerPrivate +struct GsdXrandrManagerPrivate
+{ +{
+ /* Key code of the fn-F7 video key (XF86Display) */ + /* Key code of the fn-F7 video key (XF86Display) */
+ guint keycode; + guint keycode;
+ RWScreen *rw_screen; + RWScreen *rw_screen;
+ gboolean running; + gboolean running;
+}; +};
+ +
+enum { +enum {
+ PROP_0, + PROP_0,
+}; +};
+ +
static void gsd_xrandr_manager_class_init (GsdXrandrManagerClass *klass); static void gsd_xrandr_manager_class_init (GsdXrandrManagerClass *klass);
static void gsd_xrandr_manager_init (GsdXrandrManager *xrandr_manager); static void gsd_xrandr_manager_init (GsdXrandrManager *xrandr_manager);
static void gsd_xrandr_manager_finalize (GObject *object); static void gsd_xrandr_manager_finalize (GObject *object);
@@ -52,252 +70,74 @@ G_DEFINE_TYPE (GsdXrandrManager, gsd_xra @@ -56,248 +75,74 @@ G_DEFINE_TYPE (GsdXrandrManager, gsd_xra
static gpointer manager_object = NULL; static gpointer manager_object = NULL;
@ -66,7 +65,7 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
+static GdkAtom +static GdkAtom
+gnome_randr_atom (void) +gnome_randr_atom (void)
+{ +{
+ return gdk_atom_intern ("_GNOME_RANDR_ATOM", FALSE); + return gdk_atom_intern ("_GNOME_RANDR_ATOM", FALSE);
} }
-static int -static int
@ -99,37 +98,35 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
+static Atom +static Atom
+gnome_randr_xatom (void) +gnome_randr_xatom (void)
+{ +{
+ return gdk_x11_atom_to_xatom (gnome_randr_atom()); + return gdk_x11_atom_to_xatom (gnome_randr_atom());
+} +}
- if (sscanf (val, "%dx%d", &w, &h) != 2) { - if (sscanf (val, "%dx%d", &w, &h) != 2) {
- g_free (val); - g_free (val);
- return -1; - return -1;
- }
+static GdkFilterReturn +static GdkFilterReturn
+on_client_message (GdkXEvent *xevent, +on_client_message (GdkXEvent *xevent,
+ GdkEvent *event, + GdkEvent *event,
+ gpointer data) + gpointer data)
+{ +{
+ RWScreen *screen = data; + RWScreen *screen = data;
+ XEvent *ev = (XEvent *)xevent; + XEvent *ev = (XEvent *)xevent;
+ +
+ if (ev->type == ClientMessage && + if (ev->type == ClientMessage &&
+ ev->xclient.message_type == gnome_randr_xatom()) { + ev->xclient.message_type == gnome_randr_xatom()) {
+
+ configuration_apply_stored (screen);
+
+ return GDK_FILTER_REMOVE;
}
-
- g_free (val); - g_free (val);
- + configuration_apply_stored (screen);
- *width = w; - *width = w;
- *height = h; - *height = h;
- + return GDK_FILTER_REMOVE;
+ }
- return i; - return i;
+ + /* Pass the event on to GTK+ */
+ /* Pass the event on to GTK+ */ + return GDK_FILTER_CONTINUE;
+ return GDK_FILTER_CONTINUE;
} }
-static int -static int
@ -138,30 +135,35 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
- int screen) - int screen)
+static GdkFilterReturn +static GdkFilterReturn
+event_filter (GdkXEvent *xevent, +event_filter (GdkXEvent *xevent,
+ GdkEvent *event, + GdkEvent *event,
+ gpointer data) + gpointer data)
{ {
- char *key; - char *key;
- int val; - int val;
- GError *error; - GError *error;
+ GsdXrandrManager *manager = data; + GsdXrandrManager *manager = data;
+ XEvent *xev = (XEvent *) xevent; + XEvent *xev = (XEvent *) xevent;
- key = g_strdup_printf ("%s/%d/rate", display, screen); - key = g_strdup_printf ("%s/%d/rate", display, screen);
- error = NULL; - error = NULL;
- val = gconf_client_get_int (client, key, &error); - val = gconf_client_get_int (client, key, &error);
- g_free (key); - g_free (key);
+ if (!manager->priv->running) + if (!manager->priv->running)
+ return GDK_FILTER_CONTINUE; + return GDK_FILTER_CONTINUE;
- if (error == NULL) { - if (error == NULL) {
- return val; - return val;
- } - }
- + /* verify we have a key event */
+ if (xev->xany.type != KeyPress && xev->xany.type != KeyRelease)
+ return GDK_FILTER_CONTINUE;
- g_error_free (error); - g_error_free (error);
+ /* verify we have a key event */ + if (xev->xkey.keycode == manager->priv->keycode) {
+ if (xev->xany.type != KeyPress && xev->xany.type != KeyRelease) + /* FIXME: here we should cycle between valid
+ return GDK_FILTER_CONTINUE; + * configurations, and save them
+ */
+ configuration_apply_stored (manager->priv->rw_screen);
- return 0; - return 0;
-} -}
@ -188,17 +190,12 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
- closest_width = sizes[i].width; - closest_width = sizes[i].width;
- closest_height = sizes[i].height; - closest_height = sizes[i].height;
- } - }
+ if (xev->xkey.keycode == manager->priv->keycode) { - }
+ /* FIXME: here we should cycle between valid + return GDK_FILTER_CONTINUE;
+ * configurations, and save them + }
+ */
+ configuration_apply_stored (manager->priv->rw_screen);
+
+ return GDK_FILTER_CONTINUE;
}
- return closest; - return closest;
+ return GDK_FILTER_CONTINUE; + return GDK_FILTER_CONTINUE;
} }
-#endif /* HAVE_RANDR */ -#endif /* HAVE_RANDR */
@ -221,11 +218,7 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
- int height; - int height;
- int rate; - int rate;
- int rotation; - int rotation;
-#ifdef HOST_NAME_MAX
- char hostname[HOST_NAME_MAX + 1]; - char hostname[HOST_NAME_MAX + 1];
-#else
- char hostname[256];
-#endif
- char *specific_path; - char *specific_path;
- char *keys[3]; - char *keys[3];
- int i; - int i;
@ -316,10 +309,10 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
- XRRFreeScreenConfigInfo (config); - XRRFreeScreenConfigInfo (config);
- } - }
- } - }
+ GsdXrandrManager *manager = data;
- g_free (specific_path);
- -
- g_free (specific_path);
+ GsdXrandrManager *manager = data;
- /* We need to make sure we process the screen resize event. */ - /* We need to make sure we process the screen resize event. */
- gdk_display_sync (display); - gdk_display_sync (display);
- -
@ -334,14 +327,14 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
- gnome_settings_profile_end (NULL); - gnome_settings_profile_end (NULL);
- -
-#endif /* HAVE_RANDR */ -#endif /* HAVE_RANDR */
+ if (!manager->priv->running) + if (!manager->priv->running)
+ return; + return;
+ +
+ /* FIXME: Set up any new screens here */ + /* FIXME: Set up any new screens here */
} }
gboolean gboolean
@@ -306,8 +146,30 @@ gsd_xrandr_manager_start (GsdXrandrManag @@ -306,8 +151,30 @@ gsd_xrandr_manager_start (GsdXrandrManag
{ {
g_debug ("Starting xrandr manager"); g_debug ("Starting xrandr manager");
@ -374,7 +367,7 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
return TRUE; return TRUE;
} }
@@ -315,6 +177,16 @@ void @@ -315,6 +182,16 @@ void
gsd_xrandr_manager_stop (GsdXrandrManager *manager) gsd_xrandr_manager_stop (GsdXrandrManager *manager)
{ {
g_debug ("Stopping xrandr manager"); g_debug ("Stopping xrandr manager");
@ -391,7 +384,7 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
} }
static void static void
@@ -388,11 +260,22 @@ gsd_xrandr_manager_class_init (GsdXrandr @@ -388,11 +265,22 @@ gsd_xrandr_manager_class_init (GsdXrandr
object_class->constructor = gsd_xrandr_manager_constructor; object_class->constructor = gsd_xrandr_manager_constructor;
object_class->dispose = gsd_xrandr_manager_dispose; object_class->dispose = gsd_xrandr_manager_dispose;
object_class->finalize = gsd_xrandr_manager_finalize; object_class->finalize = gsd_xrandr_manager_finalize;
@ -414,7 +407,7 @@ diff -up gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-ra
} }
static void static void
@@ -405,6 +288,8 @@ gsd_xrandr_manager_finalize (GObject *ob @@ -405,6 +293,8 @@ gsd_xrandr_manager_finalize (GObject *ob
xrandr_manager = GSD_XRANDR_MANAGER (object); xrandr_manager = GSD_XRANDR_MANAGER (object);