Use enum wl_pointer_button_state instead of integer
Instead of using a uint32_t for state everywhere (except on the wire, where that's still the call signature), use the new wl_pointer_button_state enum, and explicit comparisons. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
11d7139989
commit
4dbadb1556
@@ -547,10 +547,12 @@ input_handle_motion(void *data, struct wl_pointer *pointer,
|
||||
|
||||
static void
|
||||
input_handle_button(void *data, struct wl_pointer *pointer,
|
||||
uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
|
||||
uint32_t serial, uint32_t time, uint32_t button,
|
||||
uint32_t state_w)
|
||||
{
|
||||
struct wayland_input *input = data;
|
||||
struct wayland_compositor *c = input->compositor;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
notify_button(&c->base.seat->seat, time, button, state);
|
||||
}
|
||||
|
||||
@@ -525,7 +525,9 @@ x11_compositor_deliver_button_event(struct x11_compositor *c,
|
||||
}
|
||||
|
||||
notify_button(&c->base.seat->seat,
|
||||
weston_compositor_get_time(), button, state);
|
||||
weston_compositor_get_time(), button,
|
||||
state ? WL_POINTER_BUTTON_STATE_PRESSED :
|
||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
+2
-2
@@ -1668,7 +1668,7 @@ weston_surface_activate(struct weston_surface *surface,
|
||||
|
||||
WL_EXPORT void
|
||||
notify_button(struct wl_seat *seat, uint32_t time, int32_t button,
|
||||
uint32_t state)
|
||||
enum wl_pointer_button_state state)
|
||||
{
|
||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||
struct weston_compositor *compositor = ws->compositor;
|
||||
@@ -1676,7 +1676,7 @@ notify_button(struct wl_seat *seat, uint32_t time, int32_t button,
|
||||
(struct weston_surface *) seat->pointer->focus;
|
||||
uint32_t serial = wl_display_next_serial(compositor->wl_display);
|
||||
|
||||
if (state) {
|
||||
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
if (compositor->ping_handler && focus)
|
||||
compositor->ping_handler(focus, serial);
|
||||
weston_compositor_idle_inhibit(compositor);
|
||||
|
||||
+1
-1
@@ -478,7 +478,7 @@ notify_motion(struct wl_seat *seat, uint32_t time,
|
||||
wl_fixed_t x, wl_fixed_t y);
|
||||
void
|
||||
notify_button(struct wl_seat *seat, uint32_t time, int32_t button,
|
||||
uint32_t state);
|
||||
enum wl_pointer_button_state state);
|
||||
void
|
||||
notify_axis(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
||||
int32_t value);
|
||||
|
||||
@@ -444,7 +444,9 @@ process_key(struct touchpad_dispatch *touchpad,
|
||||
case BTN_BACK:
|
||||
case BTN_TASK:
|
||||
notify_button(&device->master->base.seat,
|
||||
time, e->code, e->value);
|
||||
time, e->code,
|
||||
e->value ? WL_POINTER_BUTTON_STATE_PRESSED :
|
||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
||||
break;
|
||||
case BTN_TOOL_PEN:
|
||||
case BTN_TOOL_RUBBER:
|
||||
|
||||
+3
-1
@@ -79,7 +79,9 @@ evdev_process_key(struct evdev_input_device *device,
|
||||
case BTN_BACK:
|
||||
case BTN_TASK:
|
||||
notify_button(&device->master->base.seat,
|
||||
time, e->code, e->value);
|
||||
time, e->code,
|
||||
e->value ? WL_POINTER_BUTTON_STATE_PRESSED :
|
||||
WL_POINTER_BUTTON_STATE_RELEASED);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+21
-11
@@ -335,13 +335,15 @@ move_grab_motion(struct wl_pointer_grab *grab,
|
||||
|
||||
static void
|
||||
move_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 shell_grab *shell_grab = container_of(grab, struct shell_grab,
|
||||
grab);
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
if (pointer->button_count == 0 && state == 0) {
|
||||
if (pointer->button_count == 0 &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
shell_grab_finish(shell_grab);
|
||||
wl_pointer_end_grab(pointer);
|
||||
free(grab);
|
||||
@@ -608,12 +610,14 @@ static const struct weston_shell_client shell_client = {
|
||||
|
||||
static void
|
||||
resize_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 weston_resize_grab *resize = (struct weston_resize_grab *) grab;
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
if (pointer->button_count == 0 && state == 0) {
|
||||
if (pointer->button_count == 0 &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
shell_grab_finish(&resize->base);
|
||||
wl_pointer_end_grab(pointer);
|
||||
free(grab);
|
||||
@@ -1097,12 +1101,13 @@ popup_grab_motion(struct wl_pointer_grab *grab,
|
||||
|
||||
static void
|
||||
popup_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_resource *resource;
|
||||
struct shell_surface *shsurf =
|
||||
container_of(grab, struct shell_surface, popup.grab);
|
||||
struct wl_display *display;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
uint32_t serial;
|
||||
|
||||
resource = grab->pointer->focus_resource;
|
||||
@@ -1110,7 +1115,7 @@ popup_grab_button(struct wl_pointer_grab *grab,
|
||||
display = wl_client_get_display(resource->client);
|
||||
serial = wl_display_get_serial(display);
|
||||
wl_pointer_send_button(resource, serial, time, button, state);
|
||||
} else if (state == 0 &&
|
||||
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
|
||||
(shsurf->popup.initial_up ||
|
||||
time - shsurf->popup.seat->pointer->grab_time > 500)) {
|
||||
wl_shell_surface_send_popup_done(&shsurf->resource);
|
||||
@@ -1118,7 +1123,7 @@ popup_grab_button(struct wl_pointer_grab *grab,
|
||||
shsurf->popup.grab.pointer = NULL;
|
||||
}
|
||||
|
||||
if (state == 0)
|
||||
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
|
||||
shsurf->popup.initial_up = 1;
|
||||
}
|
||||
|
||||
@@ -1776,14 +1781,16 @@ rotate_grab_motion(struct wl_pointer_grab *grab,
|
||||
|
||||
static void
|
||||
rotate_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 rotate_grab *rotate =
|
||||
container_of(grab, struct rotate_grab, base.grab);
|
||||
struct wl_pointer *pointer = grab->pointer;
|
||||
struct shell_surface *shsurf = rotate->base.shsurf;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
if (pointer->button_count == 0 && state == 0) {
|
||||
if (pointer->button_count == 0 &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
if (shsurf)
|
||||
weston_matrix_multiply(&shsurf->rotation.rotation,
|
||||
&rotate->rotation);
|
||||
@@ -1931,12 +1938,14 @@ is_black_surface (struct weston_surface *es, struct weston_surface **fs_surface)
|
||||
static void
|
||||
click_to_activate_binding(struct wl_seat *seat,
|
||||
uint32_t time, uint32_t key,
|
||||
uint32_t button, uint32_t axis, int32_t state, void *data)
|
||||
uint32_t button, uint32_t axis, int32_t state_w,
|
||||
void *data)
|
||||
{
|
||||
struct weston_seat *ws = (struct weston_seat *) seat;
|
||||
struct desktop_shell *shell = data;
|
||||
struct weston_surface *focus;
|
||||
struct weston_surface *upper;
|
||||
enum wl_pointer_button_state state = state_w;
|
||||
|
||||
focus = (struct weston_surface *) seat->pointer->focus;
|
||||
if (!focus)
|
||||
@@ -1945,7 +1954,8 @@ click_to_activate_binding(struct wl_seat *seat,
|
||||
if (is_black_surface(focus, &upper))
|
||||
focus = upper;
|
||||
|
||||
if (state && seat->pointer->grab == &seat->pointer->default_grab)
|
||||
if (state == WL_POINTER_BUTTON_STATE_PRESSED &&
|
||||
seat->pointer->grab == &seat->pointer->default_grab)
|
||||
activate(shell, focus, ws);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user