X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=796153b47edfa3db573b016ad62abfcf9b179884;hb=3ce4ba02b4120821833b08ca9f7829c6b723c3e4;hp=947da08f770314094afa5a8d60054dd5aabe2099;hpb=a658878aea0a8ed61e2f6bd253338d15f425124e;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 947da08..796153b 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -241,8 +241,7 @@ struct search_window { Window indicator; }; TAILQ_HEAD(search_winlist, search_window); - -struct search_winlist search_wl; +struct search_winlist search_wl; /* search actions */ enum { @@ -476,7 +475,6 @@ struct swm_screen { GC bar_gc; }; struct swm_screen *screens; -int num_screens; /* args to functions */ union arg { @@ -608,11 +606,11 @@ get_property(Window id, Atom atom, long count, Atom type, unsigned long *nitems, &real, &format, nitems_ret, nbytes_ret, data); if (status != Success) - return False; + return (False); if (real != type) - return False; + return (False); - return True; + return (True); } void @@ -680,7 +678,7 @@ setup_ewmh(void) for (j = 0; j < LENGTH(ewmh); j++) XChangeProperty(display, screens[i].root, sup_list, XA_ATOM, 32, - PropModeAppend, (unsigned char *)&ewmh[j].atom,1); + PropModeAppend, (unsigned char *)&ewmh[j].atom, 1); } } @@ -763,10 +761,10 @@ ewmh_set_win_fullscreen(struct ws_win *win, int fs) struct swm_geometry rg; if (!win->ws->r) - return 0; + return (0); if (!win->floating) - return 0; + return (0); DNPRINTF(SWM_D_MISC, "ewmh_set_win_fullscreen: window: 0x%lx, " "fullscreen %s\n", win->id, YESNO(fs)); @@ -787,7 +785,7 @@ ewmh_set_win_fullscreen(struct ws_win *win, int fs) } } - return 1; + return (1); } void @@ -1028,7 +1026,7 @@ geteventname(XEvent *e) name = "Unknown"; } - return name; + return (name); } char * @@ -1044,7 +1042,7 @@ xrandr_geteventname(XEvent *e) name = "Unknown"; } - return name; + return (name); } void @@ -1355,32 +1353,24 @@ void bar_class_name(char *s, ssize_t sz, struct ws_win *cur_focus) { int do_class, do_name; - Status status; - XClassHint *xch = NULL; + XClassHint *ch; - if ((title_name_enabled == 1 || title_class_enabled == 1) && - cur_focus != NULL) { - if ((xch = XAllocClassHint()) == NULL) - goto out; - status = XGetClassHint(display, cur_focus->id, xch); - if (status == BadWindow || status == BadAlloc) - goto out; - do_class = (title_class_enabled && xch->res_class != NULL); - do_name = (title_name_enabled && xch->res_name != NULL); - if (do_class) - strlcat(s, xch->res_class, sz); - if (do_class && do_name) - strlcat(s, ":", sz); - if (do_name) - strlcat(s, xch->res_name, sz); - strlcat(s, " ", sz); - } -out: - if (xch) { - XFree(xch->res_name); - XFree(xch->res_class); - XFree(xch); - } + if (title_name_enabled == 0 && title_class_enabled == 0) + return; + if (cur_focus == NULL) + return; + + ch = &cur_focus->ch; + do_class = (title_class_enabled && ch->res_class != NULL); + do_name = (title_name_enabled && ch->res_name != NULL); + + if (do_class) + strlcat(s, ch->res_class, sz); + if (do_class && do_name) + strlcat(s, ":", sz); + if (do_name) + strlcat(s, ch->res_name, sz); + strlcat(s, " ", sz); } void @@ -2168,7 +2158,7 @@ unfocus_win(struct ws_win *win) XChangeProperty(display, win->s->root, ewmh[_NET_ACTIVE_WINDOW].atom, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)&none,1); + PropModeReplace, (unsigned char *)&none, 1); } void @@ -2244,7 +2234,7 @@ focus_win(struct ws_win *win) XChangeProperty(display, win->s->root, ewmh[_NET_ACTIVE_WINDOW].atom, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)&win->id,1); + PropModeReplace, (unsigned char *)&win->id, 1); } bar_check_opts(); @@ -2485,7 +2475,6 @@ swapwin(struct swm_region *r, union arg *args) if (target == source) { if (source->ws->focus_prev != NULL && source->ws->focus_prev != target) - source = source->ws->focus_prev; else return; @@ -3777,16 +3766,16 @@ floating_toggle_win(struct ws_win *win) struct swm_region *r; if (win == NULL) - return 0; + return (0); if (!win->ws->r) - return 0; + return (0); r = win->ws->r; /* reject floating toggles in max stack mode */ if (win->ws->cur_layout == &layouts[SWM_MAX_STACK]) - return 0; + return (0); if (win->floating) { if (!win->floatmaxed) { @@ -3807,7 +3796,7 @@ floating_toggle_win(struct ws_win *win) ewmh_update_actions(win); - return 1; + return (1); } void @@ -6310,9 +6299,8 @@ configurerequest(XEvent *e) wc.sibling = ev->above; wc.stack_mode = ev->detail; XConfigureWindow(display, ev->window, ev->value_mask, &wc); - } else { + } else config_win(win, ev); - } } void @@ -7088,9 +7076,9 @@ workaround(void) screens[i].c[SWM_S_COLOR_UNFOCUS].color); XChangeProperty(display, root, netwmcheck, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)&win,1); + PropModeReplace, (unsigned char *)&win, 1); XChangeProperty(display, win, netwmcheck, XA_WINDOW, 32, - PropModeReplace, (unsigned char *)&win,1); + PropModeReplace, (unsigned char *)&win, 1); XChangeProperty(display, win, netwmname, utf8_string, 8, PropModeReplace, (unsigned char*)"LG3D", strlen("LG3D")); }