Enlightenment CVS committal
Author : xcomputerman
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_x
Modified Files:
Ecore_X.h ecore_x.c ecore_x_netwm.c
Log Message:
Add netwm window state hints to ecore_x_netwm.c
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -3 -r1.86 -r1.87
--- Ecore_X.h 29 Dec 2004 12:36:24 -0000 1.86
+++ Ecore_X.h 30 Dec 2004 05:35:57 -0000 1.87
@@ -927,6 +927,7 @@
EAPI int ecore_x_drawable_border_width_get(Ecore_X_Drawable d);
EAPI int ecore_x_drawable_depth_get(Ecore_X_Drawable d);
EAPI Ecore_X_Window *ecore_x_window_root_list(int *num_ret);
+ EAPI Ecore_X_Window ecore_x_window_root_first_get(void);
EAPI int ecore_x_window_manage(Ecore_X_Window win);
EAPI void ecore_x_window_container_manage(Ecore_X_Window win);
EAPI void ecore_x_window_client_manage(Ecore_X_Window win);
@@ -1093,6 +1094,8 @@
EAPI int ecore_x_netwm_desktop_get(Ecore_X_Window win,
unsigned int *desk);
EAPI void ecore_x_netwm_opacity_set(Ecore_X_Window win,
unsigned int opacity);
EAPI int ecore_x_netwm_opacity_get(Ecore_X_Window win,
unsigned int *opacity);
+ EAPI void ecore_x_netwm_window_state_set(Ecore_X_Window win,
Ecore_X_Window_State state, int on);
+ EAPI int ecore_x_netwm_window_state_isset(Ecore_X_Window
win, Ecore_X_Window_State state);
/* FIXME: these funcs need categorising */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -3 -r1.59 -r1.60
--- ecore_x.c 29 Dec 2004 12:36:24 -0000 1.59
+++ ecore_x.c 30 Dec 2004 05:35:59 -0000 1.60
@@ -788,6 +788,25 @@
return roots;
}
+Ecore_X_Window
+ecore_x_window_root_first_get(void)
+{
+ int num;
+ Ecore_X_Window root, *roots = NULL;
+
+ roots = ecore_x_window_root_list(&num);
+ if(!(roots)) return 0;
+
+ if (num > 0)
+ root = roots[0];
+ else
+ root = 0;
+
+ free(roots);
+ return root;
+}
+
+
static void _ecore_x_window_manage_error(void *data);
static int _ecore_x_window_manage_failed = 0;
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_netwm.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ecore_x_netwm.c 9 Dec 2004 19:29:24 -0000 1.6
+++ ecore_x_netwm.c 30 Dec 2004 05:36:01 -0000 1.7
@@ -139,6 +139,36 @@
return str;
}
+/* Set/clear atom in list */
+static void
+_ecore_x_netwm_atom_list_set(Ecore_X_Atom *atoms, int size, int *count,
+ Ecore_X_Atom atom, int set)
+{
+ int i, n, in_list;
+
+ n = *count;
+ /* Check if atom is in list or not (+get index) */
+ for (i = 0; i < n; i++)
+ if (atoms[i] == atom)
+ break;
+ in_list = i < n;
+
+ if (set && !in_list)
+ {
+ /* Add it (if space left) */
+ if (n < size)
+ atoms[n++] = atom;
+ *count = n;
+ }
+ else if (!set && in_list)
+ {
+ /* Remove it */
+ atoms[i] = atoms[--n];
+ *count = n;
+ }
+}
+
+
/*
* Root window NetWM hints.
*/
@@ -498,3 +528,123 @@
return ecore_x_window_prop_card32_get(win,
ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
opacity, 1);
}
+
+static Ecore_X_Atom
+_ecore_x_netwm_state_atom_get(Ecore_X_Window_State s)
+{
+ switch(s)
+ {
+ case ECORE_X_WINDOW_STATE_MODAL:
+ return ECORE_X_ATOM_NET_WM_STATE_MODAL;
+ case ECORE_X_WINDOW_STATE_STICKY:
+ return ECORE_X_ATOM_NET_WM_STATE_STICKY;
+ case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
+ return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT;
+ case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
+ return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ;
+ case ECORE_X_WINDOW_STATE_SHADED:
+ return ECORE_X_ATOM_NET_WM_STATE_SHADED;
+ case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
+ return ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR;
+ case ECORE_X_WINDOW_STATE_SKIP_PAGER:
+ return ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER;
+ case ECORE_X_WINDOW_STATE_HIDDEN:
+ return ECORE_X_ATOM_NET_WM_STATE_HIDDEN;
+ case ECORE_X_WINDOW_STATE_FULLSCREEN:
+ return ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN;
+ case ECORE_X_WINDOW_STATE_ABOVE:
+ return ECORE_X_ATOM_NET_WM_STATE_ABOVE;
+ case ECORE_X_WINDOW_STATE_BELOW:
+ return ECORE_X_ATOM_NET_WM_STATE_BELOW;
+ default:
+ return 0;
+ }
+
+}
+
+int
+ecore_x_netwm_window_state_isset(Ecore_X_Window win, Ecore_X_Window_State s)
+{
+ int num, i, ret = 0;
+ unsigned char *data;
+ Ecore_X_Atom *states, state;
+
+ state = _ecore_x_netwm_state_atom_get(s);
+ if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_NET_WM_STATE,
+ XA_ATOM, 32, &data, &num))
+ return ret;
+
+ states = (Ecore_X_Atom *) data;
+
+ for (i = 0; i < num; ++i)
+ {
+ if (states[i] == state)
+ {
+ ret = 1;
+ break;
+ }
+ }
+
+ XFree(data);
+ return ret;
+}
+
+void
+ecore_x_netwm_window_state_set(Ecore_X_Window win, Ecore_X_Window_State state,
int on)
+{
+ Ecore_X_Atom atom;
+ Ecore_X_Atom *oldset = NULL, *newset = NULL;
+ int i, j = 0, num = 0;
+ unsigned char *data = NULL;
+ unsigned char *old_data = NULL;
+
+ atom = _ecore_x_netwm_state_atom_get(state);
+
+ ecore_x_window_prop_property_get(win, ECORE_X_ATOM_NET_WM_STATE,
+ XA_ATOM, 32, &old_data, &num);
+ oldset = (Ecore_X_Atom *) old_data;
+
+ if (on)
+ {
+ if (ecore_x_netwm_window_state_isset(win, state))
+ {
+ XFree(old_data);
+ return;
+ }
+ newset = calloc(num + 1, sizeof(Ecore_X_Atom));
+ if (!newset) return;
+ data = (unsigned char *) newset;
+
+ for (i = 0; i < num; i++)
+ newset[i] = oldset[i];
+ newset[num] = state;
+ }
+ else
+ {
+ if (!ecore_x_netwm_window_state_isset(win, state))
+ {
+ XFree(old_data);
+ return;
+ }
+ newset = calloc(num - 1, sizeof(Atom));
+ if (!newset)
+ {
+ XFree(old_data);
+ return;
+ }
+ data = (unsigned char *) newset;
+ for (i = 0; i < num; i++)
+ if (oldset[i] != state)
+ newset[j++] = oldset[i];
+ }
+
+ ecore_x_window_prop_property_set(win, ECORE_X_ATOM_NET_WM_STATE,
+ XA_ATOM, 32, data, j);
+ XFree(oldset);
+ free(newset);
+}
+
+
+
+
+
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs