Blender V5.0
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#ifndef NOMINMAX
17# define NOMINMAX
18#endif
19
20#define WIN32_LEAN_AND_MEAN
21#include <ole2.h> /* For drag-n-drop. */
22#include <windows.h>
23
24#include "GHOST_System.hh"
25
28class GHOST_EventKey;
30class GHOST_EventWindow;
32
35
41 public:
46
50 ~GHOST_SystemWin32() override;
51
52 /***************************************************************************************
53 ** Time(r) functionality
54 ***************************************************************************************/
55
61 uint64_t performanceCounterToMillis(__int64 perf_ticks) const;
62
69 uint64_t getMilliSeconds() const override;
70
71 /***************************************************************************************
72 ** Display/window management functionality
73 ***************************************************************************************/
74
79 uint8_t getNumDisplays() const override;
80
85 void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override;
86
91 void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override;
92
109 GHOST_IWindow *createWindow(const char *title,
111 int32_t top,
112 uint32_t width,
113 uint32_t height,
115 GHOST_GPUSettings gpu_settings,
116 const bool exclusive = false,
117 const bool is_dialog = false,
118 const GHOST_IWindow *parent_window = nullptr) override;
119
126
133
142
150
155 GHOST_IWindow *getWindowUnderCursor(int32_t /*x*/, int32_t /*y*/) override;
156
157 /***************************************************************************************
158 ** Event management functionality
159 ***************************************************************************************/
160
166 bool processEvents(bool waitForEvent) override;
167
168 /***************************************************************************************
169 ** Cursor management functionality
170 ***************************************************************************************/
171
179
187
193 GHOST_TSuccess getPixelAtCursor(float r_color[3]) const override;
194
195 uint32_t getCursorPreferredLogicalSize() const override;
196
197 /***************************************************************************************
198 ** Access to mouse button and keyboard states.
199 ***************************************************************************************/
200
207
213 GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
214
215 GHOST_TCapabilityFlag getCapabilities() const override;
216
222 char *getClipboard(bool selection) const override;
223
229 void putClipboard(const char *buffer, bool selection) const override;
230
234 GHOST_TSuccess hasClipboardImage() const override;
235
242 uint *getClipboardImage(int *r_width, int *r_height) const override;
243
250 GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const override;
251
261 GHOST_TSuccess showMessageBox(const char *title,
262 const char *message,
263 const char *help_label,
264 const char *continue_label,
265 const char *link,
266 GHOST_DialogOptions dialog_options) const override;
267
280 GHOST_TDragnDropTypes draggedObjectType,
281 GHOST_WindowWin32 *window,
282 int mouseX,
283 int mouseY,
284 void *data);
285
286 /***************************************************************************************
287 ** Modify tablet API
288 ***************************************************************************************/
289
294 void setTabletAPI(GHOST_TTabletAPI api) override;
295
296 /***************************************************************************************
297 ** Debug Info
298 ***************************************************************************************/
299
304 void initDebug(GHOST_Debug debug) override;
305
306 protected:
312 GHOST_TSuccess init() override;
313
318 GHOST_TSuccess exit() override;
319
327 GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
328
335 GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_key_down);
336
345 GHOST_WindowWin32 *window,
347
352 static void processWintabEvent(GHOST_WindowWin32 *window);
353
362 static void processPointerEvent(
363 UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled);
364
371 const int32_t screen_co[2]);
372
379 static void processWheelEventVertical(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
380
387 static void processWheelEventHorizontal(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
388
396 static GHOST_EventKey *processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw);
397
404 GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
405
412
420
421#ifdef WITH_INPUT_IME
429 static GHOST_Event *processImeEvent(GHOST_TEventType type,
430 GHOST_WindowWin32 *window,
432#endif /* WITH_INPUT_IME */
433
438 static void processMinMaxInfo(MINMAXINFO *minmax);
439
440#ifdef WITH_INPUT_NDOF
448 bool processNDOF(RAWINPUT const &raw);
449#endif
450
454 void driveTrackpad();
455
459 void processTrackpad();
460
464 inline void handleKeyboardChange();
465
469 static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
470
477
481 __int64 freq_;
488
491
495};
496
498{
499 keylayout_ = GetKeyboardLayout(0); /* Get keylayout for current thread. */
500 int i;
501 SHORT s;
502
503 /* Save the language identifier. */
504 lang_id_ = LOWORD(keylayout_);
505
506 for (has_alt_gr_ = false, i = 32; i < 256; ++i) {
507 s = VkKeyScanEx((char)i, keylayout_);
508 /* `s == -1` means no key that translates passed char code high byte contains shift state.
509 * bit 2 Control pressed, bit 4 `Alt` pressed if both are pressed,
510 * we have `AltGr` key-combination on key-layout. */
511 if (s != -1 && (s & 0x600) == 0x600) {
512 has_alt_gr_ = true;
513 break;
514 }
515 }
516}
unsigned int uint
GHOST_TWindowState
GHOST_TEventType
GHOST_TCapabilityFlag
GHOST_TKey
GHOST_TSuccess
Definition GHOST_Types.h:57
GHOST_TDragnDropTypes
GHOST_TButton
GHOST_TConsoleWindowState
GHOST_TTabletAPI
GHOST_DialogOptions
BMesh const char void * data
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
static GHOST_EventButton * processButtonEvent(GHOST_TEventType type, GHOST_WindowWin32 *window, GHOST_TButton mask)
GHOST_TKey processSpecialKey(short vKey, short scanCode) const
static GHOST_Event * processWindowSizeEvent(GHOST_WindowWin32 *window)
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)
static GHOST_EventCursor * processCursorEvent(GHOST_WindowWin32 *window, const int32_t screen_co[2])
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
uint * getClipboardImage(int *r_width, int *r_height) const override
GHOST_TCapabilityFlag getCapabilities() const override
static GHOST_EventKey * processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
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
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
uint32_t getCursorPreferredLogicalSize() const override
static GHOST_Event * processWindowEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
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 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
uint top
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static ulong state[N]
static int left
i
Definition text_draw.cc:230