]> Pileus Git - ~andy/gtk/commitdiff
Implement offscreen get_pointer with offscreen signals
authorAlexander Larsson <alexl@redhat.com>
Mon, 8 Jun 2009 17:38:15 +0000 (19:38 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 8 Jun 2009 17:39:14 +0000 (19:39 +0200)
gdk/gdkoffscreenwindow.c

index beeb3d1dac891d5e239a91875c063d643f8bbad2..5682b224856518d8926722d85ae1dcd649ece582 100644 (file)
@@ -698,13 +698,71 @@ gdk_offscreen_window_get_origin (GdkWindow *window,
   return TRUE;
 }
 
+static GdkWindow *
+get_offscreen_parent (GdkWindow *window)
+{
+  GdkWindowObject *private;
+  GdkWindow *res;
+
+  private = (GdkWindowObject *)window;
+
+  res = NULL;
+  g_signal_emit_by_name (private->impl_window,
+                        "get-offscreen-parent",
+                        &res);
+
+  return res;
+}
+
+static void
+from_parent (GdkWindow *window,
+            double parent_x, double parent_y,
+            double *offscreen_x, double *offscreen_y)
+{
+  GdkWindowObject *private;
+
+  private = (GdkWindowObject *)window;
+
+  g_signal_emit_by_name (private->impl_window,
+                        "from_parent",
+                        parent_x, parent_y,
+                        offscreen_x, offscreen_y,
+                        NULL);
+}
+
+
 static gboolean
 gdk_offscreen_window_get_pointer (GdkWindow       *window,
                                  gint            *x,
                                  gint            *y,
                                  GdkModifierType *mask)
 {
-  /* TODO: Base on signals */
+  int tmpx, tmpy;
+  double dtmpx, dtmpy;
+  GdkModifierType tmpmask;
+  GdkWindow *parent;
+
+  tmpx = 0;
+  tmpy = 0;
+  tmpmask = 0;
+
+  parent = get_offscreen_parent (window);
+  if (parent != NULL)
+    {
+      gdk_window_get_pointer (parent, &tmpx, &tmpy, &tmpmask);
+      from_parent (window,
+                  tmpx, tmpy,
+                  &dtmpx, &dtmpy);
+      tmpx = floor (dtmpx + 0.5);
+      tmpy = floor (dtmpy + 0.5);
+    }
+
+  if (x)
+    *x = tmpx;
+  if (y)
+    *y = tmpy;
+  if (mask)
+    *mask = tmpmask;
   return TRUE;
 }