Linux 下双显示器设置上的 SDL 假全屏模式
使用SDL 1.3我想在linux下创建假全屏SDL_Window。如果我只有一台显示器,这很容易。 我刚刚获得当前显示模式并创建了一个窗口。
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)
但我有两个显示器(1680x1050 和 1280x1024)。
如何强制窗口仅停留在一个(假设是主)显示器上?
Using SDL 1.3 I want to create fake fullscreen SDL_Window under linux. It is easy if i have only one display.
I just got current display mode and created a window.
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 );
But when i have two displays, things get complicated. The window spreads across multiple monitors. SDL sees only one, double sized virtual display.
I tested it with this code
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;
}
output:
display 0: x,y,w,h(0, 0, 2960, 1050)
But i have two displays (1680x1050 and 1280x1024).
How to force the window to stay on only one (assume main) display?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
src/video/x11/SDL_x11modes.c< /code>
检查一些有趣的
#define
:您可能会检查
include/SDL_config.h
查看您的副本所遵循的路径。使用定义的X11MODES_DEBUG
进行重建也可能会很有成效。编辑:在我的系统上使用
X11MODES_DEBUG
尝试test/testvidinfo.c
并得到以下结果:您可以看到 SDL 已查询 Xinerama 并获取了我的两个显示器,但似乎没有以有用的方式将其传达给客户。
遗憾的是,您似乎需要发布到邮件列表或提交错误:(
src/video/x11/SDL_x11modes.c
checks some interesting#define
s:You might check
include/SDL_config.h
to see which path(s) your copy is following. Rebuilding withX11MODES_DEBUG
defined may also be productive.EDIT: Tried
test/testvidinfo.c
on my system withX11MODES_DEBUG
and got this:You can see SDL has queried Xinerama and gotten both of my monitors but doesn't seem to communicate that back to the client in a useful manner.
Sadly it looks like you need to post to the mailing list or file a bug :(