Update randr plugin
This commit is contained in:
parent
d06746449f
commit
e24287c8c1
@ -1,6 +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
|
||||||
--- 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.22.1/plugins/xrandr/gsd-xrandr-manager.c.add-randr-12 2008-03-24 17:21:50.000000000 -0400
|
||||||
+++ gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c 2008-03-24 18:23:32.000000000 -0400
|
+++ gnome-settings-daemon-2.22.1/plugins/xrandr/gsd-xrandr-manager.c 2008-04-05 12:42:41.000000000 -0400
|
||||||
@@ -35,7 +35,10 @@
|
@@ -35,15 +35,33 @@
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
@ -12,8 +13,9 @@
|
|||||||
|
|
||||||
#ifdef HAVE_RANDR
|
#ifdef HAVE_RANDR
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
@@ -44,6 +47,22 @@
|
#endif
|
||||||
#include "gnome-settings-profile.h"
|
|
||||||
|
-#include "gnome-settings-profile.h"
|
||||||
#include "gsd-xrandr-manager.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))
|
||||||
@ -35,7 +37,7 @@
|
|||||||
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 +71,74 @@ G_DEFINE_TYPE (GsdXrandrManager, gsd_xra
|
@@ -52,252 +70,74 @@ G_DEFINE_TYPE (GsdXrandrManager, gsd_xra
|
||||||
|
|
||||||
static gpointer manager_object = NULL;
|
static gpointer manager_object = NULL;
|
||||||
|
|
||||||
@ -94,11 +96,30 @@
|
|||||||
- if (val == NULL) {
|
- if (val == NULL) {
|
||||||
- return -1;
|
- 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) {
|
- if (sscanf (val, "%dx%d", &w, &h) != 2) {
|
||||||
- g_free (val);
|
- g_free (val);
|
||||||
- return -1;
|
- 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);
|
- g_free (val);
|
||||||
-
|
-
|
||||||
@ -106,10 +127,9 @@
|
|||||||
- *height = h;
|
- *height = h;
|
||||||
-
|
-
|
||||||
- return i;
|
- return i;
|
||||||
+static Atom
|
+
|
||||||
+gnome_randr_xatom (void)
|
+ /* Pass the event on to GTK+ */
|
||||||
+{
|
+ return GDK_FILTER_CONTINUE;
|
||||||
+ return gdk_x11_atom_to_xatom (gnome_randr_atom());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-static int
|
-static int
|
||||||
@ -117,29 +137,31 @@
|
|||||||
- char *display,
|
- char *display,
|
||||||
- int screen)
|
- int screen)
|
||||||
+static GdkFilterReturn
|
+static GdkFilterReturn
|
||||||
+on_client_message (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;
|
||||||
+ RWScreen *screen = data;
|
+ GsdXrandrManager *manager = data;
|
||||||
+ XEvent *ev = (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 (ev->type == ClientMessage &&
|
+ if (!manager->priv->running)
|
||||||
+ ev->xclient.message_type == gnome_randr_xatom()) {
|
+ return GDK_FILTER_CONTINUE;
|
||||||
|
|
||||||
- if (error == NULL) {
|
- if (error == NULL) {
|
||||||
- return val;
|
- return val;
|
||||||
- }
|
- }
|
||||||
-
|
-
|
||||||
- g_error_free (error);
|
- g_error_free (error);
|
||||||
+ configuration_apply_stored (screen);
|
+ /* verify we have a key event */
|
||||||
|
+ if (xev->xany.type != KeyPress && xev->xany.type != KeyRelease)
|
||||||
|
+ return GDK_FILTER_CONTINUE;
|
||||||
|
|
||||||
- return 0;
|
- return 0;
|
||||||
-}
|
-}
|
||||||
@ -166,21 +188,23 @@
|
|||||||
- closest_width = sizes[i].width;
|
- closest_width = sizes[i].width;
|
||||||
- closest_height = sizes[i].height;
|
- closest_height = sizes[i].height;
|
||||||
- }
|
- }
|
||||||
+ return GDK_FILTER_REMOVE;
|
+ 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);
|
||||||
|
+
|
||||||
|
+ return GDK_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
- return closest;
|
- return closest;
|
||||||
+ /* Pass the event on to GTK+ */
|
|
||||||
+ return GDK_FILTER_CONTINUE;
|
+ return GDK_FILTER_CONTINUE;
|
||||||
}
|
}
|
||||||
-#endif /* HAVE_RANDR */
|
-#endif /* HAVE_RANDR */
|
||||||
|
|
||||||
-static void
|
static void
|
||||||
-apply_settings (GsdXrandrManager *manager)
|
-apply_settings (GsdXrandrManager *manager)
|
||||||
+static GdkFilterReturn
|
+on_randr_event (RWScreen *screen, gpointer data)
|
||||||
+event_filter (GdkXEvent *xevent,
|
|
||||||
+ GdkEvent *event,
|
|
||||||
+ gpointer data)
|
|
||||||
{
|
{
|
||||||
-#ifdef HAVE_RANDR
|
-#ifdef HAVE_RANDR
|
||||||
- GdkDisplay *display;
|
- GdkDisplay *display;
|
||||||
@ -222,13 +246,9 @@
|
|||||||
- g_message ("Display has unsupported version of XRandR (%d.%d), not setting resolution.", major, minor);
|
- g_message ("Display has unsupported version of XRandR (%d.%d), not setting resolution.", major, minor);
|
||||||
- goto out;
|
- goto out;
|
||||||
- }
|
- }
|
||||||
+ GsdXrandrManager *manager = data;
|
-
|
||||||
+ XEvent *xev = (XEvent *) xevent;
|
|
||||||
|
|
||||||
- client = gconf_client_get_default ();
|
- client = gconf_client_get_default ();
|
||||||
+ if (!manager->priv->running)
|
-
|
||||||
+ return GDK_FILTER_CONTINUE;
|
|
||||||
|
|
||||||
- i = 0;
|
- i = 0;
|
||||||
- specific_path = NULL;
|
- specific_path = NULL;
|
||||||
- if (gethostname (hostname, sizeof (hostname)) == 0) {
|
- if (gethostname (hostname, sizeof (hostname)) == 0) {
|
||||||
@ -237,10 +257,7 @@
|
|||||||
- }
|
- }
|
||||||
- keys[i++] = "/desktop/gnome/screen/default";
|
- keys[i++] = "/desktop/gnome/screen/default";
|
||||||
- keys[i++] = NULL;
|
- keys[i++] = NULL;
|
||||||
+ /* verify we have a key event */
|
-
|
||||||
+ if (xev->xany.type != KeyPress && xev->xany.type != KeyRelease)
|
|
||||||
+ return GDK_FILTER_CONTINUE;
|
|
||||||
|
|
||||||
- n_screens = gdk_display_get_n_screens (display);
|
- n_screens = gdk_display_get_n_screens (display);
|
||||||
- for (i = 0; i < n_screens; i++) {
|
- for (i = 0; i < n_screens; i++) {
|
||||||
- screen = gdk_display_get_screen (display, i);
|
- screen = gdk_display_get_screen (display, i);
|
||||||
@ -295,85 +312,86 @@
|
|||||||
- rate,
|
- rate,
|
||||||
- GDK_CURRENT_TIME);
|
- GDK_CURRENT_TIME);
|
||||||
- }
|
- }
|
||||||
+ 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);
|
|
||||||
|
|
||||||
- XRRFreeScreenConfigInfo (config);
|
- XRRFreeScreenConfigInfo (config);
|
||||||
- }
|
- }
|
||||||
+ return GDK_FILTER_CONTINUE;
|
- }
|
||||||
}
|
+ GsdXrandrManager *manager = data;
|
||||||
|
|
||||||
- g_free (specific_path);
|
- g_free (specific_path);
|
||||||
-
|
-
|
||||||
- /* 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);
|
||||||
+ return GDK_FILTER_CONTINUE;
|
-
|
||||||
+}
|
|
||||||
|
|
||||||
- while (gtk_events_pending ()) {
|
- while (gtk_events_pending ()) {
|
||||||
- gtk_main_iteration ();
|
- gtk_main_iteration ();
|
||||||
- }
|
- }
|
||||||
+static void
|
-
|
||||||
+on_randr_event (RWScreen *screen, gpointer data)
|
|
||||||
+{
|
|
||||||
+ GsdXrandrManager *manager = data;
|
|
||||||
|
|
||||||
- if (client != NULL) {
|
- if (client != NULL) {
|
||||||
- g_object_unref (client);
|
- g_object_unref (client);
|
||||||
- }
|
- }
|
||||||
- out:
|
- out:
|
||||||
- gnome_settings_profile_end (NULL);
|
- gnome_settings_profile_end (NULL);
|
||||||
|
-
|
||||||
|
-#endif /* HAVE_RANDR */
|
||||||
+ if (!manager->priv->running)
|
+ if (!manager->priv->running)
|
||||||
+ return;
|
+ return;
|
||||||
|
+
|
||||||
-#endif /* HAVE_RANDR */
|
|
||||||
+ /* FIXME: Set up any new screens here */
|
+ /* FIXME: Set up any new screens here */
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@@ -306,7 +147,24 @@ gsd_xrandr_manager_start (GsdXrandrManag
|
@@ -306,8 +146,30 @@ gsd_xrandr_manager_start (GsdXrandrManag
|
||||||
{
|
{
|
||||||
g_debug ("Starting xrandr manager");
|
g_debug ("Starting xrandr manager");
|
||||||
|
|
||||||
- apply_settings (manager);
|
- apply_settings (manager);
|
||||||
|
-
|
||||||
+ manager->priv->running = TRUE;
|
+ manager->priv->running = TRUE;
|
||||||
+
|
+
|
||||||
+ if (manager->priv->keycode) {
|
+ if (manager->priv->keycode) {
|
||||||
|
+ gdk_error_trap_push ();
|
||||||
|
+
|
||||||
+ XGrabKey (gdk_x11_get_default_xdisplay(),
|
+ XGrabKey (gdk_x11_get_default_xdisplay(),
|
||||||
+ manager->priv->keycode, AnyModifier,
|
+ manager->priv->keycode, AnyModifier,
|
||||||
+ gdk_x11_get_default_root_xwindow(),
|
+ gdk_x11_get_default_root_xwindow(),
|
||||||
+ True, GrabModeAsync, GrabModeAsync);
|
+ True, GrabModeAsync, GrabModeAsync);
|
||||||
|
+
|
||||||
|
+ gdk_flush ();
|
||||||
|
+ gdk_error_trap_pop ();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ configuration_apply_stored (manager->priv->rw_screen);
|
+ configuration_apply_stored (manager->priv->rw_screen);
|
||||||
+
|
+
|
||||||
+ gdk_window_add_filter (gdk_get_default_root_window(),
|
+ gdk_window_add_filter (gdk_get_default_root_window(),
|
||||||
+ (GdkFilterFunc)event_filter,
|
+ (GdkFilterFunc)event_filter,
|
||||||
+ manager);
|
+ manager);
|
||||||
+
|
+
|
||||||
+ gdk_add_client_message_filter (gnome_randr_atom(),
|
+ gdk_add_client_message_filter (gnome_randr_atom(),
|
||||||
+ on_client_message,
|
+ on_client_message,
|
||||||
+ manager->priv->rw_screen);
|
+ manager->priv->rw_screen);
|
||||||
|
+
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -315,6 +173,12 @@ void
|
|
||||||
|
@@ -315,6 +177,16 @@ void
|
||||||
gsd_xrandr_manager_stop (GsdXrandrManager *manager)
|
gsd_xrandr_manager_stop (GsdXrandrManager *manager)
|
||||||
{
|
{
|
||||||
g_debug ("Stopping xrandr manager");
|
g_debug ("Stopping xrandr manager");
|
||||||
+
|
+
|
||||||
+ manager->priv->running = FALSE;
|
+ manager->priv->running = FALSE;
|
||||||
+
|
+
|
||||||
|
+ gdk_error_trap_push ();
|
||||||
|
+
|
||||||
+ XUngrabKey (gdk_x11_get_default_xdisplay(),
|
+ XUngrabKey (gdk_x11_get_default_xdisplay(),
|
||||||
+ manager->priv->keycode, AnyModifier,
|
+ manager->priv->keycode, AnyModifier,
|
||||||
+ gdk_x11_get_default_root_xwindow());
|
+ gdk_x11_get_default_root_xwindow());
|
||||||
|
+
|
||||||
|
+ gdk_error_trap_pop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -388,11 +252,22 @@ gsd_xrandr_manager_class_init (GsdXrandr
|
@@ -388,11 +260,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;
|
||||||
@ -387,7 +405,7 @@
|
|||||||
+ Display *dpy = gdk_x11_get_default_xdisplay ();
|
+ Display *dpy = gdk_x11_get_default_xdisplay ();
|
||||||
+ guint keyval = gdk_keyval_from_name (VIDEO_KEYSYM);
|
+ guint keyval = gdk_keyval_from_name (VIDEO_KEYSYM);
|
||||||
+ guint keycode = XKeysymToKeycode (dpy, keyval);
|
+ guint keycode = XKeysymToKeycode (dpy, keyval);
|
||||||
+
|
+
|
||||||
+ manager->priv = GSD_XRANDR_MANAGER_GET_PRIVATE (manager);
|
+ manager->priv = GSD_XRANDR_MANAGER_GET_PRIVATE (manager);
|
||||||
+
|
+
|
||||||
+ manager->priv->keycode = keycode;
|
+ manager->priv->keycode = keycode;
|
||||||
@ -396,7 +414,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -405,6 +280,8 @@ gsd_xrandr_manager_finalize (GObject *ob
|
@@ -405,6 +288,8 @@ gsd_xrandr_manager_finalize (GObject *ob
|
||||||
|
|
||||||
xrandr_manager = GSD_XRANDR_MANAGER (object);
|
xrandr_manager = GSD_XRANDR_MANAGER (object);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Name: gnome-settings-daemon
|
Name: gnome-settings-daemon
|
||||||
Version: 2.22.1
|
Version: 2.22.1
|
||||||
Release: 0.2008.03.26.4%{?dist}
|
Release: 0.2008.03.26.5%{?dist}
|
||||||
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
|
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
|
||||||
|
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
@ -140,6 +140,9 @@ fi
|
|||||||
%{_libdir}/pkgconfig/gnome-settings-daemon.pc
|
%{_libdir}/pkgconfig/gnome-settings-daemon.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat Apr 5 2008 - Soren Sandmann <sandmann@redhat.com> - 2.22.1-2008.03.26.5
|
||||||
|
- Update randr plugin
|
||||||
|
|
||||||
* Mon Mar 31 2008 - Ray Strode <rstrode@redhat.com> - 2.22.1-0.2008.03.26.4
|
* Mon Mar 31 2008 - Ray Strode <rstrode@redhat.com> - 2.22.1-0.2008.03.26.4
|
||||||
- Over the releases we've accumulated default.png, default-wide.png default-5_4.png
|
- Over the releases we've accumulated default.png, default-wide.png default-5_4.png
|
||||||
and default.jpg. We haven't been able to drop them because it would leave some
|
and default.jpg. We haven't been able to drop them because it would leave some
|
||||||
|
Loading…
Reference in New Issue
Block a user