Updated OSX subwindow simulation code to better add and remove from the clipping list

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5379 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2006-08-29 11:03:05 +00:00
parent 00ec9da8f5
commit 7ae0ff0240
6 changed files with 94 additions and 42 deletions

View File

@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.8
- Improved Mac OS X subwindow handling (STR #1402)
- Fixed more inconsistencies between fl_draw
and fl_measure (STR #1408)
- Fixed fl_measure which mistook a trailing '@@'

View File

@ -54,10 +54,6 @@ inline void XDestroyRegion(Fl_Region r) {
DisposeRgn(r);
}
# define XDestroyWindow(a,b) DisposeWindow(b)
# define XMapWindow(a,b) ShowWindow(b)
# define XUnmapWindow(a,b) HideWindow(b)
# include "Fl_Window.H"
// This object contains all mac-specific stuff about a window:
@ -90,6 +86,11 @@ public:
static void q_end_image();
};
extern void MacDestroyWindow(Fl_Window*,WindowPtr);
extern void MacMapWindow(Fl_Window*,WindowPtr);
extern void MacUnmapWindow(Fl_Window*,WindowPtr);
extern int MacUnlinkWindow(Fl_X*,Fl_X*start=0L);
inline Window fl_xid(const Fl_Window*w)
{
return Fl_X::i(w)->xid;

View File

@ -881,23 +881,9 @@ void Fl_Window::hide() {
Fl_X** pp = &Fl_X::first;
for (; *pp != ip; pp = &(*pp)->next) if (!*pp) return;
*pp = ip->next;
#ifdef __APPLE_QD__
// remove all childwindow links
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next )
{
if ( pc->xidNext == ip ) pc->xidNext = ip->xidNext;
if ( pc->xidChildren == ip ) pc->xidChildren = ip->xidNext;
}
#elif defined(__APPLE_QUARTZ__)
// remove all childwindow links
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next )
{
if ( pc->xidNext == ip ) pc->xidNext = ip->xidNext;
if ( pc->xidChildren == ip ) pc->xidChildren = ip->xidNext;
}
#endif // __APPLE__
#ifdef __APPLE__
MacUnlinkWindow(ip);
#endif
i = 0;
// recursively remove any subwindows:
@ -941,11 +927,11 @@ void Fl_Window::hide() {
fl_gc = 0;
}
#elif defined(__APPLE_QD__)
if ( ip->xid == fl_window )
if ( ip->xid == fl_window && !parent() )
fl_window = 0;
#elif defined(__APPLE_QUARTZ__)
Fl_X::q_release_context(ip);
if ( ip->xid == fl_window )
if ( ip->xid == fl_window && !parent() )
fl_window = 0;
#endif
@ -960,19 +946,9 @@ void Fl_Window::hide() {
}
XDestroyWindow(fl_display, ip->xid);
#elif defined(__APPLE_QD__)
if ( !parent() ) // don't destroy shared windows!
{
//+ RemoveTrackingHandler( dndTrackingHandler, ip->xid );
//+ RemoveReceiveHandler( dndReceiveHandler, ip->xid );
XDestroyWindow(fl_display, ip->xid);
}
MacDestroyWindow(this, ip->xid);
#elif defined(__APPLE_QUARTZ__)
if ( !parent() ) // don't destroy shared windows!
{
//+ RemoveTrackingHandler( dndTrackingHandler, ip->xid );
//+ RemoveReceiveHandler( dndReceiveHandler, ip->xid );
XDestroyWindow(fl_display, ip->xid);
}
MacDestroyWindow(this, ip->xid);
#else
# if USE_XFT
fl_destroy_xft_draw(ip->xid);
@ -1006,7 +982,15 @@ int Fl_Window::handle(int ev)
switch (ev) {
case FL_SHOW:
if (!shown()) show();
else XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
else {
#ifdef __APPLE_QD__
MacMapWindow(this, fl_xid(this));
#elif defined(__APPLE_QUARTZ__)
MacMapWindow(this, fl_xid(this));
#else
XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
#endif // __APPLE__
}
break;
case FL_HIDE:
if (shown()) {
@ -1022,9 +1006,9 @@ int Fl_Window::handle(int ev)
if (p->type() >= FL_WINDOW) break; // don't do the unmap
}
#ifdef __APPLE_QD__
hide();
MacUnmapWindow(this, fl_xid(this));
#elif defined(__APPLE_QUARTZ__)
hide();
MacUnmapWindow(this, fl_xid(this));
#else
XUnmapWindow(fl_display, fl_xid(this));
#endif // __APPLE__

View File

@ -247,7 +247,6 @@ char Fl_Preferences::set( const char *key, float value )
{
sprintf( nameBuffer, "%g", value );
node->set( key, nameBuffer );
float v1 = atof(nameBuffer);
return 1;
}
@ -259,7 +258,6 @@ char Fl_Preferences::set( const char *key, float value, int precision )
{
sprintf( nameBuffer, "%.*g", precision, value );
node->set( key, nameBuffer );
float v1 = atof(nameBuffer);
return 1;
}

View File

@ -2321,7 +2321,67 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data)
}
}
int MacUnlinkWindow(Fl_X *ip, Fl_X *start) {
if (!ip) return 0;
if (start) {
Fl_X *pc = start;
while (pc) {
if (pc->xidNext == ip) {
pc->xidNext = ip->xidNext;
return 1;
}
if (pc->xidChildren) {
if (pc->xidChildren == ip) {
pc->xidChildren = ip->xidNext;
return 1;
}
if (MacUnlinkWindow(ip, pc->xidChildren))
return 1;
}
pc = pc->xidNext;
}
} else {
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next ) {
if (MacUnlinkWindow(ip, pc))
return 1;
}
}
return 0;
}
static void MacRelinkWindow(Fl_X *x, Fl_X *p) {
if (!x || !p) return;
// first, check if 'x' is already registered as a child of 'p'
for (Fl_X *i = p->xidChildren; i; i=i->xidNext) {
if (i == x) return;
}
// now add 'x' as the first child of 'p'
x->xidNext = p->xidChildren;
p->xidChildren = x;
}
void MacDestroyWindow(Fl_Window *w, WindowPtr p) {
MacUnmapWindow(w, p);
if (w && !w->parent() && p)
DisposeWindow(p);
}
void MacMapWindow(Fl_Window *w, WindowPtr p) {
if (w && p)
ShowWindow(p);
//+ link to window list
if (w && w->parent()) {
MacRelinkWindow(Fl_X::i(w), Fl_X::i(w->window()));
w->redraw();
}
}
void MacUnmapWindow(Fl_Window *w, WindowPtr p) {
if (w && !w->parent() && p)
HideWindow(p);
if (w && Fl_X::i(w))
MacUnlinkWindow(Fl_X::i(w));
}
//
// End of "$Id$".

View File

@ -103,9 +103,17 @@ Function {} {open
label {Make sure this clock does not use processor time when this tab is hidden or window is iconized}
xywh {160 50 100 100} box OSHADOW_BOX color 238 selection_color 0 labelfont 8 labelsize 10 align 130
}
Fl_Group {} {open
xywh {20 145 40 55} box THIN_DOWN_BOX color 173 align 16
class Fl_Window
} {}
Fl_Group {} {
label subwindow open
xywh {20 135 130 65} box THIN_DOWN_BOX color 167 align 16
label {subwindows:} open
xywh {65 145 40 55} box THIN_DOWN_BOX color 167
class Fl_Window
} {}
Fl_Group {} {open
xywh {110 145 40 55} box THIN_DOWN_BOX color 239 align 16
class Fl_Window
} {}
}