]> Pileus Git - ~andy/gtk/commitdiff
wayland: Set GdkWindow focused state based on keyboard focus
authorKristian Høgsberg <krh@bitplanet.net>
Mon, 16 Jan 2012 15:20:36 +0000 (10:20 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Mon, 16 Jan 2012 20:36:28 +0000 (15:36 -0500)
gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkprivate-wayland.h
gdk/wayland/gdkwindow-wayland.c

index 1e0080fa469ddb7f44cdafab95c73396c42e4996..09ec304355f450e2f16cde108ee38736c3d4a1f7 100644 (file)
@@ -675,6 +675,7 @@ input_handle_keyboard_focus(void *data,
   device->time = time;
   if (device->keyboard_focus)
     {
+      _gdk_wayland_window_remove_focus (device->keyboard_focus);
       event = gdk_event_new (GDK_FOCUS_CHANGE);
       event->focus_change.window = g_object_ref (device->keyboard_focus);
       event->focus_change.send_event = FALSE;
@@ -709,6 +710,8 @@ input_handle_keyboard_focus(void *data,
                           device, device->keyboard_focus));
 
       _gdk_wayland_display_deliver_event (device->display, event);
+
+      _gdk_wayland_window_add_focus (device->keyboard_focus);
     }
 }
 
index e8764940178c3541d5c6c8ba5440eb34f0fa247f..68b81d66b351882a890a134c6a8743ba00162c85 100644 (file)
@@ -49,6 +49,8 @@ void  _gdk_wayland_window_update_size (GdkWindow *window,
                                       int32_t width,
                                       int32_t height,
                                       uint32_t edges);
+void _gdk_wayland_window_add_focus    (GdkWindow *window);
+void _gdk_wayland_window_remove_focus (GdkWindow *window);
 
 GdkKeymap *_gdk_wayland_keymap_new (GdkDisplay *display);
 struct xkb_desc *_gdk_wayland_keymap_get_xkb_desc (GdkKeymap *keymap);
index c773c8b688781d9def2cbaa305af3919404c8c28..834642e1ab1faa6a4853d1c3e9c9e502ef8e6619 100644 (file)
@@ -109,36 +109,7 @@ struct _GdkWindowImplWayland
   GLuint texture;
   uint32_t resize_edges;
 
-  /* Set if the window, or any descendent of it, is the server's focus window
-   */
-  guint has_focus_window : 1;
-
-  /* Set if window->has_focus_window and the focus isn't grabbed elsewhere.
-   */
-  guint has_focus : 1;
-
-  /* Set if the pointer is inside this window. (This is needed for
-   * for focus tracking)
-   */
-  guint has_pointer : 1;
-  
-  /* Set if the window is a descendent of the focus window and the pointer is
-   * inside it. (This is the case where the window will receive keystroke
-   * events even window->has_focus_window is FALSE)
-   */
-  guint has_pointer_focus : 1;
-
-  /* Set if we are requesting these hints */
-  guint skip_taskbar_hint : 1;
-  guint skip_pager_hint : 1;
-  guint urgency_hint : 1;
-
-  guint on_all_desktops : 1;   /* _NET_WM_STICKY == 0xFFFFFFFF */
-
-  guint have_sticky : 1;       /* _NET_WM_STATE_STICKY */
-  guint have_maxvert : 1;       /* _NET_WM_STATE_MAXIMIZED_VERT */
-  guint have_maxhorz : 1;       /* _NET_WM_STATE_MAXIMIZED_HORZ */
-  guint have_fullscreen : 1;    /* _NET_WM_STATE_FULLSCREEN */
+  int focus_count;
 
   gulong map_serial;   /* Serial of last transition from unmapped */
 
@@ -165,6 +136,26 @@ _gdk_window_impl_wayland_init (GdkWindowImplWayland *impl)
   impl->toplevel_window_type = -1;
 }
 
+void
+_gdk_wayland_window_add_focus (GdkWindow *window)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  impl->focus_count++;
+  if (impl->focus_count == 1)
+    gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
+}
+
+void
+_gdk_wayland_window_remove_focus (GdkWindow *window)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  impl->focus_count--;
+  if (impl->focus_count == 0)
+    gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
+}
+
 /**
  * _gdk_wayland_window_update_size:
  * @drawable: a #GdkDrawableImplWayland.