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_icccm.c ecore_x_window_prop.c 


Log Message:
More ICCCM code, replicated from window_prop*. Corresponding functions are
deprecated and will be removed in the future.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/Ecore_X.h,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -3 -r1.76 -r1.77
--- Ecore_X.h   25 Nov 2004 14:09:23 -0000      1.76
+++ Ecore_X.h   26 Nov 2004 06:42:24 -0000      1.77
@@ -995,6 +995,24 @@
      ecore_x_icccm_title_set(Ecore_X_Window win, const char *t);
    EAPI char *
      ecore_x_icccm_title_get(Ecore_X_Window win);
+   EAPI void
+     ecore_x_icccm_protocol_set(Ecore_X_Window win,
+                                Ecore_X_WM_Protocol protocol,
+                                int on);
+   EAPI int
+     ecore_x_icccm_protocol_isset(Ecore_X_Window win,
+                                  Ecore_X_WM_Protocol protocol);
+   EAPI void
+     ecore_x_icccm_name_class_set(Ecore_X_Window win,
+                                  const char *n,
+                                  const char *c);
+   EAPI char *
+     ecore_x_icccm_client_machine_get(Ecore_X_Window win);
+   EAPI void
+     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);
+   
    
    typedef enum _Ecore_X_MWM_Hint_Func
      {
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_icccm.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ecore_x_icccm.c     24 Nov 2004 07:27:58 -0000      1.7
+++ ecore_x_icccm.c     26 Nov 2004 06:42:24 -0000      1.8
@@ -409,6 +409,191 @@
    return NULL;
 }
 
+/**
+ * Set or unset a wm protocol property.
+ * @param win The Window
+ * @param protocol The protocol to enable/disable
+ * @param on On/Off
+ */
+void
+ecore_x_icccm_protocol_set(Ecore_X_Window win,
+                           Ecore_X_WM_Protocol protocol,
+                           int on)
+{
+   Atom *protos = NULL;
+   Atom  proto;
+   int   protos_count = 0;
+   int   already_set = 0;
+   int   i;
+
+   /* Check for invalid values */
+   if (protocol < 0 || protocol >= ECORE_X_WM_PROTOCOL_NUM)
+      return;
+
+   proto = _ecore_x_atoms_wm_protocols[protocol];
+
+   if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
+   {
+      protos = NULL;
+      protos_count = 0;
+   }
+
+   for (i = 0; i < protos_count; i++)
+   {
+      if (protos[i] == proto)
+      {
+         already_set = 1;
+         break;
+      }
+   }
+
+   if (on)
+   {
+      Atom *new_protos = NULL;
+
+      if (already_set) goto leave;
+      new_protos = malloc((protos_count + 1) * sizeof(Atom));
+      if (!new_protos) goto leave;
+      for (i = 0; i < protos_count; i++)
+         new_protos[i] = protos[i];
+      new_protos[protos_count] = proto;
+      XSetWMProtocols(_ecore_x_disp, win, new_protos, protos_count + 1);
+      free(new_protos);
+   }
+   else
+   {
+      if (!already_set) goto leave;
+      for (i = 0; i < protos_count; i++)
+      {
+         if (protos[i] == proto)
+         {
+            int j;
+
+            for (j = i + 1; j < protos_count; j++)
+               protos[j-1] = protos[j];
+            if (protos_count > 1)
+               XSetWMProtocols(_ecore_x_disp, win, protos, 
+                               protos_count - 1);
+            else
+               XDeleteProperty(_ecore_x_disp, win,
+                               _ecore_x_atom_wm_protocols);
+            goto leave;
+         }
+      }
+   }
+
+   leave:
+   if (protos)
+      XFree(protos);
+
+}
+
+
+/**
+ * Determines whether a protocol is set for a window.
+ * @param win The Window
+ * @param protocol The protocol to query
+ * @return 1 if the protocol is set, else 0.
+ */
+int
+ecore_x_icccm_protocol_isset(Ecore_X_Window win,
+                             Ecore_X_WM_Protocol protocol)
+{
+   Atom proto, *protos = NULL;
+   int i, ret = 0, protos_count = 0;
+
+   /* check for invalid values */
+   if (protocol < 0 || protocol >= ECORE_X_WM_PROTOCOL_NUM)
+      return 0;
+
+   proto = _ecore_x_atoms_wm_protocols[protocol];
+
+   if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
+      return 0;
+   
+   for (i = 0; i < protos_count; i++)
+      if (protos[i] == proto)
+      {
+         ret = 1;
+         break;
+      }
+
+   XFree(protos);
+   return ret;
+
+}
+
+/**
+ * Set a window name & class.
+ * @param win The window
+ * @param n The name string
+ * @param c The class string
+ * 
+ * Set a window name * class
+ */
+void
+ecore_x_icccm_name_class_set(Ecore_X_Window win,
+                             const char *n,
+                             const char *c)
+{
+   XClassHint *xch;
+
+   xch = XAllocClassHint();
+   if (!xch)
+      return;
+   xch->res_name = (char *)n;
+   xch->res_class = (char *)c;
+   XSetClassHint(_ecore_x_disp, win, xch);
+   XFree(xch);
+}
+
+/**
+ * Get a window client machine string.
+ * @param win The window
+ * @return The windows client machine string
+ * 
+ * Return the client machine of a window. String must be free'd when done with.
+ */
+char *
+ecore_x_icccm_client_machine_get(Ecore_X_Window win)
+{
+   char *name;
+
+   name = ecore_x_window_prop_string_get(win, _ecore_x_atom_wm_client_machine);
+   return name;
+}
+
+/**
+ * Sets the WM_COMMAND property for @a win.
+ * 
+ * @param win  The window.
+ * @param argc Number of arguments.
+ * @param argv Arguments.
+ */
+void
+ecore_x_icccm_command_set(Ecore_X_Window win, int argc, char **argv)
+{
+   XSetCommand(_ecore_x_disp, win, argv, argc);
+}
+
+/**
+ * Get the WM_COMMAND property for @a win.
+ *
+ * Return the command of a window. String must be free'd when done with.
+ *
+ * @param win  The window.
+ * @param argc Number of arguments.
+ * @param argv Arguments.
+ */
+void
+ecore_x_window_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv)
+{
+   XGetCommand(_ecore_x_disp, win, argv, argc);
+}
+
+
+
+ 
 /* FIXME: move these things in here as they are icccm related */
 /* get/set wm protocols */
 /* get/set name/class */
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_x/ecore_x_window_prop.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -3 -r1.53 -r1.54
--- ecore_x_window_prop.c       25 Nov 2004 14:09:24 -0000      1.53
+++ ecore_x_window_prop.c       26 Nov 2004 06:42:24 -0000      1.54
@@ -260,6 +260,8 @@
  * @param win  The window.
  * @param argc Number of arguments.
  * @param argv Arguments.
