From 7a598e55678de1dcfabfeb325abd1541bdc8c47a Mon Sep 17 00:00:00 2001 From: Craig Black Date: Thu, 8 Aug 2002 04:45:13 +0000 Subject: [PATCH] clear expected focus window on open 2002-08-07 Craig Black * src/display.c: (meta_display_open): clear expected focus window on open * src/display.h: add expected_focus_window field * src/window.c: (meta_window_make_fullscreen), (meta_window_unmake_fullscreen): change meta_window_update_layer() to meta_stack_update_layer() so build works again. (meta_window_free), (meta_window_make_fullscreen), (meta_window_focus), (meta_window_notify_focus): keep track of expected focus window after sending WM_TAKE_FOCUS event, previously if a UnmapNotify event arrived before the FocusIn event we would lose focus, fixes #84564. --- ChangeLog | 16 ++++++++++++++++ src/display.c | 1 + src/display.h | 5 +++++ src/window.c | 16 ++++++++++++++-- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31a86dfe7..956d2ae9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2002-08-07 Craig Black + + * src/display.c: (meta_display_open): clear expected focus window + on open + + * src/display.h: add expected_focus_window field + + * src/window.c: (meta_window_make_fullscreen), + (meta_window_unmake_fullscreen): change meta_window_update_layer() + to meta_stack_update_layer() so build works again. + (meta_window_free), (meta_window_make_fullscreen), + (meta_window_focus), (meta_window_notify_focus): keep track of + expected focus window after sending WM_TAKE_FOCUS event, + previously if a UnmapNotify event arrived before the FocusIn event + we would lose focus, fixes #84564. + 2002-08-07 Havoc Pennington * src/window.c (meta_window_unmake_fullscreen): update layer diff --git a/src/display.c b/src/display.c index 78ade79ca..ec68bb5d3 100644 --- a/src/display.c +++ b/src/display.c @@ -288,6 +288,7 @@ meta_display_open (const char *name) display->pending_pings = NULL; display->autoraise_timeout_id = 0; display->focus_window = NULL; + display->expected_focus_window = NULL; display->mru_list = NULL; display->showing_desktop = FALSE; diff --git a/src/display.h b/src/display.h index a16bc5bc3..c48292fde 100644 --- a/src/display.h +++ b/src/display.h @@ -153,6 +153,11 @@ struct _MetaDisplay */ MetaWindow *focus_window; + /* WM_TAKE_FOCUS has been sent but we have not yet + * received the resulting FocusIn event for this window + */ + MetaWindow *expected_focus_window; + /* Most recently focused list. Always contains all * live windows. */ diff --git a/src/window.c b/src/window.c index cc5123405..f1145179d 100644 --- a/src/window.c +++ b/src/window.c @@ -812,6 +812,14 @@ meta_window_free (MetaWindow *window) window->desc); meta_screen_focus_top_window (window->screen, window); } + else if (window->display->expected_focus_window == window) + { + meta_topic (META_DEBUG_FOCUS, + "Focusing top window since expected focus window freed %s\n", + window->desc); + window->display->expected_focus_window = NULL; + meta_screen_focus_top_window (window->screen, window); + } else { meta_topic (META_DEBUG_FOCUS, @@ -1632,7 +1640,7 @@ meta_window_make_fullscreen (MetaWindow *window) window->fullscreen = TRUE; - meta_window_update_layer (window); + meta_stack_update_layer (window->screen->stack, window); meta_window_raise (window); /* save size/pos as appropriate args for move_resize */ @@ -1661,7 +1669,7 @@ meta_window_unmake_fullscreen (MetaWindow *window) window->fullscreen = FALSE; - meta_window_update_layer (window); + meta_stack_update_layer (window->screen->stack, window); meta_window_move_resize (window, TRUE, @@ -2798,6 +2806,7 @@ meta_window_focus (MetaWindow *window, meta_window_send_icccm_message (window, window->display->atom_wm_take_focus, timestamp); + window->display->expected_focus_window = window; } meta_error_trap_pop (window->display); @@ -3580,6 +3589,9 @@ meta_window_notify_focus (MetaWindow *window, if (event->type == FocusIn) { + if (window->display->expected_focus_window == window) + window->display->expected_focus_window = NULL; + if (window != window->display->focus_window) { meta_topic (META_DEBUG_FOCUS,