简体   繁体   English

带有SDL 1.2的X11 XMoveWindow不会移动窗口

[英]X11 XMoveWindow with SDL 1.2 does NOT move window

I'm working on a dual screen setup. 我正在双屏设置。 The screens are positioned one on top of the other. 屏幕位于一个屏幕上。 I create a window in SDL that is the size of both screens combined. 我在SDL中创建一个窗口,该窗口是两个屏幕的总和。 The window appears at the top left of the BOTTOM screen. 该窗口出现在“底部”屏幕的左上方。 I want it to be at the top left of the TOP screen. 我希望它位于TOP屏幕的左上方。 When I try to move it with XMoveWindow, it shifts the image inside of it instead of moving the window. 当我尝试使用XMoveWindow移动它时,它会在其中移动图像,而不是移动窗口。 I'm rendering an OpenGL scene. 我正在渲染OpenGL场景。 I'm using linux and SDL 1.2, I know, there's the problem, but I can't move to SDL2. 我使用的是Linux和SDL 1.2,我知道这是有问题的,但是我无法使用SDL2。

Any ideas what's going on? 有什么想法吗?

I have an SDL window I've created with 我有一个创建的SDL窗口

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE);

SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
screen = SDL_SetVideoMode(w, h, 32, SDL_HWACCEL | SDL_OPENGL | SDL_GL_DOUBLEBUFFER);

But when I run run my program, the window stays in place and the image inside it has been shifted by 200,-200. 但是,当我运行我的程序时,窗口将保留在原处,并且其中的图像已偏移200-200。

#include <SDL/SDL.h>
#include <SDL/SDL_syswm.h>
#include <GL/gl.h>
#include <X11/Xlib.h>

void move()
{
    SDL_SysWMinfo info;
    SDL_VERSION(&info.version);


    if (SDL_GetWMInfo(&info))
    {
        // Put the window at origin!!!!!
        cout << "xmovewindow: " << XMoveWindow(info.info.x11.display, info.info.x11.window, 200, -200) << endl;
        // prints "xmovewindow: 1"
    }
}

Halp!

I am also trying to achieve this, there seem to be only a dirty way. 我也在努力实现这一目标,似乎只有一种肮脏的方式。

You have to use SDL_SetVideoMode() which permit do do that as mentioned in SDL documentation . 您必须使用SDL_SetVideoMode() ,它可以按照SDL文档中所述进行操作

Try this: 尝试这个:

SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED="));
SDL_putenv(const_cast<char*>("SDL_VIDEO_WINDOW_POS=100,50"));
SDL_SetVideoMode(width, height, bpp, flags);

But this has no effect if Video Mode was already same with same witdh and same height! 但是,如果视频模式已经相同且具有相同的高度和高度,则这将无效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM