mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-18 06:59:46 -05:00
Move basic grab handling to core libraries
This commit is contained in:
parent
0d8805ea18
commit
5753188e16
3 changed files with 81 additions and 69 deletions
|
|
@ -499,56 +499,6 @@ wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
|
||||||
pointer_images[type].hotspot_y);
|
pointer_images[type].hotspot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
wl_input_device_end_grab(struct wl_input_device *device, uint32_t time);
|
|
||||||
|
|
||||||
static void
|
|
||||||
lose_grab_surface(struct wl_listener *listener,
|
|
||||||
struct wl_surface *surface, uint32_t time)
|
|
||||||
{
|
|
||||||
struct wl_input_device *device =
|
|
||||||
container_of(listener,
|
|
||||||
struct wl_input_device, grab_listener);
|
|
||||||
|
|
||||||
wl_input_device_end_grab(device, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
wl_input_device_start_grab(struct wl_input_device *device,
|
|
||||||
struct wl_grab *grab,
|
|
||||||
uint32_t button, uint32_t time)
|
|
||||||
{
|
|
||||||
struct wl_surface *focus = device->pointer_focus;
|
|
||||||
|
|
||||||
device->grab = grab;
|
|
||||||
device->grab_button = button;
|
|
||||||
device->grab_time = time;
|
|
||||||
device->grab_x = device->x;
|
|
||||||
device->grab_y = device->y;
|
|
||||||
|
|
||||||
device->grab_listener.func = lose_grab_surface;
|
|
||||||
wl_list_insert(focus->destroy_listener_list.prev,
|
|
||||||
&device->grab_listener.link);
|
|
||||||
|
|
||||||
grab->input_device = device;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
wl_input_device_update_grab(struct wl_input_device *device,
|
|
||||||
struct wl_grab *grab,
|
|
||||||
struct wl_surface *surface, uint32_t time)
|
|
||||||
{
|
|
||||||
if (device->grab != &device->motion_grab ||
|
|
||||||
device->grab_time != time ||
|
|
||||||
device->pointer_focus != surface)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
device->grab = grab;
|
|
||||||
grab->input_device = device;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlsc_move_grab {
|
struct wlsc_move_grab {
|
||||||
struct wl_grab grab;
|
struct wl_grab grab;
|
||||||
int32_t dx, dy;
|
int32_t dx, dy;
|
||||||
|
|
@ -933,25 +883,6 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
|
||||||
wlsc_compositor_schedule_repaint(ec);
|
wlsc_compositor_schedule_repaint(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
wl_input_device_end_grab(struct wl_input_device *device, uint32_t time)
|
|
||||||
{
|
|
||||||
struct wlsc_surface *es;
|
|
||||||
const struct wl_grab_interface *interface;
|
|
||||||
int32_t sx, sy;
|
|
||||||
|
|
||||||
interface = device->grab->interface;
|
|
||||||
interface->end(device->grab, time);
|
|
||||||
device->grab->input_device = NULL;
|
|
||||||
device->grab = NULL;
|
|
||||||
|
|
||||||
wl_list_remove(&device->grab_listener.link);
|
|
||||||
es = pick_surface(device, &sx, &sy);
|
|
||||||
wl_input_device_set_pointer_focus(device,
|
|
||||||
&es->surface, time,
|
|
||||||
device->x, device->y, sx, sy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
notify_button(struct wl_input_device *device,
|
notify_button(struct wl_input_device *device,
|
||||||
uint32_t time, int32_t button, int32_t state)
|
uint32_t time, int32_t button, int32_t state)
|
||||||
|
|
|
||||||
|
|
@ -401,6 +401,76 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device,
|
||||||
&device->keyboard_focus_listener.link);
|
&device->keyboard_focus_listener.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_input_device_end_grab(struct wl_input_device *device, uint32_t time)
|
||||||
|
{
|
||||||
|
const struct wl_grab_interface *interface;
|
||||||
|
|
||||||
|
interface = device->grab->interface;
|
||||||
|
interface->end(device->grab, time);
|
||||||
|
device->grab->input_device = NULL;
|
||||||
|
device->grab = NULL;
|
||||||
|
|
||||||
|
wl_list_remove(&device->grab_listener.link);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
struct wlsc_surface *es;
|
||||||
|
int32_t sx, sy;
|
||||||
|
|
||||||
|
es = pick_surface(device, &sx, &sy);
|
||||||
|
wl_input_device_set_pointer_focus(device,
|
||||||
|
&es->surface, time,
|
||||||
|
device->x, device->y, sx, sy);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
lose_grab_surface(struct wl_listener *listener,
|
||||||
|
struct wl_surface *surface, uint32_t time)
|
||||||
|
{
|
||||||
|
struct wl_input_device *device =
|
||||||
|
container_of(listener,
|
||||||
|
struct wl_input_device, grab_listener);
|
||||||
|
|
||||||
|
wl_input_device_end_grab(device, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT void
|
||||||
|
wl_input_device_start_grab(struct wl_input_device *device,
|
||||||
|
struct wl_grab *grab,
|
||||||
|
uint32_t button, uint32_t time)
|
||||||
|
{
|
||||||
|
struct wl_surface *focus = device->pointer_focus;
|
||||||
|
|
||||||
|
device->grab = grab;
|
||||||
|
device->grab_button = button;
|
||||||
|
device->grab_time = time;
|
||||||
|
device->grab_x = device->x;
|
||||||
|
device->grab_y = device->y;
|
||||||
|
|
||||||
|
device->grab_listener.func = lose_grab_surface;
|
||||||
|
wl_list_insert(focus->destroy_listener_list.prev,
|
||||||
|
&device->grab_listener.link);
|
||||||
|
|
||||||
|
grab->input_device = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT int
|
||||||
|
wl_input_device_update_grab(struct wl_input_device *device,
|
||||||
|
struct wl_grab *grab,
|
||||||
|
struct wl_surface *surface, uint32_t time)
|
||||||
|
{
|
||||||
|
if (device->grab != &device->motion_grab ||
|
||||||
|
device->grab_time != time ||
|
||||||
|
device->pointer_focus != surface)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
device->grab = grab;
|
||||||
|
grab->input_device = device;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_sync(struct wl_client *client,
|
display_sync(struct wl_client *client,
|
||||||
struct wl_display *display, uint32_t key)
|
struct wl_display *display, uint32_t key)
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,17 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device,
|
||||||
struct wl_surface *surface,
|
struct wl_surface *surface,
|
||||||
uint32_t time);
|
uint32_t time);
|
||||||
|
|
||||||
|
void
|
||||||
|
wl_input_device_end_grab(struct wl_input_device *device, uint32_t time);
|
||||||
|
void
|
||||||
|
wl_input_device_start_grab(struct wl_input_device *device,
|
||||||
|
struct wl_grab *grab,
|
||||||
|
uint32_t button, uint32_t time);
|
||||||
|
int
|
||||||
|
wl_input_device_update_grab(struct wl_input_device *device,
|
||||||
|
struct wl_grab *grab,
|
||||||
|
struct wl_surface *surface, uint32_t time);
|
||||||
|
|
||||||
int
|
int
|
||||||
wl_compositor_init(struct wl_compositor *compositor,
|
wl_compositor_init(struct wl_compositor *compositor,
|
||||||
const struct wl_compositor_interface *interface,
|
const struct wl_compositor_interface *interface,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue