Revision: 37765
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37765
Author:   blendix
Date:     2011-06-23 19:55:47 +0000 (Thu, 23 Jun 2011)
Log Message:
-----------
GHOST Cocoa: move y origin top/bottom conversions out of windowmanager module
and into GHOST. Also fixes a problem where e.g. the user preferences window
would not open under the mouse cursor correctly.

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
    trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
    trunk/blender/intern/ghost/intern/GHOST_Window.cpp
    trunk/blender/intern/ghost/intern/GHOST_Window.h
    trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
    trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
    trunk/blender/intern/ghost/intern/GHOST_WindowX11.cpp
    trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
    trunk/blender/source/blender/windowmanager/intern/wm_window.c

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h       2011-06-23 
19:49:53 UTC (rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.h       2011-06-23 
19:55:47 UTC (rev 37765)
@@ -272,6 +272,17 @@
         */
        GHOST_TSuccess setMouseCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y);
 
+       /**
+        * Push cursor event, with coordinate conversion to follow GHOST 
convention.
+        */
+       void pushEventCursor(GHOST_TUns64 msec, GHOST_TEventType type, 
GHOST_IWindow* window, GHOST_TInt32 x, GHOST_TInt32 y);
+
+       /**
+        * Push trackpad event, with coordinate conversion to follow GHOST 
convention.
+        */
+       void pushEventTrackpad(GHOST_TUns64 msec, GHOST_IWindow* window, 
GHOST_TTrackpadEventSubTypes subtype,
+               GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 deltaX, 
GHOST_TInt32 deltaY);
+
        /** Start time at initialization. */
        GHOST_TUns64 m_start_time;
        

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm      2011-06-23 
19:49:53 UTC (rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemCocoa.mm      2011-06-23 
19:55:47 UTC (rev 37765)
@@ -741,12 +741,14 @@
        NSRect contentRect = [NSWindow contentRectForFrameRect:frame
                                                                                
                 styleMask:(NSTitledWindowMask | NSClosableWindowMask | 
NSMiniaturizableWindowMask)];
        
+       GHOST_TInt32 bottom = (contentRect.size.height - 1) - height - top;
+
        //Ensures window top left is inside this available rect
        left = left > contentRect.origin.x ? left : contentRect.origin.x;
-       top = top > contentRect.origin.y ? top : contentRect.origin.y;
-       
-       window = new GHOST_WindowCocoa (this, title, left, top, width, height, 
state, type, stereoVisual, numOfAASamples);
+       bottom = bottom > contentRect.origin.y ? bottom : contentRect.origin.y;
 
+       window = new GHOST_WindowCocoa (this, title, left, bottom, width, 
height, state, type, stereoVisual, numOfAASamples);
+
     if (window) {
         if (window->getValid()) {
             // Store the pointer to the window 
@@ -804,6 +806,31 @@
     return GHOST_kSuccess;
 }
 
+void GHOST_SystemCocoa::pushEventCursor(GHOST_TUns64 msec, GHOST_TEventType 
type, GHOST_IWindow* window, GHOST_TInt32 x, GHOST_TInt32 y)
+{
+       GHOST_Rect cBnds;
+       window->getClientBounds(cBnds);
+       y = (cBnds.getHeight() - 1) - y;
+
+       GHOST_TInt32 screen_x, screen_y;
+       window->clientToScreen(x, y, screen_x, screen_y);
+
+       pushEvent(new GHOST_EventCursor(msec, type, window, screen_x, 
screen_y));
+}
+
+void GHOST_SystemCocoa::pushEventTrackpad(GHOST_TUns64 msec, GHOST_IWindow* 
window, GHOST_TTrackpadEventSubTypes subtype, GHOST_TInt32 x, GHOST_TInt32 y, 
GHOST_TInt32 deltaX, GHOST_TInt32 deltaY)
+{
+       GHOST_Rect cBnds;
+       window->getClientBounds(cBnds);
+       y = (cBnds.getHeight() - 1) - y;
+       deltaY = -deltaY;
+
+       GHOST_TInt32 screen_x, screen_y;
+       window->clientToScreen(x, y, screen_x, screen_y);
+
+       pushEvent(new GHOST_EventTrackpad(msec, window, subtype, screen_x, 
screen_y, deltaX, deltaY));
+}
+
 /**
  * @note : expect Cocoa screen coordinates
  */
@@ -821,7 +848,7 @@
        
        //Force mouse move event (not pushed by Cocoa)
        window->screenToClient(x, y, wx, wy);
-       pushEvent(new GHOST_EventCursor(getMilliSeconds(), 
GHOST_kEventCursorMove, window, wx,wy));
+       pushEventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, 
wx,wy);
        m_outsideLoopEventProcessed = true;
        
        return GHOST_kSuccess;
@@ -1508,7 +1535,7 @@
                                                y_accum += -[event deltaY]; 
//Strange Apple implementation (inverted coordinates for the deltaY) ...
                                                
window->setCursorGrabAccum(x_accum, y_accum);
                                                
-                                               pushEvent(new 
GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, 
x_warp+x_accum, y_warp+y_accum));
+                                               pushEventCursor([event 
timestamp]*1000, GHOST_kEventCursorMove, window, x_warp+x_accum, 
y_warp+y_accum);
                                        }
                                                break;
                                        case GHOST_kGrabWrap: //Wrap cursor at 
