Add support for the proposed _NET_WM_WINDOW_OPACITY window manager hint.

At the moment does nothing useful unless you're running kdrive with a
specially patched version of Metacity ... but I just felt like putting it
in there anyways for later.

A little bit of the upcoming selections code leaked in with one of the
files in this commit.


SVN revision: 8280
This commit is contained in:
xcomputerman 2004-01-06 03:42:05 +00:00 committed by xcomputerman
parent 023fa75ea5
commit e348e59778
4 changed files with 64 additions and 1 deletions

View File

@ -640,10 +640,11 @@ void ecore_x_window_prop_window_type_utility_set(Ecore_X_Window win)
void ecore_x_window_prop_window_type_splash_set(Ecore_X_Window win);
void ecore_x_window_prop_window_type_dialog_set(Ecore_X_Window win);
void ecore_x_window_prop_window_type_normal_set(Ecore_X_Window win);
void ecore_x_window_prop_window_opacity_set(Ecore_X_Window win, int opacity);
int ecore_x_window_prop_window_opacity_get(Ecore_X_Window win);
void ecore_x_window_prop_state_set(Ecore_X_Window win, Ecore_X_Window_State s);
int ecore_x_window_prop_state_isset(Ecore_X_Window win, Ecore_X_Window_State s);
void ecore_x_window_prop_state_unset(Ecore_X_Window win, Ecore_X_Window_State s);
void ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask);
Ecore_X_Pixmap ecore_x_pixmap_new(Ecore_X_Window win, int w, int h, int dep);

View File

@ -100,6 +100,8 @@ Atom _ecore_x_atom_net_wm_state_fullscreen = 0;
Atom _ecore_x_atom_net_wm_state_above = 0;
Atom _ecore_x_atom_net_wm_state_below = 0;
Atom _ecore_x_atom_net_wm_window_opacity = 0;
Atom _ecore_x_atom_file_name = 0;
Atom _ecore_x_atom_string = 0;
Atom _ecore_x_atom_text = 0;
@ -353,6 +355,7 @@ ecore_x_init(const char *name)
_ecore_x_atom_net_wm_state_fullscreen = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_FULLSCREEN", False);
_ecore_x_atom_net_wm_state_above = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_ABOVE", False);
_ecore_x_atom_net_wm_state_below = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_BELOW", False);
_ecore_x_atom_net_wm_window_opacity = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_OPACITY", False);
_ecore_x_atom_utf8_string = XInternAtom(_ecore_x_disp, "UTF8_STRING", False);
_ecore_x_atom_file_name = XInternAtom(_ecore_x_disp, "FILE_NAME", False);

View File

@ -34,6 +34,16 @@ struct _Ecore_X_Reply
void *data;
};
typedef struct _Ecore_X_Selection_Data Ecore_X_Selection_Data;
struct _Ecore_X_Selection_Data
{
Window win;
Atom selection;
char *data;
int length;
};
typedef enum _Ecore_X_WM_Protocol {
/**
* If enabled the window manager will be asked to send a
@ -96,6 +106,8 @@ extern Atom _ecore_x_atom_net_wm_window_type_splash;
extern Atom _ecore_x_atom_net_wm_window_type_dialog;
extern Atom _ecore_x_atom_net_wm_window_type_normal;
extern Atom _ecore_x_atom_net_wm_window_opacity;
extern Atom _ecore_x_atom_net_wm_state_modal;
extern Atom _ecore_x_atom_net_wm_state_sticky;
extern Atom _ecore_x_atom_net_wm_state_maximized_vert;

View File

@ -1080,3 +1080,50 @@ ecore_x_window_prop_window_type_normal_set(Ecore_X_Window win)
ecore_x_window_prop_window_type_set(win, _ecore_x_atom_net_wm_window_type_normal);
}
/**
* Set the requested opacity of the window
* @param win The window whose opacity will be set
* @param opacity The opacity value to be applied to the window
*
* 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.
* <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)
{
unsigned long o_val;
o_val = (unsigned long) opacity / 100UL * 0xffffffff;
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_window_opacity,
XA_CARDINAL, 32, &o_val, 1);
}
/**
* 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,
* 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>
*/
int ecore_x_window_prop_window_opacity_get(Ecore_X_Window win)
{
unsigned char *data = NULL;
unsigned long tmp;
int ret_val = -1;
int num;
if(ecore_x_window_prop_property_get(win, _ecore_x_atom_net_wm_window_opacity,
XA_CARDINAL, 32, &data, &num))
{
if (data && num)
{
tmp = *(unsigned long *) data;
ret_val = (int) (tmp / 0xffffffff * 100UL);
}
}
return ret_val;
}