summaryrefslogtreecommitdiff
path: root/src/gpm-backlight.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpm-backlight.c')
-rw-r--r--src/gpm-backlight.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index d2938a4..0989640 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -21,7 +21,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <stdlib.h>
@@ -38,6 +38,7 @@
#endif /* HAVE_UNISTD_H */
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <libupower-glib/upower.h>
@@ -51,7 +52,7 @@
#include "gpm-dpms.h"
#include "gpm-idle.h"
#include "gpm-marshal.h"
-#include "gpm-stock-icons.h"
+#include "gpm-icon-names.h"
#include "egg-console-kit.h"
#define GPM_BACKLIGHT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_BACKLIGHT, GpmBacklightPrivate))
@@ -209,6 +210,9 @@ gpm_backlight_dialog_show (GpmBacklight *backlight)
GdkScreen *pointer_screen;
GdkRectangle geometry;
int monitor;
+ GdkDisplay *display;
+ GdkDeviceManager *device_manager;
+ GdkDevice *device;
/*
* get the window size
@@ -216,7 +220,7 @@ gpm_backlight_dialog_show (GpmBacklight *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;
@@ -226,11 +230,14 @@ gpm_backlight_dialog_show (GpmBacklight *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);
@@ -380,7 +387,7 @@ gpm_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmBacklight
"on-battery", &on_battery,
NULL);
- if (!on_battery && g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_AC) == 0) {
+ if (g_strcmp0 (key, GPM_SETTINGS_BRIGHTNESS_AC) == 0) {
backlight->priv->master_percentage = g_settings_get_double (settings, key);
gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
@@ -433,6 +440,7 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
GError *error = NULL;
guint percentage;
gboolean hw_changed;
+ gboolean on_battery;
egg_debug ("Button press event type=%s", type);
if (g_strcmp0 (type, GPM_BUTTON_BRIGHT_UP) == 0) {
@@ -448,6 +456,13 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
gpm_backlight_dialog_show (backlight);
/* save the new percentage */
backlight->priv->master_percentage = percentage;
+ /* if using AC power supply, save the new brightness settings */
+ g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL);
+ if (!on_battery) {
+ egg_debug ("saving brightness for ac supply: %i", percentage);
+ g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+ percentage*1.0);
+ }
}
/* we emit a signal for the brightness applet */
if (ret && hw_changed) {
@@ -467,6 +482,13 @@ gpm_backlight_button_pressed_cb (GpmButton *button, const gchar *type, GpmBackli
gpm_backlight_dialog_show (backlight);
/* save the new percentage */
backlight->priv->master_percentage = percentage;
+ /* if using AC power supply, save the new brightness settings */
+ g_object_get (backlight->priv->client, "on-battery", &on_battery, NULL);
+ if (!on_battery) {
+ egg_debug ("saving brightness for ac supply: %i", percentage);
+ g_settings_set_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC,
+ percentage*1.0);
+ }
}
/* we emit a signal for the brightness applet */
if (ret && hw_changed) {
@@ -567,7 +589,7 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
if (mode == GPM_IDLE_MODE_NORMAL) {
/* sync lcd brightness */
gpm_backlight_notify_system_idle_changed (backlight, FALSE);
- gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, FALSE);
+ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
/* ensure backlight is on */
ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
@@ -580,7 +602,7 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
/* sync lcd brightness */
gpm_backlight_notify_system_idle_changed (backlight, TRUE);
- gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, FALSE);
+ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
/* ensure backlight is on */
ret = gpm_dpms_set_mode (backlight->priv->dpms, GPM_DPMS_MODE_ON, &error);
@@ -593,7 +615,7 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
/* sync lcd brightness */
gpm_backlight_notify_system_idle_changed (backlight, TRUE);
- gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, FALSE);
+ gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
/* get the DPMS state we're supposed to use on the power state */
g_object_get (backlight->priv->client,