Windowmanager, ghost side:
authorTon Roosendaal <ton@blender.org>
Sun, 30 Dec 2007 13:30:31 +0000 (13:30 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 30 Dec 2007 13:30:31 +0000 (13:30 +0000)
- Added GHOST_kEventWindowMove event, for sending event that the
  window has moved
- Fixed GHOST_GetClientBounds() for OSX (get window rect)

Todos:
- add same event for X11 and Windows
- solve why ghost doesn't call client event-proc while scaling window
  (at least, not in osx)

intern/ghost/GHOST_Types.h
intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/ghost/intern/GHOST_WindowCarbon.cpp
source/blender/windowmanager/intern/wm_window.c

index d55753543708e99b52ac9c1f4fea127e72950ff7..b11e7c922f0fc13c3037a9f06bc07439b897d267 100644 (file)
@@ -144,6 +144,7 @@ typedef enum {
        GHOST_kEventWindowDeactivate,
        GHOST_kEventWindowUpdate,
        GHOST_kEventWindowSize,
+       GHOST_kEventWindowMove,
 
        GHOST_kNumEventTypes
 } GHOST_TEventType;
index e1e3853e8a86efa51107ecb7dc63c19c6f456f3c..ad2088c8b1414fa548a3fb4a6bdf694bb6f5cbe8 100644 (file)
@@ -936,10 +936,16 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event)
                         * events. By setting m_ignoreWindowSizedMessages these are suppressed.
                         * @see GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                         */
+                       /* even worse: scale window also generates a load of events, and nothing 
+                          is handled (read: client's event proc called) until you release mouse (ton) */
+                       
                        GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window");
                        m_ignoreWindowSizedMessages = true;
                        ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds);
                        m_ignoreWindowSizedMessages = false;
+                       
+                       pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, ghostWindow) );
+
                        break;
                
                case inContent:
index 04debe36191dbdfdf229b216e15b86285aabbbc4..0473b16335a079c4e1f7bbb72e8f53ee25746b1d 100644 (file)
@@ -255,7 +255,9 @@ void GHOST_WindowCarbon::getClientBounds(GHOST_Rect& bounds) const
 {
        Rect rect;
        GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::getClientBounds(): window invalid")
-       ::GetPortBounds(m_grafPtr, &rect);
+//     ::GetPortBounds(m_grafPtr, &rect);
+       ::GetWindowBounds(m_windowRef, kWindowContentRgn, &rect);
+
        bounds.m_b = rect.bottom;
        bounds.m_l = rect.left;
        bounds.m_r = rect.right;
index 4a6a3c572d39d173fd75e0b7de36e6b1b1b31df7..16ed2e7b4e5b3eaf244c2257df57e08966c3cb8d 100644 (file)
@@ -369,12 +369,12 @@ int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
 //                             window_handle(win, REDRAW, 1);
                                break;
                        }
-                       case GHOST_kEventWindowSize: {
+                       case GHOST_kEventWindowSize:
+                       case GHOST_kEventWindowMove: {
                                GHOST_RectangleHandle client_rect;
                                int l, t, r, b, scr_w, scr_h;
                                
-                               /* was GetClientBounds, doesnt work (at least osx) */
-                               client_rect= GHOST_GetWindowBounds(win->ghostwin);
+                               client_rect= GHOST_GetClientBounds(win->ghostwin);
                                GHOST_GetRectangle(client_rect, &l, &t, &r, &b);
                                
                                GHOST_DisposeRectangle(client_rect);
@@ -384,9 +384,9 @@ int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
                                win->sizey= b-t;
                                win->posx= l;
                                win->posy= scr_h - t - win->sizey;
-#ifdef __APPLE__
-                               win->posy-= 24; /* gutter... see ghost, bad stuff */
-#endif
+
+                               if(type!=GHOST_kEventWindowSize)
+                                       printf("win move event pos %d %d size %d %d\n", win->posx, win->posy, win->sizex, win->sizey);
                                
 //                             window_handle(win, RESHAPE, 1);
                                break;