[gtk+/wip/attente/mir-content-hub: 2/6] mir: track focused window



commit 9dedf059fb1ecace2de64cae4c4616367b729ebd
Author: William Hua <william hua canonical com>
Date:   Fri Oct 14 17:00:34 2016 -0400

    mir: track focused window

 gdk/mir/gdkmir-private.h    |    4 ++++
 gdk/mir/gdkmirdisplay.c     |   21 +++++++++++++++++++++
 gdk/mir/gdkmireventsource.c |   10 ++++++++--
 3 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
index 38f1d7a..7e3893c 100644
--- a/gdk/mir/gdkmir-private.h
+++ b/gdk/mir/gdkmir-private.h
@@ -107,6 +107,10 @@ void _gdk_mir_event_source_queue (GdkMirWindowReference *window_ref, const MirEv
 
 MirPixelFormat _gdk_mir_display_get_pixel_format (GdkDisplay *display, MirBufferUsage usage);
 
+void _gdk_mir_display_focus_window (GdkDisplay *display, GdkWindow *window);
+
+void _gdk_mir_display_unfocus_window (GdkDisplay *display, GdkWindow *window);
+
 gboolean _gdk_mir_display_init_egl_display (GdkDisplay *display);
 
 EGLDisplay _gdk_mir_display_get_egl_display (GdkDisplay *display);
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index eea892c..f9aab6f 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -47,6 +47,8 @@ typedef struct GdkMirDisplay
 
   GdkKeymap *keymap;
 
+  GdkWindow *focused_window;
+
   MirPixelFormat sw_pixel_format;
   MirPixelFormat hw_pixel_format;
 
@@ -582,6 +584,25 @@ _gdk_mir_display_get_pixel_format (GdkDisplay *display,
   return mir_dpy->sw_pixel_format;
 }
 
+void
+_gdk_mir_display_focus_window (GdkDisplay *display,
+                               GdkWindow  *window)
+{
+  GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
+
+  mir_display->focused_window = window;
+}
+
+void
+_gdk_mir_display_unfocus_window (GdkDisplay *display,
+                                 GdkWindow  *window)
+{
+  GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
+
+  if (window == mir_display->focused_window)
+    mir_display->focused_window = NULL;
+}
+
 gboolean
 _gdk_mir_display_init_egl_display (GdkDisplay *display)
 {
diff --git a/gdk/mir/gdkmireventsource.c b/gdk/mir/gdkmireventsource.c
index 8c7e106..a2a1a12 100644
--- a/gdk/mir/gdkmireventsource.c
+++ b/gdk/mir/gdkmireventsource.c
@@ -240,9 +240,15 @@ generate_focus_event (GdkWindow *window, gboolean focused)
   GdkEvent *event;
 
   if (focused)
-    gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
+    {
+      gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
+      _gdk_mir_display_focus_window (gdk_window_get_display (window), window);
+    }
   else
-    gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
+    {
+      gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
+      _gdk_mir_display_unfocus_window (gdk_window_get_display (window), window);
+    }
 
   event = gdk_event_new (GDK_FOCUS_CHANGE);
   event->focus_change.send_event = FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]