2011-10-28 69 views
8

使用SDL 1.3我想在linux下创建假全屏SDL_Window。如果我只有一个显示器很容易。 我刚刚获得当前显示模式并创建了一个窗口。SDL假全屏模式在Linux下的双显示器设置

SDL_GetDesktopDisplayMode(0, &mode); 

SDL_Window *win = SDL_CreateWindow("my window", 
    0,0,mode.w, mode.h, 
    SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS); 

但是,当我有两个显示器,事情变得复杂。该窗口分布在多个显示器上。 SDL只能看到一个双倍大小的虚拟显示器。

我与此代码测试它

int num = SDL_GetNumVideoDisplays(); 
for(int i=0; i < num; i++) 
{ 
    SDL_Rect displayRect; 
    SDL_GetDisplayBounds(i, &displayRect); 
    std::cout 
     << "display " << i << ": x,y,w,h(" 
     << displayRect.x << ", " 
     << displayRect.y << ", " 
     << displayRect.w << ", " 
     << displayRect.h << ")" 
     << std::endl; 
} 

输出:

display 0: x,y,w,h(0, 0, 2960, 1050) 

但是我有两个显示器(1680×1050 1280×1024和)。

如何强制窗口停留在只有一个(假设主)显示?

+1

+1有趣。这似乎是在操作系统的选择,我不知道你可以做任何事情。 – karlphillip

+1

你使用多种监视器的方法是什么?Xinerama?Xrandr?Nvidia twinview?在你的xorg.conf文件中单独显示屏幕? – genpfault

+1

@genpfault:我在默认设置下(使用gnome-shell)使用fedora 15。 xrandr可能(我不是linux专家),但它也可以在其他机器上工作 – Frizi

回答

2

src/video/x11/SDL_x11modes.c检查了一些有趣的#define S:

SDL_VIDEO_DRIVER_X11_XINERAMA 
SDL_VIDEO_DRIVER_X11_XRANDR 
SDL_VIDEO_DRIVER_X11_XVIDMODE 

您可能会检查include/SDL_config.h,看看哪条路径(S)的副本以下。定义的X11MODES_DEBUG重建也可能具有生产力。

编辑:我与X11MODES_DEBUG系统上尝试test/testvidinfo.c和得到这个:

Built-in video drivers: x11, dummy 
Video driver: x11 
Number of displays: 1 
Display 0: 2646x1024 at 0,0 
    Current mode: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
X11 detected Xinerama: 
xinerama 0: 1366x768+0+0 
xinerama 1: 1280x1024+1366+0 
XRANDR: XRRQueryVersion: V1.3 
XRANDR: mode = 0[0], w = 1366, h = 768, rate = 60 
XRANDR: mode = 1[0], w = 1360, h = 768, rate = 60 
XRANDR: mode = 2[0], w = 1024, h = 768, rate = 60 
XRANDR: mode = 3[0], w = 800, h = 600, rate = 60 
XRANDR: mode = 3[1], w = 800, h = 600, rate = 56 
XRANDR: mode = 4[0], w = 640, h = 480, rate = 60 
Xinerama is enabled 
XRandR is enabled 
    Fullscreen video modes: 
    Mode 0: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 1: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 2: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 3: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 4: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 5: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 6: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
    Mode 7: [email protected], 32 bits-per-pixel 
     Red Mask = 0x00ff0000 
     Green Mask = 0x0000ff00 
     Blue Mask = 0x000000ff 
Current resolution: 2646x1024 

你可以看到SDL已Xinerama的查询,并得到我的两个显示器,但似乎并没有传达回客户端一种有用的方式。

可悲的是它看起来像你需要发布到邮件列表或提交错误:(

+0

你是如何得到这个xinerama和xrandr信息的?我在测试源里没有任何与它有关的东西 – Frizi

+0

I取消注释src/video/x11/S顶部的#define X11MODES_DEBUG DL_x11modes.c',重建/重新安装SDL,然后在SDL源代码树中构建/运行'test/testvidinfo.c'。确保你已经安装了用于Xinerama和Xrandr的开发库(Ubuntu上的libxinerama-dev和libxrandr-dev,不知道Fedora)。 – genpfault