diff options
| author | Francesco Abbate <francesco.bbt@gmail.com> | 2020-12-31 11:25:12 +0100 |
|---|---|---|
| committer | Francesco Abbate <francesco.bbt@gmail.com> | 2020-12-31 11:25:12 +0100 |
| commit | 2cdf674b972bd2e3826845ade752cab36ba18c8c (patch) | |
| tree | 929b666438e1196c574d636465d3a26b20e8899e /src | |
| parent | 9e5bf485dffb067dc931323e0cf7870c347fe959 (diff) | |
| download | lite-xl-2cdf674b972bd2e3826845ade752cab36ba18c8c.tar.gz lite-xl-2cdf674b972bd2e3826845ade752cab36ba18c8c.zip | |
Keep memory of window's size and position and restore them on start
Fix also a problem with directory path on windows.
Diffstat (limited to 'src')
| -rw-r--r-- | src/api/system.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/api/system.c b/src/api/system.c index 3d6de1ea..3f43dca0 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -201,6 +201,29 @@ static int f_set_window_mode(lua_State *L) { } +static int f_get_window_size(lua_State *L) { + int x, y, w, h; + SDL_GetWindowSize(window, &w, &h); + SDL_GetWindowPosition(window, &x, &y); + lua_pushnumber(L, w); + lua_pushnumber(L, h); + lua_pushnumber(L, x); + lua_pushnumber(L, y); + return 4; +} + + +static int f_set_window_size(lua_State *L) { + double w = luaL_checknumber(L, 1); + double h = luaL_checknumber(L, 2); + double x = luaL_checknumber(L, 3); + double y = luaL_checknumber(L, 4); + SDL_SetWindowSize(window, w, h); + SDL_SetWindowPosition(window, x, y); + return 0; +} + + static int f_window_has_focus(lua_State *L) { unsigned flags = SDL_GetWindowFlags(window); lua_pushboolean(L, flags & SDL_WINDOW_INPUT_FOCUS); @@ -414,6 +437,8 @@ static const luaL_Reg lib[] = { { "set_cursor", f_set_cursor }, { "set_window_title", f_set_window_title }, { "set_window_mode", f_set_window_mode }, + { "get_window_size", f_get_window_size }, + { "set_window_size", f_set_window_size }, { "window_has_focus", f_window_has_focus }, { "show_confirm_dialog", f_show_confirm_dialog }, { "chdir", f_chdir }, |
