From 48aefa32f558a343aec0d232ef2275c63133e88c Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Fri, 10 Dec 2021 00:01:55 +0100 Subject: [PATCH] get scale --- TODO | 5 +++-- src/main.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 2f22006..f3d2a99 100644 --- a/TODO +++ b/TODO @@ -52,11 +52,12 @@ [x] selected + tab == indent up [x] selected +shift+tab == indent down [x] change alt+ to ctrl+ -[ ] add multi cursor system +[ ] doc: add multi cursor system [ ] add binding to open up a cheatsheet of keybinding, with a search feature [x] implement visual "ruler" at column 80 -[ ] show hidden files config and binding +[ ] treeview: show hidden files config and binding +[ ] treeview: add a config to hide files bsed on patterns (*.\.o etc) [ ] syntax: highlight FIXME TODO BUG FIX and IMPROVEMENT keywords [ ] do not open doc in new tab if current tab has an unchanged document [ ] doc: add auto close brackets and quotes diff --git a/src/main.c b/src/main.c index 88b879e..aecb863 100644 --- a/src/main.c +++ b/src/main.c @@ -15,13 +15,15 @@ SDL_Window *window; -static double get_scale(void) +static double get_scale(SDL_DisplayMode *dm) { float dpi, s; SDL_GetDisplayDPI(0, NULL, &dpi, NULL); + // TODO: get the current window's screen not the primary + printf("w: %d, h: %d\n", dm->w, dm->h); s = (1.0/dpi)*25.4; // size of a point // as per standard 14 point should be 3mm - return floor((FONT_14PT_SIZE_MM/(14*s))*10)/10.0; + return fmax(1.0, floor((FONT_14PT_SIZE_MM/(14*s))*10)/10.0); } static void get_exe_filename(char *buf, int sz) @@ -70,12 +72,15 @@ int main(int argc, char **argv) #endif SDL_DisplayMode dm; - SDL_GetCurrentDisplayMode(0, &dm); + SDL_GetDesktopDisplayMode(0, &dm); window = SDL_CreateWindow( "", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w * 0.8, dm.h * 0.8, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN); + int wd = SDL_GetWindowDisplayIndex(window); + printf("%d \n", wd); + SDL_GetDesktopDisplayMode(wd, &dm); init_window_icon(); ren_init(window); @@ -97,7 +102,9 @@ int main(int argc, char **argv) lua_pushstring(L, SDL_GetPlatform()); lua_setglobal(L, "PLATFORM"); - lua_pushnumber(L, get_scale()); + double scale = get_scale(&dm); + printf("%f\n", scale); + lua_pushnumber(L, scale); lua_setglobal(L, "SCALE"); char exename[2048];