Skip to content

Commit

Permalink
fixed logic for keeping track of touch points
Browse files Browse the repository at this point in the history
  • Loading branch information
gg-rewrite committed Apr 7, 2020
1 parent 1e21b35 commit 585646d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions include/slurp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"

#define TOUCH_ID_EMPTY -1

struct slurp_box {
int32_t x, y;
int32_t width, height;
Expand Down Expand Up @@ -82,8 +84,8 @@ struct slurp_seat {
int32_t anchor_x, anchor_y;
struct slurp_box selection;
bool has_selection;
bool already_touched;
int32_t touch_id;

// pointer:
struct wl_pointer *wl_pointer;
enum wl_pointer_button_state button_state;
Expand Down
15 changes: 9 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ static void touch_handle_down(void *data, struct wl_touch *touch,
struct wl_surface *surface, int32_t id,
wl_fixed_t x, wl_fixed_t y) {
struct slurp_seat *seat = data;
if (!seat->already_touched) {
seat->already_touched = true;
if (seat->touch_id == TOUCH_ID_EMPTY) {
seat->touch_id = id;
seat->current_output =
output_from_surface(seat->state, surface);
move_seat(seat, x, y);
Expand All @@ -246,7 +246,7 @@ static void touch_handle_down(void *data, struct wl_touch *touch,
}

static void touch_clear_state(struct slurp_seat *seat) {
seat->already_touched = false;
seat->touch_id = TOUCH_ID_EMPTY;
seat->current_output = NULL;
}

Expand All @@ -261,9 +261,11 @@ static void touch_handle_motion(void *data, struct wl_touch *touch,
uint32_t time, int32_t id, wl_fixed_t x,
wl_fixed_t y) {
struct slurp_seat *seat = data;
move_seat(seat, x, y);
handle_active_selection_motion(seat);
seat_set_outputs_dirty(seat);
if (seat->touch_id == id) {
move_seat(seat, x, y);
handle_active_selection_motion(seat);
seat_set_outputs_dirty(seat);
}
}

static void touch_handle_cancel(void *data, struct wl_touch *touch) {
Expand Down Expand Up @@ -311,6 +313,7 @@ static void create_seat(struct slurp_state *state, struct wl_seat *wl_seat) {
}
seat->state = state;
seat->wl_seat = wl_seat;
seat->touch_id = TOUCH_ID_EMPTY;
wl_list_insert(&state->seats, &seat->link);
wl_seat_add_listener(wl_seat, &seat_listener, seat);
}
Expand Down

0 comments on commit 585646d

Please sign in to comment.