Fix some indentation issues and make sure everything* uses CamelCase.
* MonitorArrangement is left as snake_case in order to pretend it is an
independent FLTK widget class.
if (fullscreen_active()) {
assert(Fl::screen_count() >= 1);
- rfb::Rect window_rect, screen_rect;
- window_rect.setXYWH(x(), y(), w(), h());
+ rfb::Rect windowRect, screenRect;
+ windowRect.setXYWH(x(), y(), w(), h());
- bool found_enclosed_screen = false;
+ bool foundEnclosedScreen = false;
for (int i = 0; i < Fl::screen_count(); i++) {
Fl::screen_xywh(sx, sy, sw, sh, i);
// The screen with the smallest index that are enclosed by
// the viewport will be used for showing the overlay.
- screen_rect.setXYWH(sx, sy, sw, sh);
- if (screen_rect.enclosed_by(window_rect)) {
- found_enclosed_screen = true;
+ screenRect.setXYWH(sx, sy, sw, sh);
+ if (screenRect.enclosed_by(windowRect)) {
+ foundEnclosedScreen = true;
break;
}
}
// If no monitor inside the viewport was found,
// use the one primary instead.
- if (!found_enclosed_screen)
+ if (!foundEnclosedScreen)
Fl::screen_xywh(sx, sy, sw, sh, 0);
// Adjust the coordinates so they are relative to the viewport.
void DesktopWindow::fullscreen_on()
{
- bool all_monitors = !strcasecmp(fullScreenMode, "all");
- bool selected_monitors = !strcasecmp(fullScreenMode, "selected");
+ bool allMonitors = !strcasecmp(fullScreenMode, "all");
+ bool selectedMonitors = !strcasecmp(fullScreenMode, "selected");
- if (not selected_monitors and not all_monitors) {
+ if (not selectedMonitors and not allMonitors) {
int n = Fl::screen_num(x(), y(), w(), h());
fullscreen_screens(n, n, n, n);
} else {
std::set<int> monitors;
- if (selected_monitors and not all_monitors) {
+ if (selectedMonitors and not allMonitors) {
std::set<int> selected = fullScreenSelectedMonitors.getParam();
monitors.insert(selected.begin(), selected.end());
} else {
: Fl_Group(x, y, w, h),
SELECTION_COLOR(fl_lighter(FL_BLUE)),
AVAILABLE_COLOR(fl_lighter(fl_lighter(fl_lighter(FL_BACKGROUND_COLOR)))),
- m_monitors()
+ monitors()
{
// Used for required monitors.
Fl::set_boxtype(FL_CHECKERED_BOX, checkered_pattern_draw, 0, 0, 0, 0);
{
std::set<int> indices;
- for (int i = 0; i < (int) m_monitors.size(); i++) {
- if (m_monitors[i]->value() == 1)
+ for (int i = 0; i < (int) monitors.size(); i++) {
+ if (monitors[i]->value() == 1)
indices.insert(i);
}
void MonitorArrangement::set(std::set<int> indices)
{
- for (int i = 0; i < (int) m_monitors.size(); i++) {
+ for (int i = 0; i < (int) monitors.size(); i++) {
bool selected = std::find(indices.begin(), indices.end(), i) != indices.end();
- m_monitors[i]->value(selected ? 1 : 0);
+ monitors[i]->value(selected ? 1 : 0);
}
}
void MonitorArrangement::draw()
{
- for (int i = 0; i < (int) m_monitors.size(); i++) {
- Fl_Button * monitor = m_monitors[i];
+ for (int i = 0; i < (int) monitors.size(); i++) {
+ Fl_Button * monitor = monitors[i];
if (is_required(i)) {
monitor->box(FL_CHECKERED_BOX);
monitor->callback(monitor_pressed, this);
monitor->type(FL_TOGGLE_BUTTON);
monitor->when(FL_WHEN_CHANGED);
- m_monitors.push_back(monitor);
+ monitors.push_back(monitor);
}
- for (int i = 0; i < (int) m_monitors.size(); i++)
- m_monitors[i]->copy_tooltip(description(i).c_str());
+ for (int i = 0; i < (int) monitors.size(); i++)
+ monitors[i]->copy_tooltip(description(i).c_str());
}
void MonitorArrangement::refresh()
// pressed. We need to manually restore the current selection
// when the widget is refreshed.
std::set<int> indices = get();
- m_monitors.clear();
+ monitors.clear();
// FLTK recursively deletes all children for us.
clear();
bool MonitorArrangement::is_required(int m)
{
// A selected monitor is never required.
- if (m_monitors[m]->value() == 1)
+ if (monitors[m]->value() == 1)
return false;
// If no monitors are selected, none are required.
std::string MonitorArrangement::description(int m)
{
- assert(m < (int) m_monitors.size());
+ assert(m < (int) monitors.size());
const size_t name_len = 1024;
char name[name_len] = {};
int bytes_written = get_monitor_name(m, name, name_len);
private:
const Fl_Color SELECTION_COLOR;
const Fl_Color AVAILABLE_COLOR;
- std::vector<Fl_Button *> m_monitors;
+ std::vector<Fl_Button *> monitors;
// Layout the monitor arrangement.
void layout();
{
bool valid = false;
std::set<int> indices;
- std::set<int> config_indices;
- std::vector<MonitorIndicesParameter::Monitor> monitors = this->monitors();
+ std::set<int> configIndices;
+ std::vector<MonitorIndicesParameter::Monitor> monitors = fetchMonitors();
if (monitors.size() <= 0) {
vlog.error(_("Failed to get monitors."));
return indices;
}
- valid = parse_indices(value, &config_indices);
+ valid = parseIndices(value, &configIndices);
if (!valid) {
return indices;
}
- if (config_indices.size() <= 0) {
+ if (configIndices.size() <= 0) {
return indices;
}
// Go through the monitors and see what indices are present in the config.
for (int i = 0; i < ((int) monitors.size()); i++) {
- if (std::find(config_indices.begin(), config_indices.end(), i) != config_indices.end())
- indices.insert(monitors[i].fltk_index);
+ if (std::find(configIndices.begin(), configIndices.end(), i) != configIndices.end())
+ indices.insert(monitors[i].fltkIndex);
}
return indices;
if (strlen(value) < 0)
return false;
- if (!parse_indices(value, &indices)) {
+ if (!parseIndices(value, &indices)) {
vlog.error(_("Invalid FullScreenSelectedMonitors configuration."));
return false;
}
{
static const int BUF_MAX_LEN = 1024;
char buf[BUF_MAX_LEN] = {0};
- std::set<int> config_indices;
- std::vector<MonitorIndicesParameter::Monitor> monitors = this->monitors();
+ std::set<int> configIndices;
+ std::vector<MonitorIndicesParameter::Monitor> monitors = fetchMonitors();
if (monitors.size() <= 0) {
vlog.error(_("Failed to get monitors."));
}
for (int i = 0; i < ((int) monitors.size()); i++) {
- if (std::find(indices.begin(), indices.end(), monitors[i].fltk_index) != indices.end())
- config_indices.insert(i);
+ if (std::find(indices.begin(), indices.end(), monitors[i].fltkIndex) != indices.end())
+ configIndices.insert(i);
}
- int bytes_written = 0;
+ int bytesWritten = 0;
char const * separator = "";
- for (std::set<int>::iterator index = config_indices.begin();
- index != config_indices.end();
+ for (std::set<int>::iterator index = configIndices.begin();
+ index != configIndices.end();
index++)
{
- bytes_written += snprintf(
- buf+bytes_written,
- BUF_MAX_LEN-bytes_written,
+ bytesWritten += snprintf(
+ buf+bytesWritten,
+ BUF_MAX_LEN-bytesWritten,
"%s%u",
separator,
(*index)+1
return setParam(buf);
}
-static bool parse_number(std::string number, std::set<int> *indices)
+static bool parseNumber(std::string number, std::set<int> *indices)
{
if (number.size() <= 0)
return false;
return true;
}
-bool MonitorIndicesParameter::parse_indices(const char* value, std::set<int> *indices)
+bool MonitorIndicesParameter::parseIndices(const char* value, std::set<int> *indices)
{
char d;
std::string current;
else if (d >= '0' && d <= '9')
current.push_back(d);
else if (d == ',') {
- if (!parse_number(current, indices)) {
+ if (!parseNumber(current, indices)) {
vlog.error(_("Invalid monitor index '%s' in FullScreenSelectedMonitors"), current.c_str());
return false;
}
return true;
// Parsing anything we have left.
- if (!parse_number(current, indices))
+ if (!parseNumber(current, indices))
return false;
return true;
}
-std::vector<MonitorIndicesParameter::Monitor> MonitorIndicesParameter::monitors()
+std::vector<MonitorIndicesParameter::Monitor> MonitorIndicesParameter::fetchMonitors()
{
std::vector<Monitor> monitors;
i
);
- monitor.fltk_index = i;
+ monitor.fltkIndex = i;
monitors.push_back(monitor);
}
// Sort the monitors according to the specification in the vncviewer manual.
- qsort(&monitors[0], monitors.size(), sizeof(*(&monitors[0])), sort_cb);
+ qsort(&monitors[0], monitors.size(), sizeof(*(&monitors[0])), compare);
return monitors;
}
-int MonitorIndicesParameter::sort_cb(const void *a, const void *b)
+int MonitorIndicesParameter::compare(const void *a, const void *b)
{
MonitorIndicesParameter::Monitor * monitor1 = (MonitorIndicesParameter::Monitor *) a;
MonitorIndicesParameter::Monitor * monitor2 = (MonitorIndicesParameter::Monitor *) b;
private:
typedef struct {
int x, y, w, h;
- int fltk_index;
+ int fltkIndex;
} Monitor;
- bool parse_indices(const char* value, std::set<int> *indices);
- std::vector<MonitorIndicesParameter::Monitor> monitors();
- static int sort_cb(const void*, const void*);
+ bool parseIndices(const char* value, std::set<int> *indices);
+ std::vector<MonitorIndicesParameter::Monitor> fetchMonitors();
+ static int compare(const void*, const void*);
};
#endif // __MONITOR_INDEX_PARAMETER_H
}
typedef struct {
- int x, y, w, h;
- char* name;
- size_t name_len;
- int bytes_written;
+ int x, y, w, h;
+ char* name;
+ size_t name_len;
+ int bytes_written;
} EnumCallbackData;
static BOOL CALLBACK EnumDisplayMonitorsCallback(
- HMONITOR monitor, HDC deviceContext, LPRECT rect, LPARAM userData)
+ HMONITOR monitor, HDC deviceContext, LPRECT rect, LPARAM userData)
{
- EnumCallbackData *data = (EnumCallbackData *)userData;
- MONITORINFOEX info;
- info.cbSize = sizeof(info);
- GetMonitorInfo(monitor, (LPMONITORINFO)&info);
+ EnumCallbackData *data = (EnumCallbackData *)userData;
+ MONITORINFOEX info;
+ info.cbSize = sizeof(info);
+ GetMonitorInfo(monitor, (LPMONITORINFO)&info);
- int x = info.rcMonitor.left;
- int y = info.rcMonitor.top;
- int w = info.rcMonitor.right - info.rcMonitor.left;
- int h = info.rcMonitor.bottom - info.rcMonitor.top;
+ int x = info.rcMonitor.left;
+ int y = info.rcMonitor.top;
+ int w = info.rcMonitor.right - info.rcMonitor.left;
+ int h = info.rcMonitor.bottom - info.rcMonitor.top;
- if ((data->x == x) && (data->y == y) && (data->w == w) && (data->h == h)) {
- data->bytes_written = snprintf(data->name, data->name_len,
- "%.*s", (int)(data->name_len - 1), info.szDevice);
+ if ((data->x == x) && (data->y == y) && (data->w == w) && (data->h == h)) {
+ data->bytes_written = snprintf(data->name, data->name_len,
+ "%.*s", (int)(data->name_len - 1), info.szDevice);
- if (data->bytes_written < 0)
- return FALSE;
+ if (data->bytes_written < 0)
+ return FALSE;
- // Stop the iteration.
- return FALSE;
- }
+ // Stop the iteration.
+ return FALSE;
+ }
- // Keep iterating.
- return TRUE;
+ // Keep iterating.
+ return TRUE;
}
int win32_get_monitor_name(int x, int y, int w, int h, char name[], size_t name_len)
{
- EnumCallbackData data = {
- .x = x,
- .y = y,
- .w = w,
- .h = h,
- .name = name,
- .name_len = name_len,
- .bytes_written = -1
- };
-
- EnumDisplayMonitors(NULL, NULL, EnumDisplayMonitorsCallback, (LPARAM) &data);
- return data.bytes_written;
+ EnumCallbackData data = {
+ .x = x,
+ .y = y,
+ .w = w,
+ .h = h,
+ .name = name,
+ .name_len = name_len,
+ .bytes_written = -1
+ };
+
+ EnumDisplayMonitors(NULL, NULL, EnumDisplayMonitorsCallback, (LPARAM) &data);
+ return data.bytes_written;
}