Cleanup: remove GHOST API to query tablet state from Window

It's not used by Blender anymore and it's unreliable since this state really
only makes sense associated with events in a particular order.

Ref D6675
This commit is contained in:
Brecht Van Lommel 2020-03-27 17:41:02 +01:00
parent d478cc71dd
commit c43473e884
14 changed files with 119 additions and 80 deletions

View File

@ -761,13 +761,6 @@ extern unsigned int GHOST_GetDefaultOpenGLFramebuffer(GHOST_WindowHandle windwHa
*/
extern void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api);
/**
* Returns the status of the tablet
* \param windowhandle The handle to the window
* \return Status of tablet
*/
extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle);
/**
* Access to rectangle width.
* \param rectanglehandle The handle to the rectangle

View File

@ -243,16 +243,6 @@ class GHOST_IWindow {
virtual bool isDialog() const = 0;
/**
* Returns the tablet data (pressure etc).
* \return The tablet data (pressure etc).
*/
virtual const GHOST_TabletData &GetTabletData()
{
/* Default state when no tablet is used, for systems without tablet support. */
return GHOST_TABLET_DATA_DEFAULT;
}
/***************************************************************************************
* Progress bar functionality
***************************************************************************************/

View File

@ -117,7 +117,7 @@ typedef struct GHOST_TabletData {
float Ytilt; /* as above */
} GHOST_TabletData;
static const GHOST_TabletData GHOST_TABLET_DATA_DEFAULT = {
static const GHOST_TabletData GHOST_TABLET_DATA_NONE = {
GHOST_kTabletModeNone, /* No tablet connected. */
1.0f, /* Pressure */
0.0f, /* Xtilt */

View File

@ -717,11 +717,6 @@ void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI api)
system->setTabletAPI(api);
}
const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
{
return &((GHOST_IWindow *)windowhandle)->GetTabletData();
}
GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
{
return ((GHOST_Rect *)rectanglehandle)->getWidth();

View File

@ -37,17 +37,19 @@ class GHOST_EventButton : public GHOST_Event {
* Constructor.
* \param time The time this event was generated.
* \param type The type of this event.
* \param window: The window of this event.
* \param button: The state of the buttons were at the time of the event.
* \param window The window of this event.
* \param button The state of the buttons were at the time of the event.
* \param tablet The tablet data associated with this event.
*/
GHOST_EventButton(GHOST_TUns64 time,
GHOST_TEventType type,
GHOST_IWindow *window,
GHOST_TButtonMask button)
GHOST_TButtonMask button,
const GHOST_TabletData &tablet)
: GHOST_Event(time, type, window)
{
m_buttonEventData.button = button;
m_buttonEventData.tablet = window->GetTabletData();
m_buttonEventData.tablet = tablet;
m_data = &m_buttonEventData;
}

View File

@ -38,17 +38,19 @@ class GHOST_EventCursor : public GHOST_Event {
* \param type The type of this event.
* \param x The x-coordinate of the location the cursor was at the time of the event.
* \param y The y-coordinate of the location the cursor was at the time of the event.
* \param tablet The tablet data associated with this event.
*/
GHOST_EventCursor(GHOST_TUns64 msec,
GHOST_TEventType type,
GHOST_IWindow *window,
GHOST_TInt32 x,
GHOST_TInt32 y)
GHOST_TInt32 y,
const GHOST_TabletData &tablet)
: GHOST_Event(msec, type, window)
{
m_cursorEventData.x = x;
m_cursorEventData.y = y;
m_cursorEventData.tablet = window->GetTabletData();
m_cursorEventData.tablet = tablet;
m_data = &m_cursorEventData;
}

View File

@ -817,7 +817,8 @@ GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
CGAssociateMouseAndMouseCursorPosition(true);
// Force mouse move event (not pushed by Cocoa)
pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x, y));
pushEvent(new GHOST_EventCursor(
getMilliSeconds(), GHOST_kEventCursorMove, window, x, y, window->GetCocoaTabletData()));
m_outsideLoopEventProcessed = true;
return GHOST_kSuccess;
@ -1098,8 +1099,11 @@ GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType,
pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
// Mouse up event is trapped by the resizing event loop,
// so send it anyway to the window manager.
pushEvent(new GHOST_EventButton(
getMilliSeconds(), GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft));
pushEvent(new GHOST_EventButton(getMilliSeconds(),
GHOST_kEventButtonUp,
window,
GHOST_kButtonMaskLeft,
GHOST_TABLET_DATA_NONE));
// m_ignoreWindowSizedMessages = true;
}
break;
@ -1437,7 +1441,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT
case NSEventTypeTabletProximity:
/* Reset tablet data when device enters proximity or leaves. */
ct = GHOST_TABLET_DATA_DEFAULT;
ct = GHOST_TABLET_DATA_NONE;
if ([event isEnteringProximity]) {
/* Pointer is entering tablet area proximity. */
switch ([event pointingDeviceType]) {
@ -1504,38 +1508,52 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
switch ([event type]) {
case NSEventTypeLeftMouseDown:
handleTabletEvent(event); // Update window tablet state to be included in event.
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonDown, window, GHOST_kButtonMaskLeft));
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonDown,
window,
GHOST_kButtonMaskLeft,
window -> GetCocoaTabletData()));
break;
case NSEventTypeRightMouseDown:
handleTabletEvent(event); // Update window tablet state to be included in event.
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonDown, window, GHOST_kButtonMaskRight));
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonDown,
window,
GHOST_kButtonMaskRight,
window -> GetCocoaTabletData()));
break;
case NSEventTypeOtherMouseDown:
handleTabletEvent(event); // Handle tablet events combined with mouse events
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonDown,
window,
convertButton([event buttonNumber])));
convertButton([event buttonNumber]),
window -> GetCocoaTabletData()));
break;
case NSEventTypeLeftMouseUp:
handleTabletEvent(event); // Update window tablet state to be included in event.
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonUp, window, GHOST_kButtonMaskLeft));
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonUp,
window,
GHOST_kButtonMaskLeft,
window -> GetCocoaTabletData()));
break;
case NSEventTypeRightMouseUp:
handleTabletEvent(event); // Update window tablet state to be included in event.
pushEvent(new GHOST_EventButton(
[event timestamp] * 1000, GHOST_kEventButtonUp, window, GHOST_kButtonMaskRight));
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonUp,
window,
GHOST_kButtonMaskRight,
window -> GetCocoaTabletData()));
break;
case NSEventTypeOtherMouseUp:
handleTabletEvent(event); // Update window tablet state to be included in event.
pushEvent(new GHOST_EventButton([event timestamp] * 1000,
GHOST_kEventButtonUp,
window,
convertButton([event buttonNumber])));
convertButton([event buttonNumber]),
window -> GetCocoaTabletData()));
break;
case NSEventTypeLeftMouseDragged:
@ -1568,8 +1586,12 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
window->setCursorGrabAccum(x_accum, y_accum);
window->clientToScreenIntern(x_warp + x_accum, y_warp + y_accum, x, y);
pushEvent(new GHOST_EventCursor(
[event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
pushEvent(new GHOST_EventCursor([event timestamp] * 1000,
GHOST_kEventCursorMove,
window,
x,
y,
window -> GetCocoaTabletData()));
break;
}
case GHOST_kGrabWrap: // Wrap cursor at area/window boundaries
@ -1614,8 +1636,12 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
// Generate event
GHOST_TInt32 x, y;
window->clientToScreenIntern(x_mouse + x_accum, y_mouse + y_accum, x, y);
pushEvent(new GHOST_EventCursor(
[event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
pushEvent(new GHOST_EventCursor([event timestamp] * 1000,
GHOST_kEventCursorMove,
window,
x,
y,
window -> GetCocoaTabletData()));
break;
}
default: {
@ -1624,8 +1650,12 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
GHOST_TInt32 x, y;
window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
pushEvent(new GHOST_EventCursor(
[event timestamp] * 1000, GHOST_kEventCursorMove, window, x, y));
pushEvent(new GHOST_EventCursor([event timestamp] * 1000,
GHOST_kEventCursorMove,
window,
x,
y,
window -> GetCocoaTabletData()));
break;
}
}

View File

@ -390,22 +390,31 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win);
}
g_event = new GHOST_EventCursor(
getMilliSeconds(), GHOST_kEventCursorMove, window, x_new, y_new);
g_event = new GHOST_EventCursor(getMilliSeconds(),
GHOST_kEventCursorMove,
window,
x_new,
y_new,
GHOST_TABLET_DATA_NONE);
}
else {
g_event = new GHOST_EventCursor(getMilliSeconds(),
GHOST_kEventCursorMove,
window,
x_root + x_accum,
y_root + y_accum);
y_root + y_accum,
GHOST_TABLET_DATA_NONE);
}
}
else
#endif
{
g_event = new GHOST_EventCursor(
getMilliSeconds(), GHOST_kEventCursorMove, window, x_root, y_root);
g_event = new GHOST_EventCursor(getMilliSeconds(),
GHOST_kEventCursorMove,
window,
x_root,
y_root,
GHOST_TABLET_DATA_NONE);
}
break;
}
@ -435,7 +444,8 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
else
break;
g_event = new GHOST_EventButton(getMilliSeconds(), type, window, gbmask);
g_event = new GHOST_EventButton(
getMilliSeconds(), type, window, gbmask, GHOST_TABLET_DATA_NONE);
break;
}
case SDL_MOUSEWHEEL: {

View File

@ -911,7 +911,8 @@ GHOST_EventButton *GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
if (window->useTabletAPI(GHOST_kTabletNative)) {
window->setTabletData(NULL);
}
return new GHOST_EventButton(system->getMilliSeconds(), type, window, mask);
return new GHOST_EventButton(
system->getMilliSeconds(), type, window, mask, window->getTabletData());
}
GHOST_Event *GHOST_SystemWin32::processPointerEvent(GHOST_TEventType type,
@ -943,21 +944,27 @@ GHOST_Event *GHOST_SystemWin32::processPointerEvent(GHOST_TEventType type,
/* Update window tablet data to be included in event. */
window->setTabletData(&pointerInfo.tabletData);
eventHandled = true;
return new GHOST_EventButton(
system->getMilliSeconds(), GHOST_kEventButtonDown, window, pointerInfo.buttonMask);
return new GHOST_EventButton(system->getMilliSeconds(),
GHOST_kEventButtonDown,
window,
pointerInfo.buttonMask,
pointerInfo.tabletData);
case GHOST_kEventButtonUp:
eventHandled = true;
return new GHOST_EventButton(
system->getMilliSeconds(), GHOST_kEventButtonUp, window, pointerInfo.buttonMask);
return new GHOST_EventButton(system->getMilliSeconds(),
GHOST_kEventButtonUp,
window,
pointerInfo.buttonMask,
window->getTabletData());
case GHOST_kEventCursorMove:
/* Update window tablet data to be included in event. */
window->setTabletData(&pointerInfo.tabletData);
eventHandled = true;
return new GHOST_EventCursor(system->getMilliSeconds(),
GHOST_kEventCursorMove,
window,
pointerInfo.pixelLocation.x,
pointerInfo.pixelLocation.y);
pointerInfo.pixelLocation.y,
pointerInfo.tabletData);
default:
return NULL;
}
@ -1001,12 +1008,17 @@ GHOST_EventCursor *GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type,
GHOST_kEventCursorMove,
window,
x_screen + x_accum,
y_screen + y_accum);
y_screen + y_accum,
window->getTabletData());
}
}
else {
return new GHOST_EventCursor(
system->getMilliSeconds(), GHOST_kEventCursorMove, window, x_screen, y_screen);
return new GHOST_EventCursor(system->getMilliSeconds(),
GHOST_kEventCursorMove,
window,
x_screen,
y_screen,
window->getTabletData());
}
return NULL;
}

