ref: 817743a2d1468248a025c4abb9fd5ff43d01e277
parent: a4c94ff0a55c99b2bf3aab13bcea037b76ab43f2
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Nov 8 20:24:29 EST 2023
vid (sdl): fix weird glitches and crashes Hello, Wayland. Seems like doing things in the previous order and not "grabbing" the mouse (setting it to relative mode) resulted in somehow view getting stuck randomly (moving the camera in one direction would pull it back in a fraction of a second) and crashes (in random unrelated places, and it did not crash with valgrind). Just pressing the right mouse button once, before *moving* the mouse at all, would result in glitches. Solve this by changing the order, keeping sway from resizing the window on start, and grabbing the mouse right away.
--- a/unix/vid.c
+++ b/unix/vid.c
@@ -112,9 +112,9 @@
vid.colormap = host_colormap;
vid.fullbright = 256 - LittleLong(*((int *)vid.colormap + 2048));
- if(SDL_Init(SDL_INIT_VIDEO) < 0)
+ if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0)
fatal("SDL_Init: %s", SDL_GetError());
- win = SDL_CreateWindow("quake", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_RESIZABLE);
+ win = SDL_CreateWindow("quake", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
if(win == nil)
fatal("SDL_CreateWindow: %s", SDL_GetError());
if((rend = SDL_CreateRenderer(win, -1, 0)) == NULL)
@@ -122,9 +122,10 @@
SDL_SetRenderDrawColor(rend, 0, 0, 0, 255);
SDL_RenderClear(rend);
SDL_RenderPresent(rend);
- SDL_SetWindowPosition(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
- SDL_ShowWindow(win);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
resetfb();
+ SDL_SetWindowResizable(win, SDL_TRUE);
+ SDL_SetWindowMinimumSize(win, 320, 240);
+ IN_Grabm(1);
}