[gtk+/wip/mir] Make separate keyboard and pointer device classes



commit 86ff72337c2521dfc03958a439b2dcd86240a639
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue May 27 09:10:02 2014 +0200

    Make separate keyboard and pointer device classes

 gdk/mir/Makefile.am           |    3 +-
 gdk/mir/gdkmir-private.h      |    6 +-
 gdk/mir/gdkmirdevice.c        |  168 -----------------------------
 gdk/mir/gdkmirdevicemanager.c |    4 +-
 gdk/mir/gdkmirdisplay.c       |   10 +-
 gdk/mir/gdkmirkeyboard.c      |  173 ++++++++++++++++++++++++++++++
 gdk/mir/gdkmirpointer.c       |  233 +++++++++++++++++++++++++++++++++++++++++
 gdk/mir/gdkmirscreen.c        |    9 +-
 gdk/mir/gdkmirwindowimpl.c    |   60 ++++++++---
 9 files changed, 471 insertions(+), 195 deletions(-)
---
diff --git a/gdk/mir/Makefile.am b/gdk/mir/Makefile.am
index aff5e27..1bfb5f4 100644
--- a/gdk/mir/Makefile.am
+++ b/gdk/mir/Makefile.am
@@ -21,10 +21,11 @@ noinst_LTLIBRARIES = \
 
 libgdk_mir_la_SOURCES =        \
        gdkmircursor.c \
-       gdkmirdevice.c \
        gdkmirdevicemanager.c \
        gdkmirdisplay.c \
+       gdkmirkeyboard.c \
        gdkmirkeymap.c \
+       gdkmirpointer.c \
        gdkmirscreen.c  \
        gdkmirwindow.c  \
        gdkmirwindowimpl.c      \
diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h
index c49cf90..2a6ff04 100644
--- a/gdk/mir/gdkmir-private.h
+++ b/gdk/mir/gdkmir-private.h
@@ -52,7 +52,11 @@ GdkDevice *_gdk_mir_device_manager_get_keyboard (GdkDeviceManager *device_manage
 
 GdkKeymap *_gdk_mir_keymap_new (void);
 
-GdkDevice *_gdk_mir_device_new (GdkDeviceManager *device_manager, const gchar *name, GdkInputSource 
input_source, gboolean has_cursor);
+GdkDevice *_gdk_mir_keyboard_new (GdkDeviceManager *device_manager, const gchar *name);
+
+GdkDevice *_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *name);
+
+void _gdk_mir_pointer_set_location (GdkDevice *pointer, gdouble x, gdouble y, GdkWindow *window, 
GdkModifierType mask);
 
 GdkCursor *_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type);
 
diff --git a/gdk/mir/gdkmirdevicemanager.c b/gdk/mir/gdkmirdevicemanager.c
index 4140fe7..92bccd3 100644
--- a/gdk/mir/gdkmirdevicemanager.c
+++ b/gdk/mir/gdkmirdevicemanager.c
@@ -96,8 +96,8 @@ gdk_mir_device_manager_constructed (GObject *object)
 {
   GdkMirDeviceManager *device_manager = GDK_MIR_DEVICE_MANAGER (object);
 
-  device_manager->keyboard = _gdk_mir_device_new (GDK_DEVICE_MANAGER (device_manager), "Mir Keyboard", 
GDK_SOURCE_KEYBOARD, FALSE);
-  device_manager->pointer = _gdk_mir_device_new (GDK_DEVICE_MANAGER (device_manager), "Mir Pointer", 
GDK_SOURCE_MOUSE, TRUE);
+  device_manager->keyboard = _gdk_mir_keyboard_new (GDK_DEVICE_MANAGER (device_manager), "Mir Keyboard");
+  device_manager->pointer = _gdk_mir_pointer_new (GDK_DEVICE_MANAGER (device_manager), "Mir Pointer");
 
   G_OBJECT_CLASS (gdk_mir_device_manager_parent_class)->constructed (object);
 }
diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c
index 8ca31cd..0b8745b 100644
--- a/gdk/mir/gdkmirdisplay.c
+++ b/gdk/mir/gdkmirdisplay.c
@@ -205,7 +205,7 @@ gdk_mir_display_queue_events (GdkDisplay *display)
 static void
 gdk_mir_display_make_default (GdkDisplay *display)
 {
-  g_printerr ("gdk_mir_display_make_default\n");
+  //g_printerr ("gdk_mir_display_make_default\n");
 }
 
 static GdkWindow *
@@ -451,10 +451,10 @@ gdk_mir_display_send_selection_notify (GdkDisplay *display,
 
 static gint
 gdk_mir_display_get_selection_property (GdkDisplay  *display,
-                                            GdkWindow   *requestor,
-                                            guchar     **data,
-                                            GdkAtom     *ret_type,
-                                            gint        *ret_format)
+                                        GdkWindow   *requestor,
+                                        guchar     **data,
+                                        GdkAtom     *ret_type,
+                                        gint        *ret_format)
 {
   g_printerr ("gdk_mir_display_get_selection_property\n");
   return 0;
diff --git a/gdk/mir/gdkmirkeyboard.c b/gdk/mir/gdkmirkeyboard.c
new file mode 100644
index 0000000..93268fc
--- /dev/null
+++ b/gdk/mir/gdkmirkeyboard.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright © 2014 Canonical Ltd
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdeviceprivate.h"
+
+typedef struct GdkMirKeyboard      GdkMirKeyboard;
+typedef struct GdkMirKeyboardClass GdkMirKeyboardClass;
+
+#define GDK_TYPE_MIR_KEYBOARD              (gdk_mir_keyboard_get_type ())
+#define GDK_MIR_KEYBOARD(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_KEYBOARD, 
GdkMirKeyboard))
+#define GDK_MIR_KEYBOARD_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_KEYBOARD, 
GdkMirKeyboardClass))
+#define GDK_IS_MIR_KEYBOARD(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_KEYBOARD))
+#define GDK_IS_MIR_KEYBOARD_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_KEYBOARD))
+#define GDK_MIR_KEYBOARD_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_KEYBOARD, 
GdkMirKeyboardClass))
+
+struct GdkMirKeyboard
+{
+  GdkDevice parent_instance;
+};
+
+struct GdkMirKeyboardClass
+{
+  GdkDeviceClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkMirKeyboard, gdk_mir_keyboard, GDK_TYPE_DEVICE)
+
+GdkDevice *
+_gdk_mir_keyboard_new (GdkDeviceManager *device_manager, const gchar *name)
+{
+  return g_object_new (GDK_TYPE_MIR_KEYBOARD,
+                       "display", gdk_device_manager_get_display (device_manager),
+                       "device-manager", device_manager,
+                       "name", name,
+                       "type", GDK_DEVICE_TYPE_MASTER,
+                       "input-source", GDK_SOURCE_KEYBOARD,
+                       "input-mode", GDK_MODE_SCREEN,
+                       "has-cursor", FALSE,
+                       NULL);
+}
+
+static gboolean
+gdk_mir_keyboard_get_history (GdkDevice      *device,
+                              GdkWindow      *window,
+                              guint32         start,
+                              guint32         stop,
+                              GdkTimeCoord ***events,
+                              gint           *n_events)
+{
+  g_printerr ("gdk_mir_keyboard_get_history\n");
+  return FALSE;
+}
+
+static void
+gdk_mir_keyboard_get_state (GdkDevice      *device,
+                            GdkWindow       *window,
+                            gdouble         *axes,
+                            GdkModifierType *mask)
+{
+  g_printerr ("gdk_mir_keyboard_get_state\n");
+}
+
+static void
+gdk_mir_keyboard_set_window_cursor (GdkDevice *device,
+                                    GdkWindow *window,
+                                    GdkCursor *cursor)
+{
+  //g_printerr ("gdk_mir_keyboard_set_window_cursor\n");
+  /* Keyboards don't have cursors... */
+}
+
+static void
+gdk_mir_keyboard_warp (GdkDevice *device,
+                       GdkScreen *screen,
+                       gdouble    x,
+                       gdouble    y)
+{
+  //g_printerr ("gdk_mir_keyboard_warp\n");
+  /* Can't warp a keyboard... */
+}
+
+static void
+gdk_mir_keyboard_query_state (GdkDevice        *device,
+                              GdkWindow        *window,
+                              GdkWindow       **root_window,
+                              GdkWindow       **child_window,
+                              gdouble          *root_x,
+                              gdouble          *root_y,
+                              gdouble          *win_x,
+                              gdouble          *win_y,
+                              GdkModifierType  *mask)
+{
+  g_printerr ("gdk_mir_keyboard_query_state\n");
+}
+
+static GdkGrabStatus
+gdk_mir_keyboard_grab (GdkDevice    *device,
+                       GdkWindow    *window,
+                       gboolean      owner_events,
+                       GdkEventMask  event_mask,
+                       GdkWindow    *confine_to,
+                       GdkCursor    *cursor,
+                       guint32       time_)
+{
+  g_printerr ("gdk_mir_keyboard_grab\n");
+  /* Mir doesn't do grabs, so sure, you have the grab */
+  return GDK_GRAB_SUCCESS;
+}
+
+static void
+gdk_mir_keyboard_ungrab (GdkDevice *device,
+                         guint32    time_)
+{
+  g_printerr ("gdk_mir_keyboard_ungrab\n");
+  /* Mir doesn't do grabs */
+}
+
+static GdkWindow *
+gdk_mir_keyboard_window_at_position (GdkDevice       *device,
+                                     gdouble         *win_x,
+                                     gdouble         *win_y,
+                                     GdkModifierType *mask,
+                                     gboolean         get_toplevel)
+{
+  //g_printerr ("gdk_mir_keyboard_window_at_position (%f, %f)\n", *win_x, *win_y);
+  /* Keyboard don't have locations... */
+  return NULL; // FIXME: Or the window with the keyboard focus?
+}
+
+static void
+gdk_mir_keyboard_select_window_events (GdkDevice    *device,
+                                       GdkWindow    *window,
+                                       GdkEventMask  event_mask)
+{
+  g_printerr ("gdk_mir_keyboard_select_window_events\n");
+}
+
+static void
+gdk_mir_keyboard_init (GdkMirKeyboard *device)
+{
+}
+
+static void
+gdk_mir_keyboard_class_init (GdkMirKeyboardClass *klass)
+{
+  GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
+
+  device_class->get_history = gdk_mir_keyboard_get_history;
+  device_class->get_state = gdk_mir_keyboard_get_state;
+  device_class->set_window_cursor = gdk_mir_keyboard_set_window_cursor;
+  device_class->warp = gdk_mir_keyboard_warp;
+  device_class->query_state = gdk_mir_keyboard_query_state;
+  device_class->grab = gdk_mir_keyboard_grab;
+  device_class->ungrab = gdk_mir_keyboard_ungrab;
+  device_class->window_at_position = gdk_mir_keyboard_window_at_position;
+  device_class->select_window_events = gdk_mir_keyboard_select_window_events;
+}
diff --git a/gdk/mir/gdkmirpointer.c b/gdk/mir/gdkmirpointer.c
new file mode 100644
index 0000000..21877cd
--- /dev/null
+++ b/gdk/mir/gdkmirpointer.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright © 2014 Canonical Ltd
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdkdeviceprivate.h"
+
+typedef struct GdkMirPointer      GdkMirPointer;
+typedef struct GdkMirPointerClass GdkMirPointerClass;
+
+#define GDK_TYPE_MIR_POINTER              (gdk_mir_pointer_get_type ())
+#define GDK_MIR_POINTER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_MIR_POINTER, 
GdkMirPointer))
+#define GDK_MIR_POINTER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_MIR_POINTER, 
GdkMirPointerClass))
+#define GDK_IS_MIR_POINTER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_MIR_POINTER))
+#define GDK_IS_MIR_POINTER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_MIR_POINTER))
+#define GDK_MIR_POINTER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_MIR_POINTER, 
GdkMirPointerClass))
+
+struct GdkMirPointer
+{
+  GdkDevice parent_instance;
+
+  /* Location of pointer */
+  gdouble x;
+  gdouble y;
+
+  /* Window this pointer is over */
+  GdkWindow *over_window;
+
+  /* Current modifier mask */
+  GdkModifierType modifier_mask;
+};
+
+struct GdkMirPointerClass
+{
+  GdkDeviceClass parent_class;
+};
+
+G_DEFINE_TYPE (GdkMirPointer, gdk_mir_pointer, GDK_TYPE_DEVICE)
+
+GdkDevice *
+_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar *name)
+{
+  return g_object_new (GDK_TYPE_MIR_POINTER,
+                       "display", gdk_device_manager_get_display (device_manager),
+                       "device-manager", device_manager,
+                       "name", name,
+                       "type", GDK_DEVICE_TYPE_MASTER,
+                       "input-source", GDK_SOURCE_MOUSE,
+                       "input-mode", GDK_MODE_SCREEN,
+                       "has-cursor", TRUE,
+                       NULL);
+}
+
+void
+_gdk_mir_pointer_set_location (GdkDevice *pointer,
+                               gdouble x,
+                               gdouble y,
+                               GdkWindow *window,
+                               GdkModifierType mask)
+{
+  GdkMirPointer *p = GDK_MIR_POINTER (pointer);
+
+  p->x = x;
+  p->y = y;
+  if (p->over_window)
+    g_object_unref (p->over_window);
+  p->over_window = g_object_ref (window);
+  p->modifier_mask = mask;
+}
+
+static gboolean
+gdk_mir_pointer_get_history (GdkDevice      *device,
+                             GdkWindow      *window,
+                             guint32         start,
+                             guint32         stop,
+                             GdkTimeCoord ***events,
+                             gint           *n_events)
+{
+  g_printerr ("gdk_mir_pointer_get_history\n");
+  return FALSE;
+}
+
+static void
+gdk_mir_pointer_get_state (GdkDevice       *device,
+                           GdkWindow       *window,
+                           gdouble         *axes,
+                           GdkModifierType *mask)
+{
+  g_printerr ("gdk_mir_pointer_get_state\n");
+  GdkMirPointer *p = GDK_MIR_POINTER (device);
+
+  if (axes)
+    {
+      axes[0] = p->x;
+      axes[1] = p->y;
+    }
+  if (mask)
+    *mask = p->modifier_mask;
+}
+
+static void
+gdk_mir_pointer_set_window_cursor (GdkDevice *device,
+                                   GdkWindow *window,
+                                   GdkCursor *cursor)
+{
+  g_printerr ("gdk_mir_pointer_set_window_cursor\n");
+  /* Mir doesn't support cursors */
+}
+
+static void
+gdk_mir_pointer_warp (GdkDevice *device,
+                      GdkScreen *screen,
+                      gdouble    x,
+                      gdouble    y)
+{
+  g_printerr ("gdk_mir_pointer_warp\n");
+  /* Mir doesn't support warping */
+}
+
+static void
+gdk_mir_pointer_query_state (GdkDevice        *device,
+                             GdkWindow        *window,
+                             GdkWindow       **root_window,
+                             GdkWindow       **child_window,
+                             gdouble          *root_x,
+                             gdouble          *root_y,
+                             gdouble          *win_x,
+                             gdouble          *win_y,
+                             GdkModifierType  *mask)
+{
+  g_printerr ("gdk_mir_pointer_query_state\n");
+  GdkMirPointer *p = GDK_MIR_POINTER (device);
+  if (root_window)
+    ;//*root_window = ?; // FIXME
+  if (child_window)
+    ;//*child_window = ?; // FIXME
+  if (root_x)
+    *root_x = p->x;
+  if (root_y)
+    *root_y = p->y;
+  if (win_x)
+    *win_x = p->x; // FIXME
+  if (win_y)
+    *win_y = p->y;
+  if (mask)
+    *mask = p->modifier_mask;
+}
+
+static GdkGrabStatus
+gdk_mir_pointer_grab (GdkDevice    *device,
+                      GdkWindow    *window,
+                      gboolean      owner_events,
+                      GdkEventMask  event_mask,
+                      GdkWindow    *confine_to,
+                      GdkCursor    *cursor,
+                      guint32       time_)
+{
+  g_printerr ("gdk_mir_pointer_grab\n");
+  /* Mir doesn't do grabs, so sure, you have the grab */
+  return GDK_GRAB_SUCCESS;
+}
+
+static void
+gdk_mir_pointer_ungrab (GdkDevice *device,
+                        guint32    time_)
+{
+  g_printerr ("gdk_mir_pointer_ungrab\n");
+  /* Mir doesn't do grabs */
+}
+
+static GdkWindow *
+gdk_mir_pointer_window_at_position (GdkDevice       *device,
+                                    gdouble         *win_x,
+                                    gdouble         *win_y,
+                                    GdkModifierType *mask,
+                                    gboolean         get_toplevel)
+{
+  //g_printerr ("gdk_mir_pointer_window_at_position\n");
+  GdkMirPointer *p = GDK_MIR_POINTER (device);
+
+  if (win_x)
+    *win_x = p->x;
+  if (win_y)
+    *win_y = p->y;
+  if (mask)
+    *mask = p->modifier_mask;
+
+  return p->over_window;
+}
+
+static void
+gdk_mir_pointer_select_window_events (GdkDevice    *device,
+                                      GdkWindow    *window,
+                                      GdkEventMask  event_mask)
+{
+  g_printerr ("gdk_mir_pointer_select_window_events\n");
+  // FIXME?
+}
+
+static void
+gdk_mir_pointer_init (GdkMirPointer *device)
+{
+}
+
+static void
+gdk_mir_pointer_class_init (GdkMirPointerClass *klass)
+{
+  GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
+
+  device_class->get_history = gdk_mir_pointer_get_history;
+  device_class->get_state = gdk_mir_pointer_get_state;
+  device_class->set_window_cursor = gdk_mir_pointer_set_window_cursor;
+  device_class->warp = gdk_mir_pointer_warp;
+  device_class->query_state = gdk_mir_pointer_query_state;
+  device_class->grab = gdk_mir_pointer_grab;
+  device_class->ungrab = gdk_mir_pointer_ungrab;
+  device_class->window_at_position = gdk_mir_pointer_window_at_position;
+  device_class->select_window_events = gdk_mir_pointer_select_window_events;
+}
diff --git a/gdk/mir/gdkmirscreen.c b/gdk/mir/gdkmirscreen.c
index 1077271..57d2803 100644
--- a/gdk/mir/gdkmirscreen.c
+++ b/gdk/mir/gdkmirscreen.c
@@ -207,8 +207,9 @@ gdk_mir_screen_get_height_mm (GdkScreen *screen)
 static gint
 gdk_mir_screen_get_number (GdkScreen *screen)
 {
-  g_printerr ("gdk_mir_screen_get_number\n");
-  return 0; //?
+  //g_printerr ("gdk_mir_screen_get_number\n");
+  /* There is only one screen... */
+  return 0;
 }
 
 static GdkWindow *