View File

@ -1000,12 +1000,17 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
GHOST_kEventCursorMove,
window,
xme.x_root + x_accum,
xme.y_root + y_accum);
xme.y_root + y_accum,
window->GetTabletData());
}
}
else {
g_event = new GHOST_EventCursor(
getMilliSeconds(), GHOST_kEventCursorMove, window, xme.x_root, xme.y_root);
g_event = new GHOST_EventCursor(getMilliSeconds(),
GHOST_kEventCursorMove,
window,
xme.x_root,
xme.y_root,
window->GetTabletData());
}
break;
}
@ -1272,7 +1277,8 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
else
break;
g_event = new GHOST_EventButton(getMilliSeconds(), type, window, gbmask);
g_event = new GHOST_EventButton(
getMilliSeconds(), type, window, gbmask, window->GetTabletData());
break;
}
@ -1373,8 +1379,12 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
*/
XCrossingEvent &xce = xe->xcrossing;
if (xce.mode == NotifyNormal) {
g_event = new GHOST_EventCursor(
getMilliSeconds(), GHOST_kEventCursorMove, window, xce.x_root, xce.y_root);
g_event = new GHOST_EventCursor(getMilliSeconds(),
GHOST_kEventCursorMove,
window,
xce.x_root,
xce.y_root,
window->GetTabletData());
}
// printf("X: %s window %d\n",

