fix event handling a bit

This commit is contained in:
David Rose 2006-11-02 03:03:32 +00:00
parent 285622c36f
commit 2cfec74ada

View File

@ -188,6 +188,9 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) {
SystemSetWindowForground(true); SystemSetWindowForground(true);
DoResize(); DoResize();
break; break;
case kEventWindowDeactivated:
SystemSetWindowForground(false);
break;
case kEventWindowClose: // called when window is being closed (close box) case kEventWindowClose: // called when window is being closed (close box)
// This is a message from the window manager indicating that // This is a message from the window manager indicating that
// the user has requested to close the window. // the user has requested to close the window.
@ -201,8 +204,21 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) {
case kEventWindowBoundsChanged: // called for resize and moves (drag) case kEventWindowBoundsChanged: // called for resize and moves (drag)
DoResize(); DoResize();
break; break;
case kEventWindowZoomed: // called when user clicks on zoom button (occurs after the window has been zoomed) case kEventWindowZoomed:
// use this if you need to some special here as you always get a kEventWindowBoundsChanged event break;
case kEventWindowCollapsed:
{
WindowProperties properties;
properties.set_minimized(true);
system_changed_properties(properties);
}
break;
case kEventWindowExpanded:
{
WindowProperties properties;
properties.set_minimized(false);
system_changed_properties(properties);
}
break; break;
} }
break; break;
@ -264,10 +280,12 @@ windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void *userData) {
if (window != NULL) { if (window != NULL) {
osxGraphicsWindow *osx_win = osxGraphicsWindow::GetCurrentOSxWindow(window); osxGraphicsWindow *osx_win = osxGraphicsWindow::GetCurrentOSxWindow(window);
return osx_win->event_handler(myHandler, event); if (osx_win != (osxGraphicsWindow *)NULL) {
} else { return osx_win->event_handler(myHandler, event);
return eventNotHandledErr; }
} }
return eventNotHandledErr;
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -514,10 +532,16 @@ osxGraphicsWindow(GraphicsPipe *pipe,
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
osxGraphicsWindow::~osxGraphicsWindow() osxGraphicsWindow::~osxGraphicsWindow()
{ {
if (osxdisplay_cat.is_debug()) if (osxdisplay_cat.is_debug())
osxdisplay_cat.debug() << "osxGraphicsWindow::~osxGraphicsWindow() -" <<_ID << "\n"; osxdisplay_cat.debug() << "osxGraphicsWindow::~osxGraphicsWindow() -" <<_ID << "\n";
ReleaseSystemResources(); // Make sure the window callback won't come back to this
// (destructed) object any more.
if (_osx_window) {
SetWRefCon (_osx_window, (long) NULL);
}
ReleaseSystemResources();
} }
@ -992,8 +1016,8 @@ bool osxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties )
//{ kEventClassWindow, kEventWindowHidden }, //{ kEventClassWindow, kEventWindowHidden },
//{ kEventClassWindow, kEventWindowCollapse }, //{ kEventClassWindow, kEventWindowCollapse },
//{ kEventClassWindow, kEventWindowCollapsed }, { kEventClassWindow, kEventWindowCollapsed },
//{ kEventClassWindow, kEventWindowExpanded }, { kEventClassWindow, kEventWindowExpanded },
{ kEventClassWindow, kEventWindowZoomed }, { kEventClassWindow, kEventWindowZoomed },
//{ kEventClassWindow, kEventWindowDragStarted }, //{ kEventClassWindow, kEventWindowDragStarted },
//{ kEventClassWindow, kEventWindowDragCompleted }, //{ kEventClassWindow, kEventWindowDragCompleted },