summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/x11.H1
-rw-r--r--src/Fl_arg.cxx3
-rw-r--r--src/Fl_x.cxx39
3 files changed, 35 insertions, 8 deletions
diff --git a/FL/x11.H b/FL/x11.H
index 576b8f1bd..6dcb972e5 100644
--- a/FL/x11.H
+++ b/FL/x11.H
@@ -85,7 +85,6 @@ private:
extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
-extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
#endif // FL_LIBRARY || FL_INTERNALS
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));