Changeset View
Standalone View
intern/ghost/intern/GHOST_WindowWin32.h
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup GHOST | * \ingroup GHOST | ||||
| * Declaration of GHOST_WindowWin32 class. | * Declaration of GHOST_WindowWin32 class. | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| #ifndef WIN32 | #ifndef WIN32 | ||||
| # error WIN32 only! | # error WIN32 only! | ||||
| #endif // WIN32 | #endif // WIN32 | ||||
| #include "GHOST_TaskbarWin32.h" | #include "GHOST_TaskbarWin32.h" | ||||
| #include "GHOST_TrackpadWin32.h" | |||||
| #include "GHOST_Window.h" | #include "GHOST_Window.h" | ||||
| #include "GHOST_Wintab.h" | #include "GHOST_Wintab.h" | ||||
| #ifdef WITH_INPUT_IME | #ifdef WITH_INPUT_IME | ||||
| # include "GHOST_ImeWin32.h" | # include "GHOST_ImeWin32.h" | ||||
| #endif | #endif | ||||
| #include <vector> | #include <vector> | ||||
| Show All 10 Lines | struct GHOST_PointerInfoWin32 { | ||||
| int32_t pointerId; | int32_t pointerId; | ||||
| int32_t isPrimary; | int32_t isPrimary; | ||||
| GHOST_TButtonMask buttonMask; | GHOST_TButtonMask buttonMask; | ||||
| POINT pixelLocation; | POINT pixelLocation; | ||||
| uint64_t time; | uint64_t time; | ||||
| GHOST_TabletData tabletData; | GHOST_TabletData tabletData; | ||||
| }; | }; | ||||
| typedef enum { | typedef enum { | ||||
nicholas_rishel: Please move this after pktdef.h with a separating newline, wintab.h through pktdef.h are a… | |||||
| MousePressed, | MousePressed, | ||||
| MouseReleased, | MouseReleased, | ||||
| OperatorGrab, | OperatorGrab, | ||||
| OperatorUngrab | OperatorUngrab | ||||
| } GHOST_MouseCaptureEventWin32; | } GHOST_MouseCaptureEventWin32; | ||||
| /** | /** | ||||
| * GHOST window on MS Windows OSs. | * GHOST window on MS Windows OSs. | ||||
| ▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | GHOST_TSuccess beginFullScreen() const | ||||
| return GHOST_kFailure; | return GHOST_kFailure; | ||||
| } | } | ||||
| GHOST_TSuccess endFullScreen() const | GHOST_TSuccess endFullScreen() const | ||||
| { | { | ||||
| return GHOST_kFailure; | return GHOST_kFailure; | ||||
| } | } | ||||
| void updateDPI(); | |||||
| uint16_t getDPIHint() override; | uint16_t getDPIHint() override; | ||||
| /** True if the mouse is either over or captured by the window. */ | /** True if the mouse is either over or captured by the window. */ | ||||
| bool m_mousePresent; | bool m_mousePresent; | ||||
| /** True if the window currently resizing. */ | /** True if the window currently resizing. */ | ||||
| bool m_inLiveResize; | bool m_inLiveResize; | ||||
| /** Called when OS colors change and when the window is created. */ | /** Called when OS colors change and when the window is created. */ | ||||
| void ThemeRefresh(); | void ThemeRefresh(); | ||||
| #ifdef WITH_INPUT_IME | #ifdef WITH_INPUT_IME | ||||
| GHOST_ImeWin32 *getImeInput() | GHOST_ImeWin32 *getImeInput() | ||||
| { | { | ||||
| return &m_imeInput; | return &m_imeInput; | ||||
| } | } | ||||
| void beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed); | void beginIME(int32_t x, int32_t y, int32_t w, int32_t h, bool completed); | ||||
| void endIME(); | void endIME(); | ||||
| #endif /* WITH_INPUT_IME */ | #endif /* WITH_INPUT_IME */ | ||||
| /* | |||||
| * Drive DirectManipulation context. | |||||
| */ | |||||
| void updateDirectManipulation(); | |||||
| /* | |||||
| * Handle DM_POINTERHITTEST events. | |||||
| * \param wParam: wParam from the event. | |||||
| */ | |||||
| void onPointerHitTest(WPARAM wParam); | |||||
| GHOST_TTrackpadInfo getTrackpadInfo(); | |||||
| private: | private: | ||||
| /** | /** | ||||
| * \param type: The type of rendering context create. | * \param type: The type of rendering context create. | ||||
| * \return Indication of success. | * \return Indication of success. | ||||
| */ | */ | ||||
| GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type); | GHOST_Context *newDrawingContext(GHOST_TDrawingContextType type); | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | private: | ||||
| GHOST_TabletData m_lastPointerTabletData; | GHOST_TabletData m_lastPointerTabletData; | ||||
| GHOST_TWindowState m_normal_state; | GHOST_TWindowState m_normal_state; | ||||
| /** `user32.dll` handle */ | /** `user32.dll` handle */ | ||||
| HMODULE m_user32; | HMODULE m_user32; | ||||
| HWND m_parentWindowHwnd; | HWND m_parentWindowHwnd; | ||||
| GHOST_DirectManipulationHelper *m_directManipulationHelper; | |||||
| #ifdef WITH_INPUT_IME | #ifdef WITH_INPUT_IME | ||||
Done Inline ActionsThis needs to be initialized to nullptr (see the intializer list in GHOST_WindowWin32's constructor). nicholas_rishel: This needs to be initialized to `nullptr` (see the intializer list in `GHOST_WindowWin32`'s… | |||||
| /** Handle input method editors event */ | /** Handle input method editors event */ | ||||
| GHOST_ImeWin32 m_imeInput; | GHOST_ImeWin32 m_imeInput; | ||||
| #endif | #endif | ||||
| bool m_debug_context; | bool m_debug_context; | ||||
| }; | }; | ||||
Done Inline ActionsAny reason not to use std::unique_ptr? brecht: Any reason not to use `std::unique_ptr`? | |||||
Not Done Inline ActionsThey are COM objects, which need lifetime management though IUnknown, ComPtr will do this for you while unique_ptr won't, previously there was/is not a whole lot of COM usage in our codebase and we have used the raw interface pointers previously in the directX bindings for openXR. I don't think we have any guidance here LazyDodo: They are COM objects, which need lifetime management though `IUnknown`, `ComPtr` will do this… | |||||
Not Done Inline ActionsOk, it's fine to use it then. brecht: Ok, it's fine to use it then. | |||||
Not Done Inline ActionsI wouldn't mind, even prefer using ComPtr XR or other Win32 code (XR code did use it at first). In general I prefer RAII memory management. Probably the main reason why I removed them was the fact that we didn't use them elsewhere, which made me insecure about using them. It seemed like on purpose. Severin: I wouldn't mind, even prefer using `ComPtr` XR or other Win32 code (XR code did use it at… | |||||
Not Done Inline Actionsif we're ok with using smart pointers, we should probably also update the dx bindings, i think i made @Julian Eisel (Severin) take them out previously, the explanation above was to explain why unique_ptr would not work, it's not an endorsement or rejection of the use of ComPtr LazyDodo: if we're ok with using smart pointers, we should probably also update the dx bindings, i think… | |||||
Done Inline Actionscursor_x, cursor_y don't need to be class member, they can be local variables. brecht: `cursor_x`, `cursor_y` don't need to be class member, they can be local variables. | |||||
Not Done Inline Actionscursor_x and cursor_y are updated only when the gesture starts and are used until the next gesture. Otherwise inertia animation will update UI under the cursor, which is incorrect if cursor changed position. pembem22: `cursor_x` and `cursor_y` are updated only when the gesture starts and are used until the next… | |||||
Please move this after pktdef.h with a separating newline, wintab.h through pktdef.h are a logical block of related includes/defines.