Hub,

You may want to apply something like the attached. It makes the code
look like the changes I made to the unix files.

The problem was twofold: (1) user specified geometry was not not used,
and there was no sensible fallback to pref or hardwired, and (2) the
code tried to use an enum to hold an set of flags.

I have not made (suggested) changes to the QNX code but it also suffers
from the enum bit-manipulation problem.

It might be worth moving the fall-back logic to XP, and let the
platforms translate their pos/size flags to a common format. Some other
day maybe...

? wp/main/cocoa/bundle/GNUmakefile.in
Index: af/xap/cocoa/xap_CocoaApp.h
===================================================================
RCS file: /cvsroot/abi/src/af/xap/cocoa/xap_CocoaApp.h,v
retrieving revision 1.2
diff -u -p -u -5 -p -r1.2 xap_CocoaApp.h
--- af/xap/cocoa/xap_CocoaApp.h 15 May 2002 08:32:06 -0000      1.2
+++ af/xap/cocoa/xap_CocoaApp.h 18 Jul 2002 11:21:49 -0000
@@ -69,27 +69,27 @@ public:
                                                                                       
                                         const char **pszFormatFound) = 0;
        virtual void                                                    
cacheCurrentSelection(AV_View *) = 0;
 
        XAP_CocoaFontManager *                                  getFontManager();
 
-       typedef enum
+       enum
        {
                GEOMETRY_FLAG_POS =     1 << 0,
                GEOMETRY_FLAG_SIZE =    1 << 1
-       } windowGeometryFlags;
+       };
        
        struct windowGeometry
        {
                int x, y;
                UT_uint32 width, height;
-               XAP_CocoaApp::windowGeometryFlags flags;
+               UT_uint32 flags;
        };
        
-       virtual void                                    setGeometry(int x, int y, 
UT_uint32 width, UT_uint32 height,
-                                                                                      
         windowGeometryFlags flags);
-       virtual void                                    getGeometry(int * x, int * y, 
UT_uint32 * width, UT_uint32 * height,
-                                                                                      
         windowGeometryFlags * flags);
+       virtual void                                    setWinGeometry(int x, int y, 
+UT_uint32 width, UT_uint32 height,
+                                                                                      
+         UT_uint32 flags);
+       virtual void                                    getWinGeometry(int * x, int * 
+y, UT_uint32 * width, UT_uint32 * height,
+                                                                                      
+         UT_uint32 * flags);
 
        void                                                    
setTimeOfLastEvent(NSTimeInterval eventTime);
        NSTimeInterval                                  getTimeOfLastEvent() const { 
return m_eventTime; };
        virtual UT_sint32                               makeDirectory(const char * 
szPath, const UT_sint32 mode ) const;
        
