mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-13 11:48:05 +08:00
Support SDL_EVENT_DROP_FILE in Windows with IDropTarget instead of WM_DROPFILES
Support SDL_EVENT_DROP_TEXT in Windows
src/video/windows/SDL_windowsvideo.c + .h
Connect to COM WIN_CoInitialize + OLE OleInitialize in WIN_VideoInit
Disconnect from COM WIN_CoUninitialize + OLE OleUninitialize in WIN_VideoQuit
src/video/windows/SDL_windowswindow.c + .h
Create / Destroy IDropTarget or use fallback WM_DROPFILES
depending on OleInitialize success in WIN_VideoInit
Handle text/uri-list, text/plain;charset=utf-8, CF_UNICODE_TEXT, CF_TEXT, CF_HDROP
Call terminating WIN_AcceptDragAndDrop from WIN_DestroyWindow ( CleanupVideoData )
This commit is contained in:
committed by
Sam Lantinga
parent
efefc4a1f3
commit
808c312b2a
@@ -467,6 +467,21 @@ static void WIN_InitDPIAwareness(SDL_VideoDevice *_this)
|
||||
int WIN_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_VideoData *data = _this->internal;
|
||||
HRESULT hr;
|
||||
|
||||
hr = WIN_CoInitialize();
|
||||
if (SUCCEEDED(hr)) {
|
||||
data->coinitialized = SDL_TRUE;
|
||||
|
||||
hr = OleInitialize(NULL);
|
||||
if (SUCCEEDED(hr)) {
|
||||
data->oleinitialized = SDL_TRUE;
|
||||
} else {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "OleInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr);
|
||||
}
|
||||
} else {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "CoInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr);
|
||||
}
|
||||
|
||||
WIN_InitDPIAwareness(_this);
|
||||
|
||||
@@ -511,6 +526,8 @@ int WIN_VideoInit(SDL_VideoDevice *_this)
|
||||
|
||||
void WIN_VideoQuit(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_VideoData *data = _this->internal;
|
||||
|
||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
WIN_QuitModes(_this);
|
||||
WIN_QuitDeviceNotification();
|
||||
@@ -525,6 +542,15 @@ void WIN_VideoQuit(SDL_VideoDevice *_this)
|
||||
|
||||
WIN_SetRawMouseEnabled(_this, SDL_FALSE);
|
||||
WIN_SetRawKeyboardEnabled(_this, SDL_FALSE);
|
||||
|
||||
if (data->oleinitialized) {
|
||||
OleUninitialize();
|
||||
data->oleinitialized = SDL_FALSE;
|
||||
}
|
||||
if (data->coinitialized) {
|
||||
WIN_CoUninitialize();
|
||||
data->coinitialized = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
|
||||
|
||||
@@ -379,6 +379,9 @@ struct SDL_VideoData
|
||||
{
|
||||
int render;
|
||||
|
||||
SDL_bool coinitialized;
|
||||
SDL_bool oleinitialized;
|
||||
|
||||
DWORD clipboard_count;
|
||||
|
||||
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Xbox doesn't support user32/shcore*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,16 @@ typedef enum SDL_WindowEraseBackgroundMode
|
||||
SDL_ERASEBACKGROUNDMODE_ALWAYS,
|
||||
} SDL_WindowEraseBackgroundMode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void **lpVtbl;
|
||||
int refcount;
|
||||
SDL_Window *window;
|
||||
HWND hwnd;
|
||||
UINT format_text;
|
||||
UINT format_file;
|
||||
} SDLDropTarget;
|
||||
|
||||
struct SDL_WindowData
|
||||
{
|
||||
SDL_Window *window;
|
||||
@@ -89,6 +99,7 @@ struct SDL_WindowData
|
||||
|
||||
/* Whether we retain the content of the window when changing state */
|
||||
UINT copybits_flag;
|
||||
SDLDropTarget *drop_target;
|
||||
};
|
||||
|
||||
extern int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
|
||||
Reference in New Issue
Block a user