diff options
author | Pierre Ossman <ossman@cendio.se> | 2021-12-10 10:05:25 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2021-12-10 10:22:41 +0100 |
commit | e8105c4f85123b1a3bf76de27ebf8bdee287a7c1 (patch) | |
tree | 5b4a6f297b81d7f9d0fc054cac39165b35ccdf9c | |
parent | 6c121afcaad1ebd7f46aad62fc431991eec0e69c (diff) | |
download | tigervnc-e8105c4f85123b1a3bf76de27ebf8bdee287a7c1.tar.gz tigervnc-e8105c4f85123b1a3bf76de27ebf8bdee287a7c1.zip |
Simplify screen settings
Try to focus on the commonly used settings here in order to keep things
understandable. The uncommon settings will need to be specified as
command line arguments instead.
-rw-r--r-- | vncviewer/OptionsDialog.cxx | 201 | ||||
-rw-r--r-- | vncviewer/OptionsDialog.h | 11 | ||||
-rw-r--r-- | vncviewer/parameters.cxx | 2 |
3 files changed, 71 insertions, 143 deletions
diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx index 1bed858e..d7c545da 100644 --- a/vncviewer/OptionsDialog.cxx +++ b/vncviewer/OptionsDialog.cxx @@ -1,4 +1,4 @@ -/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB +/* Copyright 2011-2021 Pierre Ossman <ossman@cendio.se> for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -282,34 +282,20 @@ void OptionsDialog::loadOptions(void) menuKeyChoice->value(i + 1); /* Screen */ - int width, height; - - if (sscanf((const char*)desktopSize, "%dx%d", &width, &height) != 2) { - desktopSizeCheckbox->value(false); - desktopWidthInput->value("1024"); - desktopHeightInput->value("768"); + if (!fullScreen) { + windowedButton->setonly(); } else { - char buf[32]; - desktopSizeCheckbox->value(true); - snprintf(buf, sizeof(buf), "%d", width); - desktopWidthInput->value(buf); - snprintf(buf, sizeof(buf), "%d", height); - desktopHeightInput->value(buf); - } - remoteResizeCheckbox->value(remoteResize); - fullScreenCheckbox->value(fullScreen); - - if (!strcasecmp(fullScreenMode, "all")) { - allMonitorsButton->setonly(); - } else if (!strcasecmp(fullScreenMode, "selected")) { - selectedMonitorsButton->setonly(); - } else { - currentMonitorButton->setonly(); + if (!strcasecmp(fullScreenMode, "all")) { + allMonitorsButton->setonly(); + } else if (!strcasecmp(fullScreenMode, "selected")) { + selectedMonitorsButton->setonly(); + } else { + currentMonitorButton->setonly(); + } } monitorArrangement->set(fullScreenSelectedMonitors.getParam()); - handleDesktopSize(desktopSizeCheckbox, this); handleFullScreenMode(selectedMonitorsButton, this); /* Misc. */ @@ -406,26 +392,18 @@ void OptionsDialog::storeOptions(void) } /* Screen */ - int width, height; - - if (desktopSizeCheckbox->value() && - (sscanf(desktopWidthInput->value(), "%d", &width) == 1) && - (sscanf(desktopHeightInput->value(), "%d", &height) == 1)) { - char buf[64]; - snprintf(buf, sizeof(buf), "%dx%d", width, height); - desktopSize.setParam(buf); - } else { - desktopSize.setParam(""); - } - remoteResize.setParam(remoteResizeCheckbox->value()); - fullScreen.setParam(fullScreenCheckbox->value()); - - if (allMonitorsButton->value()) { - fullScreenMode.setParam("All"); - } else if (selectedMonitorsButton->value()) { - fullScreenMode.setParam("Selected"); + if (windowedButton->value()) { + fullScreen.setParam(false); } else { - fullScreenMode.setParam("Current"); + fullScreen.setParam(true); + + if (allMonitorsButton->value()) { + fullScreenMode.setParam("All"); + } else if (selectedMonitorsButton->value()) { + fullScreenMode.setParam("Selected"); + } else { + fullScreenMode.setParam("Current"); + } } fullScreenSelectedMonitors.setParam(monitorArrangement->get()); @@ -776,88 +754,60 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th) void OptionsDialog::createScreenPage(int tx, int ty, int tw, int th) { - int x; - int width, height; - Fl_Group *group = new Fl_Group(tx, ty, tw, th, _("Screen")); tx += OUTER_MARGIN; ty += OUTER_MARGIN; - desktopSizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, - CHECK_MIN_WIDTH, - CHECK_HEIGHT, - _("Resize remote session on connect"))); - desktopSizeCheckbox->callback(handleDesktopSize, this); - ty += CHECK_HEIGHT + TIGHT_MARGIN; - - desktopWidthInput = new Fl_Int_Input(tx + INDENT, ty, 50, INPUT_HEIGHT); - x = desktopWidthInput->x() + desktopWidthInput->w() + \ - gui_str_len("x") + 3 * 2; - desktopHeightInput = new Fl_Int_Input(x, ty, 50, INPUT_HEIGHT, "x"); - ty += INPUT_HEIGHT + TIGHT_MARGIN; - - remoteResizeCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, - CHECK_MIN_WIDTH, - CHECK_HEIGHT, - _("Resize remote session to the local window"))); - ty += CHECK_HEIGHT + TIGHT_MARGIN; - - fullScreenCheckbox = new Fl_Check_Button(LBLRIGHT(tx, ty, - CHECK_MIN_WIDTH, - CHECK_HEIGHT, - _("Enable full screen"))); - ty += CHECK_HEIGHT + INNER_MARGIN; - - width = tw - OUTER_MARGIN * 2; - height = th - ty + OUTER_MARGIN * 3; - Fl_Group *fullScreenModeGroup = new Fl_Group(tx, - ty, - width, - height); - - { - tx += INDENT; - - currentMonitorButton = new Fl_Round_Button(LBLRIGHT(tx, ty, - RADIO_MIN_WIDTH, - RADIO_HEIGHT, - _("Use current monitor"))); - currentMonitorButton->type(FL_RADIO_BUTTON); - currentMonitorButton->callback(handleFullScreenMode, this); - ty += RADIO_HEIGHT + TIGHT_MARGIN; - - allMonitorsButton = new Fl_Round_Button(LBLRIGHT(tx, ty, - RADIO_MIN_WIDTH, - RADIO_HEIGHT, - _("Use all monitors"))); - allMonitorsButton->type(FL_RADIO_BUTTON); - allMonitorsButton->callback(handleFullScreenMode, this); - ty += RADIO_HEIGHT + TIGHT_MARGIN; - - selectedMonitorsButton = new Fl_Round_Button(LBLRIGHT(tx, ty, - RADIO_MIN_WIDTH, - RADIO_HEIGHT, - _("Use selected monitor(s)"))); - selectedMonitorsButton->type(FL_RADIO_BUTTON); - selectedMonitorsButton->callback(handleFullScreenMode, this); - ty += RADIO_HEIGHT + TIGHT_MARGIN; - - int full_width = tw - OUTER_MARGIN * 2; - int margin_width = full_width - INDENT - INNER_MARGIN*2; - int full_height = th; - int margin_height = full_height - ty + INNER_MARGIN*3; - - monitorArrangement = new MonitorArrangement( - tx + INDENT, - ty, - margin_width, - margin_height); - - ty += CHECK_HEIGHT + margin_height; - } + windowedButton = new Fl_Round_Button(LBLRIGHT(tx, ty, + RADIO_MIN_WIDTH, + RADIO_HEIGHT, + _("Windowed"))); + windowedButton->type(FL_RADIO_BUTTON); + windowedButton->callback(handleFullScreenMode, this); + ty += RADIO_HEIGHT + TIGHT_MARGIN; + + currentMonitorButton = new Fl_Round_Button(LBLRIGHT(tx, ty, + RADIO_MIN_WIDTH, + RADIO_HEIGHT, + _("Full screen on current monitor"))); + currentMonitorButton->type(FL_RADIO_BUTTON); + currentMonitorButton->callback(handleFullScreenMode, this); + ty += RADIO_HEIGHT + TIGHT_MARGIN; + + allMonitorsButton = new Fl_Round_Button(LBLRIGHT(tx, ty, + RADIO_MIN_WIDTH, + RADIO_HEIGHT, + _("Full screen on all monitors"))); + allMonitorsButton->type(FL_RADIO_BUTTON); + allMonitorsButton->callback(handleFullScreenMode, this); + ty += RADIO_HEIGHT + TIGHT_MARGIN; + + selectedMonitorsButton = new Fl_Round_Button(LBLRIGHT(tx, ty, + RADIO_MIN_WIDTH, + RADIO_HEIGHT, + _("Full screen on selected monitor(s)"))); + selectedMonitorsButton->type(FL_RADIO_BUTTON); + selectedMonitorsButton->callback(handleFullScreenMode, this); + ty += RADIO_HEIGHT + TIGHT_MARGIN; + + /* + * Right now these occupy all remaining space, but that can probably + * be reduced if we add more stuff to this page. + */ + int full_width = tw - OUTER_MARGIN * 2; + int margin_width = full_width - INDENT; + int full_height = th; + int margin_height = full_height - ty + INNER_MARGIN; + + monitorArrangement = new MonitorArrangement( + tx + INDENT, + ty, + margin_width, + margin_height); + + ty += CHECK_HEIGHT + margin_height; - fullScreenModeGroup->end(); group->end(); } @@ -945,19 +895,6 @@ void OptionsDialog::handleX509(Fl_Widget *widget, void *data) } -void OptionsDialog::handleDesktopSize(Fl_Widget *widget, void *data) -{ - OptionsDialog *dialog = (OptionsDialog*)data; - - if (dialog->desktopSizeCheckbox->value()) { - dialog->desktopWidthInput->activate(); - dialog->desktopHeightInput->activate(); - } else { - dialog->desktopWidthInput->deactivate(); - dialog->desktopHeightInput->deactivate(); - } -} - void OptionsDialog::handleClipboard(Fl_Widget *widget, void *data) { #if !defined(WIN32) && !defined(__APPLE__) diff --git a/vncviewer/OptionsDialog.h b/vncviewer/OptionsDialog.h index 03e51e22..b3375fba 100644 --- a/vncviewer/OptionsDialog.h +++ b/vncviewer/OptionsDialog.h @@ -1,4 +1,4 @@ -/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB +/* Copyright 2011-2021 Pierre Ossman <ossman@cendio.se> for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,8 +63,6 @@ protected: static void handleX509(Fl_Widget *widget, void *data); - static void handleDesktopSize(Fl_Widget *widget, void *data); - static void handleClipboard(Fl_Widget *widget, void *data); static void handleFullScreenMode(Fl_Widget *widget, void *data); @@ -123,12 +121,7 @@ protected: Fl_Choice *menuKeyChoice; /* Screen */ - Fl_Check_Button *desktopSizeCheckbox; - Fl_Int_Input *desktopWidthInput; - Fl_Int_Input *desktopHeightInput; - Fl_Check_Button *remoteResizeCheckbox; - Fl_Check_Button *fullScreenCheckbox; - + Fl_Round_Button *windowedButton; Fl_Round_Button *currentMonitorButton; Fl_Round_Button *allMonitorsButton; Fl_Round_Button *selectedMonitorsButton; diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 1217e8d4..7eb9cb15 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -197,8 +197,6 @@ static VoidParameter* parameterArray[] = { &fullScreen, &fullScreenMode, &fullScreenSelectedMonitors, - &desktopSize, - &remoteResize, /* Input */ &viewOnly, &emulateMiddleButton, |