From c10fc7a058c05edcedeb23bdcc9faae635f1780d Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 7 Sep 2021 22:08:22 +0300 Subject: App: Added options -w, -h for window sizing --- res/arg-help.txt | 2 ++ src/app.c | 12 ++++++++++++ src/app.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/res/arg-help.txt b/res/arg-help.txt index 9f6548f2..bf6e7e97 100644 --- a/res/arg-help.txt +++ b/res/arg-help.txt @@ -6,6 +6,7 @@ separate tabs. General options: -E, --echo Print all internal app events to stdout. + -h, --height N Set initial window height to N pixels. --help Print these instructions. --sw Disable hardware accelerated rendering. -u, --url-or-search URL | text @@ -13,6 +14,7 @@ General options: This only works if the search query URL has been configured. -V, --version Print the application version. + -w, --width N Set initial window width to N pixels. Options that control a running instance of Lagrange: diff --git a/src/app.c b/src/app.c index 9ff8ebc8..fa8cc105 100644 --- a/src/app.c +++ b/src/app.c @@ -668,6 +668,8 @@ static void init_App_(iApp *d, int argc, char **argv) { defineValues_CommandLine(&d->args, "help", 0); defineValues_CommandLine(&d->args, listTabUrls_CommandLineOption, 0); defineValues_CommandLine(&d->args, openUrlOrSearch_CommandLineOption, 1); + defineValues_CommandLine(&d->args, windowWidth_CommandLineOption, 1); + defineValues_CommandLine(&d->args, windowHeight_CommandLineOption, 1); defineValuesN_CommandLine(&d->args, "new-tab", 0, 1); defineValues_CommandLine(&d->args, "tab-url", 0); defineValues_CommandLine(&d->args, "sw", 0); @@ -787,6 +789,16 @@ static void init_App_(iApp *d, int argc, char **argv) { setThemePalette_Color(d->prefs.theme); /* default UI colors */ loadPrefs_App_(d); load_Keys(dataDir_App_()); + /* See if the user wants to override the window size. */ { + iCommandLineArg *arg = iClob(checkArgument_CommandLine(&d->args, windowWidth_CommandLineOption)); + if (arg) { + d->initialWindowRect.size.x = toInt_String(value_CommandLineArg(arg, 0)); + } + arg = iClob(checkArgument_CommandLine(&d->args, windowHeight_CommandLineOption)); + if (arg) { + d->initialWindowRect.size.y = toInt_String(value_CommandLineArg(arg, 0)); + } + } d->window = new_Window(d->initialWindowRect); load_Visited(d->visited, dataDir_App_()); load_Bookmarks(d->bookmarks, dataDir_App_()); diff --git a/src/app.h b/src/app.h index 55bec5a6..08589000 100644 --- a/src/app.h +++ b/src/app.h @@ -44,6 +44,8 @@ iDeclareType(Window) /* Command line options strings. */ #define listTabUrls_CommandLineOption "list-tab-urls;L" #define openUrlOrSearch_CommandLineOption "url-or-search;u" +#define windowWidth_CommandLineOption "width;w" +#define windowHeight_CommandLineOption "height;h" enum iAppDeviceType { desktop_AppDeviceType, -- cgit v1.2.3