1

The window always pops up in the background, but I want it to be in the foreground, at least in front of the terminal, in which the code is executed that opens the window.

I do not need focus on that window, so just raising without focus would be ok. (SDL2 Raising a window without giving it focus).

I've tried all SDL_WindowFlags, but none seems to help. Also SDL_RaiseWindow() did not help.

The window is meant for graphically displaying results of a terminal program. I compiled SDL2 from source 2.0.3 on CentOs 6.4

I compile the below program and start it from a bash terminal in KDE (Focus stealing prevention level: low, Focus Policy: click to focus).

Example code:

#include <SDL.h>

int main(int, char**){
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, 640, 480,
        SDL_WINDOW_SHOWN | SDL_WINDOW_INPUT_GRABBED |
        SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS |
        SDL_WINDOW_FOREIGN | SDL_WINDOW_OPENGL);
    SDL_RaiseWindow(win);

    SDL_Delay(4000);
    SDL_DestroyWindow(win);
    SDL_Quit();

    return 0;
}

EDIT: I've tried the same example in Cygwin64 under windows. The window pops-up in front of the terminal in that case. So is this a CentOS/window-manager problem?

Community
  • 1
  • 1
eagle123
  • 164
  • 9
  • How are you executing the program? Is the *focus policy* of the *window manager* set to *click to focus*? – Aabesh Karmacharya Feb 28 '15 at 14:22
  • Hi Elvisjames, I compile the above program and start it from a bash terminal in KDE. Focus stealing prevention level: low, Focus Policy: click to focus. – eagle123 Feb 28 '15 at 14:34

1 Answers1

0

The behavior in KDE/CentOs depends on the focus stealing prevention level setting of the window manager. It was set to low. The window will raise on top when I set it to none instead. My new question is: Can I somehow force the window to be raised, even with setting low? (https://stackoverflow.com/questions/28785519/force-window-to-be-raised-with-focus-stealing-prevention-level-low)

The window also raises under Cygwin64 in Windows.

Community
  • 1
  • 1
eagle123
  • 164
  • 9