Blender V5.3
GHOST_SystemWin32.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#pragma once
11
12#ifndef WIN32
13# error WIN32 only!
14#endif /* WIN32 */
15
16#include <ole2.h> /* For drag-n-drop. */
17#include <windows.h>
18
19#include "GHOST_System.hh"
20
23class GHOST_EventKey;
25class GHOST_EventWindow;
27
30
36 public:
41
45 ~GHOST_SystemWin32() override;
46
47 /***************************************************************************************
48 ** Time(r) functionality
49 ***************************************************************************************/
50
56 uint64_t performanceCounterToMillis(__int64 perf_ticks) const;
57
64 uint64_t getMilliSeconds() const override;
65
66 /***************************************************************************************
67 ** Display/window management functionality
68 ***************************************************************************************/
69
74 uint8_t getNumDisplays() const override;
75
80 void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
81
86 void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
87
104 GHOST_IWindow *createWindow(const char *title,
105 int32_t left,
106 int32_t top,
107 uint32_t width,
108 uint32_t height,
110 GHOST_GPUSettings gpu_settings,
111 const bool exclusive = false,
112 const bool is_dialog = false,
113 const GHOST_IWindow *parent_window = nullptr) override;
114
121
128
137
145
150 GHOST_IWindow *getWindowUnderCursor(int32_t /*x*/, int32_t /*y*/) override;
151
152 /***************************************************************************************
153 ** Event management functionality
154 ***************************************************************************************/
155
161 bool processEvents(bool waitForEvent) override;
162
163 /***************************************************************************************
164 ** Cursor management functionality
165 ***************************************************************************************/
166
174
182
188 GHOST_TSuccess getPixelAtCursor(float r_color[3]) const override;
189
190 uint32_t getCursorPreferredLogicalSize() const override;
191
192 /***************************************************************************************
193 ** Access to mouse button and keyboard states.
194 ***************************************************************************************/
195
202
208 GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
209
210 GHOST_TCapabilityFlag getCapabilities() const override;
211
217 char *getClipboard(bool selection) const override;
218
224 void putClipboard(const char *buffer, bool selection) const override;
225
229 GHOST_TSuccess hasClipboardImage() const override;
230
237 uint *getClipboardImage(int *r_width, int *r_height) const override;
238
245 GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const override;
246
256 GHOST_TSuccess showMessageBox(const char *title,
257 const char *message,
258 const char *help_label,
259 const char *continue_label,
260 const char *link,
261 GHOST_DialogOptions dialog_options) const override;
262
275 GHOST_TDragnDropTypes draggedObjectType,
276 GHOST_WindowWin32 *window,
277 int mouseX,
278 int mouseY,
279 void *data);
280
281 /***************************************************************************************
282 ** Modify tablet API
283 ***************************************************************************************/
284
289 void setTabletAPI(GHOST_TTabletAPI api) override;
290
291 /***************************************************************************************
292 ** Debug Info
293 ***************************************************************************************/
294
299 void initDebug(GHOST_Debug debug) override;
300
301 protected:
307 GHOST_TSuccess init() override;
308
313 GHOST_TSuccess exit() override;
314
322 GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
323
330 GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_key_down);
331
339 static std::unique_ptr<GHOST_EventButton> processButtonEvent(GHOST_TEventType type,
340 GHOST_WindowWin32 *window,
342
347 static void processWintabEvent(GHOST_WindowWin32 *window);
348
357 static void processPointerEvent(
358 UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled);
359
365 static std::unique_ptr<GHOST_EventCursor> processCursorEvent(GHOST_WindowWin32 *window,
366 const int32_t screen_co[2]);
367
374 static void processWheelEventVertical(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
375
382 static void processWheelEventHorizontal(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
383
391 static std::unique_ptr<GHOST_EventKey> processKeyEvent(GHOST_WindowWin32 *window,
392 RAWINPUT const &raw);
393
400 GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
401
407 static std::unique_ptr<GHOST_Event> processWindowSizeEvent(GHOST_WindowWin32 *window);
408
415 static std::unique_ptr<GHOST_Event> processWindowEvent(GHOST_TEventType type,
416 GHOST_WindowWin32 *window);
417
418#ifdef WITH_INPUT_IME
426 static std::unique_ptr<GHOST_Event> processImeEvent(GHOST_TEventType type,
427 GHOST_WindowWin32 *window,
428 const GHOST_TEventImeData *data);
429#endif /* WITH_INPUT_IME */
430
435 static void processMinMaxInfo(MINMAXINFO *minmax);
436
437#ifdef WITH_INPUT_NDOF
445 bool processNDOF(RAWINPUT const &raw);
446#endif
447
451 void driveTrackpad();
452
456 void processTrackpad();
457
461 inline void handleKeyboardChange();
462
466 static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
467
474
478 __int64 freq_;
485
488
492};
493
495{
496 keylayout_ = GetKeyboardLayout(0); /* Get keylayout for current thread. */
497 int i;
498 SHORT s;
499
500 /* Save the language identifier. */
501 lang_id_ = LOWORD(keylayout_);
502
503 for (has_alt_gr_ = false, i = 32; i < 256; ++i) {
504 s = VkKeyScanEx((char)i, keylayout_);
505 /* `s == -1` means no key that translates passed char code high byte contains shift state.
506 * bit 2 Control pressed, bit 4 `Alt` pressed if both are pressed,
507 * we have `AltGr` key-combination on key-layout. */
508 if (s != -1 && (s & 0x600) == 0x600) {
509 has_alt_gr_ = true;
510 break;
511 }
512 }
513}
GHOST_TWindowState
GHOST_TEventType
GHOST_TCapabilityFlag
GHOST_TKey
GHOST_TSuccess
GHOST_TDragnDropTypes
GHOST_TButton
GHOST_TConsoleWindowState
GHOST_TTabletAPI
GHOST_DialogOptions
unsigned long long int uint64_t
GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_key_down)
void setTabletAPI(GHOST_TTabletAPI api) override
GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const override
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpu_settings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parent_window=nullptr) override
GHOST_TKey processSpecialKey(short vKey, short scanCode) const
GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override
GHOST_TSuccess showMessageBox(const char *title, const char *message, const char *help_label, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options) const override
static void processWheelEventHorizontal(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam)
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override
static GHOST_ContextD3D * createOffscreenContextD3D()
static GHOST_TSuccess disposeContextD3D(GHOST_ContextD3D *context)
GHOST_TSuccess hasClipboardImage() const override
static void processWintabEvent(GHOST_WindowWin32 *window)
uint64_t performanceCounterToMillis(__int64 perf_ticks) const
static std::unique_ptr< GHOST_EventButton > processButtonEvent(GHOST_TEventType type, GHOST_WindowWin32 *window, GHOST_TButton mask)
uint * getClipboardImage(int *r_width, int *r_height) const override
GHOST_TCapabilityFlag getCapabilities() const override
void initDebug(GHOST_Debug debug) override
char * getClipboard(bool selection) const override
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override
uint8_t getNumDisplays() const override
static std::unique_ptr< GHOST_Event > processWindowEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override
static void processMinMaxInfo(MINMAXINFO *minmax)
static void processWheelEventVertical(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam)
void putClipboard(const char *buffer, bool selection) const override
static std::unique_ptr< GHOST_EventCursor > processCursorEvent(GHOST_WindowWin32 *window, const int32_t screen_co[2])
uint32_t getCursorPreferredLogicalSize() const override
static std::unique_ptr< GHOST_EventKey > processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override
GHOST_TSuccess init() override
bool setConsoleWindowState(GHOST_TConsoleWindowState action) override
GHOST_TSuccess exit() override
bool processEvents(bool waitForEvent) override
static void processPointerEvent(UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled)
uint64_t getMilliSeconds() const override
GHOST_IWindow * getWindowUnderCursor(int32_t, int32_t) override
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const override
static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
static std::unique_ptr< GHOST_Event > processWindowSizeEvent(GHOST_WindowWin32 *window)
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowWin32 *window, int mouseX, int mouseY, void *data)
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override
GHOST_TSuccess disposeContext(GHOST_IContext *context) override
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpu_settings) override
const int state
ccl_device_inline float2 mask(const MaskType mask, const float2 a)