Focus parents of dismissed transient windows in preference to the window

2005-02-02  Elijah Newren  <newren@gmail.com>

	Focus parents of dismissed transient windows in preference to the
	window that most recently had keyboard focus.  Fixes #157360.

	* doc/how-to-get-focus-right.txt: Note the distinction between
	"most recently used window" and "most recent to have keyboard
	focus" that we are now making.

	* src/workspace.c: (focus_ancestor_or_mru_window): rename from
	meta_workspace_focus_mru_window, and first check whether we need
	to focus an ancestor window before looking for the mru window,
	(record_ancestor): helper function for
	focus_ancestor_or_mru_window,
	(meta_workspace_focus_default_window): update due to the function
	rename from meta_workspace_focus_mru_window to
	focus_ancestor_or_mru_window
This commit is contained in:
Elijah Newren 2005-02-02 18:46:09 +00:00 committed by Elijah Newren
parent 03adcdac31
commit de5588c10e
3 changed files with 77 additions and 13 deletions

View File

@ -1,3 +1,21 @@
2005-02-02 Elijah Newren <newren@gmail.com>
Focus parents of dismissed transient windows in preference to the
window that most recently had keyboard focus. Fixes #157360.
* doc/how-to-get-focus-right.txt: Note the distinction between
"most recently used window" and "most recent to have keyboard
focus" that we are now making.
* src/workspace.c: (focus_ancestor_or_mru_window): rename from
meta_workspace_focus_mru_window, and first check whether we need
to focus an ancestor window before looking for the mru window,
(record_ancestor): helper function for
focus_ancestor_or_mru_window,
(meta_workspace_focus_default_window): update due to the function
rename from meta_workspace_focus_mru_window to
focus_ancestor_or_mru_window
2005-01-31 Elijah Newren <newren@gmail.com> 2005-01-31 Elijah Newren <newren@gmail.com>
Try 2 to correct misleading and inaccurate wording. Hopefully, Try 2 to correct misleading and inaccurate wording. Hopefully,

View File

@ -37,6 +37,14 @@ Focus method Behavior
mouse Focus the window containing the pointer if there is one, mouse Focus the window containing the pointer if there is one,
otherwise focus the designated "no_focus_window". otherwise focus the designated "no_focus_window".
Note that "most recently used window", as used here, has a slightly
different connotation than "most recent to have keyboard focus". This
is because when a user activates a window that is a transient, its
ancestor(s) should be considered to be more recently used than other
windows that have had the keyboard focus more recently. (See bug
157360; this may mean that the alt-tab order should also change
simultaneously, although the current implementation does not do that.)
Also, sometimes a new window will be mapped (e.g. unminimizing a Also, sometimes a new window will be mapped (e.g. unminimizing a
window or launching a new application). Most users want to interact window or launching a new application). Most users want to interact
with new windows right away, so these should typically be focused. with new windows right away, so these should typically be focused.

View File

@ -29,7 +29,7 @@
void meta_workspace_queue_calc_showing (MetaWorkspace *workspace); void meta_workspace_queue_calc_showing (MetaWorkspace *workspace);
static void set_active_space_hint (MetaScreen *screen); static void set_active_space_hint (MetaScreen *screen);
static void meta_workspace_focus_mru_window (MetaWorkspace *workspace, static void focus_ancestor_or_mru_window (MetaWorkspace *workspace,
MetaWindow *not_this_one, MetaWindow *not_this_one,
Time timestamp); Time timestamp);
@ -801,7 +801,7 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK) if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK)
meta_workspace_focus_mru_window (workspace, not_this_one, timestamp); focus_ancestor_or_mru_window (workspace, not_this_one, timestamp);
else else
{ {
MetaWindow * window; MetaWindow * window;
@ -838,7 +838,7 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
} }
} }
else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_SLOPPY) else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_SLOPPY)
meta_workspace_focus_mru_window (workspace, not_this_one, timestamp); focus_ancestor_or_mru_window (workspace, not_this_one, timestamp);
else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_MOUSE) else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_MOUSE)
{ {
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
@ -850,9 +850,21 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace,
} }
} }
/* Focus MRU window (or top window if failed) on active workspace */ static gboolean
void record_ancestor (MetaWindow *window,
meta_workspace_focus_mru_window (MetaWorkspace *workspace, void *data)
{
MetaWindow **result = data;
*result = window;
return FALSE; /* quit with the first ancestor we find */
}
/* Focus ancestor of not_this_one if there is one, otherwise focus the MRU
* window on active workspace
*/
static void
focus_ancestor_or_mru_window (MetaWorkspace *workspace,
MetaWindow *not_this_one, MetaWindow *not_this_one,
Time timestamp) Time timestamp)
{ {
@ -862,7 +874,33 @@ meta_workspace_focus_mru_window (MetaWorkspace *workspace,
if (not_this_one) if (not_this_one)
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Focusing MRU window excluding %s\n", not_this_one->desc); "Focusing MRU window excluding %s\n", not_this_one->desc);
else
meta_topic (META_DEBUG_FOCUS,
"Focusing MRU window\n");
/* First, check to see if we need to focus an ancestor of a window */
if (not_this_one)
{
MetaWindow *ancestor;
ancestor = NULL;
meta_window_foreach_ancestor (not_this_one, record_ancestor, &ancestor);
if (ancestor != NULL)
{
meta_topic (META_DEBUG_FOCUS,
"Focusing %s, ancestor of %s\n",
ancestor->desc, not_this_one->desc);
meta_window_focus (ancestor, timestamp);
/* Also raise the window if in click-to-focus */
if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK)
meta_window_raise (ancestor);
return;
}
}
/* No ancestor, look for the MRU window */
tmp = workspace->mru_list; tmp = workspace->mru_list;
while (tmp) while (tmp)