Bug fix #99: Rewrite focus detection logic

- Rewrite focus detection logic. Remove w->focused_real and use
  ps->active_win to identify focused window uniformly. Use a more
  expensive way to filter FocusIn/Out events to improve reliability.
  Only limited tests are done, and bugs are likely to be introduced.
  (#99)

- Known issue: Under fvwm, compton sometimes does not consistently
  report the window input gets sent to. But there's something wrong in
  that case: XGetInputFocus() shows the root window is focused but
  another window is receiving input.
This commit is contained in:
Richard Grenville
2013-09-18 21:50:57 +08:00
parent a6b76e954f
commit 4bd3db2bc7
5 changed files with 107 additions and 103 deletions

View File

@ -563,6 +563,20 @@ clear_cache_win_leaders(session_t *ps) {
static win *
find_toplevel2(session_t *ps, Window wid);
/**
* Find matched window.
*/
static inline win *
find_win_all(session_t *ps, const Window wid) {
if (!wid || PointerRoot == wid || wid == ps->root || wid == ps->overlay)
return NULL;
win *w = find_win(ps, wid);
if (!w) w = find_toplevel(ps, wid);
if (!w) w = find_toplevel2(ps, wid);
return w;
}
static Window
win_get_leader_raw(session_t *ps, win *w, int recursions);
@ -589,7 +603,7 @@ group_is_focused(session_t *ps, Window leader) {
for (win *w = ps->list; w; w = w->next) {
if (win_get_leader(ps, w) == leader && !w->destroyed
&& w->focused_real)
&& win_is_focused_real(ps, w))
return true;
}
@ -764,6 +778,9 @@ group_update_focused(session_t *ps, Window leader) {
static inline void
win_set_focused(session_t *ps, win *w, bool focused);
static void
win_on_focus_change(session_t *ps, win *w);
static void
win_determine_fade(session_t *ps, win *w);