From 38c947bd093c0edb1eb746911150574fa4a0fb2f Mon Sep 17 00:00:00 2001 From: Bill Spitzak Date: Sat, 5 May 2001 23:39:01 +0000 Subject: [PATCH] Compiling with -DBOXX_BUGS will work around some problems with the newest X drivers that BoXX delivers, the problems all affect use of Overlays for normal X drawing and OpenGL drawing. Normal compilation is unchanged. The file chooser buttons use user_data() rather than the label to decide what to do, allowing the label to be somewhat cleaner. Selection color on X changed to blue, to match what happens on Windows now. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1452 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Gl_Overlay.cxx | 21 ++++++++++++-- src/Fl_Overlay_Window.cxx | 13 +++++++-- src/cmap.cxx | 16 ++++++---- src/fl_cmap.h | 2 +- src/fl_file_chooser.cxx | 61 ++++++++++++++++++++------------------- src/fl_overlay_visual.cxx | 10 +++---- test/input.cxx | 5 ++-- 7 files changed, 80 insertions(+), 48 deletions(-) diff --git a/src/Fl_Gl_Overlay.cxx b/src/Fl_Gl_Overlay.cxx index a3518000e..5bf993ab2 100644 --- a/src/Fl_Gl_Overlay.cxx +++ b/src/Fl_Gl_Overlay.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.17 2001/03/20 18:02:52 spitzak Exp $" +// "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.18 2001/05/05 23:39:01 spitzak Exp $" // // OpenGL overlay code for the Fast Light Tool Kit (FLTK). // @@ -66,6 +66,7 @@ extern unsigned long fl_transparent_pixel; extern uchar fl_overlay; class _Fl_Gl_Overlay : public Fl_Gl_Window { + void flush(); void draw(); public: void show(); @@ -75,6 +76,22 @@ public: } }; +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); @@ -214,5 +231,5 @@ void Fl_Gl_Window::hide_overlay() { #endif // -// End of "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.17 2001/03/20 18:02:52 spitzak Exp $". +// End of "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.18 2001/05/05 23:39:01 spitzak Exp $". // diff --git a/src/Fl_Overlay_Window.cxx b/src/Fl_Overlay_Window.cxx index 57f029a1f..0d31fb5dc 100644 --- a/src/Fl_Overlay_Window.cxx +++ b/src/Fl_Overlay_Window.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Overlay_Window.cxx,v 1.7.2.5 2001/01/22 15:13:40 easysw Exp $" +// "$Id: Fl_Overlay_Window.cxx,v 1.7.2.6 2001/05/05 23:39:01 spitzak Exp $" // // Overlay window code for the Fast Light Tool Kit (FLTK). // @@ -43,6 +43,15 @@ void Fl_Overlay_Window::hide() { } void Fl_Overlay_Window::flush() { +#ifdef BOXX_BUGS + if (overlay_ && overlay_ != this && overlay_->shown()) { + // all drawing to windows hidden by overlay windows is ignored, fix this + XUnmapWindow(fl_display, fl_xid(overlay_)); + Fl_Double_Window::flush(0); + XMapWindow(fl_display, fl_xid(overlay_)); + return; + } +#endif int erase_overlay = (damage()&FL_DAMAGE_OVERLAY); clear_damage(damage()&~FL_DAMAGE_OVERLAY); Fl_Double_Window::flush(erase_overlay); @@ -140,5 +149,5 @@ void Fl_Overlay_Window::redraw_overlay() { #endif // -// End of "$Id: Fl_Overlay_Window.cxx,v 1.7.2.5 2001/01/22 15:13:40 easysw Exp $". +// End of "$Id: Fl_Overlay_Window.cxx,v 1.7.2.6 2001/05/05 23:39:01 spitzak Exp $". // diff --git a/src/cmap.cxx b/src/cmap.cxx index 9383e204a..0c635f504 100644 --- a/src/cmap.cxx +++ b/src/cmap.cxx @@ -1,5 +1,5 @@ // -// "$Id: cmap.cxx,v 1.4.2.5 2001/01/22 15:13:40 easysw Exp $" +// "$Id: cmap.cxx,v 1.4.2.6 2001/05/05 23:39:01 spitzak Exp $" // // Colormap generation program for the Fast Light Tool Kit (FLTK). // @@ -59,7 +59,11 @@ static short cmap[256][3] = { {113,113,198}, // pale blue {142, 56,142}, // purple, orchid, pale magenta { 56,142,142}, // cadet blue, aquamarine, pale cyan - {170,170,170}, // 2/3 gray (FL_SELECTION_COLOR location) +// The next location is used for FL_SELECTION_COLOR. It formerly was 2/3 gray +// but this is changed to be the Windows blue color. This allows the default +// behavior on both X and Windows to match: + { 0, 0,128}, +//{170,170,170}, // old 2/3 gray color // These next 16 are the FL_FREE_COLOR area. In some versions of fltk // these were filled with random colors that a Irix 5.3 machine placed // in these locations. Other versions of fltk filled this with the 1/3 @@ -146,10 +150,10 @@ int main() { // fill in the gray ramp: background(0xc0, 0xc0, 0xc0); // microsoft colors - // background(cmap[15][0],cmap[15][1],cmap[15][2]); // old fltk colors + // background(170, 170, 170); // old fltk colors // copy the 1/3 and 2/3 gray to the closest locations in gray ramp: - cmap[39][0] = cmap[39][1] = cmap[39][2] = cmap[8][0]; - cmap[47][0] = cmap[47][1] = cmap[47][2] = cmap[15][0]; + cmap[39][0] = cmap[39][1] = cmap[39][2] = 85; + cmap[47][0] = cmap[47][1] = cmap[47][2] = 170; // fill in the color cube i = 56; @@ -171,5 +175,5 @@ int main() { } // -// End of "$Id: cmap.cxx,v 1.4.2.5 2001/01/22 15:13:40 easysw Exp $". +// End of "$Id: cmap.cxx,v 1.4.2.6 2001/05/05 23:39:01 spitzak Exp $". // diff --git a/src/fl_cmap.h b/src/fl_cmap.h index 4ad9b0d13..3b05ee7cf 100644 --- a/src/fl_cmap.h +++ b/src/fl_cmap.h @@ -13,7 +13,7 @@ 0x7171c600, 0x8e388e00, 0x388e8e00, - 0xaaaaaa00, + 0x00008000, 0xa8a89800, 0xe8e8d800, 0x68685800, diff --git a/src/fl_file_chooser.cxx b/src/fl_file_chooser.cxx index 1e6b463e3..7b5cb2380 100644 --- a/src/fl_file_chooser.cxx +++ b/src/fl_file_chooser.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_file_chooser.cxx,v 1.10.2.9 2001/03/14 17:20:02 spitzak Exp $" +// "$Id: fl_file_chooser.cxx,v 1.10.2.10 2001/05/05 23:39:01 spitzak Exp $" // // File chooser widget for the Fast Light Tool Kit (FLTK). // @@ -435,8 +435,8 @@ static void input_cb(Fl_Widget*, void* v) { w->browser.set(buf); } -static void up_cb(Fl_Widget*, void* v) { // the .. button - FCW* w = (FCW*)v; +static void up_cb(Fl_Widget*wd, void*) { // the .. button + FCW* w = (FCW*)(wd->window()); char* p; const char* newname; char buf[FL_PATH_MAX]; @@ -462,18 +462,16 @@ static void up_cb(Fl_Widget*, void* v) { // the .. button } static void dir_cb(Fl_Widget* obj, void* v) { // directory buttons - FCW* w = (FCW*)v; - const char* p = obj->label(); if (*p=='&') p++; + FCW* w = (FCW*)(obj->window()); char buf[FL_PATH_MAX]; - char* q; for (q=buf; *p && *p!=' '; *q++ = *p++); *q = 0; - filename_expand(buf, buf); + filename_expand(buf, (const char*)v); w->input.value(buf); w->input.position(10000); w->browser.set(buf); } -static void working_cb(Fl_Widget*, void* v) { // directory buttons - FCW*w = (FCW*)v; +static void working_cb(Fl_Widget* obj, void*) { // directory buttons + FCW* w = (FCW*)(obj->window()); char buf[FL_PATH_MAX]; filename_absolute(buf, ""); w->input.value(buf); @@ -482,15 +480,11 @@ static void working_cb(Fl_Widget*, void* v) { // directory buttons } static void files_cb(Fl_Widget* obj, void* v) { // file pattern buttons - FCW* w = (FCW*)v; + FCW* w = (FCW*)(obj->window()); char buf[FL_PATH_MAX]; strcpy(buf, w->input.value()); char* q = buf+w->browser.dirend; - if (obj != w->normal_button) { // tack on first word of label - const char* p = obj->label(); if (*p=='&') p++; - for (; *p && *p!=' '; *q++ = *p++); - } - *q = 0; + if (v) strcpy(q, (char*)v); else *q = 0; w->input.value(buf); w->input.position(10000, w->browser.dirend); w->browser.set(buf); @@ -517,7 +511,9 @@ int FCW::handle(int event) { } // set this to make extra directory-jumping button: +static Fl_Button* extra_button; const char* fl_file_chooser_button; +const char* fl_file_chooser_data; extern const char* fl_ok; extern const char* fl_cancel; @@ -544,41 +540,41 @@ FCW::FCW() : Fl_Window(WIDTH_BOX, HEIGHT_BOX), cancel_button->shortcut("^["); obj=new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, "&Up one directory"); - obj->callback(up_cb, this); + obj->callback(up_cb); but_y += HEIGHT_BUT; - obj = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&~/ Home"); - obj->callback(dir_cb, this); + obj = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&~ Home"); + obj->callback(dir_cb, (void*)"~/"); but_y += HEIGHT_BUT; obj = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&/ Root"); - obj->callback(dir_cb, this); + obj->callback(dir_cb, (void*)"/"); but_y += HEIGHT_BUT; obj=new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, "&Current dir"); - obj->callback(working_cb, this); + obj->callback(working_cb); but_y += HEIGHT_BUT; if (fl_file_chooser_button) { - obj=new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT,fl_file_chooser_button); - obj->callback(dir_cb, this); + obj = extra_button = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT,fl_file_chooser_button); + obj->callback(dir_cb, (void*)fl_file_chooser_button); but_y += HEIGHT_BUT; } normal_button = new Fl_Button(WIDTH_SPC, but_y, WIDTH_BUT, HEIGHT_BUT, ""); - normal_button->callback(files_cb, this); + normal_button->callback(files_cb, 0); but_y += HEIGHT_BUT; - obj = new Fl_Button(WIDTH_SPC,but_y, WIDTH_BUT, HEIGHT_BUT, "* &All files"); - obj->callback(files_cb, this); + obj = new Fl_Button(WIDTH_SPC,but_y, WIDTH_BUT, HEIGHT_BUT, "&All files"); + obj->callback(files_cb, (void*)"*"); but_y += HEIGHT_BUT; - obj = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, ". &Hidden files"); - obj->callback(files_cb, this); + obj = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, "&Hidden files"); + obj->callback(files_cb, (void*)"."); but_y += HEIGHT_BUT; - obj = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, "*/ &Directories"); - obj->callback(files_cb, this); + obj = new Fl_Button(WIDTH_SPC,but_y,WIDTH_BUT,HEIGHT_BUT, "&Directories"); + obj->callback(files_cb, (void*)"*/"); but_y += HEIGHT_BUT; resizable(new Fl_Box(browser.x(), but_y, @@ -594,6 +590,10 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname) static FCW* f; if (!f) f = new FCW(); f->ok_button->label(fl_ok); f->cancel_button->label(fl_cancel); + if (extra_button) { + extra_button->label(fl_file_chooser_button); + extra_button->user_data((void*)(fl_file_chooser_data ? fl_file_chooser_data : fl_file_chooser_button)); + } if (pat && !*pat) pat = 0; if (fname && *fname) { @@ -607,6 +607,7 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname) } f->browser.pattern = pat; f->normal_button->label(pat ? pat : "visible files"); + f->normal_button->user_data((void*)(pat ? pat : 0)); f->browser.set(f->input.value()); f->input.position(10000, f->browser.dirend); @@ -632,5 +633,5 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname) } // -// End of "$Id: fl_file_chooser.cxx,v 1.10.2.9 2001/03/14 17:20:02 spitzak Exp $". +// End of "$Id: fl_file_chooser.cxx,v 1.10.2.10 2001/05/05 23:39:01 spitzak Exp $". // diff --git a/src/fl_overlay_visual.cxx b/src/fl_overlay_visual.cxx index 42a38d5c8..8a14c1a56 100644 --- a/src/fl_overlay_visual.cxx +++ b/src/fl_overlay_visual.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_overlay_visual.cxx,v 1.4.2.3 2001/01/22 15:13:41 easysw Exp $" +// "$Id: fl_overlay_visual.cxx,v 1.4.2.4 2001/05/05 23:39:01 spitzak Exp $" // // X overlay support for the Fast Light Tool Kit (FLTK). // @@ -75,8 +75,8 @@ XVisualInfo *fl_find_overlay_visual() { templt.visualid = overlayInfo[i].overlay_visual; int num; XVisualInfo *v1=XGetVisualInfo(fl_display, VisualIDMask, &templt, &num); - if (v1->screen == fl_screen && - !v1->red_mask && (!v || v1->depth >= v->depth && v1->depth <= 8)) { + if (v1->screen == fl_screen && v1->c_class == PseudoColor + && (!v || v1->depth >= v->depth && v1->depth <= 8)) { if (v) XFree((char*)v); v = v1; fl_transparent_pixel = overlayInfo[i].value; @@ -92,12 +92,12 @@ XVisualInfo *fl_find_overlay_visual() { } } XFree((char*)overlayInfo); - // printf("overlay visual %d selected\n", fl_overlay_visual->visualid); + //printf("overlay visual %ld selected\n", fl_overlay_visual->visualid); return fl_overlay_visual; } #endif // -// End of "$Id: fl_overlay_visual.cxx,v 1.4.2.3 2001/01/22 15:13:41 easysw Exp $". +// End of "$Id: fl_overlay_visual.cxx,v 1.4.2.4 2001/05/05 23:39:01 spitzak Exp $". // diff --git a/test/input.cxx b/test/input.cxx index 56cc52d30..db65bfba5 100644 --- a/test/input.cxx +++ b/test/input.cxx @@ -1,5 +1,5 @@ // -// "$Id: input.cxx,v 1.5.2.3 2001/01/22 15:13:41 easysw Exp $" +// "$Id: input.cxx,v 1.5.2.4 2001/05/05 23:39:01 spitzak Exp $" // // Input field test program for the Fast Light Tool Kit (FLTK). // @@ -107,6 +107,7 @@ int main(int argc, char **argv) { b->color(input[0]->color()); b->callback(color_cb, (void*)0); b = new Fl_Button(220,y1,100,25,"selection_color"); y1 += 25; b->color(input[0]->selection_color()); b->callback(color_cb, (void*)1); + b->labelcolor(contrast(FL_BLACK,b->color())); b = new Fl_Button(220,y1,100,25,"textcolor"); y1 += 25; b->color(input[0]->textcolor()); b->callback(color_cb, (void*)2); b->labelcolor(contrast(FL_BLACK,b->color())); @@ -117,5 +118,5 @@ int main(int argc, char **argv) { } // -// End of "$Id: input.cxx,v 1.5.2.3 2001/01/22 15:13:41 easysw Exp $". +// End of "$Id: input.cxx,v 1.5.2.4 2001/05/05 23:39:01 spitzak Exp $". //