+ *
+ * DEPRECATED. Please use ecore_x_icccm_command_set() instead.
  */
 void
 ecore_x_window_prop_command_set(Ecore_X_Window win, int argc, char **argv)
@@ -275,6 +277,8 @@
  * @param win  The window.
  * @param argc Number of arguments.
  * @param argv Arguments.
+ *
+ * DEPRECATED. Please use ecore_x_icccm_command_get() instead.
  */
 void
 ecore_x_window_prop_command_get(Ecore_X_Window win, int *argc, char ***argv)
@@ -382,6 +386,7 @@
  * @return The windows client machine string
  * 
  * Return the client machine of a window. String must be free'd when done with.
+ * DEPRECATED. Please use ecore_x_icccm_client_machine_get() instead.
  */
 char *
 ecore_x_window_prop_client_machine_get(Ecore_X_Window win)
@@ -423,6 +428,7 @@
  * @param c The class string
  * 
  * Set a window name * class
+ * DEPRECATED. Please use ecore_x_icccm_name_class_set() instead.
  */
 void
 ecore_x_window_prop_name_class_set(Ecore_X_Window win, const char *n, const 
char *c)
@@ -473,7 +479,8 @@
  * @param win The Window
  * @param protocol The protocol to enable/disable
  * @param on On/Off
- * 
+ *
+ * DEPRECATED. Please use ecore_x_icccm_protocol_set() instead.
  */
 void
 ecore_x_window_prop_protocol_set(Ecore_X_Window win,
@@ -547,6 +554,8 @@
  * @param win The Window
  * @param protocol The protocol to query
  * @return 1 if the protocol is set, else 0.
+ *
+ * DEPRECATED. Please use ecore_x_icccm_protocol_isset() instead.
  */
 int
 ecore_x_window_prop_protocol_isset(Ecore_X_Window win,




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to