I have created a simple OpenGL window with SDL2. I'm running this on Linux and my WM is xfwm4.
My problem is that if I change workspace (with ctrl+alt+arrows) while window is not focused, it will raise itself. This makes the window appear on the new workspace, or (depending on the WM settings) immediately switches the workspace back. Is there way to prevent this?
Here's a testcase that demonstrates this behavior:
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window = SDL_CreateWindow("test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 200, 200, SDL_WINDOW_OPENGL);
SDL_GLContext glcontext = SDL_GL_CreateContext(window);
glEnable(GL_SCISSOR_TEST);
while (1)
{
SDL_Event e;
SDL_PollEvent(&e);
if (e.type == SDL_QUIT || e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE)
break;
// a small opengl effect, please don't mind
int bs = (rand() % 50) + 50; int bo = (200-bs)/2;
float t = SDL_GetTicks()*0.001f; glScissor(0, cos(t*18.92623f)*bo+bo,200,bs);
float g = sin(t)*0.5f+0.5f; glClearColor(2.0f*g,1.5f*g,0.8f*g,0.f); glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(window);
}
SDL_GL_DeleteContext(glcontext);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}