mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-20 09:41:13 +00:00
SDL2: Create window on display the cursor is currently on, fix #309
I hope this provides a good enough way to "select" the display to play on.
This commit is contained in:
parent
12fa3eb814
commit
c684c38f2d
1 changed files with 23 additions and 2 deletions
|
@ -179,9 +179,30 @@ bool GLimp_Init(glimpParms_t parms) {
|
|||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, parms.multiSamples);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
int displayIndex = 0;
|
||||
|
||||
// try to put the window on the display the mousecursor currently is on
|
||||
{
|
||||
int x, y;
|
||||
SDL_GetGlobalMouseState(&x, &y);
|
||||
|
||||
int numDisplays = SDL_GetNumVideoDisplays();
|
||||
for (i=0; i<numDisplays; ++i) {
|
||||
SDL_Rect rect;
|
||||
if (SDL_GetDisplayBounds(i, &rect) == 0) {
|
||||
if ( x >= rect.x && x < rect.x + rect.w
|
||||
&& y >= rect.y && y < rect.y + rect.h )
|
||||
{
|
||||
displayIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow(ENGINE_VERSION,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex),
|
||||
SDL_WINDOWPOS_UNDEFINED_DISPLAY(displayIndex),
|
||||
parms.width, parms.height, flags);
|
||||
|
||||
if (!window) {
|
||||
|
|
Loading…
Reference in a new issue