1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5   This software is provided 'as-is', without any express or implied
6   warranty.  In no event will the authors be held liable for any damages
7   arising from the use of this software.
8 
9   Permission is granted to anyone to use this software for any purpose,
10   including commercial applications, and to alter it and redistribute it
11   freely, subject to the following restrictions:
12 
13   1. The origin of this software must not be misrepresented; you must not
14      claim that you wrote the original software. If you use this software
15      in a product, an acknowledgment in the product documentation would be
16      appreciated but is not required.
17   2. Altered source versions must be plainly marked as such, and must not be
18      misrepresented as being the original software.
19   3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../../SDL_internal.h"
22 
23 #ifndef SDL_windowsvideo_h_
24 #define SDL_windowsvideo_h_
25 
26 #include "../../core/windows/SDL_windows.h"
27 
28 #include "../SDL_sysvideo.h"
29 
30 #if defined(_MSC_VER) && (_MSC_VER >= 1500)
31 #include <msctf.h>
32 #else
33 #include "SDL_msctf.h"
34 #endif
35 
36 #include <imm.h>
37 
38 #define MAX_CANDLIST    10
39 #define MAX_CANDLENGTH  256
40 
41 #include "SDL_windowsclipboard.h"
42 #include "SDL_windowsevents.h"
43 #include "SDL_windowskeyboard.h"
44 #include "SDL_windowsmodes.h"
45 #include "SDL_windowsmouse.h"
46 #include "SDL_windowsopengl.h"
47 #include "SDL_windowsopengles.h"
48 #include "SDL_windowswindow.h"
49 #include "SDL_events.h"
50 #include "SDL_loadso.h"
51 
52 
53 #if WINVER < 0x0601
54 /* Touch input definitions */
55 #define TWF_FINETOUCH   1
56 #define TWF_WANTPALM    2
57 
58 #define TOUCHEVENTF_MOVE 0x0001
59 #define TOUCHEVENTF_DOWN 0x0002
60 #define TOUCHEVENTF_UP   0x0004
61 
62 DECLARE_HANDLE(HTOUCHINPUT);
63 
64 typedef struct _TOUCHINPUT {
65     LONG      x;
66     LONG      y;
67     HANDLE    hSource;
68     DWORD     dwID;
69     DWORD     dwFlags;
70     DWORD     dwMask;
71     DWORD     dwTime;
72     ULONG_PTR dwExtraInfo;
73     DWORD     cxContact;
74     DWORD     cyContact;
75 } TOUCHINPUT, *PTOUCHINPUT;
76 
77 #endif /* WINVER < 0x0601 */
78 
79 #if WINVER < 0x0603
80 
81 typedef enum MONITOR_DPI_TYPE {
82     MDT_EFFECTIVE_DPI = 0,
83     MDT_ANGULAR_DPI = 1,
84     MDT_RAW_DPI = 2,
85     MDT_DEFAULT = MDT_EFFECTIVE_DPI
86 } MONITOR_DPI_TYPE;
87 
88 #endif /* WINVER < 0x0603 */
89 
90 typedef BOOL  (*PFNSHFullScreen)(HWND, DWORD);
91 typedef void  (*PFCoordTransform)(SDL_Window*, POINT*);
92 
93 typedef struct
94 {
95     void **lpVtbl;
96     int refcount;
97     void *data;
98 } TSFSink;
99 
100 /* Definition from Win98DDK version of IMM.H */
101 typedef struct tagINPUTCONTEXT2 {
102     HWND hWnd;
103     BOOL fOpen;
104     POINT ptStatusWndPos;
105     POINT ptSoftKbdPos;
106     DWORD fdwConversion;
107     DWORD fdwSentence;
108     union {
109         LOGFONTA A;
110         LOGFONTW W;
111     } lfFont;
112     COMPOSITIONFORM cfCompForm;
113     CANDIDATEFORM cfCandForm[4];
114     HIMCC hCompStr;
115     HIMCC hCandInfo;
116     HIMCC hGuideLine;
117     HIMCC hPrivate;
118     DWORD dwNumMsgBuf;
119     HIMCC hMsgBuf;
120     DWORD fdwInit;
121     DWORD dwReserve[3];
122 } INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2;
123 
124 /* Private display data */
125 
126 typedef struct SDL_VideoData
127 {
128     int render;
129 
130     DWORD clipboard_count;
131 
132     /* Touch input functions */
133     void* userDLL;
134     BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
135     BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
136     BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
137 
138     void* shcoreDLL;
139     HRESULT (WINAPI *GetDpiForMonitor)( HMONITOR         hmonitor,
140                                         MONITOR_DPI_TYPE dpiType,
141                                         UINT             *dpiX,
142                                         UINT             *dpiY );
143 
144     SDL_bool ime_com_initialized;
145     struct ITfThreadMgr *ime_threadmgr;
146     SDL_bool ime_initialized;
147     SDL_bool ime_enabled;
148     SDL_bool ime_available;
149     HWND ime_hwnd_main;
150     HWND ime_hwnd_current;
151     HIMC ime_himc;
152 
153     WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
154     WCHAR ime_readingstring[16];
155     int ime_cursor;
156 
157     SDL_bool ime_candlist;
158     WCHAR ime_candidates[MAX_CANDLIST][MAX_CANDLENGTH];
159     DWORD ime_candcount;
160     DWORD ime_candref;
161     DWORD ime_candsel;
162     UINT ime_candpgsize;
163     int ime_candlistindexbase;
164     SDL_bool ime_candvertical;
165 
166     SDL_bool ime_dirty;
167     SDL_Rect ime_rect;
168     SDL_Rect ime_candlistrect;
169     int ime_winwidth;
170     int ime_winheight;
171 
172     HKL ime_hkl;
173     void* ime_himm32;
174     UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
175     BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
176     LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
177     BOOL (WINAPI *ImmUnlockIMC)(HIMC himc);
178     LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc);
179     BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
180 
181     SDL_bool ime_uiless;
182     struct ITfThreadMgrEx *ime_threadmgrex;
183     DWORD ime_uielemsinkcookie;
184     DWORD ime_alpnsinkcookie;
185     DWORD ime_openmodesinkcookie;
186     DWORD ime_convmodesinkcookie;
187     TSFSink *ime_uielemsink;
188     TSFSink *ime_ippasink;
189 } SDL_VideoData;
190 
191 extern SDL_bool g_WindowsEnableMessageLoop;
192 extern SDL_bool g_WindowFrameUsableWhileCursorHidden;
193 
194 typedef struct IDirect3D9 IDirect3D9;
195 extern SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface );
196 
197 #endif /* SDL_windowsvideo_h_ */
198 
199 /* vi: set ts=4 sw=4 expandtab: */
200