Revision: 23737 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23737 Author: damien78 Date: 2009-10-09 14:48:28 +0200 (Fri, 09 Oct 2009)
Log Message: ----------- Cocoa port : - Fullscreen mode is back! - Cleaner fix for tablet events handling Modified Paths: -------------- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h =================================================================== --- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h 2009-10-09 12:47:25 UTC (rev 23736) +++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h 2009-10-09 12:48:28 UTC (rev 23737) @@ -210,9 +210,10 @@ /** * Handles a tablet event. * @param eventPtr An NSEvent pointer (casted to void* to enable compilation in standard C++) + * @param eventType The type of the event. It needs to be passed separately as it can be either directly in the event type, or as a subtype if combined with a mouse button event * @return Indication whether the event was handled. */ - GHOST_TSuccess handleTabletEvent(void *eventPtr); + GHOST_TSuccess handleTabletEvent(void *eventPtr, short eventType); /** * Handles a mouse event. Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm =================================================================== --- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm 2009-10-09 12:47:25 UTC (rev 23736) +++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm 2009-10-09 12:48:28 UTC (rev 23737) @@ -51,44 +51,7 @@ #pragma mark KeyMap, mouse converters -//TODO: remove (kept as reminder to implement window events) -/* -const EventTypeSpec kEvents[] = -{ - { kEventClassAppleEvent, kEventAppleEvent }, -// { kEventClassApplication, kEventAppActivated }, -// { kEventClassApplication, kEventAppDeactivated }, - - { kEventClassKeyboard, kEventRawKeyDown }, - { kEventClassKeyboard, kEventRawKeyRepeat }, - { kEventClassKeyboard, kEventRawKeyUp }, - { kEventClassKeyboard, kEventRawKeyModifiersChanged }, - - { kEventClassMouse, kEventMouseDown }, - { kEventClassMouse, kEventMouseUp }, - { kEventClassMouse, kEventMouseMoved }, - { kEventClassMouse, kEventMouseDragged }, - { kEventClassMouse, kEventMouseWheelMoved }, - - { kEventClassWindow, kEventWindowClickZoomRgn } , // for new zoom behaviour - { kEventClassWindow, kEventWindowZoom }, // for new zoom behaviour - { kEventClassWindow, kEventWindowExpand } , // for new zoom behaviour - { kEventClassWindow, kEventWindowExpandAll }, // for new zoom behaviour - - { kEventClassWindow, kEventWindowClose }, - { kEventClassWindow, kEventWindowActivated }, - { kEventClassWindow, kEventWindowDeactivated }, - { kEventClassWindow, kEventWindowUpdate }, - { kEventClassWindow, kEventWindowBoundsChanged }, - - { kEventClassBlender, kEventBlenderNdofAxis }, - { kEventClassBlender, kEventBlenderNdofButtons } - - - -};*/ - /* Keycodes from Carbon include file */ /* * Summary: @@ -701,25 +664,6 @@ } [pool drain]; - - /* - * Initialize the cursor to the standard arrow shape (so that we can change it later on). - * This initializes the cursor's visibility counter to 0. - */ - /*::InitCursor(); - - MenuRef windMenu; - ::CreateStandardWindowMenu(0, &windMenu); - ::InsertMenu(windMenu, 0); - ::DrawMenuBar(); - - ::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler); - - ::AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, sAEHandlerLaunch, (SInt32) this, false); - ::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false); - ::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false); - ::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false); - */ } return success; } @@ -789,6 +733,13 @@ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; GHOST_IWindow* window = 0; + //First check if we are in fullscreen mode + //If so, exit it before creating a new window + window = m_windowManager->getActiveWindow(); + if (window && (window->getState() == GHOST_kWindowStateFullScreen)) + window->setState(GHOST_kWindowStateNormal); + window = NULL; + //Get the available rect for including window contents NSRect frame = [[NSScreen mainScreen] visibleFrame]; NSRect contentRect = [NSWindow contentRectForFrameRect:frame @@ -826,27 +777,18 @@ GHOST_TSuccess GHOST_SystemCocoa::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual) { - GHOST_TSuccess success = GHOST_kFailure; + GHOST_IWindow* currentWindow = m_windowManager->getActiveWindow(); - //TODO: update this method - // need yo make this Carbon all on 10.5 for fullscreen to work correctly - CGCaptureAllDisplays(); + *window = currentWindow; - success = GHOST_System::beginFullScreen( setting, window, stereoVisual); - - if( success != GHOST_kSuccess ) { - // fullscreen failed for other reasons, release - CGReleaseAllDisplays(); - } - - return success; + return currentWindow->setState(GHOST_kWindowStateFullScreen); } GHOST_TSuccess GHOST_SystemCocoa::endFullScreen(void) { - //TODO: update this method - CGReleaseAllDisplays(); - return GHOST_System::endFullScreen(); + GHOST_IWindow* currentWindow = m_windowManager->getActiveWindow(); + + return currentWindow->setState(GHOST_kWindowStateNormal); } @@ -936,8 +878,7 @@ anyProcessed = true; } - //TODO: check fullscreen redrawing issues - if (getFullScreen()) { + if (getFullScreen()) { // Check if the full-screen window is dirty GHOST_IWindow* window = m_windowManager->getFullScreenWindow(); if (((GHOST_WindowCarbon*)window)->getFullScreenDirty()) { @@ -987,7 +928,7 @@ case NSTabletPoint: case NSTabletProximity: - handleTabletEvent(event); + handleTabletEvent(event,[event type]); break; /* Trackpad features, will need OS X 10.6 for implementation @@ -1028,8 +969,6 @@ if (!validWindow(window)) { return GHOST_kFailure; } - - //if (!getFullScreen()) { switch(eventType) { case GHOST_kEventWindowClose: @@ -1045,7 +984,6 @@ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) ); break; case GHOST_kEventWindowUpdate: - //if (getFullScreen()) GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen update event\n"); pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) ); break; case GHOST_kEventWindowSize: @@ -1059,12 +997,6 @@ return GHOST_kFailure; break; } -// } - //else { - //window = (GHOST_WindowCarbon*) m_windowManager->getFullScreenWindow(); - //GHOST_PRINT("GHOST_SystemCarbon::handleWindowEvent(): full-screen window event, " << window << "\n"); - //::RemoveEventFromQueue(::GetMainEventQueue(), event); - //} return GHOST_kSuccess; } @@ -1073,6 +1005,13 @@ //Check open windows if some changes are not saved if (m_windowManager->getAnyModifiedState()) { + //First check if we are in fullscreen mode + //If so, exit it before creating a new window + GHOST_IWindow *window = m_windowManager->getActiveWindow(); + if (window && (window->getState() == GHOST_kWindowStateFullScreen)) + window->setState(GHOST_kWindowStateNormal); + window = NULL; + int shouldQuit = NSRunAlertPanel(@"Exit Blender", @"Some changes have not been saved. Do you really want to quit ?", @"Cancel", @"Quit anyway", nil); if (shouldQuit == NSAlertAlternateReturn) @@ -1090,35 +1029,13 @@ } -GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr) +GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType) { NSEvent *event = (NSEvent *)eventPtr; GHOST_IWindow* window = m_windowManager->getActiveWindow(); GHOST_TabletData& ct=((GHOST_WindowCocoa*)window)->GetCocoaTabletData(); - NSUInteger tabletEvent; - //Handle tablet events combined with mouse events - @try { - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - tabletEvent = NSTabletPoint; - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - tabletEvent = NSTabletProximity; - break; - - default: - tabletEvent = [event type]; - break; - } - } - @catch (NSException * e) { - //FIXME: check why we get such exceptions when using a tablet - return GHOST_kFailure; - } - - - switch (tabletEvent) { + switch (eventType) { case NSTabletPoint: ct.Pressure = [event tangentialPressure]; ct.Xtilt = [event tilt].x; @@ -1175,20 +1092,53 @@ case NSRightMouseDown: case NSOtherMouseDown: pushEvent(new GHOST_EventButton([event timestamp], GHOST_kEventButtonDown, window, convertButton([event buttonNumber]))); - handleTabletEvent(eventPtr); + //Handle tablet events combined with mouse events + switch ([event subtype]) { + case NX_SUBTYPE_TABLET_POINT: + handleTabletEvent(eventPtr, NSTabletPoint); + break; + case NX_SUBTYPE_TABLET_PROXIMITY: + handleTabletEvent(eventPtr, NSTabletProximity); + break; + default: + //No tablet event included : do nothing + break; + } break; case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp: pushEvent(new GHOST_EventButton([event timestamp], GHOST_kEventButtonUp, window, convertButton([event buttonNumber]))); - handleTabletEvent(eventPtr); + //Handle tablet events combined with mouse events + switch ([event subtype]) { + case NX_SUBTYPE_TABLET_POINT: + handleTabletEvent(eventPtr, NSTabletPoint); + break; + case NX_SUBTYPE_TABLET_PROXIMITY: + handleTabletEvent(eventPtr, NSTabletProximity); + break; + default: + //No tablet event included : do nothing + break; + } break; case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDragged: - handleTabletEvent(eventPtr); + //Handle tablet events combined with mouse events + switch ([event subtype]) { + case NX_SUBTYPE_TABLET_POINT: + handleTabletEvent(eventPtr, NSTabletPoint); + break; + case NX_SUBTYPE_TABLET_PROXIMITY: + handleTabletEvent(eventPtr, NSTabletProximity); + break; + default: + //No tablet event included : do nothing + break; + } case NSMouseMoved: { NSPoint mousePos = [event locationInWindow]; @@ -1227,6 +1177,7 @@ * the window go away and we still get an HKey up. */ if (!window) { + printf("\nW failure"); return GHOST_kFailure; } @@ -1246,7 +1197,7 @@ if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask)) break; //Cmd-Q is directly handled by Cocoa - + if ([event type] == NSKeyDown) { @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs