Added setup for more netwm atoms, also API for working with the current desktop.
SVN revision: 7597
This commit is contained in:
parent
911e66a03c
commit
f2130a93f5
|
@ -386,9 +386,12 @@ int
|
|||
handler_x_window_configure(void *data, int type, void *event)
|
||||
{
|
||||
Ecore_X_Event_Window_Configure *e;
|
||||
const int desktop = 0;
|
||||
|
||||
e = event;
|
||||
printf("Configure %i %i, %ix%i\n", e->x, e->y, e->w, e->h);
|
||||
printf("Switching desktops to %d\n", desktop);
|
||||
ecore_x_window_prop_desktop_request(e->win, desktop);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -504,6 +507,7 @@ void
|
|||
setup_ecore_x_test(void)
|
||||
{
|
||||
char *tmp;
|
||||
long data[5] = { 1, 0, 0, 0, 0 };
|
||||
|
||||
win = ecore_x_window_new(0, 0, 0, 120, 60);
|
||||
ecore_x_window_prop_title_set(win, "Ecore Test Program");
|
||||
|
@ -545,6 +549,8 @@ setup_ecore_x_test(void)
|
|||
}
|
||||
printf("Pid: %d\n", ecore_x_window_prop_pid_get(win));
|
||||
ecore_x_window_prop_name_class_set(win, "ecore_test", "main");
|
||||
ecore_x_window_prop_desktop_set(win, 1);
|
||||
printf("Window on desktop %u\n", ecore_x_window_prop_desktop_get(win));
|
||||
ecore_x_window_prop_protocol_set(win, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, 1);
|
||||
ecore_x_window_show(win);
|
||||
ecore_x_flush();
|
||||
|
@ -569,6 +575,7 @@ setup_ecore_x_test(void)
|
|||
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_NAME_CLASS_CHANGE, handler_x_window_prop_name_class_change, NULL);
|
||||
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_CLIENT_MACHINE_CHANGE, handler_x_window_prop_client_machine_change, NULL);
|
||||
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_PID_CHANGE, handler_x_window_prop_pid_change, NULL);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -536,6 +536,7 @@ void ecore_x_window_cursor_show(Ecore_X_Window win, int show);
|
|||
void ecore_x_window_defaults_set(Ecore_X_Window win);
|
||||
|
||||
void ecore_x_window_prop_property_set(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_Atom format, int size, void *data, int number);
|
||||
void ecore_x_window_prop_property_notify(Ecore_X_Window win, const char *type, long *data);
|
||||
void ecore_x_window_prop_string_set(Ecore_X_Window win, Ecore_X_Atom type, char *str);
|
||||
char *ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type);
|
||||
void ecore_x_window_prop_title_set(Ecore_X_Window win, const char *t);
|
||||
|
@ -561,6 +562,9 @@ void ecore_x_window_prop_xy_set(Ecore_X_Window win, int x, int y);
|
|||
void ecore_x_window_prop_borderless_set(Ecore_X_Window win, int borderless);
|
||||
int ecore_x_window_prop_layer_set(Ecore_X_Window win, int layer);
|
||||
void ecore_x_window_prop_withdrawn_set(Ecore_X_Window win, int withdrawn);
|
||||
void ecore_x_window_prop_desktop_request(Ecore_X_Window win, long desktop);
|
||||
void ecore_x_window_prop_desktop_set(Ecore_X_Window win, long desktop);
|
||||
long ecore_x_window_prop_desktop_get(Ecore_X_Window win);
|
||||
|
||||
void ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask);
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ Window _ecore_x_event_last_win = 0;
|
|||
int _ecore_x_event_last_root_x = 0;
|
||||
int _ecore_x_event_last_root_y = 0;
|
||||
|
||||
/*
|
||||
* ICCCM and Motif hints.
|
||||
*/
|
||||
Atom _ecore_x_atom_wm_delete_window = 0;
|
||||
Atom _ecore_x_atom_wm_take_focus = 0;
|
||||
Atom _ecore_x_atom_wm_protocols = 0;
|
||||
|
@ -33,17 +36,34 @@ Atom _ecore_x_atom_wm_icon_name = 0;
|
|||
Atom _ecore_x_atom_wm_client_machine = 0;
|
||||
Atom _ecore_x_atom_motif_wm_hints = 0;
|
||||
Atom _ecore_x_atom_win_layer = 0;
|
||||
Atom _ecore_x_atom_net_wm_desktop = 0;
|
||||
Atom _ecore_x_atom_net_current_desktop = 0;
|
||||
|
||||
/*
|
||||
* Root window NetWM hints.
|
||||
*/
|
||||
Atom _ecore_x_atom_net_supported = 0;
|
||||
Atom _ecore_x_atom_net_client_list = 0;
|
||||
Atom _ecore_x_atom_net_number_of_desktops = 0;
|
||||
Atom _ecore_x_atom_net_desktop_geometry = 0;
|
||||
Atom _ecore_x_atom_net_desktop_viewport = 0;
|
||||
Atom _ecore_x_atom_net_current_desktop = 0;
|
||||
Atom _ecore_x_atom_net_desktop_names = 0;
|
||||
Atom _ecore_x_atom_net_active_window = 0;
|
||||
Atom _ecore_x_atom_net_workarea = 0;
|
||||
Atom _ecore_x_atom_net_supporting_wm_check = 0;
|
||||
Atom _ecore_x_atom_net_virtual_roots = 0;
|
||||
Atom _ecore_x_atom_net_desktop_layout = 0;
|
||||
Atom _ecore_x_atom_net_showing_desktop = 0;
|
||||
|
||||
/*
|
||||
* Application window specific NetWM hints.
|
||||
*/
|
||||
Atom _ecore_x_atom_net_wm_desktop = 0;
|
||||
Atom _ecore_x_atom_net_wm_name = 0;
|
||||
Atom _ecore_x_atom_net_wm_visible_name = 0;
|
||||
Atom _ecore_x_atom_net_wm_icon_name = 0;
|
||||
Atom _ecore_x_atom_net_wm_visible_icon_name = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type = 0;
|
||||
Atom _ecore_x_atom_net_wm_state = 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_allowed_actions = 0;
|
||||
Atom _ecore_x_atom_net_wm_strut = 0;
|
||||
Atom _ecore_x_atom_net_wm_strut_partial = 0;
|
||||
|
@ -53,6 +73,27 @@ Atom _ecore_x_atom_net_wm_pid = 0;
|
|||
Atom _ecore_x_atom_net_wm_handle_icons = 0;
|
||||
Atom _ecore_x_atom_net_wm_user_time = 0;
|
||||
|
||||
Atom _ecore_x_atom_net_wm_window_type_desktop = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_dock = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_toolbar = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_menu = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_utility = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_splash = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_dialog = 0;
|
||||
Atom _ecore_x_atom_net_wm_window_type_normal = 0;
|
||||
|
||||
Atom _ecore_x_atom_net_wm_state_modal = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_sticky = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_maximized_vert = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_maximized_horz = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_shaded = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_skip_taskbar = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_skip_pager = 0;
|
||||
Atom _ecore_x_atom_net_wm_state_hidden = 0;
|
||||
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_utf8_string = 0;
|
||||
|
||||
Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM] = {0};
|
||||
|
@ -267,8 +308,6 @@ ecore_x_init(const char *name)
|
|||
_ecore_x_atom_net_wm_desktop = XInternAtom(_ecore_x_disp, "_NET_WM_DESKTOP", False);
|
||||
_ecore_x_atom_net_wm_window_type = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE", False);
|
||||
_ecore_x_atom_net_wm_state = XInternAtom(_ecore_x_disp, "_NET_WM_STATE", 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_allowed_actions = XInternAtom(_ecore_x_disp, "_NET_WM_ALLOWED_ACTIONS", False);
|
||||
_ecore_x_atom_net_wm_strut = XInternAtom(_ecore_x_disp, "_NET_WM_STRUT", False);
|
||||
_ecore_x_atom_net_wm_strut_partial = XInternAtom(_ecore_x_disp, "_NET_WM_STRUT_PARTIAL", False);
|
||||
|
@ -277,7 +316,28 @@ ecore_x_init(const char *name)
|
|||
_ecore_x_atom_net_wm_pid = XInternAtom(_ecore_x_disp, "_NET_WM_PID", False);
|
||||
_ecore_x_atom_net_wm_user_time = XInternAtom(_ecore_x_disp, "_NET_WM_USER_TIME", False);
|
||||
|
||||
_ecore_x_atom_utf8_string = XInternAtom(_ecore_x_disp, "UTF8_STRING", False);
|
||||
_ecore_x_atom_net_wm_window_type_desktop = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
|
||||
_ecore_x_atom_net_wm_window_type_dock = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_DOCK", False);
|
||||
_ecore_x_atom_net_wm_window_type_toolbar = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_TOOLBAR", False);
|
||||
_ecore_x_atom_net_wm_window_type_menu = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_MENU", False);
|
||||
_ecore_x_atom_net_wm_window_type_utility = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_UTILITY", False);
|
||||
_ecore_x_atom_net_wm_window_type_splash = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_SPLASH", False);
|
||||
_ecore_x_atom_net_wm_window_type_dialog = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
_ecore_x_atom_net_wm_window_type_normal = XInternAtom(_ecore_x_disp, "_NET_WM_WINDOW_TYPE_NORMAL", False);
|
||||
|
||||
_ecore_x_atom_net_wm_state_modal = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_MODAL", False);
|
||||
_ecore_x_atom_net_wm_state_sticky = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_STICKY", False);
|
||||
_ecore_x_atom_net_wm_state_maximized_vert = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_MAXIMIZED_VERT", False);
|
||||
_ecore_x_atom_net_wm_state_maximized_horz = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
||||
_ecore_x_atom_net_wm_state_shaded = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_SHADED", False);
|
||||
_ecore_x_atom_net_wm_state_skip_taskbar = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_SKIP_TASKBAR", False);
|
||||
_ecore_x_atom_net_wm_state_skip_pager = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_SKIP_PAGER", False);
|
||||
_ecore_x_atom_net_wm_state_hidden = XInternAtom(_ecore_x_disp, "_NET_WM_STATE_HIDDEN", False);
|
||||
_ecore_x_atom_net_wm_state_fullscreen = XInternAtom(_ecore_x_disp, "_NET_WM_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_utf8_string = XInternAtom(_ecore_x_disp, "UTF8_STRING", False);
|
||||
|
||||
_ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] = _ecore_x_atom_wm_delete_window;
|
||||
_ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] = _ecore_x_atom_wm_take_focus;
|
||||
|
|
|
@ -87,6 +87,27 @@ extern Atom _ecore_x_atom_net_wm_pid;
|
|||
extern Atom _ecore_x_atom_net_wm_handle_icons;
|
||||
extern Atom _ecore_x_atom_net_wm_user_time;
|
||||
|
||||
extern Atom _ecore_x_atom_net_wm_window_type_desktop;
|
||||
extern Atom _ecore_x_atom_net_wm_window_type_dock;
|
||||
extern Atom _ecore_x_atom_net_wm_window_type_toolbar;
|
||||
extern Atom _ecore_x_atom_net_wm_window_type_menu;
|
||||
extern Atom _ecore_x_atom_net_wm_window_type_utility;
|
||||
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_state_modal;
|
||||
extern Atom _ecore_x_atom_net_wm_state_sticky;
|
||||
extern Atom _ecore_x_atom_net_wm_state_maximized_vert;
|
||||
extern Atom _ecore_x_atom_net_wm_state_maximized_horz;
|
||||
extern Atom _ecore_x_atom_net_wm_state_shaded;
|
||||
extern Atom _ecore_x_atom_net_wm_state_skip_taskbar;
|
||||
extern Atom _ecore_x_atom_net_wm_state_skip_pager;
|
||||
extern Atom _ecore_x_atom_net_wm_state_hidden;
|
||||
extern Atom _ecore_x_atom_net_wm_state_fullscreen;
|
||||
extern Atom _ecore_x_atom_net_wm_state_above;
|
||||
extern Atom _ecore_x_atom_net_wm_state_below;
|
||||
|
||||
extern Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM];
|
||||
|
||||
extern Atom _ecore_x_atom_utf8_string;
|
||||
|
|
|
@ -84,6 +84,39 @@ ecore_x_window_prop_property_get(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a property notify to a window.
|
||||
* @param win The window
|
||||
* @param type Type of notification
|
||||
* @param data The data
|
||||
*
|
||||
* Send a property notify to a window.
|
||||
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
*/
|
||||
void
|
||||
ecore_x_window_prop_property_notify(Ecore_X_Window win, const char *type, long *data)
|
||||
{
|
||||
Ecore_X_Atom tmp;
|
||||
XClientMessageEvent xev;
|
||||
|
||||
tmp = XInternAtom(_ecore_x_disp, type, False);
|
||||
|
||||
xev.type = PropertyNotify;
|
||||
xev.display = _ecore_x_disp;
|
||||
xev.window = win;
|
||||
xev.message_type = tmp;
|
||||
xev.format = 32;
|
||||
xev.data.l[0] = data[0];
|
||||
xev.data.l[1] = data[1];
|
||||
xev.data.l[2] = data[2];
|
||||
xev.data.l[3] = data[3];
|
||||
xev.data.l[4] = data[4];
|
||||
|
||||
XSendEvent(_ecore_x_disp, DefaultRootWindow(_ecore_x_disp), False,
|
||||
(SubstructureNotifyMask | SubstructureRedirectMask),
|
||||
(XEvent *)&xev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a window string property.
|
||||
* @param win The window
|
||||
|
@ -304,14 +337,17 @@ ecore_x_window_prop_client_machine_get(Ecore_X_Window win)
|
|||
pid_t
|
||||
ecore_x_window_prop_pid_get(Ecore_X_Window win)
|
||||
{
|
||||
int num = 0;
|
||||
long *tmp;
|
||||
pid_t pid = 0;
|
||||
int num = 0;
|
||||
pid_t pid = 0;
|
||||
unsigned char *tmp = NULL;
|
||||
|
||||
ecore_x_window_prop_property_get(win, _ecore_x_atom_net_wm_pid, XA_CARDINAL,
|
||||
32, &tmp, &num);
|
||||
if (num && tmp) pid = (pid_t)(*tmp);
|
||||
free(tmp);
|
||||
if ((num) && (tmp))
|
||||
{
|
||||
pid = (pid_t)(*tmp);
|
||||
free(tmp);
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
@ -636,36 +672,43 @@ ecore_x_window_prop_layer_set(Ecore_X_Window win, int layer)
|
|||
unsigned char *data = NULL;
|
||||
int i, val = 4, num = 0; /* normal layer */
|
||||
|
||||
if (layer < 0) { /* below */
|
||||
if (layer < 0) /* below */
|
||||
{
|
||||
atom = _ecore_x_atom_net_wm_state_below;
|
||||
val = 2;
|
||||
} else if (layer > 0) { /* above */
|
||||
}
|
||||
else if (layer > 0) /* above */
|
||||
{
|
||||
atom = _ecore_x_atom_net_wm_state_above;
|
||||
val = 6;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the NetWM atoms
|
||||
* get the atoms that are already set
|
||||
*/
|
||||
if (ecore_x_window_prop_property_get(win, _ecore_x_atom_net_wm_state,
|
||||
XA_ATOM, 32, &data, &num)) {
|
||||
XA_ATOM, 32, &data, &num))
|
||||
{
|
||||
/* and set the ones we're interested in */
|
||||
for (i = 0; i < num; i++)
|
||||
if (data[i] == _ecore_x_atom_net_wm_state_below)
|
||||
data[i] = (layer < 0);
|
||||
else if (data[i] == _ecore_x_atom_net_wm_state_above)
|
||||
data[i] = (layer > 0);
|
||||
|
||||
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_state,
|
||||
XA_ATOM, 32, data, num);
|
||||
free(data);
|
||||
} else
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
if (data[i] == _ecore_x_atom_net_wm_state_below)
|
||||
data[i] = (layer < 0);
|
||||
else if (data[i] == _ecore_x_atom_net_wm_state_above)
|
||||
data[i] = (layer > 0);
|
||||
}
|
||||
|
||||
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_state,
|
||||
XA_ATOM, 32, data, num);
|
||||
free(data);
|
||||
}
|
||||
else
|
||||
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_state,
|
||||
XA_ATOM, 32, &atom, 1);
|
||||
|
||||
/* set the gnome atom */
|
||||
ecore_x_window_prop_property_set(win, _ecore_x_atom_win_layer,
|
||||
XA_CARDINAL, 32, &val, 1);
|
||||
ecore_x_window_prop_property_set(win, _ecore_x_atom_win_layer,
|
||||
XA_CARDINAL, 32, &val, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -696,3 +739,63 @@ ecore_x_window_prop_withdrawn_set(Ecore_X_Window win, int withdrawn)
|
|||
XSetWMNormalHints(_ecore_x_disp, win, (XSizeHints *) &hints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the window manager to change this windows desktop.
|
||||
* @param win The Window
|
||||
* @param desktop The desktop number.
|
||||
*
|
||||
* Request the window manager to change this windows desktop.
|
||||
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
*/
|
||||
void
|
||||
ecore_x_window_prop_desktop_request(Ecore_X_Window win, long desktop)
|
||||
{
|
||||
long data[5];
|
||||
|
||||
data[0] = desktop;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
data[3] = 0;
|
||||
data[4] = 0;
|
||||
ecore_x_window_prop_property_notify(win, "_NET_WM_DESKTOP", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the window manager, or client prior mapping, to set window desktop.
|
||||
* @param win The Window
|
||||
* @param desktop The desktop number.
|
||||
*
|
||||
* Used by the window manager, or client prior mapping, to set window desktop.
|
||||
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
*/
|
||||
void
|
||||
ecore_x_window_prop_desktop_set(Ecore_X_Window win, long desktop)
|
||||
{
|
||||
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_desktop,
|
||||
XA_CARDINAL, 32, &desktop, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current desktop of a window
|
||||
* @param win The Window
|
||||
*
|
||||
* Get the current desktop of a window
|
||||
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
||||
*/
|
||||
long
|
||||
ecore_x_window_prop_desktop_get(Ecore_X_Window win)
|
||||
{
|
||||
int num;
|
||||
unsigned char *tmp;
|
||||
long desktop = -1;
|
||||
|
||||
ecore_x_window_prop_property_get(win, _ecore_x_atom_net_wm_desktop,
|
||||
XA_CARDINAL, 32, &tmp, &num);
|
||||
if ((tmp) && (num))
|
||||
{
|
||||
desktop = *(long *)tmp;
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
return desktop;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue