diff options
author | okan <okan> | 2013-12-02 20:01:19 +0000 |
---|---|---|
committer | okan <okan> | 2013-12-02 20:01:19 +0000 |
commit | 873763f4c6a4369d703274a279296200bfd271a2 (patch) | |
tree | b9e271a8395656cebd2de507b6abffda288d9ed6 | |
parent | 3c78191e2ef0b51da1f70327cc9b7e087413f88d (diff) | |
parent | 5dc65d9242c423fd4f45ec48c32e525d9f1300f2 (diff) | |
download | cwm-873763f4c6a4369d703274a279296200bfd271a2.tar.gz cwm-873763f4c6a4369d703274a279296200bfd271a2.tar.xz cwm-873763f4c6a4369d703274a279296200bfd271a2.zip |
cvsimport
-rw-r--r-- | calmwm.h | 7 | ||||
-rw-r--r-- | client.c | 150 | ||||
-rw-r--r-- | conf.c | 18 | ||||
-rw-r--r-- | cwmrc.5 | 8 | ||||
-rw-r--r-- | kbfunc.c | 4 | ||||
-rw-r--r-- | menu.c | 9 | ||||
-rw-r--r-- | mousefunc.c | 17 | ||||
-rw-r--r-- | parse.y | 10 | ||||
-rw-r--r-- | search.c | 4 | ||||
-rw-r--r-- | xevents.c | 31 |
10 files changed, 99 insertions, 159 deletions
diff --git a/calmwm.h b/calmwm.h index fdcf62c..349101b 100644 --- a/calmwm.h +++ b/calmwm.h @@ -228,6 +228,7 @@ struct screen_ctx { Window rootwin; Window menuwin; int cycling; + int snapdist; struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ struct gap gap; @@ -380,8 +381,7 @@ void client_applysizehints(struct client_ctx *); void client_config(struct client_ctx *); struct client_ctx *client_current(void); void client_cycle(struct screen_ctx *, int); -void client_cycle_leave(struct screen_ctx *, - struct client_ctx *); +void client_cycle_leave(struct screen_ctx *); void client_delete(struct client_ctx *); void client_draw_border(struct client_ctx *); struct client_ctx *client_find(Window); @@ -390,7 +390,6 @@ void client_getsizehints(struct client_ctx *); void client_hide(struct client_ctx *); void client_hmaximize(struct client_ctx *); void client_htile(struct client_ctx *); -void client_leave(struct client_ctx *); void client_lower(struct client_ctx *); void client_map(struct client_ctx *); void client_maximize(struct client_ctx *); @@ -402,7 +401,7 @@ void client_ptrwarp(struct client_ctx *); void client_raise(struct client_ctx *); void client_resize(struct client_ctx *, int); void client_send_delete(struct client_ctx *); -void client_setactive(struct client_ctx *, int); +void client_setactive(struct client_ctx *); void client_setname(struct client_ctx *); int client_snapcalc(int, int, int, int, int); void client_transient(struct client_ctx *); diff --git a/client.c b/client.c index a874c6e..05b1965 100644 --- a/client.c +++ b/client.c @@ -180,53 +180,35 @@ client_delete(struct client_ctx *cc) } void -client_leave(struct client_ctx *cc) +client_setactive(struct client_ctx *cc) { - if (cc == NULL) - cc = client_current(); - if (cc == NULL) - return; -} - -void -client_setactive(struct client_ctx *cc, int fg) -{ - struct screen_ctx *sc; - - if (cc == NULL) - cc = client_current(); - if (cc == NULL) - return; + struct screen_ctx *sc = cc->sc; + struct client_ctx *oldcc; - sc = cc->sc; + XInstallColormap(X_Dpy, cc->colormap); - if (fg) { - XInstallColormap(X_Dpy, cc->colormap); - if ((cc->flags & CLIENT_INPUT) || - ((cc->flags & CLIENT_WM_TAKE_FOCUS) == 0)) { - XSetInputFocus(X_Dpy, cc->win, - RevertToPointerRoot, CurrentTime); - } - if (cc->flags & CLIENT_WM_TAKE_FOCUS) - client_msg(cc, cwmh[WM_TAKE_FOCUS]); - conf_grab_mouse(cc->win); - /* - * If we're in the middle of alt-tabbing, don't change - * the order please. - */ - if (!sc->cycling) - client_mtf(cc); - } else - client_leave(cc); + if ((cc->flags & CLIENT_INPUT) || + ((cc->flags & CLIENT_WM_TAKE_FOCUS) == 0)) { + XSetInputFocus(X_Dpy, cc->win, + RevertToPointerRoot, CurrentTime); + } + if (cc->flags & CLIENT_WM_TAKE_FOCUS) + client_msg(cc, cwmh[WM_TAKE_FOCUS]); - if (fg && cc != client_current()) { - client_setactive(NULL, 0); - _curcc = cc; - xu_ewmh_net_active_window(sc, cc->win); + if ((oldcc = client_current())) { + oldcc->active = 0; + client_draw_border(oldcc); } - cc->active = fg; + /* If we're in the middle of cycing, don't change the order. */ + if (!sc->cycling) + client_mtf(cc); + + _curcc = cc; + cc->active = 1; client_draw_border(cc); + conf_grab_mouse(cc->win); + xu_ewmh_net_active_window(sc, cc->win); } /* @@ -640,12 +622,14 @@ client_cycle(struct screen_ctx *sc, int flags) } void -client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc) +client_cycle_leave(struct screen_ctx *sc) { + struct client_ctx *cc; + sc->cycling = 0; - client_mtf(NULL); - if (cc) { + if ((cc = client_current())) { + client_mtf(cc); group_sticky_toggle_exit(cc); XUngrabKeyboard(X_Dpy, CurrentTime); } @@ -724,14 +708,8 @@ client_placecalc(struct client_ctx *cc) static void client_mtf(struct client_ctx *cc) { - struct screen_ctx *sc; - - if (cc == NULL) - cc = client_current(); - if (cc == NULL) - return; + struct screen_ctx *sc = cc->sc; - sc = cc->sc; TAILQ_REMOVE(&sc->mruq, cc, mru_entry); TAILQ_INSERT_HEAD(&sc->mruq, cc, mru_entry); } @@ -740,52 +718,46 @@ void client_getsizehints(struct client_ctx *cc) { long tmp; - XSizeHints *size; + XSizeHints size; - if ((size = XAllocSizeHints()) == NULL) - warnx("XAllocSizeHints failure"); + if (!XGetWMNormalHints(X_Dpy, cc->win, &size, &tmp)) + size.flags = 0; - if (!XGetWMNormalHints(X_Dpy, cc->win, size, &tmp)) - size->flags = 0; + cc->hint.flags = size.flags; - cc->hint.flags = size->flags; - - if (size->flags & PBaseSize) { - cc->hint.basew = size->base_width; - cc->hint.baseh = size->base_height; - } else if (size->flags & PMinSize) { - cc->hint.basew = size->min_width; - cc->hint.baseh = size->min_height; + if (size.flags & PBaseSize) { + cc->hint.basew = size.base_width; + cc->hint.baseh = size.base_height; + } else if (size.flags & PMinSize) { + cc->hint.basew = size.min_width; + cc->hint.baseh = size.min_height; } - if (size->flags & PMinSize) { - cc->hint.minw = size->min_width; - cc->hint.minh = size->min_height; - } else if (size->flags & PBaseSize) { - cc->hint.minw = size->base_width; - cc->hint.minh = size->base_height; + if (size.flags & PMinSize) { + cc->hint.minw = size.min_width; + cc->hint.minh = size.min_height; + } else if (size.flags & PBaseSize) { + cc->hint.minw = size.base_width; + cc->hint.minh = size.base_height; } - if (size->flags & PMaxSize) { - cc->hint.maxw = size->max_width; - cc->hint.maxh = size->max_height; + if (size.flags & PMaxSize) { + cc->hint.maxw = size.max_width; + cc->hint.maxh = size.max_height; } - if (size->flags & PResizeInc) { - cc->hint.incw = size->width_inc; - cc->hint.inch = size->height_inc; + if (size.flags & PResizeInc) { + cc->hint.incw = size.width_inc; + cc->hint.inch = size.height_inc; } cc->hint.incw = MAX(1, cc->hint.incw); cc->hint.inch = MAX(1, cc->hint.inch); - if (size->flags & PAspect) { - if (size->min_aspect.x > 0) - cc->hint.mina = (float)size->min_aspect.y / - size->min_aspect.x; - if (size->max_aspect.y > 0) - cc->hint.maxa = (float)size->max_aspect.x / - size->max_aspect.y; + if (size.flags & PAspect) { + if (size.min_aspect.x > 0) + cc->hint.mina = (float)size.min_aspect.y / + size.min_aspect.x; + if (size.max_aspect.y > 0) + cc->hint.maxa = (float)size.max_aspect.x / + size.max_aspect.y; } - - if (size) - XFree(size); } void @@ -803,12 +775,10 @@ client_applysizehints(struct client_ctx *cc) } /* adjust for aspect limits */ - if (cc->hint.mina > 0 && cc->hint.maxa > 0) { - if (cc->hint.maxa < - (float)cc->geom.w / cc->geom.h) + if (cc->hint.mina && cc->hint.maxa) { + if (cc->hint.maxa < (float)cc->geom.w / cc->geom.h) cc->geom.w = cc->geom.h * cc->hint.maxa; - else if (cc->hint.mina < - (float)cc->geom.h / cc->geom.w) + else if (cc->hint.mina < (float)cc->geom.h / cc->geom.w) cc->geom.h = cc->geom.w * cc->hint.mina; } diff --git a/conf.c b/conf.c index cd8f9d2..5eadfaf 100644 --- a/conf.c +++ b/conf.c @@ -103,6 +103,7 @@ conf_screen(struct screen_ctx *sc) XftColor xc; sc->gap = Conf.gap; + sc->snapdist = Conf.snapdist; sc->xftfont = XftFontOpenXlfd(X_Dpy, sc->which, Conf.font); if (sc->xftfont == NULL) { @@ -479,17 +480,8 @@ conf_bind_kbd(struct conf *c, char *name, char *binding) substring = conf_bind_getmask(name, &mask); current_binding->modmask |= mask; - if (substring[0] == '[' && - substring[strlen(substring)-1] == ']') { - sscanf(substring, "[%d]", ¤t_binding->keycode); - current_binding->keysym = NoSymbol; - } else { - current_binding->keycode = 0; - current_binding->keysym = XStringToKeysym(substring); - } - - if (current_binding->keysym == NoSymbol && - current_binding->keycode == 0) { + current_binding->keysym = XStringToKeysym(substring); + if (current_binding->keysym == NoSymbol) { free(current_binding); return; } @@ -530,9 +522,7 @@ conf_unbind_kbd(struct conf *c, struct keybinding *unbind) if (key->modmask != unbind->modmask) continue; - if ((key->keycode != 0 && key->keysym == NoSymbol && - key->keycode == unbind->keycode) || - key->keysym == unbind->keysym) { + if (key->keysym == unbind->keysym) { TAILQ_REMOVE(&c->keybindingq, key, entry); if (key->argtype & ARG_CHAR) free(key->argument.c); diff --git a/cwmrc.5 b/cwmrc.5 index 9f75dbd..2d00e73 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 17 2013 $ +.Dd $Mdocdate: July 8 2013 $ .Dt CWMRC 5 .Os .Sh NAME @@ -84,10 +84,8 @@ The Mod4 key (normally the windows key). .Pp The .Sq - -should be followed by either a keysym name, taken from -.Pa /usr/X11R6/include/X11/keysymdef.h , -or a numerical keycode value enclosed in -.Dq [] . +should be followed by a keysym name, taken from +.Pa /usr/X11R6/include/X11/keysymdef.h . The .Ar command may either be one from the diff --git a/kbfunc.c b/kbfunc.c index 3717b39..22b6a68 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -101,10 +101,10 @@ kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg) cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x + cc->geom.w + (cc->bwidth * 2), - sc->work.x, sc->work.w, Conf.snapdist); + sc->work.x, sc->work.w, sc->snapdist); cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y + cc->geom.h + (cc->bwidth * 2), - sc->work.y, sc->work.h, Conf.snapdist); + sc->work.y, sc->work.h, sc->snapdist); client_move(cc); xu_ptr_getpos(cc->win, &x, &y); diff --git a/menu.c b/menu.c index 6277595..af9eda1 100644 --- a/menu.c +++ b/menu.c @@ -427,10 +427,8 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) xu_xft_draw(sc, text, CWM_COLOR_MENU_FONT, 0, y); n++; } - if (mc->hasprompt && n > 1 && (mc->searchstr[0] != '\0')) { - mc->entry = 1; - menu_draw_entry(mc, resultq, mc->entry, 1); - } + if (mc->hasprompt && n > 1) + menu_draw_entry(mc, resultq, 1, 1); } static void @@ -477,9 +475,6 @@ menu_handle_move(XEvent *e, struct menu_ctx *mc, struct menu_q *resultq) menu_draw_entry(mc, resultq, mc->entry, 1); } else (void)xu_ptr_regrab(MENUGRABMASK, Conf.cursor[CF_DEFAULT]); - - if (mc->hasprompt) - menu_draw_entry(mc, resultq, 1, 1); } static struct menu * diff --git a/mousefunc.c b/mousefunc.c index 0de35c8..9813c5b 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -50,21 +50,19 @@ static void mousefunc_sweep_draw(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; - char asize[14]; /* fits " nnnn x nnnn \0" */ + char s[14]; /* fits " nnnn x nnnn \0" */ - (void)snprintf(asize, sizeof(asize), " %4d x %-4d ", + (void)snprintf(s, sizeof(s), " %4d x %-4d ", (cc->geom.w - cc->hint.basew) / cc->hint.incw, (cc->geom.h - cc->hint.baseh) / cc->hint.inch); XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0); XMoveResizeWindow(X_Dpy, sc->menuwin, 0, 0, - xu_xft_width(sc->xftfont, asize, strlen(asize)), - sc->xftfont->height); + xu_xft_width(sc->xftfont, s, strlen(s)), sc->xftfont->height); XMapWindow(X_Dpy, sc->menuwin); XClearWindow(X_Dpy, sc->menuwin); - xu_xft_draw(sc, asize, CWM_COLOR_MENU_FONT, - 0, sc->xftfont->ascent + 1); + xu_xft_draw(sc, s, CWM_COLOR_MENU_FONT, 0, sc->xftfont->ascent + 1); } void @@ -149,10 +147,10 @@ mousefunc_client_move(struct client_ctx *cc, void *arg) cc->geom.x += client_snapcalc(cc->geom.x, cc->geom.x + cc->geom.w + (cc->bwidth * 2), - sc->work.x, sc->work.w, Conf.snapdist); + sc->work.x, sc->work.w, sc->snapdist); cc->geom.y += client_snapcalc(cc->geom.y, cc->geom.y + cc->geom.h + (cc->bwidth * 2), - sc->work.y, sc->work.h, Conf.snapdist); + sc->work.y, sc->work.h, sc->snapdist); /* don't move more than 60 times / second */ if ((ev.xmotion.time - ltime) > (1000 / 60)) { @@ -233,7 +231,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg) continue; mi = xcalloc(1, sizeof(*mi)); - (void)strlcpy(mi->text, wname, sizeof(mi->text)); + (void)snprintf(mi->text, sizeof(mi->text), + "(%d) %s", cc->group->shortcut, wname); mi->ctx = cc; TAILQ_INSERT_TAIL(&menuq, mi, entry); } diff --git a/parse.y b/parse.y index 0178092..43499fe 100644 --- a/parse.y +++ b/parse.y @@ -288,9 +288,9 @@ lookup(char *s) #define MAXPUSHBACK 128 -char *parsebuf; +u_char *parsebuf; int parseindex; -char pushback_buffer[MAXPUSHBACK]; +u_char pushback_buffer[MAXPUSHBACK]; int pushback_index = 0; int @@ -383,8 +383,8 @@ findeol(void) int yylex(void) { - char buf[8096]; - char *p; + u_char buf[8096]; + u_char *p; int quotec, next, c; int token; @@ -425,7 +425,7 @@ yylex(void) yyerror("string too long"); return (findeol()); } - *p++ = (char)c; + *p++ = c; } yylval.v.string = xstrdup(buf); return (STRING); diff --git a/search.c b/search.c index 1884ef8..2d5dd29 100644 --- a/search.c +++ b/search.c @@ -142,8 +142,8 @@ search_print_client(struct menu *mi, int list) if (list) cc->matchname = cc->name; - (void)snprintf(mi->print, sizeof(mi->print), "%c%s", flag, - cc->matchname); + (void)snprintf(mi->print, sizeof(mi->print), "(%d) %c%s", + cc->group->shortcut, flag, cc->matchname); if (!list && cc->matchname != cc->name && strlen(mi->print) < sizeof(mi->print) - 1) { diff --git a/xevents.c b/xevents.c index 0d7c41c..cff5f0f 100644 --- a/xevents.c +++ b/xevents.c @@ -43,7 +43,6 @@ static void xev_handle_destroynotify(XEvent *); static void xev_handle_configurerequest(XEvent *); static void xev_handle_propertynotify(XEvent *); static void xev_handle_enternotify(XEvent *); -static void xev_handle_leavenotify(XEvent *); static void xev_handle_buttonpress(XEvent *); static void xev_handle_buttonrelease(XEvent *); static void xev_handle_keypress(XEvent *); @@ -60,7 +59,6 @@ void (*xev_handlers[LASTEvent])(XEvent *) = { [ConfigureRequest] = xev_handle_configurerequest, [PropertyNotify] = xev_handle_propertynotify, [EnterNotify] = xev_handle_enternotify, - [LeaveNotify] = xev_handle_leavenotify, [ButtonPress] = xev_handle_buttonpress, [ButtonRelease] = xev_handle_buttonrelease, [KeyPress] = xev_handle_keypress, @@ -81,7 +79,7 @@ xev_handle_maprequest(XEvent *ee) struct client_ctx *cc = NULL, *old_cc; XWindowAttributes xattr; - if ((old_cc = client_current()) != NULL) + if ((old_cc = client_current())) client_ptrsave(old_cc); if ((cc = client_find(e->window)) == NULL) { @@ -103,8 +101,10 @@ xev_handle_unmapnotify(XEvent *ee) if (e->send_event) { cc->state = WithdrawnState; xu_set_wm_state(cc->win, cc->state); - } else - client_hide(cc); + } else { + if (!(cc->flags & CLIENT_HIDDEN)) + client_delete(cc); + } } } @@ -211,13 +211,7 @@ xev_handle_enternotify(XEvent *ee) struct client_ctx *cc; if ((cc = client_find(e->window)) != NULL) - client_setactive(cc, 1); -} - -static void -xev_handle_leavenotify(XEvent *ee) -{ - client_leave(NULL); + client_setactive(cc); } /* We can split this into two event handlers. */ @@ -256,7 +250,7 @@ xev_handle_buttonrelease(XEvent *ee) { struct client_ctx *cc; - if ((cc = client_current()) != NULL) + if ((cc = client_current())) group_sticky_toggle_exit(cc); } @@ -283,9 +277,7 @@ xev_handle_keypress(XEvent *ee) if ((kb->modmask | modshift) != e->state) continue; - if ((kb->keycode != 0 && kb->keysym == NoSymbol && - kb->keycode == e->keycode) || kb->keysym == - (modshift == 0 ? keysym : skeysym)) + if (kb->keysym == (modshift == 0 ? keysym : skeysym)) break; } @@ -311,17 +303,15 @@ xev_handle_keyrelease(XEvent *ee) { XKeyEvent *e = &ee->xkey; struct screen_ctx *sc; - struct client_ctx *cc; KeySym keysym; u_int i; sc = screen_fromroot(e->root); - cc = client_current(); keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); for (i = 0; i < nitems(modkeys); i++) { if (keysym == modkeys[i]) { - client_cycle_leave(sc, cc); + client_cycle_leave(sc); break; } } @@ -344,8 +334,7 @@ xev_handle_clientmessage(XEvent *ee) client_send_delete(cc); if (e->message_type == ewmh[_NET_ACTIVE_WINDOW] && e->format == 32) { - old_cc = client_current(); - if (old_cc) + if ((old_cc = client_current())) client_ptrsave(old_cc); client_ptrwarp(cc); } |