[gnome-power-manager] Do not handle the brightness keys, it's all now done in gnome-settings-daemon



commit c571716464d08a5d4005d6a5f72ac02de44ecfc2
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jul 4 12:30:24 2011 +0100

    Do not handle the brightness keys, it's all now done in gnome-settings-daemon

 src/gpm-backlight.c |   40 +--------------
 src/gpm-button.c    |  146 ---------------------------------------------------
 src/gpm-button.h    |    2 -
 3 files changed, 1 insertions(+), 187 deletions(-)
---
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index a82b5bd..fc2ef33 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -364,47 +364,9 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
 {
 	gboolean ret;
 	GError *error = NULL;
-	guint percentage;
-	gboolean hw_changed;
 	g_debug ("Button press event type=%s", type);
 
-	if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_UP) == 0) {
-		/* go up one step */
-		ret = gpm_brightness_up (backlight->priv->brightness, &hw_changed);
-
-		/* show the new value */
-		if (ret) {
-			gpm_brightness_get (backlight->priv->brightness, &percentage);
-			gpm_osd_dialog_init (&backlight->priv->popup, "display-brightness-symbolic");
-			gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
-								percentage);
-			gpm_osd_dialog_show (backlight->priv->popup);
-			/* save the new percentage */
-			backlight->priv->master_percentage = percentage;
-		}
-		/* we emit a signal for the brightness applet */
-		if (ret && hw_changed)
-			gpm_backlight_brightness_changed (backlight, percentage);
-
-	} else if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_DOWN) == 0) {
-		/* go up down step */
-		ret = gpm_brightness_down (backlight->priv->brightness, &hw_changed);
-
-		/* show the new value */
-		if (ret) {
-			gpm_brightness_get (backlight->priv->brightness, &percentage);
-			gpm_osd_dialog_init (&backlight->priv->popup, "display-brightness-symbolic");
-			gsd_media_keys_window_set_volume_level (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
-								percentage);
-			gpm_osd_dialog_show (backlight->priv->popup);
-			/* save the new percentage */
-			backlight->priv->master_percentage = percentage;
-		}
-		/* we emit a signal for the brightness applet */
-		if (ret && hw_changed)
-			gpm_backlight_brightness_changed (backlight, percentage);
-
-	} else if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0) {
+	if (g_strcmp0 (type, GPM_BUTTON_LID_OPEN) == 0) {
 		/* make sure we undim when we lift the lid */
 		gpm_backlight_brightness_evaluate_and_set (backlight, FALSE);
 
diff --git a/src/gpm-button.c b/src/gpm-button.c
index 1fa947b..a795cd6 100644
--- a/src/gpm-button.c
+++ b/src/gpm-button.c
@@ -88,145 +88,6 @@ gpm_button_emit_type (GpmButton *button, const gchar *type)
 }
 
 /**
- * gpm_button_filter_x_events:
- **/
-static GdkFilterReturn
-gpm_button_filter_x_events (GdkXEvent *xevent, GdkEvent *event, gpointer data)
-{
-	GpmButton *button = (GpmButton *) data;
-	XEvent *xev = (XEvent *) xevent;
-	guint keycode;
-	const gchar *key;
-	gchar *keycode_str;
-
-	if (xev->type != KeyPress)
-		return GDK_FILTER_CONTINUE;
-
-	keycode = xev->xkey.keycode;
-
-	/* is the key string already in our DB? */
-	keycode_str = g_strdup_printf ("0x%x", keycode);
-	key = g_hash_table_lookup (button->priv->keysym_to_name_hash, (gpointer) keycode_str);
-	g_free (keycode_str);
-
-	/* found anything? */
-	if (key == NULL) {
-		g_debug ("Key %i not found in hash", keycode);
-		/* pass normal keypresses on, which might help with accessibility access */
-		return GDK_FILTER_CONTINUE;
-	}
-
-	g_debug ("Key %i mapped to key %s", keycode, key);
-	gpm_button_emit_type (button, key);
-
-	return GDK_FILTER_REMOVE;
-}
-
-/**
- * gpm_button_grab_keystring:
- * @button: This button class instance
- * @keystr: The key string, e.g. "<Control><Alt>F11"
- * @hashkey: A unique key made up from the modmask and keycode suitable for
- *           referencing in a hashtable.
- *           You must free this string, or specify NULL to ignore.
- *
- * Grab the key specified in the key string.
- *
- * Return value: TRUE if we parsed and grabbed okay
- **/
-static gboolean
-gpm_button_grab_keystring (GpmButton *button, guint64 keycode)
-{
-	guint modmask = AnyModifier;
-	Display *display;
-	gint ret;
-
-	/* get the current X Display */
-	display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default());
-
-	/* don't abort on error */
-	gdk_error_trap_push ();
-
-	/* grab the key if possible */
-	ret = XGrabKey (display, keycode, modmask,
-			GDK_WINDOW_XID (button->priv->window), True,
-			GrabModeAsync, GrabModeAsync);
-	if (ret == BadAccess) {
-		g_warning ("Failed to grab modmask=%u, keycode=%li",
-			     modmask, (long int) keycode);
-		return FALSE;
-	}
-
-	/* grab the lock key if possible */
-	ret = XGrabKey (display, keycode, LockMask | modmask,
-			GDK_WINDOW_XID (button->priv->window), True,
-			GrabModeAsync, GrabModeAsync);
-	if (ret == BadAccess) {
-		g_warning ("Failed to grab modmask=%u, keycode=%li",
-			     LockMask | modmask, (long int) keycode);
-		return FALSE;
-	}
-
-	/* we are not processing the error */
-	gdk_flush ();
-	gdk_error_trap_pop_ignored ();
-
-	g_debug ("Grabbed modmask=%x, keycode=%li", modmask, (long int) keycode);
-	return TRUE;
-}
-
-/**
- * gpm_button_grab_keystring:
- * @button: This button class instance
- * @keystr: The key string, e.g. "<Control><Alt>F11"
- * @hashkey: A unique key made up from the modmask and keycode suitable for
- *           referencing in a hashtable.
- *           You must free this string, or specify NULL to ignore.
- *
- * Grab the key specified in the key string.
- *
- * Return value: TRUE if we parsed and grabbed okay
- **/
-static gboolean
-gpm_button_xevent_key (GpmButton *button, guint keysym, const gchar *key_name)
-{
-	gchar *key = NULL;
-	gboolean ret;
-	gchar *keycode_str;
-	guint keycode;
-
-	/* convert from keysym to keycode */
-	keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default()), keysym);
-	if (keycode == 0) {
-		g_warning ("could not map keysym %x to keycode", keysym);
-		return FALSE;
-	}
-
-	/* is the key string already in our DB? */
-	keycode_str = g_strdup_printf ("0x%x", keycode);
-	key = g_hash_table_lookup (button->priv->keysym_to_name_hash, (gpointer) keycode_str);
-	if (key != NULL) {
-		g_warning ("found in hash %i", keycode);
-		g_free (keycode_str);
-		return FALSE;
-	}
-
-	/* try to register X event */
-	ret = gpm_button_grab_keystring (button, keycode);
-	if (!ret) {
-		g_warning ("Failed to grab %i", keycode);
-		g_free (keycode_str);
-		return FALSE;
-	}
-
-	/* add to hash table */
-	g_hash_table_insert (button->priv->keysym_to_name_hash, (gpointer) keycode_str, (gpointer) g_strdup (key_name));
-
-	/* the key is freed in the hash function unref */
-	return TRUE;
-}
-
-/**
  * gpm_button_class_init:
  * @button: This class instance
  **/
