Slight change to opacity API:

- Use a 0 - 255 range instead, keeping consistent with 8-bit RGBA
  conventions
- Clip supplied value if not in bounds


SVN revision: 8318
This commit is contained in:
xcomputerman 2004-01-09 08:38:39 +00:00 committed by xcomputerman
parent 2c5ac0ccbe
commit f8823f65d3
1 changed files with 9 additions and 4 deletions

View File

@ -1088,7 +1088,7 @@ ecore_x_window_prop_window_type_normal_set(Ecore_X_Window win)
* This only has an effect if the Composite extension is present and
* a compositing manager is running. This hint is still pending approval
* as part of the EWMH specification. The value supplied should be an
* integer between 0 and 100, with 100 representing full opacity.
* integer between 0 and 255, with 255 representing full opacity.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void ecore_x_window_prop_window_opacity_set(Ecore_X_Window win, int opacity)
@ -1096,7 +1096,12 @@ void ecore_x_window_prop_window_opacity_set(Ecore_X_Window win, int opacity)
unsigned long o_val;
double tmp;
tmp = (double) opacity/100. * 4294967295.;
if (opacity < 0)
opacity = 0;
else if (opacity > 255)
opacity = 255;
tmp = (double) opacity/255. * 4294967295.;
o_val = (unsigned long) tmp;
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_window_opacity,
XA_CARDINAL, 32, &o_val, 1);
@ -1105,7 +1110,7 @@ void ecore_x_window_prop_window_opacity_set(Ecore_X_Window win, int opacity)
/**
* Get the current opacity value of the window
* @param win The window whose opacity is being requested
* @return An int between 0 and 100 representing the window's opacity value,
* @return An int between 0 and 255 representing the window's opacity value,
* or -1 if the property is not found.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
@ -1122,7 +1127,7 @@ int ecore_x_window_prop_window_opacity_get(Ecore_X_Window win)
if (data && num)
{
lval = *(unsigned long *) data;
ret_val = (int) ((double) lval / 4294967295. * 100.);
ret_val = (int) ((double) lval / 4294967295. * 255.);
}
}