Browse Source

Merge pull request #1405 from TigerVNC/monitorArrangementSync

Update MonitorArrangement widget to match parameter settings after screen configuration change
tags/v1.12.90
Samuel Mannehed 2 years ago
parent
commit
eee6638e77
No account linked to committer's email address
2 changed files with 41 additions and 1 deletions
  1. 37
    1
      vncviewer/OptionsDialog.cxx
  2. 4
    0
      vncviewer/OptionsDialog.h

+ 37
- 1
vncviewer/OptionsDialog.cxx View File

@@ -20,8 +20,8 @@
#include <config.h>
#endif

#include <assert.h>
#include <stdlib.h>

#include <list>

#include <rdr/types.h>
@@ -40,6 +40,7 @@
#include "parameters.h"
#include "MonitorArrangement.h"

#include <FL/Fl.H>
#include <FL/Fl_Tabs.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Check_Button.H>
@@ -54,6 +55,8 @@ using namespace rfb;

std::map<OptionsCallback*, void*> OptionsDialog::callbacks;

static std::set<OptionsDialog *> instances;

OptionsDialog::OptionsDialog()
: Fl_Window(450, 460, _("VNC Viewer: Connection Options"))
{
@@ -92,11 +95,19 @@ OptionsDialog::OptionsDialog()
callback(this->handleCancel, this);

set_modal();

if (instances.size() == 0)
Fl::add_handler(fltk_event_handler);
instances.insert(this);
}


OptionsDialog::~OptionsDialog()
{
instances.erase(this);

if (instances.size() == 0)
Fl::remove_handler(fltk_event_handler);
}


@@ -1031,3 +1042,28 @@ void OptionsDialog::handleOK(Fl_Widget *widget, void *data)

dialog->storeOptions();
}

int OptionsDialog::fltk_event_handler(int event)
{
std::set<OptionsDialog *>::iterator iter;

if (event != FL_SCREEN_CONFIGURATION_CHANGED)
return 0;

// Refresh monitor arrangement widget to match the parameter settings after
// screen configuration has changed. The MonitorArrangement index doesn't work
// the same way as the FLTK screen index.
for (iter = instances.begin(); iter != instances.end(); iter++)
Fl::add_timeout(0, handleScreenConfigTimeout, (*iter));

return 0;
}

void OptionsDialog::handleScreenConfigTimeout(void *data)
{
OptionsDialog *self = (OptionsDialog *)data;

assert(self);

self->monitorArrangement->set(fullScreenSelectedMonitors.getParam());
}

+ 4
- 0
vncviewer/OptionsDialog.h View File

@@ -135,6 +135,10 @@ protected:
/* Misc. */
Fl_Check_Button *sharedCheckbox;
Fl_Check_Button *reconnectCheckbox;

private:
static int fltk_event_handler(int event);
static void handleScreenConfigTimeout(void *data);
};

#endif

Loading…
Cancel
Save