diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2016-09-29 00:21:56 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2016-09-29 00:21:56 +0000 |
commit | e68278c461a59ab4b5e3832cf0930ba559fcc82f (patch) | |
tree | c73edf9a28a5b5d30a6a9007fdc490238fab997b /app | |
parent | aedc6746103419b3c5b626bdaa5898754c4d2d98 (diff) |
Mechanical change: move screen menu bits to their own struct.
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/calmwm.c | 8 | ||||
-rw-r--r-- | app/cwm/calmwm.h | 8 | ||||
-rw-r--r-- | app/cwm/conf.c | 8 | ||||
-rw-r--r-- | app/cwm/menu.c | 32 | ||||
-rw-r--r-- | app/cwm/mousefunc.c | 16 |
5 files changed, 37 insertions, 35 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c index 1c315f001..ecf48439d 100644 --- a/app/cwm/calmwm.c +++ b/app/cwm/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.c,v 1.96 2015/11/12 17:56:54 okan Exp $ + * $OpenBSD: calmwm.c,v 1.97 2016/09/29 00:21:55 okan Exp $ */ #include <sys/types.h> @@ -161,10 +161,10 @@ x_teardown(void) XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which), &sc->xftcolor[i]); - XftDrawDestroy(sc->xftdraw); + XftDrawDestroy(sc->menu.xftdraw); XftFontClose(X_Dpy, sc->xftfont); - XUnmapWindow(X_Dpy, sc->menuwin); - XDestroyWindow(X_Dpy, sc->menuwin); + XUnmapWindow(X_Dpy, sc->menu.win); + XDestroyWindow(X_Dpy, sc->menu.win); XUngrabKey(X_Dpy, AnyKey, AnyModifier, sc->rootwin); } XUngrabPointer(X_Dpy, CurrentTime); diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 31961fdd4..3ad75e4ba 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.315 2016/09/28 17:06:33 okan Exp $ + * $OpenBSD: calmwm.h,v 1.316 2016/09/29 00:21:55 okan Exp $ */ #ifndef _CALMWM_H_ @@ -228,7 +228,6 @@ struct screen_ctx { TAILQ_ENTRY(screen_ctx) entry; int which; Window rootwin; - Window menuwin; int cycling; int hideall; int snapdist; @@ -240,8 +239,11 @@ struct screen_ctx { #define CALMWM_NGROUPS 10 struct group_ctx_q groupq; struct group_ctx *group_active; + struct { + Window win; + XftDraw *xftdraw; + } menu; XftColor xftcolor[CWM_COLOR_NITEMS]; - XftDraw *xftdraw; XftFont *xftfont; }; TAILQ_HEAD(screen_ctx_q, screen_ctx); diff --git a/app/cwm/conf.c b/app/cwm/conf.c index f414bb50d..5791db461 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.206 2016/09/22 14:36:03 okan Exp $ + * $OpenBSD: conf.c,v 1.207 2016/09/29 00:21:55 okan Exp $ */ #include <sys/types.h> @@ -162,13 +162,13 @@ conf_screen(struct screen_ctx *sc) } } - sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, + sc->menu.win = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, Conf.bwidth, sc->xftcolor[CWM_COLOR_MENU_FG].pixel, sc->xftcolor[CWM_COLOR_MENU_BG].pixel); - sc->xftdraw = XftDrawCreate(X_Dpy, sc->menuwin, visual, colormap); - if (sc->xftdraw == NULL) + sc->menu.xftdraw = XftDrawCreate(X_Dpy, sc->menu.win, visual, colormap); + if (sc->menu.xftdraw == NULL) errx(1, "XftDrawCreate"); conf_grab_kbd(sc->rootwin); diff --git a/app/cwm/menu.c b/app/cwm/menu.c index a9de92593..94eb399fa 100644 --- a/app/cwm/menu.c +++ b/app/cwm/menu.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: menu.c,v 1.93 2016/09/28 17:06:33 okan Exp $ + * $OpenBSD: menu.c,v 1.94 2016/09/29 00:21:55 okan Exp $ */ #include <sys/types.h> @@ -118,26 +118,26 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, const char *prompt, mc.hasprompt = 1; } - XSelectInput(X_Dpy, sc->menuwin, evmask); - XMapRaised(X_Dpy, sc->menuwin); + XSelectInput(X_Dpy, sc->menu.win, evmask); + XMapRaised(X_Dpy, sc->menu.win); - if (xu_ptr_grab(sc->menuwin, MENUGRABMASK, + if (xu_ptr_grab(sc->menu.win, MENUGRABMASK, Conf.cursor[CF_QUESTION]) < 0) { - XUnmapWindow(X_Dpy, sc->menuwin); + XUnmapWindow(X_Dpy, sc->menu.win); return(NULL); } XGetInputFocus(X_Dpy, &focuswin, &focusrevert); - XSetInputFocus(X_Dpy, sc->menuwin, RevertToPointerRoot, CurrentTime); + XSetInputFocus(X_Dpy, sc->menu.win, RevertToPointerRoot, CurrentTime); /* make sure keybindings don't remove keys from the menu stream */ - XGrabKeyboard(X_Dpy, sc->menuwin, True, + XGrabKeyboard(X_Dpy, sc->menu.win, True, GrabModeAsync, GrabModeAsync, CurrentTime); for (;;) { mc.changed = 0; - XWindowEvent(X_Dpy, sc->menuwin, evmask, &e); + XWindowEvent(X_Dpy, sc->menu.win, evmask, &e); switch (e.type) { case KeyPress: @@ -174,8 +174,8 @@ out: xu_ptr_setpos(sc->rootwin, xsave, ysave); xu_ptr_ungrab(); - XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, 1, 1); - XUnmapWindow(X_Dpy, sc->menuwin); + XMoveResizeWindow(X_Dpy, sc->menu.win, 0, 0, 1, 1); + XUnmapWindow(X_Dpy, sc->menu.win); XUngrabKeyboard(X_Dpy, CurrentTime); return(mi); @@ -402,12 +402,12 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) if (mc->geom.x != xsave || mc->geom.y != ysave) xu_ptr_setpos(sc->rootwin, mc->geom.x, mc->geom.y); - XClearWindow(X_Dpy, sc->menuwin); - XMoveResizeWindow(X_Dpy, sc->menuwin, mc->geom.x, mc->geom.y, + XClearWindow(X_Dpy, sc->menu.win); + XMoveResizeWindow(X_Dpy, sc->menu.win, mc->geom.x, mc->geom.y, mc->geom.w, mc->geom.h); if (mc->hasprompt) { - XftDrawStringUtf8(sc->xftdraw, + XftDrawStringUtf8(sc->menu.xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT], sc->xftfont, 0, sc->xftfont->ascent, (const FcChar8*)mc->dispstr, strlen(mc->dispstr)); @@ -422,7 +422,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) if (mc->geom.y + y > area.h) break; - XftDrawStringUtf8(sc->xftdraw, + XftDrawStringUtf8(sc->menu.xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT], sc->xftfont, 0, y, (const FcChar8*)mi->print, strlen(mi->print)); @@ -450,11 +450,11 @@ menu_draw_entry(struct menu_ctx *mc, struct menu_q *resultq, return; color = (active) ? CWM_COLOR_MENU_FG : CWM_COLOR_MENU_BG; - XftDrawRect(sc->xftdraw, &sc->xftcolor[color], 0, + XftDrawRect(sc->menu.xftdraw, &sc->xftcolor[color], 0, (sc->xftfont->height + 1) * entry, mc->geom.w, (sc->xftfont->height + 1) + sc->xftfont->descent); color = (active) ? CWM_COLOR_MENU_FONT_SEL : CWM_COLOR_MENU_FONT; - XftDrawStringUtf8(sc->xftdraw, + XftDrawStringUtf8(sc->menu.xftdraw, &sc->xftcolor[color], sc->xftfont, 0, (sc->xftfont->height + 1) * entry + sc->xftfont->ascent + 1, (const FcChar8*)mi->print, strlen(mi->print)); diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c index c351e72a0..805a10055 100644 --- a/app/cwm/mousefunc.c +++ b/app/cwm/mousefunc.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: mousefunc.c,v 1.107 2016/09/28 17:06:33 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.108 2016/09/29 00:21:55 okan Exp $ */ #include <sys/types.h> @@ -46,13 +46,13 @@ mousefunc_sweep_draw(struct client_ctx *cc) XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)s, strlen(s), &extents); - XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0); - XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, + XReparentWindow(X_Dpy, sc->menu.win, cc->win, 0, 0); + XMoveResizeWindow(X_Dpy, sc->menu.win, 0, 0, extents.xOff, sc->xftfont->height); - XMapWindow(X_Dpy, sc->menuwin); - XClearWindow(X_Dpy, sc->menuwin); + XMapWindow(X_Dpy, sc->menu.win); + XClearWindow(X_Dpy, sc->menu.win); - XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT], + XftDrawStringUtf8(sc->menu.xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT], sc->xftfont, 0, sc->xftfont->ascent + 1, (const FcChar8*)s, strlen(s)); } @@ -93,8 +93,8 @@ mousefunc_client_resize(struct client_ctx *cc, union arg *arg) break; case ButtonRelease: client_resize(cc, 1); - XUnmapWindow(X_Dpy, sc->menuwin); - XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0); + XUnmapWindow(X_Dpy, sc->menu.win); + XReparentWindow(X_Dpy, sc->menu.win, sc->rootwin, 0, 0); xu_ptr_ungrab(); /* Make sure the pointer stays within the window. */ |