diff options
author | Elijah Newren <newren@gmail.com> | 2005-02-20 17:14:16 +0000 |
---|---|---|
committer | Elijah Newren <newren@src.gnome.org> | 2005-02-20 17:14:16 +0000 |
commit | 50312dd0e89daf704fb2849dc25bd332aa07eebe (patch) | |
tree | 6b2777ab317be177736bb7242a2ec7c9d1d10a5d /src/display.h | |
parent | 11508ce27e83f2f890f15045bf7617bb4671af70 (diff) | |
download | metacity-50312dd0e89daf704fb2849dc25bd332aa07eebe.tar.gz |
Big patch to cover about 6 different issues in order to correct rare
2005-02-20 Elijah Newren <newren@gmail.com>
Big patch to cover about 6 different issues in order to correct
rare problems with timestamps (make sure window selected in
tasklist actually gets focus, sanity check timestamps to avoid
rogue apps hosing the system, correct the updating of
net_wm_user_time, correctly handle timestamps of 0 when comparing
xserver timestamps for those who have had their systems up for
over 25 days or so, add some debugging information to verbose
logs, some code cleanups). Fixes all issues listed in #167358.
* src/display.h: (struct _MetaDisplay): clarify comment on
last_focus_time, introduce a new variable--last_user_time,
(XSERVER_TIME_IS_BEFORE macro): put this functionality into a
separate macro and then introduce a new macro with this name that
uses the old one but adds additional special-case checks for
timestamps that are 0, (comment to
meta_display_set_input_focus_window): add information about how
last_user_time should be used in this function
* src/display.c (santiy_check_timestamps): new function,
(meta_display_open): intialize display->last_user_time,
(meta_display_get_current_time_roundtrip): use the timestamp,
which is known to be good, in order to sanity_check_timestamps,
(event_callback): use the new meta_window_ste_user_time() function
in order to correct problems, use the timestamp of KeyPress and
ButtonPress events, which are known to be good, in order to
sanity_check_timestamps, (timestamp_too_old): new function for
common behavior of meta_display_focus_the_no_focus_window and
meta_display_set_input_focus_window, with added checking for
display->last_user_time in addition to display->last_focus_time,
(meta_display_set_input_focus_window): replace some of the code
with a call to timestamp_too_old(),
(meta_display_focus_the_no_focus_window): replace some of th ecode
with a call to timestamp_too_old()
* src/window.h: (meta_window_set_user_time): new function to
abstract the many things that need to be done when updating the
net_wm_user_time of any window
* src/window.c: (meta_window_activate): add debugging spew, make
sure the comparison is made with last_user_time NOT
last_focus_time, use meta_window_set_user_time() function in order
to correct problems, (meta_window_client_message): add a newline
to a debugging message to make them easier to read,
(meta_window_set_user_time): new function
* src/window-props.c (reload_net_wm_user_time): use the new
meta_window_ste_user_time() function in order to correct problems
Diffstat (limited to 'src/display.h')
-rw-r--r-- | src/display.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/display.h b/src/display.h index 07070342..df309efb 100644 --- a/src/display.h +++ b/src/display.h @@ -198,9 +198,12 @@ struct _MetaDisplay */ MetaWindow *expected_focus_window; - /* last timestamp that a window was focused */ + /* last timestamp passed to XSetInputFocus */ Time last_focus_time; + /* last user interaction time in any app */ + Time last_user_time; + guint static_gravity_works : 1; /*< private-ish >*/ @@ -361,11 +364,21 @@ struct _MetaDisplay * has occurred, this is equivalent to * time1 < time2 * Of course, the rest of the ugliness of this macro comes from accounting - * for the fact that wraparound can occur. + * for the fact that wraparound can occur and the fact that a timestamp of + * 0 must be special-cased since it means older than anything else. + * + * Note that this is NOT an equivalent for time1 <= time2; if that's what + * you need then you'll need to swap the order of the arguments and negate + * the result. */ -#define XSERVER_TIME_IS_BEFORE(time1, time2) \ - ( (( time1 < time2 ) && ( time2 - time1 < ((guint32)-1)/2 )) || \ - (( time1 > time2 ) && ( time1 - time2 > ((guint32)-1)/2 )) \ +#define XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) \ + ( (( time1 < time2 ) && ( time2 - time1 < ((guint32)-1)/2 )) || \ + (( time1 > time2 ) && ( time1 - time2 > ((guint32)-1)/2 )) \ + ) +#define XSERVER_TIME_IS_BEFORE(time1, time2) \ + ( time1 == 0 || \ + (XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) && \ + time2 != 0) \ ) gboolean meta_display_open (const char *name); @@ -507,9 +520,11 @@ gboolean meta_display_focus_sentinel_clear (MetaDisplay *display); /* meta_display_set_input_focus_window is like XSetInputFocus, except * that (a) it can't detect timestamps later than the current time, * since Metacity isn't part of the XServer, and thus gives erroneous - * behavior in this circumstance (so don't do it), and (b) it uses - * display->last_focus_time and display->expected_focus_window since - * we don't have access to the true Xserver ones. + * behavior in this circumstance (so don't do it), (b) it uses + * display->last_focus_time since we don't have access to the true + * Xserver one, (c) it makes use of display->user_time since checking + * whether a window should be allowed to be focused should depend + * on user_time events (see bug 167358, comment 15 in particular) */ void meta_display_set_input_focus_window (MetaDisplay *display, MetaWindow *window, |