Blender V4.5
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 gpuSettings,
116 const bool exclusive = false,
117 const bool is_dialog = false,
118 const GHOST_IWindow *parentWindow = 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 /***************************************************************************************
196 ** Access to mouse button and keyboard states.
197 ***************************************************************************************/
198
205
211 GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override;
212
213 GHOST_TCapabilityFlag getCapabilities() const override;
214
220 char *getClipboard(bool selection) const override;
221
227 void putClipboard(const char *buffer, bool selection) const override;
228
232 GHOST_TSuccess hasClipboardImage() const override;
233
240 uint *getClipboardImage(int *r_width, int *r_height) const override;
241
248 GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const override;
249
259 GHOST_TSuccess showMessageBox(const char *title,
260 const char *message,
261 const char *help_label,
262 const char *continue_label,
263 const char *link,
264 GHOST_DialogOptions dialog_options) const override;
265
278 GHOST_TDragnDropTypes draggedObjectType,
279 GHOST_WindowWin32 *window,
280 int mouseX,
281 int mouseY,
282 void *data);
283
284 /***************************************************************************************
285 ** Modify tablet API
286 ***************************************************************************************/
287
292 void setTabletAPI(GHOST_TTabletAPI api) override;
293
294 /***************************************************************************************
295 ** Debug Info
296 ***************************************************************************************/
297
302 void initDebug(GHOST_Debug debug) override;
303
304 protected:
310 GHOST_TSuccess init() override;
311
316 GHOST_TSuccess exit() override;
317
325 GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
326
333 GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_key_down);
334
343 GHOST_WindowWin32 *window,
345
350 static void processWintabEvent(GHOST_WindowWin32 *window);
351
360 static void processPointerEvent(
361 UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled);
362
369 const int32_t screen_co[2]);
370
377 static void processWheelEventVertical(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
378
385 static void processWheelEventHorizontal(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
386
394 static GHOST_EventKey *processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw);
395
402 GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
403
410
418
419#ifdef WITH_INPUT_IME
427 static GHOST_Event *processImeEvent(GHOST_TEventType type,
428 GHOST_WindowWin32 *window,
430#endif /* WITH_INPUT_IME */
431
436 static void processMinMaxInfo(MINMAXINFO *minmax);
437
438#ifdef WITH_INPUT_NDOF
446 bool processNDOF(RAWINPUT const &raw);
447#endif
448
452 void driveTrackpad();
453
457 void processTrackpad();
458
462 inline void handleKeyboardChange();
463
467 static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
468
475
479 __int64 m_freq;
486
489
493};
494
496{
497 m_keylayout = GetKeyboardLayout(0); /* Get keylayout for current thread. */
498 int i;
499 SHORT s;
500
501 /* Save the language identifier. */
502 m_langId = LOWORD(m_keylayout);
503
504 for (m_hasAltGr = false, i = 32; i < 256; ++i) {
505 s = VkKeyScanEx((char)i, m_keylayout);
506 /* `s == -1` means no key that translates passed char code high byte contains shift state.
507 * bit 2 Control pressed, bit 4 `Alt` pressed if both are pressed,
508 * we have `AltGr` key-combination on key-layout. */
509 if (s != -1 && (s & 0x600) == 0x600) {
510 m_hasAltGr = true;
511 break;
512 }
513 }
514}
unsigned int uint
GHOST_TWindowState
GHOST_TEventType
GHOST_TCapabilityFlag
Definition GHOST_Types.h:89
GHOST_TKey
GHOST_TSuccess
Definition GHOST_Types.h:80
GHOST_TDragnDropTypes
GHOST_TButton
GHOST_TConsoleWindowState
GHOST_TTabletAPI
GHOST_DialogOptions
Definition GHOST_Types.h:73
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
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()
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpuSettings) override
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
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_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpuSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=nullptr) 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
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