- AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) ,
- (long) wxTheApp , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) ,
- (long) wxTheApp , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) ,
- (long) wxTheApp , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) ,
- (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) ,
+ (long) wxTheApp , FALSE ) ;
- long theSystem ;
- long theMachine;
-
- if (Gestalt(gestaltMachineType, &theMachine) != noErr)
- {
- error = kMacSTRWrongMachine;
- }
- else if (theMachine < gestaltMacPlus)
- {
- error = kMacSTRWrongMachine;
- }
- else if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
- {
- error = kMacSTROldSystem ;
- }
- else if ( theSystem < 0x0750 )
- {
- error = kMacSTROldSystem ;
- }
- #if !TARGET_CARBON
- else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
- {
- error = kMacSTRSmallSize;
- }
- #endif
- /*
- else
- {
- if ( !UMAHasAppearance() )
- {
- error = kMacSTRNoPre8Yet ;
- }
- }
- */
+ #if !TARGET_CARBON
+ long theSystem ;
+ long theMachine;
+
+ if (Gestalt(gestaltMachineType, &theMachine) != noErr)
+ {
+ error = kMacSTRWrongMachine;
+ }
+ else if (theMachine < gestaltMacPlus)
+ {
+ error = kMacSTRWrongMachine;
+ }
+ else if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
+ {
+ error = kMacSTROldSystem ;
+ }
+ else if ( theSystem < 0x0750 )
+ {
+ error = kMacSTROldSystem ;
+ }
+ else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
+ {
+ error = kMacSTRSmallSize;
+ }
+ #endif
+ /*
+ else
+ {
+ if ( !UMAHasAppearance() )
+ {
+ error = kMacSTRNoPre8Yet ;
+ }
+ }
+ */
- if ( wxTheApp->OnInit() )
- {
- if ( enterLoop )
- {
- retValue = wxTheApp->OnRun();
- }
- else
- // We want to initialize, but not run or exit immediately.
- return 1;
- }
- //else: app initialization failed, so we skipped OnRun()
-
- wxWindow *topWindow = wxTheApp->GetTopWindow();
- if ( topWindow )
- {
- // Forcibly delete the window.
- if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
- topWindow->IsKindOf(CLASSINFO(wxDialog)) )
- {
- topWindow->Close(TRUE);
- wxTheApp->DeletePendingObjects();
- }
- else
- {
- delete topWindow;
- wxTheApp->SetTopWindow(NULL);
- }
- }
-
- wxTheApp->OnExit();
-
- wxApp::CleanUp();
-
- return retValue;
+ if ( wxTheApp->OnInit() )
+ {
+ if ( enterLoop )
+ {
+ retValue = wxTheApp->OnRun();
+ }
+ else
+ // We want to initialize, but not run or exit immediately.
+ return 1;
+ }
+ //else: app initialization failed, so we skipped OnRun()
+
+ wxWindow *topWindow = wxTheApp->GetTopWindow();
+ if ( topWindow )
+ {
+ // Forcibly delete the window.
+ if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
+ topWindow->IsKindOf(CLASSINFO(wxDialog)) )
+ {
+ topWindow->Close(TRUE);
+ wxTheApp->DeletePendingObjects();
+ }
+ else
+ {
+ delete topWindow;
+ wxTheApp->SetTopWindow(NULL);
+ }
+ }
+
+ wxTheApp->OnExit();
+
+ wxApp::CleanUp();
+
+ return retValue;
- m_macCurrentEvent = ev ;
-
- wxApp::sm_lastMessageTime = ev->when ;
-
- switch (ev->what)
- {
- case mouseDown:
- MacHandleMouseDownEvent( ev ) ;
- if ( ev->modifiers & controlKey )
- s_lastMouseDown = 2;
- else
- s_lastMouseDown = 1;
- break;
- case mouseUp:
- if ( s_lastMouseDown == 2 )
- {
- ev->modifiers |= controlKey ;
- }
- else
- {
- ev->modifiers &= ~controlKey ;
- }
- MacHandleMouseUpEvent( ev ) ;
- s_lastMouseDown = 0;
- break;
- case activateEvt:
- MacHandleActivateEvent( ev ) ;
- break;
- case updateEvt:
- MacHandleUpdateEvent( ev ) ;
- break;
- case keyDown:
- case autoKey:
- MacHandleKeyDownEvent( ev ) ;
- break;
- case keyUp:
- MacHandleKeyUpEvent( ev ) ;
- break;
- case diskEvt:
- MacHandleDiskEvent( ev ) ;
- break;
- case osEvt:
- MacHandleOSEvent( ev ) ;
- break;
- case kHighLevelEvent:
- MacHandleHighLevelEvent( ev ) ;
- break;
- default:
- break;
- }
- wxMacProcessNotifierAndPendingEvents() ;
+ m_macCurrentEvent = ev ;
+
+ wxApp::sm_lastMessageTime = ev->when ;
+
+ switch (ev->what)
+ {
+ case mouseDown:
+ MacHandleMouseDownEvent( ev ) ;
+ if ( ev->modifiers & controlKey )
+ s_lastMouseDown = 2;
+ else
+ s_lastMouseDown = 1;
+ break;
+ case mouseUp:
+ if ( s_lastMouseDown == 2 )
+ {
+ ev->modifiers |= controlKey ;
+ }
+ else
+ {
+ ev->modifiers &= ~controlKey ;
+ }
+ MacHandleMouseUpEvent( ev ) ;
+ s_lastMouseDown = 0;
+ break;
+ case activateEvt:
+ MacHandleActivateEvent( ev ) ;
+ break;
+ case updateEvt:
+ MacHandleUpdateEvent( ev ) ;
+ break;
+ case keyDown:
+ case autoKey:
+ MacHandleKeyDownEvent( ev ) ;
+ break;
+ case keyUp:
+ MacHandleKeyUpEvent( ev ) ;
+ break;
+ case diskEvt:
+ MacHandleDiskEvent( ev ) ;
+ break;
+ case osEvt:
+ MacHandleOSEvent( ev ) ;
+ break;
+ case kHighLevelEvent:
+ MacHandleHighLevelEvent( ev ) ;
+ break;
+ default:
+ break;
+ }
+ wxMacProcessNotifierAndPendingEvents() ;
- wxToolTip::RemoveToolTips() ;
-
- WindowRef window;
- WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
- WindowAttributes frontWindowAttributes = NULL ;
- if ( frontWindow )
- UMAGetWindowAttributes( frontWindow , &frontWindowAttributes ) ;
-
- short windowPart = ::FindWindow(ev->where, &window);
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
-
- BitMap screenBits;
- GetQDGlobalsScreenBits( &screenBits );
-
- switch (windowPart)
- {
- case inMenuBar :
- if ( s_macIsInModalLoop )
- {
- SysBeep ( 30 ) ;
- }
- else
- {
- UInt32 menuresult = MenuSelect(ev->where) ;
- MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) );
- s_lastMouseDown = 0;
- }
- break ;
+ wxToolTip::RemoveToolTips() ;
+
+ WindowRef window;
+ WindowRef frontWindow = UMAFrontNonFloatingWindow() ;
+ WindowAttributes frontWindowAttributes = NULL ;
+ if ( frontWindow )
+ UMAGetWindowAttributes( frontWindow , &frontWindowAttributes ) ;
+
+ short windowPart = ::FindWindow(ev->where, &window);
+ wxWindow* win = wxFindWinFromMacWindow( window ) ;
+ if ( wxPendingDelete.Member(win) )
+ return ;
+
+ BitMap screenBits;
+ GetQDGlobalsScreenBits( &screenBits );
+
+ switch (windowPart)
+ {
+ case inMenuBar :
+ if ( s_macIsInModalLoop )
+ {
+ SysBeep ( 30 ) ;
+ }
+ else
+ {
+ UInt32 menuresult = MenuSelect(ev->where) ;
+ MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) );
+ s_lastMouseDown = 0;
+ }
+ break ;
- case inDrag :
- if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
- {
- SysBeep ( 30 ) ;
- }
- else
- {
- DragWindow(window, ev->where, &screenBits.bounds);
- if (win)
- {
- GrafPtr port ;
- GetPort( &port ) ;
- Point pt = { 0, 0 } ;
- #if TARGET_CARBON
- SetPort( GetWindowPort(window) ) ;
- #else
- SetPort( (window) ) ;
- #endif
- SetOrigin( 0 , 0 ) ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
- win->SetSize( pt.h , pt.v , -1 ,
- -1 , wxSIZE_USE_EXISTING);
- }
- s_lastMouseDown = 0;
- }
- break ;
- case inGoAway:
- if (TrackGoAway(window, ev->where))
- {
- if ( win )
- win->Close() ;
- }
- s_lastMouseDown = 0;
- break;
- case inGrow:
- {
- int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
- if (growResult != 0)
- {
- int newWidth = LoWord(growResult);
- int newHeight = HiWord(growResult);
- int oldWidth, oldHeight;
-
-
- if (win)
- {
- win->GetSize(&oldWidth, &oldHeight);
- if (newWidth == 0)
- newWidth = oldWidth;
- if (newHeight == 0)
- newHeight = oldHeight;
- win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING);
- }
- }
- s_lastMouseDown = 0;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(window, ev->where, windowPart))
- {
- // TODO setup size event
- ZoomWindow( window , windowPart , false ) ;
- if (win)
- {
- Rect tempRect ;
-
- GetWindowPortBounds(window, &tempRect ) ;
- win->SetSize( -1, -1, tempRect.right-tempRect.left ,
- tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
- }
- }
- s_lastMouseDown = 0;
- break;
- case inCollapseBox :
- // TODO setup size event
- s_lastMouseDown = 0;
- break ;
-
- case inContent :
- {
- GrafPtr port ;
- GetPort( &port ) ;
- #if TARGET_CARBON
- SetPort( GetWindowPort(window) ) ;
- #else
- SetPort( (window) ) ;
- #endif
- SetOrigin( 0 , 0 ) ;
- SetPort( port ) ;
- }
- if ( window != frontWindow )
- {
- if ( s_macIsInModalLoop )
- {
- SysBeep ( 30 ) ;
- }
- else if ( UMAIsWindowFloating( window ) )
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- else
- {
- UMASelectWindow( window ) ;
- }
- }
- else
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- break ;
-
- default:
- break;
- }
+ case inDrag :
+ if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
+ {
+ SysBeep ( 30 ) ;
+ }
+ else
+ {
+ DragWindow(window, ev->where, &screenBits.bounds);
+ if (win)
+ {
+ GrafPtr port ;
+ GetPort( &port ) ;
+ Point pt = { 0, 0 } ;
+ #if TARGET_CARBON
+ SetPort( GetWindowPort(window) ) ;
+ #else
+ SetPort( (window) ) ;
+ #endif
+ SetOrigin( 0 , 0 ) ;
+ LocalToGlobal( &pt ) ;
+ SetPort( port ) ;
+ win->SetSize( pt.h , pt.v , -1 ,
+ -1 , wxSIZE_USE_EXISTING);
+ }
+ s_lastMouseDown = 0;
+ }
+ break ;
+ case inGoAway:
+ if (TrackGoAway(window, ev->where))
+ {
+ if ( win )
+ win->Close() ;
+ }
+ s_lastMouseDown = 0;
+ break;
+ case inGrow:
+ {
+ int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
+ if (growResult != 0)
+ {
+ int newWidth = LoWord(growResult);
+ int newHeight = HiWord(growResult);
+ int oldWidth, oldHeight;
+
+
+ if (win)
+ {
+ win->GetSize(&oldWidth, &oldHeight);
+ if (newWidth == 0)
+ newWidth = oldWidth;
+ if (newHeight == 0)
+ newHeight = oldHeight;
+ win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING);
+ }
+ }
+ s_lastMouseDown = 0;
+ }
+ break;
+ case inZoomIn:
+ case inZoomOut:
+ if (TrackBox(window, ev->where, windowPart))
+ {
+ // TODO setup size event
+ ZoomWindow( window , windowPart , false ) ;
+ if (win)
+ {
+ Rect tempRect ;
+
+ GetWindowPortBounds(window, &tempRect ) ;
+ win->SetSize( -1, -1, tempRect.right-tempRect.left ,
+ tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
+ }
+ }
+ s_lastMouseDown = 0;
+ break;
+ case inCollapseBox :
+ // TODO setup size event
+ s_lastMouseDown = 0;
+ break ;
+
+ case inContent :
+ {
+ GrafPtr port ;
+ GetPort( &port ) ;
+ #if TARGET_CARBON
+ SetPort( GetWindowPort(window) ) ;
+ #else
+ SetPort( (window) ) ;
+ #endif
+ SetOrigin( 0 , 0 ) ;
+ SetPort( port ) ;
+ }
+ if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
+ {
+ if ( s_macIsInModalLoop )
+ {
+ SysBeep ( 30 ) ;
+ }
+ else if ( UMAIsWindowFloating( window ) )
+ {
+ if ( win )
+ win->MacMouseDown( ev , windowPart ) ;
+ }
+ else
+ {
+ if ( win )
+ win->MacMouseDown( ev , windowPart ) ;
+ UMASelectWindow( window ) ;
+ }
+ }
+ else
+ {
+ if ( win )
+ win->MacMouseDown( ev , windowPart ) ;
+ }
+ break ;
+
+ default:
+ break;
+ }
- wxToolTip::RemoveToolTips() ;
-
- UInt32 menuresult = UMAMenuEvent(ev) ;
- if ( HiWord( menuresult ) )
- {
- if ( !s_macIsInModalLoop )
- MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
- }
- else
- {
- short keycode ;
- short keychar ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
-
- wxWindow* focus = wxWindow::FindFocus() ;
- if ( focus )
- {
- long keyval = wxMacTranslateKey(keychar, keycode) ;
-
- wxKeyEvent event(wxEVT_KEY_DOWN);
- event.m_shiftDown = ev->modifiers & shiftKey;
- event.m_controlDown = ev->modifiers & controlKey;
- event.m_altDown = ev->modifiers & optionKey;
- event.m_metaDown = ev->modifiers & cmdKey;
- event.m_keyCode = keyval;
- event.m_x = ev->where.h;
- event.m_y = ev->where.v;
- event.m_timeStamp = ev->when;
- event.SetEventObject(focus);
- bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
- if ( !handled )
- {
- #if wxUSE_ACCEL
- if (!handled)
- {
- wxWindow *ancestor = focus;
- /*
- while (ancestor)
- {
- int command = ancestor->GetAcceleratorTable()->GetCommand( event );
- if (command != -1)
- {
- wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
- handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
- break;
- }
- if (ancestor->m_isFrame)
- break;
- ancestor = ancestor->GetParent();
- }
- */
- }
- #endif // wxUSE_ACCEL
- }
- if (!handled)
- {
- wxKeyEvent event(wxEVT_CHAR);
- event.m_shiftDown = ev->modifiers & shiftKey;
- event.m_controlDown = ev->modifiers & controlKey;
- event.m_altDown = ev->modifiers & optionKey;
- event.m_metaDown = ev->modifiers & cmdKey;
- event.m_keyCode = keyval;
- event.m_x = ev->where.h;
- event.m_y = ev->where.v;
- event.m_timeStamp = ev->when;
- event.SetEventObject(focus);
- handled = focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( !handled &&
- (keyval == WXK_TAB) &&
- (!focus->HasFlag(wxTE_PROCESS_TAB)) &&
- (focus->GetParent()) &&
- (focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
- {
- wxNavigationKeyEvent new_event;
- new_event.SetEventObject( focus );
- new_event.SetDirection( !event.ShiftDown() );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
- new_event.SetWindowChange( event.ControlDown() );
- new_event.SetCurrentFocus( focus );
- handled = focus->GetEventHandler()->ProcessEvent( new_event );
- }
- /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
- if ( (!handled) &&
- (keyval == '.' && event.ControlDown() ) )
- {
- wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
- new_event.SetEventObject( focus );
- handled = focus->GetEventHandler()->ProcessEvent( new_event );
- }
- }
- }
+ wxToolTip::RemoveToolTips() ;
+
+ UInt32 menuresult = UMAMenuEvent(ev) ;
+ if ( HiWord( menuresult ) )
+ {
+ if ( !s_macIsInModalLoop )
+ MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
+ }
+ else
+ {
+ short keycode ;
+ short keychar ;
+ keychar = short(ev->message & charCodeMask);
+ keycode = short(ev->message & keyCodeMask) >> 8 ;
+
+ wxWindow* focus = wxWindow::FindFocus() ;
+ if ( focus )
+ {
+ long keyval = wxMacTranslateKey(keychar, keycode) ;
+
+ wxKeyEvent event(wxEVT_KEY_DOWN);
+ event.m_shiftDown = ev->modifiers & shiftKey;
+ event.m_controlDown = ev->modifiers & controlKey;
+ event.m_altDown = ev->modifiers & optionKey;
+ event.m_metaDown = ev->modifiers & cmdKey;
+ event.m_keyCode = keyval;
+ event.m_x = ev->where.h;
+ event.m_y = ev->where.v;
+ event.m_timeStamp = ev->when;
+ event.SetEventObject(focus);
+ bool handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+ if ( !handled )
+ {
+ #if wxUSE_ACCEL
+ if (!handled)
+ {
+ wxWindow *ancestor = focus;
+ /*
+ while (ancestor)
+ {
+ int command = ancestor->GetAcceleratorTable()->GetCommand( event );
+ if (command != -1)
+ {
+ wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
+ handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
+ break;
+ }
+ if (ancestor->m_isFrame)
+ break;
+ ancestor = ancestor->GetParent();
+ }
+ */
+ }
+ #endif // wxUSE_ACCEL
+ }
+ if (!handled)
+ {
+ wxKeyEvent event(wxEVT_CHAR);
+ event.m_shiftDown = ev->modifiers & shiftKey;
+ event.m_controlDown = ev->modifiers & controlKey;
+ event.m_altDown = ev->modifiers & optionKey;
+ event.m_metaDown = ev->modifiers & cmdKey;
+ event.m_keyCode = keyval;
+ event.m_x = ev->where.h;
+ event.m_y = ev->where.v;
+ event.m_timeStamp = ev->when;
+ event.SetEventObject(focus);
+ handled = focus->GetEventHandler()->ProcessEvent( event ) ;
+ }
+ if ( !handled &&
+ (keyval == WXK_TAB) &&
+ (!focus->HasFlag(wxTE_PROCESS_TAB)) &&
+ (focus->GetParent()) &&
+ (focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
+ {
+ wxNavigationKeyEvent new_event;
+ new_event.SetEventObject( focus );
+ new_event.SetDirection( !event.ShiftDown() );
+ /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
+ new_event.SetWindowChange( event.ControlDown() );
+ new_event.SetCurrentFocus( focus );
+ handled = focus->GetEventHandler()->ProcessEvent( new_event );
+ }
+ /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
+ if ( (!handled) &&
+ (keyval == '.' && event.ControlDown() ) )
+ {
+ wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
+ new_event.SetEventObject( focus );
+ handled = focus->GetEventHandler()->ProcessEvent( new_event );
+ }
+ }
+ }
- bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
- if ( isResuming )
- {
- WindowRef oldFrontWindow = NULL ;
- WindowRef newFrontWindow = NULL ;
-
- // in case we don't take care of activating ourselves, we have to synchronize
- // our idea of the active window with the process manager's - which it already activated
-
- if ( !doesActivate )
- oldFrontWindow = UMAFrontNonFloatingWindow() ;
-
- MacResume( convertClipboard ) ;
-
- newFrontWindow = UMAFrontNonFloatingWindow() ;
-
- if ( oldFrontWindow )
- {
- wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ;
- if ( win )
- win->MacActivate( ev , false ) ;
- }
- if ( newFrontWindow )
- {
- wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ;
- if ( win )
- win->MacActivate( ev , true ) ;
- }
- }
- else
- {
- MacSuspend( convertClipboard ) ;
-
- // in case this suspending did close an active window, another one might
- // have surfaced -> lets deactivate that one
-
- WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ;
- if ( newActiveWindow )
- {
- wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
- if ( win )
- win->MacActivate( ev , false ) ;
- }
- }
- }
- break ;
- case mouseMovedMessage :
- {
- WindowRef window;
-
- wxWindow* currentMouseWindow = NULL ;
-
- wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
- ¤tMouseWindow ) ;
-
- if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent event ;
-
- bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
- bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
-
- event.m_leftDown = isDown && !controlDown;
- event.m_middleDown = FALSE;
- event.m_rightDown = isDown && controlDown;
- event.m_shiftDown = ev->modifiers & shiftKey;
- event.m_controlDown = ev->modifiers & controlKey;
- event.m_altDown = ev->modifiers & optionKey;
- event.m_metaDown = ev->modifiers & cmdKey;
- event.m_x = ev->where.h;
- event.m_y = ev->where.v;
- event.m_timeStamp = ev->when;
- event.SetEventObject(this);
-
- if ( wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent eventleave(event ) ;
- eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ;
- wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
- }
- if ( currentMouseWindow )
- {
- wxMouseEvent evententer(event ) ;
- evententer.SetEventType( wxEVT_ENTER_WINDOW ) ;
- currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
- }
- wxWindow::s_lastMouseWindow = currentMouseWindow ;
- }
-
- short windowPart = ::FindWindow(ev->where, &window);
-
- switch (windowPart)
- {
- // fixes for setting the cursor back from dominic mazzoni
- case inMenuBar :
- UMAShowArrowCursor();
- break ;
- case inSysWindow :
- UMAShowArrowCursor();
- break ;
- default:
- {
- if ( s_lastMouseDown == 0 )
- ev->modifiers |= btnState ;
-
- wxWindow* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacMouseMoved( ev , windowPart ) ;
- else
- UMAShowArrowCursor();
-
- }
- break;
- }
- }
- break ;
-
- }
+ bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
+ if ( isResuming )
+ {
+ WindowRef oldFrontWindow = NULL ;
+ WindowRef newFrontWindow = NULL ;
+
+ // in case we don't take care of activating ourselves, we have to synchronize
+ // our idea of the active window with the process manager's - which it already activated
+
+ if ( !doesActivate )
+ oldFrontWindow = UMAFrontNonFloatingWindow() ;
+
+ MacResume( convertClipboard ) ;
+
+ newFrontWindow = UMAFrontNonFloatingWindow() ;
+
+ if ( oldFrontWindow )
+ {
+ wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ;
+ if ( win )
+ win->MacActivate( ev , false ) ;
+ }
+ if ( newFrontWindow )
+ {
+ wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ;
+ if ( win )
+ win->MacActivate( ev , true ) ;
+ }
+ }
+ else
+ {
+ MacSuspend( convertClipboard ) ;
+
+ // in case this suspending did close an active window, another one might
+ // have surfaced -> lets deactivate that one
+
+ WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ;
+ if ( newActiveWindow )
+ {
+ wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ;
+ if ( win )
+ win->MacActivate( ev , false ) ;
+ }
+ }
+ }
+ break ;
+ case mouseMovedMessage :
+ {
+ WindowRef window;
+
+ wxWindow* currentMouseWindow = NULL ;
+
+ wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
+ ¤tMouseWindow ) ;
+
+ if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
+ {
+ wxMouseEvent event ;
+
+ bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
+ bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
+
+ event.m_leftDown = isDown && !controlDown;
+ event.m_middleDown = FALSE;
+ event.m_rightDown = isDown && controlDown;
+ event.m_shiftDown = ev->modifiers & shiftKey;
+ event.m_controlDown = ev->modifiers & controlKey;
+ event.m_altDown = ev->modifiers & optionKey;
+ event.m_metaDown = ev->modifiers & cmdKey;
+ event.m_x = ev->where.h;
+ event.m_y = ev->where.v;
+ event.m_timeStamp = ev->when;
+ event.SetEventObject(this);
+
+ if ( wxWindow::s_lastMouseWindow )
+ {
+ wxMouseEvent eventleave(event ) ;
+ eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ;
+ wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
+ }
+ if ( currentMouseWindow )
+ {
+ wxMouseEvent evententer(event ) ;
+ evententer.SetEventType( wxEVT_ENTER_WINDOW ) ;
+ currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
+ }
+ wxWindow::s_lastMouseWindow = currentMouseWindow ;
+ }
+
+ short windowPart = ::FindWindow(ev->where, &window);
+
+ switch (windowPart)
+ {
+ // fixes for setting the cursor back from dominic mazzoni
+ case inMenuBar :
+ UMAShowArrowCursor();
+ break ;
+ case inSysWindow :
+ UMAShowArrowCursor();
+ break ;
+ default:
+ {
+ if ( s_lastMouseDown == 0 )
+ ev->modifiers |= btnState ;
+
+ wxWindow* win = wxFindWinFromMacWindow( window ) ;
+ if ( win )
+ win->MacMouseMoved( ev , windowPart ) ;
+ else
+ UMAShowArrowCursor();
+
+ }
+ break;
+ }
+ }
+ break ;
+
+ }
- if (macMenuId == 0)
- return; // no menu item selected
-
- if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1)
- {
- #if ! TARGET_CARBON
- Str255 deskAccessoryName ;
- GrafPtr savedPort ;
-
- GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName);
- GetPort(&savedPort);
- OpenDeskAcc(deskAccessoryName);
- SetPort(savedPort);
- #endif
- }
- else
- {
- wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
- if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
- wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
- }
- HiliteMenu(0);
+ if (macMenuId == 0)
+ return; // no menu item selected
+
+ if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1)
+ {
+ #if ! TARGET_CARBON
+ Str255 deskAccessoryName ;
+ GrafPtr savedPort ;
+
+ GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName);
+ GetPort(&savedPort);
+ OpenDeskAcc(deskAccessoryName);
+ SetPort(savedPort);
+ #endif
+ }
+ else
+ {
+ wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
+ if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
+ wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
+ }
+ HiliteMenu(0);