@@ -293,7 +294,7 @@ gdk_mir_screen_get_monitor_geometry (GdkScreen    *screen,
                                      gint          monitor_num,
                                      GdkRectangle *dest)
 {
-  g_printerr ("gdk_mir_screen_get_monitor_geometry (%d)\n", monitor_num);
+  //g_printerr ("gdk_mir_screen_get_monitor_geometry (%d)\n", monitor_num);
   MirDisplayOutput *output;
   MirDisplayMode *mode;
 
@@ -310,7 +311,7 @@ gdk_mir_screen_get_monitor_workarea (GdkScreen    *screen,
                                      gint          monitor_num,
                                      GdkRectangle *dest)
 {
-  g_printerr ("gdk_mir_screen_get_monitor_workarea (%d)\n", monitor_num);
+  //g_printerr ("gdk_mir_screen_get_monitor_workarea (%d)\n", monitor_num);
   // FIXME: Don't know what this is
   gdk_mir_screen_get_monitor_geometry (screen, monitor_num, dest);
 }
diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c
index 80c1dd3..559f7f6 100644
--- a/gdk/mir/gdkmirwindowimpl.c
+++ b/gdk/mir/gdkmirwindowimpl.c
@@ -409,6 +409,12 @@ generate_key_event (GdkWindow *window, GdkEventType type, guint state, guint key
   send_event (window, _gdk_mir_device_manager_get_keyboard (gdk_display_get_device_manager 
(gdk_window_get_display (window))), event);
 }
 
+static GdkDevice *
+get_pointer (GdkWindow *window)
+{
+  return gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gdk_window_get_display 
(window)));
+}
+
 void
 generate_button_event (GdkWindow *window, GdkEventType type, gdouble x, gdouble y, guint button, guint state)
 {
@@ -420,7 +426,7 @@ generate_button_event (GdkWindow *window, GdkEventType type, gdouble x, gdouble
   event->button.state = state;
   event->button.button = button;
 
-  send_event (window, gdk_device_manager_get_client_pointer (gdk_display_get_device_manager 
(gdk_window_get_display (window))), event);
+  send_event (window, get_pointer (window), event);
 }
 
 static void
@@ -436,7 +442,7 @@ generate_scroll_event (GdkWindow *window, gdouble x, gdouble y, gdouble delta_x,
   event->scroll.delta_x = delta_x;
   event->scroll.delta_y = delta_y;
 
-  send_event (window, gdk_device_manager_get_client_pointer (gdk_display_get_device_manager 
(gdk_window_get_display (window))), event);
+  send_event (window, get_pointer (window), event);
 }
 
 static void
@@ -450,7 +456,7 @@ generate_motion_event (GdkWindow *window, gdouble x, gdouble y, guint state)
   event->motion.state = state;
   event->motion.is_hint = FALSE;
 
-  send_event (window, gdk_device_manager_get_client_pointer (gdk_display_get_device_manager 
(gdk_window_get_display (window))), event);
+  send_event (window, get_pointer (window), event);
 }
 
 static guint
