Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -31,6 +31,11 @@ ; Hides a window border in the windowed mode. borderless.window = false +; Constrain mouse in the fullscreen mode to a window boundaries. +window.mousegrabinfullscreen = true +; The same but for the window mode. +window.mousegrabinwindowmode = false + ; Show detailed tooltips (Unit stats) showdetailedtooltips = false Index: ps/trunk/binaries/data/mods/public/gui/options/options.json =================================================================== --- ps/trunk/binaries/data/mods/public/gui/options/options.json +++ ps/trunk/binaries/data/mods/public/gui/options/options.json @@ -176,6 +176,18 @@ "config": "gui.session.dragdelta", "min": "1", "max": "200" + }, + { + "type": "boolean", + "label": "Mouse grab in fullscreen", + "tooltip": "Constrain mouse in the fullscreen mode to the window boundaries. It's used to avoid mouse going out of a display in case of multiple displays.", + "config": "window.mousegrabinfullscreen" + }, + { + "type": "boolean", + "label": "Mouse grab in window mode", + "tooltip": "Constrain mouse in the window mode to the window boundaries.", + "config": "window.mousegrabinwindowmode" } ] }, Index: ps/trunk/source/ps/VideoMode.cpp =================================================================== --- ps/trunk/source/ps/VideoMode.cpp +++ ps/trunk/source/ps/VideoMode.cpp @@ -515,7 +515,14 @@ SDL_GetWindowSize(m_Window, &m_CurrentW, &m_CurrentH); m_CurrentBPP = bpp; - if (fullscreen) + // #545: we need to constrain the window in fullscreen mode to avoid mouse + // "falling out" of the window in case of multiple displays. + bool mouseGrabInFullscreen = true; + CFG_GET_VAL("window.mousegrabinfullscreen", mouseGrabInFullscreen); + bool mouseGrabInWindowMode = false; + CFG_GET_VAL("window.mousegrabinwindowmode", mouseGrabInWindowMode); + + if (fullscreen ? mouseGrabInFullscreen : mouseGrabInWindowMode) SDL_SetWindowGrab(m_Window, SDL_TRUE); else SDL_SetWindowGrab(m_Window, SDL_FALSE);