mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 11:21:28 +00:00
Replace seatup allows_events with button callback
This commit is contained in:
parent
73605dac2a
commit
fb3475e291
|
@ -9,13 +9,15 @@
|
||||||
struct sway_seat;
|
struct sway_seat;
|
||||||
|
|
||||||
struct sway_seatop_impl {
|
struct sway_seatop_impl {
|
||||||
|
void (*button)(struct sway_seat *seat, uint32_t time_msec,
|
||||||
|
struct wlr_input_device *device, uint32_t button,
|
||||||
|
enum wlr_button_state state);
|
||||||
void (*motion)(struct sway_seat *seat, uint32_t time_msec);
|
void (*motion)(struct sway_seat *seat, uint32_t time_msec);
|
||||||
void (*finish)(struct sway_seat *seat, uint32_t time_msec);
|
void (*finish)(struct sway_seat *seat, uint32_t time_msec);
|
||||||
void (*abort)(struct sway_seat *seat);
|
void (*abort)(struct sway_seat *seat);
|
||||||
void (*unref)(struct sway_seat *seat, struct sway_container *con);
|
void (*unref)(struct sway_seat *seat, struct sway_container *con);
|
||||||
void (*render)(struct sway_seat *seat, struct sway_output *output,
|
void (*render)(struct sway_seat *seat, struct sway_output *output,
|
||||||
pixman_region32_t *damage);
|
pixman_region32_t *damage);
|
||||||
bool allows_events;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sway_seat_device {
|
struct sway_seat_device {
|
||||||
|
@ -214,6 +216,10 @@ void seat_consider_warp_to_focus(struct sway_seat *seat);
|
||||||
|
|
||||||
bool seat_doing_seatop(struct sway_seat *seat);
|
bool seat_doing_seatop(struct sway_seat *seat);
|
||||||
|
|
||||||
|
void seatop_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
|
struct wlr_input_device *device, uint32_t button,
|
||||||
|
enum wlr_button_state state);
|
||||||
|
|
||||||
void seatop_motion(struct sway_seat *seat, uint32_t time_msec);
|
void seatop_motion(struct sway_seat *seat, uint32_t time_msec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,6 +246,4 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con);
|
||||||
void seatop_render(struct sway_seat *seat, struct sway_output *output,
|
void seatop_render(struct sway_seat *seat, struct sway_output *output,
|
||||||
pixman_region32_t *damage);
|
pixman_region32_t *damage);
|
||||||
|
|
||||||
bool seatop_allows_events(struct sway_seat *seat);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -610,9 +610,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
|
||||||
} else {
|
} else {
|
||||||
state_erase_button(cursor, button);
|
state_erase_button(cursor, button);
|
||||||
}
|
}
|
||||||
if (seatop_allows_events(seat)) {
|
seatop_button(seat, time_msec, device, button, state);
|
||||||
seat_pointer_notify_button(seat, time_msec, button, state);
|
|
||||||
}
|
|
||||||
if (button == seat->seatop_button && state == WLR_BUTTON_RELEASED) {
|
if (button == seat->seatop_button && state == WLR_BUTTON_RELEASED) {
|
||||||
seatop_finish(seat, time_msec);
|
seatop_finish(seat, time_msec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1216,6 +1216,14 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void seatop_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
|
struct wlr_input_device *device, uint32_t button,
|
||||||
|
enum wlr_button_state state) {
|
||||||
|
if (seat->seatop_impl && seat->seatop_impl->button) {
|
||||||
|
seat->seatop_impl->button(seat, time_msec, device, button, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void seatop_motion(struct sway_seat *seat, uint32_t time_msec) {
|
void seatop_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
if (seat->seatop_impl && seat->seatop_impl->motion) {
|
if (seat->seatop_impl && seat->seatop_impl->motion) {
|
||||||
seat->seatop_impl->motion(seat, time_msec);
|
seat->seatop_impl->motion(seat, time_msec);
|
||||||
|
@ -1246,7 +1254,3 @@ void seatop_render(struct sway_seat *seat, struct sway_output *output,
|
||||||
seat->seatop_impl->render(seat, output, damage);
|
seat->seatop_impl->render(seat, output, damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool seatop_allows_events(struct sway_seat *seat) {
|
|
||||||
return seat->seatop_impl && seat->seatop_impl->allows_events;
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,6 +11,12 @@ struct seatop_down_event {
|
||||||
bool moved;
|
bool moved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
|
struct wlr_input_device *device, uint32_t button,
|
||||||
|
enum wlr_button_state state) {
|
||||||
|
seat_pointer_notify_button(seat, time_msec, button, state);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
|
static void handle_motion(struct sway_seat *seat, uint32_t time_msec) {
|
||||||
struct seatop_down_event *e = seat->seatop_data;
|
struct seatop_down_event *e = seat->seatop_data;
|
||||||
struct sway_container *con = e->con;
|
struct sway_container *con = e->con;
|
||||||
|
@ -54,11 +60,11 @@ static void handle_unref(struct sway_seat *seat, struct sway_container *con) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct sway_seatop_impl seatop_impl = {
|
static const struct sway_seatop_impl seatop_impl = {
|
||||||
|
.button = handle_button,
|
||||||
.motion = handle_motion,
|
.motion = handle_motion,
|
||||||
.finish = handle_finish,
|
.finish = handle_finish,
|
||||||
.abort = handle_abort,
|
.abort = handle_abort,
|
||||||
.unref = handle_unref,
|
.unref = handle_unref,
|
||||||
.allows_events = true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
|
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
|
||||||
|
|
Loading…
Reference in a new issue