mirror of
https://github.com/brl/mutter.git
synced 2025-08-05 16:14:51 +00:00
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
This commit is contained in:

committed by
Elijah Newren

parent
11508ce27e
commit
50312dd0e8
46
src/window.c
46
src/window.c
@@ -2206,15 +2206,20 @@ void
|
||||
meta_window_activate (MetaWindow *window,
|
||||
guint32 timestamp)
|
||||
{
|
||||
meta_topic (META_DEBUG_FOCUS,
|
||||
"_NET_ACTIVE_WINDOW message sent for %s at time %lu.\n",
|
||||
window->desc, (unsigned long)timestamp);
|
||||
|
||||
/* Older EWMH spec didn't specify a timestamp, so it can be 0 and we
|
||||
* have to treat that as a new request.
|
||||
*/
|
||||
if (XSERVER_TIME_IS_BEFORE (timestamp, window->display->last_focus_time) &&
|
||||
if (XSERVER_TIME_IS_BEFORE (timestamp, window->display->last_user_time) &&
|
||||
timestamp != 0)
|
||||
{
|
||||
meta_topic (META_DEBUG_FOCUS,
|
||||
"_NET_ACTIVE_WINDOW message sent but with a timestamp that"
|
||||
"requests the window not be active, so we're ignoring it.\n");
|
||||
"last_user_time (%lu) is more recent; ignoring "
|
||||
" _NET_ACTIVE_WINDOW message.\n",
|
||||
window->display->last_user_time);
|
||||
window->wm_state_demands_attention = TRUE;
|
||||
set_net_wm_state (window);
|
||||
return;
|
||||
@@ -2223,7 +2228,7 @@ meta_window_activate (MetaWindow *window,
|
||||
if (timestamp == 0)
|
||||
timestamp = meta_display_get_current_time_roundtrip (window->display);
|
||||
|
||||
window->net_wm_user_time = timestamp;
|
||||
meta_window_set_user_time (window, timestamp);
|
||||
|
||||
/* disable show desktop mode unless we're a desktop component */
|
||||
maybe_leave_show_desktop_mode (window);
|
||||
@@ -4305,7 +4310,7 @@ meta_window_client_message (MetaWindow *window,
|
||||
else if (event->xclient.message_type ==
|
||||
display->atom_net_active_window)
|
||||
{
|
||||
meta_verbose ("_NET_ACTIVE_WINDOW request for window '%s', activating",
|
||||
meta_verbose ("_NET_ACTIVE_WINDOW request for window '%s', activating\n",
|
||||
window->desc);
|
||||
|
||||
if (event->xclient.data.l[0] != 0)
|
||||
@@ -7378,3 +7383,34 @@ meta_window_stack_just_below (MetaWindow *window,
|
||||
window->desc, below_this_one->desc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_set_user_time (MetaWindow *window,
|
||||
Time timestamp)
|
||||
{
|
||||
/* FIXME: If Soeren's suggestion in bug 151984 is implemented, it will allow
|
||||
* us to sanity check the timestamp here and ensure it doesn't correspond to
|
||||
* a future time.
|
||||
*/
|
||||
|
||||
/* Only update the time if this timestamp is newer... */
|
||||
if (window->net_wm_user_time_set &&
|
||||
XSERVER_TIME_IS_BEFORE (timestamp, window->net_wm_user_time))
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Window %s _NET_WM_USER_TIME not updated to %lu, because it "
|
||||
"is less than %lu\n",
|
||||
window->desc, timestamp, window->net_wm_user_time);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_topic (META_DEBUG_STARTUP,
|
||||
"Window %s has _NET_WM_USER_TIME of %lu\n",
|
||||
window->desc, timestamp);
|
||||
window->net_wm_user_time_set = TRUE;
|
||||
window->net_wm_user_time = timestamp;
|
||||
if (XSERVER_TIME_IS_BEFORE (window->display->last_user_time, timestamp))
|
||||
window->display->last_user_time = timestamp;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user