mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 07:04:29 +00:00
[broadway] Send and use canvas ids in events
This commit is contained in:
parent
d211d78eef
commit
6fe849d4f1
@ -93,8 +93,9 @@ function apply_delta(id, img, x, y)
|
|||||||
delete tmp_surface
|
delete tmp_surface
|
||||||
}
|
}
|
||||||
|
|
||||||
function initContext(canvas, x, y)
|
function initContext(canvas, x, y, id)
|
||||||
{
|
{
|
||||||
|
canvas.surface_id = id;
|
||||||
canvas.style["position"] = "absolute"
|
canvas.style["position"] = "absolute"
|
||||||
canvas.style["top"] = x + "px"
|
canvas.style["top"] = x + "px"
|
||||||
canvas.style["left"] = y + "px"
|
canvas.style["left"] = y + "px"
|
||||||
@ -130,7 +131,7 @@ function handleCommands(cmd_obj)
|
|||||||
var surface = document.createElement("canvas");
|
var surface = document.createElement("canvas");
|
||||||
surface.width = w;
|
surface.width = w;
|
||||||
surface.height = h;
|
surface.height = h;
|
||||||
surfaces[id] = initContext(surface, x, y);
|
surfaces[id] = initContext(surface, x, y, id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* show a surface */
|
/* 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)
|
function send_input(cmd, args)
|
||||||
{
|
{
|
||||||
if (input_socket != null) {
|
if (input_socket != null) {
|
||||||
@ -304,15 +312,15 @@ function send_input(cmd, args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function on_mouse_move (ev) {
|
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) {
|
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) {
|
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()
|
function connect()
|
||||||
|
@ -181,7 +181,7 @@ got_input (GInputStream *stream,
|
|||||||
char *message, *p;
|
char *message, *p;
|
||||||
gsize len;
|
gsize len;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
int x, y, button;
|
int x, y, button, id;
|
||||||
guint64 time;
|
guint64 time;
|
||||||
GdkEvent *event = NULL;
|
GdkEvent *event = NULL;
|
||||||
char cmd;
|
char cmd;
|
||||||
@ -204,13 +204,15 @@ got_input (GInputStream *stream,
|
|||||||
cmd = *p++;
|
cmd = *p++;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 'm':
|
case 'm':
|
||||||
|
id = strtol(p, &p, 10);
|
||||||
|
p++; /* Skip , */
|
||||||
x = strtol(p, &p, 10);
|
x = strtol(p, &p, 10);
|
||||||
p++; /* Skip , */
|
p++; /* Skip , */
|
||||||
y = strtol(p, &p, 10);
|
y = strtol(p, &p, 10);
|
||||||
p++; /* Skip , */
|
p++; /* Skip , */
|
||||||
time = strtol(p, &p, 10);
|
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)
|
if (display_broadway->mouse_in_toplevel != window)
|
||||||
{
|
{
|
||||||
@ -287,6 +289,8 @@ got_input (GInputStream *stream,
|
|||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'B':
|
case 'B':
|
||||||
|
id = strtol(p, &p, 10);
|
||||||
|
p++; /* Skip , */
|
||||||
x = strtol(p, &p, 10);
|
x = strtol(p, &p, 10);
|
||||||
p++; /* Skip , */
|
p++; /* Skip , */
|
||||||
y = strtol(p, &p, 10);
|
y = strtol(p, &p, 10);
|
||||||
@ -295,7 +299,7 @@ got_input (GInputStream *stream,
|
|||||||
p++; /* Skip , */
|
p++; /* Skip , */
|
||||||
time = strtol(p, &p, 10);
|
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)
|
if (window)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user