From 4241c87ca86e03567270fd19374b9aff6367fcc6 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 7 Sep 2022 10:57:36 +0200 Subject: [PATCH] Use standard accessors for Fl_Monitor_Arrangement The accessor functions are called value() for all standard FLTK widgets, so let's keep that theme here as well. --- vncviewer/OptionsDialog.cxx | 6 +++--- vncviewer/fltk/Fl_Monitor_Arrangement.cxx | 18 ++++++++++++------ vncviewer/fltk/Fl_Monitor_Arrangement.h | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/vncviewer/OptionsDialog.cxx b/vncviewer/OptionsDialog.cxx index 9dd00c33..22224a9b 100644 --- a/vncviewer/OptionsDialog.cxx +++ b/vncviewer/OptionsDialog.cxx @@ -334,7 +334,7 @@ void OptionsDialog::loadOptions(void) } } - monitorArrangement->set(fullScreenSelectedMonitors.getParam()); + monitorArrangement->value(fullScreenSelectedMonitors.getParam()); handleFullScreenMode(selectedMonitorsButton, this); @@ -467,7 +467,7 @@ void OptionsDialog::storeOptions(void) } } - fullScreenSelectedMonitors.setParam(monitorArrangement->get()); + fullScreenSelectedMonitors.setParam(monitorArrangement->value()); /* Misc. */ shared.setParam(sharedCheckbox->value()); @@ -1158,5 +1158,5 @@ void OptionsDialog::handleScreenConfigTimeout(void *data) assert(self); - self->monitorArrangement->set(fullScreenSelectedMonitors.getParam()); + self->monitorArrangement->value(fullScreenSelectedMonitors.getParam()); } diff --git a/vncviewer/fltk/Fl_Monitor_Arrangement.cxx b/vncviewer/fltk/Fl_Monitor_Arrangement.cxx index 062a5051..ce61b1e7 100644 --- a/vncviewer/fltk/Fl_Monitor_Arrangement.cxx +++ b/vncviewer/fltk/Fl_Monitor_Arrangement.cxx @@ -85,7 +85,7 @@ Fl_Monitor_Arrangement::~Fl_Monitor_Arrangement() Fl::remove_handler(fltk_event_handler); } -std::set Fl_Monitor_Arrangement::get() +std::set Fl_Monitor_Arrangement::value() const { std::set indices; MonitorMap::const_iterator iter; @@ -98,15 +98,21 @@ std::set Fl_Monitor_Arrangement::get() return indices; } -void Fl_Monitor_Arrangement::set(std::set indices) +int Fl_Monitor_Arrangement::value(std::set indices) { MonitorMap::const_iterator iter; + bool changed; + changed = false; for (iter = monitors.begin(); iter != monitors.end(); ++iter) { bool selected = std::find(indices.begin(), indices.end(), iter->first) != indices.end(); - iter->second->value(selected ? 1 : 0); + if (iter->second->value() != selected) + changed = true; + iter->second->value(selected); } + + return changed; } void Fl_Monitor_Arrangement::draw() @@ -178,7 +184,7 @@ void Fl_Monitor_Arrangement::refresh() // The selection state is only saved persistently when "OK" is // pressed. We need to manually restore the current selection // when the widget is refreshed. - std::set indices = get(); + std::set indices = value(); monitors.clear(); // FLTK recursively deletes all children for us. @@ -188,7 +194,7 @@ void Fl_Monitor_Arrangement::refresh() end(); // Restore the current selection state. - set(indices); + value(indices); redraw(); } @@ -199,7 +205,7 @@ bool Fl_Monitor_Arrangement::is_required(int m) return false; // If no monitors are selected, none are required. - std::set selected = get(); + std::set selected = value(); if (selected.size() <= 0) return false; diff --git a/vncviewer/fltk/Fl_Monitor_Arrangement.h b/vncviewer/fltk/Fl_Monitor_Arrangement.h index 770503bf..b8e9ba78 100644 --- a/vncviewer/fltk/Fl_Monitor_Arrangement.h +++ b/vncviewer/fltk/Fl_Monitor_Arrangement.h @@ -39,10 +39,10 @@ public: ~Fl_Monitor_Arrangement(); // Get selected indices. - std::set get(); + std::set value() const; // Set selected indices. - void set(std::set indices); + int value(std::set indices); protected: virtual void draw(); -- 2.39.5