Fix for issue #254: remove hardware overlay support .

This commit is contained in:
ManoloFLTK 2021-11-26 15:16:15 +01:00
parent 84cf249482
commit eb8b016fab
12 changed files with 3 additions and 366 deletions

View File

@ -30,17 +30,6 @@
*/
class FL_EXPORT Fl_Menu_Window : public Fl_Single_Window {
public:
void show();
void erase();
void flush();
void hide();
/** Tells if hardware overlay mode is set */
unsigned int overlay() {return !(flags()&NO_OVERLAY);}
/** Tells FLTK to use hardware overlay planes if they are available. */
void set_overlay() {clear_flag(NO_OVERLAY);}
/** Tells FLTK to use normal drawing planes instead of overlay planes.
This is usually necessary if your menu contains multi-color pixmaps. */
void clear_overlay() {set_flag(NO_OVERLAY);}
~Fl_Menu_Window();
/** Creates a new Fl_Menu_Window widget using the given size, and label string. */
Fl_Menu_Window(int W, int H, const char *l = 0);

View File

@ -170,17 +170,6 @@
#cmakedefine USE_SDL 1
/*
* HAVE_OVERLAY:
*
* Use the X overlay extension? FLTK will try to use an overlay
* visual for Fl_Overlay_Window, the Gl_Window overlay, and for the
* menus. Setting this to zero will remove a substantial amount of
* code from FLTK. Overlays have only been tested on SGI servers!
*/
#define HAVE_OVERLAY 0
/*
* HAVE_GL_OVERLAY:
*
@ -188,7 +177,7 @@
* set this to 1.
*/
#define HAVE_GL_OVERLAY HAVE_OVERLAY
#define HAVE_GL_OVERLAY 0
/*
* WORDS_BIGENDIAN:

View File

@ -170,17 +170,6 @@
#undef USE_SDL
/*
* HAVE_OVERLAY:
*
* Use the X overlay extension? FLTK will try to use an overlay
* visual for Fl_Overlay_Window, the Gl_Window overlay, and for the
* menus. Setting this to zero will remove a substantial amount of
* code from FLTK. Overlays have only been tested on SGI servers!
*/
#define HAVE_OVERLAY 0
/*
* HAVE_GL_OVERLAY:
*
@ -188,7 +177,7 @@
* set this to 1.
*/
#define HAVE_GL_OVERLAY HAVE_OVERLAY
#define HAVE_GL_OVERLAY 0
/*
* WORDS_BIGENDIAN:

View File

@ -1193,24 +1193,6 @@ AS_CASE([$host_os_gui], [cygwin* | mingw*], [
AC_DEFINE([HAVE_X11_XREGION_H])
], [], [#include <X11/Xlib.h>])
dnl Check for overlay visuals...
AC_PATH_PROG([XPROP], [xprop])
AC_CACHE_CHECK([for X overlay visuals], [ac_cv_have_overlay], [
AS_IF([test "x$XPROP" != x], [
AS_IF([$XPROP -root 2>/dev/null | grep -c "SERVER_OVERLAY_VISUALS" >/dev/null], [
ac_cv_have_overlay=yes
], [
ac_cv_have_overlay=no
])
], [
ac_cv_have_overlay=no
])
])
AS_IF([test x$ac_cv_have_overlay = xyes], [
AC_DEFINE([HAVE_OVERLAY])
])
# Make symlinks since UNIX/Linux is case sensitive,
# but Cygwin in general not.
AS_CASE([$host_os], [cygwin*], [

View File

@ -283,7 +283,6 @@ menutitle::menutitle(int X, int Y, int W, int H, const Fl_Menu_Item* L) :
clear_border();
set_menu_window();
menu = L;
if (L->labelcolor_ || Fl::scheme() || L->labeltype_ > FL_NO_LABEL) clear_overlay();
}
menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
@ -363,7 +362,6 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
}
}
}
if (m->labelcolor_ || Fl::scheme() || m->labeltype_ > FL_NO_LABEL) clear_overlay();
}
shortcutWidth = hotKeysw;
if (selected >= 0 && !Wp) X -= W/2;

View File

@ -24,27 +24,6 @@
#include <FL/Fl_Menu_Window.H>
#include "Fl_Window_Driver.H"
void Fl_Menu_Window::show() {
Fl_Window_Driver::driver(this)->show_menu();
}
void Fl_Menu_Window::flush() {
if (!shown()) return;
Fl_Window_Driver::driver(this)->flush_menu();
}
/** Erases the window, does nothing if HAVE_OVERLAY is not defined in config.h */
void Fl_Menu_Window::erase() {
Fl_Window_Driver::driver(this)->erase_menu();
}
// Fix the colormap flashing on Maximum Impact Graphics by erasing the
// menu before unmapping it:
void Fl_Menu_Window::hide() {
erase();
Fl_Single_Window::hide();
}
/** Destroys the window and all of its children.*/
Fl_Menu_Window::~Fl_Menu_Window() {
hide();

View File

@ -134,8 +134,6 @@ public:
virtual void flush(); // the default implementation may be enough
virtual void flush_double();
virtual void flush_overlay();
virtual void flush_menu();
virtual void erase_menu() {}
/** Usable for platform-specific code executed before the platform-independent part of Fl_Window::draw() */
virtual void draw_begin();
/** Usable for platform-specific code executed after the platform-independent part of Fl_Window::draw() */
@ -148,7 +146,6 @@ public:
virtual void wait_for_expose();
virtual void destroy_double_buffer();
virtual void show();
virtual void show_menu();
virtual void resize(int X,int Y,int W,int H) {}
virtual void hide() {}
int hide_common();

View File

@ -72,7 +72,6 @@ unsigned char Fl_Window_Driver::size_range_set() {return pWindow->size_range_set
void Fl_Window_Driver::flush_Fl_Window() { pWindow->Fl_Window::flush(); }
void Fl_Window_Driver::flush_menu() { pWindow->Fl_Window::flush(); }
/**
Draw the window content.
@ -92,7 +91,6 @@ void Fl_Window_Driver::make_current() { }
*/
void Fl_Window_Driver::show() { }
void Fl_Window_Driver::show_menu() { pWindow->Fl_Window::show(); }
/**
Change the window title.

View File

@ -35,18 +35,11 @@ class Fl_X11_Gl_Window_Driver : public Fl_Gl_Window_Driver {
virtual void before_show(int& need_after);
virtual int mode_(int m, const int *a);
virtual void swap_buffers();
virtual void resize(int is_a_resize, int w, int h);
virtual char swap_type();
virtual Fl_Gl_Choice *find(int m, const int *alistp);
virtual GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer = 0);
virtual void set_gl_context(Fl_Window* w, GLContext context);
virtual void delete_gl_context(GLContext);
#if HAVE_GL_OVERLAY
virtual void make_overlay(void *&o);
virtual int can_do_overlay();
virtual void hide_overlay();
virtual int overlay_color(Fl_Color i);
#endif
virtual void make_overlay_current();
virtual void redraw_overlay();
virtual void waitGL();
@ -357,122 +350,13 @@ void Fl_X11_Gl_Window_Driver::delete_gl_context(GLContext context) {
void Fl_X11_Gl_Window_Driver::make_overlay_current() {
#if HAVE_GL_OVERLAY
if (overlay() != pWindow) {
((Fl_Gl_Window*)overlay())->make_current();
} else
#endif
glDrawBuffer(GL_FRONT);
}
void Fl_X11_Gl_Window_Driver::redraw_overlay() {
if (overlay() != pWindow)
((Fl_Gl_Window*)overlay())->redraw();
else
pWindow->damage(FL_DAMAGE_OVERLAY);
}
#if HAVE_GL_OVERLAY
// Methods on Fl_Gl_Window_Driver that create an overlay window.
// Under X this is done by creating another window, of class _Fl_Gl_Overlay
// which is a subclass of Fl_Gl_Window except it uses the overlay planes.
// A pointer to this is stored in the "overlay" pointer of the Fl_Gl_Window.
// If overlay hardware is unavailable, the overlay is
// "faked" by drawing into the main layers. This is indicated by
// setting overlay == this.
extern XVisualInfo *fl_find_overlay_visual();
extern XVisualInfo *fl_overlay_visual;
extern Colormap fl_overlay_colormap;
extern unsigned long fl_transparent_pixel;
//extern uchar fl_overlay;
int Fl_X11_Gl_Window_Driver::overlay_color(Fl_Color i) {
if (Fl_Xlib_Graphics_Driver::fl_overlay) {glIndexi(int(fl_xpixel(i))); return 1;}
return 0;
}
class _Fl_Gl_Overlay : public Fl_Gl_Window {
void flush();
void draw();
public:
void show();
_Fl_Gl_Overlay(int x, int y, int w, int h) :
Fl_Gl_Window(x,y,w,h) {
set_flag(INACTIVE);
}
};
void _Fl_Gl_Overlay::flush() {
make_current();
#ifdef BOXX_BUGS
// The BoXX overlay is broken and you must not call swap-buffers. This
// code will make it work, but we lose because machines that do support
// double-buffered overlays will blink when they don't have to
glDrawBuffer(GL_FRONT);
draw();
#else
draw();
swap_buffers();
#endif
glFlush();
valid(1);
}
void _Fl_Gl_Overlay::draw() {
if (!valid()) glClearIndex((GLfloat)fl_transparent_pixel);
if (damage() != FL_DAMAGE_EXPOSE) glClear(GL_COLOR_BUFFER_BIT);
Fl_Gl_Window *w = (Fl_Gl_Window *)parent();
uchar save_valid = w->valid();
w->valid(valid());
Fl_Xlib_Graphics_Driver::fl_overlay = 1;
Fl_Gl_Window_Driver::driver(w)->draw_overlay();
Fl_Xlib_Graphics_Driver::fl_overlay = 0;
valid(w->valid());
w->valid(save_valid);
}
void _Fl_Gl_Overlay::show() {
if (!shown()) {
fl_background_pixel = int(fl_transparent_pixel);
Fl_X::make_xid(this, fl_overlay_visual, fl_overlay_colormap);
fl_background_pixel = -1;
// find the outermost window to tell wm about the colormap:
Fl_Window *w = window();
for (;;) {Fl_Window *w1 = w->window(); if (!w1) break; w = w1;}
XSetWMColormapWindows(fl_display, fl_xid(w), &(Fl_X::i(this)->xid), 1);
context(Fl_X11_Gl_Window_Driver::create_gl_context(fl_overlay_visual), 1);
valid(0);
}
Fl_Gl_Window::show();
}
void Fl_X11_Gl_Window_Driver::hide_overlay() {
if (overlay() && overlay() != pWindow) ((Fl_Gl_Window*)overlay())->hide();
}
int Fl_X11_Gl_Window_Driver::can_do_overlay() {
return fl_find_overlay_visual() != 0;
}
void Fl_X11_Gl_Window_Driver::make_overlay(void *&current) {
if (current) return;
if (can_do_overlay()) {
_Fl_Gl_Overlay* o = new _Fl_Gl_Overlay(0, 0, pWindow->w(), pWindow->h());
current = o;
pWindow->add(*o);
o->show();
} else {
current = pWindow; // fake the overlay
}
}
#endif // HAVE_GL_OVERLAY
Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w)
{
@ -482,7 +366,6 @@ Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w)
void Fl_X11_Gl_Window_Driver::before_show(int&) {
Fl_X11_Gl_Choice *g = (Fl_X11_Gl_Choice*)this->g();
Fl_X::make_xid(pWindow, g->vis, g->colormap);
if (overlay() && overlay() != pWindow) ((Fl_Gl_Window*)overlay())->show();
}
float Fl_X11_Gl_Window_Driver::pixels_per_unit()
@ -523,11 +406,6 @@ void Fl_X11_Gl_Window_Driver::swap_buffers() {
glXSwapBuffers(fl_display, fl_xid(pWindow));
}
void Fl_X11_Gl_Window_Driver::resize(int is_a_resize, int W, int H) {
if (is_a_resize && !pWindow->resizable() && overlay() && overlay() != pWindow) {
((Fl_Gl_Window*)overlay())->resize(0,0,W,H);
}
}
char Fl_X11_Gl_Window_Driver::swap_type() {return copy;}

View File

@ -100,12 +100,9 @@ public:
virtual void take_focus();
virtual void flush_double();
virtual void flush_overlay();
virtual void flush_menu();
virtual void erase_menu();
virtual void draw_begin();
virtual void make_current();
virtual void show();
virtual void show_menu();
virtual void resize(int X,int Y,int W,int H);
virtual void label(const char *name, const char *mininame);
virtual void destroy_double_buffer();
@ -131,8 +128,6 @@ public:
virtual void free_icons();
void set_icons(); // driver-internal support function
virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
virtual int can_do_overlay();
virtual void redraw_overlay();
virtual int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, void (*draw_area)(void*, int,int,int,int), void* data);
};

View File

@ -35,13 +35,6 @@
#define ShapeBounding 0
#define ShapeSet 0
#if HAVE_OVERLAY
extern XVisualInfo *fl_find_overlay_visual();
extern XVisualInfo *fl_overlay_visual;
extern Colormap fl_overlay_colormap;
extern unsigned long fl_transparent_pixel;
#endif
Window fl_window;
@ -392,20 +385,6 @@ void Fl_X11_Window_Driver::make_current() {
}
void Fl_X11_Window_Driver::show_menu()
{
#if HAVE_OVERLAY
if (!shown() && ((Fl_Menu_Window*)pWindow)->overlay() && fl_find_overlay_visual()) {
XInstallColormap(fl_display, fl_overlay_colormap);
fl_background_pixel = int(fl_transparent_pixel);
Fl_X::make_xid(pWindow, fl_overlay_visual, fl_overlay_colormap);
fl_background_pixel = -1;
} else
#endif
pWindow->Fl_Window::show();
}
void Fl_X11_Window_Driver::hide() {
Fl_X* ip = Fl_X::i(pWindow);
if (hide_common()) return;
@ -499,107 +478,6 @@ void Fl_X11_Window_Driver::show_with_args_end(int argc, char **argv) {
}
}
#if HAVE_OVERLAY
class _Fl_Overlay : public Fl_Window {
friend class Fl_Overlay_Window;
void flush();
void show();
public:
_Fl_Overlay(int x, int y, int w, int h) : Fl_Window(x,y,w,h) {
set_flag(INACTIVE);
}
};
/*int Fl_Overlay_Window::can_do_overlay() {
return fl_find_overlay_visual() != 0;
}*/
void _Fl_Overlay::show() {
if (shown()) {Fl_Window::show(); return;}
fl_background_pixel = int(fl_transparent_pixel);
Fl_X::make_xid(this, fl_overlay_visual, fl_overlay_colormap);
fl_background_pixel = -1;
// find the outermost window to tell wm about the colormap:
Fl_Window *w = window();
for (;;) {Fl_Window *w1 = w->window(); if (!w1) break; w = w1;}
XSetWMColormapWindows(fl_display, fl_xid(w), &(Fl_X::i(this)->xid), 1);
}
void _Fl_Overlay::flush() {
fl_window = fl_xid(this);
#if defined(FLTK_USE_CAIRO)
if (Fl::cairo_autolink_context()) Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
#endif
Fl_Xlib_Graphics_Driver::fl_overlay = 1;
Fl_Overlay_Window *w = (Fl_Overlay_Window *)parent();
Fl_X *myi = Fl_X::i(this);
if (damage() != FL_DAMAGE_EXPOSE) XClearWindow(fl_display, fl_xid(this));
fl_clip_region(myi->region); myi->region = 0;
w->draw_overlay();
Fl_Xlib_Graphics_Driver::fl_overlay = 0;
}
#endif // HAVE_OVERLAY
int Fl_X11_Window_Driver::can_do_overlay() {
#if HAVE_OVERLAY
return fl_find_overlay_visual() != 0;
#endif
return Fl_Window_Driver::can_do_overlay();
}
void Fl_X11_Window_Driver::redraw_overlay() {
#if HAVE_OVERLAY
if (!fl_display) return; // this prevents fluid -c from opening display
if (!overlay()) {
if (can_do_overlay()) {
Fl_Group::current(pWindow);
overlay(new _Fl_Overlay(0,0,w(),h()));
Fl_Group::current(0);
} else {
overlay(pWindow); // fake the overlay
}
}
if (shown()) {
if (overlay() == pWindow) {
pWindow->clear_damage(pWindow->damage()|FL_DAMAGE_OVERLAY);
Fl::damage(FL_DAMAGE_CHILD);
} else if (!overlay()->shown())
overlay()->show();
else
overlay()->redraw();
}
return;
#endif
Fl_Window_Driver::redraw_overlay();
}
void Fl_X11_Window_Driver::flush_menu() {
#if HAVE_OVERLAY
if (!fl_overlay_visual || !overlay()) {flush_Fl_Window(); return;}
Fl_X *myi = Fl_X::i(pWindow);
fl_window = myi->xid;
# if defined(FLTK_USE_CAIRO)
// capture gc changes automatically to update the cairo context adequately
if(Fl::autolink_context()) Fl::cairo_make_current(fl_graphics_driver->gc());
# endif
Fl_Xlib_Graphics_Driver::fl_overlay = 1;
fl_clip_region(myi->region); myi->region = 0; current(pWindow);
draw();
Fl_Xlib_Graphics_Driver::fl_overlay = 0;
#else
flush_Fl_Window();
#endif
}
void Fl_X11_Window_Driver::erase_menu() {
#if HAVE_OVERLAY
if (pWindow->shown()) XClearWindow(fl_display, fl_xid(pWindow));
#endif
}
int Fl_X11_Window_Driver::scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y,
void (*draw_area)(void*, int,int,int,int), void* data)
{

View File

@ -93,16 +93,7 @@ static void figure_out_visual() {
}
# if HAVE_OVERLAY
/** HAVE_OVERLAY determines whether fl_xmap is one or two planes */
Fl_XColor fl_xmap[2][256];
Colormap fl_overlay_colormap;
XVisualInfo* fl_overlay_visual;
ulong fl_transparent_pixel;
# else
/** HAVE_OVERLAY determines whether fl_xmap is one or two planes */
Fl_XColor fl_xmap[1][256];
# endif
void Fl_Xlib_Graphics_Driver::color(Fl_Color i) {
if (i & 0xffffff00) {
@ -204,9 +195,6 @@ ulong fl_xpixel(Fl_Color i) {
# if USE_COLORMAP
Colormap colormap = fl_colormap;
# if HAVE_OVERLAY
if (Fl_Xlib_Graphics_Driver::fl_overlay) colormap = fl_overlay_colormap; else
# endif
if (fl_redmask) {
# endif
// return color for a truecolor visual:
@ -221,15 +209,8 @@ ulong fl_xpixel(Fl_Color i) {
) >> fl_extrashift;
# if USE_COLORMAP
}
# if HAVE_OVERLAY
static XColor* ac[2];
XColor*& allcolors = ac[Fl_Xlib_Graphics_Driver::fl_overlay];
static int nc[2];
int& numcolors = nc[Fl_Xlib_Graphics_Driver::fl_overlay];
# else
static XColor *allcolors;
static int numcolors;
# endif
// I don't try to allocate colors with XAllocColor once it fails
// with any color. It is possible that it will work, since a color
@ -249,10 +230,7 @@ ulong fl_xpixel(Fl_Color i) {
// I only read the colormap once. Again this is due to the slowness
// of round-trips to the X server, even though other programs may alter
// the colormap after this and make decisions here wrong.
# if HAVE_OVERLAY
if (Fl_Xlib_Graphics_Driver::fl_overlay) numcolors = fl_overlay_visual->colormap_size; else
# endif
numcolors = fl_visual->colormap_size;
numcolors = fl_visual->colormap_size;
if (!allcolors) allcolors = new XColor[numcolors];
for (int p = numcolors; p--;) allcolors[p].pixel = p;
XQueryColors(fl_display, colormap, allcolors, numcolors);
@ -262,9 +240,6 @@ ulong fl_xpixel(Fl_Color i) {
int mindist = 0x7FFFFFFF;
unsigned int bestmatch = 0;
for (unsigned int n = numcolors; n--;) {
# if HAVE_OVERLAY
if (Fl_Xlib_Graphics_Driver::fl_overlay && n == fl_transparent_pixel) continue;
# endif
XColor &a = allcolors[n];
int d, t;
t = int(r)-int(a.red>>8); d = t*t;
@ -303,17 +278,10 @@ ulong fl_xpixel(Fl_Color i) {
\param[in] overlay 0 for normal, 1 for overlay color
*/
void Fl_Xlib_Graphics_Driver::free_color(Fl_Color i, int overlay) {
# if HAVE_OVERLAY
# else
if (overlay) return;
# endif
if (fl_xmap[overlay][i].mapped) {
# if USE_COLORMAP
# if HAVE_OVERLAY
Colormap colormap = overlay ? fl_overlay_colormap : fl_colormap;
# else
Colormap colormap = fl_colormap;
# endif
if (fl_xmap[overlay][i].mapped == 1)
XFreeColors(fl_display, colormap, &(fl_xmap[overlay][i].pixel), 1, 0);
# endif
@ -329,9 +297,6 @@ void Fl_Xlib_Graphics_Driver::free_color(Fl_Color i, int overlay) {
void Fl_Xlib_Graphics_Driver::set_color(Fl_Color i, unsigned c) {
if (fl_cmap[i] != c) {
free_color(i,0);
# if HAVE_OVERLAY
free_color(i,1);
# endif
fl_cmap[i] = c;
}
}