Commit 67bcc6f0 authored by Alexander Larsson's avatar Alexander Larsson

broadway: Improve touch events

We now respect core pointer grabs, and we do the pointer emulation
detection on the browser side.
parent f682aabf
......@@ -82,6 +82,7 @@ typedef struct {
guint32 touch_type;
guint32 event_window_id;
guint32 sequence_id;
guint32 is_emulated;
gint32 root_x;
gint32 root_y;
gint32 win_x;
......
......@@ -238,7 +238,7 @@ 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 &&
if (message->touch.touch_type == 0 && message->touch.is_emulated &&
server->focused_window_id != message->touch.event_window_id)
{
broadway_server_window_raise (server, message->touch.event_window_id);
......@@ -246,6 +246,12 @@ update_event_state (BroadwayServer *server,
broadway_server_flush (server);
}
if (message->touch.is_emulated)
{
server->last_x = message->pointer.root_x;
server->last_y = message->pointer.root_y;
}
server->last_state = message->touch.state;
break;
case BROADWAY_EVENT_KEY_PRESS:
......@@ -386,6 +392,7 @@ parse_touch_data (guint32 *p, BroadwayInputTouchMsg *data)
data->touch_type = ntohl (*p++);
data->event_window_id = ntohl (*p++);
data->sequence_id = ntohl (*p++);
data->is_emulated = ntohl (*p++);
data->root_x = ntohl (*p++);
data->root_y = ntohl (*p++);
data->win_x = ntohl (*p++);
......
......@@ -46,6 +46,8 @@ guint32 broadway_server_grab_pointer (BroadwayServer *
guint32 broadway_server_ungrab_pointer (BroadwayServer *server,
guint32 time_);
gint32 broadway_server_get_mouse_toplevel (BroadwayServer *server);
void broadway_server_set_show_keyboard (BroadwayServer *server,
gboolean show);
guint32 broadway_server_new_window (BroadwayServer *server,
int x,
int y,
......
......@@ -106,6 +106,7 @@ var debugDecoding = false;
var fakeInput = null;
var showKeyboard = false;
var showKeyboardChanged = false;
var firstTouchDownId = null;
var GDK_CROSSING_NORMAL = 0;
var GDK_CROSSING_GRAB = 1;
......@@ -2488,10 +2489,28 @@ function onTouchStart(ev) {
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var id = getSurfaceId(touch);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
var isEmulated = 0;
sendInput ("t", [0, id, touch.identifier, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
if (firstTouchDownId == null) {
firstTouchDownId = touch.identifier;
isEmulated = 1;
if (realWindowWithMouse != origId || id != windowWithMouse) {
if (id != 0) {
sendInput ("l", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
}
windowWithMouse = id;
realWindowWithMouse = origId;
sendInput ("e", [origId, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
}
}
sendInput ("t", [0, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
......@@ -2504,10 +2523,16 @@ function onTouchMove(ev) {
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var id = getSurfaceId(touch);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
sendInput ("t", [1, id, touch.identifier, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
var isEmulated = 0;
if (firstTouchDownId == touch.identifier) {
isEmulated = 1;
}
sendInput ("t", [1, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
......@@ -2520,10 +2545,17 @@ function onTouchEnd(ev) {
for (var i = 0; i < ev.changedTouches.length; i++) {
var touch = ev.changedTouches.item(i);
var id = getSurfaceId(touch);
var origId = getSurfaceId(touch);
var id = getEffectiveEventTarget (origId);
var pos = getPositionsFromEvent(touch, id);
sendInput ("t", [2, id, touch.identifier, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
var isEmulated = 0;
if (firstTouchDownId == touch.identifier) {
isEmulated = 1;
firstTouchDownId = null;
}
sendInput ("t", [2, id, touch.identifier, isEmulated, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
}
......
......@@ -804,6 +804,4 @@ _gdk_broadway_server_set_show_keyboard (GdkBroadwayServer *server,
msg.show_keyboard = show;
gdk_broadway_server_send_message (server, msg,
BROADWAY_REQUEST_SET_SHOW_KEYBOARD);
return TRUE;
}
......@@ -59,8 +59,6 @@ struct _GdkBroadwayDisplay
GdkBroadwayServer *server;
guint32 touch_sequence_down;
gpointer move_resize_data;
};
......
......@@ -214,7 +214,6 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
if (window)
{
GdkEventType event_type = 0;
gboolean is_first_down = FALSE;
switch (message->touch.touch_type) {
case 0:
......@@ -230,25 +229,14 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
g_printerr ("_gdk_broadway_events_got_input - Unknown touch type %d\n", message->touch.touch_type);
}
if (event_type == GDK_TOUCH_BEGIN &&
display_broadway->touch_sequence_down == 0)
display_broadway->touch_sequence_down = message->touch.sequence_id;
if (display_broadway->touch_sequence_down == message->touch.sequence_id)
is_first_down = TRUE;
if (event_type == GDK_TOUCH_END &&
display_broadway->touch_sequence_down == message->touch.sequence_id)
display_broadway->touch_sequence_down = 0;
if (event_type != GDK_TOUCH_BEGIN &&
is_first_down && _gdk_broadway_moveresize_handle_event (display, message))
message->touch.is_emulated && _gdk_broadway_moveresize_handle_event (display, message))
break;
event = gdk_event_new (event_type);
event->touch.window = g_object_ref (window);
event->touch.sequence = GUINT_TO_POINTER(message->touch.sequence_id);
event->touch.emulating_pointer = is_first_down;
event->touch.emulating_pointer = message->touch.is_emulated;
event->touch.time = message->base.time;
event->touch.x = message->touch.win_x;
event->touch.y = message->touch.win_y;
......@@ -259,7 +247,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
gdk_event_set_device (event, device_manager->core_pointer);
gdk_event_set_source_device (event, device_manager->touchscreen);
if (is_first_down)
if (message->touch.is_emulated)
_gdk_event_set_pointer_emulated (event, TRUE);
if (event_type == GDK_TOUCH_BEGIN || event_type == GDK_TOUCH_UPDATE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment