aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-16 17:17:07 +0100
committeremersion <contact@emersion.fr>2017-12-16 17:17:07 +0100
commit9e345f0f98804646f080acde3f576e314f2a73bb (patch)
treed88bcaec7ff92e91c6a65aa5924d7440113e5b3b
parent9310d101bc81da28dbb02aac46a4c8ccb0721436 (diff)
Simplify seat pointer functions
-rw-r--r--types/wlr_data_device.c2
-rw-r--r--types/wlr_seat.c28
2 files changed, 11 insertions, 19 deletions
diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c
index bd7665cf..7cd9c6ba 100644
--- a/types/wlr_data_device.c
+++ b/types/wlr_data_device.c
@@ -728,7 +728,6 @@ static bool seat_client_start_drag(struct wlr_seat_client *client,
// set in the iteration
struct wlr_touch_point *point = NULL;
-
if (is_touch_grab) {
wl_list_for_each(point, &client->seat->touch_state.touch_points, link) {
is_touch_grab = point->surface && point->surface == origin;
@@ -746,7 +745,6 @@ static bool seat_client_start_drag(struct wlr_seat_client *client,
struct wlr_drag_icon *icon =
wlr_drag_icon_create(icon_surface, client, drag->is_pointer_grab,
touch_id);
-
if (!icon) {
free(drag);
return false;
diff --git a/types/wlr_seat.c b/types/wlr_seat.c
index 325c3ab3..2a931241 100644
--- a/types/wlr_seat.c
+++ b/types/wlr_seat.c
@@ -506,11 +506,6 @@ static void pointer_resource_destroy_notify(struct wl_listener *listener,
wlr_seat_pointer_clear_focus(state->seat);
}
-static bool wlr_seat_pointer_has_focus_resource(struct wlr_seat *wlr_seat) {
- return wlr_seat->pointer_state.focused_client &&
- !wl_list_empty(&wlr_seat->pointer_state.focused_client->pointers);
-}
-
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy) {
assert(wlr_seat);
@@ -521,7 +516,6 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
}
struct wlr_seat_client *client = NULL;
-
if (surface) {
struct wl_client *wl_client = wl_resource_get_client(surface->resource);
client = wlr_seat_client_for_wl_client(wlr_seat, wl_client);
@@ -543,7 +537,7 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
}
// enter the current surface
- if (client != NULL) {
+ if (client != NULL && surface != NULL) {
uint32_t serial = wl_display_next_serial(wlr_seat->display);
struct wl_resource *resource;
wl_resource_for_each(resource, &client->pointers) {
@@ -558,7 +552,7 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
wl_list_init(&wlr_seat->pointer_state.surface_destroy.link);
wl_list_remove(&wlr_seat->pointer_state.resource_destroy.link);
wl_list_init(&wlr_seat->pointer_state.resource_destroy.link);
- if (surface) {
+ if (surface != NULL) {
wl_signal_add(&surface->events.destroy,
&wlr_seat->pointer_state.surface_destroy);
wl_resource_add_destroy_listener(surface->resource,
@@ -581,13 +575,13 @@ void wlr_seat_pointer_clear_focus(struct wlr_seat *wlr_seat) {
void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
double sx, double sy) {
- if (!wlr_seat_pointer_has_focus_resource(wlr_seat)) {
+ struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
+ if (client == NULL) {
return;
}
struct wl_resource *resource;
- wl_resource_for_each(resource,
- &wlr_seat->pointer_state.focused_client->pointers) {
+ wl_resource_for_each(resource, &client->pointers) {
wl_pointer_send_motion(resource, time, wl_fixed_from_double(sx),
wl_fixed_from_double(sy));
pointer_send_frame(resource);
@@ -596,14 +590,14 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t button, uint32_t state) {
- if (!wlr_seat_pointer_has_focus_resource(wlr_seat)) {
+ struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
+ if (client == NULL) {
return 0;
}
uint32_t serial = wl_display_next_serial(wlr_seat->display);
struct wl_resource *resource;
- wl_resource_for_each(resource,
- &wlr_seat->pointer_state.focused_client->pointers) {
+ wl_resource_for_each(resource, &client->pointers) {
wl_pointer_send_button(resource, serial, time, button, state);
pointer_send_frame(resource);
}
@@ -612,13 +606,13 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time,
void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
enum wlr_axis_orientation orientation, double value) {
- if (!wlr_seat_pointer_has_focus_resource(wlr_seat)) {
+ struct wlr_seat_client *client = wlr_seat->pointer_state.focused_client;
+ if (client == NULL) {
return;
}
struct wl_resource *resource;
- wl_resource_for_each(resource,
- &wlr_seat->pointer_state.focused_client->pointers) {
+ wl_resource_for_each(resource, &client->pointers) {
if (value) {
wl_pointer_send_axis(resource, time, orientation,
wl_fixed_from_double(value));