From 49bf115c84ed91e6408ad7fe72460439f59bdbc9 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 3 Jan 2020 16:51:24 +1100 Subject: [PATCH] [client] fix issue with windowmanager forcing the window size (i3wm) --- VERSION | 2 +- client/src/main.c | 44 ++++++++++++++++++++++++++++++++------------ client/src/main.h | 1 + 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index 585a33b3..9bb7fbb5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-48-g899dbff7e9+1 \ No newline at end of file +B1-49-g2196516e2b+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 1022a55e..9f36b3f9 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -636,10 +636,14 @@ int eventFilter(void * userdata, SDL_Event * event) break; case SDL_WINDOWEVENT_SIZE_CHANGED: - state.windowW = event->window.data1; - state.windowH = event->window.data2; - updatePositionInfo(); - realignGuest = true; + case SDL_WINDOWEVENT_RESIZED: + if (state.wminfo.subsystem != SDL_SYSWM_X11) + { + state.windowW = event->window.data1; + state.windowH = event->window.data2; + updatePositionInfo(); + realignGuest = true; + } break; // allow a window close event to close the application even if ignoreQuit is set @@ -652,6 +656,23 @@ int eventFilter(void * userdata, SDL_Event * event) case SDL_SYSWMEVENT: { + // When the window manager forces the window size after calling SDL_SetWindowSize, SDL + // ignores this update and caches the incorrect window size. + if (state.wminfo.subsystem == SDL_SYSWM_X11) + { + XEvent xe = event->syswm.msg->msg.x11.event; + if (xe.type == ConfigureNotify) + { + if (state.windowW != xe.xconfigure.width || state.windowH != xe.xconfigure.height) + { + state.windowW = xe.xconfigure.width; + state.windowH = xe.xconfigure.height; + updatePositionInfo(); + realignGuest = true; + } + } + } + if (params.useSpiceClipboard && state.lgc && state.lgc->wmevent) state.lgc->wmevent(event->syswm.msg); return 0; @@ -1194,21 +1215,20 @@ static int lg_run() register_key_binds(); // set the compositor hint to bypass for low latency - SDL_SysWMinfo wminfo; - SDL_VERSION(&wminfo.version); - if (SDL_GetWindowWMInfo(state.window, &wminfo)) + SDL_VERSION(&state.wminfo.version); + if (SDL_GetWindowWMInfo(state.window, &state.wminfo)) { - if (wminfo.subsystem == SDL_SYSWM_X11) + if (state.wminfo.subsystem == SDL_SYSWM_X11) { Atom NETWM_BYPASS_COMPOSITOR = XInternAtom( - wminfo.info.x11.display, + state.wminfo.info.x11.display, "NETWM_BYPASS_COMPOSITOR", False); unsigned long value = 1; XChangeProperty( - wminfo.info.x11.display, - wminfo.info.x11.window, + state.wminfo.info.x11.display, + state.wminfo.info.x11.window, NETWM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, @@ -1227,7 +1247,7 @@ static int lg_run() if (state.lgc) { DEBUG_INFO("Using Clipboard: %s", state.lgc->getName()); - if (!state.lgc->init(&wminfo, clipboardRelease, clipboardNotify, clipboardData)) + if (!state.lgc->init(&state.wminfo, clipboardRelease, clipboardNotify, clipboardData)) { DEBUG_WARN("Failed to initialize the clipboard interface, continuing anyway"); state.lgc = NULL; diff --git a/client/src/main.h b/client/src/main.h index ad623e69..73350132 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -54,6 +54,7 @@ struct AppState SpiceDataType cbType; struct ll * cbRequestList; + SDL_SysWMinfo wminfo; SDL_Window * window; struct IVSHMEM shm;