[mutter] window: Merge got_focus/lost_focus to a new function
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] window: Merge got_focus/lost_focus to a new function
- Date: Wed, 22 May 2013 16:35:43 +0000 (UTC)
commit 696d9d2fa9e0b56de86d35653c9e19a2e1d24544
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Dec 16 21:24:32 2012 -0500
window: Merge got_focus/lost_focus to a new function
Make it a static function for now, but this will be a private
function soon, replacing meta_window_lost_focus. This should
contain no functional changes, only cosmetic indentation changes,
so best viewed with ignorews=1 or -w or -b, you know the drill.
https://bugzilla.gnome.org/show_bug.cgi?id=647706
src/core/window.c | 192 ++++++++++++++++++++++++++++-------------------------
1 files changed, 101 insertions(+), 91 deletions(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 7d558f8..59eb056 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -7209,116 +7209,124 @@ meta_window_propagate_focus_appearance (MetaWindow *window,
}
static void
-meta_window_got_focus (MetaWindow *window)
+meta_window_set_focused_internal (MetaWindow *window,
+ gboolean focused)
{
- if (window != window->display->focus_window)
+ if (focused)
{
- meta_topic (META_DEBUG_FOCUS,
- "* Focus --> %s\n", window->desc);
- window->display->focus_window = window;
- window->has_focus = TRUE;
-
- /* Move to the front of the focusing workspace's MRU list.
- * We should only be "removing" it from the MRU list if it's
- * not already there. Note that it's possible that we might
- * be processing this FocusIn after we've changed to a
- * different workspace; we should therefore update the MRU
- * list only if the window is actually on the active
- * workspace.
- */
- if (window->screen->active_workspace &&
- meta_window_located_on_workspace (window,
- window->screen->active_workspace))
+ if (window != window->display->focus_window)
{
- GList* link;
- link = g_list_find (window->screen->active_workspace->mru_list,
- window);
- g_assert (link);
-
- window->screen->active_workspace->mru_list =
- g_list_remove_link (window->screen->active_workspace->mru_list,
- link);
- g_list_free (link);
-
- window->screen->active_workspace->mru_list =
- g_list_prepend (window->screen->active_workspace->mru_list,
- window);
- }
+ meta_topic (META_DEBUG_FOCUS,
+ "* Focus --> %s\n", window->desc);
+ window->display->focus_window = window;
+ window->has_focus = TRUE;
+
+ /* Move to the front of the focusing workspace's MRU list.
+ * We should only be "removing" it from the MRU list if it's
+ * not already there. Note that it's possible that we might
+ * be processing this FocusIn after we've changed to a
+ * different workspace; we should therefore update the MRU
+ * list only if the window is actually on the active
+ * workspace.
+ */
+ if (window->screen->active_workspace &&
+ meta_window_located_on_workspace (window,
+ window->screen->active_workspace))
+ {
+ GList* link;
+ link = g_list_find (window->screen->active_workspace->mru_list,
+ window);
+ g_assert (link);
+
+ window->screen->active_workspace->mru_list =
+ g_list_remove_link (window->screen->active_workspace->mru_list,
+ link);
+ g_list_free (link);
+
+ window->screen->active_workspace->mru_list =
+ g_list_prepend (window->screen->active_workspace->mru_list,
+ window);
+ }
- if (window->frame)
- meta_frame_queue_draw (window->frame);
+ if (window->frame)
+ meta_frame_queue_draw (window->frame);
- meta_error_trap_push (window->display);
- XInstallColormap (window->display->xdisplay,
- window->colormap);
- meta_error_trap_pop (window->display);
+ meta_error_trap_push (window->display);
+ XInstallColormap (window->display->xdisplay,
+ window->colormap);
+ meta_error_trap_pop (window->display);
- /* move into FOCUSED_WINDOW layer */
- meta_window_update_layer (window);
+ /* move into FOCUSED_WINDOW layer */
+ meta_window_update_layer (window);
- /* Ungrab click to focus button since the sync grab can interfere
- * with some things you might do inside the focused window, by
- * causing the client to get funky enter/leave events.
- *
- * The reason we usually have a passive grab on the window is
- * so that we can intercept clicks and raise the window in
- * response. For click-to-focus we don't need that since the
- * focused window is already raised. When raise_on_click is
- * FALSE we also don't need that since we don't do anything
- * when the window is clicked.
- *
- * There is dicussion in bugs 102209, 115072, and 461577
- */
- if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
- !meta_prefs_get_raise_on_click())
- meta_display_ungrab_focus_window_button (window->display, window);
+ /* Ungrab click to focus button since the sync grab can interfere
+ * with some things you might do inside the focused window, by
+ * causing the client to get funky enter/leave events.
+ *
+ * The reason we usually have a passive grab on the window is
+ * so that we can intercept clicks and raise the window in
+ * response. For click-to-focus we don't need that since the
+ * focused window is already raised. When raise_on_click is
+ * FALSE we also don't need that since we don't do anything
+ * when the window is clicked.
+ *
+ * There is dicussion in bugs 102209, 115072, and 461577
+ */
+ if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
+ !meta_prefs_get_raise_on_click())
+ meta_display_ungrab_focus_window_button (window->display, window);
- g_signal_emit (window, window_signals[FOCUS], 0);
- g_object_notify (G_OBJECT (window->display), "focus-window");
+ g_signal_emit (window, window_signals[FOCUS], 0);
+ g_object_notify (G_OBJECT (window->display), "focus-window");
- if (!window->attached_focus_window)
- meta_window_appears_focused_changed (window);
+ if (!window->attached_focus_window)
+ meta_window_appears_focused_changed (window);
- meta_window_propagate_focus_appearance (window, TRUE);
+ meta_window_propagate_focus_appearance (window, TRUE);
+ }
}
-}
-
-void
-meta_window_lost_focus (MetaWindow *window)
-{
- if (window == window->display->focus_window)
+ else
{
- meta_topic (META_DEBUG_FOCUS,
- "%s is now the previous focus window due to being focused out or unmapped\n",
- window->desc);
+ if (window == window->display->focus_window)
+ {
+ meta_topic (META_DEBUG_FOCUS,
+ "%s is now the previous focus window due to being focused out or unmapped\n",
+ window->desc);
- meta_topic (META_DEBUG_FOCUS,
- "* Focus --> NULL (was %s)\n", window->desc);
+ meta_topic (META_DEBUG_FOCUS,
+ "* Focus --> NULL (was %s)\n", window->desc);
- meta_window_propagate_focus_appearance (window, FALSE);
+ meta_window_propagate_focus_appearance (window, FALSE);
- window->display->focus_window = NULL;
- g_object_notify (G_OBJECT (window->display), "focus-window");
- window->has_focus = FALSE;
+ window->display->focus_window = NULL;
+ g_object_notify (G_OBJECT (window->display), "focus-window");
+ window->has_focus = FALSE;
- if (!window->attached_focus_window)
- meta_window_appears_focused_changed (window);
+ if (!window->attached_focus_window)
+ meta_window_appears_focused_changed (window);
- meta_error_trap_push (window->display);
- XUninstallColormap (window->display->xdisplay,
- window->colormap);
- meta_error_trap_pop (window->display);
+ meta_error_trap_push (window->display);
+ XUninstallColormap (window->display->xdisplay,
+ window->colormap);
+ meta_error_trap_pop (window->display);
- /* move out of FOCUSED_WINDOW layer */
- meta_window_update_layer (window);
+ /* move out of FOCUSED_WINDOW layer */
+ meta_window_update_layer (window);
- /* Re-grab for click to focus and raise-on-click, if necessary */
- if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
- !meta_prefs_get_raise_on_click ())
- meta_display_grab_focus_window_button (window->display, window);
+ /* Re-grab for click to focus and raise-on-click, if necessary */
+ if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK ||
+ !meta_prefs_get_raise_on_click ())
+ meta_display_grab_focus_window_button (window->display, window);
+ }
}
}
+void
+meta_window_lost_focus (MetaWindow *window)
+{
+ meta_window_set_focused_internal (window, FALSE);
+}
+
gboolean
meta_window_notify_focus (MetaWindow *window,
XIEnterEvent *event)
@@ -7395,8 +7403,10 @@ meta_window_notify_focus (MetaWindow *window,
g_object_notify (G_OBJECT (window->display), "focus-window");
return FALSE;
}
-
- meta_window_got_focus (window);
+ else
+ {
+ meta_window_set_focused_internal (window, TRUE);
+ }
}
else if (event->evtype == XI_FocusOut)
{
@@ -7410,7 +7420,7 @@ meta_window_notify_focus (MetaWindow *window,
}
else
{
- meta_window_lost_focus (window);
+ meta_window_set_focused_internal (window, FALSE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]