From 27398643404e43c2dd043c143d877a3cba613e31 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 15 Feb 2002 22:18:49 +0000 Subject: [PATCH] wxX11: 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 | 4 +- src/x11/window.cpp | 102 ++++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/x11/popupwin.cpp b/src/x11/popupwin.cpp index df21552719..881d442bbc 100644 --- a/src/x11/popupwin.cpp +++ b/src/x11/popupwin.cpp @@ -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 ) diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 39614cd0c1..296ceb73c7 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -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 ); } // --------------------------------------------------------------------------- -- 2.47.2