Explorar el Código

Use condition to get _WMFS_FUNCTIOn in event

Martin Duquesnoy hace 12 años
padre
commit
966fdb2acf
Se han modificado 4 ficheros con 25 adiciones y 16 borrados
  1. 4 4
      src/client.c
  2. 19 12
      src/event.c
  3. 1 0
      src/ewmh.c
  4. 1 0
      src/ewmh.h

+ 4 - 4
src/client.c

@@ -660,10 +660,10 @@ client_get_name(struct client *c)
      unsigned long ir, il;
 
      /* This one instead XFetchName for utf8 name support */
-     if(XGetWindowProperty(W->dpy, c->win, ATOM("_NET_WM_NAME"), 0, 4096,
-                    False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, (unsigned char**)&c->title) != Success)
-          XGetWindowProperty(W->dpy, c->win, ATOM("WM_NAME"), 0, 4096,
-                             False, ATOM("UTF8_STRING"), &rt, &rf, &ir, &il, (unsigned char**)&c->title);
+     if(XGetWindowProperty(W->dpy, c->win, W->net_atom[net_wm_name], 0, 65536,
+                    False, W->net_atom[utf8_string], &rt, &rf, &ir, &il, (unsigned char**)&c->title) != Success)
+          XGetWindowProperty(W->dpy, c->win, W->net_atom[net_wm_name], 0, 65536,
+                             False, W->net_atom[utf8_string], &rt, &rf, &ir, &il, (unsigned char**)&c->title);
 
      /* Still no title... */
      if(!c->title)

+ 19 - 12
src/event.c

@@ -110,21 +110,28 @@ event_clientmessageevent(XEvent *e)
                if(type == wmfs_function || type == wmfs_cmd)
                {
                     int d;
+                    long unsigned int len;
                     unsigned char *ret = NULL, *ret_cmd = NULL;
                     void (*func)(Uicb);
 
-                    XGetWindowProperty(EVDPY(e), W->root, W->net_atom[wmfs_function], 0, 4096,
-                                       False, W->net_atom[utf8_string], (Atom*)&d, &d,
-                                       (long unsigned int*)&d, (long unsigned int*)&d, &ret);
-                    XGetWindowProperty(EVDPY(e), W->root, W->net_atom[wmfs_cmd], 0, 4096,
-                                       False, W->net_atom[utf8_string], (Atom*)&d, &d,
-                                       (long unsigned int*)&d, (long unsigned int*)&d, &ret_cmd);
-
-                    if((func = uicb_name_func((char*)ret)))
-                         func((Uicb)ret_cmd);
-
-                    XFree(ret_cmd);
-                    XFree(ret);
+                    if(XGetWindowProperty(EVDPY(e), W->root, W->net_atom[wmfs_function], 0, 65536,
+                                          False, W->net_atom[utf8_string], (Atom*)&d, &d,
+                                          (long unsigned int*)&d, (long unsigned int*)&d, &ret) == Success
+                       && ret && ((func = uicb_name_func((char*)ret))))
+                    {
+                         if(XGetWindowProperty(EVDPY(e), W->root, W->net_atom[wmfs_cmd], 0, 65536,
+                                               False, W->net_atom[utf8_string], (Atom*)&d, &d,
+                                               &len, (long unsigned int*)&d, &ret_cmd) == Success
+                            && len && ret_cmd)
+                         {
+                              func((Uicb)ret_cmd);
+                              XFree(ret_cmd);
+                         }
+                         else
+                              func(NULL);
+
+                         XFree(ret);
+                    }
                }
           }
 

+ 1 - 0
src/ewmh.c

@@ -23,6 +23,7 @@ ewmh_init(void)
      /* EWMH hints */
      W->net_atom[wm_state]                       = ATOM("WM_STATE");
      W->net_atom[wm_class]                       = ATOM("WM_CLASS");
+     W->net_atom[wm_name]                        = ATOM("WM_NAME");
      W->net_atom[net_supported]                  = ATOM("_NET_SUPPORTED");
      W->net_atom[net_client_list]                = ATOM("_NET_CLIENT_LIST");
      W->net_atom[net_frame_extents]              = ATOM("_NET_FRAME_EXTENTS");

+ 1 - 0
src/ewmh.h

@@ -41,6 +41,7 @@ enum
      /* ICCCM */
      wm_state,
      wm_class,
+     wm_name,
      /* EWMH */
      net_supported,
      net_wm_name,