X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=ea332558d2f6bb357413a0404e47c88424108f84;hb=78cac56aec5d7d3d4743ffed76556525f53df6c8;hp=822d1f5d3d5feca94a448866b817914f99452956;hpb=f52df6cff180069d25ae18b0ee926bbf6e890e9c;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 822d1f5..ea33255 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -5,7 +5,7 @@ * Copyright (c) 2009 Pierre-Yves Ritschard * Copyright (c) 2010 Tuukka Kataja * Copyright (c) 2011 Jason L. Wright - * Copyright (c) 2011-2013 Reginald Kennedy + * Copyright (c) 2011-2014 Reginald Kennedy * Copyright (c) 2011-2012 Lawrence Teo * Copyright (c) 2011-2012 Tiago Cunha * Copyright (c) 2012-2013 David Hill @@ -669,6 +669,7 @@ struct quirk { #define SWM_Q_FOCUSPREV (1<<5) /* focus on caller */ #define SWM_Q_NOFOCUSONMAP (1<<6) /* Don't focus on window when mapped. */ #define SWM_Q_FOCUSONMAP_SINGLE (1<<7) /* Only focus if single win of type. */ +#define SWM_Q_OBEYAPPFOCUSREQ (1<<8) /* Focus when applications ask. */ }; TAILQ_HEAD(quirk_list, quirk); struct quirk_list quirks = TAILQ_HEAD_INITIALIZER(quirks); @@ -1028,6 +1029,7 @@ int get_region_index(struct swm_region *); xcb_screen_t *get_screen(int); int get_screen_count(void); #ifdef SWM_DEBUG +char *get_source_type_label(uint32_t); char *get_stack_mode_name(uint8_t); #endif int32_t get_swm_ws(xcb_window_t); @@ -1900,24 +1902,13 @@ name_to_pixel(int sidx, const char *colorname) void setscreencolor(const char *val, int i, int c) { - int num_screens; + if (i < 0 || i >= get_screen_count()) + return; - num_screens = get_screen_count(); - if (i > 0 && i <= num_screens) { - screens[i - 1].c[c].pixel = name_to_pixel(i - 1, val); - free(screens[i - 1].c[c].name); - if ((screens[i - 1].c[c].name = strdup(val)) == NULL) - err(1, "strdup"); - } else if (i == -1) { - for (i = 0; i < num_screens; i++) { - screens[i].c[c].pixel = name_to_pixel(0, val); - free(screens[i].c[c].name); - if ((screens[i].c[c].name = strdup(val)) == NULL) - err(1, "strdup"); - } - } else - errx(1, "invalid screen index: %d out of bounds (maximum %d)", - i, num_screens); + screens[i].c[c].pixel = name_to_pixel(i, val); + free(screens[i].c[c].name); + if ((screens[i].c[c].name = strdup(val)) == NULL) + err(1, "strdup"); } void @@ -3593,13 +3584,15 @@ focus_win(struct ws_win *win) set_region(ws->r); - update_window_color(win); - xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win->s->root, ewmh[_NET_ACTIVE_WINDOW].atom, XCB_ATOM_WINDOW, 32, 1, &win->id); } + if (cfw != win) + /* Update window border even if workspace is hidden. */ + update_window_color(win); + out: bar_draw(); @@ -4493,6 +4486,8 @@ update_floater(struct ws_win *win) DNPRINTF(SWM_D_MISC, "update_floater: win %#x\n", win->id); + win->bordered = 1; + if (FULLSCREEN(win)) { /* _NET_WM_FULLSCREEN: fullscreen without border. */ if (!win->g_floatvalid) @@ -4508,14 +4503,11 @@ update_floater(struct ws_win *win) win->g = r->g; if (bar_enabled && ws->bar_enabled) { - win->bordered = 1; if (!bar_at_bottom) Y(win) += bar_height; HEIGHT(win) -= bar_height; } else if (disable_border) { win->bordered = 0; - } else { - win->bordered = 1; } if (win->bordered) { @@ -5047,10 +5039,14 @@ send_to_ws(struct swm_region *r, union arg *args) win_to_ws(win, wsid, 1); - /* Set window to be focus on target ws. */ + /* Set new focus on target ws. */ if (focus_mode != SWM_FOCUS_FOLLOW) { + win->ws->focus_prev = win->ws->focus; win->ws->focus = win; win->ws->focus_pending = NULL; + + if (win->ws->focus_prev) + update_window_color(win->ws->focus_prev); } DNPRINTF(SWM_D_STACK, "send_to_ws: focus_pending: %#x, focus: %#x, " @@ -5062,7 +5058,7 @@ send_to_ws(struct swm_region *r, union arg *args) ewmh_apply_flags(win, win->ewmh_flags & ~EWMH_F_MAXIMIZED); ewmh_update_wm_state(win); - /* Restack and set new focus. */ + /* Restack and set new focus on current ws. */ if (FLOATING(win)) load_float_geom(win); @@ -7519,6 +7515,7 @@ const char *quirkname[] = { "FOCUSPREV", "NOFOCUSONMAP", "FOCUSONMAP_SINGLE", + "OBEYAPPFOCUSREQ", }; /* SWM_Q_WS: retain '|' for back compat for now (2009-08-11) */ @@ -8102,34 +8099,40 @@ setconfmodkey(const char *selector, const char *value, int flags) int setconfcolor(const char *selector, const char *value, int flags) { - int sid, i, num_screens; + int first, last, i = 0, num_screens; - sid = (selector == NULL || strlen(selector) == 0) ? -1 : atoi(selector); + num_screens = get_screen_count(); - /* - * When setting focus/unfocus colors, we need to also - * set maximize colors to match if they haven't been customized. - */ - i = sid < 0 ? 0 : sid; - if (flags == SWM_S_COLOR_FOCUS && - !screens[i].c[SWM_S_COLOR_FOCUS_MAXIMIZED].manual) - setscreencolor(value, sid, SWM_S_COLOR_FOCUS_MAXIMIZED); - else if (flags == SWM_S_COLOR_UNFOCUS && - !screens[i].c[SWM_S_COLOR_UNFOCUS_MAXIMIZED].manual) - setscreencolor(value, sid, SWM_S_COLOR_UNFOCUS_MAXIMIZED); + /* conf screen indices begin at 1; treat vals <= 0 as 'all screens.' */ + if (selector == NULL || strlen(selector) == 0 || + (last = atoi(selector) - 1) < 0) { + first = 0; + last = num_screens - 1; + } else { + first = last; + } + + if (last >= num_screens) { + add_startup_exception("invalid screen index: %d out of bounds " + "(maximum %d)", last + 1, num_screens); + return (1); + } - setscreencolor(value, sid, flags); + for (i = first; i <= last; ++i) { + setscreencolor(value, i, flags); + + /* + * When setting focus/unfocus colors, we need to also + * set maximize colors to match if they haven't been customized. + */ + if (flags == SWM_S_COLOR_FOCUS && + !screens[i].c[SWM_S_COLOR_FOCUS_MAXIMIZED].manual) + setscreencolor(value, i, SWM_S_COLOR_FOCUS_MAXIMIZED); + else if (flags == SWM_S_COLOR_UNFOCUS && + !screens[i].c[SWM_S_COLOR_UNFOCUS_MAXIMIZED].manual) + setscreencolor(value, i, SWM_S_COLOR_UNFOCUS_MAXIMIZED); - /* Track override of color. */ - num_screens = get_screen_count(); - if (sid > 0 && sid <= num_screens) { screens[i].c[flags].manual = 1; - } else if (sid == -1) { - for (i = 0; i < num_screens; ++i) - screens[i].c[flags].manual = 1; - } else { - errx(1, "invalid screen index: %d out of bounds (maximum %d)", - sid, num_screens); } return (0); @@ -9823,7 +9826,8 @@ clientmessage(xcb_client_message_event_t *e) * Allow focus changes that are a result of direct user * action and from applications that use the old EWMH spec. */ - if (e->data.data32[0] != EWMH_SOURCE_TYPE_NORMAL) { + if (e->data.data32[0] != EWMH_SOURCE_TYPE_NORMAL || + win->quirks & SWM_Q_OBEYAPPFOCUSREQ) { if (WS_FOCUSED(win->ws)) focus_win(win); else @@ -10371,15 +10375,16 @@ setup_screens(void) screens[i].root = screen->root; /* set default colors */ - setscreencolor("red", i + 1, SWM_S_COLOR_FOCUS); - setscreencolor("rgb:88/88/88", i + 1, SWM_S_COLOR_UNFOCUS); - setscreencolor("rgb:00/80/80", i + 1, SWM_S_COLOR_BAR_BORDER); - setscreencolor("rgb:00/40/40", i + 1, + setscreencolor("red", i, SWM_S_COLOR_FOCUS); + setscreencolor("rgb:88/88/88", i, SWM_S_COLOR_UNFOCUS); + setscreencolor("rgb:00/80/80", i, SWM_S_COLOR_BAR_BORDER); + setscreencolor("rgb:00/40/40", i, SWM_S_COLOR_BAR_BORDER_UNFOCUS); - setscreencolor("black", i + 1, SWM_S_COLOR_BAR); - setscreencolor("rgb:a0/a0/a0", i + 1, SWM_S_COLOR_BAR_FONT); - setscreencolor("red", i + 1, SWM_S_COLOR_FOCUS_MAXIMIZED); - setscreencolor("rgb:88/88/88", i + 1, SWM_S_COLOR_UNFOCUS_MAXIMIZED); + setscreencolor("black", i, SWM_S_COLOR_BAR); + setscreencolor("rgb:a0/a0/a0", i, SWM_S_COLOR_BAR_FONT); + setscreencolor("red", i, SWM_S_COLOR_FOCUS_MAXIMIZED); + setscreencolor("rgb:88/88/88", i, + SWM_S_COLOR_UNFOCUS_MAXIMIZED); /* create graphics context on screen */ screens[i].bar_gc = xcb_generate_id(conn);