summaryrefslogtreecommitdiff
path: root/src/Fl_Screen_Driver.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-12-16 21:59:39 +0100
committerMatthias Melcher <github@matthiasm.com>2023-12-16 21:59:43 +0100
commit469d3ef3d5e9bc27eb5cd0ef6532f89568604572 (patch)
tree3a76a496fc53c2d50ab21f1d961b75a54fa1f7c6 /src/Fl_Screen_Driver.cxx
parent638e762d3ebdb0b2e736e1deecaa7d86529fc1e5 (diff)
#842: Enables command line color arguments on macOS
Diffstat (limited to 'src/Fl_Screen_Driver.cxx')
-rw-r--r--src/Fl_Screen_Driver.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx
index 877576fdf..af6b3a3c3 100644
--- a/src/Fl_Screen_Driver.cxx
+++ b/src/Fl_Screen_Driver.cxx
@@ -23,6 +23,7 @@
#include "Fl_Screen_Driver.H"
#include <FL/Fl_Image.H>
#include <FL/Fl.H>
+#include <FL/platform.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
@@ -32,6 +33,12 @@
#include <FL/Fl_Tooltip.H>
#include <string.h> // for memchr
+// these are set by Fl::args() and override any system colors: from Fl_get_system_colors.cxx
+extern const char *fl_fg;
+extern const char *fl_bg;
+extern const char *fl_bg2;
+// end of extern additions workaround
+
char Fl_Screen_Driver::bg_set = 0;
char Fl_Screen_Driver::bg2_set = 0;
char Fl_Screen_Driver::fg_set = 0;
@@ -181,6 +188,29 @@ int Fl_Screen_Driver::screen_num(int x, int y, int w, int h)
return best_screen;
}
+static void getsyscolor(const char* arg, void (*func)(uchar,uchar,uchar))
+{
+ if (arg && *arg) {
+ uchar r,g,b;
+ if (!fl_parse_color(arg, r,g,b))
+ Fl::error("Unknown color: %s", arg);
+ else
+ func(r,g,b);
+ }
+}
+
+static void set_selection_color(uchar r, uchar g, uchar b)
+{
+ Fl::set_color(FL_SELECTION_COLOR,r,g,b);
+}
+
+void Fl_Screen_Driver::get_system_colors()
+{
+ if (!bg2_set) getsyscolor(fl_bg2, Fl::background2);
+ if (!fg_set) getsyscolor(fl_fg, Fl::foreground);
+ if (!bg_set) getsyscolor(fl_bg, Fl::background);
+ getsyscolor(0, set_selection_color);
+}
const char *Fl_Screen_Driver::get_system_scheme()
{