OS X fix:
authorJean-Luc Peurière <jlp@nerim.net>
Sun, 1 Aug 2004 22:28:56 +0000 (22:28 +0000)
committerJean-Luc Peurière <jlp@nerim.net>
Sun, 1 Aug 2004 22:28:56 +0000 (22:28 +0000)
those who work with visible dock where experimenting slowdown of UI  when
 blender window was overlapping dock.

now :
     - check available space excluding dock
     - create window with a 10 pixels border
     - maximised mode is only 1 click away

This code is fixing only. Will review that when consensus will be found
about how we should create the window.

intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/ghost/intern/GHOST_WindowCarbon.cpp
source/blender/src/editscreen.c
source/blender/src/ghostwinlay.c
source/creator/creator.c

index 88bc859be6e1a524da45ae053c9d12035875d673..e7f087a86bcd8da31be5e83117d607740edaed44 100644 (file)
@@ -899,16 +899,18 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event)
                                        if (macState == 2) { // always ok
                                                        ::ZoomWindow(window, part, true);
                                                        ghostWindow->setMac_windowState(1);
-                                               } else { // need to force size again
-                                                       GHOST_TUns32 scr_x,scr_y;
+                                       } else { // need to force size again
+                                               GHOST_TUns32 scr_x,scr_y;
+                                               Rect outAvailableRect;
                                                
-                                                       ghostWindow->setMac_windowState(2);
+                                               ghostWindow->setMac_windowState(2);
+                                               ::GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
                                                
-                                                       this->getMainDisplayDimensions(scr_x,scr_y);
-                                                       ::SizeWindow (window, scr_x,scr_y-22,false);
-                                                       ::MoveWindow (window, 1,22,true);
-                                               }
-
+                                               //this->getMainDisplayDimensions(scr_x,scr_y);
+                                               ::SizeWindow (window, outAvailableRect.right-outAvailableRect.left,outAvailableRect.bottom-outAvailableRect.top-1,false);
+                                               ::MoveWindow (window, outAvailableRect.left, outAvailableRect.top,true);
+                                       }
+                               
                        }
                        break;
 
