diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-11-07 06:49:40 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-11-07 06:49:40 +0100 |
| commit | 37bf3835b0b3ce7f4c80924f40735698f057ef6f (patch) | |
| tree | 5862a10eef97cf3575bfe55b2f29fc5a79ae3270 /src/drivers/X11/Fl_X11_Screen_Driver.cxx | |
| parent | b663e272e7f39063a5c1bf744038ded0a7566990 (diff) | |
Create class Fl_Unix_Screen_Driver used by X11 and Wayland platforms
Diffstat (limited to 'src/drivers/X11/Fl_X11_Screen_Driver.cxx')
| -rw-r--r-- | src/drivers/X11/Fl_X11_Screen_Driver.cxx | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index 87a91636c..6876c6d47 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -18,7 +18,6 @@ #include <config.h> #include "Fl_X11_Screen_Driver.H" #include "Fl_X11_Window_Driver.H" -#include "Fl_X11_System_Driver.H" #include "../Posix/Fl_Posix_System_Driver.H" #include <FL/Fl.H> #include <FL/platform.H> @@ -69,6 +68,11 @@ char Fl_X11_Screen_Driver::fl_is_over_the_spot = 0; Window Fl_X11_Screen_Driver::xim_win = 0; +Fl_X11_Screen_Driver::Fl_X11_Screen_Driver() : Fl_Unix_Screen_Driver() { + // X11 screen driver does not use a key table + key_table = NULL; + key_table_size = 0; +} void Fl_X11_Screen_Driver::display(const char *d) { @@ -76,6 +80,60 @@ void Fl_X11_Screen_Driver::display(const char *d) } +int Fl_X11_Screen_Driver::XParseGeometry(const char* string, int* x, int* y, + unsigned int* width, unsigned int* height) { + return ::XParseGeometry(string, x, y, width, height); +} + + +void Fl_X11_Screen_Driver::own_colormap() { + fl_open_display(); +#if USE_COLORMAP + switch (fl_visual->c_class) { + case GrayScale : + case PseudoColor : + case DirectColor : + break; + default: + return; // don't do anything for non-colormapped visuals + } + int i; + XColor colors[16]; + // Get the first 16 colors from the default colormap... + for (i = 0; i < 16; i ++) colors[i].pixel = i; + XQueryColors(fl_display, fl_colormap, colors, 16); + // Create a new colormap... + fl_colormap = XCreateColormap(fl_display, + RootWindow(fl_display,fl_screen), + fl_visual->visual, AllocNone); + // Copy those first 16 colors to our own colormap: + for (i = 0; i < 16; i ++) + XAllocColor(fl_display, fl_colormap, colors + i); +#endif // USE_COLORMAP +} + + +const char *Fl_X11_Screen_Driver::shortcut_add_key_name(unsigned key, char *p, char *buf, const char **eom) +{ + const char* q; + if (key == FL_Enter || key == '\r') q = "Enter"; // don't use Xlib's "Return": + else if (key > 32 && key < 0x100) q = 0; + else q = XKeysymToString(key); + if (!q) { + p += fl_utf8encode(fl_toupper(key), p); + *p = 0; + return buf; + } + if (p > buf) { + strcpy(p,q); + return buf; + } else { + if (eom) *eom = q; + return q; + } +} + + static int test_visual(XVisualInfo& v, int flags) { if (v.screen != fl_screen) return 0; #if USE_COLORMAP |
