Added a multi-monitor fullscreen mode
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8501 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b667a89e7a255bc31d2042386857c37f171f2ea6 Former-commit-id: 63eaa4d24a4484f540dcb5010212cd92ae0fffd4
This commit is contained in:
parent
3dc3dd5972
commit
db063a2321
3 changed files with 127 additions and 2 deletions
|
@ -90,6 +90,7 @@ GfuiMenuDefaultKeysAdd(void* scr)
|
|||
if(GfScrUsingResizableWindow())
|
||||
{
|
||||
GfuiAddKey(scr, GFUIK_RETURN, GFUIM_ALT, "Toggle Full-screen", (void*)0, GfScrToggleFullScreen, NULL);
|
||||
GfuiAddKey(scr, GFUIK_RETURN, GFUIM_CTRL | GFUIM_ALT, "Toggle Multi Full-screens", (void*)0, GfScrToggleMultiFullScreens, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ void GfScrInitialWindowedPosition();
|
|||
void gfScrSaveWindowState();
|
||||
bool gfScrAAOpenGLSetup();
|
||||
void gfScrDisableResizable();
|
||||
bool GfscrAllowMultiFullScreens();
|
||||
SDL_Rect GetMultiFullScreenBounds();
|
||||
|
||||
|
||||
// The screen properties.
|
||||
|
@ -1207,10 +1209,18 @@ void GfScrInitialWindowedPosition()
|
|||
SDL_SetWindowSize(GfuiWindow, w, h);
|
||||
|
||||
if(max)
|
||||
{
|
||||
SDL_MaximizeWindow(GfuiWindow);
|
||||
}
|
||||
|
||||
if(full)
|
||||
if(full == 1)
|
||||
{
|
||||
SDL_SetWindowFullscreen(GfuiWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
else if(full == 2)
|
||||
{
|
||||
GfScrToggleMultiFullScreens(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
bool GfScrInitSDL2()
|
||||
|
@ -1283,11 +1293,118 @@ void GfScrToggleFullScreen(void* unused)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (flags & SDL_WINDOW_BORDERLESS) // we are MultiFullScreen
|
||||
{
|
||||
GfScrToggleMultiFullScreens(NULL);
|
||||
}
|
||||
GfScrSetFullscreen(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Rect GetMultiFullScreenBounds()
|
||||
{
|
||||
SDL_Rect bounds;
|
||||
SDL_Rect maxBounds;
|
||||
int nDisplays = SDL_GetNumVideoDisplays();
|
||||
for(int i = 0;i < nDisplays;i++)
|
||||
{
|
||||
if(SDL_GetDisplayBounds(i, &bounds) == 0)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
maxBounds = bounds;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bounds.x < maxBounds.x)
|
||||
maxBounds.x = bounds.x;
|
||||
|
||||
maxBounds.w += bounds.w;
|
||||
}
|
||||
}
|
||||
}
|
||||
return maxBounds;
|
||||
}
|
||||
|
||||
bool GfscrAllowMultiFullScreens()
|
||||
{
|
||||
bool bRet = false;
|
||||
SDL_Rect bounds;
|
||||
|
||||
int nDisplays = SDL_GetNumVideoDisplays();
|
||||
if(nDisplays > 1)
|
||||
{
|
||||
int height = 0;
|
||||
int top = 0;
|
||||
for(int i = 0;i < nDisplays;i++)
|
||||
{
|
||||
if(SDL_GetDisplayBounds(i, &bounds) == 0)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
top = bounds.y;
|
||||
height = bounds.h;
|
||||
bRet = true;
|
||||
continue;
|
||||
}
|
||||
if((bounds.h != height) || (bounds.y != top))
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void GfScrToggleMultiFullScreens(void* unused)
|
||||
{
|
||||
static int restoreX = 0;
|
||||
static int restoreY = 0;
|
||||
static int restoreW = 800;
|
||||
static int restoreH = 600;
|
||||
Uint32 flags = SDL_GetWindowFlags(GfuiWindow);
|
||||
|
||||
if (flags & SDL_WINDOW_BORDERLESS) // we are MultiFullScreen
|
||||
{
|
||||
SDL_SetWindowBordered(GfuiWindow, SDL_TRUE);
|
||||
SDL_SetWindowPosition(GfuiWindow, restoreX, restoreY);
|
||||
SDL_SetWindowSize(GfuiWindow, restoreW, restoreH);
|
||||
}
|
||||
else if(GfscrAllowMultiFullScreens()) // NOT in Full-multiscreen
|
||||
{
|
||||
if ((flags & SDL_WINDOW_FULLSCREEN) || (flags & SDL_WINDOW_FULLSCREEN_DESKTOP))
|
||||
{
|
||||
GfScrSetFullscreen(false);
|
||||
}
|
||||
|
||||
SDL_GetWindowPosition(GfuiWindow, &restoreX, &restoreY);
|
||||
SDL_GetWindowSize(GfuiWindow, &restoreW, &restoreH);
|
||||
|
||||
SDL_SetWindowBordered(GfuiWindow, SDL_FALSE);
|
||||
SDL_Rect bounds = GetMultiFullScreenBounds();
|
||||
|
||||
if(!SDL_RectEmpty(&bounds))
|
||||
{
|
||||
SDL_SetWindowPosition(GfuiWindow,bounds.x, bounds.y);
|
||||
SDL_SetWindowSize(GfuiWindow, bounds.w, bounds.h);
|
||||
}
|
||||
else
|
||||
{
|
||||
GfLogError("GetMultiFullScreenBounds() returned an empty rectangle.\n");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gfScrSaveWindowState()
|
||||
{
|
||||
GfLogTrace("Saving resizable window state.\n");
|
||||
|
@ -1296,12 +1413,18 @@ void gfScrSaveWindowState()
|
|||
int x = 0;
|
||||
int y = 0;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
int h = 0;
|
||||
int full = 0;
|
||||
int max = 0;
|
||||
|
||||
int dispIndex = SDL_GetWindowDisplayIndex(GfuiWindow);
|
||||
|
||||
Uint32 flags = SDL_GetWindowFlags(GfuiWindow);
|
||||
if (flags & SDL_WINDOW_BORDERLESS) // we are MultiFullScreen
|
||||
{
|
||||
full = 2;
|
||||
GfScrToggleMultiFullScreens(NULL);
|
||||
}
|
||||
if ((flags & SDL_WINDOW_FULLSCREEN) || (flags & SDL_WINDOW_FULLSCREEN_DESKTOP))
|
||||
{
|
||||
full = 1;
|
||||
|
|
|
@ -98,6 +98,7 @@ TGFCLIENT_API tScreenSize GfScrGetCurrentDisplaySize(int nDisplayIndex);
|
|||
|
||||
TGFCLIENT_API bool GfScrUsingResizableWindow();
|
||||
TGFCLIENT_API void GfScrToggleFullScreen(void* unused);
|
||||
TGFCLIENT_API void GfScrToggleMultiFullScreens(void* unused);
|
||||
|
||||
/********************
|
||||
* Music Interface *
|
||||
|
|
Loading…
Reference in a new issue