diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2016-02-13 12:57:00 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2016-02-13 12:57:00 +0000 |
| commit | 5d1df0e789c794b8040c5db0d84b03ae2b42fd8d (patch) | |
| tree | 4e99ebb978d30bf6c7138181489dd37ce435c310 /src/drivers/X11 | |
| parent | 8deac1e6baf7a016aabd3b6cb5ccffd7f09263cd (diff) | |
Details on PORTME items. Move fl_parse_color() to screen drivers.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11163 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/X11')
| -rw-r--r-- | src/drivers/X11/Fl_X11_Screen_Driver.cxx | 36 | ||||
| -rw-r--r-- | src/drivers/X11/Fl_X11_Screen_Driver.h | 5 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index e98dc3413..49fa840f5 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -42,8 +42,30 @@ Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver() } +void Fl_X11_Screen_Driver::display(const char *d) +{ + if (!d) return; + + static const char *cmd = "DISPLAY="; + static const char *ext = ":0.0"; + int nc = strlen(cmd); + int ne = strlen(ext); + int nd = strlen(d); + + char *buf = malloc(nc+ne+nd+1); + strcpy(buf, cmd); + strcat(buf, d); + if (strchr(d, ':')) { + strcat(d, ext); + } + putenv(e); + free(buf); +} + + static int fl_workarea_xywh[4] = { -1, -1, -1, -1 }; + void Fl_X11_Screen_Driver::init_workarea() { fl_open_display(); @@ -210,6 +232,20 @@ void Fl_X11_Screen_Driver::flush() } +// Wrapper around XParseColor... +int Fl_X11_Screen_Driver::parse_color(const char* p, uchar& r, uchar& g, uchar& b) +{ + XColor x; + if (!fl_display) fl_open_display(); + if (XParseColor(fl_display, fl_colormap, p, &x)) { + r = (uchar)(x.red>>8); + g = (uchar)(x.green>>8); + b = (uchar)(x.blue>>8); + return 1; + } else return 0; +} + + // // End of "$Id$". // diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.h b/src/drivers/X11/Fl_X11_Screen_Driver.h index 4a4667cf5..27ced8822 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.h +++ b/src/drivers/X11/Fl_X11_Screen_Driver.h @@ -41,6 +41,9 @@ protected: float dpi[MAX_SCREENS][2]; public: + // --- display management + virtual void display(const char *disp); + // --- screen configuration void init_workarea(); virtual void init(); virtual int x(); @@ -54,6 +57,8 @@ public: virtual void beep(int type); // --- global events virtual void flush(); + // --- global colors + virtual int parse_color(const char* p, uchar& r, uchar& g, uchar& b); }; |
