diff options
Diffstat (limited to 'src/gpm-kbd-backlight.c')
-rw-r--r-- | src/gpm-kbd-backlight.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c index b3091ac..ae8e0fa 100644 --- a/src/gpm-kbd-backlight.c +++ b/src/gpm-kbd-backlight.c @@ -22,6 +22,7 @@ #include <gio/gio.h> #include <glib.h> #include <libupower-glib/upower.h> +#include <gtk/gtk.h> #include "egg-debug.h" #include "gpm-button.h" @@ -121,6 +122,11 @@ gpm_kbd_backlight_set (GpmKbdBacklight *backlight, goal = gpm_discrete_from_percent (percentage, backlight->priv->max_brightness); scale = percentage > backlight->priv->brightness_percent ? 1 : -1; + /* if percentage change too small force next value */ + if (goal == backlight->priv->brightness) { + goal += percentage == backlight->priv->brightness_percent ? 0 : scale; + } + /* step loop down by 1 for a dimming effect */ while (backlight->priv->brightness != goal) { backlight->priv->brightness += scale; @@ -180,6 +186,9 @@ gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight) GdkScreen *pointer_screen; GdkRectangle geometry; int monitor; + GdkDisplay *display; + GdkDeviceManager *device_manager; + GdkDevice *device; /* * get the window size @@ -187,7 +196,7 @@ gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight) * know its true size, yet, so we need to jump through hoops */ gtk_window_get_default_size (GTK_WINDOW (backlight->priv->popup), &orig_w, &orig_h); - gtk_widget_size_request (backlight->priv->popup, &win_req); + gtk_widget_get_preferred_size (backlight->priv->popup, NULL, &win_req); if (win_req.width > orig_w) { orig_w = win_req.width; @@ -197,11 +206,14 @@ gpm_kbd_backlight_dialog_show (GpmKbdBacklight *backlight) } pointer_screen = NULL; - gdk_display_get_pointer (gtk_widget_get_display (backlight->priv->popup), + display = gtk_widget_get_display (backlight->priv->popup); + device_manager = gdk_display_get_device_manager (display); + device = gdk_device_manager_get_client_pointer (device_manager); + gdk_device_get_position (device, &pointer_screen, &pointer_x, - &pointer_y, - NULL); + &pointer_y); + monitor = gdk_screen_get_monitor_at_point (pointer_screen, pointer_x, pointer_y); |