diff --git a/client/src/app.c b/client/src/app.c index 156dab00..38eaa326 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -95,6 +95,9 @@ void app_updateCursorPos(double x, double y) void app_handleFocusEvent(bool focused) { + if (g_state.focused == focused) + return; + g_state.focused = focused; // release any imgui buttons/keys if we lost focus @@ -126,6 +129,9 @@ void app_handleFocusEvent(bool focused) if (g_params.minimizeOnFocusLoss) g_state.ds->minimize(); } + else + if (g_params.captureOnFocus) + core_setGrab(true); g_cursor.realign = true; g_state.ds->realignPointer(); diff --git a/client/src/config.c b/client/src/config.c index bfc69c5a..feb2e6f0 100644 --- a/client/src/config.c +++ b/client/src/config.c @@ -297,6 +297,13 @@ static struct Option options[] = }, // input options + { + .module = "input", + .name = "captureOnFocus", + .description = "Enable capture mode when the window becomes focused", + .type = OPTION_TYPE_BOOL, + .value.x_bool = false + }, { .module = "input", .name = "grabKeyboard", @@ -664,6 +671,7 @@ bool config_load(int argc, char * argv[]) case 270: g_params.winRotate = LG_ROTATE_270; break; } + g_params.captureOnFocus = option_get_bool("input", "captureOnFocus" ); g_params.grabKeyboard = option_get_bool("input", "grabKeyboard" ); g_params.grabKeyboardOnFocus = option_get_bool("input", "grabKeyboardOnFocus" ); g_params.releaseKeysOnFocusLoss = option_get_bool("input", "releaseKeysOnFocusLoss"); diff --git a/client/src/main.h b/client/src/main.h index 828a635d..9755f94b 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -186,6 +186,7 @@ struct AppParams bool ignoreQuit; bool noScreensaver; bool autoScreensaver; + bool captureOnFocus; bool grabKeyboard; bool grabKeyboardOnFocus; int escapeKey;