early-access version 1611
This commit is contained in:
242
externals/SDL/src/video/windows/SDL_msctf.h
vendored
Executable file
242
externals/SDL/src/video/windows/SDL_msctf.h
vendored
Executable file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_msctf_h_
|
||||
#define SDL_msctf_h_
|
||||
|
||||
#include <unknwn.h>
|
||||
|
||||
#define TF_INVALID_COOKIE (0xffffffff)
|
||||
#define TF_IPSINK_FLAG_ACTIVE 0x0001
|
||||
#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004
|
||||
|
||||
typedef struct ITfThreadMgr ITfThreadMgr;
|
||||
typedef struct ITfDocumentMgr ITfDocumentMgr;
|
||||
typedef struct ITfClientId ITfClientId;
|
||||
|
||||
typedef struct IEnumTfDocumentMgrs IEnumTfDocumentMgrs;
|
||||
typedef struct IEnumTfFunctionProviders IEnumTfFunctionProviders;
|
||||
typedef struct ITfFunctionProvider ITfFunctionProvider;
|
||||
typedef struct ITfCompartmentMgr ITfCompartmentMgr;
|
||||
typedef struct ITfContext ITfContext;
|
||||
typedef struct IEnumTfContexts IEnumTfContexts;
|
||||
typedef struct ITfUIElementSink ITfUIElementSink;
|
||||
typedef struct ITfUIElement ITfUIElement;
|
||||
typedef struct ITfUIElementMgr ITfUIElementMgr;
|
||||
typedef struct IEnumTfUIElements IEnumTfUIElements;
|
||||
typedef struct ITfThreadMgrEx ITfThreadMgrEx;
|
||||
typedef struct ITfCandidateListUIElement ITfCandidateListUIElement;
|
||||
typedef struct ITfReadingInformationUIElement ITfReadingInformationUIElement;
|
||||
typedef struct ITfInputProcessorProfileActivationSink ITfInputProcessorProfileActivationSink;
|
||||
typedef struct ITfSource ITfSource;
|
||||
|
||||
typedef DWORD TfClientId;
|
||||
typedef DWORD TfEditCookie;
|
||||
|
||||
typedef struct ITfThreadMgrVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgr *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgr *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgr *, TfClientId *);
|
||||
HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgr *, IEnumTfDocumentMgrs **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgr *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgr *, ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgr *, HWND, ITfDocumentMgr *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgr *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgr *, REFCLSID, ITfFunctionProvider **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgr *, IEnumTfFunctionProviders **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgr *, ITfCompartmentMgr **);
|
||||
} ITfThreadMgrVtbl;
|
||||
|
||||
struct ITfThreadMgr
|
||||
{
|
||||
const struct ITfThreadMgrVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfThreadMgrExVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgrEx *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgrEx *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgrEx *);
|
||||
HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgrEx *, TfClientId *);
|
||||
HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgrEx *);
|
||||
HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgrEx *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgrEx *, IEnumTfDocumentMgrs **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgrEx *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgrEx *, ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgrEx *, ITfDocumentMgr *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgrEx *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgrEx *, REFCLSID, ITfFunctionProvider **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgrEx *, IEnumTfFunctionProviders **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgrEx *, ITfCompartmentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *ActivateEx)(ITfThreadMgrEx *, TfClientId *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *GetActiveFlags)(ITfThreadMgrEx *, DWORD *);
|
||||
} ITfThreadMgrExVtbl;
|
||||
|
||||
struct ITfThreadMgrEx
|
||||
{
|
||||
const struct ITfThreadMgrExVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfDocumentMgrVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfDocumentMgr *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfDocumentMgr *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *CreateContext)(ITfDocumentMgr *, TfClientId, DWORD, IUnknown *, ITfContext **, TfEditCookie *);
|
||||
HRESULT (STDMETHODCALLTYPE *Push)(ITfDocumentMgr *, ITfContext *);
|
||||
HRESULT (STDMETHODCALLTYPE *Pop)(ITfDocumentMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetTop)(ITfDocumentMgr *, ITfContext **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetBase)(ITfDocumentMgr *, ITfContext **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumContexts)(ITfDocumentMgr *, IEnumTfContexts **);
|
||||
} ITfDocumentMgrVtbl;
|
||||
|
||||
struct ITfDocumentMgr
|
||||
{
|
||||
const struct ITfDocumentMgrVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfUIElementSinkVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementSink *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementSink *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementSink *);
|
||||
HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementSink *, DWORD, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementSink *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementSink *, DWORD);
|
||||
} ITfUIElementSinkVtbl;
|
||||
|
||||
struct ITfUIElementSink
|
||||
{
|
||||
const struct ITfUIElementSinkVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfUIElementMgrVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementMgr *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementMgr *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementMgr *);
|
||||
HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementMgr *, ITfUIElement *, BOOL *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementMgr *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementMgr *, DWORD);
|
||||
HRESULT (STDMETHODCALLTYPE *GetUIElement)(ITfUIElementMgr *, DWORD, ITfUIElement **);
|
||||
HRESULT (STDMETHODCALLTYPE *EnumUIElements)(ITfUIElementMgr *, IEnumTfUIElements **);
|
||||
} ITfUIElementMgrVtbl;
|
||||
|
||||
struct ITfUIElementMgr
|
||||
{
|
||||
const struct ITfUIElementMgrVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfCandidateListUIElementVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfCandidateListUIElement *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfCandidateListUIElement *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfCandidateListUIElement *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfCandidateListUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfCandidateListUIElement *, GUID *);
|
||||
HRESULT (STDMETHODCALLTYPE *Show)(ITfCandidateListUIElement *, BOOL);
|
||||
HRESULT (STDMETHODCALLTYPE *IsShown)(ITfCandidateListUIElement *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfCandidateListUIElement *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetDocumentMgr)(ITfCandidateListUIElement *, ITfDocumentMgr **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetCount)(ITfCandidateListUIElement *, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetSelection)(ITfCandidateListUIElement *, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetString)(ITfCandidateListUIElement *, UINT, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *SetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT);
|
||||
HRESULT (STDMETHODCALLTYPE *GetCurrentPage)(ITfCandidateListUIElement *, UINT *);
|
||||
} ITfCandidateListUIElementVtbl;
|
||||
|
||||
struct ITfCandidateListUIElement
|
||||
{
|
||||
const struct ITfCandidateListUIElementVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfReadingInformationUIElementVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfReadingInformationUIElement *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfReadingInformationUIElement *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfReadingInformationUIElement *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfReadingInformationUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfReadingInformationUIElement *, GUID *);
|
||||
HRESULT (STDMETHODCALLTYPE *Show)(ITfReadingInformationUIElement *, BOOL);
|
||||
HRESULT (STDMETHODCALLTYPE *IsShown)(ITfReadingInformationUIElement *, BOOL *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfReadingInformationUIElement *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetContext)(ITfReadingInformationUIElement *, ITfContext **);
|
||||
HRESULT (STDMETHODCALLTYPE *GetString)(ITfReadingInformationUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetMaxReadingStringLength)(ITfReadingInformationUIElement *, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetErrorIndex)(ITfReadingInformationUIElement *, UINT *);
|
||||
HRESULT (STDMETHODCALLTYPE *IsVerticalOrderPreferred)(ITfReadingInformationUIElement *, BOOL *);
|
||||
} ITfReadingInformationUIElementVtbl;
|
||||
|
||||
struct ITfReadingInformationUIElement
|
||||
{
|
||||
const struct ITfReadingInformationUIElementVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfUIElementVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElement *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElement *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfUIElement *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfUIElement *, BSTR *);
|
||||
HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfUIElement *, GUID *);
|
||||
HRESULT (STDMETHODCALLTYPE *Show)(ITfUIElement *, BOOL);
|
||||
HRESULT (STDMETHODCALLTYPE *IsShown)(ITfUIElement *, BOOL *);
|
||||
} ITfUIElementVtbl;
|
||||
|
||||
struct ITfUIElement
|
||||
{
|
||||
const struct ITfUIElementVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfInputProcessorProfileActivationSinkVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfInputProcessorProfileActivationSink *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfInputProcessorProfileActivationSink *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfInputProcessorProfileActivationSink *);
|
||||
HRESULT (STDMETHODCALLTYPE *OnActivated)(ITfInputProcessorProfileActivationSink *, DWORD, LANGID, REFCLSID, REFGUID, REFGUID, HKL, DWORD);
|
||||
|
||||
} ITfInputProcessorProfileActivationSinkVtbl;
|
||||
|
||||
struct ITfInputProcessorProfileActivationSink
|
||||
{
|
||||
const struct ITfInputProcessorProfileActivationSinkVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
typedef struct ITfSourceVtbl
|
||||
{
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfSource *, REFIID, void **);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(ITfSource *);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(ITfSource *);
|
||||
HRESULT (STDMETHODCALLTYPE *AdviseSink)(ITfSource *, REFIID, IUnknown *, DWORD *);
|
||||
HRESULT (STDMETHODCALLTYPE *UnadviseSink)(ITfSource *, DWORD);
|
||||
} ITfSourceVtbl;
|
||||
|
||||
struct ITfSource
|
||||
{
|
||||
const struct ITfSourceVtbl *lpVtbl;
|
||||
};
|
||||
|
||||
#endif /* SDL_msctf_h_ */
|
76
externals/SDL/src/video/windows/SDL_vkeys.h
vendored
Executable file
76
externals/SDL/src/video/windows/SDL_vkeys.h
vendored
Executable file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef VK_0
|
||||
#define VK_0 '0'
|
||||
#define VK_1 '1'
|
||||
#define VK_2 '2'
|
||||
#define VK_3 '3'
|
||||
#define VK_4 '4'
|
||||
#define VK_5 '5'
|
||||
#define VK_6 '6'
|
||||
#define VK_7 '7'
|
||||
#define VK_8 '8'
|
||||
#define VK_9 '9'
|
||||
#define VK_A 'A'
|
||||
#define VK_B 'B'
|
||||
#define VK_C 'C'
|
||||
#define VK_D 'D'
|
||||
#define VK_E 'E'
|
||||
#define VK_F 'F'
|
||||
#define VK_G 'G'
|
||||
#define VK_H 'H'
|
||||
#define VK_I 'I'
|
||||
#define VK_J 'J'
|
||||
#define VK_K 'K'
|
||||
#define VK_L 'L'
|
||||
#define VK_M 'M'
|
||||
#define VK_N 'N'
|
||||
#define VK_O 'O'
|
||||
#define VK_P 'P'
|
||||
#define VK_Q 'Q'
|
||||
#define VK_R 'R'
|
||||
#define VK_S 'S'
|
||||
#define VK_T 'T'
|
||||
#define VK_U 'U'
|
||||
#define VK_V 'V'
|
||||
#define VK_W 'W'
|
||||
#define VK_X 'X'
|
||||
#define VK_Y 'Y'
|
||||
#define VK_Z 'Z'
|
||||
#endif /* VK_0 */
|
||||
|
||||
/* These keys haven't been defined, but were experimentally determined */
|
||||
#define VK_SEMICOLON 0xBA
|
||||
#define VK_EQUALS 0xBB
|
||||
#define VK_COMMA 0xBC
|
||||
#define VK_MINUS 0xBD
|
||||
#define VK_PERIOD 0xBE
|
||||
#define VK_SLASH 0xBF
|
||||
#define VK_GRAVE 0xC0
|
||||
#define VK_LBRACKET 0xDB
|
||||
#define VK_BACKSLASH 0xDC
|
||||
#define VK_RBRACKET 0xDD
|
||||
#define VK_APOSTROPHE 0xDE
|
||||
#define VK_BACKTICK 0xDF
|
||||
#define VK_OEM_102 0xE2
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
160
externals/SDL/src/video/windows/SDL_windowsclipboard.c
vendored
Executable file
160
externals/SDL/src/video/windows/SDL_windowsclipboard.c
vendored
Executable file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "../../events/SDL_clipboardevents_c.h"
|
||||
|
||||
|
||||
#ifdef UNICODE
|
||||
#define TEXT_FORMAT CF_UNICODETEXT
|
||||
#else
|
||||
#define TEXT_FORMAT CF_TEXT
|
||||
#endif
|
||||
|
||||
|
||||
/* Get any application owned window handle for clipboard association */
|
||||
static HWND
|
||||
GetWindowHandle(_THIS)
|
||||
{
|
||||
SDL_Window *window;
|
||||
|
||||
window = _this->windows;
|
||||
if (window) {
|
||||
return ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_SetClipboardText(_THIS, const char *text)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
int result = 0;
|
||||
|
||||
if (OpenClipboard(GetWindowHandle(_this))) {
|
||||
HANDLE hMem;
|
||||
LPTSTR tstr;
|
||||
SIZE_T i, size;
|
||||
|
||||
/* Convert the text from UTF-8 to Windows Unicode */
|
||||
tstr = WIN_UTF8ToString(text);
|
||||
if (!tstr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Find out the size of the data */
|
||||
for (size = 0, i = 0; tstr[i]; ++i, ++size) {
|
||||
if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) {
|
||||
/* We're going to insert a carriage return */
|
||||
++size;
|
||||
}
|
||||
}
|
||||
size = (size+1)*sizeof(*tstr);
|
||||
|
||||
/* Save the data to the clipboard */
|
||||
hMem = GlobalAlloc(GMEM_MOVEABLE, size);
|
||||
if (hMem) {
|
||||
LPTSTR dst = (LPTSTR)GlobalLock(hMem);
|
||||
if (dst) {
|
||||
/* Copy the text over, adding carriage returns as necessary */
|
||||
for (i = 0; tstr[i]; ++i) {
|
||||
if (tstr[i] == '\n' && (i == 0 || tstr[i-1] != '\r')) {
|
||||
*dst++ = '\r';
|
||||
}
|
||||
*dst++ = tstr[i];
|
||||
}
|
||||
*dst = 0;
|
||||
GlobalUnlock(hMem);
|
||||
}
|
||||
|
||||
EmptyClipboard();
|
||||
if (!SetClipboardData(TEXT_FORMAT, hMem)) {
|
||||
result = WIN_SetError("Couldn't set clipboard data");
|
||||
}
|
||||
data->clipboard_count = GetClipboardSequenceNumber();
|
||||
}
|
||||
SDL_free(tstr);
|
||||
|
||||
CloseClipboard();
|
||||
} else {
|
||||
result = WIN_SetError("Couldn't open clipboard");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
WIN_GetClipboardText(_THIS)
|
||||
{
|
||||
char *text;
|
||||
|
||||
text = NULL;
|
||||
if (IsClipboardFormatAvailable(TEXT_FORMAT) &&
|
||||
OpenClipboard(GetWindowHandle(_this))) {
|
||||
HANDLE hMem;
|
||||
LPTSTR tstr;
|
||||
|
||||
hMem = GetClipboardData(TEXT_FORMAT);
|
||||
if (hMem) {
|
||||
tstr = (LPTSTR)GlobalLock(hMem);
|
||||
text = WIN_StringToUTF8(tstr);
|
||||
GlobalUnlock(hMem);
|
||||
} else {
|
||||
WIN_SetError("Couldn't get clipboard data");
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
if (!text) {
|
||||
text = SDL_strdup("");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
WIN_HasClipboardText(_THIS)
|
||||
{
|
||||
SDL_bool result = SDL_FALSE;
|
||||
char *text = WIN_GetClipboardText(_this);
|
||||
if (text) {
|
||||
result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_free(text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
{
|
||||
const DWORD count = GetClipboardSequenceNumber();
|
||||
if (count != data->clipboard_count) {
|
||||
if (data->clipboard_count) {
|
||||
SDL_SendClipboardUpdate();
|
||||
}
|
||||
data->clipboard_count = count;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
36
externals/SDL/src/video/windows/SDL_windowsclipboard.h
vendored
Executable file
36
externals/SDL/src/video/windows/SDL_windowsclipboard.h
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsclipboard_h_
|
||||
#define SDL_windowsclipboard_h_
|
||||
|
||||
/* Forward declaration */
|
||||
struct SDL_VideoData;
|
||||
|
||||
extern int WIN_SetClipboardText(_THIS, const char *text);
|
||||
extern char *WIN_GetClipboardText(_THIS);
|
||||
extern SDL_bool WIN_HasClipboardText(_THIS);
|
||||
extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data);
|
||||
|
||||
#endif /* SDL_windowsclipboard_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1309
externals/SDL/src/video/windows/SDL_windowsevents.c
vendored
Executable file
1309
externals/SDL/src/video/windows/SDL_windowsevents.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
36
externals/SDL/src/video/windows/SDL_windowsevents.h
vendored
Executable file
36
externals/SDL/src/video/windows/SDL_windowsevents.h
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsevents_h_
|
||||
#define SDL_windowsevents_h_
|
||||
|
||||
extern LPTSTR SDL_Appname;
|
||||
extern Uint32 SDL_Appstyle;
|
||||
extern HINSTANCE SDL_Instance;
|
||||
|
||||
extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
extern void WIN_PumpEvents(_THIS);
|
||||
|
||||
#endif /* SDL_windowsevents_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
128
externals/SDL/src/video/windows/SDL_windowsframebuffer.c
vendored
Executable file
128
externals/SDL/src/video/windows/SDL_windowsframebuffer.c
vendored
Executable file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
|
||||
int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_bool isstack;
|
||||
size_t size;
|
||||
LPBITMAPINFO info;
|
||||
HBITMAP hbm;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
if (data->mdc) {
|
||||
DeleteDC(data->mdc);
|
||||
}
|
||||
if (data->hbm) {
|
||||
DeleteObject(data->hbm);
|
||||
}
|
||||
|
||||
/* Find out the format of the screen */
|
||||
size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
|
||||
info = (LPBITMAPINFO)SDL_small_alloc(Uint8, size, &isstack);
|
||||
if (!info) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_memset(info, 0, size);
|
||||
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
|
||||
/* The second call to GetDIBits() fills in the bitfields */
|
||||
hbm = CreateCompatibleBitmap(data->hdc, 1, 1);
|
||||
GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS);
|
||||
GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS);
|
||||
DeleteObject(hbm);
|
||||
|
||||
*format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
if (info->bmiHeader.biCompression == BI_BITFIELDS) {
|
||||
int bpp;
|
||||
Uint32 *masks;
|
||||
|
||||
bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount;
|
||||
masks = (Uint32*)((Uint8*)info + info->bmiHeader.biSize);
|
||||
*format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0);
|
||||
}
|
||||
if (*format == SDL_PIXELFORMAT_UNKNOWN)
|
||||
{
|
||||
/* We'll use RGB format for now */
|
||||
*format = SDL_PIXELFORMAT_RGB888;
|
||||
|
||||
/* Create a new one */
|
||||
SDL_memset(info, 0, size);
|
||||
info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
info->bmiHeader.biPlanes = 1;
|
||||
info->bmiHeader.biBitCount = 32;
|
||||
info->bmiHeader.biCompression = BI_RGB;
|
||||
}
|
||||
|
||||
/* Fill in the size information */
|
||||
*pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
||||
info->bmiHeader.biWidth = window->w;
|
||||
info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */
|
||||
info->bmiHeader.biSizeImage = window->h * (*pitch);
|
||||
|
||||
data->mdc = CreateCompatibleDC(data->hdc);
|
||||
data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0);
|
||||
SDL_small_free(info, isstack);
|
||||
|
||||
if (!data->hbm) {
|
||||
return WIN_SetError("Unable to create DIB");
|
||||
}
|
||||
SelectObject(data->mdc, data->hbm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
BitBlt(data->hdc, 0, 0, window->w, window->h, data->mdc, 0, 0, SRCCOPY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (!data) {
|
||||
/* The window wasn't fully initialized */
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->mdc) {
|
||||
DeleteDC(data->mdc);
|
||||
data->mdc = NULL;
|
||||
}
|
||||
if (data->hbm) {
|
||||
DeleteObject(data->hbm);
|
||||
data->hbm = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
27
externals/SDL/src/video/windows/SDL_windowsframebuffer.h
vendored
Executable file
27
externals/SDL/src/video/windows/SDL_windowsframebuffer.h
vendored
Executable file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
extern int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
|
||||
extern int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
|
||||
extern void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1579
externals/SDL/src/video/windows/SDL_windowskeyboard.c
vendored
Executable file
1579
externals/SDL/src/video/windows/SDL_windowskeyboard.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
40
externals/SDL/src/video/windows/SDL_windowskeyboard.h
vendored
Executable file
40
externals/SDL/src/video/windows/SDL_windowskeyboard.h
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowskeyboard_h_
|
||||
#define SDL_windowskeyboard_h_
|
||||
|
||||
extern void WIN_InitKeyboard(_THIS);
|
||||
extern void WIN_UpdateKeymap(void);
|
||||
extern void WIN_QuitKeyboard(_THIS);
|
||||
|
||||
extern void WIN_ResetDeadKeys(void);
|
||||
|
||||
extern void WIN_StartTextInput(_THIS);
|
||||
extern void WIN_StopTextInput(_THIS);
|
||||
extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect);
|
||||
|
||||
extern SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata);
|
||||
|
||||
#endif /* SDL_windowskeyboard_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
918
externals/SDL/src/video/windows/SDL_windowsmessagebox.c
vendored
Executable file
918
externals/SDL/src/video/windows/SDL_windowsmessagebox.c
vendored
Executable file
@@ -0,0 +1,918 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#else
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX ((size_t)-1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowstaskdialog.h"
|
||||
|
||||
#ifndef SS_EDITCONTROL
|
||||
#define SS_EDITCONTROL 0x2000
|
||||
#endif
|
||||
|
||||
#ifndef IDOK
|
||||
#define IDOK 1
|
||||
#endif
|
||||
|
||||
#ifndef IDCANCEL
|
||||
#define IDCANCEL 2
|
||||
#endif
|
||||
|
||||
/* Custom dialog return codes */
|
||||
#define IDCLOSED 20
|
||||
#define IDINVALPTRINIT 50
|
||||
#define IDINVALPTRCOMMAND 51
|
||||
#define IDINVALPTRSETFOCUS 52
|
||||
#define IDINVALPTRDLGITEM 53
|
||||
/* First button ID */
|
||||
#define IDBUTTONINDEX0 100
|
||||
|
||||
#define DLGITEMTYPEBUTTON 0x0080
|
||||
#define DLGITEMTYPESTATIC 0x0082
|
||||
|
||||
/* Windows only sends the lower 16 bits of the control ID when a button
|
||||
* gets clicked. There are also some predefined and custom IDs that lower
|
||||
* the available number further. 2^16 - 101 buttons should be enough for
|
||||
* everyone, no need to make the code more complex.
|
||||
*/
|
||||
#define MAX_BUTTONS (0xffff - 100)
|
||||
|
||||
|
||||
/* Display a Windows message box */
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD dlgVer;
|
||||
WORD signature;
|
||||
DWORD helpID;
|
||||
DWORD exStyle;
|
||||
DWORD style;
|
||||
WORD cDlgItems;
|
||||
short x;
|
||||
short y;
|
||||
short cx;
|
||||
short cy;
|
||||
} DLGTEMPLATEEX;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD helpID;
|
||||
DWORD exStyle;
|
||||
DWORD style;
|
||||
short x;
|
||||
short y;
|
||||
short cx;
|
||||
short cy;
|
||||
DWORD id;
|
||||
} DLGITEMTEMPLATEEX;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DLGTEMPLATEEX* lpDialog;
|
||||
Uint8 *data;
|
||||
size_t size;
|
||||
size_t used;
|
||||
WORD numbuttons;
|
||||
} WIN_DialogData;
|
||||
|
||||
static SDL_bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, Uint32 flags, size_t *i)
|
||||
{
|
||||
for (*i = 0; *i < (size_t)messageboxdata->numbuttons; ++*i) {
|
||||
if (messageboxdata->buttons[*i].flags & flags) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
const SDL_MessageBoxData *messageboxdata;
|
||||
size_t buttonindex;
|
||||
|
||||
switch ( iMessage ) {
|
||||
case WM_INITDIALOG:
|
||||
if (lParam == 0) {
|
||||
EndDialog(hDlg, IDINVALPTRINIT);
|
||||
return TRUE;
|
||||
}
|
||||
messageboxdata = (const SDL_MessageBoxData *)lParam;
|
||||
SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
|
||||
|
||||
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) {
|
||||
/* Focus on the first default return-key button */
|
||||
HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex));
|
||||
if (buttonctl == NULL) {
|
||||
EndDialog(hDlg, IDINVALPTRDLGITEM);
|
||||
}
|
||||
PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE);
|
||||
} else {
|
||||
/* Give the focus to the dialog window instead */
|
||||
SetFocus(hDlg);
|
||||
}
|
||||
return FALSE;
|
||||
case WM_SETFOCUS:
|
||||
messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
|
||||
if (messageboxdata == NULL) {
|
||||
EndDialog(hDlg, IDINVALPTRSETFOCUS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Let the default button be focused if there is one. Otherwise, prevent any initial focus. */
|
||||
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
|
||||
if (messageboxdata == NULL) {
|
||||
EndDialog(hDlg, IDINVALPTRCOMMAND);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Return the ID of the button that was pushed */
|
||||
if (wParam == IDOK) {
|
||||
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) {
|
||||
EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex);
|
||||
}
|
||||
} else if (wParam == IDCANCEL) {
|
||||
if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, &buttonindex)) {
|
||||
EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex);
|
||||
} else {
|
||||
/* Closing of window was requested by user or system. It would be rude not to comply. */
|
||||
EndDialog(hDlg, IDCLOSED);
|
||||
}
|
||||
} else if (wParam >= IDBUTTONINDEX0 && (int)wParam - IDBUTTONINDEX0 < messageboxdata->numbuttons) {
|
||||
EndDialog(hDlg, wParam);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space)
|
||||
{
|
||||
/* Growing memory in 64 KiB steps. */
|
||||
const size_t sizestep = 0x10000;
|
||||
size_t size = dialog->size;
|
||||
|
||||
if (size == 0) {
|
||||
/* Start with 4 KiB or a multiple of 64 KiB to fit the data. */
|
||||
size = 0x1000;
|
||||
if (SIZE_MAX - sizestep < space) {
|
||||
size = space;
|
||||
} else if (space > size) {
|
||||
size = (space + sizestep) & ~(sizestep - 1);
|
||||
}
|
||||
} else if (SIZE_MAX - dialog->used < space) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
} else if (SIZE_MAX - (dialog->used + space) < sizestep) {
|
||||
/* Close to the maximum. */
|
||||
size = dialog->used + space;
|
||||
} else if (size < dialog->used + space) {
|
||||
/* Round up to the next 64 KiB block. */
|
||||
size = dialog->used + space;
|
||||
size += sizestep - size % sizestep;
|
||||
}
|
||||
|
||||
if (size > dialog->size) {
|
||||
void *data = SDL_realloc(dialog->data, size);
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return SDL_FALSE;
|
||||
}
|
||||
dialog->data = data;
|
||||
dialog->size = size;
|
||||
dialog->lpDialog = (DLGTEMPLATEEX*)dialog->data;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static SDL_bool AlignDialogData(WIN_DialogData *dialog, size_t size)
|
||||
{
|
||||
size_t padding = (dialog->used % size);
|
||||
|
||||
if (!ExpandDialogSpace(dialog, padding)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
dialog->used += padding;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static SDL_bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t size)
|
||||
{
|
||||
if (!ExpandDialogSpace(dialog, size)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_memcpy(dialog->data+dialog->used, data, size);
|
||||
dialog->used += size;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string)
|
||||
{
|
||||
WCHAR *wstring;
|
||||
WCHAR *p;
|
||||
size_t count;
|
||||
SDL_bool status;
|
||||
|
||||
if (!string) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
wstring = WIN_UTF8ToString(string);
|
||||
if (!wstring) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Find out how many characters we have, including null terminator */
|
||||
count = 0;
|
||||
for (p = wstring; *p; ++p) {
|
||||
++count;
|
||||
}
|
||||
++count;
|
||||
|
||||
status = AddDialogData(dialog, wstring, count*sizeof(WCHAR));
|
||||
SDL_free(wstring);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int s_BaseUnitsX;
|
||||
static int s_BaseUnitsY;
|
||||
static void Vec2ToDLU(short *x, short *y)
|
||||
{
|
||||
SDL_assert(s_BaseUnitsX != 0); /* we init in WIN_ShowMessageBox(), which is the only public function... */
|
||||
|
||||
*x = MulDiv(*x, 4, s_BaseUnitsX);
|
||||
*y = MulDiv(*y, 8, s_BaseUnitsY);
|
||||
}
|
||||
|
||||
|
||||
static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal)
|
||||
{
|
||||
DLGITEMTEMPLATEEX item;
|
||||
WORD marker = 0xFFFF;
|
||||
WORD extraData = 0;
|
||||
|
||||
SDL_zero(item);
|
||||
item.style = style;
|
||||
item.exStyle = exStyle;
|
||||
item.x = x;
|
||||
item.y = y;
|
||||
item.cx = w;
|
||||
item.cy = h;
|
||||
item.id = id;
|
||||
|
||||
Vec2ToDLU(&item.x, &item.y);
|
||||
Vec2ToDLU(&item.cx, &item.cy);
|
||||
|
||||
if (!AlignDialogData(dialog, sizeof(DWORD))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (!AddDialogData(dialog, &item, sizeof(item))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (!AddDialogData(dialog, &marker, sizeof(marker))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (!AddDialogData(dialog, &type, sizeof(type))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL)) {
|
||||
if (!AddDialogString(dialog, caption)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
} else {
|
||||
if (!AddDialogData(dialog, &marker, sizeof(marker))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (!AddDialogData(dialog, &ordinal, sizeof(ordinal))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
if (!AddDialogData(dialog, &extraData, sizeof(extraData))) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (type == DLGITEMTYPEBUTTON) {
|
||||
dialog->numbuttons++;
|
||||
}
|
||||
++dialog->lpDialog->cDlgItems;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static SDL_bool AddDialogStaticText(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text)
|
||||
{
|
||||
DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX | SS_EDITCONTROL | WS_GROUP;
|
||||
return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -1, text, 0);
|
||||
}
|
||||
|
||||
static SDL_bool AddDialogStaticIcon(WIN_DialogData *dialog, int x, int y, int w, int h, Uint16 ordinal)
|
||||
{
|
||||
DWORD style = WS_VISIBLE | WS_CHILD | SS_ICON | WS_GROUP;
|
||||
return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -2, NULL, ordinal);
|
||||
}
|
||||
|
||||
static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text, int id, SDL_bool isDefault)
|
||||
{
|
||||
DWORD style = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
|
||||
if (isDefault) {
|
||||
style |= BS_DEFPUSHBUTTON;
|
||||
} else {
|
||||
style |= BS_PUSHBUTTON;
|
||||
}
|
||||
/* The first button marks the start of the group. */
|
||||
if (dialog->numbuttons == 0) {
|
||||
style |= WS_GROUP;
|
||||
}
|
||||
return AddDialogControl(dialog, DLGITEMTYPEBUTTON, style, 0, x, y, w, h, id, text, 0);
|
||||
}
|
||||
|
||||
static void FreeDialogData(WIN_DialogData *dialog)
|
||||
{
|
||||
SDL_free(dialog->data);
|
||||
SDL_free(dialog);
|
||||
}
|
||||
|
||||
static WIN_DialogData *CreateDialogData(int w, int h, const char *caption)
|
||||
{
|
||||
WIN_DialogData *dialog;
|
||||
DLGTEMPLATEEX dialogTemplate;
|
||||
WORD WordToPass;
|
||||
|
||||
SDL_zero(dialogTemplate);
|
||||
dialogTemplate.dlgVer = 1;
|
||||
dialogTemplate.signature = 0xffff;
|
||||
dialogTemplate.style = (WS_CAPTION | DS_CENTER | DS_SHELLFONT);
|
||||
dialogTemplate.x = 0;
|
||||
dialogTemplate.y = 0;
|
||||
dialogTemplate.cx = w;
|
||||
dialogTemplate.cy = h;
|
||||
Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy);
|
||||
|
||||
dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog));
|
||||
if (!dialog) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!AddDialogData(dialog, &dialogTemplate, sizeof(dialogTemplate))) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* No menu */
|
||||
WordToPass = 0;
|
||||
if (!AddDialogData(dialog, &WordToPass, 2)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* No custom class */
|
||||
if (!AddDialogData(dialog, &WordToPass, 2)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* title */
|
||||
if (!AddDialogString(dialog, caption)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Font stuff */
|
||||
{
|
||||
/*
|
||||
* We want to use the system messagebox font.
|
||||
*/
|
||||
BYTE ToPass;
|
||||
|
||||
NONCLIENTMETRICSA NCM;
|
||||
NCM.cbSize = sizeof(NCM);
|
||||
SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0);
|
||||
|
||||
/* Font size - convert to logical font size for dialog parameter. */
|
||||
{
|
||||
HDC ScreenDC = GetDC(NULL);
|
||||
int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY);
|
||||
if (!LogicalPixelsY) /* This can happen if the application runs out of GDI handles */
|
||||
LogicalPixelsY = 72;
|
||||
WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY);
|
||||
ReleaseDC(NULL, ScreenDC);
|
||||
}
|
||||
|
||||
if (!AddDialogData(dialog, &WordToPass, 2)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Font weight */
|
||||
WordToPass = (WORD)NCM.lfMessageFont.lfWeight;
|
||||
if (!AddDialogData(dialog, &WordToPass, 2)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* italic? */
|
||||
ToPass = NCM.lfMessageFont.lfItalic;
|
||||
if (!AddDialogData(dialog, &ToPass, 1)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* charset? */
|
||||
ToPass = NCM.lfMessageFont.lfCharSet;
|
||||
if (!AddDialogData(dialog, &ToPass, 1)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* font typeface. */
|
||||
if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) {
|
||||
FreeDialogData(dialog);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/* Escaping ampersands is necessary to disable mnemonics in dialog controls.
|
||||
* The caller provides a char** for dst and a size_t* for dstlen where the
|
||||
* address of the work buffer and its size will be stored. Their values must be
|
||||
* NULL and 0 on the first call. src is the string to be escaped. On error, the
|
||||
* function returns NULL and, on success, returns a pointer to the escaped
|
||||
* sequence as a read-only string that is valid until the next call or until the
|
||||
* work buffer is freed. Once all strings have been processed, it's the caller's
|
||||
* responsibilty to free the work buffer with SDL_free, even on errors.
|
||||
*/
|
||||
static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src)
|
||||
{
|
||||
char *newdst;
|
||||
size_t ampcount = 0;
|
||||
size_t srclen = 0;
|
||||
|
||||
if (src == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (src[srclen]) {
|
||||
if (src[srclen] == '&') {
|
||||
ampcount++;
|
||||
}
|
||||
srclen++;
|
||||
}
|
||||
srclen++;
|
||||
|
||||
if (ampcount == 0) {
|
||||
/* Nothing to do. */
|
||||
return src;
|
||||
}
|
||||
if (SIZE_MAX - srclen < ampcount) {
|
||||
return NULL;
|
||||
}
|
||||
if (*dst == NULL || *dstlen < srclen + ampcount) {
|
||||
/* Allocating extra space in case the next strings are a bit longer. */
|
||||
size_t extraspace = SIZE_MAX - (srclen + ampcount);
|
||||
if (extraspace > 512) {
|
||||
extraspace = 512;
|
||||
}
|
||||
*dstlen = srclen + ampcount + extraspace;
|
||||
SDL_free(*dst);
|
||||
*dst = NULL;
|
||||
newdst = SDL_malloc(*dstlen);
|
||||
if (newdst == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
*dst = newdst;
|
||||
} else {
|
||||
newdst = *dst;
|
||||
}
|
||||
|
||||
/* The escape character is the ampersand itself. */
|
||||
while (srclen--) {
|
||||
if (*src == '&') {
|
||||
*newdst++ = '&';
|
||||
}
|
||||
*newdst++ = *src++;
|
||||
}
|
||||
|
||||
return *dst;
|
||||
}
|
||||
|
||||
/* This function is called if a Task Dialog is unsupported. */
|
||||
static int
|
||||
WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
WIN_DialogData *dialog;
|
||||
int i, x, y, retval;
|
||||
HFONT DialogFont;
|
||||
SIZE Size;
|
||||
RECT TextSize;
|
||||
wchar_t* wmessage;
|
||||
TEXTMETRIC TM;
|
||||
HDC FontDC;
|
||||
INT_PTR result;
|
||||
char *ampescape = NULL;
|
||||
size_t ampescapesize = 0;
|
||||
Uint16 defbuttoncount = 0;
|
||||
Uint16 icon = 0;
|
||||
|
||||
HWND ParentWindow = NULL;
|
||||
|
||||
const int ButtonWidth = 88;
|
||||
const int ButtonHeight = 26;
|
||||
const int TextMargin = 16;
|
||||
const int ButtonMargin = 12;
|
||||
const int IconWidth = GetSystemMetrics(SM_CXICON);
|
||||
const int IconHeight = GetSystemMetrics(SM_CYICON);
|
||||
const int IconMargin = 20;
|
||||
|
||||
if (messageboxdata->numbuttons > MAX_BUTTONS) {
|
||||
return SDL_SetError("Number of butons exceeds limit of %d", MAX_BUTTONS);
|
||||
}
|
||||
|
||||
switch (messageboxdata->flags) {
|
||||
case SDL_MESSAGEBOX_ERROR:
|
||||
icon = (Uint16)(size_t)IDI_ERROR;
|
||||
break;
|
||||
case SDL_MESSAGEBOX_WARNING:
|
||||
icon = (Uint16)(size_t)IDI_WARNING;
|
||||
break;
|
||||
case SDL_MESSAGEBOX_INFORMATION:
|
||||
icon = (Uint16)(size_t)IDI_INFORMATION;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Jan 25th, 2013 - dant@fleetsa.com
|
||||
*
|
||||
*
|
||||
* I've tried to make this more reasonable, but I've run in to a lot
|
||||
* of nonsense.
|
||||
*
|
||||
* The original issue is the code was written in pixels and not
|
||||
* dialog units (DLUs). All DialogBox functions use DLUs, which
|
||||
* vary based on the selected font (yay).
|
||||
*
|
||||
* According to MSDN, the most reliable way to convert is via
|
||||
* MapDialogUnits, which requires an HWND, which we don't have
|
||||
* at time of template creation.
|
||||
*
|
||||
* We do however have:
|
||||
* The system font (DLU width 8 for me)
|
||||
* The font we select for the dialog (DLU width 6 for me)
|
||||
*
|
||||
* Based on experimentation, *neither* of these return the value
|
||||
* actually used. Stepping in to MapDialogUnits(), the conversion
|
||||
* is fairly clear, and uses 7 for me.
|
||||
*
|
||||
* As a result, some of this is hacky to ensure the sizing is
|
||||
* somewhat correct.
|
||||
*
|
||||
* Honestly, a long term solution is to use CreateWindow, not CreateDialog.
|
||||
*
|
||||
|
||||
*
|
||||
* In order to get text dimensions we need to have a DC with the desired font.
|
||||
* I'm assuming a dialog box in SDL is rare enough we can to the create.
|
||||
*/
|
||||
FontDC = CreateCompatibleDC(0);
|
||||
|
||||
{
|
||||
/* Create a duplicate of the font used in system message boxes. */
|
||||
LOGFONT lf;
|
||||
NONCLIENTMETRICS NCM;
|
||||
NCM.cbSize = sizeof(NCM);
|
||||
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0);
|
||||
lf = NCM.lfMessageFont;
|
||||
DialogFont = CreateFontIndirect(&lf);
|
||||
}
|
||||
|
||||
/* Select the font in to our DC */
|
||||
SelectObject(FontDC, DialogFont);
|
||||
|
||||
{
|
||||
/* Get the metrics to try and figure our DLU conversion. */
|
||||
GetTextMetrics(FontDC, &TM);
|
||||
|
||||
/* Calculation from the following documentation:
|
||||
* https://support.microsoft.com/en-gb/help/125681/how-to-calculate-dialog-base-units-with-non-system-based-font
|
||||
* This fixes bug 2137, dialog box calculation with a fixed-width system font
|
||||
*/
|
||||
{
|
||||
SIZE extent;
|
||||
GetTextExtentPoint32A(FontDC, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &extent);
|
||||
s_BaseUnitsX = (extent.cx / 26 + 1) / 2;
|
||||
}
|
||||
/*s_BaseUnitsX = TM.tmAveCharWidth + 1;*/
|
||||
s_BaseUnitsY = TM.tmHeight;
|
||||
}
|
||||
|
||||
/* Measure the *pixel* size of the string. */
|
||||
wmessage = WIN_UTF8ToString(messageboxdata->message);
|
||||
SDL_zero(TextSize);
|
||||
DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL);
|
||||
|
||||
/* Add margins and some padding for hangs, etc. */
|
||||
TextSize.left += TextMargin;
|
||||
TextSize.right += TextMargin + 2;
|
||||
TextSize.top += TextMargin;
|
||||
TextSize.bottom += TextMargin + 2;
|
||||
|
||||
/* Done with the DC, and the string */
|
||||
DeleteDC(FontDC);
|
||||
SDL_free(wmessage);
|
||||
|
||||
/* Increase the size of the dialog by some border spacing around the text. */
|
||||
Size.cx = TextSize.right - TextSize.left;
|
||||
Size.cy = TextSize.bottom - TextSize.top;
|
||||
Size.cx += TextMargin * 2;
|
||||
Size.cy += TextMargin * 2;
|
||||
|
||||
/* Make dialog wider and shift text over for the icon. */
|
||||
if (icon) {
|
||||
Size.cx += IconMargin + IconWidth;
|
||||
TextSize.left += IconMargin + IconWidth;
|
||||
TextSize.right += IconMargin + IconWidth;
|
||||
}
|
||||
|
||||
/* Ensure the size is wide enough for all of the buttons. */
|
||||
if (Size.cx < messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin)
|
||||
Size.cx = messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin;
|
||||
|
||||
/* Reset the height to the icon size if it is actually bigger than the text. */
|
||||
if (icon && Size.cy < IconMargin * 2 + IconHeight) {
|
||||
Size.cy = IconMargin * 2 + IconHeight;
|
||||
}
|
||||
|
||||
/* Add vertical space for the buttons and border. */
|
||||
Size.cy += ButtonHeight + TextMargin;
|
||||
|
||||
dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title);
|
||||
if (!dialog) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (icon && ! AddDialogStaticIcon(dialog, IconMargin, IconMargin, IconWidth, IconHeight, icon)) {
|
||||
FreeDialogData(dialog);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!AddDialogStaticText(dialog, TextSize.left, TextSize.top, TextSize.right - TextSize.left, TextSize.bottom - TextSize.top, messageboxdata->message)) {
|
||||
FreeDialogData(dialog);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Align the buttons to the right/bottom. */
|
||||
x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->numbuttons;
|
||||
y = Size.cy - ButtonHeight - ButtonMargin;
|
||||
for (i = 0; i < messageboxdata->numbuttons; i++) {
|
||||
SDL_bool isdefault = SDL_FALSE;
|
||||
const char *buttontext;
|
||||
const SDL_MessageBoxButtonData *sdlButton;
|
||||
|
||||
/* We always have to create the dialog buttons from left to right
|
||||
* so that the tab order is correct. Select the info to use
|
||||
* depending on which order was requested. */
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT) {
|
||||
sdlButton = &messageboxdata->buttons[i];
|
||||
} else {
|
||||
sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i];
|
||||
}
|
||||
|
||||
if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||
defbuttoncount++;
|
||||
if (defbuttoncount == 1) {
|
||||
isdefault = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
buttontext = EscapeAmpersands(&escape, &escapesize, sdlButton->text);
|
||||
/* Make sure to provide the correct ID to keep buttons indexed in the
|
||||
* same order as how they are in messageboxdata. */
|
||||
if (buttontext == NULL || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) {
|
||||
FreeDialogData(dialog);
|
||||
SDL_free(ampescape);
|
||||
return -1;
|
||||
}
|
||||
|
||||
x += ButtonWidth + ButtonMargin;
|
||||
}
|
||||
SDL_free(ampescape);
|
||||
|
||||
/* If we have a parent window, get the Instance and HWND for them
|
||||
* so that our little dialog gets exclusive focus at all times. */
|
||||
if (messageboxdata->window) {
|
||||
ParentWindow = ((SDL_WindowData*)messageboxdata->window->driverdata)->hwnd;
|
||||
}
|
||||
|
||||
result = DialogBoxIndirectParam(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, (DLGPROC)MessageBoxDialogProc, (LPARAM)messageboxdata);
|
||||
if (result >= IDBUTTONINDEX0 && result - IDBUTTONINDEX0 < messageboxdata->numbuttons) {
|
||||
*buttonid = messageboxdata->buttons[result - IDBUTTONINDEX0].buttonid;
|
||||
retval = 0;
|
||||
} else if (result == IDCLOSED) {
|
||||
/* Dialog window closed by user or system. */
|
||||
/* This could use a special return code. */
|
||||
retval = 0;
|
||||
*buttonid = -1;
|
||||
} else {
|
||||
if (result == 0) {
|
||||
SDL_SetError("Invalid parent window handle");
|
||||
} else if (result == -1) {
|
||||
SDL_SetError("The message box encountered an error.");
|
||||
} else if (result == IDINVALPTRINIT || result == IDINVALPTRSETFOCUS || result == IDINVALPTRCOMMAND) {
|
||||
SDL_SetError("Invalid message box pointer in dialog procedure");
|
||||
} else if (result == IDINVALPTRDLGITEM) {
|
||||
SDL_SetError("Couldn't find dialog control of the default enter-key button");
|
||||
} else {
|
||||
SDL_SetError("An unknown error occured");
|
||||
}
|
||||
retval = -1;
|
||||
}
|
||||
|
||||
FreeDialogData(dialog);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* TaskDialogIndirect procedure
|
||||
* This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK.
|
||||
*/
|
||||
typedef HRESULT(FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
|
||||
|
||||
int
|
||||
WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
HWND ParentWindow = NULL;
|
||||
wchar_t *wmessage;
|
||||
wchar_t *wtitle;
|
||||
TASKDIALOGCONFIG TaskConfig;
|
||||
TASKDIALOG_BUTTON *pButtons;
|
||||
TASKDIALOG_BUTTON *pButton;
|
||||
HMODULE hComctl32;
|
||||
TASKDIALOGINDIRECTPROC pfnTaskDialogIndirect;
|
||||
HRESULT hr;
|
||||
char *ampescape = NULL;
|
||||
size_t ampescapesize = 0;
|
||||
int nButton;
|
||||
int nCancelButton;
|
||||
int i;
|
||||
|
||||
if (SIZE_MAX / sizeof(TASKDIALOG_BUTTON) < messageboxdata->numbuttons) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* If we cannot load comctl32.dll use the old messagebox! */
|
||||
hComctl32 = LoadLibrary(TEXT("Comctl32.dll"));
|
||||
if (hComctl32 == NULL) {
|
||||
return WIN_ShowOldMessageBox(messageboxdata, buttonid);
|
||||
}
|
||||
|
||||
/* If TaskDialogIndirect doesn't exist use the old messagebox!
|
||||
This will fail prior to Windows Vista.
|
||||
The manifest file in the application may require targeting version 6 of comctl32.dll, even
|
||||
when we use LoadLibrary here!
|
||||
If you don't want to bother with manifests, put this #pragma in your app's source code somewhere:
|
||||
pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
*/
|
||||
pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC) GetProcAddress(hComctl32, "TaskDialogIndirect");
|
||||
if (pfnTaskDialogIndirect == NULL) {
|
||||
FreeLibrary(hComctl32);
|
||||
return WIN_ShowOldMessageBox(messageboxdata, buttonid);
|
||||
}
|
||||
|
||||
/* If we have a parent window, get the Instance and HWND for them
|
||||
so that our little dialog gets exclusive focus at all times. */
|
||||
if (messageboxdata->window) {
|
||||
ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd;
|
||||
}
|
||||
|
||||
wmessage = WIN_UTF8ToString(messageboxdata->message);
|
||||
wtitle = WIN_UTF8ToString(messageboxdata->title);
|
||||
|
||||
SDL_zero(TaskConfig);
|
||||
TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG);
|
||||
TaskConfig.hwndParent = ParentWindow;
|
||||
TaskConfig.dwFlags = TDF_SIZE_TO_CONTENT;
|
||||
TaskConfig.pszWindowTitle = wtitle;
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
||||
TaskConfig.pszMainIcon = TD_ERROR_ICON;
|
||||
} else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
|
||||
TaskConfig.pszMainIcon = TD_WARNING_ICON;
|
||||
} else if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) {
|
||||
TaskConfig.pszMainIcon = TD_INFORMATION_ICON;
|
||||
} else {
|
||||
TaskConfig.pszMainIcon = NULL;
|
||||
}
|
||||
|
||||
TaskConfig.pszContent = wmessage;
|
||||
TaskConfig.cButtons = messageboxdata->numbuttons;
|
||||
pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
|
||||
TaskConfig.nDefaultButton = 0;
|
||||
nCancelButton = 0;
|
||||
for (i = 0; i < messageboxdata->numbuttons; i++)
|
||||
{
|
||||
const char *buttontext;
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT) {
|
||||
pButton = &pButtons[i];
|
||||
} else {
|
||||
pButton = &pButtons[messageboxdata->numbuttons - 1 - i];
|
||||
}
|
||||
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
||||
nCancelButton = messageboxdata->buttons[i].buttonid;
|
||||
pButton->nButtonID = IDCANCEL;
|
||||
} else {
|
||||
pButton->nButtonID = IDBUTTONINDEX0 + i;
|
||||
}
|
||||
buttontext = EscapeAmpersands(&escape, &escapesize, messageboxdata->buttons[i].text);
|
||||
if (buttontext == NULL) {
|
||||
int j;
|
||||
FreeLibrary(hComctl32);
|
||||
SDL_free(ampescape);
|
||||
SDL_free(wmessage);
|
||||
SDL_free(wtitle);
|
||||
for (j = 0; j < i; j++) {
|
||||
SDL_free((wchar_t *) pButtons[j].pszButtonText);
|
||||
}
|
||||
SDL_free(pButtons);
|
||||
return -1;
|
||||
}
|
||||
pButton->pszButtonText = WIN_UTF8ToString(buttontext);
|
||||
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||
TaskConfig.nDefaultButton = pButton->nButtonID;
|
||||
}
|
||||
}
|
||||
TaskConfig.pButtons = pButtons;
|
||||
|
||||
/* Show the Task Dialog */
|
||||
hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL);
|
||||
|
||||
/* Free everything */
|
||||
FreeLibrary(hComctl32);
|
||||
SDL_free(ampescape);
|
||||
SDL_free(wmessage);
|
||||
SDL_free(wtitle);
|
||||
for (i = 0; i < messageboxdata->numbuttons; i++) {
|
||||
SDL_free((wchar_t *) pButtons[i].pszButtonText);
|
||||
}
|
||||
SDL_free(pButtons);
|
||||
|
||||
/* Check the Task Dialog was successful and give the result */
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (nButton == IDCANCEL) {
|
||||
*buttonid = nCancelButton;
|
||||
} else if (nButton >= IDBUTTONINDEX0 && nButton < IDBUTTONINDEX0 + messageboxdata->numbuttons) {
|
||||
*buttonid = messageboxdata->buttons[nButton - IDBUTTONINDEX0].buttonid;
|
||||
} else {
|
||||
*buttonid = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We failed showing the Task Dialog, use the old message box! */
|
||||
return WIN_ShowOldMessageBox(messageboxdata, buttonid);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
29
externals/SDL/src/video/windows/SDL_windowsmessagebox.h
vendored
Executable file
29
externals/SDL/src/video/windows/SDL_windowsmessagebox.h
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
extern int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
407
externals/SDL/src/video/windows/SDL_windowsmodes.c
vendored
Executable file
407
externals/SDL/src/video/windows/SDL_windowsmodes.c
vendored
Executable file
@@ -0,0 +1,407 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "../../../include/SDL_assert.h"
|
||||
#include "../../../include/SDL_log.h"
|
||||
|
||||
/* Windows CE compatibility */
|
||||
#ifndef CDS_FULLSCREEN
|
||||
#define CDS_FULLSCREEN 0
|
||||
#endif
|
||||
|
||||
/* #define DEBUG_MODES */
|
||||
|
||||
static void
|
||||
WIN_UpdateDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
||||
{
|
||||
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
||||
HDC hdc;
|
||||
|
||||
data->DeviceMode.dmFields =
|
||||
(DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
|
||||
DM_DISPLAYFLAGS);
|
||||
|
||||
if (index == ENUM_CURRENT_SETTINGS
|
||||
&& (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) {
|
||||
char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
|
||||
LPBITMAPINFO bmi;
|
||||
HBITMAP hbm;
|
||||
int logical_width = GetDeviceCaps( hdc, HORZRES );
|
||||
int logical_height = GetDeviceCaps( hdc, VERTRES );
|
||||
|
||||
mode->w = logical_width;
|
||||
mode->h = logical_height;
|
||||
|
||||
SDL_zeroa(bmi_data);
|
||||
bmi = (LPBITMAPINFO) bmi_data;
|
||||
bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
|
||||
hbm = CreateCompatibleBitmap(hdc, 1, 1);
|
||||
GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
|
||||
GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS);
|
||||
DeleteObject(hbm);
|
||||
DeleteDC(hdc);
|
||||
if (bmi->bmiHeader.biCompression == BI_BITFIELDS) {
|
||||
switch (*(Uint32 *) bmi->bmiColors) {
|
||||
case 0x00FF0000:
|
||||
mode->format = SDL_PIXELFORMAT_RGB888;
|
||||
break;
|
||||
case 0x000000FF:
|
||||
mode->format = SDL_PIXELFORMAT_BGR888;
|
||||
break;
|
||||
case 0xF800:
|
||||
mode->format = SDL_PIXELFORMAT_RGB565;
|
||||
break;
|
||||
case 0x7C00:
|
||||
mode->format = SDL_PIXELFORMAT_RGB555;
|
||||
break;
|
||||
}
|
||||
} else if (bmi->bmiHeader.biBitCount == 8) {
|
||||
mode->format = SDL_PIXELFORMAT_INDEX8;
|
||||
} else if (bmi->bmiHeader.biBitCount == 4) {
|
||||
mode->format = SDL_PIXELFORMAT_INDEX4LSB;
|
||||
}
|
||||
} else if (mode->format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
/* FIXME: Can we tell what this will be? */
|
||||
if ((data->DeviceMode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
|
||||
switch (data->DeviceMode.dmBitsPerPel) {
|
||||
case 32:
|
||||
mode->format = SDL_PIXELFORMAT_RGB888;
|
||||
break;
|
||||
case 24:
|
||||
mode->format = SDL_PIXELFORMAT_RGB24;
|
||||
break;
|
||||
case 16:
|
||||
mode->format = SDL_PIXELFORMAT_RGB565;
|
||||
break;
|
||||
case 15:
|
||||
mode->format = SDL_PIXELFORMAT_RGB555;
|
||||
break;
|
||||
case 8:
|
||||
mode->format = SDL_PIXELFORMAT_INDEX8;
|
||||
break;
|
||||
case 4:
|
||||
mode->format = SDL_PIXELFORMAT_INDEX4LSB;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
|
||||
{
|
||||
SDL_DisplayModeData *data;
|
||||
DEVMODE devmode;
|
||||
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
devmode.dmDriverExtra = 0;
|
||||
if (!EnumDisplaySettings(deviceName, index, &devmode)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
|
||||
if (!data) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
mode->driverdata = data;
|
||||
data->DeviceMode = devmode;
|
||||
|
||||
mode->format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
mode->w = data->DeviceMode.dmPelsWidth;
|
||||
mode->h = data->DeviceMode.dmPelsHeight;
|
||||
mode->refresh_rate = data->DeviceMode.dmDisplayFrequency;
|
||||
|
||||
/* Fill in the mode information */
|
||||
WIN_UpdateDisplayMode(_this, deviceName, index, mode);
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEX *info)
|
||||
{
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayData *displaydata;
|
||||
SDL_DisplayMode mode;
|
||||
DISPLAY_DEVICE device;
|
||||
|
||||
#ifdef DEBUG_MODES
|
||||
SDL_Log("Display: %s\n", WIN_StringToUTF8(info->szDevice));
|
||||
#endif
|
||||
|
||||
if (!WIN_GetDisplayMode(_this, info->szDevice, ENUM_CURRENT_SETTINGS, &mode)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
|
||||
if (!displaydata) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
SDL_memcpy(displaydata->DeviceName, info->szDevice,
|
||||
sizeof(displaydata->DeviceName));
|
||||
displaydata->MonitorHandle = hMonitor;
|
||||
|
||||
SDL_zero(display);
|
||||
device.cb = sizeof(device);
|
||||
if (EnumDisplayDevices(info->szDevice, 0, &device, 0)) {
|
||||
display.name = WIN_StringToUTF8(device.DeviceString);
|
||||
}
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = displaydata;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
SDL_free(display.name);
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
typedef struct _WIN_AddDisplaysData {
|
||||
SDL_VideoDevice *video_device;
|
||||
SDL_bool want_primary;
|
||||
} WIN_AddDisplaysData;
|
||||
|
||||
static BOOL CALLBACK
|
||||
WIN_AddDisplaysCallback(HMONITOR hMonitor,
|
||||
HDC hdcMonitor,
|
||||
LPRECT lprcMonitor,
|
||||
LPARAM dwData)
|
||||
{
|
||||
WIN_AddDisplaysData *data = (WIN_AddDisplaysData*)dwData;
|
||||
MONITORINFOEX info;
|
||||
|
||||
SDL_zero(info);
|
||||
info.cbSize = sizeof(info);
|
||||
|
||||
if (GetMonitorInfo(hMonitor, (LPMONITORINFO)&info) != 0) {
|
||||
const SDL_bool is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY);
|
||||
|
||||
if (is_primary == data->want_primary) {
|
||||
WIN_AddDisplay(data->video_device, hMonitor, &info);
|
||||
}
|
||||
}
|
||||
|
||||
// continue enumeration
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_AddDisplays(_THIS)
|
||||
{
|
||||
WIN_AddDisplaysData callback_data;
|
||||
callback_data.video_device = _this;
|
||||
|
||||
callback_data.want_primary = SDL_TRUE;
|
||||
EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data);
|
||||
|
||||
callback_data.want_primary = SDL_FALSE;
|
||||
EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data);
|
||||
}
|
||||
|
||||
int
|
||||
WIN_InitModes(_THIS)
|
||||
{
|
||||
WIN_AddDisplays(_this);
|
||||
|
||||
if (_this->num_displays == 0) {
|
||||
return SDL_SetError("No displays available");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
{
|
||||
const SDL_DisplayData *data = (const SDL_DisplayData *)display->driverdata;
|
||||
MONITORINFO minfo;
|
||||
BOOL rc;
|
||||
|
||||
SDL_zero(minfo);
|
||||
minfo.cbSize = sizeof(MONITORINFO);
|
||||
rc = GetMonitorInfo(data->MonitorHandle, &minfo);
|
||||
|
||||
if (!rc) {
|
||||
return SDL_SetError("Couldn't find monitor data");
|
||||
}
|
||||
|
||||
rect->x = minfo.rcMonitor.left;
|
||||
rect->y = minfo.rcMonitor.top;
|
||||
rect->w = minfo.rcMonitor.right - minfo.rcMonitor.left;
|
||||
rect->h = minfo.rcMonitor.bottom - minfo.rcMonitor.top;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, float * hdpi_out, float * vdpi_out)
|
||||
{
|
||||
const SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||
const SDL_VideoData *videodata = (SDL_VideoData *)display->device->driverdata;
|
||||
float hdpi = 0, vdpi = 0, ddpi = 0;
|
||||
|
||||
if (videodata->GetDpiForMonitor) {
|
||||
UINT hdpi_uint, vdpi_uint;
|
||||
// Windows 8.1+ codepath
|
||||
if (videodata->GetDpiForMonitor(displaydata->MonitorHandle, MDT_EFFECTIVE_DPI, &hdpi_uint, &vdpi_uint) == S_OK) {
|
||||
// GetDpiForMonitor docs promise to return the same hdpi/vdpi
|
||||
hdpi = (float)hdpi_uint;
|
||||
vdpi = (float)hdpi_uint;
|
||||
ddpi = (float)hdpi_uint;
|
||||
} else {
|
||||
return SDL_SetError("GetDpiForMonitor failed");
|
||||
}
|
||||
} else {
|
||||
// Window 8.0 and below: same DPI for all monitors.
|
||||
HDC hdc;
|
||||
int hdpi_int, vdpi_int, hpoints, vpoints, hpix, vpix;
|
||||
float hinches, vinches;
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
if (hdc == NULL) {
|
||||
return SDL_SetError("GetDC failed");
|
||||
}
|
||||
hdpi_int = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
vdpi_int = GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
hpoints = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
vpoints = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
|
||||
hpix = MulDiv(hpoints, hdpi_int, 96);
|
||||
vpix = MulDiv(vpoints, vdpi_int, 96);
|
||||
|
||||
hinches = (float)hpoints / 96.0f;
|
||||
vinches = (float)vpoints / 96.0f;
|
||||
|
||||
hdpi = (float)hdpi_int;
|
||||
vdpi = (float)vdpi_int;
|
||||
ddpi = SDL_ComputeDiagonalDPI(hpix, vpix, hinches, vinches);
|
||||
}
|
||||
|
||||
if (ddpi_out) {
|
||||
*ddpi_out = ddpi;
|
||||
}
|
||||
if (hdpi_out) {
|
||||
*hdpi_out = hdpi;
|
||||
}
|
||||
if (vdpi_out) {
|
||||
*vdpi_out = vdpi;
|
||||
}
|
||||
|
||||
return ddpi != 0.0f ? 0 : SDL_SetError("Couldn't get DPI");
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
{
|
||||
const SDL_DisplayData *data = (const SDL_DisplayData *)display->driverdata;
|
||||
MONITORINFO minfo;
|
||||
BOOL rc;
|
||||
|
||||
SDL_zero(minfo);
|
||||
minfo.cbSize = sizeof(MONITORINFO);
|
||||
rc = GetMonitorInfo(data->MonitorHandle, &minfo);
|
||||
|
||||
if (!rc) {
|
||||
return SDL_SetError("Couldn't find monitor data");
|
||||
}
|
||||
|
||||
rect->x = minfo.rcWork.left;
|
||||
rect->y = minfo.rcWork.top;
|
||||
rect->w = minfo.rcWork.right - minfo.rcWork.left;
|
||||
rect->h = minfo.rcWork.bottom - minfo.rcWork.top;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
{
|
||||
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
|
||||
DWORD i;
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
for (i = 0;; ++i) {
|
||||
if (!WIN_GetDisplayMode(_this, data->DeviceName, i, &mode)) {
|
||||
break;
|
||||
}
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) {
|
||||
/* We don't support palettized modes now */
|
||||
SDL_free(mode.driverdata);
|
||||
continue;
|
||||
}
|
||||
if (mode.format != SDL_PIXELFORMAT_UNKNOWN) {
|
||||
if (!SDL_AddDisplayMode(display, &mode)) {
|
||||
SDL_free(mode.driverdata);
|
||||
}
|
||||
} else {
|
||||
SDL_free(mode.driverdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
{
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
||||
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
|
||||
LONG status;
|
||||
|
||||
if (mode->driverdata == display->desktop_mode.driverdata) {
|
||||
status = ChangeDisplaySettingsEx(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL);
|
||||
} else {
|
||||
status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL);
|
||||
}
|
||||
if (status != DISP_CHANGE_SUCCESSFUL) {
|
||||
const char *reason = "Unknown reason";
|
||||
switch (status) {
|
||||
case DISP_CHANGE_BADFLAGS:
|
||||
reason = "DISP_CHANGE_BADFLAGS";
|
||||
break;
|
||||
case DISP_CHANGE_BADMODE:
|
||||
reason = "DISP_CHANGE_BADMODE";
|
||||
break;
|
||||
case DISP_CHANGE_BADPARAM:
|
||||
reason = "DISP_CHANGE_BADPARAM";
|
||||
break;
|
||||
case DISP_CHANGE_FAILED:
|
||||
reason = "DISP_CHANGE_FAILED";
|
||||
break;
|
||||
}
|
||||
return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason);
|
||||
}
|
||||
EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
|
||||
WIN_UpdateDisplayMode(_this, displaydata->DeviceName, ENUM_CURRENT_SETTINGS, mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_QuitModes(_THIS)
|
||||
{
|
||||
/* All fullscreen windows should have restored modes by now */
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
47
externals/SDL/src/video/windows/SDL_windowsmodes.h
vendored
Executable file
47
externals/SDL/src/video/windows/SDL_windowsmodes.h
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsmodes_h_
|
||||
#define SDL_windowsmodes_h_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TCHAR DeviceName[32];
|
||||
HMONITOR MonitorHandle;
|
||||
} SDL_DisplayData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DEVMODE DeviceMode;
|
||||
} SDL_DisplayModeData;
|
||||
|
||||
extern int WIN_InitModes(_THIS);
|
||||
extern int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
extern int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
extern int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
|
||||
extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
extern void WIN_QuitModes(_THIS);
|
||||
|
||||
#endif /* SDL_windowsmodes_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
321
externals/SDL/src/video/windows/SDL_windowsmouse.c
vendored
Executable file
321
externals/SDL/src/video/windows/SDL_windowsmouse.c
vendored
Executable file
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
|
||||
HCURSOR SDL_cursor = NULL;
|
||||
|
||||
static int rawInputEnableCount = 0;
|
||||
|
||||
static int
|
||||
ToggleRawInput(SDL_bool enabled)
|
||||
{
|
||||
RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */
|
||||
|
||||
if (enabled) {
|
||||
rawInputEnableCount++;
|
||||
if (rawInputEnableCount > 1) {
|
||||
return 0; /* already done. */
|
||||
}
|
||||
} else {
|
||||
if (rawInputEnableCount == 0) {
|
||||
return 0; /* already done. */
|
||||
}
|
||||
rawInputEnableCount--;
|
||||
if (rawInputEnableCount > 0) {
|
||||
return 0; /* not time to disable yet */
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
rawMouse.dwFlags |= RIDEV_REMOVE;
|
||||
}
|
||||
|
||||
/* (Un)register raw input for mice */
|
||||
if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) {
|
||||
|
||||
/* Only return an error when registering. If we unregister and fail,
|
||||
then it's probably that we unregistered twice. That's OK. */
|
||||
if (enabled) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static SDL_Cursor *
|
||||
WIN_CreateDefaultCursor()
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = LoadCursor(NULL, IDC_ARROW);
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
{
|
||||
/* msdn says cursor mask has to be padded out to word alignment. Not sure
|
||||
if that means machine word or WORD, but this handles either case. */
|
||||
const size_t pad = (sizeof (size_t) * 8); /* 32 or 64, or whatever. */
|
||||
SDL_Cursor *cursor;
|
||||
HICON hicon;
|
||||
HDC hdc;
|
||||
BITMAPV4HEADER bmh;
|
||||
LPVOID pixels;
|
||||
LPVOID maskbits;
|
||||
size_t maskbitslen;
|
||||
SDL_bool isstack;
|
||||
ICONINFO ii;
|
||||
|
||||
SDL_zero(bmh);
|
||||
bmh.bV4Size = sizeof(bmh);
|
||||
bmh.bV4Width = surface->w;
|
||||
bmh.bV4Height = -surface->h; /* Invert the image */
|
||||
bmh.bV4Planes = 1;
|
||||
bmh.bV4BitCount = 32;
|
||||
bmh.bV4V4Compression = BI_BITFIELDS;
|
||||
bmh.bV4AlphaMask = 0xFF000000;
|
||||
bmh.bV4RedMask = 0x00FF0000;
|
||||
bmh.bV4GreenMask = 0x0000FF00;
|
||||
bmh.bV4BlueMask = 0x000000FF;
|
||||
|
||||
maskbitslen = ((surface->w + (pad - (surface->w % pad))) / 8) * surface->h;
|
||||
maskbits = SDL_small_alloc(Uint8, maskbitslen, &isstack);
|
||||
if (maskbits == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* AND the cursor against full bits: no change. We already have alpha. */
|
||||
SDL_memset(maskbits, 0xFF, maskbitslen);
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
SDL_zero(ii);
|
||||
ii.fIcon = FALSE;
|
||||
ii.xHotspot = (DWORD)hot_x;
|
||||
ii.yHotspot = (DWORD)hot_y;
|
||||
ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0);
|
||||
ii.hbmMask = CreateBitmap(surface->w, surface->h, 1, 1, maskbits);
|
||||
ReleaseDC(NULL, hdc);
|
||||
SDL_small_free(maskbits, isstack);
|
||||
|
||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->pitch == surface->w * 4);
|
||||
SDL_memcpy(pixels, surface->pixels, surface->h * surface->pitch);
|
||||
|
||||
hicon = CreateIconIndirect(&ii);
|
||||
|
||||
DeleteObject(ii.hbmColor);
|
||||
DeleteObject(ii.hbmMask);
|
||||
|
||||
if (!hicon) {
|
||||
WIN_SetError("CreateIconIndirect()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = hicon;
|
||||
} else {
|
||||
DestroyIcon(hicon);
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
WIN_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
LPCTSTR name;
|
||||
|
||||
switch(id)
|
||||
{
|
||||
default:
|
||||
SDL_assert(0);
|
||||
return NULL;
|
||||
case SDL_SYSTEM_CURSOR_ARROW: name = IDC_ARROW; break;
|
||||
case SDL_SYSTEM_CURSOR_IBEAM: name = IDC_IBEAM; break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT: name = IDC_WAIT; break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR: name = IDC_CROSS; break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW: name = IDC_WAIT; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE: name = IDC_SIZENWSE; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW: name = IDC_SIZENESW; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE: name = IDC_SIZEWE; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS: name = IDC_SIZENS; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL: name = IDC_SIZEALL; break;
|
||||
case SDL_SYSTEM_CURSOR_NO: name = IDC_NO; break;
|
||||
case SDL_SYSTEM_CURSOR_HAND: name = IDC_HAND; break;
|
||||
}
|
||||
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
HICON hicon;
|
||||
|
||||
hicon = LoadCursor(NULL, name);
|
||||
|
||||
cursor->driverdata = hicon;
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
HICON hicon = (HICON)cursor->driverdata;
|
||||
|
||||
DestroyIcon(hicon);
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
||||
static int
|
||||
WIN_ShowCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
if (cursor) {
|
||||
SDL_cursor = (HCURSOR)cursor->driverdata;
|
||||
} else {
|
||||
SDL_cursor = NULL;
|
||||
}
|
||||
if (SDL_GetMouseFocus() != NULL) {
|
||||
SetCursor(SDL_cursor);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_WarpMouse(SDL_Window * window, int x, int y)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
HWND hwnd = data->hwnd;
|
||||
POINT pt;
|
||||
|
||||
/* Don't warp the mouse while we're doing a modal interaction */
|
||||
if (data->in_title_click || data->focus_click_pending) {
|
||||
return;
|
||||
}
|
||||
|
||||
pt.x = x;
|
||||
pt.y = y;
|
||||
ClientToScreen(hwnd, &pt);
|
||||
SetCursorPos(pt.x, pt.y);
|
||||
}
|
||||
|
||||
static int
|
||||
WIN_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
POINT pt;
|
||||
|
||||
pt.x = x;
|
||||
pt.y = y;
|
||||
SetCursorPos(pt.x, pt.y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
WIN_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
return ToggleRawInput(enabled);
|
||||
}
|
||||
|
||||
static int
|
||||
WIN_CaptureMouse(SDL_Window *window)
|
||||
{
|
||||
if (!window) {
|
||||
SDL_Window *focusWin = SDL_GetKeyboardFocus();
|
||||
if (focusWin) {
|
||||
WIN_OnWindowEnter(SDL_GetVideoDevice(), focusWin); /* make sure WM_MOUSELEAVE messages are (re)enabled. */
|
||||
}
|
||||
}
|
||||
|
||||
/* While we were thinking of SetCapture() when designing this API in SDL,
|
||||
we didn't count on the fact that SetCapture() only tracks while the
|
||||
left mouse button is held down! Instead, we listen for raw mouse input
|
||||
and manually query the mouse when it leaves the window. :/ */
|
||||
return ToggleRawInput(window != NULL);
|
||||
}
|
||||
|
||||
static Uint32
|
||||
WIN_GetGlobalMouseState(int *x, int *y)
|
||||
{
|
||||
Uint32 retval = 0;
|
||||
POINT pt = { 0, 0 };
|
||||
GetCursorPos(&pt);
|
||||
*x = (int) pt.x;
|
||||
*y = (int) pt.y;
|
||||
|
||||
retval |= GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_BUTTON_LMASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_BUTTON_RMASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_BUTTON_MMASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_BUTTON_X1MASK : 0;
|
||||
retval |= GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_BUTTON_X2MASK : 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_InitMouse(_THIS)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
mouse->CreateCursor = WIN_CreateCursor;
|
||||
mouse->CreateSystemCursor = WIN_CreateSystemCursor;
|
||||
mouse->ShowCursor = WIN_ShowCursor;
|
||||
mouse->FreeCursor = WIN_FreeCursor;
|
||||
mouse->WarpMouse = WIN_WarpMouse;
|
||||
mouse->WarpMouseGlobal = WIN_WarpMouseGlobal;
|
||||
mouse->SetRelativeMouseMode = WIN_SetRelativeMouseMode;
|
||||
mouse->CaptureMouse = WIN_CaptureMouse;
|
||||
mouse->GetGlobalMouseState = WIN_GetGlobalMouseState;
|
||||
|
||||
SDL_SetDefaultCursor(WIN_CreateDefaultCursor());
|
||||
}
|
||||
|
||||
void
|
||||
WIN_QuitMouse(_THIS)
|
||||
{
|
||||
if (rawInputEnableCount) { /* force RAWINPUT off here. */
|
||||
rawInputEnableCount = 1;
|
||||
ToggleRawInput(SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
33
externals/SDL/src/video/windows/SDL_windowsmouse.h
vendored
Executable file
33
externals/SDL/src/video/windows/SDL_windowsmouse.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsmouse_h_
|
||||
#define SDL_windowsmouse_h_
|
||||
|
||||
extern HCURSOR SDL_cursor;
|
||||
|
||||
extern void WIN_InitMouse(_THIS);
|
||||
extern void WIN_QuitMouse(_THIS);
|
||||
|
||||
#endif /* SDL_windowsmouse_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
895
externals/SDL/src/video/windows/SDL_windowsopengl.c
vendored
Executable file
895
externals/SDL/src/video/windows/SDL_windowsopengl.c
vendored
Executable file
@@ -0,0 +1,895 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowsopengles.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
/* WGL implementation of SDL OpenGL support */
|
||||
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
#include "SDL_opengl.h"
|
||||
|
||||
#define DEFAULT_OPENGL "OPENGL32.DLL"
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_ARB_create_context
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_ARB_create_context_profile
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_robustness
|
||||
#define WGL_ARB_create_context_robustness
|
||||
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_create_context_es2_profile
|
||||
#define WGL_EXT_create_context_es2_profile
|
||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_create_context_es_profile
|
||||
#define WGL_EXT_create_context_es_profile
|
||||
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_framebuffer_sRGB
|
||||
#define WGL_ARB_framebuffer_sRGB
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_context_flush_control
|
||||
#define WGL_ARB_context_flush_control
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_no_error
|
||||
#define WGL_ARB_create_context_no_error
|
||||
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
|
||||
#endif
|
||||
|
||||
typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC,
|
||||
HGLRC
|
||||
hShareContext,
|
||||
const int
|
||||
*attribList);
|
||||
|
||||
int
|
||||
WIN_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
void *handle;
|
||||
|
||||
if (path == NULL) {
|
||||
path = SDL_getenv("SDL_OPENGL_LIBRARY");
|
||||
}
|
||||
if (path == NULL) {
|
||||
path = DEFAULT_OPENGL;
|
||||
}
|
||||
_this->gl_config.dll_handle = SDL_LoadObject(path);
|
||||
if (!_this->gl_config.dll_handle) {
|
||||
return -1;
|
||||
}
|
||||
SDL_strlcpy(_this->gl_config.driver_path, path,
|
||||
SDL_arraysize(_this->gl_config.driver_path));
|
||||
|
||||
/* Allocate OpenGL memory */
|
||||
_this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData));
|
||||
if (!_this->gl_data) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
/* Load function pointers */
|
||||
handle = _this->gl_config.dll_handle;
|
||||
_this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
|
||||
SDL_LoadFunction(handle, "wglGetProcAddress");
|
||||
_this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
|
||||
SDL_LoadFunction(handle, "wglCreateContext");
|
||||
_this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
|
||||
SDL_LoadFunction(handle, "wglDeleteContext");
|
||||
_this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
|
||||
SDL_LoadFunction(handle, "wglMakeCurrent");
|
||||
_this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
|
||||
SDL_LoadFunction(handle, "wglShareLists");
|
||||
|
||||
if (!_this->gl_data->wglGetProcAddress ||
|
||||
!_this->gl_data->wglCreateContext ||
|
||||
!_this->gl_data->wglDeleteContext ||
|
||||
!_this->gl_data->wglMakeCurrent) {
|
||||
return SDL_SetError("Could not retrieve OpenGL functions");
|
||||
}
|
||||
|
||||
/* XXX Too sleazy? WIN_GL_InitExtensions looks for certain OpenGL
|
||||
extensions via SDL_GL_DeduceMaxSupportedESProfile. This uses
|
||||
SDL_GL_ExtensionSupported which in turn calls SDL_GL_GetProcAddress.
|
||||
However SDL_GL_GetProcAddress will fail if the library is not
|
||||
loaded; it checks for gl_config.driver_loaded > 0. To avoid this
|
||||
test failing, increment driver_loaded around the call to
|
||||
WIN_GLInitExtensions.
|
||||
|
||||
Successful loading of the library is normally indicated by
|
||||
SDL_GL_LoadLibrary incrementing driver_loaded immediately after
|
||||
this function returns 0 to it.
|
||||
|
||||
Alternatives to this are:
|
||||
- moving SDL_GL_DeduceMaxSupportedESProfile to both the WIN and
|
||||
X11 platforms while adding a function equivalent to
|
||||
SDL_GL_ExtensionSupported but which directly calls
|
||||
glGetProcAddress(). Having 3 copies of the
|
||||
SDL_GL_ExtensionSupported makes this alternative unattractive.
|
||||
- moving SDL_GL_DeduceMaxSupportedESProfile to a new file shared
|
||||
by the WIN and X11 platforms while adding a function equivalent
|
||||
to SDL_GL_ExtensionSupported. This is unattractive due to the
|
||||
number of project files that will need updating, plus there
|
||||
will be 2 copies of the SDL_GL_ExtensionSupported code.
|
||||
- Add a private equivalent of SDL_GL_ExtensionSupported to
|
||||
SDL_video.c.
|
||||
- Move the call to WIN_GL_InitExtensions back to WIN_CreateWindow
|
||||
and add a flag to gl_data to avoid multiple calls to this
|
||||
expensive function. This is probably the least objectionable
|
||||
alternative if this increment/decrement trick is unacceptable.
|
||||
|
||||
Note that the driver_loaded > 0 check needs to remain in
|
||||
SDL_GL_ExtensionSupported and SDL_GL_GetProcAddress as they are
|
||||
public API functions.
|
||||
*/
|
||||
++_this->gl_config.driver_loaded;
|
||||
WIN_GL_InitExtensions(_this);
|
||||
--_this->gl_config.driver_loaded;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
WIN_GL_GetProcAddress(_THIS, const char *proc)
|
||||
{
|
||||
void *func;
|
||||
|
||||
/* This is to pick up extensions */
|
||||
func = _this->gl_data->wglGetProcAddress(proc);
|
||||
if (!func) {
|
||||
/* This is probably a normal GL function */
|
||||
func = GetProcAddress(_this->gl_config.dll_handle, proc);
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_GL_UnloadLibrary(_THIS)
|
||||
{
|
||||
SDL_UnloadObject(_this->gl_config.dll_handle);
|
||||
_this->gl_config.dll_handle = NULL;
|
||||
|
||||
/* Free OpenGL memory */
|
||||
SDL_free(_this->gl_data);
|
||||
_this->gl_data = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR * pfd)
|
||||
{
|
||||
SDL_zerop(pfd);
|
||||
pfd->nSize = sizeof(*pfd);
|
||||
pfd->nVersion = 1;
|
||||
pfd->dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL);
|
||||
if (_this->gl_config.double_buffer) {
|
||||
pfd->dwFlags |= PFD_DOUBLEBUFFER;
|
||||
}
|
||||
if (_this->gl_config.stereo) {
|
||||
pfd->dwFlags |= PFD_STEREO;
|
||||
}
|
||||
pfd->iLayerType = PFD_MAIN_PLANE;
|
||||
pfd->iPixelType = PFD_TYPE_RGBA;
|
||||
pfd->cRedBits = _this->gl_config.red_size;
|
||||
pfd->cGreenBits = _this->gl_config.green_size;
|
||||
pfd->cBlueBits = _this->gl_config.blue_size;
|
||||
pfd->cAlphaBits = _this->gl_config.alpha_size;
|
||||
if (_this->gl_config.buffer_size) {
|
||||
pfd->cColorBits =
|
||||
_this->gl_config.buffer_size - _this->gl_config.alpha_size;
|
||||
} else {
|
||||
pfd->cColorBits = (pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits);
|
||||
}
|
||||
pfd->cAccumRedBits = _this->gl_config.accum_red_size;
|
||||
pfd->cAccumGreenBits = _this->gl_config.accum_green_size;
|
||||
pfd->cAccumBlueBits = _this->gl_config.accum_blue_size;
|
||||
pfd->cAccumAlphaBits = _this->gl_config.accum_alpha_size;
|
||||
pfd->cAccumBits =
|
||||
(pfd->cAccumRedBits + pfd->cAccumGreenBits + pfd->cAccumBlueBits +
|
||||
pfd->cAccumAlphaBits);
|
||||
pfd->cDepthBits = _this->gl_config.depth_size;
|
||||
pfd->cStencilBits = _this->gl_config.stencil_size;
|
||||
}
|
||||
|
||||
/* Choose the closest pixel format that meets or exceeds the target.
|
||||
FIXME: Should we weight any particular attribute over any other?
|
||||
*/
|
||||
static int
|
||||
WIN_GL_ChoosePixelFormat(HDC hdc, PIXELFORMATDESCRIPTOR * target)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int count, index, best = 0;
|
||||
unsigned int dist, best_dist = ~0U;
|
||||
|
||||
count = DescribePixelFormat(hdc, 1, sizeof(pfd), NULL);
|
||||
|
||||
for (index = 1; index <= count; index++) {
|
||||
|
||||
if (!DescribePixelFormat(hdc, index, sizeof(pfd), &pfd)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((pfd.dwFlags & target->dwFlags) != target->dwFlags) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pfd.iLayerType != target->iLayerType) {
|
||||
continue;
|
||||
}
|
||||
if (pfd.iPixelType != target->iPixelType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dist = 0;
|
||||
|
||||
if (pfd.cColorBits < target->cColorBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cColorBits - target->cColorBits);
|
||||
}
|
||||
if (pfd.cRedBits < target->cRedBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cRedBits - target->cRedBits);
|
||||
}
|
||||
if (pfd.cGreenBits < target->cGreenBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cGreenBits - target->cGreenBits);
|
||||
}
|
||||
if (pfd.cBlueBits < target->cBlueBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cBlueBits - target->cBlueBits);
|
||||
}
|
||||
if (pfd.cAlphaBits < target->cAlphaBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cAlphaBits - target->cAlphaBits);
|
||||
}
|
||||
if (pfd.cAccumBits < target->cAccumBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cAccumBits - target->cAccumBits);
|
||||
}
|
||||
if (pfd.cAccumRedBits < target->cAccumRedBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cAccumRedBits - target->cAccumRedBits);
|
||||
}
|
||||
if (pfd.cAccumGreenBits < target->cAccumGreenBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cAccumGreenBits - target->cAccumGreenBits);
|
||||
}
|
||||
if (pfd.cAccumBlueBits < target->cAccumBlueBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cAccumBlueBits - target->cAccumBlueBits);
|
||||
}
|
||||
if (pfd.cAccumAlphaBits < target->cAccumAlphaBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cAccumAlphaBits - target->cAccumAlphaBits);
|
||||
}
|
||||
if (pfd.cDepthBits < target->cDepthBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cDepthBits - target->cDepthBits);
|
||||
}
|
||||
if (pfd.cStencilBits < target->cStencilBits) {
|
||||
continue;
|
||||
} else {
|
||||
dist += (pfd.cStencilBits - target->cStencilBits);
|
||||
}
|
||||
|
||||
if (dist < best_dist) {
|
||||
best = index;
|
||||
best_dist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
HasExtension(const char *extension, const char *extensions)
|
||||
{
|
||||
const char *start;
|
||||
const char *where, *terminator;
|
||||
|
||||
/* Extension names should not have spaces. */
|
||||
where = SDL_strchr(extension, ' ');
|
||||
if (where || *extension == '\0')
|
||||
return SDL_FALSE;
|
||||
|
||||
if (!extensions)
|
||||
return SDL_FALSE;
|
||||
|
||||
/* It takes a bit of care to be fool-proof about parsing the
|
||||
* OpenGL extensions string. Don't be fooled by sub-strings,
|
||||
* etc. */
|
||||
|
||||
start = extensions;
|
||||
|
||||
for (;;) {
|
||||
where = SDL_strstr(start, extension);
|
||||
if (!where)
|
||||
break;
|
||||
|
||||
terminator = where + SDL_strlen(extension);
|
||||
if (where == start || *(where - 1) == ' ')
|
||||
if (*terminator == ' ' || *terminator == '\0')
|
||||
return SDL_TRUE;
|
||||
|
||||
start = terminator;
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_GL_InitExtensions(_THIS)
|
||||
{
|
||||
const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0;
|
||||
const char *extensions;
|
||||
HWND hwnd;
|
||||
HDC hdc;
|
||||
HGLRC hglrc;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
if (!_this->gl_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
hwnd =
|
||||
CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0,
|
||||
10, 10, NULL, NULL, SDL_Instance, NULL);
|
||||
if (!hwnd) {
|
||||
return;
|
||||
}
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
hdc = GetDC(hwnd);
|
||||
|
||||
WIN_GL_SetupPixelFormat(_this, &pfd);
|
||||
|
||||
SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);
|
||||
|
||||
hglrc = _this->gl_data->wglCreateContext(hdc);
|
||||
if (!hglrc) {
|
||||
return;
|
||||
}
|
||||
_this->gl_data->wglMakeCurrent(hdc, hglrc);
|
||||
|
||||
wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
|
||||
_this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
|
||||
if (wglGetExtensionsStringARB) {
|
||||
extensions = wglGetExtensionsStringARB(hdc);
|
||||
} else {
|
||||
extensions = NULL;
|
||||
}
|
||||
|
||||
/* Check for WGL_ARB_pixel_format */
|
||||
_this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE;
|
||||
if (HasExtension("WGL_ARB_pixel_format", extensions)) {
|
||||
_this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
|
||||
(HDC, const int *,
|
||||
const FLOAT *, UINT,
|
||||
int *, UINT *))
|
||||
WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
|
||||
_this->gl_data->wglGetPixelFormatAttribivARB =
|
||||
(BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
|
||||
WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
|
||||
|
||||
if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
|
||||
(_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
|
||||
_this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for WGL_EXT_swap_control */
|
||||
_this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
|
||||
if (HasExtension("WGL_EXT_swap_control", extensions)) {
|
||||
_this->gl_data->wglSwapIntervalEXT =
|
||||
WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
|
||||
_this->gl_data->wglGetSwapIntervalEXT =
|
||||
WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
|
||||
if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
|
||||
_this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
|
||||
}
|
||||
} else {
|
||||
_this->gl_data->wglSwapIntervalEXT = NULL;
|
||||
_this->gl_data->wglGetSwapIntervalEXT = NULL;
|
||||
}
|
||||
|
||||
/* Check for WGL_EXT_create_context_es2_profile */
|
||||
if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) {
|
||||
SDL_GL_DeduceMaxSupportedESProfile(
|
||||
&_this->gl_data->es_profile_max_supported_version.major,
|
||||
&_this->gl_data->es_profile_max_supported_version.minor
|
||||
);
|
||||
}
|
||||
|
||||
/* Check for WGL_ARB_context_flush_control */
|
||||
if (HasExtension("WGL_ARB_context_flush_control", extensions)) {
|
||||
_this->gl_data->HAS_WGL_ARB_context_flush_control = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check for WGL_ARB_create_context_robustness */
|
||||
if (HasExtension("WGL_ARB_create_context_robustness", extensions)) {
|
||||
_this->gl_data->HAS_WGL_ARB_create_context_robustness = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check for WGL_ARB_create_context_no_error */
|
||||
if (HasExtension("WGL_ARB_create_context_no_error", extensions)) {
|
||||
_this->gl_data->HAS_WGL_ARB_create_context_no_error = SDL_TRUE;
|
||||
}
|
||||
|
||||
_this->gl_data->wglMakeCurrent(hdc, NULL);
|
||||
_this->gl_data->wglDeleteContext(hglrc);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
DestroyWindow(hwnd);
|
||||
WIN_PumpEvents(_this);
|
||||
}
|
||||
|
||||
static int
|
||||
WIN_GL_ChoosePixelFormatARB(_THIS, int *iAttribs, float *fAttribs)
|
||||
{
|
||||
HWND hwnd;
|
||||
HDC hdc;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
HGLRC hglrc;
|
||||
int pixel_format = 0;
|
||||
unsigned int matching;
|
||||
|
||||
hwnd =
|
||||
CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0,
|
||||
10, 10, NULL, NULL, SDL_Instance, NULL);
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
hdc = GetDC(hwnd);
|
||||
|
||||
WIN_GL_SetupPixelFormat(_this, &pfd);
|
||||
|
||||
SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);
|
||||
|
||||
hglrc = _this->gl_data->wglCreateContext(hdc);
|
||||
if (hglrc) {
|
||||
_this->gl_data->wglMakeCurrent(hdc, hglrc);
|
||||
|
||||
if (_this->gl_data->HAS_WGL_ARB_pixel_format) {
|
||||
_this->gl_data->wglChoosePixelFormatARB(hdc, iAttribs, fAttribs,
|
||||
1, &pixel_format,
|
||||
&matching);
|
||||
}
|
||||
|
||||
_this->gl_data->wglMakeCurrent(hdc, NULL);
|
||||
_this->gl_data->wglDeleteContext(hglrc);
|
||||
}
|
||||
ReleaseDC(hwnd, hdc);
|
||||
DestroyWindow(hwnd);
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
return pixel_format;
|
||||
}
|
||||
|
||||
/* actual work of WIN_GL_SetupWindow() happens here. */
|
||||
static int
|
||||
WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window)
|
||||
{
|
||||
HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
int pixel_format = 0;
|
||||
int iAttribs[64];
|
||||
int *iAttr;
|
||||
int *iAccelAttr;
|
||||
float fAttribs[1] = { 0 };
|
||||
|
||||
WIN_GL_SetupPixelFormat(_this, &pfd);
|
||||
|
||||
/* setup WGL_ARB_pixel_format attribs */
|
||||
iAttr = &iAttribs[0];
|
||||
|
||||
*iAttr++ = WGL_DRAW_TO_WINDOW_ARB;
|
||||
*iAttr++ = GL_TRUE;
|
||||
*iAttr++ = WGL_RED_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.red_size;
|
||||
*iAttr++ = WGL_GREEN_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.green_size;
|
||||
*iAttr++ = WGL_BLUE_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.blue_size;
|
||||
|
||||
if (_this->gl_config.alpha_size) {
|
||||
*iAttr++ = WGL_ALPHA_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.alpha_size;
|
||||
}
|
||||
|
||||
*iAttr++ = WGL_DOUBLE_BUFFER_ARB;
|
||||
*iAttr++ = _this->gl_config.double_buffer;
|
||||
|
||||
*iAttr++ = WGL_DEPTH_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.depth_size;
|
||||
|
||||
if (_this->gl_config.stencil_size) {
|
||||
*iAttr++ = WGL_STENCIL_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.stencil_size;
|
||||
}
|
||||
|
||||
if (_this->gl_config.accum_red_size) {
|
||||
*iAttr++ = WGL_ACCUM_RED_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.accum_red_size;
|
||||
}
|
||||
|
||||
if (_this->gl_config.accum_green_size) {
|
||||
*iAttr++ = WGL_ACCUM_GREEN_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.accum_green_size;
|
||||
}
|
||||
|
||||
if (_this->gl_config.accum_blue_size) {
|
||||
*iAttr++ = WGL_ACCUM_BLUE_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.accum_blue_size;
|
||||
}
|
||||
|
||||
if (_this->gl_config.accum_alpha_size) {
|
||||
*iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB;
|
||||
*iAttr++ = _this->gl_config.accum_alpha_size;
|
||||
}
|
||||
|
||||
if (_this->gl_config.stereo) {
|
||||
*iAttr++ = WGL_STEREO_ARB;
|
||||
*iAttr++ = GL_TRUE;
|
||||
}
|
||||
|
||||
if (_this->gl_config.multisamplebuffers) {
|
||||
*iAttr++ = WGL_SAMPLE_BUFFERS_ARB;
|
||||
*iAttr++ = _this->gl_config.multisamplebuffers;
|
||||
}
|
||||
|
||||
if (_this->gl_config.multisamplesamples) {
|
||||
*iAttr++ = WGL_SAMPLES_ARB;
|
||||
*iAttr++ = _this->gl_config.multisamplesamples;
|
||||
}
|
||||
|
||||
if (_this->gl_config.framebuffer_srgb_capable) {
|
||||
*iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB;
|
||||
*iAttr++ = _this->gl_config.framebuffer_srgb_capable;
|
||||
}
|
||||
|
||||
/* We always choose either FULL or NO accel on Windows, because of flaky
|
||||
drivers. If the app didn't specify, we use FULL, because that's
|
||||
probably what they wanted (and if you didn't care and got FULL, that's
|
||||
a perfectly valid result in any case). */
|
||||
*iAttr++ = WGL_ACCELERATION_ARB;
|
||||
iAccelAttr = iAttr;
|
||||
if (_this->gl_config.accelerated) {
|
||||
*iAttr++ = WGL_FULL_ACCELERATION_ARB;
|
||||
} else {
|
||||
*iAttr++ = WGL_NO_ACCELERATION_ARB;
|
||||
}
|
||||
|
||||
*iAttr = 0;
|
||||
|
||||
/* Choose and set the closest available pixel format */
|
||||
pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
|
||||
|
||||
/* App said "don't care about accel" and FULL accel failed. Try NO. */
|
||||
if ( ( !pixel_format ) && ( _this->gl_config.accelerated < 0 ) ) {
|
||||
*iAccelAttr = WGL_NO_ACCELERATION_ARB;
|
||||
pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs);
|
||||
*iAccelAttr = WGL_FULL_ACCELERATION_ARB; /* if we try again. */
|
||||
}
|
||||
if (!pixel_format) {
|
||||
pixel_format = WIN_GL_ChoosePixelFormat(hdc, &pfd);
|
||||
}
|
||||
if (!pixel_format) {
|
||||
return SDL_SetError("No matching GL pixel format available");
|
||||
}
|
||||
if (!SetPixelFormat(hdc, pixel_format, &pfd)) {
|
||||
return WIN_SetError("SetPixelFormat()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_SetupWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
/* The current context is lost in here; save it and reset it. */
|
||||
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
|
||||
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
|
||||
const int retval = WIN_GL_SetupWindowInternal(_this, window);
|
||||
WIN_GL_MakeCurrent(_this, current_win, current_ctx);
|
||||
return retval;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
WIN_GL_UseEGL(_THIS)
|
||||
{
|
||||
SDL_assert(_this->gl_data != NULL);
|
||||
SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
|
||||
|
||||
return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE)
|
||||
|| _this->gl_config.major_version == 1 /* No WGL extension for OpenGL ES 1.x profiles. */
|
||||
|| _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major
|
||||
|| (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major
|
||||
&& _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor));
|
||||
}
|
||||
|
||||
SDL_GLContext
|
||||
WIN_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
|
||||
HGLRC context, share_context;
|
||||
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && WIN_GL_UseEGL(_this)) {
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
/* Switch to EGL based functions */
|
||||
WIN_GL_UnloadLibrary(_this);
|
||||
_this->GL_LoadLibrary = WIN_GLES_LoadLibrary;
|
||||
_this->GL_GetProcAddress = WIN_GLES_GetProcAddress;
|
||||
_this->GL_UnloadLibrary = WIN_GLES_UnloadLibrary;
|
||||
_this->GL_CreateContext = WIN_GLES_CreateContext;
|
||||
_this->GL_MakeCurrent = WIN_GLES_MakeCurrent;
|
||||
_this->GL_SetSwapInterval = WIN_GLES_SetSwapInterval;
|
||||
_this->GL_GetSwapInterval = WIN_GLES_GetSwapInterval;
|
||||
_this->GL_SwapWindow = WIN_GLES_SwapWindow;
|
||||
_this->GL_DeleteContext = WIN_GLES_DeleteContext;
|
||||
|
||||
if (WIN_GLES_LoadLibrary(_this, NULL) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return WIN_GLES_CreateContext(_this, window);
|
||||
#else
|
||||
SDL_SetError("SDL not configured with EGL support");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_this->gl_config.share_with_current_context) {
|
||||
share_context = (HGLRC)SDL_GL_GetCurrentContext();
|
||||
} else {
|
||||
share_context = 0;
|
||||
}
|
||||
|
||||
if (_this->gl_config.major_version < 3 &&
|
||||
_this->gl_config.profile_mask == 0 &&
|
||||
_this->gl_config.flags == 0) {
|
||||
/* Create legacy context */
|
||||
context = _this->gl_data->wglCreateContext(hdc);
|
||||
if( share_context != 0 ) {
|
||||
_this->gl_data->wglShareLists(share_context, context);
|
||||
}
|
||||
} else {
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
|
||||
HGLRC temp_context = _this->gl_data->wglCreateContext(hdc);
|
||||
if (!temp_context) {
|
||||
SDL_SetError("Could not create GL context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Make the context current */
|
||||
if (WIN_GL_MakeCurrent(_this, window, temp_context) < 0) {
|
||||
WIN_GL_DeleteContext(_this, temp_context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wglCreateContextAttribsARB =
|
||||
(PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
|
||||
wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
if (!wglCreateContextAttribsARB) {
|
||||
SDL_SetError("GL 3.x is not supported");
|
||||
context = temp_context;
|
||||
} else {
|
||||
int attribs[15]; /* max 14 attributes plus terminator */
|
||||
int iattr = 0;
|
||||
|
||||
attribs[iattr++] = WGL_CONTEXT_MAJOR_VERSION_ARB;
|
||||
attribs[iattr++] = _this->gl_config.major_version;
|
||||
attribs[iattr++] = WGL_CONTEXT_MINOR_VERSION_ARB;
|
||||
attribs[iattr++] = _this->gl_config.minor_version;
|
||||
|
||||
/* SDL profile bits match WGL profile bits */
|
||||
if (_this->gl_config.profile_mask != 0) {
|
||||
attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||
attribs[iattr++] = _this->gl_config.profile_mask;
|
||||
}
|
||||
|
||||
/* SDL flags match WGL flags */
|
||||
if (_this->gl_config.flags != 0) {
|
||||
attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB;
|
||||
attribs[iattr++] = _this->gl_config.flags;
|
||||
}
|
||||
|
||||
/* only set if wgl extension is available */
|
||||
if (_this->gl_data->HAS_WGL_ARB_context_flush_control) {
|
||||
attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB;
|
||||
attribs[iattr++] = _this->gl_config.release_behavior ?
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB :
|
||||
WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB;
|
||||
}
|
||||
|
||||
/* only set if wgl extension is available */
|
||||
if (_this->gl_data->HAS_WGL_ARB_create_context_robustness) {
|
||||
attribs[iattr++] = WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB;
|
||||
attribs[iattr++] = _this->gl_config.reset_notification ?
|
||||
WGL_LOSE_CONTEXT_ON_RESET_ARB :
|
||||
WGL_NO_RESET_NOTIFICATION_ARB;
|
||||
}
|
||||
|
||||
/* only set if wgl extension is available */
|
||||
if (_this->gl_data->HAS_WGL_ARB_create_context_no_error) {
|
||||
attribs[iattr++] = WGL_CONTEXT_OPENGL_NO_ERROR_ARB;
|
||||
attribs[iattr++] = _this->gl_config.no_error;
|
||||
}
|
||||
|
||||
attribs[iattr++] = 0;
|
||||
|
||||
/* Create the GL 3.x context */
|
||||
context = wglCreateContextAttribsARB(hdc, share_context, attribs);
|
||||
/* Delete the GL 2.x context */
|
||||
_this->gl_data->wglDeleteContext(temp_context);
|
||||
}
|
||||
}
|
||||
|
||||
if (!context) {
|
||||
WIN_SetError("Could not create GL context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (WIN_GL_MakeCurrent(_this, window, context) < 0) {
|
||||
WIN_GL_DeleteContext(_this, context);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
HDC hdc;
|
||||
|
||||
if (!_this->gl_data) {
|
||||
return SDL_SetError("OpenGL not initialized");
|
||||
}
|
||||
|
||||
/* sanity check that higher level handled this. */
|
||||
SDL_assert(window || (!window && !context));
|
||||
|
||||
/* Some Windows drivers freak out if hdc is NULL, even when context is
|
||||
NULL, against spec. Since hdc is _supposed_ to be ignored if context
|
||||
is NULL, we either use the current GL window, or do nothing if we
|
||||
already have no current context. */
|
||||
if (!window) {
|
||||
window = SDL_GL_GetCurrentWindow();
|
||||
if (!window) {
|
||||
SDL_assert(SDL_GL_GetCurrentContext() == NULL);
|
||||
return 0; /* already done. */
|
||||
}
|
||||
}
|
||||
|
||||
hdc = ((SDL_WindowData *) window->driverdata)->hdc;
|
||||
if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC) context)) {
|
||||
return WIN_SetError("wglMakeCurrent()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_SetSwapInterval(_THIS, int interval)
|
||||
{
|
||||
if ((interval < 0) && (!_this->gl_data->HAS_WGL_EXT_swap_control_tear)) {
|
||||
return SDL_SetError("Negative swap interval unsupported in this GL");
|
||||
} else if (_this->gl_data->wglSwapIntervalEXT) {
|
||||
if (_this->gl_data->wglSwapIntervalEXT(interval) != TRUE) {
|
||||
return WIN_SetError("wglSwapIntervalEXT()");
|
||||
}
|
||||
} else {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_GetSwapInterval(_THIS)
|
||||
{
|
||||
int retval = 0;
|
||||
if (_this->gl_data->wglGetSwapIntervalEXT) {
|
||||
retval = _this->gl_data->wglGetSwapIntervalEXT();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
WIN_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
|
||||
|
||||
if (!SwapBuffers(hdc)) {
|
||||
return WIN_SetError("SwapBuffers()");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{
|
||||
if (!_this->gl_data) {
|
||||
return;
|
||||
}
|
||||
_this->gl_data->wglDeleteContext((HGLRC) context);
|
||||
}
|
||||
|
||||
|
||||
SDL_bool
|
||||
WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window * fromWindow, SDL_Window * toWindow)
|
||||
{
|
||||
HDC hfromdc = ((SDL_WindowData *) fromWindow->driverdata)->hdc;
|
||||
HDC htodc = ((SDL_WindowData *) toWindow->driverdata)->hdc;
|
||||
BOOL result;
|
||||
|
||||
/* get the pixel format of the fromWindow */
|
||||
int pixel_format = GetPixelFormat(hfromdc);
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
SDL_memset(&pfd, 0, sizeof(pfd));
|
||||
DescribePixelFormat(hfromdc, pixel_format, sizeof(pfd), &pfd);
|
||||
|
||||
/* set the pixel format of the toWindow */
|
||||
result = SetPixelFormat(htodc, pixel_format, &pfd);
|
||||
|
||||
return result ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_OPENGL_WGL */
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
142
externals/SDL/src/video/windows/SDL_windowsopengl.h
vendored
Executable file
142
externals/SDL/src/video/windows/SDL_windowsopengl.h
vendored
Executable file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsopengl_h_
|
||||
#define SDL_windowsopengl_h_
|
||||
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
|
||||
struct SDL_GLDriverData
|
||||
{
|
||||
SDL_bool HAS_WGL_ARB_pixel_format;
|
||||
SDL_bool HAS_WGL_EXT_swap_control_tear;
|
||||
SDL_bool HAS_WGL_ARB_context_flush_control;
|
||||
SDL_bool HAS_WGL_ARB_create_context_robustness;
|
||||
SDL_bool HAS_WGL_ARB_create_context_no_error;
|
||||
|
||||
/* Max version of OpenGL ES context that can be created if the
|
||||
implementation supports WGL_EXT_create_context_es2_profile.
|
||||
major = minor = 0 when unsupported.
|
||||
*/
|
||||
struct {
|
||||
int major;
|
||||
int minor;
|
||||
} es_profile_max_supported_version;
|
||||
|
||||
void *(WINAPI * wglGetProcAddress) (const char *proc);
|
||||
HGLRC(WINAPI * wglCreateContext) (HDC hdc);
|
||||
BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc);
|
||||
BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc);
|
||||
BOOL(WINAPI * wglShareLists) (HGLRC hglrc1, HGLRC hglrc2);
|
||||
BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc,
|
||||
const int *piAttribIList,
|
||||
const FLOAT * pfAttribFList,
|
||||
UINT nMaxFormats,
|
||||
int *piFormats,
|
||||
UINT * nNumFormats);
|
||||
BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
UINT nAttributes,
|
||||
const int *piAttributes,
|
||||
int *piValues);
|
||||
BOOL (WINAPI * wglSwapIntervalEXT) (int interval);
|
||||
int (WINAPI * wglGetSwapIntervalEXT) (void);
|
||||
};
|
||||
|
||||
/* OpenGL functions */
|
||||
extern int WIN_GL_LoadLibrary(_THIS, const char *path);
|
||||
extern void *WIN_GL_GetProcAddress(_THIS, const char *proc);
|
||||
extern void WIN_GL_UnloadLibrary(_THIS);
|
||||
extern SDL_bool WIN_GL_UseEGL(_THIS);
|
||||
extern int WIN_GL_SetupWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
extern int WIN_GL_MakeCurrent(_THIS, SDL_Window * window,
|
||||
SDL_GLContext context);
|
||||
extern int WIN_GL_SetSwapInterval(_THIS, int interval);
|
||||
extern int WIN_GL_GetSwapInterval(_THIS);
|
||||
extern int WIN_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
extern void WIN_GL_InitExtensions(_THIS);
|
||||
extern SDL_bool WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window * fromWindow, SDL_Window * toWindow);
|
||||
|
||||
#ifndef WGL_ARB_pixel_format
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||
#define WGL_TRANSPARENT_ARB 0x200A
|
||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_COLOR_BITS_ARB 0x2014
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||
#define WGL_SWAP_COPY_ARB 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_multisample
|
||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#endif
|
||||
|
||||
#endif /* SDL_VIDEO_OPENGL_WGL */
|
||||
|
||||
#endif /* SDL_windowsopengl_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
131
externals/SDL/src/video/windows/SDL_windowsopengles.c
vendored
Executable file
131
externals/SDL/src/video/windows/SDL_windowsopengles.c
vendored
Executable file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowsopengles.h"
|
||||
#include "SDL_windowsopengl.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
int
|
||||
WIN_GLES_LoadLibrary(_THIS, const char *path) {
|
||||
|
||||
/* If the profile requested is not GL ES, switch over to WIN_GL functions */
|
||||
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
WIN_GLES_UnloadLibrary(_this);
|
||||
_this->GL_LoadLibrary = WIN_GL_LoadLibrary;
|
||||
_this->GL_GetProcAddress = WIN_GL_GetProcAddress;
|
||||
_this->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
|
||||
_this->GL_CreateContext = WIN_GL_CreateContext;
|
||||
_this->GL_MakeCurrent = WIN_GL_MakeCurrent;
|
||||
_this->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
|
||||
_this->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
|
||||
_this->GL_SwapWindow = WIN_GL_SwapWindow;
|
||||
_this->GL_DeleteContext = WIN_GL_DeleteContext;
|
||||
return WIN_GL_LoadLibrary(_this, path);
|
||||
#else
|
||||
return SDL_SetError("SDL not configured with OpenGL/WGL support");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_this->egl_data == NULL) {
|
||||
return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_GLContext
|
||||
WIN_GLES_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_GLContext context;
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
/* Switch to WGL based functions */
|
||||
WIN_GLES_UnloadLibrary(_this);
|
||||
_this->GL_LoadLibrary = WIN_GL_LoadLibrary;
|
||||
_this->GL_GetProcAddress = WIN_GL_GetProcAddress;
|
||||
_this->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
|
||||
_this->GL_CreateContext = WIN_GL_CreateContext;
|
||||
_this->GL_MakeCurrent = WIN_GL_MakeCurrent;
|
||||
_this->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
|
||||
_this->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
|
||||
_this->GL_SwapWindow = WIN_GL_SwapWindow;
|
||||
_this->GL_DeleteContext = WIN_GL_DeleteContext;
|
||||
|
||||
if (WIN_GL_LoadLibrary(_this, NULL) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return WIN_GL_CreateContext(_this, window);
|
||||
}
|
||||
#endif
|
||||
|
||||
context = SDL_EGL_CreateContext(_this, data->egl_surface);
|
||||
return context;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_GLES_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{
|
||||
SDL_EGL_DeleteContext(_this, context);
|
||||
WIN_GLES_UnloadLibrary(_this);
|
||||
}
|
||||
|
||||
SDL_EGL_SwapWindow_impl(WIN)
|
||||
SDL_EGL_MakeCurrent_impl(WIN)
|
||||
|
||||
int
|
||||
WIN_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
/* The current context is lost in here; save it and reset it. */
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
||||
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
|
||||
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
|
||||
|
||||
|
||||
if (_this->egl_data == NULL) {
|
||||
if (SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0) < 0) {
|
||||
SDL_EGL_UnloadLibrary(_this);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the GLES window surface */
|
||||
windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)windowdata->hwnd);
|
||||
|
||||
if (windowdata->egl_surface == EGL_NO_SURFACE) {
|
||||
return SDL_SetError("Could not create GLES window surface");
|
||||
}
|
||||
|
||||
return WIN_GLES_MakeCurrent(_this, current_win, current_ctx);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
49
externals/SDL/src/video/windows/SDL_windowsopengles.h
vendored
Executable file
49
externals/SDL/src/video/windows/SDL_windowsopengles.h
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_winopengles_h_
|
||||
#define SDL_winopengles_h_
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
|
||||
/* OpenGLES functions */
|
||||
#define WIN_GLES_GetAttribute SDL_EGL_GetAttribute
|
||||
#define WIN_GLES_GetProcAddress SDL_EGL_GetProcAddress
|
||||
#define WIN_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define WIN_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
#define WIN_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
|
||||
|
||||
extern int WIN_GLES_LoadLibrary(_THIS, const char *path);
|
||||
extern SDL_GLContext WIN_GLES_CreateContext(_THIS, SDL_Window * window);
|
||||
extern int WIN_GLES_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern int WIN_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
extern void WIN_GLES_DeleteContext(_THIS, SDL_GLContext context);
|
||||
extern int WIN_GLES_SetupWindow(_THIS, SDL_Window * window);
|
||||
|
||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||
|
||||
#endif /* SDL_winopengles_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
111
externals/SDL/src/video/windows/SDL_windowsshape.c
vendored
Executable file
111
externals/SDL/src/video/windows/SDL_windowsshape.c
vendored
Executable file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_windowsshape.h"
|
||||
#include "SDL_windowsvideo.h"
|
||||
|
||||
SDL_WindowShaper*
|
||||
Win32_CreateShaper(SDL_Window * window) {
|
||||
int resized_properly;
|
||||
SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
result->mode.mode = ShapeModeDefault;
|
||||
result->mode.parameters.binarizationCutoff = 1;
|
||||
result->userx = result->usery = 0;
|
||||
result->hasshape = SDL_FALSE;
|
||||
result->driverdata = (SDL_ShapeData*)SDL_malloc(sizeof(SDL_ShapeData));
|
||||
((SDL_ShapeData*)result->driverdata)->mask_tree = NULL;
|
||||
/* Put some driver-data here. */
|
||||
window->shaper = result;
|
||||
resized_properly = Win32_ResizeWindowShape(window);
|
||||
if (resized_properly != 0)
|
||||
return NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
CombineRectRegions(SDL_ShapeTree* node,void* closure) {
|
||||
HRGN mask_region = *((HRGN*)closure),temp_region = NULL;
|
||||
if(node->kind == OpaqueShape) {
|
||||
/* Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline. */
|
||||
temp_region = CreateRectRgn(node->data.shape.x,node->data.shape.y,node->data.shape.x + node->data.shape.w + 1,node->data.shape.y + node->data.shape.h + 1);
|
||||
if(mask_region != NULL) {
|
||||
CombineRgn(mask_region,mask_region,temp_region,RGN_OR);
|
||||
DeleteObject(temp_region);
|
||||
}
|
||||
else
|
||||
*((HRGN*)closure) = temp_region;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) {
|
||||
SDL_ShapeData *data;
|
||||
HRGN mask_region = NULL;
|
||||
|
||||
if( (shaper == NULL) ||
|
||||
(shape == NULL) ||
|
||||
((shape->format->Amask == 0) && (shape_mode->mode != ShapeModeColorKey)) ||
|
||||
(shape->w != shaper->window->w) ||
|
||||
(shape->h != shaper->window->h) ) {
|
||||
return SDL_INVALID_SHAPE_ARGUMENT;
|
||||
}
|
||||
|
||||
data = (SDL_ShapeData*)shaper->driverdata;
|
||||
if(data->mask_tree != NULL)
|
||||
SDL_FreeShapeTree(&data->mask_tree);
|
||||
data->mask_tree = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
SDL_TraverseShapeTree(data->mask_tree,&CombineRectRegions,&mask_region);
|
||||
SDL_assert(mask_region != NULL);
|
||||
|
||||
SetWindowRgn(((SDL_WindowData *)(shaper->window->driverdata))->hwnd, mask_region, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
Win32_ResizeWindowShape(SDL_Window *window) {
|
||||
SDL_ShapeData* data;
|
||||
|
||||
if (window == NULL)
|
||||
return -1;
|
||||
data = (SDL_ShapeData *)window->shaper->driverdata;
|
||||
if (data == NULL)
|
||||
return -1;
|
||||
|
||||
if(data->mask_tree != NULL)
|
||||
SDL_FreeShapeTree(&data->mask_tree);
|
||||
if(window->shaper->hasshape == SDL_TRUE) {
|
||||
window->shaper->userx = window->x;
|
||||
window->shaper->usery = window->y;
|
||||
SDL_SetWindowPosition(window,-1000,-1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
40
externals/SDL/src/video/windows/SDL_windowsshape.h
vendored
Executable file
40
externals/SDL/src/video/windows/SDL_windowsshape.h
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsshape_h_
|
||||
#define SDL_windowsshape_h_
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_shape_internals.h"
|
||||
|
||||
typedef struct {
|
||||
SDL_ShapeTree *mask_tree;
|
||||
} SDL_ShapeData;
|
||||
|
||||
extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window);
|
||||
extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode);
|
||||
extern int Win32_ResizeWindowShape(SDL_Window *window);
|
||||
|
||||
#endif /* SDL_windowsshape_h_ */
|
156
externals/SDL/src/video/windows/SDL_windowstaskdialog.h
vendored
Executable file
156
externals/SDL/src/video/windows/SDL_windowstaskdialog.h
vendored
Executable file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include <pshpack1.h>
|
||||
|
||||
typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData);
|
||||
|
||||
enum _TASKDIALOG_FLAGS
|
||||
{
|
||||
TDF_ENABLE_HYPERLINKS = 0x0001,
|
||||
TDF_USE_HICON_MAIN = 0x0002,
|
||||
TDF_USE_HICON_FOOTER = 0x0004,
|
||||
TDF_ALLOW_DIALOG_CANCELLATION = 0x0008,
|
||||
TDF_USE_COMMAND_LINKS = 0x0010,
|
||||
TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020,
|
||||
TDF_EXPAND_FOOTER_AREA = 0x0040,
|
||||
TDF_EXPANDED_BY_DEFAULT = 0x0080,
|
||||
TDF_VERIFICATION_FLAG_CHECKED = 0x0100,
|
||||
TDF_SHOW_PROGRESS_BAR = 0x0200,
|
||||
TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400,
|
||||
TDF_CALLBACK_TIMER = 0x0800,
|
||||
TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000,
|
||||
TDF_RTL_LAYOUT = 0x2000,
|
||||
TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000,
|
||||
TDF_CAN_BE_MINIMIZED = 0x8000,
|
||||
//#if (NTDDI_VERSION >= NTDDI_WIN8)
|
||||
TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog
|
||||
//#endif // (NTDDI_VERSION >= NTDDI_WIN8)
|
||||
TDF_SIZE_TO_CONTENT = 0x01000000 // used by ShellMessageBox to emulate MessageBox sizing behavior
|
||||
};
|
||||
typedef int TASKDIALOG_FLAGS; // Note: _TASKDIALOG_FLAGS is an int
|
||||
|
||||
typedef enum _TASKDIALOG_MESSAGES
|
||||
{
|
||||
TDM_NAVIGATE_PAGE = WM_USER + 101,
|
||||
TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID
|
||||
TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
|
||||
TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state
|
||||
TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
|
||||
TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position
|
||||
TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
|
||||
TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
|
||||
TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID
|
||||
TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
|
||||
TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
|
||||
TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
|
||||
TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
|
||||
TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
|
||||
TDM_UPDATE_ICON = WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
|
||||
} TASKDIALOG_MESSAGES;
|
||||
|
||||
typedef enum _TASKDIALOG_NOTIFICATIONS
|
||||
{
|
||||
TDN_CREATED = 0,
|
||||
TDN_NAVIGATED = 1,
|
||||
TDN_BUTTON_CLICKED = 2, // wParam = Button ID
|
||||
TDN_HYPERLINK_CLICKED = 3, // lParam = (LPCWSTR)pszHREF
|
||||
TDN_TIMER = 4, // wParam = Milliseconds since dialog created or timer reset
|
||||
TDN_DESTROYED = 5,
|
||||
TDN_RADIO_BUTTON_CLICKED = 6, // wParam = Radio Button ID
|
||||
TDN_DIALOG_CONSTRUCTED = 7,
|
||||
TDN_VERIFICATION_CLICKED = 8, // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
|
||||
TDN_HELP = 9,
|
||||
TDN_EXPANDO_BUTTON_CLICKED = 10 // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
|
||||
} TASKDIALOG_NOTIFICATIONS;
|
||||
|
||||
typedef struct _TASKDIALOG_BUTTON
|
||||
{
|
||||
int nButtonID;
|
||||
PCWSTR pszButtonText;
|
||||
} TASKDIALOG_BUTTON;
|
||||
|
||||
typedef enum _TASKDIALOG_ELEMENTS
|
||||
{
|
||||
TDE_CONTENT,
|
||||
TDE_EXPANDED_INFORMATION,
|
||||
TDE_FOOTER,
|
||||
TDE_MAIN_INSTRUCTION
|
||||
} TASKDIALOG_ELEMENTS;
|
||||
|
||||
typedef enum _TASKDIALOG_ICON_ELEMENTS
|
||||
{
|
||||
TDIE_ICON_MAIN,
|
||||
TDIE_ICON_FOOTER
|
||||
} TASKDIALOG_ICON_ELEMENTS;
|
||||
|
||||
#define TD_WARNING_ICON MAKEINTRESOURCEW(-1)
|
||||
#define TD_ERROR_ICON MAKEINTRESOURCEW(-2)
|
||||
#define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3)
|
||||
#define TD_SHIELD_ICON MAKEINTRESOURCEW(-4)
|
||||
|
||||
enum _TASKDIALOG_COMMON_BUTTON_FLAGS
|
||||
{
|
||||
TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK
|
||||
TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES
|
||||
TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO
|
||||
TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL
|
||||
TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY
|
||||
TDCBF_CLOSE_BUTTON = 0x0020 // selected control return value IDCLOSE
|
||||
};
|
||||
typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
|
||||
|
||||
typedef struct _TASKDIALOGCONFIG
|
||||
{
|
||||
UINT cbSize;
|
||||
HWND hwndParent; // incorrectly named, this is the owner window, not a parent.
|
||||
HINSTANCE hInstance; // used for MAKEINTRESOURCE() strings
|
||||
TASKDIALOG_FLAGS dwFlags; // TASKDIALOG_FLAGS (TDF_XXX) flags
|
||||
TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
|
||||
PCWSTR pszWindowTitle; // string or MAKEINTRESOURCE()
|
||||
union
|
||||
{
|
||||
HICON hMainIcon;
|
||||
PCWSTR pszMainIcon;
|
||||
} /*DUMMYUNIONNAME*/;
|
||||
PCWSTR pszMainInstruction;
|
||||
PCWSTR pszContent;
|
||||
UINT cButtons;
|
||||
const TASKDIALOG_BUTTON *pButtons;
|
||||
int nDefaultButton;
|
||||
UINT cRadioButtons;
|
||||
const TASKDIALOG_BUTTON *pRadioButtons;
|
||||
int nDefaultRadioButton;
|
||||
PCWSTR pszVerificationText;
|
||||
PCWSTR pszExpandedInformation;
|
||||
PCWSTR pszExpandedControlText;
|
||||
PCWSTR pszCollapsedControlText;
|
||||
union
|
||||
{
|
||||
HICON hFooterIcon;
|
||||
PCWSTR pszFooterIcon;
|
||||
} /*DUMMYUNIONNAME2*/;
|
||||
PCWSTR pszFooter;
|
||||
PFTASKDIALOGCALLBACK pfCallback;
|
||||
LONG_PTR lpCallbackData;
|
||||
UINT cxWidth; // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
|
||||
} TASKDIALOGCONFIG;
|
||||
|
||||
#include <poppack.h>
|
452
externals/SDL/src/video/windows/SDL_windowsvideo.c
vendored
Executable file
452
externals/SDL/src/video/windows/SDL_windowsvideo.c
vendored
Executable file
@@ -0,0 +1,452 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_main.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_system.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowsframebuffer.h"
|
||||
#include "SDL_windowsshape.h"
|
||||
#include "SDL_windowsvulkan.h"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int WIN_VideoInit(_THIS);
|
||||
static void WIN_VideoQuit(_THIS);
|
||||
|
||||
/* Hints */
|
||||
SDL_bool g_WindowsEnableMessageLoop = SDL_TRUE;
|
||||
SDL_bool g_WindowFrameUsableWhileCursorHidden = SDL_TRUE;
|
||||
|
||||
static void SDLCALL
|
||||
UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue)
|
||||
{
|
||||
if (newValue && *newValue == '0') {
|
||||
g_WindowsEnableMessageLoop = SDL_FALSE;
|
||||
} else {
|
||||
g_WindowsEnableMessageLoop = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void SDLCALL
|
||||
UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const char *oldValue, const char *newValue)
|
||||
{
|
||||
if (newValue && *newValue == '0') {
|
||||
g_WindowFrameUsableWhileCursorHidden = SDL_FALSE;
|
||||
} else {
|
||||
g_WindowFrameUsableWhileCursorHidden = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void WIN_SuspendScreenSaver(_THIS)
|
||||
{
|
||||
if (_this->suspend_screensaver) {
|
||||
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
||||
} else {
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Windows driver bootstrap functions */
|
||||
|
||||
static int
|
||||
WIN_Available(void)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_DeleteDevice(SDL_VideoDevice * device)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
|
||||
|
||||
SDL_UnregisterApp();
|
||||
if (data->userDLL) {
|
||||
SDL_UnloadObject(data->userDLL);
|
||||
}
|
||||
if (data->shcoreDLL) {
|
||||
SDL_UnloadObject(data->shcoreDLL);
|
||||
}
|
||||
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
WIN_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *data;
|
||||
|
||||
SDL_RegisterApp(NULL, 0, NULL);
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device) {
|
||||
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
} else {
|
||||
data = NULL;
|
||||
}
|
||||
if (!data) {
|
||||
SDL_free(device);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = data;
|
||||
|
||||
data->userDLL = SDL_LoadObject("USER32.DLL");
|
||||
if (data->userDLL) {
|
||||
data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT)) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
|
||||
data->GetTouchInputInfo = (BOOL (WINAPI *)(HTOUCHINPUT, UINT, PTOUCHINPUT, int)) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
|
||||
data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG)) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
|
||||
} else {
|
||||
SDL_ClearError();
|
||||
}
|
||||
|
||||
data->shcoreDLL = SDL_LoadObject("SHCORE.DLL");
|
||||
if (data->shcoreDLL) {
|
||||
data->GetDpiForMonitor = (HRESULT (WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *)) SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor");
|
||||
} else {
|
||||
SDL_ClearError();
|
||||
}
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = WIN_VideoInit;
|
||||
device->VideoQuit = WIN_VideoQuit;
|
||||
device->GetDisplayBounds = WIN_GetDisplayBounds;
|
||||
device->GetDisplayUsableBounds = WIN_GetDisplayUsableBounds;
|
||||
device->GetDisplayDPI = WIN_GetDisplayDPI;
|
||||
device->GetDisplayModes = WIN_GetDisplayModes;
|
||||
device->SetDisplayMode = WIN_SetDisplayMode;
|
||||
device->PumpEvents = WIN_PumpEvents;
|
||||
device->SuspendScreenSaver = WIN_SuspendScreenSaver;
|
||||
|
||||
device->CreateSDLWindow = WIN_CreateWindow;
|
||||
device->CreateSDLWindowFrom = WIN_CreateWindowFrom;
|
||||
device->SetWindowTitle = WIN_SetWindowTitle;
|
||||
device->SetWindowIcon = WIN_SetWindowIcon;
|
||||
device->SetWindowPosition = WIN_SetWindowPosition;
|
||||
device->SetWindowSize = WIN_SetWindowSize;
|
||||
device->GetWindowBordersSize = WIN_GetWindowBordersSize;
|
||||
device->SetWindowOpacity = WIN_SetWindowOpacity;
|
||||
device->ShowWindow = WIN_ShowWindow;
|
||||
device->HideWindow = WIN_HideWindow;
|
||||
device->RaiseWindow = WIN_RaiseWindow;
|
||||
device->MaximizeWindow = WIN_MaximizeWindow;
|
||||
device->MinimizeWindow = WIN_MinimizeWindow;
|
||||
device->RestoreWindow = WIN_RestoreWindow;
|
||||
device->SetWindowBordered = WIN_SetWindowBordered;
|
||||
device->SetWindowResizable = WIN_SetWindowResizable;
|
||||
device->SetWindowFullscreen = WIN_SetWindowFullscreen;
|
||||
device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
|
||||
device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
|
||||
device->SetWindowGrab = WIN_SetWindowGrab;
|
||||
device->DestroyWindow = WIN_DestroyWindow;
|
||||
device->GetWindowWMInfo = WIN_GetWindowWMInfo;
|
||||
device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer;
|
||||
device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer;
|
||||
device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
|
||||
device->OnWindowEnter = WIN_OnWindowEnter;
|
||||
device->SetWindowHitTest = WIN_SetWindowHitTest;
|
||||
device->AcceptDragAndDrop = WIN_AcceptDragAndDrop;
|
||||
|
||||
device->shape_driver.CreateShaper = Win32_CreateShaper;
|
||||
device->shape_driver.SetWindowShape = Win32_SetWindowShape;
|
||||
device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_WGL
|
||||
device->GL_LoadLibrary = WIN_GL_LoadLibrary;
|
||||
device->GL_GetProcAddress = WIN_GL_GetProcAddress;
|
||||
device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
|
||||
device->GL_CreateContext = WIN_GL_CreateContext;
|
||||
device->GL_MakeCurrent = WIN_GL_MakeCurrent;
|
||||
device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
|
||||
device->GL_SwapWindow = WIN_GL_SwapWindow;
|
||||
device->GL_DeleteContext = WIN_GL_DeleteContext;
|
||||
#elif SDL_VIDEO_OPENGL_EGL
|
||||
/* Use EGL based functions */
|
||||
device->GL_LoadLibrary = WIN_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = WIN_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary;
|
||||
device->GL_CreateContext = WIN_GLES_CreateContext;
|
||||
device->GL_MakeCurrent = WIN_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = WIN_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = WIN_GLES_DeleteContext;
|
||||
#endif
|
||||
#if SDL_VIDEO_VULKAN
|
||||
device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary;
|
||||
device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary;
|
||||
device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions;
|
||||
device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface;
|
||||
#endif
|
||||
|
||||
device->StartTextInput = WIN_StartTextInput;
|
||||
device->StopTextInput = WIN_StopTextInput;
|
||||
device->SetTextInputRect = WIN_SetTextInputRect;
|
||||
|
||||
device->SetClipboardText = WIN_SetClipboardText;
|
||||
device->GetClipboardText = WIN_GetClipboardText;
|
||||
device->HasClipboardText = WIN_HasClipboardText;
|
||||
|
||||
device->free = WIN_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
VideoBootStrap WINDOWS_bootstrap = {
|
||||
"windows", "SDL Windows video driver", WIN_Available, WIN_CreateDevice
|
||||
};
|
||||
|
||||
int
|
||||
WIN_VideoInit(_THIS)
|
||||
{
|
||||
if (WIN_InitModes(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WIN_InitKeyboard(_this);
|
||||
WIN_InitMouse(_this);
|
||||
|
||||
SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, UpdateWindowsEnableMessageLoop, NULL);
|
||||
SDL_AddHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WIN_VideoQuit(_THIS)
|
||||
{
|
||||
WIN_QuitModes(_this);
|
||||
WIN_QuitKeyboard(_this);
|
||||
WIN_QuitMouse(_this);
|
||||
}
|
||||
|
||||
|
||||
#define D3D_DEBUG_INFO
|
||||
#include <d3d9.h>
|
||||
|
||||
SDL_bool
|
||||
D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
|
||||
{
|
||||
*pD3DDLL = SDL_LoadObject("D3D9.DLL");
|
||||
if (*pD3DDLL) {
|
||||
typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (UINT SDKVersion);
|
||||
Direct3DCreate9_t Direct3DCreate9Func;
|
||||
|
||||
#ifdef USE_D3D9EX
|
||||
typedef HRESULT (WINAPI *Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
Direct3DCreate9Ex_t Direct3DCreate9ExFunc;
|
||||
|
||||
Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex");
|
||||
if (Direct3DCreate9ExFunc) {
|
||||
IDirect3D9Ex *pDirect3D9ExInterface;
|
||||
HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface);
|
||||
if (SUCCEEDED(hr)) {
|
||||
const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } };
|
||||
hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void**)pDirect3D9Interface);
|
||||
IDirect3D9Ex_Release(pDirect3D9ExInterface);
|
||||
if (SUCCEEDED(hr)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* USE_D3D9EX */
|
||||
|
||||
Direct3DCreate9Func = (Direct3DCreate9_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9");
|
||||
if (Direct3DCreate9Func) {
|
||||
*pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION);
|
||||
if (*pDirect3D9Interface) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnloadObject(*pD3DDLL);
|
||||
*pD3DDLL = NULL;
|
||||
}
|
||||
*pDirect3D9Interface = NULL;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_Direct3D9GetAdapterIndex(int displayIndex)
|
||||
{
|
||||
void *pD3DDLL;
|
||||
IDirect3D9 *pD3D;
|
||||
if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) {
|
||||
SDL_SetError("Unable to create Direct3D interface");
|
||||
return D3DADAPTER_DEFAULT;
|
||||
} else {
|
||||
SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);
|
||||
int adapterIndex = D3DADAPTER_DEFAULT;
|
||||
|
||||
if (!pData) {
|
||||
SDL_SetError("Invalid display index");
|
||||
adapterIndex = -1; /* make sure we return something invalid */
|
||||
} else {
|
||||
char *displayName = WIN_StringToUTF8(pData->DeviceName);
|
||||
unsigned int count = IDirect3D9_GetAdapterCount(pD3D);
|
||||
unsigned int i;
|
||||
for (i=0; i<count; i++) {
|
||||
D3DADAPTER_IDENTIFIER9 id;
|
||||
IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &id);
|
||||
|
||||
if (SDL_strcmp(id.DeviceName, displayName) == 0) {
|
||||
adapterIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_free(displayName);
|
||||
}
|
||||
|
||||
/* free up the D3D stuff we inited */
|
||||
IDirect3D9_Release(pD3D);
|
||||
SDL_UnloadObject(pD3DDLL);
|
||||
|
||||
return adapterIndex;
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_DXGI_H
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
#include <dxgi.h>
|
||||
|
||||
static SDL_bool
|
||||
DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory)
|
||||
{
|
||||
*pDXGIDLL = SDL_LoadObject("DXGI.DLL");
|
||||
if (*pDXGIDLL) {
|
||||
HRESULT (WINAPI *CreateDXGI)(REFIID riid, void **ppFactory);
|
||||
|
||||
CreateDXGI =
|
||||
(HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL,
|
||||
"CreateDXGIFactory");
|
||||
if (CreateDXGI) {
|
||||
GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}};
|
||||
if (!SUCCEEDED(CreateDXGI(&dxgiGUID, (void**)pDXGIFactory))) {
|
||||
*pDXGIFactory = NULL;
|
||||
}
|
||||
}
|
||||
if (!*pDXGIFactory) {
|
||||
SDL_UnloadObject(*pDXGIDLL);
|
||||
*pDXGIDLL = NULL;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
*pDXGIFactory = NULL;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
SDL_bool
|
||||
SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
|
||||
{
|
||||
#if !HAVE_DXGI_H
|
||||
if (adapterIndex) *adapterIndex = -1;
|
||||
if (outputIndex) *outputIndex = -1;
|
||||
SDL_SetError("SDL was compiled without DXGI support due to missing dxgi.h header");
|
||||
return SDL_FALSE;
|
||||
#else
|
||||
SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex);
|
||||
void *pDXGIDLL;
|
||||
char *displayName;
|
||||
int nAdapter, nOutput;
|
||||
IDXGIFactory *pDXGIFactory = NULL;
|
||||
IDXGIAdapter *pDXGIAdapter;
|
||||
IDXGIOutput* pDXGIOutput;
|
||||
|
||||
if (!adapterIndex) {
|
||||
SDL_InvalidParamError("adapterIndex");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!outputIndex) {
|
||||
SDL_InvalidParamError("outputIndex");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
*adapterIndex = -1;
|
||||
*outputIndex = -1;
|
||||
|
||||
if (!pData) {
|
||||
SDL_SetError("Invalid display index");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) {
|
||||
SDL_SetError("Unable to create DXGI interface");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
displayName = WIN_StringToUTF8(pData->DeviceName);
|
||||
nAdapter = 0;
|
||||
while (*adapterIndex == -1 && SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) {
|
||||
nOutput = 0;
|
||||
while (*adapterIndex == -1 && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) {
|
||||
DXGI_OUTPUT_DESC outputDesc;
|
||||
if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
|
||||
char *outputName = WIN_StringToUTF8(outputDesc.DeviceName);
|
||||
if (SDL_strcmp(outputName, displayName) == 0) {
|
||||
*adapterIndex = nAdapter;
|
||||
*outputIndex = nOutput;
|
||||
}
|
||||
SDL_free(outputName);
|
||||
}
|
||||
IDXGIOutput_Release(pDXGIOutput);
|
||||
nOutput++;
|
||||
}
|
||||
IDXGIAdapter_Release(pDXGIAdapter);
|
||||
nAdapter++;
|
||||
}
|
||||
SDL_free(displayName);
|
||||
|
||||
/* free up the DXGI factory */
|
||||
IDXGIFactory_Release(pDXGIFactory);
|
||||
SDL_UnloadObject(pDXGIDLL);
|
||||
|
||||
if (*adapterIndex == -1) {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
/* vim: set ts=4 sw=4 expandtab: */
|
199
externals/SDL/src/video/windows/SDL_windowsvideo.h
vendored
Executable file
199
externals/SDL/src/video/windows/SDL_windowsvideo.h
vendored
Executable file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsvideo_h_
|
||||
#define SDL_windowsvideo_h_
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
|
||||
#include <msctf.h>
|
||||
#else
|
||||
#include "SDL_msctf.h"
|
||||
#endif
|
||||
|
||||
#include <imm.h>
|
||||
|
||||
#define MAX_CANDLIST 10
|
||||
#define MAX_CANDLENGTH 256
|
||||
|
||||
#include "SDL_windowsclipboard.h"
|
||||
#include "SDL_windowsevents.h"
|
||||
#include "SDL_windowskeyboard.h"
|
||||
#include "SDL_windowsmodes.h"
|
||||
#include "SDL_windowsmouse.h"
|
||||
#include "SDL_windowsopengl.h"
|
||||
#include "SDL_windowsopengles.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_loadso.h"
|
||||
|
||||
|
||||
#if WINVER < 0x0601
|
||||
/* Touch input definitions */
|
||||
#define TWF_FINETOUCH 1
|
||||
#define TWF_WANTPALM 2
|
||||
|
||||
#define TOUCHEVENTF_MOVE 0x0001
|
||||
#define TOUCHEVENTF_DOWN 0x0002
|
||||
#define TOUCHEVENTF_UP 0x0004
|
||||
|
||||
DECLARE_HANDLE(HTOUCHINPUT);
|
||||
|
||||
typedef struct _TOUCHINPUT {
|
||||
LONG x;
|
||||
LONG y;
|
||||
HANDLE hSource;
|
||||
DWORD dwID;
|
||||
DWORD dwFlags;
|
||||
DWORD dwMask;
|
||||
DWORD dwTime;
|
||||
ULONG_PTR dwExtraInfo;
|
||||
DWORD cxContact;
|
||||
DWORD cyContact;
|
||||
} TOUCHINPUT, *PTOUCHINPUT;
|
||||
|
||||
#endif /* WINVER < 0x0601 */
|
||||
|
||||
#if WINVER < 0x0603
|
||||
|
||||
typedef enum MONITOR_DPI_TYPE {
|
||||
MDT_EFFECTIVE_DPI = 0,
|
||||
MDT_ANGULAR_DPI = 1,
|
||||
MDT_RAW_DPI = 2,
|
||||
MDT_DEFAULT = MDT_EFFECTIVE_DPI
|
||||
} MONITOR_DPI_TYPE;
|
||||
|
||||
#endif /* WINVER < 0x0603 */
|
||||
|
||||
typedef BOOL (*PFNSHFullScreen)(HWND, DWORD);
|
||||
typedef void (*PFCoordTransform)(SDL_Window*, POINT*);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void **lpVtbl;
|
||||
int refcount;
|
||||
void *data;
|
||||
} TSFSink;
|
||||
|
||||
/* Definition from Win98DDK version of IMM.H */
|
||||
typedef struct tagINPUTCONTEXT2 {
|
||||
HWND hWnd;
|
||||
BOOL fOpen;
|
||||
POINT ptStatusWndPos;
|
||||
POINT ptSoftKbdPos;
|
||||
DWORD fdwConversion;
|
||||
DWORD fdwSentence;
|
||||
union {
|
||||
LOGFONTA A;
|
||||
LOGFONTW W;
|
||||
} lfFont;
|
||||
COMPOSITIONFORM cfCompForm;
|
||||
CANDIDATEFORM cfCandForm[4];
|
||||
HIMCC hCompStr;
|
||||
HIMCC hCandInfo;
|
||||
HIMCC hGuideLine;
|
||||
HIMCC hPrivate;
|
||||
DWORD dwNumMsgBuf;
|
||||
HIMCC hMsgBuf;
|
||||
DWORD fdwInit;
|
||||
DWORD dwReserve[3];
|
||||
} INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2;
|
||||
|
||||
/* Private display data */
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int render;
|
||||
|
||||
DWORD clipboard_count;
|
||||
|
||||
/* Touch input functions */
|
||||
void* userDLL;
|
||||
BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
|
||||
BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
|
||||
BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
|
||||
|
||||
void* shcoreDLL;
|
||||
HRESULT (WINAPI *GetDpiForMonitor)( HMONITOR hmonitor,
|
||||
MONITOR_DPI_TYPE dpiType,
|
||||
UINT *dpiX,
|
||||
UINT *dpiY );
|
||||
|
||||
SDL_bool ime_com_initialized;
|
||||
struct ITfThreadMgr *ime_threadmgr;
|
||||
SDL_bool ime_initialized;
|
||||
SDL_bool ime_enabled;
|
||||
SDL_bool ime_available;
|
||||
HWND ime_hwnd_main;
|
||||
HWND ime_hwnd_current;
|
||||
HIMC ime_himc;
|
||||
|
||||
WCHAR ime_composition[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
WCHAR ime_readingstring[16];
|
||||
int ime_cursor;
|
||||
|
||||
SDL_bool ime_candlist;
|
||||
WCHAR ime_candidates[MAX_CANDLIST][MAX_CANDLENGTH];
|
||||
DWORD ime_candcount;
|
||||
DWORD ime_candref;
|
||||
DWORD ime_candsel;
|
||||
UINT ime_candpgsize;
|
||||
int ime_candlistindexbase;
|
||||
SDL_bool ime_candvertical;
|
||||
|
||||
SDL_bool ime_dirty;
|
||||
SDL_Rect ime_rect;
|
||||
SDL_Rect ime_candlistrect;
|
||||
int ime_winwidth;
|
||||
int ime_winheight;
|
||||
|
||||
HKL ime_hkl;
|
||||
void* ime_himm32;
|
||||
UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
|
||||
BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
|
||||
LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
|
||||
BOOL (WINAPI *ImmUnlockIMC)(HIMC himc);
|
||||
LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc);
|
||||
BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc);
|
||||
|
||||
SDL_bool ime_uiless;
|
||||
struct ITfThreadMgrEx *ime_threadmgrex;
|
||||
DWORD ime_uielemsinkcookie;
|
||||
DWORD ime_alpnsinkcookie;
|
||||
DWORD ime_openmodesinkcookie;
|
||||
DWORD ime_convmodesinkcookie;
|
||||
TSFSink *ime_uielemsink;
|
||||
TSFSink *ime_ippasink;
|
||||
} SDL_VideoData;
|
||||
|
||||
extern SDL_bool g_WindowsEnableMessageLoop;
|
||||
extern SDL_bool g_WindowFrameUsableWhileCursorHidden;
|
||||
|
||||
typedef struct IDirect3D9 IDirect3D9;
|
||||
extern SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface );
|
||||
|
||||
#endif /* SDL_windowsvideo_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
176
externals/SDL/src/video/windows/SDL_windowsvulkan.c
vendored
Executable file
176
externals/SDL/src/video/windows/SDL_windowsvulkan.c
vendored
Executable file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
|
||||
* SDL_x11vulkan.c.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_windowsvulkan.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
int WIN_Vulkan_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
VkExtensionProperties *extensions = NULL;
|
||||
Uint32 extensionCount = 0;
|
||||
Uint32 i;
|
||||
SDL_bool hasSurfaceExtension = SDL_FALSE;
|
||||
SDL_bool hasWin32SurfaceExtension = SDL_FALSE;
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL;
|
||||
if(_this->vulkan_config.loader_handle)
|
||||
return SDL_SetError("Vulkan already loaded");
|
||||
|
||||
/* Load the Vulkan loader library */
|
||||
if(!path)
|
||||
path = SDL_getenv("SDL_VULKAN_LIBRARY");
|
||||
if(!path)
|
||||
path = "vulkan-1.dll";
|
||||
_this->vulkan_config.loader_handle = SDL_LoadObject(path);
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
return -1;
|
||||
SDL_strlcpy(_this->vulkan_config.loader_path, path,
|
||||
SDL_arraysize(_this->vulkan_config.loader_path));
|
||||
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction(
|
||||
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr");
|
||||
if(!vkGetInstanceProcAddr)
|
||||
goto fail;
|
||||
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr;
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties =
|
||||
(void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)(
|
||||
VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties");
|
||||
if(!_this->vulkan_config.vkEnumerateInstanceExtensionProperties)
|
||||
goto fail;
|
||||
extensions = SDL_Vulkan_CreateInstanceExtensionsList(
|
||||
(PFN_vkEnumerateInstanceExtensionProperties)
|
||||
_this->vulkan_config.vkEnumerateInstanceExtensionProperties,
|
||||
&extensionCount);
|
||||
if(!extensions)
|
||||
goto fail;
|
||||
for(i = 0; i < extensionCount; i++)
|
||||
{
|
||||
if(SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
|
||||
hasSurfaceExtension = SDL_TRUE;
|
||||
else if(SDL_strcmp(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0)
|
||||
hasWin32SurfaceExtension = SDL_TRUE;
|
||||
}
|
||||
SDL_free(extensions);
|
||||
if(!hasSurfaceExtension)
|
||||
{
|
||||
SDL_SetError("Installed Vulkan doesn't implement the "
|
||||
VK_KHR_SURFACE_EXTENSION_NAME " extension");
|
||||
goto fail;
|
||||
}
|
||||
else if(!hasWin32SurfaceExtension)
|
||||
{
|
||||
SDL_SetError("Installed Vulkan doesn't implement the "
|
||||
VK_KHR_WIN32_SURFACE_EXTENSION_NAME "extension");
|
||||
goto fail;
|
||||
}
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void WIN_Vulkan_UnloadLibrary(_THIS)
|
||||
{
|
||||
if(_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_UnloadObject(_this->vulkan_config.loader_handle);
|
||||
_this->vulkan_config.loader_handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool WIN_Vulkan_GetInstanceExtensions(_THIS,
|
||||
SDL_Window *window,
|
||||
unsigned *count,
|
||||
const char **names)
|
||||
{
|
||||
static const char *const extensionsForWin32[] = {
|
||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME
|
||||
};
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_SetError("Vulkan is not loaded");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_Vulkan_GetInstanceExtensions_Helper(
|
||||
count, names, SDL_arraysize(extensionsForWin32),
|
||||
extensionsForWin32);
|
||||
}
|
||||
|
||||
SDL_bool WIN_Vulkan_CreateSurface(_THIS,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface)
|
||||
{
|
||||
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
|
||||
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
|
||||
PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR =
|
||||
(PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr(
|
||||
(VkInstance)instance,
|
||||
"vkCreateWin32SurfaceKHR");
|
||||
VkWin32SurfaceCreateInfoKHR createInfo;
|
||||
VkResult result;
|
||||
|
||||
if(!_this->vulkan_config.loader_handle)
|
||||
{
|
||||
SDL_SetError("Vulkan is not loaded");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if(!vkCreateWin32SurfaceKHR)
|
||||
{
|
||||
SDL_SetError(VK_KHR_WIN32_SURFACE_EXTENSION_NAME
|
||||
" extension is not enabled in the Vulkan instance.");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.flags = 0;
|
||||
createInfo.hinstance = windowData->hinstance;
|
||||
createInfo.hwnd = windowData->hwnd;
|
||||
result = vkCreateWin32SurfaceKHR(instance, &createInfo,
|
||||
NULL, surface);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
SDL_SetError("vkCreateWin32SurfaceKHR failed: %s",
|
||||
SDL_Vulkan_GetResultString(result));
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
52
externals/SDL/src/video/windows/SDL_windowsvulkan.h
vendored
Executable file
52
externals/SDL/src/video/windows/SDL_windowsvulkan.h
vendored
Executable file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's
|
||||
* SDL_x11vulkan.h.
|
||||
*/
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowsvulkan_h_
|
||||
#define SDL_windowsvulkan_h_
|
||||
|
||||
#include "../SDL_vulkan_internal.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_WINDOWS
|
||||
|
||||
int WIN_Vulkan_LoadLibrary(_THIS, const char *path);
|
||||
void WIN_Vulkan_UnloadLibrary(_THIS);
|
||||
SDL_bool WIN_Vulkan_GetInstanceExtensions(_THIS,
|
||||
SDL_Window *window,
|
||||
unsigned *count,
|
||||
const char **names);
|
||||
SDL_bool WIN_Vulkan_CreateSurface(_THIS,
|
||||
SDL_Window *window,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* SDL_windowsvulkan_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1011
externals/SDL/src/video/windows/SDL_windowswindow.c
vendored
Executable file
1011
externals/SDL/src/video/windows/SDL_windowswindow.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
87
externals/SDL/src/video/windows/SDL_windowswindow.h
vendored
Executable file
87
externals/SDL/src/video/windows/SDL_windowswindow.h
vendored
Executable file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_windowswindow_h_
|
||||
#define SDL_windowswindow_h_
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
#include "../SDL_egl_c.h"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_Window *window;
|
||||
HWND hwnd;
|
||||
HWND parent;
|
||||
HDC hdc;
|
||||
HDC mdc;
|
||||
HINSTANCE hinstance;
|
||||
HBITMAP hbm;
|
||||
WNDPROC wndproc;
|
||||
SDL_bool created;
|
||||
WPARAM mouse_button_flags;
|
||||
SDL_bool initializing;
|
||||
SDL_bool expected_resize;
|
||||
SDL_bool in_border_change;
|
||||
SDL_bool in_title_click;
|
||||
Uint8 focus_click_pending;
|
||||
SDL_bool skip_update_clipcursor;
|
||||
SDL_bool windowed_mode_was_maximized;
|
||||
SDL_bool in_window_deactivation;
|
||||
RECT cursor_clipped_rect;
|
||||
struct SDL_VideoData *videodata;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
#endif
|
||||
} SDL_WindowData;
|
||||
|
||||
extern int WIN_CreateWindow(_THIS, SDL_Window * window);
|
||||
extern int WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
|
||||
extern void WIN_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
extern void WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
extern void WIN_SetWindowPosition(_THIS, SDL_Window * window);
|
||||
extern void WIN_SetWindowSize(_THIS, SDL_Window * window);
|
||||
extern int WIN_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *bottom, int *right);
|
||||
extern int WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity);
|
||||
extern void WIN_ShowWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_HideWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_RaiseWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_MaximizeWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_MinimizeWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_RestoreWindow(_THIS, SDL_Window * window);
|
||||
extern void WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
|
||||
extern void WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
|
||||
extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||
extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
extern void WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void WIN_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
extern void WIN_OnWindowEnter(_THIS, SDL_Window * window);
|
||||
extern void WIN_UpdateClipCursor(SDL_Window *window);
|
||||
extern int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||
extern void WIN_AcceptDragAndDrop(SDL_Window * window, SDL_bool accept);
|
||||
|
||||
#endif /* SDL_windowswindow_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1052
externals/SDL/src/video/windows/wmmsg.h
vendored
Executable file
1052
externals/SDL/src/video/windows/wmmsg.h
vendored
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user