Focus correct window after minimizing via the tasklist (fixes #128200; see

2004-09-15  Elijah Newren  <newren@math.utah.edu>

	Focus correct window after minimizing via the tasklist (fixes
	#128200; see also #107681)

	* src/display.h (struct _MetaDisplay): track the
	previously_focused_window

	* src/display.c (meta_display_open): initialize
	previously_focused_window

	* src/window.c (meta_window_free): clear the
	previously_focused_window if it's being freed,
	(meta_window_client_message): if we get a request to minimize the
	previously_focused_window and the focus_window is a dock or the
	desktop, focus the default window, (meta_window_notify_focus):
	update the previously_focused_window
This commit is contained in:
Elijah Newren 2004-09-15 15:38:09 +00:00 committed by Elijah Newren
parent c188ae0954
commit 4b9fe2cae7
4 changed files with 50 additions and 1 deletions

View File

@ -1,3 +1,21 @@
2004-09-15 Elijah Newren <newren@math.utah.edu>
Focus correct window after minimizing via the tasklist (fixes
#128200; see also #107681)
* src/display.h (struct _MetaDisplay): track the
previously_focused_window
* src/display.c (meta_display_open): initialize
previously_focused_window
* src/window.c (meta_window_free): clear the
previously_focused_window if it's being freed,
(meta_window_client_message): if we get a request to minimize the
previously_focused_window and the focus_window is a dock or the
desktop, focus the default window, (meta_window_notify_focus):
update the previously_focused_window
2004-09-13 Rob Adams <readams@readams.net> 2004-09-13 Rob Adams <readams@readams.net>
* configure.in: post-release increment * configure.in: post-release increment

View File

@ -329,6 +329,7 @@ meta_display_open (const char *name)
display->pending_pings = NULL; display->pending_pings = NULL;
display->autoraise_timeout_id = 0; display->autoraise_timeout_id = 0;
display->focus_window = NULL; display->focus_window = NULL;
display->previously_focused_window = NULL;
display->expected_focus_window = NULL; display->expected_focus_window = NULL;
#ifdef HAVE_XSYNC #ifdef HAVE_XSYNC

View File

@ -188,6 +188,10 @@ struct _MetaDisplay
*/ */
MetaWindow *focus_window; MetaWindow *focus_window;
/* Window that was the actual window from focus events before focus_window
*/
MetaWindow *previously_focused_window;
/* window we are expecting a FocusIn event for /* window we are expecting a FocusIn event for
*/ */
MetaWindow *expected_focus_window; MetaWindow *expected_focus_window;

View File

@ -967,6 +967,8 @@ meta_window_free (MetaWindow *window)
if (window->display->focus_window == window) if (window->display->focus_window == window)
window->display->focus_window = NULL; window->display->focus_window = NULL;
if (window->display->previously_focused_window == window)
window->display->previously_focused_window = NULL;
meta_window_unqueue_calc_showing (window); meta_window_unqueue_calc_showing (window);
meta_window_unqueue_move_resize (window); meta_window_unqueue_move_resize (window);
@ -4022,8 +4024,30 @@ meta_window_client_message (MetaWindow *window,
event->xclient.data.l[0]); event->xclient.data.l[0]);
if (event->xclient.data.l[0] == IconicState && if (event->xclient.data.l[0] == IconicState &&
window->has_minimize_func) window->has_minimize_func)
{
meta_window_minimize (window); meta_window_minimize (window);
/* If the window being minimized was the one with focus,
* then we should focus a new window. We often receive this
* wm_change_state message when a user has clicked on the
* tasklist on the panel; in those cases, the current
* focus_window is the panel, but the previous focus_window
* will have been this one. This is a special case where we
* need to manually handle focusing a new window because
* meta_window_minimize will get it wrong.
*/
if (window->display->focus_window &&
(window->display->focus_window->type == META_WINDOW_DOCK ||
window->display->focus_window->type == META_WINDOW_DESKTOP) &&
window->display->previously_focused_window == window)
{
meta_topic (META_DEBUG_FOCUS,
"Focusing default window because of minimization of former focus window %s, which was due to a wm_change_state client message\n",
window->desc);
meta_workspace_focus_default_window (window->screen->active_workspace, window);
}
}
return TRUE; return TRUE;
} }
else if (event->xclient.message_type == else if (event->xclient.message_type ==
@ -4397,6 +4421,8 @@ meta_window_notify_focus (MetaWindow *window,
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"* Focus --> NULL (was %s)\n", window->desc); "* Focus --> NULL (was %s)\n", window->desc);
window->display->previously_focused_window =
window->display->focus_window;
window->display->focus_window = NULL; window->display->focus_window = NULL;
window->has_focus = FALSE; window->has_focus = FALSE;
if (window->frame) if (window->frame)