broadway: Implement pointer query_status
This commit is contained in:
@ -643,6 +643,24 @@ broadway_output_copy_rectangles (BroadwayOutput *output, int id,
|
||||
free (buf);
|
||||
}
|
||||
|
||||
guint32
|
||||
broadway_output_query_pointer (BroadwayOutput *output, int id)
|
||||
{
|
||||
char buf[HEADER_LEN + 3];
|
||||
guint32 serial;
|
||||
int p;
|
||||
|
||||
serial = output->serial;
|
||||
p = write_header (output, buf, 'q');
|
||||
append_uint16 (id, buf, &p);
|
||||
|
||||
assert (p == sizeof (buf));
|
||||
|
||||
broadway_output_write (output, buf, sizeof (buf));
|
||||
|
||||
return serial;
|
||||
}
|
||||
|
||||
void
|
||||
broadway_output_new_surface(BroadwayOutput *output, int id, int x, int y, int w, int h)
|
||||
{
|
||||
|
||||
@ -55,3 +55,5 @@ void broadway_output_copy_rectangles (BroadwayOutput *output,
|
||||
int n_rects,
|
||||
int dx,
|
||||
int dy);
|
||||
guint32 broadway_output_query_pointer (BroadwayOutput *output,
|
||||
int id);
|
||||
|
||||
@ -64,6 +64,8 @@ function createXHR()
|
||||
}
|
||||
|
||||
var last_serial = 0;
|
||||
var last_x = 0;
|
||||
var last_y = 0;
|
||||
var surfaces = {};
|
||||
var outstanding_commands = new Array();
|
||||
var input_socket = null;
|
||||
@ -240,6 +242,13 @@ function handleCommands(cmd_obj)
|
||||
context.restore();
|
||||
break;
|
||||
|
||||
case 'q': // Query pointer
|
||||
var id = base64_16(cmd, i);
|
||||
i = i + 3;
|
||||
|
||||
send_input ("q", [last_x, last_y]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alert("Unknown op " + command);
|
||||
}
|
||||
@ -284,16 +293,24 @@ function send_input(cmd, args)
|
||||
}
|
||||
}
|
||||
|
||||
function update_positions_from_event(ev) {
|
||||
last_x = ev.pageX;
|
||||
last_y = ev.pageY;
|
||||
}
|
||||
|
||||
function on_mouse_move (ev) {
|
||||
send_input ("m", [get_surface_id(ev), ev.pageX, ev.pageY, ev.timeStamp])
|
||||
update_positions_from_event(ev);
|
||||
send_input ("m", [get_surface_id(ev), last_x, last_y, ev.timeStamp]);
|
||||
}
|
||||
|
||||
function on_mouse_down (ev) {
|
||||
send_input ("b", [get_surface_id(ev), ev.pageX, ev.pageY, ev.button, ev.timeStamp])
|
||||
update_positions_from_event(ev);
|
||||
send_input ("b", [get_surface_id(ev), last_x, last_y, ev.button, ev.timeStamp]);
|
||||
}
|
||||
|
||||
function on_mouse_up (ev) {
|
||||
send_input ("B", [get_surface_id(ev), ev.pageX, ev.pageY, ev.button, ev.timeStamp])
|
||||
update_positions_from_event(ev);
|
||||
send_input ("B", [get_surface_id(ev), last_x, last_y, ev.button, ev.timeStamp]);
|
||||
}
|
||||
|
||||
var last_key_down = 0;
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gdkdevice-broadway.h"
|
||||
|
||||
@ -152,17 +153,87 @@ gdk_broadway_device_query_state (GdkDevice *device,
|
||||
gint *win_y,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
if (root_x)
|
||||
*root_x = 0;
|
||||
if (root_y)
|
||||
*root_y = 0;
|
||||
if (win_x)
|
||||
*win_x = 0;
|
||||
if (win_y)
|
||||
*win_y = 0;
|
||||
GdkDisplay *display;
|
||||
GdkBroadwayDisplay *broadway_display;
|
||||
GdkWindowImplBroadway *impl;
|
||||
guint32 serial;
|
||||
GdkScreen *screen;
|
||||
char *reply;
|
||||
gint device_root_x, device_root_y;
|
||||
|
||||
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
|
||||
return FALSE;
|
||||
|
||||
display = gdk_device_get_display (device);
|
||||
broadway_display = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
if (root_window)
|
||||
{
|
||||
screen = gdk_window_get_screen (window);
|
||||
*root_window = gdk_screen_get_root_window (screen);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
*mask = 0;
|
||||
return FALSE;
|
||||
*mask = 0; /* TODO */
|
||||
|
||||
device_root_x = broadway_display->last_x;
|
||||
device_root_y = broadway_display->last_y;
|
||||
|
||||
if (broadway_display->output)
|
||||
{
|
||||
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
|
||||
|
||||
serial = broadway_output_query_pointer (broadway_display->output, impl->id);
|
||||
|
||||
reply = _gdk_broadway_display_block_for_input (display, 'q', serial);
|
||||
|
||||
if (reply != NULL)
|
||||
{
|
||||
char *p;
|
||||
char cmd;
|
||||
guint32 reply_serial;
|
||||
|
||||
p = reply;
|
||||
|
||||
cmd = *p++;
|
||||
reply_serial = (guint32)strtol(p, &p, 10);
|
||||
p++; /* Skip , */
|
||||
|
||||
device_root_x = strtol(p, &p, 10);
|
||||
p++; /* Skip , */
|
||||
device_root_y = strtol(p, &p, 10);
|
||||
p++; /* Skip , */
|
||||
|
||||
g_free (reply);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fallback when unconnected */
|
||||
|
||||
if (root_x)
|
||||
*root_x = device_root_x;
|
||||
if (root_y)
|
||||
*root_y = device_root_y;
|
||||
if (win_x)
|
||||
*win_x = device_root_y - window->x;
|
||||
if (win_y)
|
||||
*win_y = device_root_y - window->y;
|
||||
if (child_window)
|
||||
{
|
||||
if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT)
|
||||
{
|
||||
*child_window = broadway_display->mouse_in_toplevel;
|
||||
if (*child_window == NULL)
|
||||
*child_window = window;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No native children */
|
||||
*child_window = window;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GdkGrabStatus
|
||||
|
||||
@ -56,7 +56,7 @@ struct _GdkBroadwayDisplay
|
||||
|
||||
GSource *event_source;
|
||||
GdkWindow *mouse_in_toplevel;
|
||||
int last_x, last_y;
|
||||
int last_x, last_y; /* in root coords */
|
||||
|
||||
/* Keyboard related information */
|
||||
GdkKeymap *keymap;
|
||||
|
||||
@ -283,9 +283,12 @@ _gdk_broadway_events_got_input (GdkDisplay *display,
|
||||
_gdk_windowing_got_event (display, node, event, serial);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'q':
|
||||
g_printerr ("Got unexpected query pointer reply w serial %d\n", serial);
|
||||
break;
|
||||
default:
|
||||
g_print ("Unknown input command %s\n", message);
|
||||
g_printerr ("Unknown input command %s\n", message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user