index 0c68a571a6895cc05b9c4f7f88aa635603510b94..c1d6e8ee49f4e75afcbbf3d159675970d2819c4d 100644 (file)
@@ -113,9 +113,11 @@ GHOST_WindowCarbon::GHOST_WindowCarbon(
     Str255 title255;
        OSStatus err;
        
+       //fprintf(stderr," main screen top %i left %i height %i width %i\n", top, left, height, width);
+       
        if (state >= 8 ) {
                state = state - 8;
-               setMac_windowState(2);
+               setMac_windowState(1);
        } else 
                setMac_windowState(0);
 
@@ -128,10 +130,10 @@ GHOST_WindowCarbon::GHOST_WindowCarbon(
                                                                 kWindowStandardDocumentAttributes+kWindowLiveResizeAttribute,
                                                                 &bnds,
                                                                 &m_windowRef);
+               
                if ( err != noErr) {
                        fprintf(stderr," error creating window %i \n",err);
                } else {
-                       //void *handler = &GHOST_WindowCarbon::myWEventHandlerProc;
                        
                        ::SetWRefCon(m_windowRef,(SInt32)this);
                        setTitle(title);
@@ -139,7 +141,10 @@ GHOST_WindowCarbon::GHOST_WindowCarbon(
                        if ( err != noErr) {
                                fprintf(stderr," error creating handler %i \n",err);
                        } else {
-                               ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL);
+                               //      ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL);
+                               ::ShowWindow(m_windowRef);
+                               ::MoveWindow (m_windowRef, left, top,true);
+                               
                        }
                }
         if (m_windowRef) {
index 9cf11275f73a43463565e2a41fef664197bb1f69..b8f26bddbeff8f92f1922ffc7204c4c10a03bdc2 100644 (file)
@@ -1212,19 +1212,25 @@ void setprefsize(int stax, int stay, int sizx, int sizy)
        int scrwidth, scrheight;
        
        winlay_get_screensize(&scrwidth, &scrheight);
-       
+               
        if(stax<0) stax= 0;
        if(stay<0) stay= 0;
        if(sizx<320) sizx= 320;
        if(sizy<256) sizy= 256;
 
-       if(stax+sizx>scrwidth) sizx= scrwidth-stax;
+       if(stax+sizx>scrwidth) {
+               fprintf(stderr," width prob \n");
+               sizx= scrwidth-stax;
+               }
 
-       if(stay+sizy>scrheight) sizy= scrheight-stay;
+       if(stay+sizy>scrheight) {
+               fprintf(stderr," height prob \n");
+               sizy= scrheight-stay;
+               }
 
-#ifdef __APPLE__
-       if(stay+sizy>scrheight-22) sizy= scrheight-22-stay;     // 22 = topbar
-#endif
+/* #ifdef __APPLE__ */
+/*     if(stay+sizy>scrheight-22) sizy= scrheight-22-stay;     // 22 = topbar  */
+/* #endif*/
 
        if(sizx<320 || sizy<256) {
                printf("ERROR: illegal prefsize\n");
index 954388b3db7d0d4f7d62e09788eba2cc13998e29..85571995b8753c39b26bfa5173270d3210df01e1 100644 (file)
@@ -118,7 +118,6 @@ int checkAppleVideoCard() {
        long value;
        long maxvram = 0;   /* we get always more than 1 renderer, check one, at least, has 8 Mo */
        
-       
        display_mask = CGDisplayIDToOpenGLDisplayMask (CGMainDisplayID() );     
        
        theErr = CGLQueryRendererInfo( display_mask, &rend, &nrend);
@@ -159,6 +158,17 @@ int checkAppleVideoCard() {
        return 0;
 }
 
+void getMacAvailableBounds(short *top, short *left, short *bottom, short *right) {
+       Rect outAvailableRect;
+       
+       GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect);
+       
+       *top = outAvailableRect.top;  
+    *left = outAvailableRect.left;
+    *bottom = outAvailableRect.bottom; 
+    *right = outAvailableRect.right;
+}
+
 #endif
 
 
index eb3cf302fed0c7e29d0d0dfcf1f0610087cc7562..baf18468b12c9782e52c79b5e5d71ad110b459c1 100644 (file)
@@ -113,6 +113,7 @@ static void print_version();
 /* defined is ghostwinlay , we can't include carbon here, conflict with DNA */
 #ifdef __APPLE
 extern int checkAppleVideoCard();
+extern void getMacAvailableBounds(short *top, short *left, short *bottom, short *right);
 #endif
 
 
@@ -200,6 +201,7 @@ static void print_help(void)
 
 double PIL_check_seconds_timer(void);
 extern void winlay_get_screensize(int *width_r, int *height_r);
+
 int main(int argc, char **argv)
 {
        int a, i, stax, stay, sizx, sizy;
@@ -225,16 +227,21 @@ int main(int argc, char **argv)
         /* first let us check if we are hardware accelerated and with VRAM >= 16 Mo */
         
         if (checkAppleVideoCard()) {
-            winlay_get_screensize(&scr_x, &scr_y);
-            /* let sneak under topbar */ 
-            setprefsize(1, 1, scr_x-2, scr_y-24);
+                       short top, left, bottom, right;
+                       
+                       winlay_get_screensize(&scr_x, &scr_y); 
+                       /*  let sneak under topbar 
+            setprefsize(1, 1, scr_x-2, scr_y-24);*/
+                       getMacAvailableBounds(&top, &left, &bottom, &right);
+                       setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
 
         } else {
+                               winlay_get_screensize(&scr_x, &scr_y);
+
                /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
                setprefsize(120, 40, 850, 684);
         }
     
-               winlay_get_screensize(&scr_x, &scr_y);
                winlay_process_events(0);
                if (GHOST_HACK_getFirstFile(firstfilebuf)) {
                        argc= 2;