mirror of https://github.com/encounter/SDL.git
Add SDL_SetWindowAlwaysOnTop()
This commit is contained in:
parent
6be9c00970
commit
a0a5da5d91
|
@ -1010,6 +1010,21 @@ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
|
||||||
extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window,
|
extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window,
|
||||||
SDL_bool resizable);
|
SDL_bool resizable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the window to always be above the others.
|
||||||
|
*
|
||||||
|
* This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP`
|
||||||
|
* flag. This will bring the window to the front and keep the window above
|
||||||
|
* the rest.
|
||||||
|
*
|
||||||
|
* \param window The window of which to change the always on top state.
|
||||||
|
* \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to disable.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetWindowAlwaysOnTop
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window * window,
|
||||||
|
SDL_bool on_top);
|
||||||
/**
|
/**
|
||||||
* Show a window.
|
* Show a window.
|
||||||
*
|
*
|
||||||
|
|
|
@ -810,3 +810,4 @@
|
||||||
#define SDL_AndroidShowToast SDL_AndroidShowToast_REAL
|
#define SDL_AndroidShowToast SDL_AndroidShowToast_REAL
|
||||||
#define SDL_GetAudioDeviceSpec SDL_GetAudioDeviceSpec_REAL
|
#define SDL_GetAudioDeviceSpec SDL_GetAudioDeviceSpec_REAL
|
||||||
#define SDL_TLSCleanup SDL_TLSCleanup_REAL
|
#define SDL_TLSCleanup SDL_TLSCleanup_REAL
|
||||||
|
#define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL
|
||||||
|
|
|
@ -875,3 +875,4 @@ SDL_DYNAPI_PROC(int,SDL_AndroidShowToast,(const char *a, int b, int c, int d, in
|
||||||
#endif
|
#endif
|
||||||
SDL_DYNAPI_PROC(int,SDL_GetAudioDeviceSpec,(int a, int b, SDL_AudioSpec *c),(a,b,c),return)
|
SDL_DYNAPI_PROC(int,SDL_GetAudioDeviceSpec,(int a, int b, SDL_AudioSpec *c),(a,b,c),return)
|
||||||
SDL_DYNAPI_PROC(void,SDL_TLSCleanup,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_TLSCleanup,(void),(),)
|
||||||
|
SDL_DYNAPI_PROC(void,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, SDL_bool b),(a,b),)
|
||||||
|
|
|
@ -229,6 +229,7 @@ struct SDL_VideoDevice
|
||||||
void (*RestoreWindow) (_THIS, SDL_Window * window);
|
void (*RestoreWindow) (_THIS, SDL_Window * window);
|
||||||
void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
|
void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
|
||||||
void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool resizable);
|
void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool resizable);
|
||||||
|
void (*SetWindowAlwaysOnTop) (_THIS, SDL_Window * window, SDL_bool on_top);
|
||||||
void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||||
int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
|
int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||||
int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
|
int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
|
||||||
|
|
|
@ -2109,6 +2109,25 @@ SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SDL_SetWindowAlwaysOnTop(SDL_Window * window, SDL_bool on_top)
|
||||||
|
{
|
||||||
|
CHECK_WINDOW_MAGIC(window,);
|
||||||
|
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||||
|
const int want = (on_top != SDL_FALSE); /* normalize the flag. */
|
||||||
|
const int have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0);
|
||||||
|
if ((want != have) && (_this->SetWindowAlwaysOnTop)) {
|
||||||
|
if (want) {
|
||||||
|
window->flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
||||||
|
} else {
|
||||||
|
window->flags &= ~SDL_WINDOW_ALWAYS_ON_TOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
_this->SetWindowAlwaysOnTop(_this, window, (SDL_bool) want);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,6 +92,7 @@ Cocoa_CreateDevice(int devindex)
|
||||||
device->RestoreWindow = Cocoa_RestoreWindow;
|
device->RestoreWindow = Cocoa_RestoreWindow;
|
||||||
device->SetWindowBordered = Cocoa_SetWindowBordered;
|
device->SetWindowBordered = Cocoa_SetWindowBordered;
|
||||||
device->SetWindowResizable = Cocoa_SetWindowResizable;
|
device->SetWindowResizable = Cocoa_SetWindowResizable;
|
||||||
|
device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop;
|
||||||
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
|
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
|
||||||
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
|
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
|
||||||
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
|
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
|
||||||
|
|
|
@ -142,6 +142,7 @@ extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
|
extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
|
||||||
extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
|
extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
|
||||||
extern void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
|
extern void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
|
||||||
|
extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top);
|
||||||
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||||
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||||
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||||
|
|
|
@ -1819,6 +1819,18 @@ Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top)
|
||||||
|
{ @autoreleasepool
|
||||||
|
{
|
||||||
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
|
if (on_top) {
|
||||||
|
[nswindow setLevel:NSFloatingWindowLevel];
|
||||||
|
} else {
|
||||||
|
[nswindow setLevel:kCGNormalWindowLevel];
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
||||||
{ @autoreleasepool
|
{ @autoreleasepool
|
||||||
|
|
|
@ -157,6 +157,7 @@ WIN_CreateDevice(int devindex)
|
||||||
device->RestoreWindow = WIN_RestoreWindow;
|
device->RestoreWindow = WIN_RestoreWindow;
|
||||||
device->SetWindowBordered = WIN_SetWindowBordered;
|
device->SetWindowBordered = WIN_SetWindowBordered;
|
||||||
device->SetWindowResizable = WIN_SetWindowResizable;
|
device->SetWindowResizable = WIN_SetWindowResizable;
|
||||||
|
device->SetWindowAlwaysOnTop = WIN_SetWindowAlwaysOnTop;
|
||||||
device->SetWindowFullscreen = WIN_SetWindowFullscreen;
|
device->SetWindowFullscreen = WIN_SetWindowFullscreen;
|
||||||
device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
|
device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
|
||||||
device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
|
device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
|
||||||
|
|
|
@ -631,6 +631,18 @@ WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||||
SetWindowLong(hwnd, GWL_STYLE, style);
|
SetWindowLong(hwnd, GWL_STYLE, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
HWND hwnd = data->hwnd;
|
||||||
|
if (on_top) {
|
||||||
|
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||||
|
} else {
|
||||||
|
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WIN_RestoreWindow(_THIS, SDL_Window * window)
|
WIN_RestoreWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,6 +73,7 @@ extern void WIN_MinimizeWindow(_THIS, SDL_Window * window);
|
||||||
extern void WIN_RestoreWindow(_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_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
|
||||||
extern void WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
|
extern void WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
|
||||||
|
extern void WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top);
|
||||||
extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
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_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||||
extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||||
|
|
Loading…
Reference in New Issue