diff options
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | calmwm.c | 132 | ||||
-rw-r--r-- | calmwm.h | 28 | ||||
-rw-r--r-- | client.c | 140 | ||||
-rw-r--r-- | conf.c | 10 | ||||
-rw-r--r-- | cursor.c | 6 | ||||
-rw-r--r-- | draw.c | 2 | ||||
-rw-r--r-- | font.c | 12 | ||||
-rw-r--r-- | geographic.c | 2 | ||||
-rw-r--r-- | grab.c | 102 | ||||
-rw-r--r-- | group.c | 148 | ||||
-rw-r--r-- | input.c | 4 | ||||
-rw-r--r-- | kbfunc.c | 20 | ||||
-rw-r--r-- | screen.c | 22 | ||||
-rw-r--r-- | search.c | 34 | ||||
-rw-r--r-- | xevents.c | 42 | ||||
-rw-r--r-- | xutil.c | 36 |
17 files changed, 370 insertions, 372 deletions
diff --git a/TODO b/TODO index d347111..a050836 100644 --- a/TODO +++ b/TODO @@ -28,5 +28,3 @@ once before moving on. - cache all the atoms somewhere. - -- convert globals from G_foo to Foo; diff --git a/calmwm.c b/calmwm.c index baa80c4..336c16c 100644 --- a/calmwm.c +++ b/calmwm.c @@ -10,24 +10,24 @@ #include "headers.h" #include "calmwm.h" -Display *G_dpy; -XFontStruct *G_font; +Display *X_Dpy; +XFontStruct *X_Font; -Cursor G_cursor_move; -Cursor G_cursor_resize; -Cursor G_cursor_select; -Cursor G_cursor_default; -Cursor G_cursor_question; +Cursor Cursor_move; +Cursor Cursor_resize; +Cursor Cursor_select; +Cursor Cursor_default; +Cursor Cursor_question; -struct screen_ctx_q G_screenq; -struct screen_ctx *G_curscreen; -u_int G_nscreens; +struct screen_ctx_q Screenq; +struct screen_ctx *Curscreen; +u_int Nscreens; -struct client_ctx_q G_clientq; +struct client_ctx_q Clientq; -int G_doshape, G_shape_ev; -int G_starting; -struct conf G_conf; +int Doshape, Shape_ev; +int Starting; +struct conf Conf; struct fontdesc *DefaultFont; char *DefaultFontName; @@ -86,12 +86,12 @@ main(int argc, char **argv) group_init(); - G_starting = 1; - conf_setup(&G_conf); - G_conf.flags |= conf_flags; + Starting = 1; + conf_setup(&Conf); + Conf.flags |= conf_flags; client_setup(); x_setup(display_name); - G_starting = 0; + Starting = 0; xev_init(); XEV_QUICK(NULL, NULL, MapRequest, xev_handle_maprequest, NULL); @@ -121,39 +121,39 @@ x_setup(char *display_name) struct screen_ctx *sc; char *fontname; - TAILQ_INIT(&G_screenq); + TAILQ_INIT(&Screenq); - if ((G_dpy = XOpenDisplay(display_name)) == NULL) + if ((X_Dpy = XOpenDisplay(display_name)) == NULL) errx(1, "%s:%d XOpenDisplay()", __FILE__, __LINE__); XSetErrorHandler(x_errorhandler); - G_doshape = XShapeQueryExtension(G_dpy, &G_shape_ev, &i); + Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i); i = 0; while ((fontname = tryfonts[i++]) != NULL) { - if ((G_font = XLoadQueryFont(G_dpy, fontname)) != NULL) + if ((X_Font = XLoadQueryFont(X_Dpy, fontname)) != NULL) break; } if (fontname == NULL) errx(1, "Couldn't load any fonts."); - G_nscreens = ScreenCount(G_dpy); - for (i = 0; i < (int)G_nscreens; i++) { + Nscreens = ScreenCount(X_Dpy); + for (i = 0; i < (int)Nscreens; i++) { XMALLOC(sc, struct screen_ctx); x_setupscreen(sc, i); - TAILQ_INSERT_TAIL(&G_screenq, sc, entry); + TAILQ_INSERT_TAIL(&Screenq, sc, entry); } - G_cursor_move = XCreateFontCursor(G_dpy, XC_fleur); - G_cursor_resize = XCreateFontCursor(G_dpy, XC_bottom_right_corner); - /* (used to be) XCreateFontCursor(G_dpy, XC_hand1); */ - G_cursor_select = XCreateFontCursor(G_dpy, XC_hand1); -/* G_cursor_select = cursor_bigarrow(G_curscreen); */ - G_cursor_default = XCreateFontCursor(G_dpy, XC_X_cursor); -/* G_cursor_default = cursor_bigarrow(G_curscreen); */ - G_cursor_question = XCreateFontCursor(G_dpy, XC_question_arrow); + Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur); + Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner); + /* (used to be) XCreateFontCursor(X_Dpy, XC_hand1); */ + Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1); +/* Cursor_select = cursor_bigarrow(Curscreen); */ + Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor); +/* Cursor_default = cursor_bigarrow(Curscreen); */ + Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow); } int @@ -169,55 +169,55 @@ x_setupscreen(struct screen_ctx *sc, u_int which) sc->display = x_screenname(which); sc->which = which; - sc->rootwin = RootWindow(G_dpy, which); - XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), + sc->rootwin = RootWindow(X_Dpy, which); + XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which), "black", &sc->fgcolor, &tmp); - XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), + XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which), "#00cc00", &sc->bgcolor, &tmp); - XAllocNamedColor(G_dpy,DefaultColormap(G_dpy, which), + XAllocNamedColor(X_Dpy,DefaultColormap(X_Dpy, which), "blue", &sc->fccolor, &tmp); - XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), + XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which), "red", &sc->redcolor, &tmp); - XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), + XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which), "#00ccc8", &sc->cyancolor, &tmp); - XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), + XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which), "white", &sc->whitecolor, &tmp); - XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), + XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which), "black", &sc->blackcolor, &tmp); - TAILQ_FOREACH(kb, &G_conf.keybindingq, entry) + TAILQ_FOREACH(kb, &Conf.keybindingq, entry) xu_key_grab(sc->rootwin, kb->modmask, kb->keysym); /* Special -- for alt state. */ /* xu_key_grab(sc->rootwin, 0, XK_Alt_L); */ /* xu_key_grab(sc->rootwin, 0, XK_Alt_R); */ - sc->blackpixl = BlackPixel(G_dpy, sc->which); - sc->whitepixl = WhitePixel(G_dpy, sc->which); + sc->blackpixl = BlackPixel(X_Dpy, sc->which); + sc->whitepixl = WhitePixel(X_Dpy, sc->which); sc->bluepixl = sc->fccolor.pixel; sc->redpixl = sc->redcolor.pixel; sc->cyanpixl = sc->cyancolor.pixel; - sc->gray = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, + sc->gray = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, gray_bits, gray_width, gray_height, - sc->blackpixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which)); + sc->blackpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); - sc->blue = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, + sc->blue = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, gray_bits, gray_width, gray_height, - sc->bluepixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which)); + sc->bluepixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); - sc->red = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, + sc->red = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, gray_bits, gray_width, gray_height, - sc->redpixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which)); + sc->redpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which)); gv.foreground = sc->blackpixl^sc->whitepixl; gv.background = sc->whitepixl; gv.function = GXxor; gv.line_width = 1; gv.subwindow_mode = IncludeInferiors; - gv.font = G_font->fid; + gv.font = X_Font->fid; - sc->gc = XCreateGC(G_dpy, sc->rootwin, + sc->gc = XCreateGC(X_Dpy, sc->rootwin, GCForeground|GCBackground|GCFunction| GCLineWidth|GCSubwindowMode|GCFont, &gv); @@ -227,19 +227,19 @@ x_setupscreen(struct screen_ctx *sc, u_int which) gv2.function = GXxor; gv2.line_width = 1; gv2.subwindow_mode = IncludeInferiors; - gv2.font = G_font->fid; + gv2.font = X_Font->fid; #endif - sc->hlgc = XCreateGC(G_dpy, sc->rootwin, + sc->hlgc = XCreateGC(X_Dpy, sc->rootwin, GCForeground|GCBackground|GCFunction| GCLineWidth|GCSubwindowMode|GCFont, &gv); gv1.function = GXinvert; gv1.subwindow_mode = IncludeInferiors; gv1.line_width = 1; - gv1.font = G_font->fid; + gv1.font = X_Font->fid; - sc->invgc = XCreateGC(G_dpy, sc->rootwin, + sc->invgc = XCreateGC(X_Dpy, sc->rootwin, GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1); font_init(sc); @@ -256,21 +256,21 @@ x_setupscreen(struct screen_ctx *sc, u_int which) search_init(sc); /* Deal with existing clients. */ - XQueryTree(G_dpy, sc->rootwin, &w0, &w1, &wins, &nwins); + XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins); for (i = 0; i < nwins; i++) { - XGetWindowAttributes(G_dpy, wins[i], &winattr); + XGetWindowAttributes(X_Dpy, wins[i], &winattr); if (winattr.override_redirect || winattr.map_state != IsViewable) { char *name; - XFetchName(G_dpy, wins[i], &name); + XFetchName(X_Dpy, wins[i], &name); continue; } client_new(wins[i], sc, winattr.map_state != IsUnmapped); } XFree(wins); - G_curscreen = sc; /* XXX */ + Curscreen = sc; /* XXX */ screen_init(); screen_updatestackingorder(); @@ -280,10 +280,10 @@ x_setupscreen(struct screen_ctx *sc, u_int which) /* Set the root cursor to a nice obnoxious arrow :-) */ /* rootattr.cursor = cursor_bigarrow(sc); */ - XChangeWindowAttributes(G_dpy, sc->rootwin, + XChangeWindowAttributes(X_Dpy, sc->rootwin, /* CWCursor| */CWEventMask, &rootattr); - XSync(G_dpy, False); + XSync(X_Dpy, False); return (0); } @@ -298,7 +298,7 @@ x_screenname(int which) errx(1, "Can't handle more than 9 screens. If you need it, " "tell <marius@monkey.org>. It's a trivial fix."); - dstr = xstrdup(DisplayString(G_dpy)); + dstr = xstrdup(DisplayString(X_Dpy)); if ((cp = rindex(dstr, ':')) == NULL) return (NULL); @@ -321,16 +321,16 @@ x_errorhandler(Display *dpy, XErrorEvent *e) { char msg[80], number[80], req[80]; - XGetErrorText(G_dpy, e->error_code, msg, sizeof(msg)); + XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg)); snprintf(number, sizeof(number), "%d", e->request_code); - XGetErrorDatabaseText(G_dpy, "XRequest", number, + XGetErrorDatabaseText(X_Dpy, "XRequest", number, "<unknown>", req, sizeof(req)); warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg); } #endif - if (G_starting && + if (Starting && e->error_code == BadAccess && e->request_code == X_GrabKey) errx(1, "root window unavailable - perhaps another " diff --git a/calmwm.h b/calmwm.h index 97fbab5..be8ff72 100644 --- a/calmwm.h +++ b/calmwm.h @@ -484,25 +484,25 @@ struct fontdesc *font_getx(struct screen_ctx *sc, const char *name); /* Externs */ -extern Display *G_dpy; -extern XFontStruct *G_font; +extern Display *X_Dpy; +extern XFontStruct *X_Font; -extern Cursor G_cursor_move; -extern Cursor G_cursor_resize; -extern Cursor G_cursor_select; -extern Cursor G_cursor_default; -extern Cursor G_cursor_question; +extern Cursor Cursor_move; +extern Cursor Cursor_resize; +extern Cursor Cursor_select; +extern Cursor Cursor_default; +extern Cursor Cursor_question; -extern struct screen_ctx_q G_screenq; -extern struct screen_ctx *G_curscreen; -extern u_int G_nscreens; +extern struct screen_ctx_q Screenq; +extern struct screen_ctx *curscreen; +extern u_int Nscreens; -extern struct client_ctx_q G_clientq; +extern struct client_ctx_q Clientq; -extern int G_doshape, G_shape_ev; -extern struct conf G_conf; +extern int Doshape, Shape_ev; +extern struct conf Conf; -extern int G_groupmode; +extern int Groupmode; extern struct fontdesc *DefaultFont; diff --git a/client.c b/client.c index f6fa360..762240d 100644 --- a/client.c +++ b/client.c @@ -21,7 +21,7 @@ struct client_ctx *_curcc = NULL; void client_setup(void) { - TAILQ_INIT(&G_clientq); + TAILQ_INIT(&Clientq); } struct client_ctx * @@ -29,7 +29,7 @@ client_find(Window win) { struct client_ctx *cc; - TAILQ_FOREACH(cc, &G_clientq, entry) + TAILQ_FOREACH(cc, &Clientq, entry) if (cc->pwin == win || cc->win == win) return (cc); @@ -51,7 +51,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) XCALLOC(cc, struct client_ctx); - XGrabServer(G_dpy); + XGrabServer(X_Dpy); cc->state = mapped ? NormalState : IconicState; cc->sc = sc; @@ -70,8 +70,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped) */ conf_client(cc); - XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp); - XGetWindowAttributes(G_dpy, cc->win, &wattr); + XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp); + XGetWindowAttributes(X_Dpy, cc->win, &wattr); if (cc->size->flags & PBaseSize) { cc->geom.min_dx = cc->size->base_width; @@ -96,7 +96,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) if (wattr.map_state != IsViewable) { client_placecalc(cc); - if ((wmhints = XGetWMHints(G_dpy, cc->win)) != NULL) { + if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) { if (wmhints->flags & StateHint) xu_setstate(cc, wmhints->initial_state); @@ -107,7 +107,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped) if (xu_getstate(cc, &state) < 0) state = NormalState; - XSelectInput(G_dpy, cc->win, + XSelectInput(X_Dpy, cc->win, ColormapChangeMask|EnterWindowMask|PropertyChangeMask|KeyReleaseMask); x = cc->geom.x - cc->bwidth; @@ -129,24 +129,24 @@ client_new(Window win, struct screen_ctx *sc, int mapped) /* pxattr.background_pixel = sc->whitepix; */ -/* cc->pwin = XCreateSimpleWindow(G_dpy, sc->rootwin, */ +/* cc->pwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, */ /* x, y, width, height, 1, sc->blackpix, sc->whitepix); */ - cc->pwin = XCreateWindow(G_dpy, sc->rootwin, x, y, + cc->pwin = XCreateWindow(X_Dpy, sc->rootwin, x, y, width, height, 0, /* XXX */ - DefaultDepth(G_dpy, sc->which), CopyFromParent, - DefaultVisual(G_dpy, sc->which), + DefaultDepth(X_Dpy, sc->which), CopyFromParent, + DefaultVisual(X_Dpy, sc->which), CWOverrideRedirect | CWBackPixel | CWEventMask, &pxattr); - if (G_doshape) { + if (Doshape) { XRectangle *r; int n, tmp; - XShapeSelectInput(G_dpy, cc->win, ShapeNotifyMask); + XShapeSelectInput(X_Dpy, cc->win, ShapeNotifyMask); - r = XShapeGetRectangles(G_dpy, cc->win, ShapeBounding, &n, &tmp); + r = XShapeGetRectangles(X_Dpy, cc->win, ShapeBounding, &n, &tmp); if (n > 1) - XShapeCombineShape(G_dpy, cc->pwin, ShapeBounding, + XShapeCombineShape(X_Dpy, cc->pwin, ShapeBounding, 0, 0, /* XXX border */ cc->win, ShapeBounding, ShapeSet); XFree(r); @@ -155,28 +155,28 @@ client_new(Window win, struct screen_ctx *sc, int mapped) cc->active = 0; client_draw_border(cc); - XAddToSaveSet(G_dpy, cc->win); - XSetWindowBorderWidth(G_dpy, cc->win, 0); - XReparentWindow(G_dpy, cc->win, cc->pwin, cc->bwidth, cc->bwidth); + XAddToSaveSet(X_Dpy, cc->win); + XSetWindowBorderWidth(X_Dpy, cc->win, 0); + XReparentWindow(X_Dpy, cc->win, cc->pwin, cc->bwidth, cc->bwidth); /* Notify client of its configuration. */ xev_reconfig(cc); - XMapRaised(G_dpy, cc->pwin); - XMapWindow(G_dpy, cc->win); + XMapRaised(X_Dpy, cc->pwin); + XMapWindow(X_Dpy, cc->win); xu_setstate(cc, cc->state); - XSync(G_dpy, False); - XUngrabServer(G_dpy); + XSync(X_Dpy, False); + XUngrabServer(X_Dpy); TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry); - TAILQ_INSERT_TAIL(&G_clientq, cc, entry); + TAILQ_INSERT_TAIL(&Clientq, cc, entry); client_gethints(cc); client_update(cc); if (mapped) { - if (G_conf.flags & CONF_STICKY_GROUPS) + if (Conf.flags & CONF_STICKY_GROUPS) group_sticky(cc); else group_autogroup(cc); @@ -195,25 +195,25 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow) return (1); group_client_delete(cc); - XGrabServer(G_dpy); + XGrabServer(X_Dpy); xu_setstate(cc, WithdrawnState); - XRemoveFromSaveSet(G_dpy, cc->win); + XRemoveFromSaveSet(X_Dpy, cc->win); if (!ignorewindow) { client_gravitate(cc, 0); - XSetWindowBorderWidth(G_dpy, cc->win, 1); /* XXX */ - XReparentWindow(G_dpy, cc->win, + XSetWindowBorderWidth(X_Dpy, cc->win, 1); /* XXX */ + XReparentWindow(X_Dpy, cc->win, sc->rootwin, cc->geom.x, cc->geom.y); } if (cc->pwin) - XDestroyWindow(G_dpy, cc->pwin); + XDestroyWindow(X_Dpy, cc->pwin); - XSync(G_dpy, False); - XUngrabServer(G_dpy); + XSync(X_Dpy, False); + XUngrabServer(X_Dpy); TAILQ_REMOVE(&sc->mruq, cc, mru_entry); - TAILQ_REMOVE(&G_clientq, cc, entry); + TAILQ_REMOVE(&Clientq, cc, entry); if (_curcc == cc) _curcc = NULL; @@ -273,8 +273,8 @@ client_setactive(struct client_ctx *cc, int fg) sc = CCTOSC(cc); if (fg) { - XInstallColormap(G_dpy, cc->cmap); - XSetInputFocus(G_dpy, cc->win, + XInstallColormap(X_Dpy, cc->cmap); + XSetInputFocus(X_Dpy, cc->win, RevertToPointerRoot, CurrentTime); xu_btn_grab(cc->pwin, Mod1Mask, AnyButton); xu_btn_grab(cc->pwin, ControlMask|Mod1Mask, Button1); @@ -334,7 +334,7 @@ client_maximize(struct client_ctx *cc) XWindowAttributes rootwin_geom; struct screen_ctx *sc = CCTOSC(cc); - XGetWindowAttributes(G_dpy, sc->rootwin, &rootwin_geom); + XGetWindowAttributes(X_Dpy, sc->rootwin, &rootwin_geom); cc->savegeom = cc->geom; cc->geom.x = 0; cc->geom.y = 0; @@ -362,10 +362,10 @@ client_restore_geometry(struct client_ctx *cc) void client_resize(struct client_ctx *cc) { - XMoveResizeWindow(G_dpy, cc->pwin, cc->geom.x - cc->bwidth, + XMoveResizeWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth, cc->geom.width + cc->bwidth*2, cc->geom.height + cc->bwidth*2); - XMoveResizeWindow(G_dpy, cc->win, cc->bwidth, cc->bwidth, + XMoveResizeWindow(X_Dpy, cc->win, cc->bwidth, cc->bwidth, cc->geom.width, cc->geom.height); xev_reconfig(cc); client_draw_border(cc); @@ -374,7 +374,7 @@ client_resize(struct client_ctx *cc) void client_move(struct client_ctx *cc) { - XMoveWindow(G_dpy, cc->pwin, + XMoveWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); xev_reconfig(cc); } @@ -382,13 +382,13 @@ client_move(struct client_ctx *cc) void client_lower(struct client_ctx *cc) { - XLowerWindow(G_dpy, cc->pwin); + XLowerWindow(X_Dpy, cc->pwin); } void client_raise(struct client_ctx *cc) { - XRaiseWindow(G_dpy, cc->pwin); + XRaiseWindow(X_Dpy, cc->pwin); client_draw_border(cc); } @@ -429,8 +429,8 @@ void client_hide(struct client_ctx *cc) { /* XXX - add wm_state stuff */ - XUnmapWindow(G_dpy, cc->pwin); - XUnmapWindow(G_dpy, cc->win); + XUnmapWindow(X_Dpy, cc->pwin); + XUnmapWindow(X_Dpy, cc->win); cc->active = 0; cc->flags |= CLIENT_HIDDEN; @@ -443,8 +443,8 @@ client_hide(struct client_ctx *cc) void client_unhide(struct client_ctx *cc) { - XMapWindow(G_dpy, cc->win); - XMapRaised(G_dpy, cc->pwin); + XMapWindow(X_Dpy, cc->win); + XMapRaised(X_Dpy, cc->pwin); cc->flags &= ~CLIENT_HIDDEN; xu_setstate(cc, NormalState); @@ -456,21 +456,21 @@ client_draw_border(struct client_ctx *cc) struct screen_ctx *sc = CCTOSC(cc); if (cc->active) { - XSetWindowBackground(G_dpy, cc->pwin, client_bg_pixel(cc)); - XClearWindow(G_dpy, cc->pwin); + XSetWindowBackground(X_Dpy, cc->pwin, client_bg_pixel(cc)); + XClearWindow(X_Dpy, cc->pwin); if (!cc->highlight && cc->bwidth > 1) - XDrawRectangle(G_dpy, cc->pwin, sc->gc, 1, 1, + XDrawRectangle(X_Dpy, cc->pwin, sc->gc, 1, 1, cc->geom.width + cc->bwidth, cc->geom.height + cc->bwidth); } else { - XSetWindowBackgroundPixmap(G_dpy, cc->pwin, + XSetWindowBackgroundPixmap(X_Dpy, cc->pwin, client_bg_pixmap(cc)); if (cc->bwidth > 1) - XSetWindowBackgroundPixmap(G_dpy, + XSetWindowBackgroundPixmap(X_Dpy, cc->pwin, client_bg_pixmap(cc)); - XClearWindow(G_dpy, cc->pwin); + XClearWindow(X_Dpy, cc->pwin); } } @@ -524,9 +524,9 @@ client_update(struct client_ctx *cc) long n; /* XXX cache these. */ - wm_delete = XInternAtom(G_dpy, "WM_DELETE_WINDOW", False); - wm_protocols = XInternAtom(G_dpy, "WM_PROTOCOLS", False); - wm_take_focus = XInternAtom(G_dpy, "WM_TAKE_FOCUS", False); + wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False); + wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False); + wm_take_focus = XInternAtom(X_Dpy, "WM_TAKE_FOCUS", False); if ((n = xu_getprop(cc, wm_protocols, XA_ATOM, 20L, (u_char **)&p)) <= 0) @@ -547,13 +547,13 @@ client_send_delete(struct client_ctx *cc) Atom wm_delete, wm_protocols; /* XXX - cache */ - wm_delete = XInternAtom(G_dpy, "WM_DELETE_WINDOW", False); - wm_protocols = XInternAtom(G_dpy, "WM_PROTOCOLS", False); + wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False); + wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False); if (cc->xproto & CLIENT_PROTO_DELETE) xu_sendmsg(cc, wm_protocols, wm_delete); else - XKillClient(G_dpy, cc->win); + XKillClient(X_Dpy, cc->win); } void @@ -562,7 +562,7 @@ client_setname(struct client_ctx *cc) char *newname; struct winname *wn; - XFetchName(G_dpy, cc->win, &newname); + XFetchName(X_Dpy, cc->win, &newname); if (newname == NULL) newname = emptystring; @@ -689,10 +689,10 @@ client_cycleinfo(struct client_ctx *cc) if ((diff = cc->geom.height - (y + h)) < 0) y += diff; - XReparentWindow(G_dpy, sc->infowin, cc->win, 0, 0); - XMoveResizeWindow(G_dpy, sc->infowin, x, y, w, h); - XMapRaised(G_dpy, sc->infowin); - XClearWindow(G_dpy, sc->infowin); + XReparentWindow(X_Dpy, sc->infowin, cc->win, 0, 0); + XMoveResizeWindow(X_Dpy, sc->infowin, x, y, w, h); + XMapRaised(X_Dpy, sc->infowin); + XClearWindow(X_Dpy, sc->infowin); for (i = 0, n = 0; i < sizeof(list)/sizeof(list[0]); i++) { if ((ccc = list[i]) == NULL) @@ -707,7 +707,7 @@ client_cycleinfo(struct client_ctx *cc) assert(curn != -1); /* Highlight the current entry. */ - XFillRectangle(G_dpy, sc->infowin, sc->hlgc, 0, curn*oneh, w, oneh); + XFillRectangle(X_Dpy, sc->infowin, sc->hlgc, 0, curn*oneh, w, oneh); } struct client_ctx * @@ -754,8 +754,8 @@ client_altrelease() return; sc = CCTOSC(cc); - XUnmapWindow(G_dpy, sc->infowin); - XReparentWindow(G_dpy, sc->infowin, sc->rootwin, 0, 0); + XUnmapWindow(X_Dpy, sc->infowin); + XReparentWindow(X_Dpy, sc->infowin, sc->rootwin, 0, 0); } void @@ -771,8 +771,8 @@ client_placecalc(struct client_ctx *cc) height = cc->geom.height; width = cc->geom.width; - ymax = DisplayHeight(G_dpy, sc->which) - cc->bwidth; - xmax = DisplayWidth(G_dpy, sc->which) - cc->bwidth; + ymax = DisplayHeight(X_Dpy, sc->which) - cc->bwidth; + xmax = DisplayWidth(X_Dpy, sc->which) - cc->bwidth; yslack = ymax - cc->geom.height; xslack = xmax - cc->geom.width; @@ -827,7 +827,7 @@ client_vertmaximize(struct client_ctx *cc) cc->geom = cc->savegeom; } else { struct screen_ctx *sc = CCTOSC(cc); - int display_height = DisplayHeight(G_dpy, sc->which) - + int display_height = DisplayHeight(X_Dpy, sc->which) - cc->bwidth*2; cc->savegeom = cc->geom; @@ -876,21 +876,21 @@ client_gethints(struct client_ctx *cc) Atom mha; struct mwm_hints *mwmh; - if (XGetClassHint(G_dpy, cc->win, &xch)) { + if (XGetClassHint(X_Dpy, cc->win, &xch)) { if (xch.res_name != NULL) cc->app_name = xch.res_name; if (xch.res_class != NULL) cc->app_class = xch.res_class; } - mha = XInternAtom(G_dpy, "_MOTIF_WM_HINTS", False); + mha = XInternAtom(X_Dpy, "_MOTIF_WM_HINTS", False); if (xu_getprop(cc, mha, mha, PROP_MWM_HINTS_ELEMENTS, (u_char **)&mwmh) == MWM_NUMHINTS) if (mwmh->flags & MWM_HINTS_DECORATIONS && !(mwmh->decorations & MWM_DECOR_ALL) && !(mwmh->decorations & MWM_DECOR_BORDER)) cc->bwidth = 0; - if (XGetCommand(G_dpy, cc->win, &argv, &argc)) { + if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) { #define MAX_ARGLEN 512 #define ARG_SEP_ " " int len = MAX_ARGLEN; diff --git a/conf.c b/conf.c index a586df5..065d6bc 100644 --- a/conf.c +++ b/conf.c @@ -78,9 +78,9 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags) /* "term" and "lock" have special meanings. */ if (strcmp(label, "term") == 0) { - strlcpy(G_conf.termpath, image, sizeof(G_conf.termpath)); + strlcpy(Conf.termpath, image, sizeof(Conf.termpath)); } else if (strcmp(label, "lock") == 0) { - strlcpy(G_conf.lockpath, image, sizeof(G_conf.lockpath)); + strlcpy(Conf.lockpath, image, sizeof(Conf.lockpath)); } else { struct cmd *cmd; XMALLOC(cmd, struct cmd); @@ -262,8 +262,8 @@ conf_setup(struct conf *c) c->flags = 0; /* Default term/lock */ - strlcpy(G_conf.termpath, "xterm", sizeof(G_conf.termpath)); - strlcpy(G_conf.lockpath, "xlock", sizeof(G_conf.lockpath)); + strlcpy(Conf.termpath, "xterm", sizeof(Conf.termpath)); + strlcpy(Conf.lockpath, "xlock", sizeof(Conf.lockpath)); } int @@ -471,7 +471,7 @@ conf_parsesettings(struct conf *c, char *filename) if (ent->d_name[0] == '.') continue; if (strncmp(ent->d_name, "sticky", 7)==0) - G_conf.flags |= CONF_STICKY_GROUPS; + Conf.flags |= CONF_STICKY_GROUPS; } closedir(dir); } diff --git a/cursor.c b/cursor.c index 2479ea6..551e046 100644 --- a/cursor.c +++ b/cursor.c @@ -48,12 +48,12 @@ _mkcursor(struct cursor_data *c, struct screen_ctx *sc) { Pixmap f, m; - f = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, (char *)c->fore, + f = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, (char *)c->fore, c->width, c->width, 1, 0, 1); - m = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, (char *)c->mask, + m = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, (char *)c->mask, c->width, c->width, 1, 0, 1); - return (XCreatePixmapCursor(G_dpy, f, m, + return (XCreatePixmapCursor(X_Dpy, f, m, &sc->blackcolor, &sc->whitecolor, c->hot[0], c->hot[1])); } diff --git a/draw.c b/draw.c index 50a6891..2e2f2aa 100644 --- a/draw.c +++ b/draw.c @@ -15,7 +15,7 @@ draw_outline(struct client_ctx *cc) { struct screen_ctx *sc = CCTOSC(cc); - XDrawRectangle(G_dpy, sc->rootwin, sc->invgc, + XDrawRectangle(X_Dpy, sc->rootwin, sc->invgc, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth, cc->geom.width + cc->bwidth, cc->geom.height + cc->bwidth); } diff --git a/font.c b/font.c index 403466b..1f9cf05 100644 --- a/font.c +++ b/font.c @@ -61,12 +61,12 @@ font_init(struct screen_ctx *sc) XColor xcolor, tmp; HASH_INIT(&sc->fonthash, fontdesc_hash); - sc->xftdraw = XftDrawCreate(G_dpy, sc->rootwin, - DefaultVisual(G_dpy, sc->which), DefaultColormap(G_dpy, sc->which)); + sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin, + DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which)); if (sc->xftdraw == NULL) errx(1, "XftDrawCreate"); - if (!XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, sc->which), + if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which), "black", &xcolor, &tmp)) errx(1, "XAllocNamedColor"); @@ -112,7 +112,7 @@ int font_width(struct fontdesc *fdp, const char *text, int len) { XGlyphInfo extents; - XftTextExtents8(G_dpy, fdp->fn, (const XftChar8*)text, len, &extents); + XftTextExtents8(X_Dpy, fdp->fn, (const XftChar8*)text, len, &extents); return (extents.xOff); } @@ -149,8 +149,8 @@ _make_font(struct screen_ctx *sc, struct fontdesc *fdp) if ((pat = FcNameParse(fdp->name)) == NULL) return (NULL); - if ((patx = XftFontMatch(G_dpy, sc->which, pat, &res)) != NULL) - fn = XftFontOpenPattern(G_dpy, patx); + if ((patx = XftFontMatch(X_Dpy, sc->which, pat, &res)) != NULL) + fn = XftFontOpenPattern(X_Dpy, patx); FcPatternDestroy(pat); diff --git a/geographic.c b/geographic.c index b29fe1a..b516fad 100644 --- a/geographic.c +++ b/geographic.c @@ -33,7 +33,7 @@ _visible(struct client_ctx *this_cc) if (cc->flags & CLIENT_HIDDEN) return (0); - TAILQ_FOREACH(cc, &G_clientq, entry) { + TAILQ_FOREACH(cc, &Clientq, entry) { if (cc->flags & CLIENT_HIDDEN) continue; diff --git a/grab.c b/grab.c index 4b5ac23..3eca5f7 100644 --- a/grab.c +++ b/grab.c @@ -32,10 +32,10 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy) wide = MAX(wide_size, wide_name); height = font_ascent(font) + font_descent(font) + 1; - XMoveResizeWindow(G_dpy, sc->menuwin, x0, y0, wide, height * 2); - XMapWindow(G_dpy, sc->menuwin); - XReparentWindow(G_dpy, sc->menuwin, cc->win, 0, 0); - XClearWindow(G_dpy, sc->menuwin); + XMoveResizeWindow(X_Dpy, sc->menuwin, x0, y0, wide, height * 2); + XMapWindow(X_Dpy, sc->menuwin); + XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0); + XClearWindow(X_Dpy, sc->menuwin); font_draw(font, cc->name, strlen(cc->name), sc->menuwin, 2, font_ascent(font) + 1); font_draw(font, asize, strlen(asize), sc->menuwin, @@ -56,7 +56,7 @@ grab_sweep(struct client_ctx *cc) client_raise(cc); client_ptrsave(cc); - if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_resize) < 0) + if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0) return (-1); xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height); @@ -64,7 +64,7 @@ grab_sweep(struct client_ctx *cc) for (;;) { /* Look for changes in ptr position. */ - XMaskEvent(G_dpy, MouseMask, &ev); + XMaskEvent(X_Dpy, MouseMask, &ev); switch (ev.type) { case MotionNotify: @@ -72,19 +72,19 @@ grab_sweep(struct client_ctx *cc) /* Recompute window output */ grab_sweep_draw(cc, dx, dy); - XMoveResizeWindow(G_dpy, cc->pwin, + XMoveResizeWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth, cc->geom.width + cc->bwidth*2, cc->geom.height + cc->bwidth*2); - XMoveResizeWindow(G_dpy, cc->win, + XMoveResizeWindow(X_Dpy, cc->win, cc->bwidth, cc->bwidth, cc->geom.width, cc->geom.height); break; case ButtonRelease: - XUnmapWindow(G_dpy, sc->menuwin); - XReparentWindow(G_dpy, sc->menuwin, sc->rootwin, 0, 0); + XUnmapWindow(X_Dpy, sc->menuwin); + XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0); xu_ptr_ungrab(); client_ptrwarp(cc); return (0); @@ -102,20 +102,20 @@ grab_drag(struct client_ctx *cc) client_raise(cc); - if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_move) < 0) + if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0) return (-1); xu_ptr_getpos(sc->rootwin, &xm, &ym); for (;;) { - XMaskEvent(G_dpy, MouseMask, &ev); + XMaskEvent(X_Dpy, MouseMask, &ev); switch (ev.type) { case MotionNotify: cc->geom.x = x0 + (ev.xmotion.x - xm); cc->geom.y = y0 + (ev.xmotion.y - ym); - XMoveWindow(G_dpy, cc->pwin, + XMoveWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); break; @@ -185,8 +185,8 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) y = e->y - cur*high - high/2; warp = 0; /* XXX - cache these in sc. */ - xmax = DisplayWidth(G_dpy, sc->which); - ymax = DisplayHeight(G_dpy, sc->which); + xmax = DisplayWidth(X_Dpy, sc->which); + ymax = DisplayHeight(X_Dpy, sc->which); if (x < 0) { e->x -= x; x = 0; @@ -210,12 +210,12 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) if (warp) xu_ptr_setpos(e->root, e->x, e->y); - XMoveResizeWindow(G_dpy, sc->menuwin, x, y, dx, dy); - XSelectInput(G_dpy, sc->menuwin, MenuMask); - XMapRaised(G_dpy, sc->menuwin); - status = xu_ptr_grab(sc->menuwin, MenuGrabMask, G_cursor_select); + XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, dx, dy); + XSelectInput(X_Dpy, sc->menuwin, MenuMask); + XMapRaised(X_Dpy, sc->menuwin); + status = xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select); if (status < 0) { - XUnmapWindow(G_dpy, sc->menuwin); + XUnmapWindow(X_Dpy, sc->menuwin); return (NULL); } drawn = 0; @@ -226,13 +226,13 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) cc = grab_menu_getcc(menuq, cur); if (cc != NULL) { client_unhide(cc); - XRaiseWindow(G_dpy, sc->menuwin); + XRaiseWindow(X_Dpy, sc->menuwin); } } #endif for (;;) { - XMaskEvent(G_dpy, MenuMask, &ev); + XMaskEvent(X_Dpy, MenuMask, &ev); switch (ev.type) { default: warnx("menuhit: unknown ev.type %d\n", ev.type); @@ -259,7 +259,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) /* XXX */ /* ungrab(&ev.xbutton); */ xu_ptr_ungrab(); - XUnmapWindow(G_dpy, sc->menuwin); + XUnmapWindow(X_Dpy, sc->menuwin); n = 0; TAILQ_FOREACH(mi, menuq, entry) if (i == n++) @@ -290,7 +290,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) client_hide(cc); } #endif - XFillRectangle(G_dpy, sc->menuwin, + XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc, 0, old*high, wide, high); } if (cur >= 0 && cur < n) { @@ -300,19 +300,19 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) cc = grab_menu_getcc(menuq, cur); if (cc != NULL) { client_unhide(cc); - XRaiseWindow(G_dpy, + XRaiseWindow(X_Dpy, sc->menuwin); } } #endif - xu_ptr_regrab(MenuGrabMask, G_cursor_select); - XFillRectangle(G_dpy, sc->menuwin, + xu_ptr_regrab(MenuGrabMask, Cursor_select); + XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc, 0, cur*high, wide, high); } else - xu_ptr_regrab(MenuGrabMask, G_cursor_default); + xu_ptr_regrab(MenuGrabMask, Cursor_default); break; case Expose: - XClearWindow(G_dpy, sc->menuwin); + XClearWindow(X_Dpy, sc->menuwin); i = 0; TAILQ_FOREACH(mi, menuq, entry) { tx = (wide - font_width(font, mi->text, @@ -323,7 +323,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) i++; } if (cur >= 0 && cur < n) - XFillRectangle(G_dpy, sc->menuwin, + XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc, 0, cur*high, wide, high); drawn = 1; } @@ -333,7 +333,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq) void grab_menuinit(struct screen_ctx *sc) { - sc->menuwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, + sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, 1, sc->blackpixl, sc->whitepixl); } @@ -364,16 +364,16 @@ grab_label(struct client_ctx *cc) dy = fontheight = font_ascent(font) + font_descent(font) + 1; dx = font_width(font, "label>", 6); - XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); - XSelectInput(G_dpy, sc->searchwin, LabelMask); - XMapRaised(G_dpy, sc->searchwin); + XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy); + XSelectInput(X_Dpy, sc->searchwin, LabelMask); + XMapRaised(X_Dpy, sc->searchwin); - XGetInputFocus(G_dpy, &focuswin, &focusrevert); - XSetInputFocus(G_dpy, sc->searchwin, + XGetInputFocus(X_Dpy, &focuswin, &focusrevert); + XSetInputFocus(X_Dpy, sc->searchwin, RevertToPointerRoot, CurrentTime); for (;;) { - XMaskEvent(G_dpy, LabelMask, &e); + XMaskEvent(X_Dpy, LabelMask, &e); switch (e.type) { case KeyPress: @@ -415,8 +415,8 @@ grab_label(struct client_ctx *cc) dx = font_width(font, dispstr, strlen(dispstr)); dy = fontheight; - XClearWindow(G_dpy, sc->searchwin); - XResizeWindow(G_dpy, sc->searchwin, dx, dy); + XClearWindow(X_Dpy, sc->searchwin); + XResizeWindow(X_Dpy, sc->searchwin, dx, dy); font_draw(font, dispstr, strlen(dispstr), sc->searchwin, 0, font_ascent(font) + 1); @@ -425,9 +425,9 @@ grab_label(struct client_ctx *cc) } out: - XSetInputFocus(G_dpy, focuswin, + XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime); - XUnmapWindow(G_dpy, sc->searchwin); + XUnmapWindow(X_Dpy, sc->searchwin); } #define ExecMask (KeyPressMask|ExposureMask) @@ -452,16 +452,16 @@ grab_exec(void) dy = fontheight = font_ascent(font) + font_descent(font) + 1; dx = font_width(font, "exec>", 5); - XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); - XSelectInput(G_dpy, sc->searchwin, ExecMask); - XMapRaised(G_dpy, sc->searchwin); + XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy); + XSelectInput(X_Dpy, sc->searchwin, ExecMask); + XMapRaised(X_Dpy, sc->searchwin); - XGetInputFocus(G_dpy, &focuswin, &focusrevert); - XSetInputFocus(G_dpy, sc->searchwin, + XGetInputFocus(X_Dpy, &focuswin, &focusrevert); + XSetInputFocus(X_Dpy, sc->searchwin, RevertToPointerRoot, CurrentTime); for (;;) { - XMaskEvent(G_dpy, ExecMask, &e); + XMaskEvent(X_Dpy, ExecMask, &e); switch (e.type) { case KeyPress: @@ -496,8 +496,8 @@ grab_exec(void) dx = font_width(font, dispstr, strlen(dispstr)); dy = fontheight; - XClearWindow(G_dpy, sc->searchwin); - XResizeWindow(G_dpy, sc->searchwin, dx, dy); + XClearWindow(X_Dpy, sc->searchwin); + XResizeWindow(X_Dpy, sc->searchwin, dx, dy); font_draw(font, dispstr, strlen(dispstr), sc->searchwin, 0, font_ascent(font) + 1); @@ -505,8 +505,8 @@ grab_exec(void) } } out: - XSetInputFocus(G_dpy, focuswin, focusrevert, CurrentTime); - XUnmapWindow(G_dpy, sc->searchwin); + XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime); + XUnmapWindow(X_Dpy, sc->searchwin); } int diff --git a/group.c b/group.c index e7d89ef..6b972e4 100644 --- a/group.c +++ b/group.c @@ -13,17 +13,17 @@ #define CALMWM_NGROUPS 9 -int G_groupmode = 0; -int G_groupnamemode = 0; -struct group_ctx *G_group_active = NULL; -struct group_ctx *G_group_current = NULL; -struct group_ctx G_groups[CALMWM_NGROUPS]; -char G_group_name[256]; -int G_groupfocusset = 0; -Window G_groupfocuswin; -int G_groupfocusrevert; -int G_grouphideall = 0; -struct group_ctx_q G_groupq; +int Groupmode = 0; +int Groupnamemode = 0; +struct group_ctx *Group_active = NULL; +struct group_ctx *Group_current = NULL; +struct group_ctx Groups[CALMWM_NGROUPS]; +char Group_name[256]; +int Groupfocusset = 0; +Window Groupfocuswin; +int Groupfocusrevert; +int Grouphideall = 0; +struct group_ctx_q Groupq; #define GroupMask (KeyPressMask|ExposureMask) @@ -137,11 +137,11 @@ _group_show(struct group_ctx *gc) } } - XRestackWindows(G_dpy, winlist, gc->nhidden); + XRestackWindows(X_Dpy, winlist, gc->nhidden); xfree(winlist); gc->hidden = 0; - G_group_active = gc; + Group_active = gc; } @@ -170,16 +170,16 @@ group_init(void) { int i; - TAILQ_INIT(&G_groupq); + TAILQ_INIT(&Groupq); for (i = 0; i < CALMWM_NGROUPS; i++) { - TAILQ_INIT(&G_groups[i].clients); - G_groups[i].hidden = 0; - G_groups[i].shortcut = i + 1; - TAILQ_INSERT_TAIL(&G_groupq, &G_groups[i], entry); + TAILQ_INIT(&Groups[i].clients); + Groups[i].hidden = 0; + Groups[i].shortcut = i + 1; + TAILQ_INSERT_TAIL(&Groupq, &Groups[i], entry); } - G_group_current = G_group_active = &G_groups[0]; + Group_current = Group_active = &Groups[0]; } /* @@ -196,8 +196,8 @@ group_new(void) int i; for (i=0; i < CALMWM_NGROUPS; i++) { - if (TAILQ_EMPTY(&G_groups[i].clients)) { - G_group_current = &G_groups[i]; + if (TAILQ_EMPTY(&Groups[i].clients)) { + Group_current = &Groups[i]; return (0); } @@ -211,7 +211,7 @@ group_new(void) int group_select(int idx) { - struct group_ctx *gc = G_group_current; + struct group_ctx *gc = Group_current; struct client_ctx *cc; if (idx < 0 || idx >= CALMWM_NGROUPS) @@ -223,7 +223,7 @@ group_select(int idx) } _group_commit(gc); - G_group_current = &G_groups[idx]; + Group_current = &Groups[idx]; group_display_draw(screen_current()); return (0); @@ -233,16 +233,16 @@ group_select(int idx) void group_enter(void) { - if (G_groupmode != 0) + if (Groupmode != 0) errx(1, "group_enter called twice"); - if (G_group_current == NULL) - G_group_current = &G_groups[0]; + if (Group_current == NULL) + Group_current = &Groups[0]; /* setup input buffer */ - G_group_name[0] = '\0'; + Group_name[0] = '\0'; - G_groupmode = 1; + Groupmode = 1; group_display_init(screen_current()); group_display_draw(screen_current()); @@ -252,10 +252,10 @@ group_enter(void) void group_exit(int commit) { - struct group_ctx *gc = G_group_current; + struct group_ctx *gc = Group_current; struct client_ctx *cc; - if (G_groupmode != 1) + if (Groupmode != 1) errx(1, "group_exit called twice"); TAILQ_FOREACH(cc, &gc->clients, group_entry) { @@ -272,21 +272,21 @@ group_exit(int commit) _group_destroy(gc); } - XUnmapWindow(G_dpy, screen_current()->groupwin); + XUnmapWindow(X_Dpy, screen_current()->groupwin); - if (G_groupnamemode) { - XSetInputFocus(G_dpy, G_groupfocuswin, G_groupfocusrevert, + if (Groupnamemode) { + XSetInputFocus(X_Dpy, Groupfocuswin, Groupfocusrevert, CurrentTime); - G_groupfocusset = 0; + Groupfocusset = 0; } - G_groupmode = G_groupnamemode = 0; + Groupmode = Groupnamemode = 0; } void group_click(struct client_ctx *cc) { - struct group_ctx *gc = G_group_current; + struct group_ctx *gc = Group_current; if (gc == cc->group) _group_remove(cc); @@ -301,13 +301,13 @@ group_click(struct client_ctx *cc) void group_sticky(struct client_ctx *cc) { - _group_add(G_group_active, cc); + _group_add(Group_active, cc); } void group_sticky_toggle_enter(struct client_ctx *cc) { - struct group_ctx *gc = G_group_active; + struct group_ctx *gc = Group_active; if (gc == cc->group) { _group_remove(cc); @@ -334,14 +334,14 @@ group_sticky_toggle_exit(struct client_ctx *cc) void group_display_init(struct screen_ctx *sc) { - sc->groupwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, + sc->groupwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, 1, sc->blackpixl, sc->whitepixl); } void group_display_draw(struct screen_ctx *sc) { - struct group_ctx *gc = G_group_current; + struct group_ctx *gc = Group_current; int x, y, dx, dy, fontheight, titlelen; struct client_ctx *cc; char titlebuf[1024]; @@ -360,13 +360,13 @@ group_display_draw(struct screen_ctx *sc) client_draw_border(cc); } - XMoveResizeWindow(G_dpy, sc->groupwin, x, y, dx, dy); + XMoveResizeWindow(X_Dpy, sc->groupwin, x, y, dx, dy); /* XXX */ - XSelectInput(G_dpy, sc->groupwin, GroupMask); + XSelectInput(X_Dpy, sc->groupwin, GroupMask); - XMapRaised(G_dpy, sc->groupwin); - XClearWindow(G_dpy, sc->groupwin); + XMapRaised(X_Dpy, sc->groupwin); + XClearWindow(X_Dpy, sc->groupwin); font_draw(font, titlebuf, strlen(titlebuf), sc->groupwin, 0, font_ascent(font) + 1); } @@ -374,12 +374,12 @@ group_display_draw(struct screen_ctx *sc) void group_display_keypress(KeyCode k) { - struct group_ctx * gc = G_group_current; + struct group_ctx * gc = Group_current; char chr; enum ctltype ctl; int len; - if (!G_groupnamemode) + if (!Groupnamemode) return; if (input_keycodetrans(k, 0, &ctl, &chr, 1) < 0) @@ -387,14 +387,14 @@ group_display_keypress(KeyCode k) switch (ctl) { case CTL_ERASEONE: - if ((len = strlen(G_group_name)) > 0) - G_group_name[len - 1] = '\0'; + if ((len = strlen(Group_name)) > 0) + Group_name[len - 1] = '\0'; break; case CTL_RETURN: if (gc->name != NULL) xfree(gc->name); - gc->name = xstrdup(G_group_name); + gc->name = xstrdup(Group_name); group_exit(1); return; @@ -403,8 +403,8 @@ group_display_keypress(KeyCode k) } if (chr != '\0') - snprintf(G_group_name, sizeof(G_group_name), "%s%c", - G_group_name, chr); + snprintf(Group_name, sizeof(Group_name), "%s%c", + Group_name, chr); out: group_display_draw(screen_current()); @@ -438,7 +438,7 @@ group_hidetoggle(int idx) if (idx < 0 || idx >= CALMWM_NGROUPS) err(1, "group_hidetoggle: index out of range (%d)", idx); - gc = &G_groups[idx]; + gc = &Groups[idx]; _group_fix_hidden_state(gc); @@ -447,7 +447,7 @@ group_hidetoggle(int idx) else { _group_hide(gc); if (TAILQ_EMPTY(&gc->clients)) - G_group_active = gc; + Group_active = gc; } #ifdef notyet @@ -468,15 +468,15 @@ group_slide(int fwd) { struct group_ctx *gc, *showgroup = NULL; - assert(G_group_active != NULL); + assert(Group_active != NULL); - gc = G_group_active; + gc = Group_active; for (;;) { gc = GROUP_NEXT(gc, fwd); if (gc == NULL) - gc = fwd ? TAILQ_FIRST(&G_groupq) : - TAILQ_LAST(&G_groupq, group_ctx_q); - if (gc == G_group_active) + gc = fwd ? TAILQ_FIRST(&Groupq) : + TAILQ_LAST(&Groupq, group_ctx_q); + if (gc == Group_active) break; if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL) @@ -488,12 +488,12 @@ group_slide(int fwd) if (showgroup == NULL) return; - _group_hide(G_group_active); + _group_hide(Group_active); if (showgroup->hidden) _group_show(showgroup); else - G_group_active = showgroup; + Group_active = showgroup; } /* called when a client is deleted */ @@ -519,7 +519,7 @@ group_menu(XButtonEvent *e) TAILQ_INIT(&menuq); for (i = 0; i < CALMWM_NGROUPS; i++) { - gc = &G_groups[i]; + gc = &Groups[i]; if (TAILQ_EMPTY(&gc->clients)) continue; @@ -563,7 +563,7 @@ group_menu(XButtonEvent *e) void group_namemode(void) { - G_groupnamemode = 1; + Groupnamemode = 1; group_display_draw(screen_current()); } @@ -574,31 +574,31 @@ group_alltoggle(void) int i; for (i=0; i < CALMWM_NGROUPS; i++) { - if (G_grouphideall) - _group_show(&G_groups[i]); + if (Grouphideall) + _group_show(&Groups[i]); else - _group_hide(&G_groups[i]); + _group_hide(&Groups[i]); } - if (G_grouphideall) - G_grouphideall = 0; + if (Grouphideall) + Grouphideall = 0; else - G_grouphideall = 1; + Grouphideall = 1; } void group_deletecurrent(void) { - _group_destroy(G_group_current); - XUnmapWindow(G_dpy, screen_current()->groupwin); + _group_destroy(Group_current); + XUnmapWindow(X_Dpy, screen_current()->groupwin); - G_groupmode = G_groupnamemode = 0; + Groupmode = Groupnamemode = 0; } void group_done(void) { - struct group_ctx *gc = G_group_current; + struct group_ctx *gc = Group_current; if (gc->name != NULL) xfree(gc->name); @@ -618,7 +618,7 @@ group_autogroup(struct client_ctx *cc) if (cc->app_class == NULL || cc->app_name == NULL) return; - TAILQ_FOREACH(aw, &G_conf.autogroupq, entry) { + TAILQ_FOREACH(aw, &Conf.autogroupq, entry) { if (strcmp(aw->class, cc->app_class) == 0 && (aw->name == NULL || strcmp(aw->name, cc->app_name) == 0)) { strlcpy(group, aw->group, sizeof(group)); @@ -626,7 +626,7 @@ group_autogroup(struct client_ctx *cc) } } - TAILQ_FOREACH(gc, &G_groupq, entry) { + TAILQ_FOREACH(gc, &Groupq, entry) { if (strcmp(shortcut_to_name[gc->shortcut], group) == 0) _group_add(gc, cc); } diff --git a/input.c b/input.c index 821ed24..9bc58e2 100644 --- a/input.c +++ b/input.c @@ -20,9 +20,9 @@ input_keycodetrans(KeyCode kc, u_int state, *chr = '\0'; if (state & ShiftMask) - ks = XKeycodeToKeysym(G_dpy, kc, 1); + ks = XKeycodeToKeysym(X_Dpy, kc, 1); else - ks = XKeycodeToKeysym(G_dpy, kc, 0); + ks = XKeycodeToKeysym(X_Dpy, kc, 0); /* Look for control characters. */ switch (ks) { diff --git a/kbfunc.c b/kbfunc.c index f8c463b..7996442 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -31,7 +31,7 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg) TAILQ_INIT(&menuq); - TAILQ_FOREACH(cc, &G_clientq, entry) { + TAILQ_FOREACH(cc, &Clientq, entry) { struct menu *mi; XCALLOC(mi, struct menu); strlcpy(mi->text, cc->name, sizeof(mi->text)); @@ -66,8 +66,8 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg) TAILQ_INIT(&menuq); - conf_cmd_refresh(&G_conf); - TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) { + conf_cmd_refresh(&Conf); + TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { XCALLOC(mi, struct menu); strlcpy(mi->text, cmd->label, sizeof(mi->text)); mi->ctx = cmd; @@ -111,15 +111,15 @@ kbfunc_cmdexec(struct client_ctx *cc, void *arg) void kbfunc_term(struct client_ctx *cc, void *arg) { - conf_cmd_refresh(&G_conf); - u_spawn(G_conf.termpath); + conf_cmd_refresh(&Conf); + u_spawn(Conf.termpath); } void kbfunc_lock(struct client_ctx *cc, void *arg) { - conf_cmd_refresh(&G_conf); - u_spawn(G_conf.lockpath); + conf_cmd_refresh(&Conf); + u_spawn(Conf.lockpath); } void @@ -143,7 +143,7 @@ kbfunc_client_delete(struct client_ctx *cc, void *arg) void kbfunc_client_groupselect(struct client_ctx *cc, void *arg) { - if (G_groupmode) + if (Groupmode) group_done(); else group_enter(); @@ -152,7 +152,7 @@ kbfunc_client_groupselect(struct client_ctx *cc, void *arg) void kbfunc_client_group(struct client_ctx *cc, void *arg) { - if (G_groupmode) + if (Groupmode) group_select(KBTOGROUP((int)arg)); else group_hidetoggle(KBTOGROUP((int)arg)); @@ -173,7 +173,7 @@ kbfunc_client_prevgroup(struct client_ctx *cc, void *arg) void kbfunc_client_nogroup(struct client_ctx *cc, void *arg) { - if (G_groupmode) + if (Groupmode) group_deletecurrent(); else group_alltoggle(); diff --git a/screen.c b/screen.c index 66c288f..548ad13 100644 --- a/screen.c +++ b/screen.c @@ -10,14 +10,14 @@ #include "headers.h" #include "calmwm.h" -extern struct screen_ctx_q G_screenq; -extern struct screen_ctx *G_curscreen; +extern struct screen_ctx_q Screenq; +extern struct screen_ctx *Curscreen; static void _clearwindow_cb(int sig) { struct screen_ctx *sc = screen_current(); - XUnmapWindow(G_dpy, sc->infowin); + XUnmapWindow(X_Dpy, sc->infowin); } struct screen_ctx * @@ -25,18 +25,18 @@ screen_fromroot(Window rootwin) { struct screen_ctx *sc; - TAILQ_FOREACH(sc, &G_screenq, entry) + TAILQ_FOREACH(sc, &Screenq, entry) if (sc->rootwin == rootwin) return (sc); /* XXX FAIL HERE */ - return (TAILQ_FIRST(&G_screenq)); + return (TAILQ_FIRST(&Screenq)); } struct screen_ctx * screen_current(void) { - return (G_curscreen); + return (Curscreen); } void @@ -47,7 +47,7 @@ screen_updatestackingorder(void) u_int nwins, i, s; struct client_ctx *cc; - if (!XQueryTree(G_dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) + if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) return; for (s = 0, i = 0; i < nwins; i++) { @@ -70,7 +70,7 @@ screen_init(void) sc->cycle_client = NULL; - sc->infowin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, + sc->infowin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, 1, sc->blackpixl, sc->whitepixl); /* XXX - marius. */ @@ -86,15 +86,15 @@ screen_infomsg(char *msg) int dy, dx; struct fontdesc *font = DefaultFont; - XUnmapWindow(G_dpy, sc->infowin); + XUnmapWindow(X_Dpy, sc->infowin); alarm(0); snprintf(buf, sizeof(buf), ">%s", msg); dy = font_ascent(font) + font_descent(font) + 1; dx = font_width(font, buf, strlen(buf)); - XMoveResizeWindow(G_dpy, sc->infowin, 0, 0, dx, dy); - XMapRaised(G_dpy, sc->infowin); + XMoveResizeWindow(X_Dpy, sc->infowin, 0, 0, dx, dy); + XMapRaised(X_Dpy, sc->infowin); font_draw(font, buf, strlen(buf), sc->infowin, 0, font_ascent(font) + 1); diff --git a/search.c b/search.c index c56b794..28cd7f2 100644 --- a/search.c +++ b/search.c @@ -17,7 +17,7 @@ static int _strsubmatch(char *, char *); void search_init(struct screen_ctx *sc) { - sc->searchwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, + sc->searchwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, 1, sc->blackpixl, sc->whitepixl); } @@ -63,8 +63,8 @@ search_start(struct menu_q *menuq, TAILQ_INIT(&resultq); - xmax = DisplayWidth(G_dpy, sc->which); - ymax = DisplayHeight(G_dpy, sc->which); + xmax = DisplayWidth(X_Dpy, sc->which); + ymax = DisplayHeight(X_Dpy, sc->which); xu_ptr_getpos(sc->rootwin, &x, &y); @@ -75,27 +75,27 @@ search_start(struct menu_q *menuq, snprintf(dispstr, sizeof(dispstr), "%s%c", promptstr, endchar); dx = font_width(font, dispstr, strlen(dispstr)); - XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); - XSelectInput(G_dpy, sc->searchwin, SearchMask); - XMapRaised(G_dpy, sc->searchwin); + XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy); + XSelectInput(X_Dpy, sc->searchwin, SearchMask); + XMapRaised(X_Dpy, sc->searchwin); /* * TODO: eventually, the mouse should be able to select * results as well. Right now we grab it only to set a fancy * cursor. */ - if (xu_ptr_grab(sc->searchwin, 0, G_cursor_question) < 0) { - XUnmapWindow(G_dpy, sc->searchwin); + if (xu_ptr_grab(sc->searchwin, 0, Cursor_question) < 0) { + XUnmapWindow(X_Dpy, sc->searchwin); return (NULL); } - XGetInputFocus(G_dpy, &focuswin, &focusrevert); - XSetInputFocus(G_dpy, sc->searchwin, RevertToPointerRoot, CurrentTime); + XGetInputFocus(X_Dpy, &focuswin, &focusrevert); + XSetInputFocus(X_Dpy, sc->searchwin, RevertToPointerRoot, CurrentTime); for (;;) { added = mutated = 0; - XMaskEvent(G_dpy, SearchMask, &e); + XMaskEvent(X_Dpy, SearchMask, &e); switch (e.type) { case KeyPress: @@ -239,8 +239,8 @@ search_start(struct menu_q *menuq, if (warp) xu_ptr_setpos(sc->rootwin, x, y); - XClearWindow(G_dpy, sc->searchwin); - XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); + XClearWindow(X_Dpy, sc->searchwin); + XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy); font_draw(font, dispstr, strlen(dispstr), sc->searchwin, 0, font_ascent(font) + 1); @@ -258,11 +258,11 @@ search_start(struct menu_q *menuq, } if (n > 1) - XFillRectangle(G_dpy, sc->searchwin, sc->gc, + XFillRectangle(X_Dpy, sc->searchwin, sc->gc, 0, fontheight, dx, fontheight); if (beobnoxious) - XFillRectangle(G_dpy, sc->searchwin, sc->gc, + XFillRectangle(X_Dpy, sc->searchwin, sc->gc, 0, 0, dx, fontheight); break; @@ -272,9 +272,9 @@ search_start(struct menu_q *menuq, out: /* (if no match) */ xu_ptr_ungrab(); - XSetInputFocus(G_dpy, focuswin, focusrevert, CurrentTime); + XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime); found: - XUnmapWindow(G_dpy, sc->searchwin); + XUnmapWindow(X_Dpy, sc->searchwin); return (mi); } diff --git a/xevents.c b/xevents.c index 784730a..8797f7b 100644 --- a/xevents.c +++ b/xevents.c @@ -38,7 +38,7 @@ xev_handle_maprequest(struct xevent *xev, XEvent *ee) client_ptrsave(old_cc); if ((cc = client_find(e->window)) == NULL) { - XGetWindowAttributes(G_dpy, e->window, &xattr); + XGetWindowAttributes(X_Dpy, e->window, &xattr); cc = client_new(e->window, screen_fromroot(xattr.root), 1); sc = CCTOSC(cc); } else { @@ -113,11 +113,11 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) cc->geom.y = e->y; if (cc->geom.x == 0 && - cc->geom.width >= DisplayWidth(G_dpy, sc->which)) + cc->geom.width >= DisplayWidth(X_Dpy, sc->which)) cc->geom.x -= cc->bwidth; if (cc->geom.y == 0 && - cc->geom.height >= DisplayHeight(G_dpy, sc->which)) + cc->geom.height >= DisplayHeight(X_Dpy, sc->which)) cc->geom.y -= cc->bwidth; client_gravitate(cc, 1); @@ -129,7 +129,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) wc.border_width = 0; /* We need to move the parent window, too. */ - XConfigureWindow(G_dpy, cc->pwin, e->value_mask, &wc); + XConfigureWindow(X_Dpy, cc->pwin, e->value_mask, &wc); xev_reconfig(cc); } @@ -142,7 +142,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) e->value_mask &= ~CWStackMode; e->value_mask |= CWBorderWidth; - XConfigureWindow(G_dpy, e->window, e->value_mask, &wc); + XConfigureWindow(X_Dpy, e->window, e->value_mask, &wc); xev_register(xev); } @@ -157,7 +157,7 @@ xev_handle_propertynotify(struct xevent *xev, XEvent *ee) if ((cc = client_find(e->window)) != NULL) { switch(e->atom) { case XA_WM_NORMAL_HINTS: - XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp); + XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp); break; case XA_WM_NAME: client_setname(cc); @@ -187,7 +187,7 @@ xev_reconfig(struct client_ctx *cc) ce.above = None; ce.override_redirect = 0; - XSendEvent(G_dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce); + XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce); } void @@ -246,7 +246,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) switch (e->button) { case Button1: - TAILQ_FOREACH(cc, &G_clientq, entry) { + TAILQ_FOREACH(cc, &Clientq, entry) { if (cc->flags & CLIENT_HIDDEN) { if (cc->label != NULL) wname = cc->label; @@ -266,11 +266,11 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) break; case Button3: { struct cmd *cmd; - if (conf_cmd_changed(G_conf.menu_path)) { - conf_cmd_clear(&G_conf); - conf_cmd_populate(&G_conf, G_conf.menu_path); + if (conf_cmd_changed(Conf.menu_path)) { + conf_cmd_clear(&Conf); + conf_cmd_populate(&Conf, Conf.menu_path); } - TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) { + TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { XCALLOC(mi, struct menu); strlcpy(mi->text, cmd->label, sizeof(mi->text)); mi->ctx = cmd; @@ -321,7 +321,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) switch (e->button) { case Button1: - if (altcontrol && !G_groupmode) + if (altcontrol && !Groupmode) group_sticky_toggle_enter(cc); else { grab_drag(cc); @@ -330,7 +330,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) break; case Button2: /* XXXSIGH!!! */ - if (G_groupmode) + if (Groupmode) group_click(cc); else { grab_sweep(cc); @@ -351,7 +351,7 @@ xev_handle_buttonrelease(struct xevent *xev, XEvent *ee) { struct client_ctx *cc = client_current(); - if (cc != NULL && !G_groupmode) + if (cc != NULL && !Groupmode) group_sticky_toggle_exit(cc); xev_register(xev); @@ -367,10 +367,10 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee) KeySym keysym, skeysym; int modshift; - keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0); - skeysym = XKeycodeToKeysym(G_dpy, e->keycode, 1); + keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); + skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1); - TAILQ_FOREACH(kb, &G_conf.keybindingq, entry) { + TAILQ_FOREACH(kb, &Conf.keybindingq, entry) { if (keysym != kb->keysym && skeysym == kb->keysym) modshift = ShiftMask; else @@ -413,7 +413,7 @@ xev_handle_keyrelease(struct xevent *xev, XEvent *ee) struct screen_ctx *sc = screen_fromroot(e->root); int keysym; - keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0); + keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); if (keysym != XK_Alt_L && keysym != XK_Alt_R) goto out; @@ -435,7 +435,7 @@ xev_handle_clientmessage(struct xevent *xev, XEvent *ee) { XClientMessageEvent *e = &ee->xclient; struct client_ctx *cc = client_find(e->window); - Atom xa_wm_change_state = XInternAtom(G_dpy, "WM_CHANGE_STATE", False); + Atom xa_wm_change_state = XInternAtom(X_Dpy, "WM_CHANGE_STATE", False); if (cc == NULL) goto out; @@ -536,7 +536,7 @@ xev_loop(void) errx(1, "X event queue empty"); #endif - XNextEvent(G_dpy, &e); + XNextEvent(X_Dpy, &e); type = e.type; win = root = 0; diff --git a/xutil.c b/xutil.c index 41f0e17..38549cf 100644 --- a/xutil.c +++ b/xutil.c @@ -13,7 +13,7 @@ int xu_ptr_grab(Window win, int mask, Cursor curs) { - return (XGrabPointer(G_dpy, win, False, mask, + return (XGrabPointer(X_Dpy, win, False, mask, GrabModeAsync, GrabModeAsync, None, curs, CurrentTime) == GrabSuccess ? 0 : -1); } @@ -21,20 +21,20 @@ xu_ptr_grab(Window win, int mask, Cursor curs) int xu_ptr_regrab(int mask, Cursor curs) { - return (XChangeActivePointerGrab(G_dpy, mask, + return (XChangeActivePointerGrab(X_Dpy, mask, curs, CurrentTime) == GrabSuccess ? 0 : -1); } void xu_ptr_ungrab(void) { - XUngrabPointer(G_dpy, CurrentTime); + XUngrabPointer(X_Dpy, CurrentTime); } int xu_btn_grab(Window win, int mask, u_int btn) { - return (XGrabButton(G_dpy, btn, mask, win, + return (XGrabButton(X_Dpy, btn, mask, win, False, ButtonMask, GrabModeAsync, GrabModeSync, None, None) == GrabSuccess ? 0 : -1); } @@ -42,7 +42,7 @@ xu_btn_grab(Window win, int mask, u_int btn) void xu_btn_ungrab(Window win, int mask, u_int btn) { - XUngrabButton(G_dpy, btn, mask, win); + XUngrabButton(X_Dpy, btn, mask, win); } void @@ -52,13 +52,13 @@ xu_ptr_getpos(Window rootwin, int *x, int *y) u_int tmp2; Window w0, w1; - XQueryPointer(G_dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); + XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); } void xu_ptr_setpos(Window win, int x, int y) { - XWarpPointer(G_dpy, None, win, 0, 0, 0, 0, x, y); + XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y); } void @@ -66,15 +66,15 @@ xu_key_grab(Window win, int mask, int keysym) { KeyCode code; - code = XKeysymToKeycode(G_dpy, keysym); - if ((XKeycodeToKeysym(G_dpy, code, 0) != keysym) && - (XKeycodeToKeysym(G_dpy, code, 1) == keysym)) + code = XKeysymToKeycode(X_Dpy, keysym); + if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && + (XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) mask |= ShiftMask; - XGrabKey(G_dpy, XKeysymToKeycode(G_dpy, keysym), mask, win, True, + XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True, GrabModeAsync, GrabModeAsync); #if 0 - XGrabKey(G_dpy, XKeysymToKeycode(G_dpy, keysym), LockMask|mask, + XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), LockMask|mask, win, True, GrabModeAsync, GrabModeAsync); #endif } @@ -82,7 +82,7 @@ xu_key_grab(Window win, int mask, int keysym) void xu_key_grab_keycode(Window win, int mask, int keycode) { - XGrabKey(G_dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync); + XGrabKey(X_Dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync); } void @@ -98,7 +98,7 @@ xu_sendmsg(struct client_ctx *cc, Atom atm, long val) e.xclient.data.l[0] = val; e.xclient.data.l[1] = CurrentTime; - XSendEvent(G_dpy, cc->win, False, 0, &e); + XSendEvent(X_Dpy, cc->win, False, 0, &e); } int @@ -108,7 +108,7 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p) u_long n, extra; int format; - if (XGetWindowProperty(G_dpy, cc->win, atm, 0L, len, False, type, + if (XGetWindowProperty(X_Dpy, cc->win, atm, 0L, len, False, type, &realtype, &format, &n, &extra, p) != Success || *p == NULL) return (-1); @@ -121,7 +121,7 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p) int xu_getstate(struct client_ctx *cc, int *state) { - Atom wm_state = XInternAtom(G_dpy, "WM_STATE", False); + Atom wm_state = XInternAtom(X_Dpy, "WM_STATE", False); long *p = NULL; if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0) @@ -151,12 +151,12 @@ xu_setstate(struct client_ctx *cc, int state) Atom wm_state; /* XXX cache */ - wm_state = XInternAtom(G_dpy, "WM_STATE", False); + wm_state = XInternAtom(X_Dpy, "WM_STATE", False); dat[0] = (long)state; dat[1] = (long)None; cc->state = state; - XChangeProperty(G_dpy, cc->win, wm_state, wm_state, 32, + XChangeProperty(X_Dpy, cc->win, wm_state, wm_state, 32, PropModeReplace, (unsigned char *)dat, 2); } |