static void
button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct clickdot *clickdot = data;
- if (state && button == BTN_LEFT)
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED && button == BTN_LEFT)
input_get_position(input, &clickdot->dot.x, &clickdot->dot.y);
widget_schedule_redraw(widget);
static void
panel_launcher_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct panel_launcher *launcher;
launcher = widget_get_user_data(widget);
widget_schedule_redraw(widget);
- if (state == 0)
+ if (state == WL_POINTER_BUTTON_STATE_RELEASED)
panel_launcher_activate(launcher);
}
static void
panel_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct panel *panel = data;
- if (button == BTN_RIGHT && state)
+ if (button == BTN_RIGHT && state == WL_POINTER_BUTTON_STATE_PRESSED)
show_menu(panel, input, time);
}
static void
unlock_dialog_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct unlock_dialog *dialog = data;
struct desktop *desktop = dialog->desktop;
if (button == BTN_LEFT) {
- if (state == 0 && !dialog->closing) {
+ if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
+ !dialog->closing) {
display_defer(desktop->display, &desktop->unlock_task);
dialog->closing = 1;
}
static void
dnd_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state,
+ void *data)
{
struct dnd *dnd = data;
int32_t x, y;
x -= allocation.x;
y -= allocation.y;
- if (item && state == 1) {
+ if (item && state == WL_POINTER_BUTTON_STATE_PRESSED) {
dnd_drag = malloc(sizeof *dnd_drag);
dnd_drag->dnd = dnd;
dnd_drag->input = input;
*/
static void
button_handler(struct widget *widget, struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state, void *data)
{
int32_t x, y;
return;
input_get_position(input, &x, &y);
- printf("button time: %d, button: %d, state: %d, x: %d, y: %d\n",
- time, button, state, x, y);
+ printf("button time: %d, button: %d, state: %s, x: %d, y: %d\n",
+ time, button,
+ (state == WL_POINTER_BUTTON_STATE_PRESSED) ? "pressed" :
+ "released",
+ x, y);
}
/**
static void
button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state, void *data)
{
struct flower *flower = data;
switch (button) {
case BTN_LEFT:
- if (state)
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
window_move(flower->window, input,
display_get_serial(flower->display));
break;
case BTN_MIDDLE:
- if (state)
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
widget_schedule_redraw(widget);
break;
case BTN_RIGHT:
- if (state)
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
window_show_frame_menu(flower->window, input, time);
break;
}
static void
button_handler(struct widget *widget, struct input *input,
- uint32_t time, uint32_t button, uint32_t state, void *data)
+ uint32_t time, uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct gears *gears = data;
if (button == BTN_LEFT) {
- if (state) {
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
gears->button_down = 1;
input_get_position(input,
&gears->last_x, &gears->last_y);
static void
button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state, void *data)
{
struct resizor *resizor = data;
switch (button) {
case BTN_RIGHT:
- if (state)
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
show_menu(resizor, input, time);
break;
}
static void
lockscreen_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct lockscreen *lockscreen = data;
- if (state && lockscreen->window) {
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED && lockscreen->window) {
window_destroy(lockscreen->window);
lockscreen->window = NULL;
}
static void
button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct terminal *terminal = data;
switch (button) {
case 272:
- if (state) {
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
terminal->dragging = 1;
input_get_position(input,
&terminal->selection_start_x,
static void
button_handler(struct widget *widget, struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state,
+ void *data)
{
struct view *view = data;
- if(!state)
+ if (state == WL_POINTER_BUTTON_STATE_RELEASED)
return;
switch(button) {
static void
frame_button_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button,
+ enum wl_pointer_button_state state, void *data)
{
struct frame_button *frame_button = data;
struct window *window = widget->window;
return;
switch (state) {
- case 1:
+ case WL_POINTER_BUTTON_STATE_PRESSED:
frame_button->state = FRAME_BUTTON_ACTIVE;
widget_schedule_redraw(frame_button->widget);
if (frame_button->type == FRAME_BUTTON_ICON)
window_show_frame_menu(window, input, time);
return;
- case 0:
+ case WL_POINTER_BUTTON_STATE_RELEASED:
frame_button->state = FRAME_BUTTON_DEFAULT;
widget_schedule_redraw(frame_button->widget);
break;
static void
frame_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state,
+ void *data)
{
struct frame *frame = data;
frame->widget->allocation.width,
frame->widget->allocation.height);
- if (window->display->shell && button == BTN_LEFT && state == 1) {
+ if (window->display->shell && button == BTN_LEFT &&
+ state == WL_POINTER_BUTTON_STATE_PRESSED) {
switch (location) {
case THEME_LOCATION_TITLEBAR:
if (!window->shell_surface)
display->serial, location);
break;
}
- } else if (button == BTN_RIGHT && state == 1) {
+ } else if (button == BTN_RIGHT &&
+ state == WL_POINTER_BUTTON_STATE_PRESSED) {
window_show_frame_menu(window, input, time);
}
}
static void
pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
- uint32_t time, uint32_t button, uint32_t state)
+ uint32_t time, uint32_t button, uint32_t state_w)
{
struct input *input = data;
struct widget *widget;
+ enum wl_pointer_button_state state = state_w;
input->display->serial = serial;
- if (input->focus_widget && input->grab == NULL && state)
+ if (input->focus_widget && input->grab == NULL &&
+ state == WL_POINTER_BUTTON_STATE_PRESSED)
input_grab(input, input->focus_widget, button);
widget = input->grab;
button, state,
input->grab->user_data);
- if (input->grab && input->grab_button == button && !state)
+ if (input->grab && input->grab_button == button &&
+ state == WL_POINTER_BUTTON_STATE_RELEASED)
input_ungrab(input);
}
static void
menu_button_handler(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state, void *data)
+ uint32_t button, enum wl_pointer_button_state state,
+ void *data)
{
struct menu *menu = data;
- if (state == 0 && time - menu->time > 500) {
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED &&
+ time - menu->time > 500) {
/* Either relase after press-drag-release or
* click-motion-click. */
menu->func(menu->window->parent,
float x, float y, void *data);
typedef void (*widget_button_handler_t)(struct widget *widget,
struct input *input, uint32_t time,
- uint32_t button, uint32_t state,
+ uint32_t button,
+ enum wl_pointer_button_state state,
void *data);
struct window *
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);
}
}
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
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;
(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);
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);
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:
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:
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);
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);
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;
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);
shsurf->popup.grab.pointer = NULL;
}
- if (state == 0)
+ if (state == WL_POINTER_BUTTON_STATE_RELEASED)
shsurf->popup.initial_up = 1;
}
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);
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)
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);
}
static void
pointer_handle_button(void *data, struct wl_pointer *pointer,
uint32_t serial, uint32_t time, uint32_t button,
- uint32_t state)
+ uint32_t state_w)
{
struct input *input = data;
uint32_t bit;
+ enum wl_pointer_button_state state = state_w;
bit = 1 << (button - BTN_LEFT);
- if (state)
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
input->button_mask |= bit;
else
input->button_mask &= ~bit;