[Xfce4-commits] <xfce4-power-manager:master> change backlight property type to long

Ali Abdallah noreply at xfce.org
Mon Jun 27 16:48:01 CEST 2011


Updating branch refs/heads/master
         to 6b86e87fabb8ffe7916aa9c18d8b21e8d7896870 (commit)
       from 643962eb2d46d48042db0ab278c46813da8b6e9b (commit)

commit 6b86e87fabb8ffe7916aa9c18d8b21e8d7896870
Author: Yves-Alexis Perez <corsac at debian.org>
Date:   Mon Jun 27 16:46:23 2011 +0200

    change backlight property type to long

 common/xfpm-brightness.c                     |   68 +++++++++++++++-----------
 common/xfpm-brightness.h                     |    8 ++--
 panel-plugins/brightness/brightness-button.c |   10 ++--
 src/xfpm-backlight.c                         |   12 ++--
 4 files changed, 55 insertions(+), 43 deletions(-)

diff --git a/common/xfpm-brightness.c b/common/xfpm-brightness.c
index e0b9c3c..45a121b 100644
--- a/common/xfpm-brightness.c
+++ b/common/xfpm-brightness.c
@@ -90,11 +90,11 @@ out:
 }
 
 static gboolean
-xfpm_brightness_xrandr_get_level (XfpmBrightness *brightness, RROutput output, gint *current)
+xfpm_brightness_xrandr_get_level (XfpmBrightness *brightness, RROutput output, long *current)
 {
     unsigned long nitems;
     unsigned long bytes_after;
-    gint *prop;
+    long *prop;
     Atom actual_type;
     int actual_format;
     gboolean ret = FALSE;
@@ -110,7 +110,7 @@ xfpm_brightness_xrandr_get_level (XfpmBrightness *brightness, RROutput output, g
     
     if (actual_type == XA_INTEGER && nitems == 1 && actual_format == 32) 
     {
-	memcpy (current, prop, sizeof (gint));
+	memcpy (current, prop, sizeof (*current));
 	ret = TRUE;
     }
     
@@ -120,7 +120,7 @@ xfpm_brightness_xrandr_get_level (XfpmBrightness *brightness, RROutput output, g
 }
 
 static gboolean
-xfpm_brightness_xrandr_set_level (XfpmBrightness *brightness, RROutput output, gint level)
+xfpm_brightness_xrandr_set_level (XfpmBrightness *brightness, RROutput output, long level)
 {
     gboolean ret = TRUE;
 
@@ -133,7 +133,7 @@ xfpm_brightness_xrandr_set_level (XfpmBrightness *brightness, RROutput output, g
     
     if ( gdk_error_trap_pop () ) 
     {
-	    g_warning ("failed to XRRChangeOutputProperty for brightness %i", level);
+	    g_warning ("failed to XRRChangeOutputProperty for brightness %li", level);
 	    ret = FALSE;
     }
     
@@ -147,16 +147,27 @@ xfpm_brightness_setup_xrandr (XfpmBrightness *brightness)
     XRROutputInfo *info;
     Window window;
     gint major, minor, screen_num;
+    int event_base, error_base;
     gint min, max;
     gboolean ret = FALSE;
     gint i;
     
-    if ( !XRRQueryVersion (GDK_DISPLAY (), &major, &minor) )
+    if (!XRRQueryExtension (GDK_DISPLAY (), &event_base, &error_base) ||
+	!XRRQueryVersion (GDK_DISPLAY (), &major, &minor) )
     {
 	g_warning ("No XRANDR extension found");
 	return FALSE;
     }
+    if (major == 1 && minor < 2)
+    {
+	g_warning ("XRANDR version < 1.2");
+	return FALSE;
+    }
     
+#ifdef RR_PROPERTY_BACKLIGHT
+    brightness->priv->backlight = XInternAtom (GDK_DISPLAY (), RR_PROPERTY_BACKLIGHT, True);
+    if (brightness->priv->backlight == None) /* fall back to deprecated name */
+#endif
     brightness->priv->backlight = XInternAtom (GDK_DISPLAY (), "BACKLIGHT", True);
     
     if (brightness->priv->backlight == None) 
@@ -172,10 +183,11 @@ xfpm_brightness_setup_xrandr (XfpmBrightness *brightness)
     window = RootWindow (GDK_DISPLAY (), screen_num);
     
 #if (RANDR_MAJOR == 1 && RANDR_MINOR >=3 )
-    brightness->priv->resource = XRRGetScreenResourcesCurrent (GDK_DISPLAY (), window);
-#else
-    brightness->priv->resource = XRRGetScreenResources (GDK_DISPLAY (), window);
+    if (major > 1 || minor >= 3)
+	brightness->priv->resource = XRRGetScreenResourcesCurrent (GDK_DISPLAY (), window);
+    else
 #endif
+	brightness->priv->resource = XRRGetScreenResources (GDK_DISPLAY (), window);
 
     for ( i = 0; i < brightness->priv->resource->noutput; i++)
     {
@@ -200,11 +212,11 @@ xfpm_brightness_setup_xrandr (XfpmBrightness *brightness)
 }
 
 static gboolean
-xfpm_brightness_xrand_up (XfpmBrightness *brightness, gint *new_level)
+xfpm_brightness_xrand_up (XfpmBrightness *brightness, glong *new_level)
 {
-    gint hw_level;
+    long hw_level;
     gboolean ret = FALSE;
-    gint set_level;
+    long set_level;
     
     ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, &hw_level);
     
@@ -225,14 +237,14 @@ xfpm_brightness_xrand_up (XfpmBrightness *brightness, gint *new_level)
     
     if ( !ret )
     {
-	g_warning ("xfpm_brightness_xrand_up failed for %d", set_level);
+	g_warning ("xfpm_brightness_xrand_up failed for %li", set_level);
 	return FALSE;
     }
 	
     /* Nothing changed in the hardware*/
     if ( *new_level == hw_level )
     {
-	g_warning ("xfpm_brightness_xrand_up did not change the hw level to %d", set_level);
+	g_warning ("xfpm_brightness_xrand_up did not change the hw level to %li", set_level);
 	return FALSE;
     }
     
@@ -240,11 +252,11 @@ xfpm_brightness_xrand_up (XfpmBrightness *brightness, gint *new_level)
 }
 
 static gboolean
-xfpm_brightness_xrand_down (XfpmBrightness *brightness, gint *new_level)
+xfpm_brightness_xrand_down (XfpmBrightness *brightness, long *new_level)
 {
-    gint hw_level;
+    long hw_level;
     gboolean ret;
-    gint set_level;
+    long set_level;
     
     ret = xfpm_brightness_xrandr_get_level (brightness, brightness->priv->output, &hw_level);
     
@@ -265,14 +277,14 @@ xfpm_brightness_xrand_down (XfpmBrightness *brightness, gint *new_level)
     
     if ( !ret )
     {
-	g_warning ("xfpm_brightness_xrand_down failed for %d", set_level);
+	g_warning ("xfpm_brightness_xrand_down failed for %li", set_level);
 	return FALSE;
     }
     
     /* Nothing changed in the hardware*/
     if ( *new_level == hw_level )
     {
-	g_warning ("xfpm_brightness_xrand_down did not change the hw level to %d", set_level);
+	g_warning ("xfpm_brightness_xrand_down did not change the hw level to %li", set_level);
 	return FALSE;
     }
     
@@ -336,7 +348,7 @@ xfpm_brightness_setup_helper (XfpmBrightness *brightness)
 }
 
 static gboolean
-xfpm_brightness_helper_get_level (XfpmBrightness *brg, gint *level)
+xfpm_brightness_helper_get_level (XfpmBrightness *brg, glong *level)
 {
     int ret;
 
@@ -381,9 +393,9 @@ out:
 }
 
 static gboolean
-xfpm_brightness_helper_up (XfpmBrightness *brightness, gint *new_level)
+xfpm_brightness_helper_up (XfpmBrightness *brightness, glong *new_level)
 {
-    gint hw_level;
+    glong hw_level;
     gboolean ret = FALSE;
     gint set_level;
     
@@ -421,9 +433,9 @@ xfpm_brightness_helper_up (XfpmBrightness *brightness, gint *new_level)
 }
 
 static gboolean
-xfpm_brightness_helper_down (XfpmBrightness *brightness, gint *new_level)
+xfpm_brightness_helper_down (XfpmBrightness *brightness, glong *new_level)
 {
-    gint hw_level;
+    glong hw_level;
     gboolean ret;
     gint set_level;
     
@@ -547,7 +559,7 @@ xfpm_brightness_setup (XfpmBrightness *brightness)
     return FALSE;
 }
 
-gboolean xfpm_brightness_up (XfpmBrightness *brightness, gint *new_level)
+gboolean xfpm_brightness_up (XfpmBrightness *brightness, glong *new_level)
 {
     gboolean ret = FALSE;
     
@@ -564,7 +576,7 @@ gboolean xfpm_brightness_up (XfpmBrightness *brightness, gint *new_level)
     return ret;
 }
 
-gboolean xfpm_brightness_down (XfpmBrightness *brightness, gint *new_level)
+gboolean xfpm_brightness_down (XfpmBrightness *brightness, glong *new_level)
 {
     gboolean ret = FALSE;
     
@@ -593,7 +605,7 @@ gint xfpm_brightness_get_max_level (XfpmBrightness *brightness)
     return brightness->priv->max_level;
 }
 
-gboolean xfpm_brightness_get_level	(XfpmBrightness *brightness, gint *level)
+gboolean xfpm_brightness_get_level	(XfpmBrightness *brightness, glong *level)
 {
     gboolean ret = FALSE;
     
@@ -607,7 +619,7 @@ gboolean xfpm_brightness_get_level	(XfpmBrightness *brightness, gint *level)
     return ret;
 }
 
-gboolean xfpm_brightness_set_level (XfpmBrightness *brightness, gint level)
+gboolean xfpm_brightness_set_level (XfpmBrightness *brightness, glong level)
 {
     gboolean ret = FALSE;
     
diff --git a/common/xfpm-brightness.h b/common/xfpm-brightness.h
index f0398e6..0c4e3ed 100644
--- a/common/xfpm-brightness.h
+++ b/common/xfpm-brightness.h
@@ -51,20 +51,20 @@ XfpmBrightness       	       *xfpm_brightness_new             (void);
 gboolean			xfpm_brightness_setup 		(XfpmBrightness *brightness);
 
 gboolean			xfpm_brightness_up		(XfpmBrightness *brightness,
-								 gint *new_level);
+								 glong *new_level);
 
 gboolean			xfpm_brightness_down		(XfpmBrightness *brightness,
-								 gint *new_level);
+								 glong *new_level);
 
 gboolean			xfpm_brightness_has_hw 		(XfpmBrightness *brightness);
 
 gint 				xfpm_brightness_get_max_level   (XfpmBrightness *brightness);
 
 gboolean			xfpm_brightness_get_level	(XfpmBrightness *brightness,
-								 gint *level);
+								 glong *level);
 
 gboolean			xfpm_brightness_set_level	(XfpmBrightness *brightness,
-								 gint level);
+								 glong level);
 
 gboolean			xfpm_brightness_dim_down	(XfpmBrightness *brightness);
 
