[metacity] window: move lost focus code to separate function
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] window: move lost focus code to separate function
- Date: Thu, 2 Mar 2017 22:15:14 +0000 (UTC)
commit 1abf8f8711c857b6f2ed3b554752af3091baff04
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Mar 2 21:14:57 2017 +0200
window: move lost focus code to separate function
src/core/display.c | 2 +-
src/core/window-private.h | 2 +
src/core/window.c | 78 ++++++++++++++++++++++++---------------------
3 files changed, 45 insertions(+), 37 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 2c71309..55a29c4 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -2062,7 +2062,7 @@ event_callback (XEvent *event,
* and move focus to another window
*/
if (window)
- meta_window_notify_focus (window, event);
+ meta_window_lost_focus (window);
}
break;
case MapNotify:
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 4b13e8e..fc6fb5a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -576,6 +576,8 @@ gboolean meta_window_client_message (MetaWindow *window,
gboolean meta_window_notify_focus (MetaWindow *window,
XEvent *event);
+void meta_window_lost_focus (MetaWindow *window);
+
void meta_window_set_current_workspace_hint (MetaWindow *window);
unsigned long meta_window_get_net_wm_desktop (MetaWindow *window);
diff --git a/src/core/window.c b/src/core/window.c
index 6edfc42..508a1fb 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5638,6 +5638,43 @@ check_ancestor_focus_appearance (MetaWindow *window)
check_ancestor_focus_appearance (parent);
}
+void
+meta_window_lost_focus (MetaWindow *window)
+{
+ 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);
+
+ window->display->focus_window = NULL;
+ window->has_focus = FALSE;
+
+ /* parent window become active. */
+ check_ancestor_focus_appearance (window);
+
+ meta_window_appears_focused_changed (window);
+
+ meta_compositor_set_active_window (window->display->compositor, NULL);
+
+ 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);
+
+ /* 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);
+ }
+}
+
gboolean
meta_window_notify_focus (MetaWindow *window,
XEvent *event)
@@ -5785,11 +5822,9 @@ meta_window_notify_focus (MetaWindow *window,
check_ancestor_focus_appearance (window);
}
}
- else if (event->type == FocusOut ||
- event->type == UnmapNotify)
+ else if (event->type == FocusOut)
{
- if (event->type == FocusOut &&
- event->xfocus.detail == NotifyInferior)
+ if (event->xfocus.detail == NotifyInferior)
{
/* This event means the client moved focus to a subwindow */
meta_topic (META_DEBUG_FOCUS,
@@ -5797,39 +5832,10 @@ meta_window_notify_focus (MetaWindow *window,
window->desc);
return TRUE;
}
-
- 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);
-
- meta_topic (META_DEBUG_FOCUS,
- "* Focus --> NULL (was %s)\n", window->desc);
-
- window->display->focus_window = NULL;
- window->has_focus = FALSE;
-
- /* parent window become active. */
- check_ancestor_focus_appearance (window);
-
- meta_window_appears_focused_changed (window);
-
- meta_compositor_set_active_window (window->display->compositor, NULL);
-
- 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);
-
- /* 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);
- }
+ meta_window_lost_focus (window);
+ }
}
/* Now set _NET_ACTIVE_WINDOW hint */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]