[broadway] Keep track of current real cursor window (sans grabs)

We need this to be able to do a non-roundtripping get-window.
This commit is contained in:
Alexander Larsson 2011-04-05 10:03:14 +02:00
parent ee1657d88e
commit e113cf26fb
4 changed files with 31 additions and 17 deletions

View File

@ -482,7 +482,7 @@ function onMouseMove (ev) {
var id = getSurfaceId(ev);
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
sendInput ("m", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
sendInput ("m", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState]);
}
function onMouseOver (ev) {
@ -493,7 +493,7 @@ function onMouseOver (ev) {
var pos = getPositionsFromEvent(ev, id);
windowWithMouse = id;
if (windowWithMouse != 0) {
sendInput ("e", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
}
}
@ -505,7 +505,7 @@ function onMouseOut (ev) {
var pos = getPositionsFromEvent(ev, id);
if (id != 0) {
sendInput ("l", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
sendInput ("l", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
}
realWindowWithMouse = 0;
windowWithMouse = 0;
@ -517,10 +517,10 @@ function doGrab(id, ownerEvents, time, implicit) {
if (windowWithMouse != id) {
if (windowWithMouse != 0) {
pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
sendInput ("l", [windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
}
pos = getPositionsFromAbsCoord(lastX, lastY, id);
sendInput ("e", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_GRAB]);
windowWithMouse = id;
}
@ -535,11 +535,11 @@ function doUngrab(time) {
if (realWindowWithMouse != windowWithMouse) {
if (windowWithMouse != 0) {
pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
sendInput ("l", [windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
}
if (realWindowWithMouse != 0) {
pos = getPositionsFromAbsCoord(lastX, lastY, realWindowWithMouse);
sendInput ("e", [realWindowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
sendInput ("e", [realWindowWithMouse, realWindowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_UNGRAB]);
}
windowWithMouse = realWindowWithMouse;
}
@ -555,7 +555,7 @@ function onMouseDown (ev) {
doGrab (id, false, ev.timeStamp, true);
var button = ev.button + 1;
lastState = lastState | getButtonMask (button);
sendInput ("b", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
sendInput ("b", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
}
function onMouseUp (ev) {
@ -565,7 +565,7 @@ function onMouseUp (ev) {
var pos = getPositionsFromEvent(ev, id);
var button = ev.button + 1;
lastState = lastState & ~getButtonMask (button);
sendInput ("B", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
sendInput ("B", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
if (grab.window != null && grab.implicit)
doUngrab(ev.timeStamp);
@ -613,7 +613,7 @@ function onMouseWheel(ev)
var dir = 0;
if (offset > 0)
dir = 1;
sendInput ("s", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, dir]);
sendInput ("s", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, dir]);
return cancelEvent(ev);
}

View File

@ -168,7 +168,9 @@ process_input_messages (GdkBroadwayDisplay *broadway_display)
static char *
parse_pointer_data (char *p, BroadwayInputPointerMsg *data)
{
data->id = strtol (p, &p, 10);
data->mouse_window_id = strtol (p, &p, 10);
p++; /* Skip , */
data->event_window_id = strtol (p, &p, 10);
p++; /* Skip , */
data->root_x = strtol (p, &p, 10);
p++; /* Skip , */

View File

@ -53,7 +53,8 @@ typedef struct {
typedef struct {
BroadwayInputBaseMsg base;
guint32 id;
guint32 mouse_window_id; /* The real window, not taking grabs into account */
guint32 event_window_id;
int root_x;
int root_y;
int win_x;
@ -118,6 +119,7 @@ struct _GdkBroadwayDisplay
GSource *event_source;
GdkWindow *mouse_in_toplevel;
int last_x, last_y; /* in root coords */
GdkWindow *real_mouse_in_toplevel; /* Not affected by grabs */
/* Keyboard related information */
GdkKeymap *keymap;

View File

@ -106,8 +106,10 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
case 'e': /* Enter */
display_broadway->last_x = message->pointer.root_x;
display_broadway->last_y = message->pointer.root_y;
display_broadway->real_mouse_in_toplevel =
g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.mouse_window_id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id));
/* TODO: Unset when it dies */
display_broadway->mouse_in_toplevel = window;
@ -140,8 +142,10 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
case 'l': /* Leave */
display_broadway->last_x = message->pointer.root_x;
display_broadway->last_y = message->pointer.root_y;
display_broadway->real_mouse_in_toplevel =
g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.mouse_window_id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id));
display_broadway->mouse_in_toplevel = NULL;
if (window)
@ -173,8 +177,10 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
case 'm': /* Mouse move */
display_broadway->last_x = message->pointer.root_x;
display_broadway->last_y = message->pointer.root_y;
display_broadway->real_mouse_in_toplevel =
g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.mouse_window_id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id));
if (window)
{
event = gdk_event_new (GDK_MOTION_NOTIFY);
@ -196,8 +202,10 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
case 'B':
display_broadway->last_x = message->pointer.root_x;
display_broadway->last_y = message->pointer.root_y;
display_broadway->real_mouse_in_toplevel =
g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.mouse_window_id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id));
if (window)
{
event = gdk_event_new (message->base.type == 'b' ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
@ -219,8 +227,10 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
case 's':
display_broadway->last_x = message->pointer.root_x;
display_broadway->last_y = message->pointer.root_y;
display_broadway->real_mouse_in_toplevel =
g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.mouse_window_id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.id));
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id));
if (window)
{
event = gdk_event_new (GDK_SCROLL);