Record whether the width or height were set manually, and refrain from changing a manually set value when the terminal size changes.
This commit is contained in:
+2
-2
@@ -258,8 +258,8 @@ int main(int argc, char **argv)
|
||||
* Copy parameters from options into main state.
|
||||
*/
|
||||
pv_state_interval_set(state, opts->interval);
|
||||
pv_state_width_set(state, opts->width);
|
||||
pv_state_height_set(state, opts->height);
|
||||
pv_state_width_set(state, opts->width, opts->width_set_manually);
|
||||
pv_state_height_set(state, opts->height, opts->height_set_manually);
|
||||
pv_state_no_display_set(state, opts->no_display);
|
||||
pv_state_force_set(state, opts->force);
|
||||
pv_state_cursor_set(state, opts->cursor);
|
||||
|
||||
@@ -238,6 +238,9 @@ opts_t opts_parse(unsigned int argc, char **argv)
|
||||
opts->watch_fd = -1;
|
||||
opts->average_rate_window = 30;
|
||||
|
||||
opts->width_set_manually = false;
|
||||
opts->height_set_manually = false;
|
||||
|
||||
do {
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
c = getopt_long((int) argc, argv, short_options, long_options, &option_index); /* flawfinder: ignore */
|
||||
@@ -431,9 +434,11 @@ opts_t opts_parse(unsigned int argc, char **argv)
|
||||
break;
|
||||
case 'w':
|
||||
opts->width = pv_getnum_ui(optarg);
|
||||
opts->width_set_manually = opts->width == 0 ? false : true;
|
||||
break;
|
||||
case 'H':
|
||||
opts->height = pv_getnum_ui(optarg);
|
||||
opts->height_set_manually = opts->height == 0 ? false : true;
|
||||
break;
|
||||
case 'N':
|
||||
opts->name = xstrdup(optarg);
|
||||
|
||||
+8
-4
@@ -42,6 +42,8 @@ struct remote_msg {
|
||||
double interval; /* interval between updates */
|
||||
unsigned int width; /* screen width */
|
||||
unsigned int height; /* screen height */
|
||||
bool width_set_manually; /* width was set manually, not detected */
|
||||
bool height_set_manually; /* height was set manually, not detected */
|
||||
char name[256]; /* flawfinder: ignore */
|
||||
char format[256]; /* flawfinder: ignore */
|
||||
};
|
||||
@@ -151,6 +153,8 @@ int pv_remote_set(opts_t opts)
|
||||
msgbuf.interval = opts->interval;
|
||||
msgbuf.width = opts->width;
|
||||
msgbuf.height = opts->height;
|
||||
msgbuf.width_set_manually = opts->width_set_manually;
|
||||
msgbuf.height_set_manually = opts->height_set_manually;
|
||||
|
||||
if (opts->name != NULL) {
|
||||
strncpy(msgbuf.name, opts->name, sizeof(msgbuf.name) - 1); /* flawfinder: ignore */
|
||||
@@ -295,10 +299,10 @@ void pv_remote_check(pvstate_t state)
|
||||
pv_state_size_set(state, msgbuf.size);
|
||||
if (msgbuf.interval > 0)
|
||||
pv_state_interval_set(state, msgbuf.interval);
|
||||
if (msgbuf.width > 0)
|
||||
pv_state_width_set(state, msgbuf.width);
|
||||
if (msgbuf.height > 0)
|
||||
pv_state_height_set(state, msgbuf.height);
|
||||
if (msgbuf.width > 0 && msgbuf.width_set_manually)
|
||||
pv_state_width_set(state, msgbuf.width, msgbuf.width_set_manually);
|
||||
if (msgbuf.height > 0 && msgbuf.height_set_manually)
|
||||
pv_state_height_set(state, msgbuf.height, msgbuf.height_set_manually);
|
||||
if (msgbuf.format[0] != '\0')
|
||||
pv_state_format_string_set(state, msgbuf.format);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user