Index: af/xap/cocoa/xap_CocoaApp.mm
===================================================================
RCS file: /cvsroot/abi/src/af/xap/cocoa/xap_CocoaApp.mm,v
retrieving revision 1.3
diff -u -p -u -5 -p -r1.3 xap_CocoaApp.mm
--- af/xap/cocoa/xap_CocoaApp.mm        15 May 2002 08:32:06 -0000      1.3
+++ af/xap/cocoa/xap_CocoaApp.mm        18 Jul 2002 11:21:49 -0000
@@ -52,20 +52,11 @@ XAP_CocoaApp::XAP_CocoaApp(XAP_Args * pA
 {
        m_pCocoaToolbarIcons = 0;
 
        _setAbiSuiteLibDir();
 
-       // set some generic window sizes and positions
-       m_geometry.x = 1;
-       m_geometry.y = 1;
-       m_geometry.width = 600;
-       m_geometry.height = 600;
-
-       // by default, which will be applied if the user does NOT
-       // specify a --geometry argument, we only want to obey the
-       // size (which is set above), not a position.
-       m_geometry.flags = GEOMETRY_FLAG_SIZE;
+       memset(&m_geometry, 0, sizeof(m_geometry));
 }
 
 XAP_CocoaApp::~XAP_CocoaApp()
 {
        DELETEP(m_pCocoaToolbarIcons);
@@ -124,23 +115,23 @@ XAP_Toolbar_ControlFactory * XAP_CocoaAp
 XAP_CocoaFontManager * XAP_CocoaApp::getFontManager()
 {
        return m_fontManager;
 }
 
-void XAP_CocoaApp::setGeometry(int x, int y, UT_uint32 width, UT_uint32 height,
-                                                         windowGeometryFlags flags)
+void XAP_CocoaApp::setWinGeometry(int x, int y, UT_uint32 width, UT_uint32 height,
+                                                                 UT_uint32 flags)
 {
        // TODO : do some range checking?
        m_geometry.x = x;
        m_geometry.y = y;
        m_geometry.width = width;
        m_geometry.height = height;
        m_geometry.flags = flags;
 }
 
-void XAP_CocoaApp::getGeometry(int * x, int * y, UT_uint32 * width,
-                                                         UT_uint32 * height, 
windowGeometryFlags * flags)
+void XAP_CocoaApp::getWinGeometry(int * x, int * y, UT_uint32 * width,
+                                                                 UT_uint32 * height, 
+UT_uint32 * flags)
 {
        UT_ASSERT(x && y && width && height);
        *x = m_geometry.x;
        *y = m_geometry.y;
        *width = m_geometry.width;
Index: af/xap/cocoa/xap_CocoaFrame.mm
===================================================================
RCS file: /cvsroot/abi/src/af/xap/cocoa/xap_CocoaFrame.mm,v
retrieving revision 1.14
diff -u -p -u -5 -p -r1.14 xap_CocoaFrame.mm
--- af/xap/cocoa/xap_CocoaFrame.mm      3 Jul 2002 17:28:15 -0000       1.14
+++ af/xap/cocoa/xap_CocoaFrame.mm      18 Jul 2002 11:21:49 -0000
@@ -535,23 +535,41 @@ void XAP_CocoaFrame::_createTopLevelWind
        _setWindowIcon();
 #if 0
        // set geometry hints as the user requested
        gint x, y;
        guint width, height;
-       XAP_CocoaApp::windowGeometryFlags f;
+       UT_uint32 f;
 
-       m_pCocoaApp->getGeometry(&x, &y, &width, &height, &f);
+       m_pCocoaApp->getWinGeometry(&x, &y, &width, &height, &f);
+
+       // Get fall-back defaults from preferences
+       UT_uint32 pref_flags, pref_width, pref_height;
+       UT_sint32 pref_x, pref_y;
+       m_pCocoaApp->getPrefs()->getGeometry(&pref_x, &pref_y, &pref_width,
+                                                                                
+&pref_height, &pref_flags);
+       if (!(f & XAP_CocoaApp::GEOMETRY_FLAG_SIZE)
+               && (pref_flags & PREF_FLAG_GEOMETRY_SIZE))
+       {
+               width = pref_width;
+               height = pref_height;
+               f |= XAP_CocoaApp::GEOMETRY_FLAG_SIZE;
+       }
+       if (!(f & XAP_CocoaApp::GEOMETRY_FLAG_POS)
+               && (pref_flags & PREF_FLAG_GEOMETRY_POS))
+       {
+               x = pref_x;
+               y = pref_y;
+               f |= XAP_CocoaApp::GEOMETRY_FLAG_POS;
+       }
 
        // Set the size if requested
 
        if (f & XAP_CocoaApp::GEOMETRY_FLAG_SIZE)
        {
-                gint abi_width = UT_MIN( gdk_screen_width() - 30, 813);
-                gint abi_height = UT_MIN( gdk_screen_height() - 100, 836);
-               gtk_widget_set_usize(m_wTopLevelWindow,
-                                                        abi_width,
-                                                        abi_height);
+               gint abi_width = UT_MIN( gdk_screen_width() - 30, (gint)width);
+               gint abi_height = UT_MIN( gdk_screen_height() - 100, (gint)height);
+               gtk_widget_set_usize(m_wTopLevelWindow, abi_width, abi_height);
        }
 #endif
 
 
        // Because we're clever, we only honor this flag when we
@@ -560,14 +578,20 @@ void XAP_CocoaFrame::_createTopLevelWind
        // places for new windows, instead of having our windows
        // pile upon each other.
 
 #if 0
        if (m_pCocoaApp->getFrameCount() <= 1)
+       {
                if (f & XAP_CocoaApp::GEOMETRY_FLAG_POS)
-                       gtk_widget_set_uposition(m_wTopLevelWindow,
-                                                                        x,
-                                                                        y);
+               {
+                       gtk_widget_set_uposition(m_wTopLevelWindow, x, y);
+               }
+       }
+
+       // Remember geometry settings for next time
+       m_pCocoaApp->getPrefs()->setGeometry(x, y, width, height, f);
+
 #endif
 
        // we let our caller decide when to show m_wTopLevelWindow.
        return;
 }

Reply via email to