From 421904a7c1a35cd546b794daf80edfa0420a9dd0 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sat, 11 Sep 2004 19:32:43 +0000 Subject: Fixed problems with 2-byte Xpm files on 64-bit platforms (STR #525) FLTK didn't handle the ReparentNotify event on X11 (STR #524) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3819 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_x.cxx | 19 ++++++++++++-- src/fl_draw_pixmap.cxx | 68 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 62 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 60567aa53..a3ba4e83b 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_x.cxx,v 1.24.2.24.2.37 2004/06/01 01:08:50 easysw Exp $" +// "$Id: Fl_x.cxx,v 1.24.2.24.2.38 2004/09/11 19:32:43 easysw Exp $" // // X specific code for the Fast Light Tool Kit (FLTK). // @@ -912,6 +912,21 @@ int fl_handle(const XEvent& thisevent) window->resize(X, Y, W, H); break; // allow add_handler to do something too } + + case ReparentNotify: { + int xpos, ypos; + Window junk; + + //ReparentNotify gives the new position of the window relative to + //the new parent. FLTK cares about the position on the root window. + XTranslateCoordinates(fl_display, xevent.xreparent.parent, + XRootWindow(fl_display, fl_screen), + xevent.xreparent.x, xevent.xreparent.y, + &xpos, &ypos, &junk); + + window->position(xpos, ypos); + break; + } } return Fl::handle(event, window); @@ -1279,5 +1294,5 @@ void Fl_Window::make_current() { #endif // -// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.37 2004/06/01 01:08:50 easysw Exp $". +// End of "$Id: Fl_x.cxx,v 1.24.2.24.2.38 2004/09/11 19:32:43 easysw Exp $". // diff --git a/src/fl_draw_pixmap.cxx b/src/fl_draw_pixmap.cxx index 6298d035c..23d2e31f6 100644 --- a/src/fl_draw_pixmap.cxx +++ b/src/fl_draw_pixmap.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.15 2004/08/31 22:00:48 matthiaswm Exp $" +// "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.16 2004/09/11 19:32:43 easysw Exp $" // // Pixmap drawing code for the Fast Light Tool Kit (FLTK). // @@ -69,12 +69,20 @@ static void cb1(void*v, int x, int y, int w, uchar* buf) { pixmap_data& d = *(pixmap_data*)v; const uchar* p = d.data[y]+x; U64* q = (U64*)buf; - for (int X=(w+1)/2; X--; p += 2) { + for (int X=w; X>0; X-=2, p += 2) { + if (X>1) { # if WORDS_BIGENDIAN - *q++ = (d.colors[p[0]]<<32) | d.colors[p[1]]; + *q++ = (d.colors[p[0]]<<32) | d.colors[p[1]]; # else - *q++ = (d.colors[p[1]]<<32) | d.colors[p[0]]; + *q++ = (d.colors[p[1]]<<32) | d.colors[p[0]]; # endif + } else { +# if WORDS_BIGENDIAN + *q++ = d.colors[p[0]]<<32; +# else + *q++ = d.colors[p[0]]; +# endif + } } } @@ -83,20 +91,28 @@ static void cb2(void*v, int x, int y, int w, uchar* buf) { pixmap_data& d = *(pixmap_data*)v; const uchar* p = d.data[y]+2*x; U64* q = (U64*)buf; - for (int X=(w+1)/2; X--;) { + for (int X=w; X>0; X-=2) { U64* colors = d.byte1[*p++]; int index = *p++; - U64* colors1 = d.byte1[*p++]; - int index1 = *p++; + if (X>1) { + U64* colors1 = d.byte1[*p++]; + int index1 = *p++; +# if WORDS_BIGENDIAN + *q++ = (colors[index]<<32) | colors1[index1]; +# else + *q++ = (colors1[index1]<<32) | colors[index]; +# endif + } else { # if WORDS_BIGENDIAN - *q++ = (colors[index]<<32) | colors1[index1]; + *q++ = colors[index]<<32; # else - *q++ = (colors1[index1]<<32) | colors[index]; + *q++ = colors[index]; # endif + } } } -#else +#else // U32 // The callback from fl_draw_image to get a row of data passes this: struct pixmap_data { @@ -108,7 +124,7 @@ struct pixmap_data { }; }; -#ifndef __APPLE_QUARTZ__ +# ifndef __APPLE_QUARTZ__ // callback for 1 byte per pixel: static void cb1(void*v, int x, int y, int w, uchar* buf) { @@ -129,9 +145,9 @@ static void cb2(void*v, int x, int y, int w, uchar* buf) { } } -#endif +# endif // !__APPLE_QUARTZ__ -#endif +#endif // U64 else U32 uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here @@ -197,7 +213,7 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) { if (!colors) colors = d.byte1[ind] = new U32[256]; #endif c = (uchar*)&colors[*p]; - ind = (ind<<8)+*p++; + ind = (ind<<8)|*p++; } else { c = (uchar *)&d.colors[ind]; } @@ -257,15 +273,21 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) { *bitmap++ = b; } } else { - for (int X = 0; X < W; X++) { - uchar b = 0; - for (int i = 0; i < 8; i++) { - int ind = *p++; - ind = (ind<<8) | (*p++); - if (ind != transparent_index) b |= (1< 1) *bitmap++ = b; } } } @@ -305,12 +327,12 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) { CGImageRelease(img); delete array; -#endif // __APPLE_QUARTZ__ +#endif // !__APPLE_QUARTZ__ if (chars_per_pixel > 1) for (int i = 0; i < 256; i++) delete[] d.byte1[i]; return 1; } // -// End of "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.15 2004/08/31 22:00:48 matthiaswm Exp $". +// End of "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.16 2004/09/11 19:32:43 easysw Exp $". // -- cgit v1.2.3