X-Git-Url: https://code.delx.au/spectrwm/blobdiff_plain/638428ac079bad32d3e9150f90450bc71397135c..e39267765c9ccde3dee0f79de9cce8c7655223a7:/spectrwm.c diff --git a/spectrwm.c b/spectrwm.c index 478a6f2..41e20cf 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -402,6 +402,7 @@ bool stack_enabled = true; bool clock_enabled = true; bool iconic_enabled = false; bool urgent_enabled = false; +bool urgent_collapse = false; char *clock_format = NULL; bool window_class_enabled = false; bool window_instance_enabled = false; @@ -1040,6 +1041,7 @@ char *get_source_type_label(uint32_t); char *get_stack_mode_name(uint8_t); #endif int32_t get_swm_ws(xcb_window_t); +bool get_urgent(struct ws_win *); char *get_win_name(xcb_window_t); uint8_t get_win_state(xcb_window_t); void get_wm_protocols(struct ws_win *); @@ -2167,6 +2169,22 @@ bar_window_name(char *s, size_t sz, struct swm_region *r) free(title); } +bool +get_urgent(struct ws_win *win) +{ + xcb_icccm_wm_hints_t hints; + xcb_get_property_cookie_t c; + bool urgent = false; + + if (win) { + c = xcb_icccm_get_wm_hints(conn, win->id); + if (xcb_icccm_get_wm_hints_reply(conn, c, &hints, NULL)) + urgent = xcb_icccm_wm_hints_get_urgency(&hints); + } + + return urgent; +} + void bar_urgent(char *s, size_t sz) { @@ -2174,8 +2192,6 @@ bar_urgent(char *s, size_t sz) int i, j, num_screens; bool urgent[SWM_WS_MAX]; char b[8]; - xcb_get_property_cookie_t c; - xcb_icccm_wm_hints_t hints; for (i = 0; i < workspace_limit; i++) urgent[i] = false; @@ -2183,21 +2199,16 @@ bar_urgent(char *s, size_t sz) num_screens = get_screen_count(); for (i = 0; i < num_screens; i++) for (j = 0; j < workspace_limit; j++) - TAILQ_FOREACH(win, &screens[i].ws[j].winlist, entry) { - c = xcb_icccm_get_wm_hints(conn, win->id); - if (xcb_icccm_get_wm_hints_reply(conn, c, - &hints, NULL) == 0) - continue; - if (hints.flags & XCB_ICCCM_WM_HINT_X_URGENCY) - urgent[j] = true; - } + TAILQ_FOREACH(win, &screens[i].ws[j].winlist, entry) + urgent[j] = get_urgent(win); for (i = 0; i < workspace_limit; i++) { - if (urgent[i]) + if (urgent[i]) { snprintf(b, sizeof b, "%d ", i + 1); - else - snprintf(b, sizeof b, "- "); - strlcat(s, b, sz); + strlcat(s, b, sz); + } else if (!urgent_collapse) { + strlcat(s, "- ", sz); + } } } @@ -3218,6 +3229,9 @@ center_pointer(struct swm_region *r) return; win = r->ws->focus; + + DNPRINTF(SWM_D_EVENT, "center_pointer: win %#x.\n", WINID(win)); + if (win && win->mapped) xcb_warp_pointer(conn, XCB_NONE, win->id, 0, 0, 0, 0, WIDTH(win) / 2, HEIGHT(win) / 2); @@ -4111,6 +4125,7 @@ swapwin(struct swm_region *r, union arg *args) ewmh_update_client_list(); stack(); + center_pointer(r); focus_flush(); out: DNPRINTF(SWM_D_MOVE, "swapwin: done\n"); @@ -4264,7 +4279,6 @@ focus(struct swm_region *r, union arg *args) struct workspace *ws = NULL; union arg a; int i; - xcb_icccm_wm_hints_t hints; if (!(r && r->ws)) goto out; @@ -4337,27 +4351,26 @@ focus(struct swm_region *r, union arg *args) head = TAILQ_FIRST(&r->s->ws[(ws->idx + i) % workspace_limit].winlist); - while (head != NULL && - (head = TAILQ_NEXT(head, entry)) != NULL) { + while (head) { if (head == cur_focus) { - winfocus = cur_focus; - break; - } - if (xcb_icccm_get_wm_hints_reply(conn, - xcb_icccm_get_wm_hints(conn, head->id), - &hints, NULL) != 0 && - xcb_icccm_wm_hints_get_urgency(&hints)) { + if (i > 0) { + winfocus = cur_focus; + break; + } + } else if (get_urgent(head)) { winfocus = head; break; } + + head = TAILQ_NEXT(head, entry); } - if (winfocus != NULL) + if (winfocus) break; } /* Switch ws if new focus is on a different ws. */ - if (winfocus != NULL && winfocus->ws != ws) { + if (winfocus && winfocus->ws != ws) { a.id = winfocus->ws->idx; switchws(r, &a); } @@ -4398,6 +4411,7 @@ cycle_layout(struct swm_region *r, union arg *args) focus_win(get_region_focus(r)); + center_pointer(r); focus_flush(); } @@ -4419,6 +4433,7 @@ stack_config(struct swm_region *r, union arg *args) stack(); bar_draw(); + center_pointer(r); focus_flush(); } @@ -4782,7 +4797,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, bool flip) win_g.y += last_h + 2 * border_width + tile_gap; if (disable_border && !(bar_enabled && ws->bar_enabled) && - winno == 1){ + winno == 1) { bordered = false; win_g.w += 2 * border_width; win_g.h += 2 * border_width; @@ -4995,12 +5010,13 @@ max_stack(struct workspace *ws, struct swm_geometry *g) if (X(w) != gg.x || Y(w) != gg.y || WIDTH(w) != gg.w || HEIGHT(w) != gg.h) { w->g = gg; - if (bar_enabled && ws->bar_enabled){ - w->bordered = true; - } else { + + if (disable_border && !(bar_enabled && ws->bar_enabled)) { w->bordered = false; WIDTH(w) += 2 * border_width; HEIGHT(w) += 2 * border_width; + } else { + w->bordered = true; } update_window(w); @@ -5946,6 +5962,7 @@ maximize_toggle(struct swm_region *r, union arg *args) if (w == w->ws->focus) focus_win(w); + center_pointer(r); focus_flush(); DNPRINTF(SWM_D_MISC, "maximize_toggle: done\n"); } @@ -6326,6 +6343,7 @@ resize_step(struct swm_region *r, union arg *args) return; resize(win, args); + center_pointer(r); focus_flush(); } @@ -6525,6 +6543,7 @@ move_step(struct swm_region *r, union arg *args) return; move(win, args); + center_pointer(r); focus_flush(); } @@ -7906,6 +7925,7 @@ enum { SWM_S_STACK_ENABLED, SWM_S_TERM_WIDTH, SWM_S_TILE_GAP, + SWM_S_URGENT_COLLAPSE, SWM_S_URGENT_ENABLED, SWM_S_VERBOSE_LAYOUT, SWM_S_WARP_POINTER, @@ -8108,6 +8128,9 @@ setconfvalue(const char *selector, const char *value, int flags) case SWM_S_TILE_GAP: tile_gap = atoi(value); break; + case SWM_S_URGENT_COLLAPSE: + urgent_collapse = (atoi(value) != 0); + break; case SWM_S_URGENT_ENABLED: urgent_enabled = (atoi(value) != 0); break; @@ -8454,6 +8477,7 @@ struct config_option configopt[] = { { "tile_gap", setconfvalue, SWM_S_TILE_GAP }, { "title_class_enabled", setconfvalue, SWM_S_WINDOW_CLASS_ENABLED }, /* For backwards compat. */ { "title_name_enabled", setconfvalue, SWM_S_WINDOW_INSTANCE_ENABLED }, /* For backwards compat. */ + { "urgent_collapse", setconfvalue, SWM_S_URGENT_COLLAPSE }, { "urgent_enabled", setconfvalue, SWM_S_URGENT_ENABLED }, { "verbose_layout", setconfvalue, SWM_S_VERBOSE_LAYOUT }, { "warp_pointer", setconfvalue, SWM_S_WARP_POINTER },