diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-02-22 19:55:11 +0100 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-02-22 19:55:11 +0100 |
| commit | cdd19336610f310f41bd7ea7b20c6cd55292c5bf (patch) | |
| tree | 087cc08f4e82b4fc00bebe5391840b1dcac208ca /src | |
| parent | 406f2c33f45beff22f868c6af83b1e1c2cee3d9e (diff) | |
X11: Disable "boxcheat" hack
For details see comment in src/Fl_x.cxx: this "Hack to speed up
bg box drawing" is now disabled for several reasons. The code
is still available if the macro ENABLE_BOXCHEAT is defined.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_arg.cxx | 3 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 39 |
2 files changed, 35 insertions, 7 deletions
diff --git a/src/Fl_arg.cxx b/src/Fl_arg.cxx index 347faee63..531b3d853 100644 --- a/src/Fl_arg.cxx +++ b/src/Fl_arg.cxx @@ -1,7 +1,7 @@ // // Optional argument initialization code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2018 by Bill Spitzak and others. +// Copyright 1998-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -277,6 +277,7 @@ void Fl_Window::show(int argc, char **argv) { pWindowDriver->show_with_args_begin(); + // note: background_pixel is no longer used since 1.4.0, but anyway ... // set colors first, so background_pixel is correct: static char beenhere; if (!beenhere) { diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 51cce9f3f..a993d1e92 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -83,6 +83,32 @@ extern Fl_Widget *fl_selection_requestor; static void open_display_i(Display *d); // open display (internal) //////////////////////////////////////////////////////////////// + +// Hack to speed up bg box drawing - aka "boxcheat": +// If the boxtype of a window is a filled rectangle, we can make the +// redisplay *look* faster by using X's background pixel erasing. +// This is done by setting a flag when the window is shown for the first time. + +// Note to FLTK devs: +// This can cause unexpected behavior, for instance if the box() or +// color() of a window is changed after show(), and it does presumably not +// have much effect on current systems (compared to 1998). +// It is also fragile WRT checking the box type if any other scheme than +// the default scheme is loaded. +// Hence this is disabled since FLTK 1.4.0 (AlbrechtS Feb 02, 2022) + +// Note to FLTK users: +// You may define ENABLE_BOXCHEAT to use it anyway but please tell the +// FLTK devs why you believe that you need it. Should we re-enable it? + +#ifdef ENABLE_BOXCHEAT +static int fl_background_pixel = -1; +static inline int can_boxcheat(Fl_Boxtype b) { + return (b == 1 || ((b & 2) && b <= 15)); +} +#endif // (ENABLE_BOXCHEAT) + +//////////////////////////////////////////////////////////////// // interface to poll/select call: # if USE_POLL @@ -2506,7 +2532,6 @@ Fl_X* Fl_X::set_xid(Fl_Window* win, Window winxid) { // normally. The global variables like fl_show_iconic are so that // subclasses of *that* class may change the behavior... -int fl_background_pixel = -1; // hack to speed up bg box drawing int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR static const int childEventMask = ExposureMask; @@ -2623,11 +2648,14 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap) H = sy + sh - Y; } +#ifdef ENABLE_BOXCHEAT if (fl_background_pixel >= 0) { attr.background_pixel = fl_background_pixel; fl_background_pixel = -1; mask |= CWBackPixel; } +#endif // (ENABLE_BOXCHEAT) + float s = 1; #if USE_XFT //compute adequate screen where to put the window @@ -3198,18 +3226,17 @@ void Fl_X11_Window_Driver::label(const char *name, const char *iname) { //////////////////////////////////////////////////////////////// // Implement the virtual functions for the base Fl_Window class: -// If the box is a filled rectangle, we can make the redisplay -// *look* faster by using X's background pixel erasing. - -static inline int can_boxcheat(uchar b) {return (b==1 || ((b&2) && b<=15));} - void Fl_X11_Window_Driver::show() { if (!shown()) { fl_open_display(); + +#ifdef ENABLE_BOXCHEAT // Don't set background pixel for double-buffered windows... if (pWindow->type() != FL_DOUBLE_WINDOW && can_boxcheat(pWindow->box())) { fl_background_pixel = int(fl_xpixel(pWindow->color())); } +#endif // (ENABLE_BOXCHEAT) + makeWindow(); } else { XMapRaised(fl_display, fl_xid(pWindow)); |
