SDL2: two displays, two windows and fullscreen mode

大憨熊 提交于 2019-12-22 14:57:11

问题


I'm trying to create two windows on two displays. But I have a problem: the second window is displayed in full screen mode, but the first window is minimized, and I need to click on it on the taskbar to expand to full screen.

I create windows in loop with code:

windows_data.window = SDL_CreateWindow("Title", SDL_WINDOWPOS_CENTERED_DISPLAY(i),
            SDL_WINDOWPOS_CENTERED_DISPLAY(i), width, height, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_SHOWN);

Adding the flag SDL_WINDOW_MAXIMIZED does not solve the problem.

My system is Windows 8.1 Proffesional.


回答1:


I debug step by step and found the reason in SDL_video.c::SDL_OnWindowFocusLost(SDL_Window * window)

SDL_OnWindowFocusLost(SDL_Window * window)
{
    if (window->gamma && _this->SetWindowGammaRamp) {
        _this->SetWindowGammaRamp(_this, window, window->saved_gamma);
    }

    SDL_UpdateWindowGrab(window);

    if (ShouldMinimizeOnFocusLoss(window)) {
        SDL_MinimizeWindow(window);
    }
}

So the problem is here "if (ShouldMinimizeOnFocusLoss(window))".

To solve the problem, I add the following code before creating the window:

SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");


来源:https://stackoverflow.com/questions/26774728/sdl2-two-displays-two-windows-and-fullscreen-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!