diff --git a/legacy/ecore/src/lib/ecore_x/Ecore_X.h b/legacy/ecore/src/lib/ecore_x/Ecore_X.h index 460e225ef7..8aed6be5a9 100644 --- a/legacy/ecore/src/lib/ecore_x/Ecore_X.h +++ b/legacy/ecore/src/lib/ecore_x/Ecore_X.h @@ -1012,7 +1012,14 @@ EAPI int ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_A ecore_x_icccm_command_set(Ecore_X_Window win, int argc, char **argv); EAPI void ecore_x_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv); - + EAPI char * + ecore_x_icccm_icon_name_get(Ecore_X_Window win); + EAPI void + ecore_x_icccm_icon_name_set(Ecore_X_Window win, const char *t); + EAPI void + ecore_x_icccm_colormap_window_set(Ecore_X_Window win, Ecore_X_Window subwin); + EAPI void + ecore_x_icccm_colormap_window_unset(Ecore_X_Window win, Ecore_X_Window subwin); typedef enum _Ecore_X_MWM_Hint_Func { diff --git a/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c b/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c index 2df9f46ab5..95a51fc07a 100644 --- a/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c +++ b/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c @@ -591,16 +591,156 @@ ecore_x_window_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv) XGetCommand(_ecore_x_disp, win, argv, argc); } +/** + * Set a window icon name. + * @param win The window + * @param t The icon name string + * + * Set a window icon name + */ +void +ecore_x_icccm_icon_name_set(Ecore_X_Window win, const char *t) +{ + ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_icon_name, (char *)t); + ecore_x_window_prop_string_set(win, _ecore_x_atom_net_wm_icon_name, + (char *)t); +} +/** + * Get a window icon name. + * @param win The window + * @return The windows icon name string + * + * Return the icon name of a window. String must be free'd when done with. + */ +char * +ecore_x_icccm_icon_name_get(Ecore_X_Window win) +{ + char *name; + + name = ecore_x_window_prop_string_get(win, _ecore_x_atom_net_wm_icon_name); + if (!name) name = ecore_x_window_prop_string_get(win, _ecore_x_atom_wm_icon_name); + return name; +} + +/** + * Add a subwindow to the list of windows that need a different colormap installed. + * @param win The toplevel window + * @param subwin The subwindow to be added to the colormap windows list + */ +void +ecore_x_icccm_colormap_window_set(Ecore_X_Window win, Ecore_X_Window subwin) +{ + int num = 0, i; + unsigned char *old_data = NULL; + unsigned char *data = NULL; + Window *oldset = NULL; + Window *newset = NULL; + + if(!ecore_x_window_prop_property_get(win, + _ecore_x_atom_wm_colormap_windows, + XA_WINDOW, + 32, + &old_data, + &num)) + { + newset = calloc(1, sizeof(Window)); + if (!newset) return; + newset[0] = subwin; + num = 1; + data = (unsigned char *)newset; + } + else + { + newset = calloc(num + 1, sizeof(Window)); + oldset = (Window *) old_data; + if (!newset) return; + for (i = 0; i < num; ++i) + { + if (oldset[i] == subwin) + { + XFree(old_data); + free(newset); + return; + } + + newset[i] = oldset[i]; + } + + newset[num++] = subwin; + XFree(old_data); + data = (unsigned char *)newset; + } + + ecore_x_window_prop_property_set(win, + _ecore_x_atom_wm_colormap_windows, + XA_WINDOW, + 32, + data, + num); + free(newset); +} + +/** + * Remove a window from the list of colormap windows. + * @param win The toplevel window + * @param subwin The window to be removed from the colormap window list. + */ +void +ecore_x_icccm_colormap_window_unset(Ecore_X_Window win, Ecore_X_Window subwin) +{ + int num = 0, i, j, k = 0; + unsigned char *old_data = NULL; + unsigned char *data = NULL; + Window *oldset = NULL; + Window *newset = NULL; + + if (!ecore_x_window_prop_property_get(win, + _ecore_x_atom_wm_colormap_windows, + XA_WINDOW, + 32, + &old_data, + &num)) + return; + + oldset = (Window *) old_data; + for (i = 0; i < num; i++) + { + if (oldset[i] == subwin) + { + if (num == 1) + { + XDeleteProperty(_ecore_x_disp, + win, + _ecore_x_atom_wm_colormap_windows); + XFree(old_data); + return; + } + else + { + newset = calloc(num - 1, sizeof(Window)); + data = (unsigned char *)newset; + for (j = 0; j < num; ++j) + if (oldset[j] != subwin) + newset[k++] = oldset[j]; + ecore_x_window_prop_property_set(win, + _ecore_x_atom_wm_colormap_windows, + XA_WINDOW, + 32, + data, + k); + XFree(old_data); + free(newset); + return; + } + } + } + + XFree(old_data); +} /* FIXME: move these things in here as they are icccm related */ -/* get/set wm protocols */ -/* get/set name/class */ -/* get/set machine */ -/* get/set command */ -/* get/set icon name */ -/* get/set colormap windows */ /* get/set window role */ /* get/set client leader */ /* get/set transient for */ diff --git a/legacy/ecore/src/lib/ecore_x/ecore_x_window_prop.c b/legacy/ecore/src/lib/ecore_x/ecore_x_window_prop.c index 2ab9e75543..94fb46a140 100644 --- a/legacy/ecore/src/lib/ecore_x/ecore_x_window_prop.c +++ b/legacy/ecore/src/lib/ecore_x/ecore_x_window_prop.c @@ -324,6 +324,7 @@ ecore_x_window_prop_visible_title_get(Ecore_X_Window win) * @param t The icon name string * * Set a window icon name + * DEPRECATED. Please use ecore_x_icccm_icon_name_set() instead. */ void ecore_x_window_prop_icon_name_set(Ecore_X_Window win, const char *t) @@ -339,6 +340,7 @@ ecore_x_window_prop_icon_name_set(Ecore_X_Window win, const char *t) * @return The windows icon name string * * Return the icon name of a window. String must be free'd when done with. + * DEPRECATED. Please use ecore_x_icccm_icon_name_get() instead. */ char * ecore_x_window_prop_icon_name_get(Ecore_X_Window win)