Add icon name set/get, colormap window set/unset ICCCM functions
authorxcomputerman <xcomputerman>
Fri, 26 Nov 2004 07:28:51 +0000 (07:28 +0000)
committerxcomputerman <xcomputerman@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 26 Nov 2004 07:28:51 +0000 (07:28 +0000)
SVN revision: 12269

legacy/ecore/src/lib/ecore_x/Ecore_X.h
legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c
legacy/ecore/src/lib/ecore_x/ecore_x_window_prop.c

index 460e225..8aed6be 100644 (file)
@@ -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
      {
index 2df9f46..95a51fc 100644 (file)
@@ -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 */
index 2ab9e75..94fb46a 100644 (file)
@@ -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)