From 3c80559db2e7bb7ce9c8df6fb352be3fdef81779 Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Mon, 30 Aug 2021 15:19:51 +0800 Subject: [PATCH] add system.capture_mouse() This allows lite-xl to temporarily read mouse events out of its window. This will be used to implement tab splitting. --- src/api/system.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/api/system.c b/src/api/system.c index 2f1bf763..616c34fd 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -274,6 +274,13 @@ static int f_set_cursor(lua_State *L) { } +static int f_capture_mouse(lua_State *L) { + int enable = lua_toboolean(L, 1); + SDL_CaptureMouse(enable); + return 0; +} + + static int f_set_window_title(lua_State *L) { const char *title = luaL_checkstring(L, 1); SDL_SetWindowTitle(window, title); @@ -642,6 +649,7 @@ static const luaL_Reg lib[] = { { "poll_event", f_poll_event }, { "wait_event", f_wait_event }, { "set_cursor", f_set_cursor }, + { "capture_mouse", f_capture_mouse }, { "set_window_title", f_set_window_title }, { "set_window_mode", f_set_window_mode }, { "get_window_mode", f_get_window_mode },