[broadway] Send and use canvas ids in events

This commit is contained in:
Alexander Larsson 2010-11-20 22:39:40 +01:00
parent d211d78eef
commit 6fe849d4f1
2 changed files with 20 additions and 8 deletions

View File

@ -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()

View File

@ -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)
{