win: clarify what win_is_focused_real means

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-03-17 19:19:13 +00:00
parent fb3305fb9b
commit d2e323c985
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
4 changed files with 17 additions and 18 deletions

View File

@ -1328,7 +1328,7 @@ static inline void c2_match_once_leaf(session_t *ps, const struct managed_win *w
case C2_L_PFULLSCREEN: tgt = win_is_fullscreen(ps, w); break; case C2_L_PFULLSCREEN: tgt = win_is_fullscreen(ps, w); break;
case C2_L_POVREDIR: tgt = w->a.override_redirect; break; case C2_L_POVREDIR: tgt = w->a.override_redirect; break;
case C2_L_PARGB: tgt = win_has_alpha(w); break; case C2_L_PARGB: tgt = win_has_alpha(w); break;
case C2_L_PFOCUSED: tgt = win_is_focused_real(ps, w); break; case C2_L_PFOCUSED: tgt = win_is_focused_raw(ps, w); break;
case C2_L_PWMWIN: tgt = w->wmwin; break; case C2_L_PWMWIN: tgt = w->wmwin; break;
case C2_L_PBSHAPED: tgt = w->bounding_shaped; break; case C2_L_PBSHAPED: tgt = w->bounding_shaped; break;
case C2_L_PROUNDED: tgt = w->rounded_corners; break; case C2_L_PROUNDED: tgt = w->rounded_corners; break;

View File

@ -785,9 +785,8 @@ static bool cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
cdbus_m_win_get_do(window_type, cdbus_reply_enum); cdbus_m_win_get_do(window_type, cdbus_reply_enum);
cdbus_m_win_get_do(wmwin, cdbus_reply_bool); cdbus_m_win_get_do(wmwin, cdbus_reply_bool);
cdbus_m_win_get_do(leader, cdbus_reply_wid); cdbus_m_win_get_do(leader, cdbus_reply_wid);
// focused_real if (!strcmp("focused_raw", target)) {
if (!strcmp("focused_real", target)) { cdbus_reply_bool(ps, msg, win_is_focused_raw(ps, w));
cdbus_reply_bool(ps, msg, win_is_focused_real(ps, w));
return true; return true;
} }
cdbus_m_win_get_do(fade_force, cdbus_reply_enum); cdbus_m_win_get_do(fade_force, cdbus_reply_enum);

View File

