mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
Add key_state and button_state enums
Rather than hardcoding 0 and 1 everywhere. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
9a1705c5f5
commit
872d074a43
3 changed files with 30 additions and 6 deletions
|
|
@ -818,6 +818,15 @@
|
|||
<arg name="surface_y" type="fixed"/>
|
||||
</event>
|
||||
|
||||
<enum name="button_state">
|
||||
<description summary="physical button state">
|
||||
Describes the physical state of a button which provoked the button
|
||||
event.
|
||||
</description>
|
||||
<entry name="released" value="0" summary="button is not pressed"/>
|
||||
<entry name="pressed" value="1" summary="button is pressed"/>
|
||||
</enum>
|
||||
|
||||
<event name="button">
|
||||
<description summary="pointer button event">
|
||||
Mouse button click and release notifications. The location
|
||||
|
|
@ -862,6 +871,16 @@
|
|||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
</event>
|
||||
|
||||
<enum name="key_state">
|
||||
<description summary="physical key state">
|
||||
Describes the physical state of a key which provoked the key event.
|
||||
When a key repeats, the sequence is down -> repeat -> repeat -> up.
|
||||
</description>
|
||||
<entry name="released" value="0" summary="key is not pressed"/>
|
||||
<entry name="pressed" value="1" summary="key is pressed"/>
|
||||
<entry name="repeat" value="2" summary="key is pressed and repeating"/>
|
||||
</enum>
|
||||
|
||||
<event name="key">
|
||||
<description summary="key event">
|
||||
A key was pressed or released.
|
||||
|
|
|
|||
|
|
@ -260,15 +260,18 @@ data_device_end_drag_grab(struct wl_seat *seat)
|
|||
|
||||
static void
|
||||
drag_grab_button(struct wl_pointer_grab *grab,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
uint32_t time, uint32_t button, uint32_t state_w)
|
||||
{
|
||||
struct wl_seat *seat = container_of(grab, struct wl_seat, drag_grab);
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
if (seat->drag_focus_resource &&
|
||||
seat->pointer->grab_button == button && state == 0)
|
||||
seat->pointer->grab_button == button &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED)
|
||||
wl_data_device_send_drop(seat->drag_focus_resource);
|
||||
|
||||
if (seat->pointer->button_count == 0 && state == 0) {
|
||||
if (seat->pointer->button_count == 0 &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
data_device_end_drag_grab(seat);
|
||||
if (seat->drag_data_source)
|
||||
wl_list_remove(&seat->drag_data_source_listener.link);
|
||||
|
|
|
|||
|
|
@ -493,19 +493,21 @@ default_grab_motion(struct wl_pointer_grab *grab,
|
|||
|
||||
static void
|
||||
default_grab_button(struct wl_pointer_grab *grab,
|
||||
uint32_t time, uint32_t button, uint32_t state)
|
||||
uint32_t time, uint32_t button, uint32_t state_w)
|
||||
{
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
struct wl_resource *resource;
|
||||
uint32_t serial;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
resource = pointer->focus_resource;
|
||||
if (resource) {
|
||||
serial = wl_display_next_serial(resource->client->display);
|
||||
wl_pointer_send_button(resource, serial, time, button, state);
|
||||
wl_pointer_send_button(resource, serial, time, button, state_w);
|
||||
}
|
||||
|
||||
if (pointer->button_count == 0 && state == 0)
|
||||
if (pointer->button_count == 0 &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED)
|
||||
wl_pointer_set_focus(pointer, pointer->current,
|
||||
pointer->current_x, pointer->current_y);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue