Adding X resource for gaps
[xmenu] / xmenu.c
diff --git a/xmenu.c b/xmenu.c
index 310b17d..92b1581 100644 (file)
--- a/xmenu.c
+++ b/xmenu.c
@@ -198,6 +198,9 @@ initresources(void)
        if (XrmGetResource(xdb, "xmenu.width", "*", &type, &xval) == True)
                if ((n = strtol(xval.addr, NULL, 10)) > 0)
                        config.width_pixels = n;
        if (XrmGetResource(xdb, "xmenu.width", "*", &type, &xval) == True)
                if ((n = strtol(xval.addr, NULL, 10)) > 0)
                        config.width_pixels = n;
+       if (XrmGetResource(xdb, "xmenu.gap", "*", &type, &xval) == True)
+               if ((n = strtol(xval.addr, NULL, 10)) > 0)
+                       config.gap_pixels = n;
        if (XrmGetResource(xdb, "xmenu.background", "*", &type, &xval) == True)
                config.background_color = strdup(xval.addr);
        if (XrmGetResource(xdb, "xmenu.foreground", "*", &type, &xval) == True)
        if (XrmGetResource(xdb, "xmenu.background", "*", &type, &xval) == True)
                config.background_color = strdup(xval.addr);
        if (XrmGetResource(xdb, "xmenu.foreground", "*", &type, &xval) == True)
@@ -300,7 +303,7 @@ allocitem(const char *label, const char *output, char *file)
        return item;
 }
 
        return item;
 }
 
-/* allocate a menu */
+/* allocate a menu and create its window */
 static struct Menu *
 allocmenu(struct Menu *parent, struct Item *list, unsigned level)
 {
 static struct Menu *
 allocmenu(struct Menu *parent, struct Item *list, unsigned level)
 {
@@ -333,8 +336,6 @@ allocmenu(struct Menu *parent, struct Item *list, unsigned level)
                                  CWBorderPixel | CWEventMask | CWSaveUnder,
                                  &swa);
 
                                  CWBorderPixel | CWEventMask | CWSaveUnder,
                                  &swa);
 
-       XSetWMProtocols(dpy, menu->win, &wmdelete, 1);
-
        return menu;
 }
 
        return menu;
 }
 
@@ -568,10 +569,10 @@ setupmenu(struct Menu *menu, XClassHint *classh)
                                     DefaultDepth(dpy, screen));
        menu->draw = XftDrawCreate(dpy, menu->pixmap, visual, colormap);
 
                                     DefaultDepth(dpy, screen));
        menu->draw = XftDrawCreate(dpy, menu->pixmap, visual, colormap);
 
-       /* set ewmh window properties */
+       /* set WM protocols and ewmh window properties */
+       XSetWMProtocols(dpy, menu->win, &wmdelete, 1);
        XChangeProperty(dpy, menu->win, netatom[NetWMName], utf8string, 8,
        XChangeProperty(dpy, menu->win, netatom[NetWMName], utf8string, 8,
-                       PropModeReplace,
-                       (unsigned char *)title, strlen(title));
+                       PropModeReplace, (unsigned char *)title, strlen(title));
        XChangeProperty(dpy, menu->win, netatom[NetWMWindowType], XA_ATOM, 32,
                        PropModeReplace,
                        (unsigned char *)&netatom[NetWMWindowTypePopupMenu], 1);
        XChangeProperty(dpy, menu->win, netatom[NetWMWindowType], XA_ATOM, 32,
                        PropModeReplace,
                        (unsigned char *)&netatom[NetWMWindowTypePopupMenu], 1);