]> source.dussan.org Git - tigervnc.git/commitdiff
Simplify screen settings
authorPierre Ossman <ossman@cendio.se>
Fri, 10 Dec 2021 09:05:25 +0000 (10:05 +0100)
committerPierre Ossman <ossman@cendio.se>
Fri, 10 Dec 2021 09:22:41 +0000 (10:22 +0100)
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.

vncviewer/OptionsDialog.cxx
vncviewer/OptionsDialog.h
vncviewer/parameters.cxx

index 1bed858e52df7a283725b783c72cf7fd2d8702c1..d7c545da6547c0a618b4960d4e5c88c767ae7c8a 100644 (file)
@@ -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__)
index 03e51e228ea82a0c0dcd017cdf97d531681232e1..b3375fba7a61b5aebc3747aa8c96efa04a1cdd88 100644 (file)
@@ -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;
index 1217e8d49d3b327cc6ee26c867f027125fbe42ae..7eb9cb152c976ce61eef7e5932a7c59c356f30b1 100644 (file)
@@ -197,8 +197,6 @@ static VoidParameter* parameterArray[] = {
   &fullScreen,
   &fullScreenMode,
   &fullScreenSelectedMonitors,
-  &desktopSize,
-  &remoteResize,
   /* Input */
   &viewOnly,
   &emulateMiddleButton,