diff --git a/panel-plugins/brightness/brightness-button.c b/panel-plugins/brightness/brightness-button.c
index c4327e2..6e60c29 100644
--- a/panel-plugins/brightness/brightness-button.c
+++ b/panel-plugins/brightness/brightness-button.c
@@ -186,7 +186,7 @@ static gboolean
 brightness_button_popup_win (GtkWidget *widget, GdkEvent *ev, guint32 ev_time)
 {
     gint x, y;
-    gint current_level = 0;
+    glong current_level = 0;
     GdkDisplay *display;
     GdkScreen *screen;
     BrightnessButton *button;
@@ -342,7 +342,7 @@ plus_clicked (GtkWidget *widget, BrightnessButton *button)
 static void
 range_value_changed (GtkWidget *widget, BrightnessButton *button)
 {
-    gint range_level, hw_level;
+    glong range_level, hw_level;
     
     range_level = (gint) gtk_range_get_value (GTK_RANGE (button->priv->range));
     
@@ -428,8 +428,8 @@ brightness_button_create_popup (BrightnessButton *button)
 static void
 brightness_button_up (BrightnessButton *button)
 {
-    gint level;
-    gint max_level;
+    glong level;
+    glong max_level;
     
     xfpm_brightness_get_level (button->priv->brightness, &level);
     max_level = xfpm_brightness_get_max_level (button->priv->brightness);
@@ -443,7 +443,7 @@ brightness_button_up (BrightnessButton *button)
 static void
 brightness_button_down (BrightnessButton *button)
 {
-    gint level;
+    glong level;
     xfpm_brightness_get_level (button->priv->brightness, &level);
     
     if ( level != 0 )
diff --git a/src/xfpm-backlight.c b/src/xfpm-backlight.c
index d69c588..94a4f44 100644
--- a/src/xfpm-backlight.c
+++ b/src/xfpm-backlight.c
@@ -72,8 +72,8 @@ struct XfpmBacklightPrivate
     gboolean	    has_hw;
     gboolean	    on_battery;
     
-    gint            last_level;
-    gint 	    max_level;
+    glong            last_level;
+    glong 	    max_level;
     
     gboolean        dimmed;
     gboolean	    block;
@@ -88,7 +88,7 @@ xfpm_backlight_dim_brightness (XfpmBacklight *backlight)
     
     if (xfpm_power_get_mode (backlight->priv->power) == XFPM_POWER_MODE_NORMAL )
     {
-	gint dim_level;
+	glong dim_level;
 	
 	g_object_get (G_OBJECT (backlight->priv->conf),
 		      backlight->priv->on_battery ? BRIGHTNESS_LEVEL_ON_BATTERY : BRIGHTNESS_LEVEL_ON_AC, &dim_level,
@@ -104,7 +104,7 @@ xfpm_backlight_dim_brightness (XfpmBacklight *backlight)
 	
 	dim_level = dim_level * backlight->priv->max_level / 100;
 	
-	XFPM_DEBUG ("Current brightness level before dimming : %i, new %i", backlight->priv->last_level, dim_level);
+	XFPM_DEBUG ("Current brightness level before dimming : %li, new %li", backlight->priv->last_level, dim_level);
 	
 	backlight->priv->dimmed = xfpm_brightness_set_level (backlight->priv->brightness, dim_level);
     }
@@ -268,7 +268,7 @@ xfpm_backlight_reset_cb (EggIdletime *idle, XfpmBacklight *backlight)
     {
 	if ( !backlight->priv->block)
 	{
-	    XFPM_DEBUG ("Alarm reset, setting level to %i", backlight->priv->last_level);
+	    XFPM_DEBUG ("Alarm reset, setting level to %li", backlight->priv->last_level);
 	    xfpm_brightness_set_level (backlight->priv->brightness, backlight->priv->last_level);
 	}
 	backlight->priv->dimmed = FALSE;
@@ -278,7 +278,7 @@ xfpm_backlight_reset_cb (EggIdletime *idle, XfpmBacklight *backlight)
 static void
 xfpm_backlight_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBacklight *backlight)
 {
-    gint level;
+    glong level;
     gboolean ret = TRUE;
     
     gboolean enable_brightness, show_popup;



More information about the Xfce4-commits mailing list