fix issue with sdl touch_ids being out of range
This commit is contained in:
parent
fc71041c3e
commit
b7b41a7bf2
2 changed files with 10 additions and 34 deletions
|
@ -59,7 +59,9 @@ extern "C" {
|
|||
|
||||
static LogScope wl_log("wlserver");
|
||||
|
||||
static struct wlserver_t wlserver = {};
|
||||
static struct wlserver_t wlserver = {
|
||||
.touch_down_ids = {}
|
||||
};
|
||||
|
||||
struct wlserver_content_override {
|
||||
struct wlr_surface *surface;
|
||||
|
@ -70,7 +72,6 @@ struct wlserver_content_override {
|
|||
enum wlserver_touch_click_mode g_nDefaultTouchClickMode = WLSERVER_TOUCH_CLICK_LEFT;
|
||||
enum wlserver_touch_click_mode g_nTouchClickMode = g_nDefaultTouchClickMode;
|
||||
|
||||
static std::set <uint32_t> wlserver_touch_down_ids = {};
|
||||
|
||||
static struct wl_list pending_surfaces = {0};
|
||||
|
||||
|
@ -1113,26 +1114,6 @@ void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time )
|
|||
bump_input_counter();
|
||||
}
|
||||
|
||||
|
||||
void wlserver_capture_touch_down( int touch_id )
|
||||
{
|
||||
if ( wlserver_touch_down_ids.size() < WLSERVER_TOUCH_COUNT )
|
||||
{
|
||||
wlserver_touch_down_ids.insert( touch_id );
|
||||
}
|
||||
}
|
||||
|
||||
void wlserver_release_touch_down( int touch_id )
|
||||
{
|
||||
wlserver_touch_down_ids.erase( touch_id );
|
||||
}
|
||||
|
||||
bool wlserver_touch_is_down( int touch_id )
|
||||
{
|
||||
return wlserver_touch_down_ids.find( touch_id ) != wlserver_touch_down_ids.end();
|
||||
}
|
||||
|
||||
|
||||
void wlserver_touchdown( double x, double y, int touch_id, uint32_t time )
|
||||
{
|
||||
if ( wlserver.mouse_focus_surface != NULL )
|
||||
|
@ -1152,15 +1133,11 @@ void wlserver_touchdown( double x, double y, int touch_id, uint32_t time )
|
|||
wlserver.mouse_surface_cursory = ty;
|
||||
|
||||
if ( g_nTouchClickMode == WLSERVER_TOUCH_CLICK_PASSTHROUGH )
|
||||
{
|
||||
int wlserver_touch_down_count = wlserver_touch_down_ids.size();
|
||||
if (wlserver_touch_down_count >= 0 && wlserver_touch_down_count < WLSERVER_TOUCH_COUNT )
|
||||
{
|
||||
wlr_seat_touch_notify_down( wlserver.wlr.seat, wlserver.mouse_focus_surface, time, touch_id,
|
||||
wlserver.mouse_surface_cursorx, wlserver.mouse_surface_cursory );
|
||||
|
||||
wlserver_capture_touch_down( touch_id );
|
||||
}
|
||||
wlserver.touch_down_ids.insert( touch_id );
|
||||
}
|
||||
else if ( g_nTouchClickMode == WLSERVER_TOUCH_CLICK_DISABLED )
|
||||
{
|
||||
|
@ -1214,11 +1191,10 @@ void wlserver_touchup( int touch_id, uint32_t time )
|
|||
wlr_seat_pointer_notify_frame( wlserver.wlr.seat );
|
||||
}
|
||||
|
||||
int wlserver_touch_down_count = wlserver_touch_down_ids.size();
|
||||
if ( wlserver_touch_down_count >= 0 && wlserver_touch_down_count < WLSERVER_TOUCH_COUNT && wlserver_touch_is_down(touch_id) )
|
||||
if ( wlserver.touch_down_ids.count( touch_id ) > 0 )
|
||||
{
|
||||
wlr_seat_touch_notify_up( wlserver.wlr.seat, time, touch_id );
|
||||
wlserver_release_touch_down( touch_id );
|
||||
wlserver.touch_down_ids.erase( touch_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#define WLSERVER_BUTTON_COUNT 4
|
||||
#define WLSERVER_TOUCH_COUNT 11 // Ten fingers + nose ought to be enough for anyone
|
||||
|
||||
struct _XDisplay;
|
||||
struct xwayland_ctx_t;
|
||||
|
@ -94,7 +94,7 @@ struct wlserver_t {
|
|||
double mouse_surface_cursory;
|
||||
|
||||
bool button_held[ WLSERVER_BUTTON_COUNT ];
|
||||
bool touch_down[ WLSERVER_TOUCH_COUNT ];
|
||||
std::set <uint32_t> touch_down_ids;
|
||||
|
||||
struct {
|
||||
char *name;
|
||||
|
|
Loading…
Reference in a new issue