@ -8,6 +8,7 @@
# include <wlr/util/log.h>
# include <wlr/util/log.h>
# include "types/wlr_seat.h"
# include "types/wlr_seat.h"
# include "util/signal.h"
# include "util/signal.h"
# include "util/array.h"
static void default_pointer_enter ( struct wlr_seat_pointer_grab * grab ,
static void default_pointer_enter ( struct wlr_seat_pointer_grab * grab ,
struct wlr_surface * surface , double sx , double sy ) {
struct wlr_surface * surface , double sx , double sy ) {
@ -339,26 +340,32 @@ void wlr_seat_pointer_notify_motion(struct wlr_seat *wlr_seat, uint32_t time,
uint32_t wlr_seat_pointer_notify_button ( struct wlr_seat * wlr_seat ,
uint32_t wlr_seat_pointer_notify_button ( struct wlr_seat * wlr_seat ,
uint32_t time , uint32_t button , enum wlr_button_state state ) {
uint32_t time , uint32_t button , enum wlr_button_state state ) {
clock_gettime ( CLOCK_MONOTONIC , & wlr_seat - > last_event ) ;
clock_gettime ( CLOCK_MONOTONIC , & wlr_seat - > last_event ) ;
struct wlr_seat_pointer_state * pointer_state = & wlr_seat - > pointer_state ;
if ( state = = WLR_BUTTON_PRESSED ) {
if ( state = = WLR_BUTTON_PRESSED ) {
if ( wlr_seat - > pointer_state . button_count = = 0 ) {
if ( pointer_state- > button_count = = 0 ) {
wlr_seat - > pointer_state . grab_button = button ;
pointer_state- > grab_button = button ;
wlr_seat- > pointer_state . grab_time = time ;
pointer_state- > grab_time = time ;
}
}
wlr_seat - > pointer_state . button_count + + ;
set_add ( pointer_state - > buttons , & pointer_state - > button_count ,
WLR_POINTER_BUTTONS_CAP , button ) ;
} else {
} else {
if ( wlr_seat - > pointer_state . button_count = = 0 ) {
set_remove ( pointer_state - > buttons , & pointer_state - > button_count ,
wlr_log ( WLR_ERROR , " Corrupted seat button count " ) ;
WLR_POINTER_BUTTONS_CAP , button ) ;
} else {
wlr_seat - > pointer_state . button_count - - ;
}
}
}
struct wlr_seat_pointer_grab * grab = wlr_seat - > pointer_state . grab ;
struct wlr_seat_pointer_grab * grab = pointer_state - > grab ;
uint32_t serial = grab - > interface - > button ( grab , time , button , state ) ;
uint32_t serial = grab - > interface - > button ( grab , time , button , state ) ;
if ( serial & & wlr_seat - > pointer_state . button_count = = 1 & &
wlr_log ( WLR_DEBUG , " button_count=%zu grab_serial=% " PRIu32 " serial=% " PRIu32 " " ,
pointer_state - > button_count ,
pointer_state - > grab_serial , serial ) ;
if ( serial & & pointer_state - > button_count = = 1 & &
state = = WLR_BUTTON_PRESSED ) {
state = = WLR_BUTTON_PRESSED ) {
wlr_seat - > pointer_state . grab_serial = serial ;
pointer_state- > grab_serial = serial ;
}
}
return serial ;
return serial ;
@ -413,7 +420,7 @@ bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat,
if ( seat - > pointer_state . button_count ! = 1 | |
if ( seat - > pointer_state . button_count ! = 1 | |
seat - > pointer_state . grab_serial ! = serial ) {
seat - > pointer_state . grab_serial ! = serial ) {
wlr_log ( WLR_DEBUG , " Pointer grab serial validation failed: "
wlr_log ( WLR_DEBUG , " Pointer grab serial validation failed: "
" button_count=% " PRIu32 " grab_serial=%" PRIu32 " (got % " PRIu32 " ) " ,
" button_count=% zu grab_serial=%" PRIu32 " (got % " PRIu32 " ) " ,
seat - > pointer_state . button_count ,
seat - > pointer_state . button_count ,
seat - > pointer_state . grab_serial , serial ) ;
seat - > pointer_state . grab_serial , serial ) ;
return false ;
return false ;