area/window boundaries
@@ -1552,14 +1579,14 @@
                                                
                                                //Post event
                                                
window->getCursorGrabInitPos(x_cur, y_cur);
-                                               pushEvent(new 
GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, x_cur 
+ x_accum, y_cur + y_accum));
+                                               pushEventCursor([event 
timestamp]*1000, GHOST_kEventCursorMove, window, x_cur + x_accum, y_cur + 
y_accum);
                                        }
                                                break;
                                        default:
                                        {
                                                //Normal cursor operation: send 
mouse position in window
                                                NSPoint mousePos = [event 
locationInWindow];
-                                               pushEvent(new 
GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, 
mousePos.x, mousePos.y));
+                                               pushEventCursor([event 
timestamp]*1000, GHOST_kEventCursorMove, window, mousePos.x, mousePos.y);
                                                m_cursorDelta_x=0;
                                                m_cursorDelta_y=0; //Mouse 
motion occurred between two cursor warps, so we can reset the delta counter
                                        }
@@ -1597,7 +1624,7 @@
                                        if (dy<0.0) dy-=0.5; else dy+=0.5;
                                        if (dy< -deltaMax) dy= -deltaMax; else 
if (dy>deltaMax) dy=deltaMax;
 
-                                       pushEvent(new 
GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventScroll, 
mousePos.x, mousePos.y, dx, dy));
+                                       pushEventTrackpad([event 
timestamp]*1000, window, GHOST_kTrackpadEventScroll, mousePos.x, mousePos.y, 
dx, dy);
                                }
                        }
                        break;