@ -94,7 +94,7 @@ static void win_update_focused(session_t *ps, struct managed_win *w) {
if (UNSET != w->focused_force) { if (UNSET != w->focused_force) {
w->focused = w->focused_force; w->focused = w->focused_force;
} else { } else {
w->focused = win_is_focused_real(ps, w); w->focused = win_is_focused_raw(ps, w);
// Use wintype_focus, and treat WM windows and override-redirected // Use wintype_focus, and treat WM windows and override-redirected
// windows specially // windows specially
@ -114,7 +114,7 @@ static void win_update_focused(session_t *ps, struct managed_win *w) {
} }
// Always recalculate the window target opacity, since some opacity-related // Always recalculate the window target opacity, since some opacity-related
// options depend on the output value of win_is_focused_real() instead of // options depend on the output value of win_is_focused_raw() instead of
// w->focused // w->focused
auto opacity_target_old = w->opacity_target; auto opacity_target_old = w->opacity_target;
w->opacity_target = win_calc_opacity_target(ps, w, false); w->opacity_target = win_calc_opacity_target(ps, w, false);
@ -175,7 +175,7 @@ static inline bool group_is_focused(session_t *ps, xcb_window_t leader) {
continue; continue;
} }
auto mw = (struct managed_win *)w; auto mw = (struct managed_win *)w;
if (win_get_leader(ps, mw) == leader && win_is_focused_real(ps, mw)) { if (win_get_leader(ps, mw) == leader && win_is_focused_raw(ps, mw)) {
return true; return true;
} }
} }
@ -618,7 +618,7 @@ double win_calc_opacity_target(session_t *ps, const struct managed_win *w, bool
opacity = ps->o.wintype_option[w->window_type].opacity; opacity = ps->o.wintype_option[w->window_type].opacity;
} else { } else {
// Respect active_opacity only when the window is physically focused // Respect active_opacity only when the window is physically focused
if (win_is_focused_real(ps, w)) if (win_is_focused_raw(ps, w))
opacity = ps->o.active_opacity; opacity = ps->o.active_opacity;
else if (!w->focused) else if (!w->focused)
// Respect inactive_opacity in some cases // Respect inactive_opacity in some cases
@ -1351,7 +1351,7 @@ static inline void win_set_leader(session_t *ps, struct managed_win *w, xcb_wind
// Update the old and new window group and active_leader if the window // Update the old and new window group and active_leader if the window
// could affect their state. // could affect their state.
xcb_window_t cache_leader = win_get_leader(ps, w); xcb_window_t cache_leader = win_get_leader(ps, w);
if (win_is_focused_real(ps, w) && cache_leader_old != cache_leader) { if (win_is_focused_raw(ps, w) && cache_leader_old != cache_leader) {
ps->active_leader = cache_leader; ps->active_leader = cache_leader;
group_update_focused(ps, cache_leader_old); group_update_focused(ps, cache_leader_old);
@ -1458,7 +1458,7 @@ static void win_on_focus_change(session_t *ps, struct managed_win *w) {
xcb_window_t leader = win_get_leader(ps, w); xcb_window_t leader = win_get_leader(ps, w);
// If the window gets focused, replace the old active_leader // If the window gets focused, replace the old active_leader
if (win_is_focused_real(ps, w) && leader != ps->active_leader) { if (win_is_focused_raw(ps, w) && leader != ps->active_leader) {
xcb_window_t active_leader_old = ps->active_leader; xcb_window_t active_leader_old = ps->active_leader;
ps->active_leader = leader; ps->active_leader = leader;
@ -1467,7 +1467,7 @@ static void win_on_focus_change(session_t *ps, struct managed_win *w) {
group_update_focused(ps, leader); group_update_focused(ps, leader);
} }
// If the group get unfocused, remove it from active_leader // If the group get unfocused, remove it from active_leader
else if (!win_is_focused_real(ps, w) && leader && else if (!win_is_focused_raw(ps, w) && leader &&
leader == ps->active_leader && !group_is_focused(ps, leader)) { leader == ps->active_leader && !group_is_focused(ps, leader)) {
ps->active_leader = XCB_NONE; ps->active_leader = XCB_NONE;
group_update_focused(ps, leader); group_update_focused(ps, leader);
@ -1487,7 +1487,7 @@ static void win_on_focus_change(session_t *ps, struct managed_win *w) {
#ifdef CONFIG_DBUS #ifdef CONFIG_DBUS
// Send D-Bus signal // Send D-Bus signal
if (ps->o.dbus) { if (ps->o.dbus) {
if (win_is_focused_real(ps, w)) if (win_is_focused_raw(ps, w))
cdbus_ev_win_focusin(ps, &w->base); cdbus_ev_win_focusin(ps, &w->base);
else else
cdbus_ev_win_focusout(ps, &w->base); cdbus_ev_win_focusout(ps, &w->base);
@ -1504,13 +1504,13 @@ void win_set_focused(session_t *ps, struct managed_win *w) {
return; return;
} }
if (win_is_focused_real(ps, w)) { if (win_is_focused_raw(ps, w)) {
return; return;
} }
auto old_active_win = ps->active_win; auto old_active_win = ps->active_win;
ps->active_win = w; ps->active_win = w;
assert(win_is_focused_real(ps, w)); assert(win_is_focused_raw(ps, w));
if (old_active_win) { if (old_active_win) {
win_on_focus_change(ps, old_active_win); win_on_focus_change(ps, old_active_win);
@ -2343,9 +2343,9 @@ bool win_is_bypassing_compositor(const session_t *ps, const struct managed_win *
} }
/** /**
* Check if a window is really focused. * Check if a window is focused, without using any focus rules or forced focus settings
*/ */
bool win_is_focused_real(const session_t *ps, const struct managed_win *w) { bool win_is_focused_raw(const session_t *ps, const struct managed_win *w) {
return w->a.map_state == XCB_MAP_STATE_VIEWABLE && ps->active_win == w; return w->a.map_state == XCB_MAP_STATE_VIEWABLE && ps->active_win == w;
} }

View File

@ -418,9 +418,9 @@ struct managed_win *find_toplevel2(session_t *ps, xcb_window_t wid);
bool attr_pure win_is_fullscreen(const session_t *ps, const struct managed_win *w); bool attr_pure win_is_fullscreen(const session_t *ps, const struct managed_win *w);
/** /**
* Check if a window is really focused. * Check if a window is focused, without using any focus rules or forced focus settings
*/ */
bool attr_pure win_is_focused_real(const session_t *ps, const struct managed_win *w); bool attr_pure win_is_focused_raw(const session_t *ps, const struct managed_win *w);
/// check if window has ARGB visual /// check if window has ARGB visual
bool attr_pure win_has_alpha(const struct managed_win *w); bool attr_pure win_has_alpha(const struct managed_win *w);