@@ -316,13 +177,6 @@ gpm_button_init (GpmButton *button)
 	button->priv->lid_is_closed = up_client_get_lid_is_closed (button->priv->client);
 	g_signal_connect (button->priv->client, "changed",
 			  G_CALLBACK (gpm_button_client_changed_cb), button);
-
-	gpm_button_xevent_key (button, XF86XK_MonBrightnessUp, GPM_BUTTON_BRIGHT_UP);
-	gpm_button_xevent_key (button, XF86XK_MonBrightnessDown, GPM_BUTTON_BRIGHT_DOWN);
-
-	/* use global filter */
-	gdk_window_add_filter (button->priv->window,
-			       gpm_button_filter_x_events, (gpointer) button);
 }
 
 /**
diff --git a/src/gpm-button.h b/src/gpm-button.h
index 959b0cf..809a1f7 100644
--- a/src/gpm-button.h
+++ b/src/gpm-button.h
@@ -38,8 +38,6 @@ typedef struct GpmButtonPrivate GpmButtonPrivate;
 #define GPM_BUTTON_LID_DEP		"lid"		/* Remove when HAL drops input support */
 #define GPM_BUTTON_LID_OPEN		"lid-up"
 #define GPM_BUTTON_LID_CLOSED		"lid-down"
-#define GPM_BUTTON_BRIGHT_UP		"brightness-up"
-#define GPM_BUTTON_BRIGHT_DOWN		"brightness-down"
 
 typedef struct
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]