shod

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e8184fa2479b80c133d89bca678d5d8589e4a258
parent d9fd653ac0ce76208e81dd0afc2d124bd0a33471
Author: seninha <lucas@seninha.org>
Date:   Mon, 26 Sep 2022 00:34:41 -0300

add automatic tabbing; dettach menu from tab; etc

I'm working on a fork of suckless's surf(1) web browser that uses
shod(1), rather than tabbed(1), for tabbing.  Previously, shod did
tabbing manually: the user needed to drag and drop a window into another
in order for both to be tabbed.  With this commit, a window being mapped
sharing the same leader as another, already mapped, window (or if the
second is the leader of the first), the window being mapped is placed
automatically as a tab next to the other.  Thus, middle clicking a link
in my fork of surf opens the new surf instance in a new tab.

Previously, menus were relative to a single window and could not be
shared.  This behavior breaked gimp's multi window mode (where the
palletes menus are shared between open images).  So if the user has two
images open, the menus only appeared on the window of the first image
(which the menus are relative to), and when the user focus the window of
the next image, the menus disappeared.  With this commit, menus can be
shared between windows.

I also fixed a bug on splash screens that made shod not map new windows
while the splash screen was visible.  Thankfully, splash screens are
short-lived windows, so that bug was only active during the short splash
screen's lifetime.

Diffstat:
Mshod.h | 13+++++++------
Mxcontainer.c | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Mxdraw.c | 105++++++++++++++++++++++++++++++++-----------------------------------------------
Mxevents.c | 69++++++++++++++++++++++++++++++++-------------------------------------
Mxhints.c | 2+-
Mxmenu.c | 46++++++++++++++++++----------------------------
Mxmon.c | 10+---------
Mxsplash.c | 12+++---------
Mxutil.c | 21+++++++++++++++++----
Mxutil.h | 1+
10 files changed, 178 insertions(+), 177 deletions(-)