View File

@ -222,11 +222,6 @@ class GHOST_WindowCocoa : public GHOST_Window {
bool isDialog() const;
const GHOST_TabletData &GetTabletData()
{
return m_tablet;
}
GHOST_TabletData &GetCocoaTabletData()
{
return m_tablet;

View File

@ -395,7 +395,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa,
setTitle(title);
m_tablet = GHOST_TABLET_DATA_DEFAULT;
m_tablet = GHOST_TABLET_DATA_NONE;
CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
[windowDelegate setSystemAndWindowCocoa:systemCocoa windowCocoa:this];

View File

@ -90,7 +90,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
{
// Initialize tablet variables
memset(&m_wintab, 0, sizeof(m_wintab));
m_tabletData = GHOST_TABLET_DATA_DEFAULT;
m_tabletData = GHOST_TABLET_DATA_NONE;
// Create window
if (state != GHOST_kWindowStateFullScreen) {
@ -1101,7 +1101,7 @@ void GHOST_WindowWin32::setTabletData(GHOST_TabletData *pTabletData)
m_tabletData = *pTabletData;
}
else {
m_tabletData = GHOST_TABLET_DATA_DEFAULT;
m_tabletData = GHOST_TABLET_DATA_NONE;
}
}

View File

@ -499,7 +499,7 @@ GHOST_WindowX11::GHOST_WindowX11(GHOST_SystemX11 *system,
#ifdef WITH_X11_XINPUT
refreshXInputDevices();
m_tabletData = GHOST_TABLET_DATA_DEFAULT;
m_tabletData = GHOST_TABLET_DATA_NONE;
#endif
/* now set up the rendering context. */