mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:21:57 +00:00
[client] wayland: make input handlers aware of multiple surfaces
This prevents input handlers from breaking in presence of subsurfaces, which are used by libdecor for client-side decorations.
This commit is contained in:
parent
d6a290a31d
commit
ba3243f88a
2 changed files with 24 additions and 0 deletions
|
@ -46,6 +46,10 @@ static void pointerEnterHandler(void * data, struct wl_pointer * pointer,
|
||||||
uint32_t serial, struct wl_surface * surface, wl_fixed_t sxW,
|
uint32_t serial, struct wl_surface * surface, wl_fixed_t sxW,
|
||||||
wl_fixed_t syW)
|
wl_fixed_t syW)
|
||||||
{
|
{
|
||||||
|
if (surface != wlWm.surface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlWm.pointerInSurface = true;
|
||||||
app_handleEnterEvent(true);
|
app_handleEnterEvent(true);
|
||||||
|
|
||||||
wl_pointer_set_cursor(pointer, serial, wlWm.showPointer ? wlWm.cursor : NULL, 0, 0);
|
wl_pointer_set_cursor(pointer, serial, wlWm.showPointer ? wlWm.cursor : NULL, 0, 0);
|
||||||
|
@ -71,6 +75,10 @@ static void pointerEnterHandler(void * data, struct wl_pointer * pointer,
|
||||||
static void pointerLeaveHandler(void * data, struct wl_pointer * pointer,
|
static void pointerLeaveHandler(void * data, struct wl_pointer * pointer,
|
||||||
uint32_t serial, struct wl_surface * surface)
|
uint32_t serial, struct wl_surface * surface)
|
||||||
{
|
{
|
||||||
|
if (surface != wlWm.surface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlWm.pointerInSurface = false;
|
||||||
app_handleEnterEvent(false);
|
app_handleEnterEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +161,10 @@ static void keyboardKeymapHandler(void * data, struct wl_keyboard * keyboard,
|
||||||
static void keyboardEnterHandler(void * data, struct wl_keyboard * keyboard,
|
static void keyboardEnterHandler(void * data, struct wl_keyboard * keyboard,
|
||||||
uint32_t serial, struct wl_surface * surface, struct wl_array * keys)
|
uint32_t serial, struct wl_surface * surface, struct wl_array * keys)
|
||||||
{
|
{
|
||||||
|
if (surface != wlWm.surface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlWm.focusedOnSurface = true;
|
||||||
app_handleFocusEvent(true);
|
app_handleFocusEvent(true);
|
||||||
wlWm.keyboardEnterSerial = serial;
|
wlWm.keyboardEnterSerial = serial;
|
||||||
|
|
||||||
|
@ -164,12 +176,19 @@ static void keyboardEnterHandler(void * data, struct wl_keyboard * keyboard,
|
||||||
static void keyboardLeaveHandler(void * data, struct wl_keyboard * keyboard,
|
static void keyboardLeaveHandler(void * data, struct wl_keyboard * keyboard,
|
||||||
uint32_t serial, struct wl_surface * surface)
|
uint32_t serial, struct wl_surface * surface)
|
||||||
{
|
{
|
||||||
|
if (surface != wlWm.surface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wlWm.focusedOnSurface = false;
|
||||||
app_handleFocusEvent(false);
|
app_handleFocusEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboardKeyHandler(void * data, struct wl_keyboard * keyboard,
|
static void keyboardKeyHandler(void * data, struct wl_keyboard * keyboard,
|
||||||
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
|
||||||
{
|
{
|
||||||
|
if (!wlWm.focusedOnSurface)
|
||||||
|
return;
|
||||||
|
|
||||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||||
app_handleKeyPress(key);
|
app_handleKeyPress(key);
|
||||||
else
|
else
|
||||||
|
@ -358,6 +377,9 @@ void waylandUngrabKeyboard(void)
|
||||||
|
|
||||||
void waylandWarpPointer(int x, int y, bool exiting)
|
void waylandWarpPointer(int x, int y, bool exiting)
|
||||||
{
|
{
|
||||||
|
if (!wlWm.pointerInSurface)
|
||||||
|
return;
|
||||||
|
|
||||||
if (x < 0) x = 0;
|
if (x < 0) x = 0;
|
||||||
else if (x >= wlWm.width) x = wlWm.width - 1;
|
else if (x >= wlWm.width) x = wlWm.width - 1;
|
||||||
if (y < 0) y = 0;
|
if (y < 0) y = 0;
|
||||||
|
|
|
@ -70,6 +70,8 @@ struct WaylandDSState
|
||||||
{
|
{
|
||||||
bool pointerGrabbed;
|
bool pointerGrabbed;
|
||||||
bool keyboardGrabbed;
|
bool keyboardGrabbed;
|
||||||
|
bool pointerInSurface;
|
||||||
|
bool focusedOnSurface;
|
||||||
|
|
||||||
struct wl_display * display;
|
struct wl_display * display;
|
||||||
struct wl_surface * surface;
|
struct wl_surface * surface;
|
||||||
|
|
Loading…
Reference in a new issue