X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;fp=spectrwm.c;h=dbcd5f6a14aa0ee9b5288eab889df503657c9bfc;hb=refs%2Fheads%2Fjason;hp=41e20cf787090f8e08289586f63b6bd8cf593bc7;hpb=e39267765c9ccde3dee0f79de9cce8c7655223a7;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 41e20cf..dbcd5f6 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -368,7 +368,7 @@ enum { /* dialog windows */ double dialog_ratio = 0.6; /* status bar */ -#define SWM_BAR_MAX (256) +#define SWM_BAR_MAX (356) #define SWM_BAR_JUSTIFY_LEFT (0) #define SWM_BAR_JUSTIFY_CENTER (1) #define SWM_BAR_JUSTIFY_RIGHT (2) @@ -402,6 +402,9 @@ bool stack_enabled = true; bool clock_enabled = true; bool iconic_enabled = false; bool urgent_enabled = false; +int composite_enabled = 0; +double opacity_focus = 1.0; +double opacity_unfocus = 0.6; bool urgent_collapse = false; char *clock_format = NULL; bool window_class_enabled = false; @@ -519,7 +522,7 @@ struct layout { } layouts[] = { /* stack, configure */ { vertical_stack, vertical_config, 0, plain_stacker }, - { horizontal_stack, horizontal_config, 0, plain_stacker }, +// { horizontal_stack, horizontal_config, 0, plain_stacker }, { max_stack, NULL, SWM_L_MAPONFOCUS | SWM_L_FOCUSPREV, plain_stacker }, { NULL, NULL, 0, NULL }, @@ -528,7 +531,7 @@ struct layout { /* position of max_stack mode in the layouts array, index into layouts! */ #define SWM_V_STACK (0) #define SWM_H_STACK (1) -#define SWM_MAX_STACK (2) +#define SWM_MAX_STACK (1) #define SWM_H_SLICE (32) #define SWM_V_SLICE (32) @@ -713,6 +716,7 @@ enum { _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_SKIP_PAGER, _NET_WM_STATE_SKIP_TASKBAR, + _NET_WM_WINDOW_OPACITY, _NET_WM_WINDOW_TYPE, _NET_WM_WINDOW_TYPE_DIALOG, _NET_WM_WINDOW_TYPE_DOCK, @@ -756,6 +760,7 @@ struct ewmh_hint { {"_NET_WM_STATE_MAXIMIZED_HORZ", XCB_ATOM_NONE}, {"_NET_WM_STATE_SKIP_PAGER", XCB_ATOM_NONE}, {"_NET_WM_STATE_SKIP_TASKBAR", XCB_ATOM_NONE}, + {"_NET_WM_WINDOW_OPACITY", XCB_ATOM_NONE}, {"_NET_WM_WINDOW_TYPE", XCB_ATOM_NONE}, {"_NET_WM_WINDOW_TYPE_DIALOG", XCB_ATOM_NONE}, {"_NET_WM_WINDOW_TYPE_DOCK", XCB_ATOM_NONE}, @@ -1134,6 +1139,7 @@ void setup_quirks(void); void setup_screens(void); void setup_spawn(void); void set_child_transient(struct ws_win *, xcb_window_t *); +void set_opacity(struct ws_win *, uint32_t); void set_win_state(struct ws_win *, uint8_t); void shutdown_cleanup(void); void sighdlr(int); @@ -3470,6 +3476,19 @@ validate_ws(struct workspace *testws) return (1); } +#define OPAQUE 0xffffffff +void +set_opacity(struct ws_win *win, uint32_t opacity) +{ + if (opacity != OPAQUE) + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win->id, + ewmh[_NET_WM_WINDOW_OPACITY].atom, XCB_ATOM_CARDINAL, 32, 1, + &opacity); + else + xcb_delete_property(conn, win->id, + ewmh[_NET_WM_WINDOW_OPACITY].atom); +} + void unfocus_win(struct ws_win *win) { @@ -3557,6 +3576,10 @@ focus_win(struct ws_win *win) &cfw->s->c[(MAXIMIZED(cfw) ? SWM_S_COLOR_UNFOCUS_MAXIMIZED : SWM_S_COLOR_UNFOCUS)].pixel); + + if (composite_enabled) + set_opacity(cfw, + opacity_unfocus * OPAQUE); } else { unfocus_win(cfw); } @@ -4339,7 +4362,7 @@ focus(struct swm_region *r, union arg *args) winfocus = TAILQ_FIRST(wl); if (winfocus == cur_focus) - winfocus = cur_focus->ws->focus_prev; + return; break; case SWM_ARG_ID_FOCUSURGENT: /* Search forward for the next urgent window. */ @@ -6091,15 +6114,22 @@ update_window_color(struct ws_win *win) { uint32_t *pixel; - if (WS_FOCUSED(win->ws) && win->ws->focus == win) + if (WS_FOCUSED(win->ws) && win->ws->focus == win) { pixel = MAXIMIZED(win) ? &win->s->c[SWM_S_COLOR_FOCUS_MAXIMIZED].pixel : &win->s->c[SWM_S_COLOR_FOCUS].pixel; - else + + if (composite_enabled) + set_opacity(win, opacity_focus * OPAQUE); + } else { pixel = MAXIMIZED(win) ? &win->s->c[SWM_S_COLOR_UNFOCUS_MAXIMIZED].pixel : &win->s->c[SWM_S_COLOR_UNFOCUS].pixel; + if (composite_enabled) + set_opacity(win, opacity_unfocus * OPAQUE); + } + xcb_change_window_attributes(conn, win->id, XCB_CW_BORDER_PIXEL, pixel); } @@ -7907,6 +7937,7 @@ enum { SWM_S_BOUNDARY_WIDTH, SWM_S_CLOCK_ENABLED, SWM_S_CLOCK_FORMAT, + SWM_S_COMPOSITE_ENABLED, SWM_S_CYCLE_EMPTY, SWM_S_CYCLE_VISIBLE, SWM_S_DIALOG_RATIO, @@ -7917,6 +7948,8 @@ enum { SWM_S_FOCUS_MODE, SWM_S_ICONIC_ENABLED, SWM_S_JAVA_WORKAROUND, + SWM_S_OPACITY_FOCUS, + SWM_S_OPACITY_UNFOCUS, SWM_S_REGION_PADDING, SWM_S_SPAWN_ORDER, SWM_S_SPAWN_TERM, @@ -8134,6 +8167,23 @@ setconfvalue(const char *selector, const char *value, int flags) case SWM_S_URGENT_ENABLED: urgent_enabled = (atoi(value) != 0); break; + case SWM_S_COMPOSITE_ENABLED: + composite_enabled = atoi(value); + break; + case SWM_S_OPACITY_FOCUS: + opacity_focus = atof(value); + if (opacity_focus > 1.0) + opacity_focus = 1.0; + else if (opacity_focus < 0.0) + opacity_focus = 0.0; + break; + case SWM_S_OPACITY_UNFOCUS: + opacity_unfocus = atof(value); + if (opacity_unfocus > 1.0) + opacity_unfocus = 1.0; + else if (opacity_unfocus < 0.0) + opacity_unfocus = 0.0; + break; case SWM_S_VERBOSE_LAYOUT: verbose_layout = (atoi(value) != 0); for (i = 0; layouts[i].l_stack != NULL; i++) { @@ -8451,6 +8501,7 @@ struct config_option configopt[] = { { "color_focus_maximized", setconfcolor, SWM_S_COLOR_FOCUS_MAXIMIZED }, { "color_unfocus", setconfcolor, SWM_S_COLOR_UNFOCUS }, { "color_unfocus_maximized", setconfcolor, SWM_S_COLOR_UNFOCUS_MAXIMIZED }, + { "composite_enabled", setconfvalue, SWM_S_COMPOSITE_ENABLED }, { "cycle_empty", setconfvalue, SWM_S_CYCLE_EMPTY }, { "cycle_visible", setconfvalue, SWM_S_CYCLE_VISIBLE }, { "dialog_ratio", setconfvalue, SWM_S_DIALOG_RATIO }, @@ -8464,6 +8515,8 @@ struct config_option configopt[] = { { "keyboard_mapping", setkeymapping, 0 }, { "layout", setlayout, 0 }, { "modkey", setconfmodkey, 0 }, + { "opacity_focus", setconfvalue, SWM_S_OPACITY_FOCUS }, + { "opacity_unfocus", setconfvalue, SWM_S_OPACITY_UNFOCUS }, { "program", setconfspawn, 0 }, { "quirk", setconfquirk, 0 }, { "region", setconfregion, 0 }, @@ -8864,6 +8917,9 @@ manage_window(xcb_window_t id, int spawn_pos, bool mapped) xcb_change_window_attributes(conn, win->id, XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK, wa); + if (composite_enabled) + set_opacity(win, opacity_unfocus * OPAQUE); + /* Get WM_SIZE_HINTS. */ xcb_icccm_get_wm_normal_hints_reply(conn, xcb_icccm_get_wm_normal_hints(conn, win->id),