Improvements from Alfred:
- Added new SDL_HINT_ALLOW_TOPMOST hint, when set to "0" then never set the topmost bit on a window. Useful when debugging fullscreen issues. - fixed crash in windows joystick scanning if we failed to load the xinput dll - added support for SDL_WINDOW_FULLSCREEN_DESKTOP under windows - synthesize relative mouse movements if directinput fails to send relative moves, happens under virtual box.
This commit is contained in:
parent
1b938d7de2
commit
f4294fd806
5 changed files with 103 additions and 29 deletions
|
@ -204,6 +204,18 @@ extern "C" {
|
||||||
#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
|
#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief If set to 0 then never set the top most bit on a SDL Window, even if the video mode expects it.
|
||||||
|
* This is a debugging aid for developers and not expected to be used by end users. The default is "1"
|
||||||
|
*
|
||||||
|
* This variable can be set to the following values:
|
||||||
|
* "0" - don't allow topmost
|
||||||
|
* "1" - allow topmost
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An enumeration of hint priorities
|
* \brief An enumeration of hint priorities
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -569,6 +569,8 @@ SDL_JoystickThread(void *_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( XINPUTGETCAPABILITIES )
|
||||||
|
{
|
||||||
// scan for any change in XInput devices
|
// scan for any change in XInput devices
|
||||||
for ( userId = 0; userId < 4; userId++ )
|
for ( userId = 0; userId < 4; userId++ )
|
||||||
{
|
{
|
||||||
|
@ -589,7 +591,7 @@ SDL_JoystickThread(void *_data)
|
||||||
bOpenedXInputDevices[userId] = SDL_FALSE;
|
bOpenedXInputDevices[userId] = SDL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( s_pKnownJoystickGUIDs && ( s_bWindowsDeviceChanged || nNewOpenedXInputDevices != nCurrentOpenedXInputDevices ) )
|
if ( s_pKnownJoystickGUIDs && ( s_bWindowsDeviceChanged || nNewOpenedXInputDevices != nCurrentOpenedXInputDevices ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -538,9 +538,14 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
|
|
||||||
if (window_flags & SDL_WINDOW_FULLSCREEN) {
|
if (window_flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
|
if ( ( window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) {
|
||||||
|
pparams.Windowed = TRUE;
|
||||||
|
pparams.FullScreen_RefreshRateInHz = 0;
|
||||||
|
} else {
|
||||||
pparams.Windowed = FALSE;
|
pparams.Windowed = FALSE;
|
||||||
pparams.FullScreen_RefreshRateInHz =
|
pparams.FullScreen_RefreshRateInHz =
|
||||||
fullscreen_mode.refresh_rate;
|
fullscreen_mode.refresh_rate;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pparams.Windowed = TRUE;
|
pparams.Windowed = TRUE;
|
||||||
pparams.FullScreen_RefreshRateInHz = 0;
|
pparams.FullScreen_RefreshRateInHz = 0;
|
||||||
|
|
|
@ -221,6 +221,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
HRAWINPUT hRawInput = (HRAWINPUT)lParam;
|
HRAWINPUT hRawInput = (HRAWINPUT)lParam;
|
||||||
RAWINPUT inp;
|
RAWINPUT inp;
|
||||||
UINT size = sizeof(inp);
|
UINT size = sizeof(inp);
|
||||||
|
|
||||||
|
if(!SDL_GetMouse()->relative_mode)
|
||||||
|
break;
|
||||||
|
|
||||||
GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
|
GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER));
|
||||||
|
|
||||||
/* Mouse data */
|
/* Mouse data */
|
||||||
|
@ -229,8 +233,24 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
RAWMOUSE* mouse = &inp.data.mouse;
|
RAWMOUSE* mouse = &inp.data.mouse;
|
||||||
|
|
||||||
if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE)
|
if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE)
|
||||||
|
{
|
||||||
SDL_SendMouseMotion(data->window, 1, (int)mouse->lLastX, (int)mouse->lLastY);
|
SDL_SendMouseMotion(data->window, 1, (int)mouse->lLastX, (int)mouse->lLastY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// synthesize relative moves from the abs position
|
||||||
|
static SDL_Point initialMousePoint;
|
||||||
|
if ( initialMousePoint.x == 0 && initialMousePoint.y == 0 )
|
||||||
|
{
|
||||||
|
initialMousePoint.x = mouse->lLastX;
|
||||||
|
initialMousePoint.y = mouse->lLastY;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SendMouseMotion(data->window, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) );
|
||||||
|
|
||||||
|
initialMousePoint.x = mouse->lLastX;
|
||||||
|
initialMousePoint.y = mouse->lLastY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "SDL_windowsvideo.h"
|
#include "SDL_windowsvideo.h"
|
||||||
#include "SDL_windowswindow.h"
|
#include "SDL_windowswindow.h"
|
||||||
|
#include "SDL_hints.h"
|
||||||
|
|
||||||
/* Dropfile support */
|
/* Dropfile support */
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
@ -73,6 +74,22 @@ GetWindowStyle(SDL_Window * window)
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SDL_bool
|
||||||
|
ShouldAllowTopMost()
|
||||||
|
{
|
||||||
|
const char *hint;
|
||||||
|
|
||||||
|
/* If the user has specified a software renderer we can't use a
|
||||||
|
texture framebuffer, or renderer creation will go recursive.
|
||||||
|
*/
|
||||||
|
hint = SDL_GetHint(SDL_HINT_ALLOW_TOPMOST);
|
||||||
|
if (hint && hint[0] == '0' ) {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
||||||
{
|
{
|
||||||
|
@ -354,7 +371,7 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags)
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
/* Figure out what the window area will be */
|
/* Figure out what the window area will be */
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if ( ShouldAllowTopMost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
|
||||||
top = HWND_TOPMOST;
|
top = HWND_TOPMOST;
|
||||||
} else {
|
} else {
|
||||||
top = HWND_NOTOPMOST;
|
top = HWND_NOTOPMOST;
|
||||||
|
@ -406,7 +423,7 @@ WIN_RaiseWindow(_THIS, SDL_Window * window)
|
||||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||||
HWND top;
|
HWND top;
|
||||||
|
|
||||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
if ( ShouldAllowTopMost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
|
||||||
top = HWND_TOPMOST;
|
top = HWND_TOPMOST;
|
||||||
} else {
|
} else {
|
||||||
top = HWND_NOTOPMOST;
|
top = HWND_NOTOPMOST;
|
||||||
|
@ -467,11 +484,12 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display,
|
||||||
int x, y;
|
int x, y;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
if (fullscreen) {
|
if ( ShouldAllowTopMost() && (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS)) == (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_INPUT_FOCUS )) {
|
||||||
top = HWND_TOPMOST;
|
top = HWND_TOPMOST;
|
||||||
} else {
|
} else {
|
||||||
top = HWND_NOTOPMOST;
|
top = HWND_NOTOPMOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
style = GetWindowLong(hwnd, GWL_STYLE);
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
||||||
style &= ~STYLE_MASK;
|
style &= ~STYLE_MASK;
|
||||||
style |= GetWindowStyle(window);
|
style |= GetWindowStyle(window);
|
||||||
|
@ -551,6 +569,23 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||||
} else {
|
} else {
|
||||||
ClipCursor(NULL);
|
ClipCursor(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( window->flags & SDL_WINDOW_FULLSCREEN )
|
||||||
|
{
|
||||||
|
HWND top;
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||||
|
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||||
|
UINT flags = SWP_NOMOVE | SWP_NOSIZE;
|
||||||
|
|
||||||
|
if ( ShouldAllowTopMost() && (window->flags & SDL_WINDOW_INPUT_FOCUS ) ) {
|
||||||
|
top = HWND_TOPMOST;
|
||||||
|
} else {
|
||||||
|
top = HWND_NOTOPMOST;
|
||||||
|
flags |= SWP_NOZORDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWindowPos(hwnd, top, 0, 0, 0, 0, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue