[gtk+/broadway: 34/71] [broadway] Send and use canvas ids in events



commit 6fe849d4f1d97f5f6ada8d34adc238b5c912cf5e
Author: Alexander Larsson <alexl redhat com>
Date:   Sat Nov 20 22:39:40 2010 +0100

    [broadway] Send and use canvas ids in events

 gdk/broadway/broadway.js           |   18 +++++++++++++-----
 gdk/broadway/gdkdisplay-broadway.c |   10 +++++++---
 2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 79a9fe7..0a2e150 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -93,8 +93,9 @@ function apply_delta(id, img, x, y)
   delete tmp_surface
 }
 
-function initContext(canvas, x, y)
+function initContext(canvas, x, y, id)
 {
+  canvas.surface_id = id;
   canvas.style["position"] = "absolute"
   canvas.style["top"] = x + "px"
   canvas.style["left"] = y + "px"
@@ -130,7 +131,7 @@ function handleCommands(cmd_obj)
         var surface = document.createElement("canvas");
 	surface.width = w;
 	surface.height = h;
-	surfaces[id] = initContext(surface, x, y);
+	surfaces[id] = initContext(surface, x, y, id);
         break;
 
       /* show a surface */
@@ -296,6 +297,13 @@ function handleLoad(event)
   }
 }
 
+function get_surface_id(ev) {
+  var id = ev.target.surface_id;
+  if (id != undefined)
+    return id;
+  return 0;
+}
+
 function send_input(cmd, args)
 {
   if (input_socket != null) {
@@ -304,15 +312,15 @@ function send_input(cmd, args)
 }
 
 function on_mouse_move (ev) {
-  send_input ("m", [ev.pageX, ev.pageY, ev.timeStamp])
+  send_input ("m", [get_surface_id(ev), ev.pageX, ev.pageY, ev.timeStamp])
 }
 
 function on_mouse_down (ev) {
-  send_input ("b", [ev.pageX, ev.pageY, ev.button, ev.timeStamp])
+  send_input ("b", [get_surface_id(ev), ev.pageX, ev.pageY, ev.button, ev.timeStamp])
 }
 
 function on_mouse_up (ev) {
-  send_input ("B", [ev.pageX, ev.pageY, ev.button, ev.timeStamp])
+  send_input ("B", [get_surface_id(ev), ev.pageX, ev.pageY, ev.button, ev.timeStamp])
 }
 
 function connect()
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 3384793..6a39217 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -181,7 +181,7 @@ got_input (GInputStream *stream,
   char *message, *p;
   gsize len;
   GError *error = NULL;
-  int x, y, button;
+  int x, y, button, id;
   guint64 time;
   GdkEvent *event = NULL;
   char cmd;
@@ -204,13 +204,15 @@ got_input (GInputStream *stream,
   cmd = *p++;
   switch (cmd) {
   case 'm':
+    id = strtol(p, &p, 10);
+    p++; /* Skip , */
     x = strtol(p, &p, 10);
     p++; /* Skip , */
     y = strtol(p, &p, 10);
     p++; /* Skip , */
     time = strtol(p, &p, 10);
 
-    window = _gdk_window_find_child_at (root, x, y);
+    window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (id));
 
     if (display_broadway->mouse_in_toplevel != window)
       {
@@ -287,6 +289,8 @@ got_input (GInputStream *stream,
     break;
   case 'b':
   case 'B':
+    id = strtol(p, &p, 10);
+    p++; /* Skip , */
     x = strtol(p, &p, 10);
     p++; /* Skip , */
     y = strtol(p, &p, 10);
@@ -295,7 +299,7 @@ got_input (GInputStream *stream,
     p++; /* Skip , */
     time = strtol(p, &p, 10);
 
-    window = _gdk_window_find_child_at (root, x, y);
+    window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (id));
 
     if (window)
       {



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