enclosed is the split version of the patch.
The first one remove trailing whitespaces. The second one implement backlight
support in Ecore. The ChangeLog is modified accordingly.
Best
Mathieu
----- Mail Original -----
De: "Tom Hacohen" <t...@stosb.com>
À: "mathieu taillefumier" <mathieu.taillefum...@free.fr>
Cc: "Tom Hacohen" <tom.haco...@partner.samsung.com>, "enlightenment-devel"
<enlightenment-devel@lists.sourceforge.net>
Envoyé: Mercredi 9 Février 2011 19h10:17 GMT +01:00 Amsterdam / Berlin / Berne
/ Rome / Stockholm / Vienne
Objet: Re: [E-devel] [PATCH][Ecore] second version of the backlight functions
Regarding formatting and logic: I mean actual code changes and spaces
changes.
For example you changed those empty lines at the start but also changed
features,
yes, your patch is short and easy to understand as is, but since I don't
work on ecore
I can't really tell if it's good or not so I won't commit it anyway.
What I was able to say, is that the patch was missing the changelog
(although you did
add it) and had mixed formatting and logic changes. :)
Regarding your question:
Yes, I think it's generally good to split to two patches.
Just got Lucas's mail, he's right :)
On Wed, Feb 9, 2011 at 7:50 PM, <mathieu.taillefum...@free.fr> wrote:
> Hey Tom,
>
> I don't know ecore enough to commit it myself, but I still have a couple
> of comments:
> 1. Your patch includes both logic and formatting changes, please split
> to two different patches.
>
> Two patches for three functions of fifteen lines each ? The formatting is
> changed because I had to add a single line on the top of the file and my
> emacs still does not want to format things the right way. Something is
> furiously wrong in my .emacs file.
>
> I do not know what do you mean about logic. Could you be more precise. The
> only thing I find too rigid is to separate the patch into two patches. It is
> very short, so I did not feel like to separate it into two parts
>
> 2. Please also include the ChangeLog change in the same patch.
>
> I Will do it.
>
> Also, if possible please also include a nice svn log message, for
> example:
> "Ecore ecore-x: Implemented the stub backlight support functions."
>
> fine by me.
>
> Mathieu.
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
--
Tom.
Index: src/lib/ecore_x/xlib/ecore_x_randr_12.c
===================================================================
--- src/lib/ecore_x/xlib/ecore_x_randr_12.c (revision 56860)
+++ src/lib/ecore_x/xlib/ecore_x_randr_12.c (working copy)
@@ -82,7 +82,7 @@
int i;
Eina_Bool ret = EINA_FALSE;
- if ((crtc == Ecore_X_Randr_None) ||
+ if ((crtc == Ecore_X_Randr_None) ||
(crtc == Ecore_X_Randr_Unset))
return ret;
@@ -837,7 +837,7 @@
}
if (crtc_info)
XRRFreeCrtcInfo(crtc_info);
-
+
if (res)
XRRFreeScreenResources(res);
@@ -867,10 +867,10 @@
}
if (crtc_info)
XRRFreeCrtcInfo(crtc_info);
-
+
if (res)
XRRFreeScreenResources(res);
-
+
return ret;
#else
return Ecore_X_Randr_None;
Index: src/lib/ecore_x/xlib/ecore_x_randr_12.c
===================================================================
--- src/lib/ecore_x/xlib/ecore_x_randr_12.c (revision 56860)
+++ src/lib/ecore_x/xlib/ecore_x_randr_12.c (working copy)
@@ -36,6 +36,7 @@
Window
window);
extern int _randr_version;
+extern Ecore_X_Atom _backlight;
#endif
/**
@@ -1904,3 +1905,162 @@
Ecore_X_Randr_Unset);
#endif
}
+
+/**
+ * @brief set up the backlight level to the given level.
+ * @param root the window's screen which will be set.
+ * @param level of the backlight between 0 and 100
+ */
+
+EAPI void
+ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root, double level)
+{
+#ifdef ECORE_XRANDR
+ RANDR_CHECK_1_2_RET();
+ /*
+ * maybe move this should be in the init part the module.
+ * Initialize it if not already initialized
+ */
+
+ if((level < 0)||(level > 100))
+ {
+ ERR("Wrong value for the backlight level. It should be between 0 and 100.");
+ return;
+ }
+
+ if(_backlight == None)
+ _backlight = XInternAtom (_ecore_x_disp, RANDR_PROPERTY_BACKLIGHT, True);
+
+ /* Clearly the server does not support it. */
+ if(_backlight == None)
+ {
+ ERR("Backlight property is not suppported on this server or driver");
+ return;
+ }
+
+ /* get the ressources */
+ XRRScreenResources *resources = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root);
+
+ if (!resources) return;
+ int o;
+ for (o = 0; o < resources->noutput; o++)
+ {
+ Ecore_X_Randr_Output output = resources->outputs[o];
+ if (ecore_x_randr_output_backlight_level_get(root, output) >= 0)
+ {
+ ecore_x_randr_output_backlight_level_set(root, output, level);
+ }
+ }
+ XRRFreeScreenResources (resources);
+#endif
+}
+
+/*
+ * @brief get the backlight level of the given output
+ * @param root window which's screen should be queried
+ * @param output from which the backlight level should be retrieved
+ * @return the backlight level
+ */
+
+EAPI double
+ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
+ Ecore_X_Randr_Output output)
+{
+#ifdef ECORE_XRANDR
+ RANDR_CHECK_1_2_RET(-1);
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop;
+ Atom actual_type;
+ int actual_format;
+ long value;
+
+ /* set backlight variable if not already done */
+ if(_backlight == None)
+ _backlight = XInternAtom (_ecore_x_disp, RANDR_PROPERTY_BACKLIGHT, True);
+ if(_backlight == None)
+ {
+ ERR("Backlight property is not suppported on this server or driver");
+ return -1;
+ }
+
+ if(!_ecore_x_randr_output_validate(root, output)) {
+ ERR("Invalid output\n");
+ return -1;
+ }
+
+ if (XRRGetOutputProperty (_ecore_x_disp, output, _backlight,
+ 0, 4, False, False, None,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &prop) != Success) {
+ WRN("Backlight not supported on this output");
+ return -1;
+ }
+
+ if (actual_type != XA_INTEGER || nitems != 1 || actual_format != 32)
+ value = -1;
+ else
+ value = *((long *) prop);
+ free (prop);
+
+ /* I have the current value of the backlight */
+ /* Now retrieve the min and max intensities of the output */
+ XRRPropertyInfo *info = XRRQueryOutputProperty (_ecore_x_disp, output, _backlight);
+ if (info)
+ {
+ if (info->range && info->num_values == 2)
+ {
+ /* finally convert the current value in percent to be user friendly */
+ long min = info->values[0];
+ long max = info->values[1];
+ value = (value-min)*100/(max-min);
+ }
+ free(info);
+ }
+ return ((double)value);
+#else
+ return -1;
+#endif
+}
+
+/*
+ * @brief set the backlight level of a given output
+ * @param root window which's screen should be queried
+ * @param output that should be set
+ * @param level for which the backlight should be set
+ * @return EINA_TRUE in case of success
+ */
+
+EAPI Eina_Bool
+ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
+ Ecore_X_Randr_Output output,
+ double level)
+{
+#ifdef ECORE_XRANDR
+ RANDR_CHECK_1_2_RET(EINA_FALSE);
+ if(!_ecore_x_randr_output_validate(root, output))
+ return EINA_FALSE;
+
+ XRRPropertyInfo *info = XRRQueryOutputProperty(_ecore_x_disp, output, _backlight);
+ if(info)
+ {
+ if (info->range && info->num_values == 2)
+ {
+ double min = info->values[0];
+ double max = info->values[1];
+ double tmp = (level * (max - min) / 100) + min;
+ long new = tmp;
+ if (new > max) new = max;
+ if (new < min) new = min;
+ XRRChangeOutputProperty(_ecore_x_disp, output, _backlight, XA_INTEGER, 32,
+ PropModeReplace, (unsigned char *) &new, 1);
+ XFlush (_ecore_x_disp);
+ }
+ free(info);
+ return EINA_TRUE;
+ }
+ return EINA_FALSE;
+#else
+ return EINA_FALSE;
+#endif
+}
Index: ChangeLog
===================================================================
--- ChangeLog (revision 56860)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2011-02-09 Mathieu Taillefumier
+
+ * Add xrandr backlight support to ecore_x
+
2011-01-29 Carsten Haitzler (The Rasterman)
1.0.0 release
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel