[gtk+] broadway: Fix focus handling with touch events



commit 6917746c8ea6e5e7a3b07d15f653afbacb441292
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Nov 12 22:06:33 2013 +0100

    broadway: Fix focus handling with touch events

 gdk/broadway/broadway-protocol.h |    2 +-
 gdk/broadway/broadway-server.c   |   10 +++++++++-
 gdk/broadway/broadway.js         |    6 +++---
 gdk/broadway/gdkeventsource.c    |    2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/gdk/broadway/broadway-protocol.h b/gdk/broadway/broadway-protocol.h
index 5d53ad4..bd48648 100644
--- a/gdk/broadway/broadway-protocol.h
+++ b/gdk/broadway/broadway-protocol.h
@@ -90,7 +90,7 @@ typedef struct {
 
 typedef struct {
   BroadwayInputBaseMsg base;
-  guint32 mouse_window_id; /* The real window, not taking grabs into account */
+  guint32 window_id;
   guint32 state;
   gint32 key;
 } BroadwayInputKeyMsg;
diff --git a/gdk/broadway/broadway-server.c b/gdk/broadway/broadway-server.c
index 9fbd6b9..0c384d8 100644
--- a/gdk/broadway/broadway-server.c
+++ b/gdk/broadway/broadway-server.c
@@ -237,6 +237,14 @@ update_event_state (BroadwayServer *server,
     server->real_mouse_in_toplevel_id = message->pointer.mouse_window_id;
     break;
   case BROADWAY_EVENT_TOUCH:
+    if (message->touch.touch_type == 0 &&
+        server->focused_window_id != message->touch.event_window_id)
+      {
+        broadway_server_window_raise (server, message->touch.event_window_id);
+        broadway_server_focus_window (server, message->touch.event_window_id);
+        broadway_server_flush (server);
+      }
+
     server->last_state = message->touch.state;
     break;
   case BROADWAY_EVENT_KEY_PRESS:
@@ -460,7 +468,7 @@ parse_input_message (BroadwayInput *input, const unsigned char *message)
 
   case BROADWAY_EVENT_KEY_PRESS:
   case BROADWAY_EVENT_KEY_RELEASE:
-    msg.key.mouse_window_id = ntohl (*p++);
+    msg.key.window_id = server->focused_window_id;
     msg.key.key = ntohl (*p++);
     msg.key.state = ntohl (*p++);
     break;
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index caea0c9..ed0a9e0 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -2347,7 +2347,7 @@ function handleKeyDown(e) {
        // browser behaviors or it has no corresponding keyPress
        // event, then send it immediately
        if (!ignoreKeyEvent(ev))
-           sendInput("k", [realWindowWithMouse, keysym, lastState]);
+           sendInput("k", [keysym, lastState]);
        suppress = true;
     }
 
@@ -2392,7 +2392,7 @@ function handleKeyPress(e) {
 
     // Send the translated keysym
     if (keysym > 0)
-       sendInput ("k", [realWindowWithMouse, keysym, lastState]);
+       sendInput ("k", [keysym, lastState]);
 
     // Stop keypress events just in case
     return cancelEvent(ev);
@@ -2411,7 +2411,7 @@ function handleKeyUp(e) {
     }
 
     if (keysym > 0)
-       sendInput ("K", [realWindowWithMouse, keysym, lastState]);
+       sendInput ("K", [keysym, lastState]);
     return cancelEvent(ev);
 }
 
diff --git a/gdk/broadway/gdkeventsource.c b/gdk/broadway/gdkeventsource.c
index fe5dad6..b5c9e1c 100644
--- a/gdk/broadway/gdkeventsource.c
+++ b/gdk/broadway/gdkeventsource.c
@@ -273,7 +273,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
   case BROADWAY_EVENT_KEY_PRESS:
   case BROADWAY_EVENT_KEY_RELEASE:
     window = g_hash_table_lookup (display_broadway->id_ht,
-                                 GINT_TO_POINTER (message->key.mouse_window_id));
+                                 GINT_TO_POINTER (message->key.window_id));
     if (window)
       {
        event = gdk_event_new (message->base.type == 'k' ? GDK_KEY_PRESS : GDK_KEY_RELEASE);


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