Rename mousedown to down and make seat operation a named enum

This commit is contained in:
Ryan Dwyer 2018-08-16 09:12:48 +10:00
parent a36625a482
commit b637b61a7a
3 changed files with 18 additions and 17 deletions

View File

@ -35,6 +35,14 @@ struct sway_drag_icon {
struct wl_listener destroy; struct wl_listener destroy;
}; };
enum sway_seat_operation {
OP_NONE,
OP_DOWN,
OP_MOVE,
OP_RESIZE_FLOATING,
OP_RESIZE_TILING,
};
struct sway_seat { struct sway_seat {
struct wlr_seat *wlr_seat; struct wlr_seat *wlr_seat;
struct sway_cursor *cursor; struct sway_cursor *cursor;
@ -54,14 +62,7 @@ struct sway_seat {
double touch_x, touch_y; double touch_x, touch_y;
// Operations (drag and resize) // Operations (drag and resize)
enum { enum sway_seat_operation operation;
OP_NONE,
OP_MOUSEDOWN,
OP_MOVE,
OP_RESIZE_FLOATING,
OP_RESIZE_TILING,
} operation;
struct sway_container *op_container; struct sway_container *op_container;
enum wlr_edges op_resize_edge; enum wlr_edges op_resize_edge;
uint32_t op_button; uint32_t op_button;
@ -158,7 +159,7 @@ bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
void drag_icon_update_position(struct sway_drag_icon *icon); void drag_icon_update_position(struct sway_drag_icon *icon);
void seat_begin_mousedown(struct sway_seat *seat, struct sway_container *con, void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
uint32_t button, double sx, double sy); uint32_t button, double sx, double sy);
void seat_begin_move(struct sway_seat *seat, struct sway_container *con, void seat_begin_move(struct sway_seat *seat, struct sway_container *con,

View File

@ -215,7 +215,7 @@ static enum wlr_edges find_resize_edge(struct sway_container *cont,
return edge; return edge;
} }
static void handle_mousedown_motion(struct sway_seat *seat, static void handle_down_motion(struct sway_seat *seat,
struct sway_cursor *cursor, uint32_t time_msec) { struct sway_cursor *cursor, uint32_t time_msec) {
struct sway_container *con = seat->op_container; struct sway_container *con = seat->op_container;
if (seat_is_input_allowed(seat, con->sway_view->surface)) { if (seat_is_input_allowed(seat, con->sway_view->surface)) {
@ -409,8 +409,8 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
if (seat->operation != OP_NONE) { if (seat->operation != OP_NONE) {
switch (seat->operation) { switch (seat->operation) {
case OP_MOUSEDOWN: case OP_DOWN:
handle_mousedown_motion(seat, cursor, time_msec); handle_down_motion(seat, cursor, time_msec);
break; break;
case OP_MOVE: case OP_MOVE:
handle_move_motion(seat, cursor); handle_move_motion(seat, cursor);
@ -762,7 +762,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
if (surface && cont && state == WLR_BUTTON_PRESSED) { if (surface && cont && state == WLR_BUTTON_PRESSED) {
seat_set_focus(seat, cont); seat_set_focus(seat, cont);
seat_pointer_notify_button(seat, time_msec, button, state); seat_pointer_notify_button(seat, time_msec, button, state);
seat_begin_mousedown(seat, cont, button, sx, sy); seat_begin_down(seat, cont, button, sx, sy);
return; return;
} }

View File

@ -954,9 +954,9 @@ struct seat_config *seat_get_config(struct sway_seat *seat) {
return NULL; return NULL;
} }
void seat_begin_mousedown(struct sway_seat *seat, struct sway_container *con, void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
uint32_t button, double sx, double sy) { uint32_t button, double sx, double sy) {
seat->operation = OP_MOUSEDOWN; seat->operation = OP_DOWN;
seat->op_container = con; seat->op_container = con;
seat->op_button = button; seat->op_button = button;
seat->op_ref_lx = seat->cursor->cursor->x; seat->op_ref_lx = seat->cursor->cursor->x;
@ -1018,7 +1018,7 @@ void seat_begin_resize_tiling(struct sway_seat *seat,
} }
void seat_end_mouse_operation(struct sway_seat *seat) { void seat_end_mouse_operation(struct sway_seat *seat) {
int operation = seat->operation; enum sway_seat_operation operation = seat->operation;
if (seat->operation == OP_MOVE) { if (seat->operation == OP_MOVE) {
// We "move" the container to its own location so it discovers its // We "move" the container to its own location so it discovers its
// output again. // output again.
@ -1027,7 +1027,7 @@ void seat_end_mouse_operation(struct sway_seat *seat) {
} }
seat->operation = OP_NONE; seat->operation = OP_NONE;
seat->op_container = NULL; seat->op_container = NULL;
if (operation == OP_MOUSEDOWN) { if (operation == OP_DOWN) {
// Set the cursor's previous coords to the x/y at the start of the // Set the cursor's previous coords to the x/y at the start of the
// operation, so the container change will be detected if using // operation, so the container change will be detected if using
// focus_follows_mouse and the cursor moved off the original container // focus_follows_mouse and the cursor moved off the original container