I happened on a game that uses SDL2 to set the screen to:

640x480
fullscreen

In the past, SDL would change the video card resolution to 640x480.
This would be handled by a modeset in X.

With SDL2 it leaves the resolution alone and instead tells the video
card to magnify everything.

It looks like Fvwm is ignorant of the process, when I run an SDL2 app
Fvwm decorates the full screen window, so I see a titlebar and border.
Just a warning, it's difficult to work with this window, you can wind up
having to reboot.

I ran FvwmIdent from a titlebar button and the window iconified and the
apparent window resolution stayed at 640x480.
Just use caution if you test, I ended up using
a keyboard driven menu that used xrandr to restore my resolution to recover.

So, I'm guessing SDL2 sets some kind of hint that it's in full screen
and should not be decorated.  I'm not sure how to find that hint.  As
long as the window is full screen I can't run anything else.

Attached is a demo module.  It's c++, uses SDL2.
Depending on your distro, you may need some packages, I needed
a few sdl devel packages:

I did:

sudo dnf install SDL2_*-devel

The demo creates a blue window which goes away after a few seconds.
You can see how to increase the time if you like.
A comment in the source code shows how to use FvwmCommand to get rid
of the unwanted border and titlebar which creates a workable 640x480
SDL2 window.

So I'll attempt to include the demo right inline, I tried to keep the
lines short enough, this is wind.cpp:

// Modification History
// Created on 04/09/20 by Dan Espen:
// - Demo fullscreen with SDL2
// - Full screen 640x480 window,
//   terminate with escape,
//   times out after a few secs.
#include <SDL2/SDL.h>

int main(int argc, char *argv[]) {
  SDL_Window* window = NULL;
  SDL_Renderer* renderer;
  if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_EVENTS) != 0) {
    SDL_Log("Failed to initialize SDL: %s", SDL_GetError());
    return 1;
  }
  // fixme, the WM is adding titlebar and borders,
  // To remove decoration, Run:
  // FvwmCommand 'Style "mywind" NoTitle, BorderWidth 0, HandleWidth 0'
  window = SDL_CreateWindow("mywind",
                            SDL_WINDOWPOS_UNDEFINED,
                            SDL_WINDOWPOS_UNDEFINED,
                            640, 480,
                            SDL_WINDOW_FULLSCREEN_DESKTOP
                            |SDL_WINDOW_BORDERLESS);
  renderer = SDL_CreateRenderer(window, -1, 0);
  SDL_SetRenderDrawColor(renderer,
                         0x80, 0x80, 0xFF, 0xFF); // RGBA
  SDL_RenderClear(renderer);
  SDL_RenderPresent(renderer);
    
  bool quitting = false;
  int how_long = 0;
  while(!quitting) {
    SDL_Event event;
    while( SDL_PollEvent(&event) ) {
      switch (event.type) {
      case SDL_QUIT:
        quitting = true;
        break;
      case SDL_KEYDOWN:
        switch (event.key.keysym.scancode) { 
        case SDL_SCANCODE_Q:
        case SDL_SCANCODE_ESCAPE:
          quitting = true;
          printf("quit on key\n");
          break;
        }
      }
    }
    SDL_Delay(3);
    if (how_long++ > 500) {
      quitting = true;
      printf("quit on count\n");
    }
  }
  SDL_DestroyWindow(window);
  SDL_Quit();
  exit(0);
}
// Local Variables:
// compile-command: "gcc wind.cpp -lSDL2 -I/usr/include/SDL2 -o wind && ./wind"
// End:



-- 
Dan Espen

Reply via email to