简体   繁体   中英

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. The window appears at the top left of the BOTTOM screen. I want it to be at the top left of the TOP screen. When I try to move it with XMoveWindow, it shifts the image inside of it instead of moving the window. I'm rendering an OpenGL scene. I'm using linux and SDL 1.2, I know, there's the problem, but I can't move to SDL2.

Any ideas what's going on?

I have an SDL window I've created with

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.

#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 .

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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