SDL2:两个显示器,两个窗口和全屏模式 [英] SDL2: two displays, two windows and fullscreen mode

查看:154
本文介绍了SDL2:两个显示器,两个窗口和全屏模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在两个显示器上创建两个窗口.但是我有一个问题:第二个窗口以全屏模式显示,但第一个窗口最小化,我需要在任务栏上单击它才能扩展到全屏.

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);

添加标志 SDL_WINDOW_MAXIMIZED 并不能解决问题.

Adding the flag SDL_WINDOW_MAXIMIZED does not solve the problem.

我的系统是 Windows 8.1 专业版.

My system is Windows 8.1 Proffesional.

推荐答案

我一步步调试,在SDL_video.c::SDL_OnWindowFocusLost(SDL_Window * window)中找到原因

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);
    }
}

所以问题是if (ShouldMinimizeOnFocusLoss(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");

这篇关于SDL2:两个显示器,两个窗口和全屏模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