The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2 oddity involving compositing
Magil


Joined: 30 Jan 2017
Posts: 2
Hello everyone.

I've been having some trouble with SDL2.

Any time I create a window, it disables compositing on my desktop, as if I had pressed ALT+SHIFT+F12, (using KDE Plasma on ArchLinux with latest packages) and I'm not sure why. In addition to this, once I have hidden a window via SDL_HideWindow(), it refuses to return to visibility with the corresponding SDL_ShowWindow() call. The following is the test case I've been using.

Code:

#include <iostream>
#include <SDL2/SDL.h>

int main(int, char**){
  if (SDL_Init(SDL_INIT_VIDEO) != 0){
    std::cout << "SDL_Init error: " << SDL_GetError() << std::endl;
    return 1;
  }

  SDL_Window *win = SDL_CreateWindow("Hello World!", 0, 0, 640, 480,
    SDL_WINDOW_HIDDEN);// SDL_WINDOW_UTILITY);
  if (win == nullptr){
    std::cout << "SDL_CreateWindow error: " << SDL_GetError() << std::endl;
    return 1;
  }

  SDL_Renderer *ren = SDL_CreateRenderer(win, -1,
    SDL_RENDERER_ACCELERATED);

  if (ren == nullptr){
    SDL_DestroyWindow(win);
    std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
    SDL_Quit();
    return 1;
  }


  int i = 0;

  SDL_Event e;
  bool loop = true;
  while (loop) {
    while (SDL_PollEvent(&e)) {
      if(e.type == SDL_QUIT) {
        loop = false;
      }
    }
    ++i;
    if(i == 200) {SDL_ShowWindow(win); printf("shown\n");}
    if(i == 400) {SDL_HideWindow(win); printf("hidden\n");}
    if(i == 600) {SDL_ShowWindow(win); printf("shown\n");}

    SDL_RenderClear(ren);
    SDL_RenderPresent(ren);
    SDL_Delay(10);
  }

  SDL_DestroyRenderer(ren);
  SDL_DestroyWindow(win);
  SDL_Quit();

  return 0;
}


And the compile command:

Code:
g++ -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib -lSDL2 sdl2-test.cpp


I'm assuming there is an error on my part somewhere, either with my setup, compile flags, or something, because I haven't been able to find any information on this anywhere via internet search. If anyone needs additonal info, I'd be glad to provide it.

Something curious to note, is that when the SDL_WINDOW_UTILITY flag is used, compositing remains as it was, but the window fails to return from being hidden, still.

Thank you for your time.
KDE Compositor
Magil


Joined: 30 Jan 2017
Posts: 2
I figured out part of the compositing bit, at least. There's an option for KDE that allows applications to block compositing, i.e. for improved performances in games, under System Settings -> Display and Monitor -> Compositor -> [X] Allow applications to block compositing.