More than ten years ago I patched SDL 1.2 to prevent applications and games from grabbing all input by swapping the SDL_FULLSCREEN flag with SDL_NOFRAME to give a borderless (fullscreen) window that is still managed by the window-manager, to give access to task switching, volume control etc. (details can be found here). There is actually a more elegant and less intrusive solution by preloading a custom version of SDL_SetVideoMode(), which changes the flags before calling the real function.

Simply save the following code as "sdl12_no_fullscreen.c" and compile it with

gcc -x c -fpic -shared -ldl -o sdl12_no_fullscreen.c

Remember to add the flag "-m32" if your binary is 32 bit. You can then preload it into applications by using

export LD_PRELOAD="$PWD/"

    gcc -x c -fpic -shared -ldl -o sdl12_no_fullscreen.c

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

#define Uint32 unsigned int
#define SDL_FULLSCREEN  0x80000000
#define SDL_RESIZABLE   0x00000010
#define SDL_NOFRAME     0x00000020

static void* (*_SDL_SetVideoMode) (int width, int height, int bpp, Uint32 flags);
void* SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) {
    if (_SDL_SetVideoMode == NULL) {
        _SDL_SetVideoMode = dlsym(RTLD_NEXT, "SDL_SetVideoMode");

    printf("\033[31mSDL_SetVideoMode(%i,%i,%i,%i)\033[0m\n", width, height, bpp, flags);

    flags &= ~SDL_FULLSCREEN;
    flags |= SDL_RESIZABLE;
    flags |= SDL_NOFRAME;
    return _SDL_SetVideoMode(width, height, bpp, flags);

No comments yet.

Leave a Comment

I respect your privacy
I don't run any trackers on this site.

Please use the share-buttons or leave comments so I know what might be worth writing about.

Thank you.