Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/ghost/intern/GHOST_WindowWin32.h')
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h214
1 files changed, 149 insertions, 65 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 224ff53bf7b..a761d7d84dc 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -34,11 +34,14 @@
# include "GHOST_ImeWin32.h"
#endif
+#include <queue>
#include <vector>
#include <wintab.h>
-#define PACKETDATA (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR)
-#define PACKETMODE PK_BUTTONS
+// PACKETDATA and PACKETMODE modify structs in pktdef.h, so make sure they come first
+#define PACKETDATA \
+ (PK_BUTTONS | PK_NORMAL_PRESSURE | PK_ORIENTATION | PK_CURSOR | PK_X | PK_Y | PK_TIME)
+#define PACKETMODE 0
#include <pktdef.h>
class GHOST_SystemWin32;
@@ -46,9 +49,13 @@ class GHOST_DropTargetWin32;
// typedefs for WinTab functions to allow dynamic loading
typedef UINT(API *GHOST_WIN32_WTInfo)(UINT, UINT, LPVOID);
+typedef BOOL(API *GHOST_WIN32_WTGet)(HCTX, LPLOGCONTEXTA);
+typedef BOOL(API *GHOST_WIN32_WTSet)(HCTX, LPLOGCONTEXTA);
typedef HCTX(API *GHOST_WIN32_WTOpen)(HWND, LPLOGCONTEXTA, BOOL);
typedef BOOL(API *GHOST_WIN32_WTClose)(HCTX);
-typedef BOOL(API *GHOST_WIN32_WTPacket)(HCTX, UINT, LPVOID);
+typedef int(API *GHOST_WIN32_WTPacketsGet)(HCTX, int, LPVOID);
+typedef int(API *GHOST_WIN32_WTQueueSizeGet)(HCTX);
+typedef BOOL(API *GHOST_WIN32_WTQueueSizeSet)(HCTX, int);
typedef BOOL(API *GHOST_WIN32_WTEnable)(HCTX, BOOL);
typedef BOOL(API *GHOST_WIN32_WTOverlap)(HCTX, BOOL);
@@ -229,7 +236,14 @@ struct GHOST_PointerInfoWin32 {
GHOST_TButtonMask buttonMask;
POINT pixelLocation;
GHOST_TUns64 time;
+ GHOST_TabletData tabletData;
+};
+struct GHOST_WintabInfoWin32 {
+ GHOST_TInt32 x, y;
+ GHOST_TEventType type;
+ GHOST_TButtonMask button;
+ GHOST_TUns64 time;
GHOST_TabletData tabletData;
};
@@ -248,16 +262,16 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Constructor.
* Creates a new window and opens it.
- * To check if the window was created properly, use the getValid() method.
- * \param title The text shown in the title bar of the window.
- * \param left The coordinate of the left edge of the window.
- * \param top The coordinate of the top edge of the window.
- * \param width The width the window.
- * \param height The height the window.
- * \param state The state the window is initially opened with.
- * \param type The type of drawing context installed in this window.
- * \param wantStereoVisual Stereo visual for quad buffered stereo.
- * \param parentWindowHwnd
+ * To check if the window was created properly, use the #getValid() method.
+ * \param title: The text shown in the title bar of the window.
+ * \param left: The coordinate of the left edge of the window.
+ * \param top: The coordinate of the top edge of the window.
+ * \param width: The width the window.
+ * \param height: The height the window.
+ * \param state: The state the window is initially opened with.
+ * \param type: The type of drawing context installed in this window.
+ * \param wantStereoVisual: Stereo visual for quad buffered stereo.
+ * \param parentWindowHwnd: TODO.
*/
GHOST_WindowWin32(GHOST_SystemWin32 *system,
const char *title,
@@ -293,7 +307,7 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Sets the title displayed in the title bar.
- * \param title The title to display in the title bar.
+ * \param title: The title to display in the title bar.
*/
void setTitle(const char *title);
@@ -307,33 +321,33 @@ class GHOST_WindowWin32 : public GHOST_Window {
* Returns the window rectangle dimensions.
* The dimensions are given in screen coordinates that are
* relative to the upper-left corner of the screen.
- * \param bounds The bounding rectangle of the window.
+ * \param bounds: The bounding rectangle of the window.
*/
void getWindowBounds(GHOST_Rect &bounds) const;
/**
* Returns the client rectangle dimensions.
* The left and top members of the rectangle are always zero.
- * \param bounds The bounding rectangle of the client area of the window.
+ * \param bounds: The bounding rectangle of the client area of the window.
*/
void getClientBounds(GHOST_Rect &bounds) const;
/**
* Resizes client rectangle width.
- * \param width The new width of the client area of the window.
+ * \param width: The new width of the client area of the window.
*/
GHOST_TSuccess setClientWidth(GHOST_TUns32 width);
/**
* Resizes client rectangle height.
- * \param height The new height of the client area of the window.
+ * \param height: The new height of the client area of the window.
*/
GHOST_TSuccess setClientHeight(GHOST_TUns32 height);
/**
* Resizes client rectangle.
- * \param width The new width of the client area of the window.
- * \param height The new height of the client area of the window.
+ * \param width: The new width of the client area of the window.
+ * \param height: The new height of the client area of the window.
*/
GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height);
@@ -345,10 +359,10 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Converts a point in screen coordinates to client rectangle coordinates
- * \param inX The x-coordinate on the screen.
- * \param inY The y-coordinate on the screen.
- * \param outX The x-coordinate in the client rectangle.
- * \param outY The y-coordinate in the client rectangle.
+ * \param inX: The x-coordinate on the screen.
+ * \param inY: The y-coordinate on the screen.
+ * \param outX: The x-coordinate in the client rectangle.
+ * \param outY: The y-coordinate in the client rectangle.
*/
void screenToClient(GHOST_TInt32 inX,
GHOST_TInt32 inY,
@@ -357,10 +371,10 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Converts a point in screen coordinates to client rectangle coordinates
- * \param inX The x-coordinate in the client rectangle.
- * \param inY The y-coordinate in the client rectangle.
- * \param outX The x-coordinate on the screen.
- * \param outY The y-coordinate on the screen.
+ * \param inX: The x-coordinate in the client rectangle.
+ * \param inY: The y-coordinate in the client rectangle.
+ * \param outX: The x-coordinate on the screen.
+ * \param outY: The y-coordinate on the screen.
*/
void clientToScreen(GHOST_TInt32 inX,
GHOST_TInt32 inY,
@@ -369,14 +383,14 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Sets the state of the window (normal, minimized, maximized).
- * \param state The state of the window.
+ * \param state: The state of the window.
* \return Indication of success.
*/
GHOST_TSuccess setState(GHOST_TWindowState state);
/**
* Sets the order of the window (bottom, top).
- * \param order The order of the window.
+ * \param order: The order of the window.
* \return Indication of success.
*/
GHOST_TSuccess setOrder(GHOST_TWindowOrder order);
@@ -388,7 +402,7 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Sets the progress bar value displayed in the window/application icon
- * \param progress The progress %
+ * \param progress: The progress percentage (0.0 to 1.0).
*/
GHOST_TSuccess setProgressBar(float progress);
@@ -402,8 +416,8 @@ class GHOST_WindowWin32 : public GHOST_Window {
* for any real button press, controls mouse
* capturing).
*
- * \param event Whether mouse was pressed and released, or an operator grabbed or ungrabbed the
- * mouse
+ * \param event: Whether mouse was pressed and released,
+ * or an operator grabbed or ungrabbed the mouse.
*/
void updateMouseCapture(GHOST_MouseCaptureEventWin32 event);
@@ -417,34 +431,64 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Loads the windows equivalent of a standard GHOST cursor.
- * \param visible Flag for cursor visibility.
- * \param cursorShape The cursor shape.
+ * \param visible: Flag for cursor visibility.
+ * \param cursorShape: The cursor shape.
*/
HCURSOR getStandardCursor(GHOST_TStandardCursor shape) const;
void loadCursor(bool visible, GHOST_TStandardCursor cursorShape) const;
- const GHOST_TabletData &getTabletData()
- {
- return m_tabletData;
- }
+ /**
+ * Handle setup and switch between Wintab and Pointer APIs.
+ * \param active: Whether the window is or will be in an active state.
+ * \param visible: Whether the window is currently (or will be) visible).
+ */
+ void updateWintab(bool active, bool visible);
- void setTabletData(GHOST_TabletData *tabletData);
+ /**
+ * Query whether given tablet API should be used.
+ * \param api: Tablet API to test.
+ */
bool useTabletAPI(GHOST_TTabletAPI api) const;
/**
* Translate WM_POINTER events into GHOST_PointerInfoWin32 structs.
- * \param outPointerInfo Storage to return resulting GHOST_PointerInfoWin32 structs
- * \param wParam WPARAM of the event
- * \param lParam LPARAM of the event
+ * \param outPointerInfo: Storage to return resulting GHOST_PointerInfoWin32 structs.
+ * \param wParam: WPARAM of the event.
+ * \param lParam: LPARAM of the event.
+ * \return True if #outPointerInfo was updated.
*/
GHOST_TSuccess getPointerInfo(std::vector<GHOST_PointerInfoWin32> &outPointerInfo,
WPARAM wParam,
LPARAM lParam);
- void processWin32TabletActivateEvent(WORD state);
- void processWin32TabletInitEvent();
- void processWin32TabletEvent(WPARAM wParam, LPARAM lParam);
- void bringTabletContextToFront();
+ /**
+ * Handle Wintab coordinate changes when DisplayChange events occur.
+ */
+ void processWintabDisplayChangeEvent();
+
+ /**
+ * Set tablet details when a cursor enters range.
+ * \param inRange: Whether the Wintab device is in tracking range.
+ */
+ void processWintabProximityEvent(bool inRange);
+
+ /**
+ * Handle Wintab info changes such as change in number of connected tablets.
+ * \param lParam: LPARAM of the event.
+ */
+ void processWintabInfoChangeEvent(LPARAM lParam);
+
+ /**
+ * Translate Wintab packets into GHOST_WintabInfoWin32 structs.
+ * \param outWintabInfo: Storage to return resulting GHOST_WintabInfoWin32 structs.
+ * \return Success if able to read packets, even if there are none.
+ */
+ GHOST_TSuccess getWintabInfo(std::vector<GHOST_WintabInfoWin32> &outWintabInfo);
+
+ /**
+ * Updates stored pending Wintab events.
+ */
+ void updatePendingWintabEvents();
GHOST_TSuccess beginFullScreen() const
{
@@ -459,12 +503,25 @@ class GHOST_WindowWin32 : public GHOST_Window {
GHOST_TUns16 getDPIHint() override;
/**
- * Get whether there are currently any mouse buttons pressed
- * \return True if there are any currently pressed mouse buttons
+ * Get whether there are currently any mouse buttons pressed.
+ * \return True if there are any currently pressed mouse buttons.
*/
bool getMousePressed() const;
- /** Whether a tablet stylus is being tracked */
+ /**
+ * Get if there are currently pressed Wintab buttons associated to a Windows mouse button press.
+ * \return True if there are currently any pressed Wintab buttons associated to a Windows
+ * mouse button press.
+ */
+ bool wintabSysButPressed() const;
+
+ /**
+ * Register a Wintab button has been associated to a Windows mouse button press.
+ * \param event: Whether the button was pressed or released.
+ */
+ void updateWintabSysBut(GHOST_MouseCaptureEventWin32 event);
+
+ /** Whether a tablet stylus is being tracked. */
bool m_tabletInRange;
/** if the window currently resizing */
@@ -483,7 +540,7 @@ class GHOST_WindowWin32 : public GHOST_Window {
private:
/**
- * \param type The type of rendering context create.
+ * \param type: The type of rendering context create.
* \return Indication of success.
*/
GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type);
@@ -497,7 +554,7 @@ class GHOST_WindowWin32 : public GHOST_Window {
/**
* Sets the cursor grab on the window using native window system calls.
* Using registerMouseClickEvent.
- * \param mode GHOST_TGrabCursorMode.
+ * \param mode: GHOST_TGrabCursorMode.
*/
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode);
@@ -547,28 +604,55 @@ class GHOST_WindowWin32 : public GHOST_Window {
static const wchar_t *s_windowClassName;
static const int s_maxTitleLength;
- /** Tablet data for GHOST */
- GHOST_TabletData m_tabletData;
-
/* Wintab API */
struct {
/** WinTab dll handle */
- HMODULE handle;
+ HMODULE handle = NULL;
/** API functions */
- GHOST_WIN32_WTInfo info;
- GHOST_WIN32_WTOpen open;
- GHOST_WIN32_WTClose close;
- GHOST_WIN32_WTPacket packet;
- GHOST_WIN32_WTEnable enable;
- GHOST_WIN32_WTOverlap overlap;
+ GHOST_WIN32_WTInfo info = NULL;
+ GHOST_WIN32_WTGet get = NULL;
+ GHOST_WIN32_WTSet set = NULL;
+ GHOST_WIN32_WTOpen open = NULL;
+ GHOST_WIN32_WTClose close = NULL;
+ GHOST_WIN32_WTPacketsGet packetsGet = NULL;
+ GHOST_WIN32_WTQueueSizeGet queueSizeGet = NULL;
+ GHOST_WIN32_WTQueueSizeSet queueSizeSet = NULL;
+ GHOST_WIN32_WTEnable enable = NULL;
+ GHOST_WIN32_WTOverlap overlap = NULL;
/** Stores the Tablet context if detected Tablet features using WinTab.dll */
- HCTX tablet;
- LONG maxPressure;
- LONG maxAzimuth, maxAltitude;
+ HCTX context = NULL;
+ /** Number of connected Wintab digitizers */
+ UINT numDevices = 0;
+ /** Number of cursors currently in contact mapped to system buttons */
+ GHOST_TUns8 numSysButtons = 0;
+ /** Cursors currently in contact mapped to system buttons */
+ DWORD sysButtonsPressed = 0;
+ LONG maxPressure = 0;
+ LONG maxAzimuth = 0, maxAltitude = 0;
+ /** Reusable buffer to read in Wintab Packets. */
+ std::vector<PACKET> pkts;
+ /** Queue of packets to process. */
+ std::queue<PACKET> pendingEvents;
} m_wintab;
+ /**
+ * Wintab setup.
+ */
+ void initializeWintab();
+
+ /**
+ * Convert Wintab system mapped (mouse) buttons into Ghost button mask.
+ * \param cursor: The Wintab cursor associated to the button.
+ * \param physicalButton: The physical button ID to inspect.
+ * \param buttonMask: Return pointer for button found.
+ * \return Whether an associated button was found.
+ */
+ GHOST_TSuccess wintabMouseToGhost(UINT cursor,
+ WORD physicalButton,
+ GHOST_TButtonMask &buttonMask);
+
GHOST_TWindowState m_normal_state;
/** user32 dll handle*/