]> git.saurik.com Git - wxWidgets.git/commitdiff
wxX11:
authorRobert Roebling <robert@roebling.de>
Fri, 15 Feb 2002 22:18:49 +0000 (22:18 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 15 Feb 2002 22:18:49 +0000 (22:18 +0000)
    Reorganized SetSize() code so that composite controls work.
    Removed call to XSync() in the same code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/x11/popupwin.cpp
src/x11/window.cpp

index df21552719435f69279c0266c5941429219a8734..881d442bbc29a4b6d8aa341235957f561c8cb3c0 100644 (file)
@@ -92,9 +92,9 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
     return TRUE;
 }
 
-void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
+void wxPopupWindow::DoMoveWindow(int x, int y, int width, int height )
 {
-    wxFAIL_MSG( wxT("DoMoveWindow called for wxPopupWindow") );
+    wxWindowX11::DoMoveWindow( x, y, width, height );
 }
 
 void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
index 39614cd0c1b01549caf307e6cb3d050eb06e9f47..296ceb73c768849aef753cec00a46cc2c329c61a 100644 (file)
@@ -645,7 +645,7 @@ void wxWindowX11::DoGetClientSize(int *x, int *y) const
 
     if (window)
     {
-        XSync(wxGlobalDisplay(), False);
+        XSync(wxGlobalDisplay(), False);  // Is this really a good idea?
         XWindowAttributes attr;
         Status status = XGetWindowAttributes( wxGlobalDisplay(), window, &attr );
         wxASSERT(status);
@@ -660,72 +660,70 @@ void wxWindowX11::DoGetClientSize(int *x, int *y) const
 
 void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
 {
-    if (!GetMainWindow())
-        return;
+    Window xwindow = (Window) GetMainWindow();
 
-    XWindowChanges windowChanges;
-    windowChanges.x = 0;
-    windowChanges.y = 0;
-    windowChanges.width = 0;
-    windowChanges.height = 0;
-    windowChanges.stack_mode = 0;
-    int valueMask = 0;
+    wxCHECK_RET( xwindow, wxT("invalid window") );
+
+    XWindowAttributes attr;
+    Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
+    wxCHECK_RET( status, wxT("invalid window attributes") );
+        
+    int new_x = attr.x;
+    int new_y = attr.y;
+    int new_w = attr.width;
+    int new_h = attr.height;
+            
 
     if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
     {
-       int yy = 0;
+        int yy = 0;
         AdjustForParentClientOrigin( x, yy, sizeFlags);
-        windowChanges.x = x;
-        valueMask |= CWX;
+        new_x = x;
     }
     if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
     {
-       int xx = 0;
+        int xx = 0;
         AdjustForParentClientOrigin( xx, y, sizeFlags);
-        windowChanges.y = y;
-        valueMask |= CWY;
+        new_y = y;
     }
-    if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    if (width != -1)
     {
-        windowChanges.width = width /* - m_borderSize*2 */;
-       if (windowChanges.width == 0)
-           windowChanges.width = 1;
-        valueMask |= CWWidth;
+        new_w = width;
+        if (new_w <= 0)
+            new_w = 20;
     }
-    if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+    if (height != -1)
     {
-        windowChanges.height = height /* -m_borderSize*2*/;
-       if (windowChanges.height == 0)
-           windowChanges.height = 1;
-        valueMask |= CWHeight;
+        new_h = height;
+        if (new_h <= 0)
+            new_h = 20;
     }
-
-    XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
-        valueMask, & windowChanges);
-    XSync(wxGlobalDisplay(), False);
+    
+    DoMoveWindow( new_x, new_y, new_w, new_h );
 }
 
 void wxWindowX11::DoSetClientSize(int width, int height)
 {
-    if (!GetMainWindow())
-        return;
+    Window xwindow = (Window) GetMainWindow();
 
-    XWindowChanges windowChanges;
-    int valueMask = 0;
+    wxCHECK_RET( xwindow, wxT("invalid window") );
 
+    XWindowAttributes attr;
+    Status status = XGetWindowAttributes( wxGlobalDisplay(), xwindow, &attr );
+    wxCHECK_RET( status, wxT("invalid window attributes") );
+        
+    int new_x = attr.x;
+    int new_y = attr.y;
+    int new_w = attr.width;
+    int new_h = attr.height;
+            
     if (width != -1)
-    {
-        windowChanges.width = width ;
-        valueMask |= CWWidth;
-    }
+        new_w = width;
+        
     if (height != -1)
-    {
-        windowChanges.height = height ;
-        valueMask |= CWHeight;
-    }
-    XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
-        valueMask, & windowChanges);
-    XSync(wxGlobalDisplay(), False);
+        new_h = height;
+    
+    DoMoveWindow( new_x, new_y, new_w, new_h );
 }
 
 // For implementation purposes - sometimes decorations make the client area
@@ -780,7 +778,19 @@ void wxWindowX11::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW,
 
 void wxWindowX11::DoMoveWindow(int x, int y, int width, int height)
 {
-    DoSetSize(x, y, width, height);
+    Window xwindow = (Window) GetMainWindow();
+
+    wxCHECK_RET( xwindow, wxT("invalid window") );
+
+    XWindowChanges windowChanges;
+    windowChanges.x = x;
+    windowChanges.y = y;
+    windowChanges.width = width;
+    windowChanges.height = height;
+    windowChanges.stack_mode = 0;
+    int valueMask = CWX | CWY | CWWidth | CWHeight;
+
+    XConfigureWindow( wxGlobalDisplay(), xwindow, valueMask, &windowChanges );
 }
 
 // ---------------------------------------------------------------------------