Wayland: Fix error spam when interacting with decorations

Also tried to make tablet handling a bit tidier (less whitespace).

That said I'll uniform tablet handling better once we're back in the dev
cycle.
This commit is contained in:
Riteo 2024-07-17 12:35:24 +02:00
parent a0943acda1
commit e307fd60d8

View file

@ -2047,6 +2047,11 @@ void WaylandThread::_wp_relative_pointer_on_relative_motion(void *data, struct z
SeatState *ss = (SeatState *)data; SeatState *ss = (SeatState *)data;
ERR_FAIL_NULL(ss); ERR_FAIL_NULL(ss);
if (!ss->pointed_surface) {
// We're probably on a decoration or some other third-party thing.
return;
}
PointerData &pd = ss->pointer_data_buffer; PointerData &pd = ss->pointer_data_buffer;
WindowState *ws = wl_surface_get_window_state(ss->pointed_surface); WindowState *ws = wl_surface_get_window_state(ss->pointed_surface);
@ -2249,13 +2254,11 @@ void WaylandThread::_wp_tablet_tool_on_done(void *data, struct zwp_tablet_tool_v
void WaylandThread::_wp_tablet_tool_on_removed(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2) { void WaylandThread::_wp_tablet_tool_on_removed(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
SeatState *ss = wl_seat_get_seat_state(ts->wl_seat); SeatState *ss = wl_seat_get_seat_state(ts->wl_seat);
if (!ss) { if (!ss) {
return; return;
} }
@ -2275,14 +2278,17 @@ void WaylandThread::_wp_tablet_tool_on_removed(void *data, struct zwp_tablet_too
} }
void WaylandThread::_wp_tablet_tool_on_proximity_in(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t serial, struct zwp_tablet_v2 *tablet, struct wl_surface *surface) { void WaylandThread::_wp_tablet_tool_on_proximity_in(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t serial, struct zwp_tablet_v2 *tablet, struct wl_surface *surface) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); if (!surface || !wl_proxy_is_godot((struct wl_proxy *)surface)) {
// We're probably on a decoration or something.
return;
}
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
SeatState *ss = wl_seat_get_seat_state(ts->wl_seat); SeatState *ss = wl_seat_get_seat_state(ts->wl_seat);
if (!ss) { if (!ss) {
return; return;
} }
@ -2304,13 +2310,12 @@ void WaylandThread::_wp_tablet_tool_on_proximity_in(void *data, struct zwp_table
void WaylandThread::_wp_tablet_tool_on_proximity_out(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2) { void WaylandThread::_wp_tablet_tool_on_proximity_out(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts || !ts->data_pending.proximal_surface) {
if (!ts) { // Not our stuff, we don't care.
return; return;
} }
SeatState *ss = wl_seat_get_seat_state(ts->wl_seat); SeatState *ss = wl_seat_get_seat_state(ts->wl_seat);
if (!ss) { if (!ss) {
return; return;
} }
@ -2331,7 +2336,6 @@ void WaylandThread::_wp_tablet_tool_on_proximity_out(void *data, struct zwp_tabl
void WaylandThread::_wp_tablet_tool_on_down(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t serial) { void WaylandThread::_wp_tablet_tool_on_down(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t serial) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
@ -2349,7 +2353,6 @@ void WaylandThread::_wp_tablet_tool_on_down(void *data, struct zwp_tablet_tool_v
void WaylandThread::_wp_tablet_tool_on_up(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2) { void WaylandThread::_wp_tablet_tool_on_up(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
@ -2365,11 +2368,15 @@ void WaylandThread::_wp_tablet_tool_on_up(void *data, struct zwp_tablet_tool_v2
void WaylandThread::_wp_tablet_tool_on_motion(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, wl_fixed_t x, wl_fixed_t y) { void WaylandThread::_wp_tablet_tool_on_motion(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, wl_fixed_t x, wl_fixed_t y) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
if (!ts->data_pending.proximal_surface) {
// We're probably on a decoration or some other third-party thing.
return;
}
WindowState *ws = wl_surface_get_window_state(ts->data_pending.proximal_surface); WindowState *ws = wl_surface_get_window_state(ts->data_pending.proximal_surface);
ERR_FAIL_NULL(ws); ERR_FAIL_NULL(ws);
@ -2386,7 +2393,6 @@ void WaylandThread::_wp_tablet_tool_on_motion(void *data, struct zwp_tablet_tool
void WaylandThread::_wp_tablet_tool_on_pressure(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t pressure) { void WaylandThread::_wp_tablet_tool_on_pressure(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t pressure) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
@ -2400,7 +2406,6 @@ void WaylandThread::_wp_tablet_tool_on_distance(void *data, struct zwp_tablet_to
void WaylandThread::_wp_tablet_tool_on_tilt(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, wl_fixed_t tilt_x, wl_fixed_t tilt_y) { void WaylandThread::_wp_tablet_tool_on_tilt(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, wl_fixed_t tilt_x, wl_fixed_t tilt_y) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
@ -2425,7 +2430,6 @@ void WaylandThread::_wp_tablet_tool_on_wheel(void *data, struct zwp_tablet_tool_
void WaylandThread::_wp_tablet_tool_on_button(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t serial, uint32_t button, uint32_t state) { void WaylandThread::_wp_tablet_tool_on_button(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t serial, uint32_t button, uint32_t state) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
@ -2461,13 +2465,11 @@ void WaylandThread::_wp_tablet_tool_on_button(void *data, struct zwp_tablet_tool
void WaylandThread::_wp_tablet_tool_on_frame(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t time) { void WaylandThread::_wp_tablet_tool_on_frame(void *data, struct zwp_tablet_tool_v2 *wp_tablet_tool_v2, uint32_t time) {
TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2); TabletToolState *ts = wp_tablet_tool_get_state(wp_tablet_tool_v2);
if (!ts) { if (!ts) {
return; return;
} }
SeatState *ss = wl_seat_get_seat_state(ts->wl_seat); SeatState *ss = wl_seat_get_seat_state(ts->wl_seat);
if (!ss) { if (!ss) {
return; return;
} }