diff --git a/src/win.c b/src/win.c index 8b2b2e0..004f513 100644 --- a/src/win.c +++ b/src/win.c @@ -68,6 +68,54 @@ static inline void clear_cache_win_leaders(session_t *ps) { } } +static xcb_window_t win_get_leader_raw(session_t *ps, struct managed_win *w, int recursions); + +/** + * Get the leader of a window. + * + * This function updates w->cache_leader if necessary. + */ +static inline xcb_window_t win_get_leader(session_t *ps, struct managed_win *w) { + return win_get_leader_raw(ps, w, 0); +} + +/** + * Update focused state of a window. + */ +static void win_update_focused(session_t *ps, struct managed_win *w) { + if (UNSET != w->focused_force) { + w->focused = w->focused_force; + } else { + w->focused = win_is_focused_real(ps, w); + + // Use wintype_focus, and treat WM windows and override-redirected + // windows specially + if (ps->o.wintype_option[w->window_type].focus || + (ps->o.mark_wmwin_focused && w->wmwin) || + (ps->o.mark_ovredir_focused && w->base.id == w->client_win && !w->wmwin) || + (w->a.map_state == XCB_MAP_STATE_VIEWABLE && + c2_match(ps, w, ps->o.focus_blacklist, NULL))) + w->focused = true; + + // If window grouping detection is enabled, mark the window active if + // its group is + if (ps->o.track_leader && ps->active_leader && + win_get_leader(ps, w) == ps->active_leader) { + w->focused = true; + } + } + + // Always recalculate the window target opacity, since some opacity-related + // options depend on the output value of win_is_focused_real() instead of + // w->focused + auto opacity_target_old = w->opacity_target; + w->opacity_target = win_calc_opacity_target(ps, w, false); + if (opacity_target_old != w->opacity_target && w->state == WSTATE_MAPPED) { + // Only MAPPED can transition to FADING + w->state = WSTATE_FADING; + } +} + /** * Run win_update_focused() on all windows with the same leader window. * @@ -91,6 +139,14 @@ static inline void group_update_focused(session_t *ps, xcb_window_t leader) { return; } +static inline const char *win_get_name_if_managed(const struct win *w) { + if (!w->managed) { + return "(unmanaged)"; + } + auto mw = (struct managed_win *)w; + return mw->name; +} + /** * Return whether a window group is really focused. * @@ -142,8 +198,6 @@ void win_get_region_noframe_local(const struct managed_win *w, region_t *res) { } } -gen_by_val(win_get_region_noframe_local); - void win_get_region_frame_local(const struct managed_win *w, region_t *res) { const margin_t extents = win_calc_frame_extents(w); pixman_region32_fini(res); @@ -548,20 +602,7 @@ void win_update_prop_shadow_raw(session_t *ps, struct managed_win *w) { free_winprop(&prop); } -/** - * Reread _COMPTON_SHADOW property from a window and update related - * things. - */ -void win_update_prop_shadow(session_t *ps, struct managed_win *w) { - long attr_shadow_old = w->prop_shadow; - - win_update_prop_shadow_raw(ps, w); - - if (w->prop_shadow != attr_shadow_old) - win_determine_shadow(ps, w); -} - -void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new) { +static void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new) { if (w->shadow == shadow_new) { return; } @@ -609,7 +650,7 @@ void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new) { * Determine if a window should have shadow, and update things depending * on shadow state. */ -void win_determine_shadow(session_t *ps, struct managed_win *w) { +static void win_determine_shadow(session_t *ps, struct managed_win *w) { log_debug("Determining shadow of window %#010x (%s)", w->base.id, w->name); bool shadow_new = w->shadow; @@ -636,7 +677,20 @@ void win_determine_shadow(session_t *ps, struct managed_win *w) { win_set_shadow(ps, w, shadow_new); } -void win_set_invert_color(session_t *ps, struct managed_win *w, bool invert_color_new) { +/** + * Reread _COMPTON_SHADOW property from a window and update related + * things. + */ +void win_update_prop_shadow(session_t *ps, struct managed_win *w) { + long attr_shadow_old = w->prop_shadow; + + win_update_prop_shadow_raw(ps, w); + + if (w->prop_shadow != attr_shadow_old) + win_determine_shadow(ps, w); +} + +static void win_set_invert_color(session_t *ps, struct managed_win *w, bool invert_color_new) { if (w->invert_color == invert_color_new) return; @@ -645,6 +699,20 @@ void win_set_invert_color(session_t *ps, struct managed_win *w, bool invert_colo add_damage_from_win(ps, w); } +/** + * Determine if a window should have color inverted. + */ +static void win_determine_invert_color(session_t *ps, struct managed_win *w) { + bool invert_color_new = w->invert_color; + + if (UNSET != w->invert_color_force) + invert_color_new = w->invert_color_force; + else if (w->a.map_state == XCB_MAP_STATE_VIEWABLE) + invert_color_new = c2_match(ps, w, ps->o.invert_color_list, NULL); + + win_set_invert_color(ps, w, invert_color_new); +} + /** * Set w->invert_color_force of a window. */ @@ -687,20 +755,6 @@ void win_set_shadow_force(session_t *ps, struct managed_win *w, switch_t val) { } } -/** - * Determine if a window should have color inverted. - */ -void win_determine_invert_color(session_t *ps, struct managed_win *w) { - bool invert_color_new = w->invert_color; - - if (UNSET != w->invert_color_force) - invert_color_new = w->invert_color_force; - else if (w->a.map_state == XCB_MAP_STATE_VIEWABLE) - invert_color_new = c2_match(ps, w, ps->o.invert_color_list, NULL); - - win_set_invert_color(ps, w, invert_color_new); -} - static void win_set_blur_background(session_t *ps, struct managed_win *w, bool blur_background_new) { if (w->blur_background == blur_background_new) @@ -716,7 +770,7 @@ win_set_blur_background(session_t *ps, struct managed_win *w, bool blur_backgrou /** * Determine if a window should have background blurred. */ -void win_determine_blur_background(session_t *ps, struct managed_win *w) { +static void win_determine_blur_background(session_t *ps, struct managed_win *w) { if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) return; @@ -749,7 +803,7 @@ void win_update_opacity_rule(session_t *ps, struct managed_win *w) { /** * Function to be called on window type changes. */ -void win_on_wtype_change(session_t *ps, struct managed_win *w) { +static void win_on_wtype_change(session_t *ps, struct managed_win *w) { win_determine_shadow(ps, w); win_update_focused(ps, w); if (ps->o.invert_color_list) @@ -909,7 +963,7 @@ void win_unmark_client(session_t *ps, struct managed_win *w) { * @param ps current session * @param w struct _win of the parent window */ -void win_recheck_client(session_t *ps, struct managed_win *w) { +static void win_recheck_client(session_t *ps, struct managed_win *w) { // Initialize wmwin to false w->wmwin = false; @@ -1169,43 +1223,6 @@ struct win *fill_win(session_t *ps, struct win *w) { return &new->base; } -/** - * Update focused state of a window. - */ -void win_update_focused(session_t *ps, struct managed_win *w) { - if (UNSET != w->focused_force) { - w->focused = w->focused_force; - } else { - w->focused = win_is_focused_real(ps, w); - - // Use wintype_focus, and treat WM windows and override-redirected - // windows specially - if (ps->o.wintype_option[w->window_type].focus || - (ps->o.mark_wmwin_focused && w->wmwin) || - (ps->o.mark_ovredir_focused && w->base.id == w->client_win && !w->wmwin) || - (w->a.map_state == XCB_MAP_STATE_VIEWABLE && - c2_match(ps, w, ps->o.focus_blacklist, NULL))) - w->focused = true; - - // If window grouping detection is enabled, mark the window active if - // its group is - if (ps->o.track_leader && ps->active_leader && - win_get_leader(ps, w) == ps->active_leader) { - w->focused = true; - } - } - - // Always recalculate the window target opacity, since some opacity-related - // options depend on the output value of win_is_focused_real() instead of - // w->focused - auto opacity_target_old = w->opacity_target; - w->opacity_target = win_calc_opacity_target(ps, w, false); - if (opacity_target_old != w->opacity_target && w->state == WSTATE_MAPPED) { - // Only MAPPED can transition to FADING - w->state = WSTATE_FADING; - } -} - /** * Set leader of a window. */ @@ -1261,7 +1278,7 @@ void win_update_leader(session_t *ps, struct managed_win *w) { /** * Internal function of win_get_leader(). */ -xcb_window_t win_get_leader_raw(session_t *ps, struct managed_win *w, int recursions) { +static xcb_window_t win_get_leader_raw(session_t *ps, struct managed_win *w, int recursions) { // Rebuild the cache if needed if (!w->cache_leader && (w->client_win || w->leader)) { // Leader defaults to client window diff --git a/src/win.h b/src/win.h index bdb06ce..4f8ca00 100644 --- a/src/win.h +++ b/src/win.h @@ -14,7 +14,6 @@ #include #endif -#include "win_defs.h" #include "c2.h" #include "compiler.h" #include "list.h" @@ -22,6 +21,7 @@ #include "render.h" #include "types.h" #include "utils.h" +#include "win_defs.h" #include "x.h" struct backend_base; @@ -271,12 +271,6 @@ void win_set_focused(session_t *ps, struct managed_win *w); bool attr_pure win_should_fade(session_t *ps, const struct managed_win *w); void win_update_prop_shadow_raw(session_t *ps, struct managed_win *w); void win_update_prop_shadow(session_t *ps, struct managed_win *w); -void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new); -void win_determine_shadow(session_t *ps, struct managed_win *w); -void win_set_invert_color(session_t *ps, struct managed_win *w, bool invert_color_new); -void win_determine_invert_color(session_t *ps, struct managed_win *w); -void win_determine_blur_background(session_t *ps, struct managed_win *w); -void win_on_wtype_change(session_t *ps, struct managed_win *w); void win_on_factor_change(session_t *ps, struct managed_win *w); /** * Update cache data in struct _win that depends on window size. @@ -285,8 +279,6 @@ void win_on_win_size_change(session_t *ps, struct managed_win *w); void win_update_wintype(session_t *ps, struct managed_win *w); void win_mark_client(session_t *ps, struct managed_win *w, xcb_window_t client); void win_unmark_client(session_t *ps, struct managed_win *w); -void win_recheck_client(session_t *ps, struct managed_win *w); -xcb_window_t win_get_leader_raw(session_t *ps, struct managed_win *w, int recursions); bool win_get_class(session_t *ps, struct managed_win *w); /** @@ -307,8 +299,6 @@ double attr_pure win_calc_opacity_target(session_t *ps, const struct managed_win bool ignore_state); bool attr_pure win_should_dim(session_t *ps, const struct managed_win *w); void win_update_screen(session_t *, struct managed_win *); -/// Prepare window for fading because opacity target changed -void win_start_fade(session_t *, struct managed_win **); /** * Reread opacity property of a window. */ @@ -317,10 +307,6 @@ void win_update_opacity_prop(session_t *ps, struct managed_win *w); * Update leader of a window. */ void win_update_leader(session_t *ps, struct managed_win *w); -/** - * Update focused state of a window. - */ -void win_update_focused(session_t *ps, struct managed_win *w); /** * Retrieve the bounding shape of a window. */ @@ -348,7 +334,6 @@ void add_damage_from_win(session_t *ps, const struct managed_win *w); * Return region in global coordinates. */ void win_get_region_noframe_local(const struct managed_win *w, region_t *); -region_t win_get_region_noframe_local_by_val(const struct managed_win *w); /// Get the region for the frame of the window void win_get_region_frame_local(const struct managed_win *w, region_t *res); @@ -417,14 +402,6 @@ bool attr_pure win_is_fullscreen(const session_t *ps, const struct managed_win * * Check if a window is really focused. */ bool attr_pure win_is_focused_real(const session_t *ps, const struct managed_win *w); -/** - * Get the leader of a window. - * - * This function updates w->cache_leader if necessary. - */ -static inline xcb_window_t win_get_leader(session_t *ps, struct managed_win *w) { - return win_get_leader_raw(ps, w, 0); -} /// check if window has ARGB visual bool attr_pure win_has_alpha(const struct managed_win *w); @@ -467,11 +444,3 @@ static inline bool attr_pure win_has_frame(const struct managed_win *w) { return w->g.border_width || w->frame_extents.top || w->frame_extents.left || w->frame_extents.right || w->frame_extents.bottom; } - -static inline const char *win_get_name_if_managed(const struct win *w) { - if (!w->managed) { - return "(unmanaged)"; - } - auto mw = (struct managed_win *)w; - return mw->name; -}