I will remove the -w (windowed) option from the master branch, for it
raises more problems than solutions, I will maintain it in the windowed
branch.
};
/* function declarations */
};
/* function declarations */
+static int menuexist(void);
static void getcolor(const char *s, XftColor *color);
static void getresources(void);
static void setupdc(void);
static void getcolor(const char *s, XftColor *color);
static void getresources(void);
static void setupdc(void);
static struct ScreenGeometry screengeom;
/* flag variables */
static struct ScreenGeometry screengeom;
/* flag variables */
-static Bool override_redirect = True;
while ((ch = getopt(argc, argv, "w")) != -1) {
switch (ch) {
case 'w':
while ((ch = getopt(argc, argv, "w")) != -1) {
switch (ch) {
case 'w':
- override_redirect = False;
colormap = DefaultColormap(dpy, screen);
wmdelete=XInternAtom(dpy, "WM_DELETE_WINDOW", True);
colormap = DefaultColormap(dpy, screen);
wmdelete=XInternAtom(dpy, "WM_DELETE_WINDOW", True);
+ /* exit if another menu exists */
+ if (menuexist()) {
+ XCloseDisplay(dpy);
+ return 1;
+ }
+
/* setup */
getresources();
setupdc();
/* setup */
getresources();
setupdc();
calcmenu(rootmenu);
/* grab mouse and keyboard */
calcmenu(rootmenu);
/* grab mouse and keyboard */
- if (override_redirect) {
grabpointer();
grabkeyboard();
}
grabpointer();
grabkeyboard();
}
+ return 0;
+}
+
+/* check whether another menu exists */
+static int
+menuexist(void)
+{
+ Window wina, winb; /* unused variables */
+ Window *children;
+ unsigned nchildren;
+ XClassHint classh;
+
+ if (XQueryTree(dpy, rootwin, &wina, &winb, &children, &nchildren) == 0)
+ errx(1, "could not query tree");
+
+ while (nchildren-- > 0) {
+ if (XGetClassHint(dpy, *children, &classh) != 0)
+ if (strcmp(classh.res_class, PROGNAME) == 0)
+ return 1;
+ children++;
+ }
menu->y = 0; /* calculated by calcmenu() */
menu->level = level;
menu->y = 0; /* calculated by calcmenu() */
menu->level = level;
- swa.override_redirect = override_redirect;
+ swa.override_redirect = (wflag) ? False : True;
swa.background_pixel = dc.decoration[ColorBG].pixel;
swa.border_pixel = dc.decoration[ColorFG].pixel;
swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask
swa.background_pixel = dc.decoration[ColorBG].pixel;
swa.border_pixel = dc.decoration[ColorFG].pixel;
swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask
screengeom.screenh = DisplayHeight(dpy, screen);
}
screengeom.screenh = DisplayHeight(dpy, screen);
}
-/* recursivelly calculate height and position of the menus */
+/* recursivelly calculate menu geometry and set window hints */
static void
calcmenu(struct Menu *menu)
{
static void
calcmenu(struct Menu *menu)
{
/* map menus from currmenu (inclusive) until lcamenu (exclusive) */
item = NULL;
for (menu = currmenu; menu != lcamenu; menu = menu->parent) {
/* map menus from currmenu (inclusive) until lcamenu (exclusive) */
item = NULL;
for (menu = currmenu; menu != lcamenu; menu = menu->parent) {
- if (override_redirect == False)
recalcmenu(menu);
XMapWindow(dpy, menu->win);
if (item != NULL)
recalcmenu(menu);
XMapWindow(dpy, menu->win);
if (item != NULL)