summaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2013-09-18 21:50:57 +0800
committerRichard Grenville <[email protected]>2013-09-18 22:41:40 +0800
commit2b534cd86445fcd770948bbb79f4732361259ab9 (patch)
tree38cbed58124b2e713d426bb60df9d078c355571c /common.h
parent6e82deb05b7e8d4c183d33c5a4acb978cf465b46 (diff)
downloadtdebase-2b534cd86445fcd770948bbb79f4732361259ab9.tar.gz
tdebase-2b534cd86445fcd770948bbb79f4732361259ab9.zip
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.
Diffstat (limited to 'common.h')
-rw-r--r--common.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/common.h b/common.h
index ea95235ae..eadaafd95 100644
--- a/common.h
+++ b/common.h
@@ -954,8 +954,6 @@ typedef struct _win {
bool focused;
/// Override value of window focus state. Set by D-Bus method calls.
switch_t focused_force;
- /// Whether the window is actually focused.
- bool focused_real;
// Blacklist related members
/// Name of the window.
@@ -1696,25 +1694,29 @@ find_toplevel(session_t *ps, Window id) {
}
/**
+ * Check if a window is really focused.
+ */
+static inline bool
+win_is_focused_real(session_t *ps, const win *w) {
+ return IsViewable == w->a.map_state && ps->active_win == w;
+}
+
+/**
* Find out the currently focused window.
*
* @return struct _win object of the found window, NULL if not found
*/
static inline win *
find_focused(session_t *ps) {
- if (!ps->o.track_focus)
- return NULL;
-
- for (win *w = ps->list; w; w = w->next) {
- if (w->focused_real && !w->destroyed)
- return w;
- }
+ if (!ps->o.track_focus) return NULL;
+ if (ps->active_win && win_is_focused_real(ps, ps->active_win))
+ return ps->active_win;
return NULL;
}
/**
- * Copies a region
+ * Copies a region.
*/
static inline XserverRegion
copy_region(const session_t *ps, XserverRegion oldregion) {