diff --git a/calmwm.h b/calmwm.h index 6b6ce63..c08f6a5 100644 --- a/calmwm.h +++ b/calmwm.h @@ -217,7 +217,7 @@ TAILQ_HEAD(autogroupwin_q, autogroupwin); struct screen_ctx { TAILQ_ENTRY(screen_ctx) entry; - u_int which; + int which; Visual *visual; Colormap colormap; Window rootwin; @@ -364,7 +364,6 @@ void group_client_delete(struct client_ctx *); void group_cycle(struct screen_ctx *, int); void group_hidetoggle(struct screen_ctx *, int); void group_init(struct screen_ctx *); -void group_make_autogroup(struct conf *, char *, int); void group_menu(XButtonEvent *); void group_movetogroup(struct client_ctx *, int); void group_only(struct screen_ctx *, int); @@ -387,7 +386,7 @@ void search_print_client(struct menu *, int); struct geom screen_find_xinerama(struct screen_ctx *, int, int); struct screen_ctx *screen_fromroot(Window); -void screen_init(u_int); +void screen_init(int); void screen_update_geometry(struct screen_ctx *); void screen_updatestackingorder(struct screen_ctx *); @@ -448,6 +447,7 @@ void menuq_clear(struct menu_q *); int parse_config(const char *, struct conf *); +void conf_autogroup(struct conf *, int, char *); void conf_bindname(struct conf *, char *, char *); void conf_clear(struct conf *); void conf_client(struct client_ctx *); @@ -458,6 +458,7 @@ void conf_gap(struct conf *, struct screen_ctx *); void conf_grab(struct conf *, struct keybinding *); void conf_grab_mouse(struct client_ctx *); void conf_init(struct conf *); +void conf_ignore(struct conf *, char *); void conf_mousebind(struct conf *, char *, char *); void conf_ungrab(struct conf *, struct keybinding *); @@ -478,7 +479,7 @@ void xu_configure(struct client_ctx *); void xu_getatoms(void); unsigned long xu_getcolor(struct screen_ctx *, char *); int xu_getprop(Window, Atom, Atom, long, u_char **); -int xu_getstate(Window, int *); +int xu_get_wm_state(Window, int *); int xu_getstrprop(Window, Atom, char **); void xu_key_grab(Window, int, int); void xu_key_ungrab(Window, int, int); @@ -488,7 +489,7 @@ int xu_ptr_regrab(int, Cursor); void xu_ptr_setpos(Window, int, int); void xu_ptr_ungrab(void); void xu_sendmsg(Window, Atom, long); -void xu_setstate(struct client_ctx *, int); +void xu_set_wm_state(Window win, int); void xu_xorcolor(XRenderColor, XRenderColor, XRenderColor *); diff --git a/client.c b/client.c index 380cd33..c485b07 100644 --- a/client.c +++ b/client.c @@ -101,17 +101,18 @@ client_new(Window win, struct screen_ctx *sc, int mapped) if (wattr.map_state != IsViewable) { client_placecalc(cc); + client_move(cc); if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) { - if (wmhints->flags & StateHint) - xu_setstate(cc, wmhints->initial_state); - + if (wmhints->flags & StateHint) { + cc->state = wmhints->initial_state; + xu_set_wm_state(cc->win, cc->state); + } XFree(wmhints); } - client_move(cc); } client_draw_border(cc); - if (xu_getstate(cc->win, &state) < 0) + if (xu_get_wm_state(cc->win, &state) < 0) state = NormalState; XSelectInput(X_Dpy, cc->win, ColormapChangeMask | EnterWindowMask | @@ -151,7 +152,8 @@ client_delete(struct client_ctx *cc) group_client_delete(cc); XGrabServer(X_Dpy); - xu_setstate(cc, WithdrawnState); + cc->state = WithdrawnState; + xu_set_wm_state(cc->win, cc->state); XRemoveFromSaveSet(X_Dpy, cc->win); XSync(X_Dpy, False); @@ -451,7 +453,8 @@ client_hide(struct client_ctx *cc) cc->active = 0; cc->flags |= CLIENT_HIDDEN; - xu_setstate(cc, IconicState); + cc->state = IconicState; + xu_set_wm_state(cc->win, cc->state); if (cc == client_current()) client_none(cc->sc); @@ -463,7 +466,8 @@ client_unhide(struct client_ctx *cc) XMapRaised(X_Dpy, cc->win); cc->flags &= ~CLIENT_HIDDEN; - xu_setstate(cc, NormalState); + cc->state = NormalState; + xu_set_wm_state(cc->win, cc->state); client_draw_border(cc); } diff --git a/conf.c b/conf.c index 342fd6a..705c9e0 100644 --- a/conf.c +++ b/conf.c @@ -39,7 +39,6 @@ void conf_cmd_add(struct conf *c, char *image, char *label) { /* "term" and "lock" have special meanings. */ - if (strcmp(label, "term") == 0) (void)strlcpy(c->termpath, image, sizeof(c->termpath)); else if (strcmp(label, "lock") == 0) @@ -52,6 +51,39 @@ conf_cmd_add(struct conf *c, char *image, char *label) } } +void +conf_autogroup(struct conf *c, int no, char *val) +{ + struct autogroupwin *aw; + char *p; + + aw = xcalloc(1, sizeof(*aw)); + + if ((p = strchr(val, ',')) == NULL) { + aw->name = NULL; + aw->class = xstrdup(val); + } else { + *(p++) = '\0'; + aw->name = xstrdup(val); + aw->class = xstrdup(p); + } + aw->num = no; + + TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry); +} + +void +conf_ignore(struct conf *c, char *val) +{ + struct winmatch *wm; + + wm = xcalloc(1, sizeof(*wm)); + + (void)strlcpy(wm->title, val, sizeof(wm->title)); + + TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry); +} + void conf_gap(struct conf *c, struct screen_ctx *sc) { diff --git a/group.c b/group.c index 34d0465..48dfc68 100644 --- a/group.c +++ b/group.c @@ -98,8 +98,7 @@ group_show(struct screen_ctx *sc, struct group_ctx *gc) { struct client_ctx *cc; Window *winlist; - u_int i; - int lastempty = -1; + int i, lastempty = -1; gc->highstack = 0; TAILQ_FOREACH(cc, &gc->clients, group_entry) { @@ -163,27 +162,6 @@ group_init(struct screen_ctx *sc) group_setactive(sc, 1); } -void -group_make_autogroup(struct conf *conf, char *val, int no) -{ - struct autogroupwin *aw; - char *p; - - aw = xcalloc(1, sizeof(*aw)); - - if ((p = strchr(val, ',')) == NULL) { - aw->name = NULL; - aw->class = xstrdup(val); - } else { - *(p++) = '\0'; - aw->name = xstrdup(val); - aw->class = xstrdup(p); - } - aw->num = no; - - TAILQ_INSERT_TAIL(&conf->autogroupq, aw, entry); -} - static void group_setactive(struct screen_ctx *sc, long idx) { diff --git a/parse.y b/parse.y index 4188418..376bc2b 100644 --- a/parse.y +++ b/parse.y @@ -139,16 +139,11 @@ main : FONTNAME STRING { YYERROR; } - group_make_autogroup(conf, $3, $2); + conf_autogroup(conf, $2, $3); free($3); } | IGNORE STRING { - struct winmatch *wm; - - wm = xcalloc(1, sizeof(*wm)); - (void)strlcpy(wm->title, $2, sizeof(wm->title)); - TAILQ_INSERT_TAIL(&conf->ignoreq, wm, entry); - + conf_ignore(conf, $2); free($2); } | BIND STRING string { diff --git a/screen.c b/screen.c index 64c4280..e856336 100644 --- a/screen.c +++ b/screen.c @@ -31,7 +31,7 @@ #include "calmwm.h" void -screen_init(u_int which) +screen_init(int which) { struct screen_ctx *sc; Window *wins, w0, w1; @@ -50,16 +50,14 @@ screen_init(u_int which) xu_ewmh_net_supported_wm_check(sc); conf_gap(&Conf, sc); + conf_color(&Conf, sc); + conf_font(&Conf, sc); screen_update_geometry(sc); - conf_color(&Conf, sc); - - group_init(sc); - conf_font(&Conf, sc); - TAILQ_INIT(&sc->mruq); + group_init(sc); menu_init(sc); rootattr.cursor = Cursor_normal; diff --git a/search.c b/search.c index d419d70..1884ef8 100644 --- a/search.c +++ b/search.c @@ -38,6 +38,8 @@ static void search_match_path(struct menu_q *, struct menu_q *, char *, int); +static void search_match_path_exec(struct menu_q *, struct menu_q *, + char *); static int strsubmatch(char *, char *, int); /* @@ -192,7 +194,7 @@ search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, in globfree(&g); } -void +static void search_match_path_exec(struct menu_q *menuq, struct menu_q *resultq, char *search) { return (search_match_path(menuq, resultq, search, PATH_EXEC)); diff --git a/xevents.c b/xevents.c index b1ebdba..da7542b 100644 --- a/xevents.c +++ b/xevents.c @@ -362,7 +362,7 @@ xev_handle_randr(XEvent *ee) i = XRRRootToScreen(X_Dpy, rev->root); TAILQ_FOREACH(sc, &Screenq, entry) { - if (sc->which == (u_int)i) { + if (sc->which == i) { XRRUpdateConfiguration(ee); screen_update_geometry(sc); } diff --git a/xutil.c b/xutil.c index 108421e..f8bd200 100644 --- a/xutil.c +++ b/xutil.c @@ -203,7 +203,7 @@ xu_getstrprop(Window win, Atom atm, char **text) { } int -xu_getstate(Window win, int *state) +xu_get_wm_state(Window win, int *state) { long *p = NULL; @@ -218,15 +218,14 @@ xu_getstate(Window win, int *state) } void -xu_setstate(struct client_ctx *cc, int state) +xu_set_wm_state(Window win, int state) { long dat[2]; dat[0] = state; dat[1] = None; - cc->state = state; - XChangeProperty(X_Dpy, cc->win, + XChangeProperty(X_Dpy, win, cwmh[WM_STATE].atom, cwmh[WM_STATE].atom, 32, PropModeReplace, (unsigned char *)dat, 2); }