Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/Backends/SDLBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,14 +742,20 @@ namespace gamescope
{
break;
}

// Temporary grab keyboard while Super is pressed
if (!g_bGrabbed && !g_bShortcutGrabbed && key == KEY_LEFTMETA) {
g_bShortcutGrabbed = true;
SDL_SetWindowKeyboardGrab(m_Connector.GetSDLWindow(), g_bShortcutGrabbed);
}
}
}
[[fallthrough]];
case SDL_KEYUP:
{
uint32_t key = SDLScancodeToLinuxKey( event.key.keysym.scancode );

if ( event.type == SDL_KEYUP && ( event.key.keysym.mod & KMOD_LGUI ) )
if ( event.type == SDL_KEYUP && ( (event.key.keysym.mod & KMOD_LGUI) != 0 || g_bShortcutGrabbed ) )
{
bool handled = true;
switch ( key )
Expand Down Expand Up @@ -781,14 +787,25 @@ namespace gamescope
case KEY_S:
gamescope::CScreenshotManager::Get().TakeScreenshot( true );
break;
case KEY_G:
case KEY_G: {
// Reset shortcut grab and allow normal grab w/ title change
if (g_bShortcutGrabbed) {
g_bShortcutGrabbed = false;
}
g_bGrabbed = !g_bGrabbed;
SDL_SetWindowKeyboardGrab( m_Connector.GetSDLWindow(), g_bGrabbed ? SDL_TRUE : SDL_FALSE );

SDL_Event event;
event.type = GetUserEventIndex( GAMESCOPE_SDL_EVENT_TITLE );
SDL_PushEvent( &event );
break;
} break;
case KEY_LEFTMETA: {
// Release shortcut grab
if (g_bShortcutGrabbed) {
g_bShortcutGrabbed = false;
SDL_SetWindowKeyboardGrab(m_Connector.GetSDLWindow(), g_bShortcutGrabbed);
}
} break;
default:
handled = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ bool g_bFullscreen = false;
bool g_bForceRelativeMouse = false;

bool g_bGrabbed = false;
bool g_bShortcutGrabbed = false;

float g_mouseSensitivity = 1.0;

Expand Down
1 change: 1 addition & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern bool g_bForceInternal;
extern bool g_bFullscreen;

extern bool g_bGrabbed;
extern bool g_bShortcutGrabbed;

extern float g_mouseSensitivity;
extern const char *g_sOutputName;
Expand Down