mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[client] ds: detect when the cursor exits into an overlapping window
This adds a new method to the display server interface to allow the application to notify the ds when there is a guest cursor position update along with the translated local guest cursor position. This makes it possible for the display server to keep the local cursor position in sync with the guest cursor so that window leave events can be detected when the cursor would move into an overlapping window. Wayland currently just has a stub for this, and the X11 implementation still needs some minor tweaking.
This commit is contained in:
@@ -106,3 +106,7 @@ void waylandShowPointer(bool show)
|
||||
wlWm.showPointer = show;
|
||||
wl_pointer_set_cursor(wlWm.pointer, wlWm.pointerEnterSerial, show ? wlWm.cursor : NULL, 0, 0);
|
||||
}
|
||||
|
||||
void waylandGuestPointerUpdated(double x, double y, int localX, int localY)
|
||||
{
|
||||
}
|
||||
|
@@ -138,43 +138,43 @@ static bool waylandGetProp(LG_DSProperty prop, void * ret)
|
||||
|
||||
struct LG_DisplayServerOps LGDS_Wayland =
|
||||
{
|
||||
.setup = waylandSetup,
|
||||
.probe = waylandProbe,
|
||||
.earlyInit = waylandEarlyInit,
|
||||
.init = waylandInit,
|
||||
.startup = waylandStartup,
|
||||
.shutdown = waylandShutdown,
|
||||
.free = waylandFree,
|
||||
.getProp = waylandGetProp,
|
||||
.setup = waylandSetup,
|
||||
.probe = waylandProbe,
|
||||
.earlyInit = waylandEarlyInit,
|
||||
.init = waylandInit,
|
||||
.startup = waylandStartup,
|
||||
.shutdown = waylandShutdown,
|
||||
.free = waylandFree,
|
||||
.getProp = waylandGetProp,
|
||||
|
||||
#ifdef ENABLE_EGL
|
||||
.getEGLDisplay = waylandGetEGLDisplay,
|
||||
.getEGLNativeWindow = waylandGetEGLNativeWindow,
|
||||
.eglSwapBuffers = waylandEGLSwapBuffers,
|
||||
.getEGLDisplay = waylandGetEGLDisplay,
|
||||
.getEGLNativeWindow = waylandGetEGLNativeWindow,
|
||||
.eglSwapBuffers = waylandEGLSwapBuffers,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_OPENGL
|
||||
.glCreateContext = waylandGLCreateContext,
|
||||
.glDeleteContext = waylandGLDeleteContext,
|
||||
.glMakeCurrent = waylandGLMakeCurrent,
|
||||
.glSetSwapInterval = waylandGLSetSwapInterval,
|
||||
.glSwapBuffers = waylandGLSwapBuffers,
|
||||
.glCreateContext = waylandGLCreateContext,
|
||||
.glDeleteContext = waylandGLDeleteContext,
|
||||
.glMakeCurrent = waylandGLMakeCurrent,
|
||||
.glSetSwapInterval = waylandGLSetSwapInterval,
|
||||
.glSwapBuffers = waylandGLSwapBuffers,
|
||||
#endif
|
||||
|
||||
.showPointer = waylandShowPointer,
|
||||
.grabPointer = waylandGrabPointer,
|
||||
.ungrabPointer = waylandUngrabPointer,
|
||||
.grabKeyboard = waylandGrabKeyboard,
|
||||
.ungrabKeyboard = waylandUngrabKeyboard,
|
||||
.warpPointer = waylandWarpPointer,
|
||||
.realignPointer = waylandRealignPointer,
|
||||
.isValidPointerPos = waylandIsValidPointerPos,
|
||||
.inhibitIdle = waylandInhibitIdle,
|
||||
.uninhibitIdle = waylandUninhibitIdle,
|
||||
.wait = waylandWait,
|
||||
.setWindowSize = waylandSetWindowSize,
|
||||
.setFullscreen = waylandSetFullscreen,
|
||||
.getFullscreen = waylandGetFullscreen,
|
||||
.guestPointerUpdated = waylandGuestPointerUpdated,
|
||||
.showPointer = waylandShowPointer,
|
||||
.grabPointer = waylandGrabPointer,
|
||||
.ungrabPointer = waylandUngrabPointer,
|
||||
.grabKeyboard = waylandGrabKeyboard,
|
||||
.ungrabKeyboard = waylandUngrabKeyboard,
|
||||
.warpPointer = waylandWarpPointer,
|
||||
.realignPointer = waylandRealignPointer,
|
||||
.isValidPointerPos = waylandIsValidPointerPos,
|
||||
.inhibitIdle = waylandInhibitIdle,
|
||||
.uninhibitIdle = waylandUninhibitIdle,
|
||||
.wait = waylandWait,
|
||||
.setWindowSize = waylandSetWindowSize,
|
||||
.setFullscreen = waylandSetFullscreen,
|
||||
.getFullscreen = waylandGetFullscreen,
|
||||
|
||||
.cbInit = waylandCBInit,
|
||||
.cbNotice = waylandCBNotice,
|
||||
|
@@ -190,6 +190,7 @@ void waylandCBRelease(void);
|
||||
// cursor module
|
||||
bool waylandCursorInit(void);
|
||||
void waylandCursorFree(void);
|
||||
void waylandGuestPointerUpdated(double x, double y, int localX, int localY);
|
||||
void waylandShowPointer(bool show);
|
||||
|
||||
// gl module
|
||||
|
@@ -41,6 +41,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/time.h"
|
||||
|
||||
#define _NET_WM_STATE_REMOVE 0
|
||||
#define _NET_WM_STATE_ADD 1
|
||||
@@ -105,7 +106,8 @@ static bool x11Init(const LG_DSInitParams params)
|
||||
.event_mask =
|
||||
StructureNotifyMask |
|
||||
PropertyChangeMask |
|
||||
ExposureMask
|
||||
ExposureMask |
|
||||
PointerMotionMask
|
||||
};
|
||||
unsigned long swaMask = CWEventMask;
|
||||
|
||||
@@ -677,6 +679,8 @@ static int x11EventThread(void * unused)
|
||||
|
||||
static void x11GenericEvent(XGenericEventCookie *cookie)
|
||||
{
|
||||
static int button_state = 0;
|
||||
|
||||
if (cookie->extension != x11.xinputOp)
|
||||
return;
|
||||
|
||||
@@ -718,10 +722,10 @@ static void x11GenericEvent(XGenericEventCookie *cookie)
|
||||
|
||||
case XI_Enter:
|
||||
{
|
||||
if (x11.entered)
|
||||
XIEnterEvent *xie = cookie->data;
|
||||
if (x11.entered || xie->event != x11.window)
|
||||
return;
|
||||
|
||||
XIEnterEvent *xie = cookie->data;
|
||||
app_updateCursorPos(xie->event_x, xie->event_y);
|
||||
app_handleEnterEvent(true);
|
||||
x11.entered = true;
|
||||
@@ -730,10 +734,11 @@ static void x11GenericEvent(XGenericEventCookie *cookie)
|
||||
|
||||
case XI_Leave:
|
||||
{
|
||||
if (!x11.entered)
|
||||
XILeaveEvent *xie = cookie->data;
|
||||
if (!x11.entered || xie->event != x11.window ||
|
||||
button_state != 0 || app_isCaptureMode())
|
||||
return;
|
||||
|
||||
XILeaveEvent *xie = cookie->data;
|
||||
app_updateCursorPos(xie->event_x, xie->event_y);
|
||||
app_handleEnterEvent(false);
|
||||
x11.entered = false;
|
||||
@@ -793,8 +798,9 @@ static void x11GenericEvent(XGenericEventCookie *cookie)
|
||||
if (raw->time == prev_time && raw->detail == prev_detail)
|
||||
return;
|
||||
|
||||
prev_time = raw->time;
|
||||
prev_detail = raw->detail;
|
||||
prev_time = raw->time;
|
||||
prev_detail = raw->detail;
|
||||
button_state |= (1 << raw->detail);
|
||||
|
||||
app_handleButtonPress(
|
||||
raw->detail > 5 ? raw->detail - 2 : raw->detail);
|
||||
@@ -814,8 +820,9 @@ static void x11GenericEvent(XGenericEventCookie *cookie)
|
||||
if (raw->time == prev_time && raw->detail == prev_detail)
|
||||
return;
|
||||
|
||||
prev_time = raw->time;
|
||||
prev_detail = raw->detail;
|
||||
prev_time = raw->time;
|
||||
prev_detail = raw->detail;
|
||||
button_state &= ~(1 << raw->detail);
|
||||
|
||||
app_handleButtonRelease(
|
||||
raw->detail > 5 ? raw->detail - 2 : raw->detail);
|
||||
@@ -957,6 +964,29 @@ static void x11GLSwapBuffers(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void x11GuestPointerUpdated(double x, double y, int localX, int localY)
|
||||
{
|
||||
if (app_isCaptureMode() || !x11.entered)
|
||||
return;
|
||||
|
||||
// avoid running too often
|
||||
static uint64_t last_warp = 0;
|
||||
uint64_t now = microtime();
|
||||
if (now - last_warp < 10000)
|
||||
return;
|
||||
last_warp = now;
|
||||
|
||||
XIWarpPointer(
|
||||
x11.display,
|
||||
x11.pointerDev,
|
||||
None,
|
||||
x11.window,
|
||||
0, 0, 0, 0,
|
||||
localX, localY);
|
||||
|
||||
XSync(x11.display, False);
|
||||
}
|
||||
|
||||
static void x11ShowPointer(bool show)
|
||||
{
|
||||
if (show)
|
||||
@@ -1000,6 +1030,8 @@ static void x11GrabPointer(void)
|
||||
XISetMask(mask.mask, XI_RawButtonRelease);
|
||||
XISetMask(mask.mask, XI_RawMotion );
|
||||
XISetMask(mask.mask, XI_Motion );
|
||||
XISetMask(mask.mask, XI_Enter );
|
||||
XISetMask(mask.mask, XI_Leave );
|
||||
|
||||
Status ret = XIGrabDevice(
|
||||
x11.display,
|
||||
@@ -1189,20 +1221,21 @@ struct LG_DisplayServerOps LGDS_X11 =
|
||||
.glSetSwapInterval = x11GLSetSwapInterval,
|
||||
.glSwapBuffers = x11GLSwapBuffers,
|
||||
#endif
|
||||
.showPointer = x11ShowPointer,
|
||||
.grabPointer = x11GrabPointer,
|
||||
.ungrabPointer = x11UngrabPointer,
|
||||
.grabKeyboard = x11GrabKeyboard,
|
||||
.ungrabKeyboard = x11UngrabKeyboard,
|
||||
.warpPointer = x11WarpPointer,
|
||||
.realignPointer = x11RealignPointer,
|
||||
.isValidPointerPos = x11IsValidPointerPos,
|
||||
.inhibitIdle = x11InhibitIdle,
|
||||
.uninhibitIdle = x11UninhibitIdle,
|
||||
.wait = x11Wait,
|
||||
.setWindowSize = x11SetWindowSize,
|
||||
.setFullscreen = x11SetFullscreen,
|
||||
.getFullscreen = x11GetFullscreen,
|
||||
.guestPointerUpdated = x11GuestPointerUpdated,
|
||||
.showPointer = x11ShowPointer,
|
||||
.grabPointer = x11GrabPointer,
|
||||
.ungrabPointer = x11UngrabPointer,
|
||||
.grabKeyboard = x11GrabKeyboard,
|
||||
.ungrabKeyboard = x11UngrabKeyboard,
|
||||
.warpPointer = x11WarpPointer,
|
||||
.realignPointer = x11RealignPointer,
|
||||
.isValidPointerPos = x11IsValidPointerPos,
|
||||
.inhibitIdle = x11InhibitIdle,
|
||||
.uninhibitIdle = x11UninhibitIdle,
|
||||
.wait = x11Wait,
|
||||
.setWindowSize = x11SetWindowSize,
|
||||
.setFullscreen = x11SetFullscreen,
|
||||
.getFullscreen = x11GetFullscreen,
|
||||
|
||||
.cbInit = x11CBInit,
|
||||
.cbNotice = x11CBNotice,
|
||||
|
Reference in New Issue
Block a user