@@ -524,6 +530,9 @@ event_cb (MirSurface *surface, const MirEvent *event, void *context)
       y = event->motion.pointer_coordinates[0].y;
       modifier_state = get_modifier_state (event->motion.modifiers, event->motion.button_state);
 
+      /* Update which window has focus */
+      _gdk_mir_pointer_set_location (get_pointer (window), x, y, window, modifier_state);
+
       switch (event->motion.action)
         {
         case mir_motion_action_down:
@@ -788,7 +797,7 @@ static void
 gdk_mir_window_impl_set_background (GdkWindow       *window,
                                     cairo_pattern_t *pattern)
 {
-  g_printerr ("gdk_mir_window_impl_set_background\n");
+  //g_printerr ("gdk_mir_window_impl_set_background\n");
   GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
 
   if (impl->background)
@@ -826,7 +835,8 @@ gdk_mir_window_impl_set_device_cursor (GdkWindow *window,
                                        GdkDevice *device,
                                        GdkCursor *cursor)
 {
-  g_printerr ("gdk_mir_window_impl_set_device_cursor\n");
+  //g_printerr ("gdk_mir_window_impl_set_device_cursor\n");
+  /* We don't support cursors yet... */
 }
 
 static void
@@ -836,7 +846,17 @@ gdk_mir_window_impl_get_geometry (GdkWindow *window,
                                   gint      *width,
                                   gint      *height)
 {
-  g_printerr ("gdk_mir_window_impl_get_geometry\n");
+  //g_printerr ("gdk_mir_window_impl_get_geometry\n");
+  GdkMirWindowImpl *impl = GDK_MIR_WINDOW_IMPL (window->impl);
+
+  if (x)
+    *x = 0; // FIXME
+  if (y)
+    *y = 0; // FIXME
+  if (width)
+    *width = impl->width;
+  if (height)
+    *height = impl->height;
 }
 
 static gint
@@ -846,8 +866,14 @@ gdk_mir_window_impl_get_root_coords (GdkWindow *window,
                                      gint      *root_x,
                                      gint      *root_y)
 {
-  g_printerr ("gdk_mir_window_impl_get_root_coords\n");
-  return 0;
+  //g_printerr ("gdk_mir_window_impl_get_root_coords\n");
+
+  if (root_x)
+    *root_x = x; // FIXME
+  if (root_y)
+    *root_y = y; // FIXME
+
+  return 1;
 }
 
 static gboolean
@@ -974,7 +1000,8 @@ void
 gdk_mir_window_impl_set_modal_hint (GdkWindow *window,
                                     gboolean   modal)
 {
-  g_printerr ("gdk_mir_window_impl_set_modal_hint\n");
+  //g_printerr ("gdk_mir_window_impl_set_modal_hint\n");
+  /* Mir doesn't support modal windows */
 }
 
 static void
@@ -1003,7 +1030,8 @@ gdk_mir_window_impl_set_geometry_hints (GdkWindow         *window,
                                         const GdkGeometry *geometry,
                                         GdkWindowHints     geom_mask)
 {
-  g_printerr ("gdk_mir_window_impl_set_geometry_hints\n");
+  //g_printerr ("gdk_mir_window_impl_set_geometry_hints\n");
+  //FIXME: ?
 }
 
 static void
@@ -1060,21 +1088,24 @@ static void
 gdk_mir_window_impl_set_accept_focus (GdkWindow *window,
                                       gboolean   accept_focus)
 {
-  g_printerr ("gdk_mir_window_impl_set_accept_focus\n");
+  //g_printerr ("gdk_mir_window_impl_set_accept_focus\n");
+  /* Mir clients cannot control focus */
 }
 
 static void
 gdk_mir_window_impl_set_focus_on_map (GdkWindow *window,
                                       gboolean focus_on_map)
 {
-  g_printerr ("gdk_mir_window_impl_set_focus_on_map\n");
+  //g_printerr ("gdk_mir_window_impl_set_focus_on_map\n");
+  /* Mir clients cannot control focus */
 }
 
 static void
 gdk_mir_window_impl_set_icon_list (GdkWindow *window,
                                    GList     *pixbufs)
 {
-  g_printerr ("gdk_mir_window_impl_set_icon_list\n");
+  //g_printerr ("gdk_mir_window_impl_set_icon_list\n");
+  // ??
 }
 
 static void
@@ -1231,7 +1262,8 @@ static void
 gdk_mir_window_impl_set_opacity (GdkWindow *window,
                                  gdouble    opacity)
 {
-  g_printerr ("gdk_mir_window_impl_set_opacity\n");
+  //g_printerr ("gdk_mir_window_impl_set_opacity\n");
+  // FIXME
 }
 
 static void


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