diff --git a/shod.h b/shod.h @@ -401,7 +401,6 @@ struct Tab { * its parent row. */ struct Queue dialq; /* queue of dialogs */ - struct Queue menuq; /* queue of menus */ struct Row *row; /* pointer to parent row */ /* @@ -473,9 +472,8 @@ struct Dialog { struct Menu { struct Object obj; - struct Queue *menuq; /* pointer to queue it is in */ - struct Tab *tab; /* tab for menu (if existant) */ struct Monitor *mon; + Window leader; /* * Frames, pixmaps, saved pixmap geometry, etc @@ -534,7 +532,7 @@ struct WM { struct Queue barq; /* queue of bars */ struct Queue splashq; /* queue of splash screen windows */ struct Queue notifq; /* queue of notifications */ - struct Queue menuq; /* queue of desktop menus */ + struct Queue menuq; /* queue of menus */ struct ContainerQueue focusq; /* queue of containers ordered by focus history */ int nclients; /* total number of container windows */ @@ -650,6 +648,7 @@ typedef int Unmanagefunc(struct Object *obj, int ignoreunmap); /* container routines */ struct Container *getnextfocused(struct Monitor *mon, int desk); struct Container *containerraisetemp(struct Container *prevc, int backward); +void containernewwithtab(struct Tab *tab, struct Monitor *mon, int desk, XRectangle rect, int state); void containerbacktoplace(struct Container *c, int restack); void containerdel(struct Container *c); void containermoveresize(struct Container *c, int checkstack); @@ -676,6 +675,7 @@ int containerisshaded(struct Container *c); int containerisvisible(struct Container *c, struct Monitor *mon, int desk); /* menu */ +void menufocus(struct Menu *menu); void menuhide(struct Menu *menu, int hide); void menuincrmove(struct Menu *menu, int x, int y); void menuconfigure(struct Menu *menu, unsigned int valuemask, XWindowChanges *wc); @@ -705,6 +705,7 @@ void fitmonitor(struct Monitor *mon, int *x, int *y, int *w, int *h, float facto void icccmdeletestate(Window win); void icccmwmstate(Window win, int state); void ewmhinit(const char *wmname); +void ewmhsetdesktop(Window win, long d); void ewmhsetframeextents(Window win, int b, int t); void ewmhsetclients(void); void ewmhsetclientsstacking(void); @@ -742,7 +743,7 @@ Managefunc managesplash; Managefunc manageprompt; Managefunc managenotif; Managefunc managemenu; -Managefunc managetab; +Managefunc managecontainer; Managefunc managebar; Unmanagefunc unmanagedockapp; Unmanagefunc unmanagedialog; @@ -750,7 +751,7 @@ Unmanagefunc unmanagesplash; Unmanagefunc unmanageprompt; Unmanagefunc unmanagenotif; Unmanagefunc unmanagemenu; -Unmanagefunc unmanagetab; +Unmanagefunc unmanagecontainer; Unmanagefunc unmanagebar; void setmod(void); void scan(void); diff --git a/xcontainer.c b/xcontainer.c @@ -31,7 +31,7 @@ snaptoedge(int *x, int *y, int w, int h) if (abs(*x + w - wm.selmon->wx - wm.selmon->ww) < config.snap) *x = wm.selmon->wx + wm.selmon->ww - w; TAILQ_FOREACH(c, &wm.focusq, entry) { - if (containerisvisible(c, wm.selmon, wm.selmon->seldesk)) { + if (!c->isminimized && containerisvisible(c, wm.selmon, wm.selmon->seldesk)) { if (*x + w >= c->x && *x <= c->x + c->w) { if (abs(*y + h - c->y) < config.snap) { *y = c->y - h; @@ -166,17 +166,21 @@ dialognew(Window win, int maxw, int maxh, int ignoreunmap) static void tabhidemenus(struct Tab *tab, int hide) { - struct Object *menu; + struct Object *obj; + struct Menu *menu; if (tab == NULL) return; - TAILQ_FOREACH(menu, &tab->menuq, entry) { + TAILQ_FOREACH(obj, &wm.menuq, entry) { + menu = ((struct Menu *)obj); + if (menu->leader != tab->obj.win && menu->leader != tab->leader) + continue; if (hide) { - XMapWindow(dpy, ((struct Menu *)menu)->frame); - icccmwmstate(menu->win, NormalState); + XUnmapWindow(dpy, ((struct Menu *)obj)->frame); + icccmwmstate(obj->win, IconicState); } else { - XUnmapWindow(dpy, ((struct Menu *)menu)->frame); - icccmwmstate(menu->win, IconicState); + XMapWindow(dpy, menu->frame); + icccmwmstate(obj->win, NormalState); } } } @@ -278,7 +282,6 @@ tabnew(Window win, Window leader, int ignoreunmap) .obj.type = TYPE_NORMAL, }; TAILQ_INIT(&tab->dialq); - TAILQ_INIT(&tab->menuq); ((struct Object *)tab)->type = TYPE_NORMAL; tab->frame = XCreateWindow(dpy, root, 0, 0, 1, 1, 0, depth, CopyFromParent, visual, clientmask, &clientswa), XReparentWindow(dpy, tab->obj.win, tab->frame, 0, 0); @@ -293,16 +296,12 @@ static void tabdel(struct Tab *tab) { struct Dialog *dial; - struct Menu *menu; + tabhidemenus(tab, ADD); while ((dial = (struct Dialog *)TAILQ_FIRST(&tab->dialq)) != NULL) { XDestroyWindow(dpy, dial->obj.win); unmanagedialog((struct Object *)dial, 0); } - while ((menu = (struct Menu *)TAILQ_FIRST(&tab->menuq)) != NULL) { - XDestroyWindow(dpy, menu->obj.win); - unmanagemenu((struct Object *)menu, 0); - } tabdetach(tab, 0, 0); if (tab->pixtitle != None) XFreePixmap(dpy, tab->pixtitle); @@ -593,6 +592,7 @@ containerhide(struct Container *c, int hide) tabhidemenus(c->selcol->selrow->seltab, ADD); } else { XMapWindow(dpy, c->frame); + tabhidemenus(c->selcol->selrow->seltab, REMOVE); } TAB_FOREACH_BEGIN(c, t) { icccmwmstate(t->win, (hide ? IconicState : NormalState)); @@ -1167,6 +1167,7 @@ containerincrmove(struct Container *c, int x, int y) void containerraise(struct Container *c, int isfullscreen, int abovebelow) { + struct Tab *tab; struct Menu *menu; struct Object *obj; Window wins[2]; @@ -1188,7 +1189,14 @@ containerraise(struct Container *c, int isfullscreen, int abovebelow) c->isfullscreen = isfullscreen; c->abovebelow = abovebelow; XRestackWindows(dpy, wins, 2); - TAILQ_FOREACH(obj, &c->selcol->selrow->seltab->menuq, entry) { + tab = c->selcol->selrow->seltab; + + /* raise any menu for the container */ + wins[0] = wm.layers[LAYER_MENU].frame; + TAILQ_FOREACH(obj, &wm.menuq, entry) { + menu = ((struct Menu *)obj); + if (menu->leader != tab->obj.win && menu->leader != tab->leader) + continue; menu = (struct Menu *)obj; wins[1] = menu->frame; XRestackWindows(dpy, wins, 2); @@ -1453,6 +1461,7 @@ found: tabfocus(det, 0); XMapSubwindows(dpy, c->frame); /* no need to call shodgrouptab() and shodgroupcontainer(); tabfocus() already calls them */ + ewmhsetdesktop(det->obj.win, c->desk); ewmhsetclientsstacking(); containermoveresize(c, 0); containerredecorate(c, NULL, NULL, 0); @@ -1768,16 +1777,14 @@ dialogmoveresize(struct Dialog *dial) /* create container for tab */ void -managetab(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window leader, XRectangle rect, int state, int ignoreunmap) +containernewwithtab(struct Tab *tab, struct Monitor *mon, int desk, XRectangle rect, int state) { struct Container *c; struct Column *col; struct Row *row; - if (tab == NULL) { - tab = tabnew(win, leader, ignoreunmap); - winupdatetitle(tab->obj.win, &tab->name); - } + if (tab == NULL) + return; c = containernew(rect.x, rect.y, rect.width, rect.height, state); c->mon = mon; c->desk = desk; @@ -1804,6 +1811,35 @@ managetab(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window lea /* create container for tab */ void +managecontainer(struct Tab *prev, struct Monitor *mon, int desk, Window win, Window leader, XRectangle rect, int state, int ignoreunmap) +{ + struct Tab *tab; + struct Container *c; + struct Row *row; + + tab = tabnew(win, leader, ignoreunmap); + winupdatetitle(tab->obj.win, &tab->name); + if (prev == NULL) { + containernewwithtab(tab, mon, desk, rect, state); + } else { + row = prev->row; + c = row->col->c; + rowaddtab(row, tab, prev); + rowcalctabs(row); + ewmhsetdesktop(win, c->desk); + ewmhsetclients(); + ewmhsetclientsstacking(); + containermoveresize(c, 0); + containerredecorate(c, NULL, NULL, 0); + XMapSubwindows(dpy, c->frame); + if (wm.focused == c) { + tabfocus(tab, 1); + } + } +} + +/* create container for tab */ +void managedialog(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window leader, XRectangle rect, int state, int ignoreunmap) { struct Dialog *dial; @@ -1827,7 +1863,7 @@ managedialog(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window /* unmanage tab (and delete its row if it is the only tab); return whether deletion occurred */ int -unmanagetab(struct Object *obj, int ignoreunmap) +unmanagecontainer(struct Object *obj, int ignoreunmap) { struct Container *c, *next; struct Column *col; diff --git a/xdraw.c b/xdraw.c @@ -44,48 +44,6 @@ getexposed(Window win, Pixmap *pix, int *pw, int *ph) struct Menu *menu; struct Notification *notif; - if (wm.wmcheckwin == win) { - *pix = wm.wmcheckpix; - *pw = 2 * config.borderwidth + config.titlewidth; - *ph = 2 * config.borderwidth + config.titlewidth; - return 1; - } - if (dock.win == win) { - *pix = dock.pix; - *pw = dock.w; - *ph = dock.h; - return 1; - } - TAILQ_FOREACH(m, &wm.menuq, entry) { - menu = (struct Menu *)m; - if (menu->frame == win) { - *pix = menu->pix; - *pw = menu->pw; - *ph = menu->ph; - return 1; - } - if (menu->titlebar == win) { - *pix = menu->pixtitlebar; - *pw = menu->tw; - *ph = menu->th; - return 1; - } - if (menu->button == win) { - *pix = menu->pixbutton; - *pw = config.titlewidth; - *ph = config.titlewidth; - return 1; - } - } - TAILQ_FOREACH(n, &wm.notifq, entry) { - notif = (struct Notification *)n; - if (notif->frame == win) { - *pix = notif->frame; - *pw = notif->pw; - *ph = notif->ph; - return 1; - } - } TAILQ_FOREACH(c, &wm.focusq, entry) { if (c->frame == win) { *pix = c->pix; @@ -136,31 +94,52 @@ getexposed(Window win, Pixmap *pix, int *pw, int *ph) return 1; } } - TAILQ_FOREACH(m, &tab->menuq, entry) { - menu = (struct Menu *)m; - if (menu->frame == win) { - *pix = menu->pix; - *pw = menu->pw; - *ph = menu->ph; - return 1; - } - if (menu->titlebar == win) { - *pix = menu->pixtitlebar; - *pw = menu->tw; - *ph = menu->th; - return 1; - } - if (menu->button == win) { - *pix = menu->pixbutton; - *pw = config.titlewidth; - *ph = config.titlewidth; - return 1; - } - } } } } } + if (wm.wmcheckwin == win) { + *pix = wm.wmcheckpix; + *pw = 2 * config.borderwidth + config.titlewidth; + *ph = 2 * config.borderwidth + config.titlewidth; + return 1; + } + if (dock.win == win) { + *pix = dock.pix; + *pw = dock.w; + *ph = dock.h; + return 1; + } + TAILQ_FOREACH(m, &wm.menuq, entry) { + menu = (struct Menu *)m; + if (menu->frame == win) { + *pix = menu->pix; + *pw = menu->pw; + *ph = menu->ph; + return 1; + } + if (menu->titlebar == win) { + *pix = menu->pixtitlebar; + *pw = menu->tw; + *ph = menu->th; + return 1; + } + if (menu->button == win) { + *pix = menu->pixbutton; + *pw = config.titlewidth; + *ph = config.titlewidth; + return 1; + } + } + TAILQ_FOREACH(n, &wm.notifq, entry) { + notif = (struct Notification *)n; + if (notif->frame == win) { + *pix = notif->frame; + *pw = notif->pw; + *ph = notif->ph; + return 1; + } + } return 0; } diff --git a/xevents.c b/xevents.c @@ -101,7 +101,7 @@ struct MwmHints { void (*managefuncs[TYPE_LAST])(struct Tab *, struct Monitor *, int, Window, Window, XRectangle, int, int) = { [TYPE_NOTIFICATION] = managenotif, [TYPE_DOCKAPP] = managedockapp, - [TYPE_NORMAL] = managetab, + [TYPE_NORMAL] = managecontainer, [TYPE_DIALOG] = managedialog, [TYPE_SPLASH] = managesplash, [TYPE_PROMPT] = manageprompt, @@ -112,7 +112,7 @@ void (*managefuncs[TYPE_LAST])(struct Tab *, struct Monitor *, int, Window, Wind int (*unmanagefuncs[TYPE_LAST])(struct Object *, int) = { [TYPE_NOTIFICATION] = unmanagenotif, [TYPE_DOCKAPP] = unmanagedockapp, - [TYPE_NORMAL] = unmanagetab, + [TYPE_NORMAL] = unmanagecontainer, [TYPE_DIALOG] = unmanagedialog, [TYPE_SPLASH] = unmanagesplash, [TYPE_PROMPT] = unmanageprompt, @@ -152,21 +152,6 @@ getmanaged(Window win) struct Row *row; int i; - GETMANAGED(dock.dappq, p, win) - GETMANAGED(wm.barq, p, win) - GETMANAGED(wm.notifq, p, win) - TAILQ_FOREACH(p, &wm.splashq, entry) { - if (p->win == win || ((struct Splash *)p)->frame) { - return p; - } - } - TAILQ_FOREACH(menu, &wm.menuq, entry) { - if (menu->win == win || - ((struct Menu *)menu)->frame == win || - ((struct Menu *)menu)->button == win || - ((struct Menu *)menu)->titlebar == win) - return menu; - } TAILQ_FOREACH(c, &wm.focusq, entry) { if (c->frame == win) return (struct Object *)c->selcol->selrow->seltab; @@ -187,17 +172,23 @@ getmanaged(Window win) ((struct Dialog *)dial)->frame == win) return dial; } - TAILQ_FOREACH(menu, &((struct Tab *)tab)->menuq, entry) { - if (menu->win == win || - ((struct Menu *)menu)->frame == win || - ((struct Menu *)menu)->button == win || - ((struct Menu *)menu)->titlebar == win) - return menu; - } } } } } + GETMANAGED(dock.dappq, p, win) + GETMANAGED(wm.barq, p, win) + GETMANAGED(wm.notifq, p, win) + TAILQ_FOREACH(p, &wm.splashq, entry) + if (p->win == win || ((struct Splash *)p)->frame == win) + return p; + TAILQ_FOREACH(menu, &wm.menuq, entry) { + if (menu->win == win || + ((struct Menu *)menu)->frame == win || + ((struct Menu *)menu)->button == win || + ((struct Menu *)menu)->titlebar == win) + return menu; + } return NULL; } @@ -466,13 +457,14 @@ getwintype(Window win, Window *leader, struct Tab **tab, int *state, XRectangle goto done; /* try to guess window type */ - type = TYPE_NORMAL; prop = getatomprop(win, atoms[_NET_WM_WINDOW_TYPE]); wmhints = XGetWMHints(dpy, win); mwmhints = getmwmhints(win); ismenu = mwmhints != NULL && (mwmhints->flags & MWM_HINTS_STATUS) && (mwmhints->status & MWM_TEAROFF_WINDOW); isdockapp = (wmhints && (wmhints->flags & (IconWindowHint | StateHint)) && wmhints->initial_state == WithdrawnState); - *leader = (wmhints != NULL && (wmhints->flags & WindowGroupHint)) ? wmhints->window_group : None; + *leader = getwinprop(win, atoms[WM_CLIENT_LEADER]); + if (*leader == None) + *leader = (wmhints != NULL && (wmhints->flags & WindowGroupHint)) ? wmhints->window_group : None; *tab = getdialogfor(win); XFree(mwmhints); XFree(wmhints); @@ -492,12 +484,20 @@ getwintype(Window win, Window *leader, struct Tab **tab, int *state, XRectangle prop == atoms[_NET_WM_WINDOW_TYPE_MENU] || prop == atoms[_NET_WM_WINDOW_TYPE_UTILITY] || prop == atoms[_NET_WM_WINDOW_TYPE_TOOLBAR]) { - if (*tab == NULL) - *tab = getleaderof(*leader); + if (*tab != NULL) + *leader = (*tab)->obj.win; type = TYPE_MENU; } else if (*tab != NULL) { + if (*tab != NULL) + *leader = (*tab)->obj.win; type = config.floatdialog ? TYPE_MENU : TYPE_DIALOG; } else { + if (prop != atoms[_NET_WM_WINDOW_TYPE_MENU] && + prop != atoms[_NET_WM_WINDOW_TYPE_DIALOG] && + prop != atoms[_NET_WM_WINDOW_TYPE_UTILITY] && + prop != atoms[_NET_WM_WINDOW_TYPE_TOOLBAR]) { + *tab = getleaderof(*leader); + } type = TYPE_NORMAL; } @@ -796,16 +796,15 @@ done: mon = getmon(x, y); if (mon == NULL) mon = wm.selmon; - managetab( + containernewwithtab( tab, mon, mon->seldesk, - None, None, (XRectangle){ .x = xroot - config.titlewidth, .y = yroot, .width = tab->winw, .height = tab->winh, }, - USERPLACED, 0 + USERPLACED ); } containerdelrow(row); @@ -1241,9 +1240,6 @@ xeventbuttonpress(XEvent *e) break; case TYPE_MENU: menu = (struct Menu *)obj; - tab = menu->tab; - if (tab != NULL) - c = tab->row->col->c; break; case TYPE_SPLASH: splashrise((struct Splash *)obj); @@ -1585,7 +1581,7 @@ xevententernotify(XEvent *e) return; switch (obj->type) { case TYPE_MENU: - tabfocus(((struct Menu *)obj)->tab, 1); + menufocus((struct Menu *)obj); break; case TYPE_DIALOG: tabfocus(((struct Dialog *)obj)->tab, 1); @@ -1625,8 +1621,7 @@ xeventfocusin(XEvent *e) goto focus; switch (obj->type) { case TYPE_MENU: - if (((struct Menu *)obj)->tab != wm.focused->selcol->selrow->seltab) - goto focus; + menufocus((struct Menu *)obj); break; case TYPE_DIALOG: if (((struct Dialog *)obj)->tab != wm.focused->selcol->selrow->seltab) diff --git a/xhints.c b/xhints.c @@ -53,7 +53,7 @@ isobscured(struct Container *c, struct Monitor *mon, int desk, int x, int y, int } /* set desktop for a given window */ -static void +void ewmhsetdesktop(Window win, long d) { XChangeProperty(dpy, win, atoms[_NET_WM_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&d, 1); diff --git a/xmenu.c b/xmenu.c @@ -48,9 +48,9 @@ menunew(Window win, int x, int y, int w, int h, int ignoreunmap) static void menudelraise(struct Menu *menu) { - if (TAILQ_EMPTY(menu->menuq)) + if (TAILQ_EMPTY(&wm.menuq)) return; - TAILQ_REMOVE(menu->menuq, (struct Object *)menu, entry); + TAILQ_REMOVE(&wm.menuq, (struct Object *)menu, entry); } /* configure menu window */ @@ -84,15 +84,11 @@ menuincrmove(struct Menu *menu, int x, int y) void menumoveresize(struct Menu *menu) { - struct Monitor *mon; - XMoveResizeWindow(dpy, menu->frame, menu->x, menu->y, menu->w, menu->h); XMoveWindow(dpy, menu->button, menu->w - config.borderwidth - config.titlewidth, config.borderwidth); XResizeWindow(dpy, menu->titlebar, max(1, menu->w - 2 * config.borderwidth - config.titlewidth), config.titlewidth); XResizeWindow(dpy, menu->obj.win, menu->w - 2 * config.borderwidth, menu->h - 2 * config.borderwidth - config.titlewidth); - if (menu->tab == NULL && (mon = getmon(menu->x, menu->y)) != NULL) { - menu->mon = mon; - } + menu->mon = getmon(menu->x, menu->y); } /* decorate menu */ @@ -125,13 +121,19 @@ menudecorate(struct Menu *menu, int titlepressed) drawcommit(menu->pixtitlebar, menu->titlebar, menu->tw, menu->th); } +void +menufocus(struct Menu *menu) +{ + XSetInputFocus(dpy, menu->obj.win, RevertToParent, CurrentTime); +} + /* put menu on beginning of menu list */ void menuaddraise(struct Menu *menu) { menudelraise(menu); - TAILQ_INSERT_HEAD(menu->menuq, (struct Object *)menu, entry); - XSetInputFocus(dpy, menu->obj.win, RevertToParent, CurrentTime); + TAILQ_INSERT_HEAD(&wm.menuq, (struct Object *)menu, entry); + menufocus(menu); } /* place menu next to its container */ @@ -168,33 +170,21 @@ menuhide(struct Menu *menu, int hide) void managemenu(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window leader, XRectangle rect, int state, int ignoreunmap) { - struct Queue *menuq; struct Menu *menu; - (void)leader; + (void)tab; + (void)mon; (void)desk; (void)state; menu = menunew(win, rect.x, rect.y, rect.width, rect.height, ignoreunmap); - if (tab) { - menuq = &tab->menuq; - mon = tab->row->col->c->mon; - } else { - menuq = &wm.menuq; - } - menu->mon = mon; - menu->menuq = menuq; - menu->tab = tab; + menu->leader = leader; winupdatetitle(menu->obj.win, &menu->name); - TAILQ_INSERT_HEAD(menuq, (struct Object *)menu, entry); + TAILQ_INSERT_HEAD(&wm.menuq, (struct Object *)menu, entry); icccmwmstate(menu->obj.win, NormalState); - menuplace(mon, menu); + menuplace(mon, menu); /* this will set menu->mon for us */ menudecorate(menu, 0); - if (tab != NULL && wm.focused != NULL && wm.focused->selcol->selrow->seltab == tab) { - tabfocus(tab, 0); - } else { - menuraise(menu); - XMapWindow(dpy, menu->frame); - } + menuraise(menu); + XMapWindow(dpy, menu->frame); } /* delete menu; return whether menu was deleted */ diff --git a/xmon.c b/xmon.c @@ -74,7 +74,7 @@ monupdate(void) XineramaScreenInfo *unique = NULL; struct Monitor *mon, *tmp; struct Container *c, *focus; - struct Object *t, *m, *s; + struct Object *m, *s; int delselmon = 0; int del, add; int i, j, n; @@ -136,14 +136,6 @@ monupdate(void) c->desk = wm.selmon->seldesk; containerplace(c, wm.selmon, wm.selmon->seldesk, 0); containermoveresize(c, 0); - - /* move menus to new monitor */ - TAB_FOREACH_BEGIN(c, t) { - TAILQ_FOREACH(m, &((struct Tab *)t)->menuq, entry) { - menuplace(wm.selmon, (struct Menu *)m); - } - } TAB_FOREACH_END - ewmhsetwmdesktop(c); ewmhsetstate(c); } diff --git a/xsplash.c b/xsplash.c @@ -13,7 +13,6 @@ splashnew(Window win, int w, int h) .w = w, .h = h, }; - ((struct Object *)splash)->type = TYPE_SPLASH; splash->frame = XCreateWindow( dpy, root, @@ -24,7 +23,7 @@ splashnew(Window win, int w, int h) clientmask, &clientswa ); XReparentWindow(dpy, win, splash->frame, 0, 0); - XMapWindow(dpy, splash->frame); + XMapWindow(dpy, win); TAILQ_INSERT_HEAD(&wm.splashq, (struct Object *)splash, entry); return splash; } @@ -33,15 +32,10 @@ splashnew(Window win, int w, int h) void splashplace(struct Monitor *mon, struct Splash *splash) { - Window wins[2]; - fitmonitor(mon, &splash->x, &splash->y, &splash->w, &splash->h, 0.5); splash->x = mon->wx + (mon->ww - splash->w) / 2; splash->y = mon->wy + (mon->wh - splash->h) / 2; - wins[1] = splash->frame; - wins[0] = wm.layers[LAYER_NORMAL].frame; XMoveWindow(dpy, splash->frame, splash->x, splash->y); - XRestackWindows(dpy, wins, 2); } /* (un)hide splash screen */ @@ -93,7 +87,7 @@ managesplash(struct Tab *tab, struct Monitor *mon, int desk, Window win, Window splash = splashnew(win, rect.width, rect.height); splash->mon = mon; splash->desk = desk; - icccmwmstate(splash->obj.win, NormalState); splashplace(mon, splash); - XMapWindow(dpy, splash->obj.win); + splashrise(splash); + splashhide(splash, REMOVE); } diff --git a/xutil.c b/xutil.c @@ -129,8 +129,21 @@ getwinsprop(Window win, Atom prop, Window **wins) return len; } +Window +getwinprop(Window win, Atom prop) +{ + Window *wins; + Window ret = None; + + getwinsprop(win, prop, &wins); + if (wins != NULL) + ret = *wins; + XFree(wins); + return ret; +} + unsigned long -getcardsprop(Window win, Atom prop, unsigned long **array) +getcardsprop(Window win, Atom prop, Atom **array) { unsigned char *p; unsigned long len; @@ -144,15 +157,15 @@ getcardsprop(Window win, Atom prop, unsigned long **array) XFree(p); return 0; } - *array = (unsigned long *)p; + *array = (Atom *)p; return len; } -unsigned long +Atom getcardprop(Window win, Atom prop) { unsigned long *array; - unsigned long card = 0; + Atom card = None; getcardsprop(win, prop, &array); if (array != NULL) diff --git a/xutil.h b/xutil.h @@ -92,6 +92,7 @@ unsigned long getwinsprop(Window win, Atom prop, Window **wins); unsigned long getcardsprop(Window win, Atom prop, unsigned long **array); unsigned long getcardprop(Window win, Atom prop); unsigned long getatomsprop(Window win, Atom prop, Atom **atoms); +Window getwinprop(Window win, Atom prop); Atom getatomprop(Window win, Atom prop); void initatoms(void); void initatom(int atomenum);