fix: vsync off no anava en Wayland
This commit is contained in:
@@ -297,11 +297,24 @@ void Screen::adjustWindowSize() {
|
||||
int old_x, old_y;
|
||||
SDL_GetWindowPosition(window_, &old_x, &old_y);
|
||||
|
||||
const int NEW_X = old_x + ((old_w - (window_width_ * Options::window.zoom)) / 2);
|
||||
const int NEW_Y = old_y + ((old_h - (window_height_ * Options::window.zoom)) / 2);
|
||||
const int new_w = window_width_ * Options::window.zoom;
|
||||
const int new_h = window_height_ * Options::window.zoom;
|
||||
const int NEW_X = old_x + ((old_w - new_w) / 2);
|
||||
const int NEW_Y = old_y + ((old_h - new_h) / 2);
|
||||
|
||||
SDL_SetWindowSize(window_, window_width_ * Options::window.zoom, window_height_ * Options::window.zoom);
|
||||
SDL_SetWindowPosition(window_, std::max(NEW_X, WINDOWS_DECORATIONS), std::max(NEW_Y, 0));
|
||||
SDL_SetWindowSize(window_, new_w, new_h);
|
||||
|
||||
// En Wayland, SDL_SetWindowPosition es ignorado por el compositor (limitación de
|
||||
// protocolo: el compositor controla la posición de ventanas toplevel). Solo se
|
||||
// aplica en X11/Windows/macOS donde el posicionado funciona correctamente.
|
||||
// SDL_SyncWindow garantiza que el resize esté completado antes de reposicionar
|
||||
// (evita el race condition en X11).
|
||||
SDL_SyncWindow(window_);
|
||||
const char* driver = SDL_GetCurrentVideoDriver();
|
||||
const bool is_wayland = (driver != nullptr && SDL_strcmp(driver, "wayland") == 0);
|
||||
if (!is_wayland) {
|
||||
SDL_SetWindowPosition(window_, std::max(NEW_X, WINDOWS_DECORATIONS), std::max(NEW_Y, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user