[Bf-blender-cvs] [c43473e8841] master: Cleanup: remove GHOST API to query tablet state from Window

Brecht Van Lommel noreply at git.blender.org
Wed Apr 8 12:28:21 CEST 2020


Commit: c43473e88415db1b62f9fa225baa23ca344cace8
Author: Brecht Van Lommel
Date:   Fri Mar 27 17:41:02 2020 +0100
Branches: master
https://developer.blender.org/rBc43473e88415db1b62f9fa225baa23ca344cace8

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

===================================================================

M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_IWindow.h
M	intern/ghost/GHOST_Types.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_EventButton.h
M	intern/ghost/intern/GHOST_EventCursor.h
M	intern/ghost/intern/GHOST_SystemCocoa.mm
M	intern/ghost/intern/GHOST_SystemSDL.cpp
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_WindowCocoa.h
M	intern/ghost/intern/GHOST_WindowCocoa.mm
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	intern/ghost/intern/GHOST_WindowX11.cpp

===================================================================

diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 5b45510a39f..75527d50c6a 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -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
diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h
index c456f2b1dba..daf07b81e01 100644
--- a/intern/ghost/GHOST_IWindow.h
+++ b/intern/ghost/GHOST_IWindow.h
@@ -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
    ***************************************************************************************/
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index eb844c9e574..8126c2299c6 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -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 */
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 6ee1557122d..db9fd2e3bf9 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -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();
diff --git a/intern/ghost/intern/GHOST_EventButton.h b/intern/ghost/intern/GHOST_EventButton.h
index e854bc23e5a..4247ae150a4 100644
--- a/intern/ghost/intern/GHOST_EventButton.h
+++ b/intern/ghost/intern/GHOST_EventButton.h
@@ -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;
   }
 
diff --git a/intern/ghost/intern/GHOST_EventCursor.h b/intern/ghost/intern/GHOST_EventCursor.h
index 41597db216a..8ba657fd9fa 100644
--- a/intern/ghost/intern/GHOST_EventCursor.h
+++ b/intern/ghost/intern/GHOST_EventCursor.h
@@ -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;
   }
 
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 9becff40995..3d6d187587c 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -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,
                                 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list