Add tablet termination and global cursor

This commit is contained in:
Anaël Seghezzi 2019-03-09 13:50:45 +01:00
parent 04cf328ca6
commit 92d93ede90
3 changed files with 29 additions and 7 deletions

View File

@ -875,8 +875,11 @@ static float * getDeviceCoordinateTransformationMatrix(Display *display, int dev
// //
static void initPenTablet(Display *display) static void initPenTablet(Display *display)
{ {
_glfw.x11.xi.tablet_cursor = 0;
_glfw.x11.xi.stylus_deviceid = 0; _glfw.x11.xi.stylus_deviceid = 0;
_glfw.x11.xi.eraser_deviceid = 0; _glfw.x11.xi.eraser_deviceid = 0;
_glfw.x11.xi.stylus_CTMatrix = NULL;
_glfw.x11.xi.eraser_CTMatrix = NULL;
if (_glfw.x11.xi.available) if (_glfw.x11.xi.available)
{ {
@ -927,6 +930,23 @@ static void initPenTablet(Display *display)
} }
} }
// XInput2 terminate pen tablet
//
static void terminatePenTablet(void)
{
if (_glfw.x11.xi.stylus_CTMatrix)
{
XFree(_glfw.x11.xi.stylus_CTMatrix);
_glfw.x11.xi.stylus_CTMatrix = NULL;
}
if (_glfw.x11.xi.eraser_CTMatrix)
{
XFree(_glfw.x11.xi.eraser_CTMatrix);
_glfw.x11.xi.eraser_CTMatrix = NULL;
}
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW internal API ////// ////// GLFW internal API //////
@ -1086,6 +1106,8 @@ int _glfwPlatformInit(void)
void _glfwPlatformTerminate(void) void _glfwPlatformTerminate(void)
{ {
terminatePenTablet();
if (_glfw.x11.helperWindowHandle) if (_glfw.x11.helperWindowHandle)
{ {
if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) == if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==

View File

@ -392,10 +392,11 @@ typedef struct _GLFWlibraryX11
PFN_XIQueryDevice QueryDevice; PFN_XIQueryDevice QueryDevice;
PFN_XIGetProperty GetProperty; PFN_XIGetProperty GetProperty;
XIValuatorClassInfo stylus_ClassInfo[32]; XIValuatorClassInfo stylus_ClassInfo[32];
float *stylus_CTMatrix; float *stylus_CTMatrix;
float *eraser_CTMatrix; float *eraser_CTMatrix;
int stylus_deviceid; unsigned int tablet_cursor;
int eraser_deviceid; int stylus_deviceid;
int eraser_deviceid;
} xi; } xi;
struct { struct {

View File

@ -1238,7 +1238,6 @@ static void processEvent(XEvent *event)
if (re->deviceid == _glfw.x11.xi.stylus_deviceid || if (re->deviceid == _glfw.x11.xi.stylus_deviceid ||
re->deviceid == _glfw.x11.xi.eraser_deviceid) re->deviceid == _glfw.x11.xi.eraser_deviceid)
{ {
static unsigned int s_cursor = 0;
unsigned int cursor = re->deviceid == _glfw.x11.xi.stylus_deviceid ? 1 : 2; unsigned int cursor = re->deviceid == _glfw.x11.xi.stylus_deviceid ? 1 : 2;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
@ -1246,10 +1245,10 @@ static void processEvent(XEvent *event)
double tiltx = 0.0; double tiltx = 0.0;
double tilty = 0.0; double tilty = 0.0;
if (cursor != s_cursor) if (cursor != _glfw.x11.xi.tablet_cursor)
{ {
_glfwInputPenTabletCursor(cursor); _glfwInputPenTabletCursor(cursor);
s_cursor = cursor; _glfw.x11.xi.tablet_cursor = cursor;
} }
if (XIMaskIsSet(re->valuators.mask, 0)) if (XIMaskIsSet(re->valuators.mask, 0))