@@ -1605,16 +1632,16 @@
                case NSEventTypeMagnify:
                        {
                                NSPoint mousePos = [event locationInWindow];
-                               pushEvent(new GHOST_EventTrackpad([event 
timestamp]*1000, window, GHOST_kTrackpadEventMagnify, mousePos.x, mousePos.y,
-                                                                               
                  [event magnification]*250.0 + 0.1, 0));
+                               pushEventTrackpad([event timestamp]*1000, 
window, GHOST_kTrackpadEventMagnify, mousePos.x, mousePos.y,
+                                                                               
                  [event magnification]*250.0 + 0.1, 0);
                        }
                        break;
 
                case NSEventTypeRotate:
                        {
                                NSPoint mousePos = [event locationInWindow];
-                               pushEvent(new GHOST_EventTrackpad([event 
timestamp]*1000, window, GHOST_kTrackpadEventRotate, mousePos.x, mousePos.y,
-                                                                               
                  -[event rotation] * 5.0, 0));
+                               pushEventTrackpad([event timestamp]*1000, 
window, GHOST_kTrackpadEventRotate, mousePos.x, mousePos.y,
+                                                                               
                  -[event rotation] * 5.0, 0);
                        }
                case NSEventTypeBeginGesture:
                        m_isGestureInProgress = true;

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.cpp  2011-06-23 19:49:53 UTC 
(rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.cpp  2011-06-23 19:55:47 UTC 
(rev 37765)
@@ -41,8 +41,7 @@
 
 
 GHOST_Window::GHOST_Window(
-       const STR_String& /*title*/,
-       GHOST_TInt32 /*left*/, GHOST_TInt32 /*top*/, GHOST_TUns32 width, 
GHOST_TUns32 height,
+       GHOST_TUns32 width, GHOST_TUns32 height,
        GHOST_TWindowState state,
        GHOST_TDrawingContextType type,
        const bool stereoVisual,

Modified: trunk/blender/intern/ghost/intern/GHOST_Window.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_Window.h    2011-06-23 19:49:53 UTC 
(rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_Window.h    2011-06-23 19:55:47 UTC 
(rev 37765)
@@ -76,9 +76,6 @@
         * Constructor.
         * Creates a new window and opens it.
         * To check if the window was created properly, use the getValid() 
method.
-        * @param title                         The text shown in the title bar 
of the window.
-        * @param left                          The coordinate of the left edge 
of the window.
-        * @param top                           The coordinate of the top edge 
of the window.
         * @param width                         The width the window.
         * @param heigh                         The height the window.
         * @param state                         The state the window is 
initially opened with.
@@ -87,9 +84,6 @@
         * @param numOfAASamples        Number of samples used for AA (zero if 
no AA)
         */
        GHOST_Window(
-               const STR_String& title, 
-               GHOST_TInt32 left,
-               GHOST_TInt32 top,
                GHOST_TUns32 width,
                GHOST_TUns32 height,
                GHOST_TWindowState state,

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp    2011-06-23 
19:49:53 UTC (rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCarbon.cpp    2011-06-23 
19:55:47 UTC (rev 37765)
@@ -102,7 +102,7 @@
        const bool stereoVisual,
        const GHOST_TUns16 numOfAASamples
 ) :
-       GHOST_Window(title, left, top, width, height, state, 
GHOST_kDrawingContextTypeNone),
+       GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone),
        m_windowRef(0),
        m_grafPtr(0),
        m_aglCtx(0),

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h       2011-06-23 
19:49:53 UTC (rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h       2011-06-23 
19:55:47 UTC (rev 37765)
@@ -77,7 +77,7 @@
                GHOST_SystemCocoa *systemCocoa,
                const STR_String& title,
                GHOST_TInt32 left,
-               GHOST_TInt32 top,
+               GHOST_TInt32 bottom,
                GHOST_TUns32 width,
                GHOST_TUns32 height,
                GHOST_TWindowState state,

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm      2011-06-23 
19:49:53 UTC (rev 37764)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm      2011-06-23 
19:55:47 UTC (rev 37765)
@@ -308,14 +308,14 @@
        GHOST_SystemCocoa *systemCocoa,
        const STR_String& title,
        GHOST_TInt32 left,
-       GHOST_TInt32 top,
+       GHOST_TInt32 bottom,
        GHOST_TUns32 width,
        GHOST_TUns32 height,
        GHOST_TWindowState state,
        GHOST_TDrawingContextType type,
        const bool stereoVisual, const GHOST_TUns16 numOfAASamples
 ) :
-       GHOST_Window(title, left, top, width, height, state, 
GHOST_kDrawingContextTypeNone, stereoVisual, numOfAASamples),
+       GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, 
stereoVisual, numOfAASamples),
        m_customCursor(0)
 {
        NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
@@ -327,13 +327,12 @@
        
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        
-
        //Creates the window
        NSRect rect;
        NSSize  minSize;
        
        rect.origin.x = left;
-       rect.origin.y = top;
+       rect.origin.y = bottom;
        rect.size.width = width;
        rect.size.height = height;
        
@@ -703,12 +702,22 @@
        
        outX = baseCoord.x;
        outY = baseCoord.y;
+

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to