X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c2c0dabfa61fc435265f3dc71122592d359f0119..f1e7793361bb0106611e5d1373b4e1e6ed30f14f:/src/x11/toplevel.cpp?ds=sidebyside diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index d1a58623b7..7ac9f69372 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "toplevel.h" #endif @@ -139,7 +139,7 @@ bool wxTopLevelWindowX11::Create(wxWindow *parent, xattributes.override_redirect = True; } - if (HasFlag( wxNO_FULL_REPAINT_ON_RESIZE )) + if (!HasFlag( wxFULL_REPAINT_ON_RESIZE )) { xattributes_mask |= CWBitGravity; xattributes.bit_gravity = NorthWestGravity; @@ -248,7 +248,7 @@ wxTopLevelWindowX11::~wxTopLevelWindowX11() wxTopLevelWindows.DeleteObject(this); // If this is the last top-level window, exit. - if ( wxTheApp && (wxTopLevelWindows.Number() == 0) ) + if ( wxTheApp && (wxTopLevelWindows.GetCount() == 0) ) { wxTheApp->SetTopWindow(NULL); @@ -264,7 +264,10 @@ void wxTopLevelWindowX11::OnInternalIdle() { wxWindow::OnInternalIdle(); - if (m_needResizeInIdle) + // Do this only after the last idle event so that + // all windows have been updated before a new + // round of size events is sent + if (m_needResizeInIdle && !wxTheApp->Pending()) { wxSizeEvent event( GetClientSize(), GetId() ); event.SetEventObject( this ); @@ -280,31 +283,15 @@ void wxTopLevelWindowX11::OnInternalIdle() bool wxTopLevelWindowX11::Show(bool show) { - // Nano-X has to force a size event, - // else there's no initial size. -#if wxUSE_NANOX if (show) -#else - if (show && m_needResizeInIdle) -#endif { wxSizeEvent event(GetSize(), GetId()); + event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); m_needResizeInIdle = FALSE; } - if (show) - { - // This does the layout _before_ the - // window is shown, else the items are - // drawn first at the wrong positions, - // then at the correct positions. - if (GetAutoLayout()) - { - Layout(); - } - } bool ret = wxWindowX11::Show(show); @@ -417,16 +404,31 @@ void wxTopLevelWindowX11::SetIcons(const wxIconBundle& icons ) wxSetIconsX11( wxGlobalDisplay(), GetMainWindow(), icons ); } +bool wxTopLevelWindowX11::SetShape(const wxRegion& region) +{ + return wxDoSetShape( wxGlobalDisplay(), + (Window)GetMainWindow(), + region ); +} + void wxTopLevelWindowX11::SetTitle(const wxString& title) { m_title = title; if (GetMainWindow()) { +#if wxUSE_UNICODE + // I wonder of e.g. Metacity takes UTF-8 here + XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(), + (const char*) title.ToAscii() ); + XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(), + (const char*) title.ToAscii() ); +#else XStoreName(wxGlobalDisplay(), (Window) GetMainWindow(), (const char*) title); XSetIconName(wxGlobalDisplay(), (Window) GetMainWindow(), (const char*) title); +#endif } } @@ -452,13 +454,29 @@ void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const *height = m_height; } +void wxTopLevelWindowX11::DoGetSize( int *width, int *height ) const +{ + // TODO add non-client size + + if (width) + *width = m_width; + if (height) + *height = m_height; +} + void wxTopLevelWindowX11::DoSetClientSize(int width, int height) { - // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height); - + int old_width = m_width; + int old_height = m_height; + m_width = width; m_height = height; + if (m_width == old_width && m_height == old_height) + return; + + // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height); + #if !wxUSE_NANOX XSizeHints size_hints; size_hints.flags = PSize; @@ -472,7 +490,10 @@ void wxTopLevelWindowX11::DoSetClientSize(int width, int height) void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height); + int old_x = m_x; + int old_y = m_y; + int old_width = m_width; + int old_height = m_height; if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) m_x = x; @@ -485,7 +506,12 @@ void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int siz if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) m_height = height; + + if (m_x == old_x && m_y == old_y && m_width == old_width && m_height == old_height) + return; + // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height); + #if !wxUSE_NANOX XSizeHints size_hints; size_hints.flags = 0; @@ -643,7 +669,7 @@ struct MwmHints { #define PROP_MOTIF_WM_HINTS_ELEMENTS 5 // Set the window manager decorations according to the -// given wxWindows style +// given wxWidgets style bool wxSetWMDecorations(Window w, long style) { #if wxUSE_NANOX @@ -658,7 +684,7 @@ bool wxSetWMDecorations(Window w, long style) wmProp.flags |= GR_WM_FLAGS_PROPS ; } - if (style & wxSYSTEM_MENU) + if (style & wxCLOSE_BOX) { wmProp.props |= GR_WM_PROPS_CLOSEBOX ; wmProp.flags |= GR_WM_FLAGS_PROPS ; @@ -732,10 +758,10 @@ bool wxSetWMDecorations(Window w, long style) hints.decorations |= MWM_DECOR_TITLE; if ((style & wxSYSTEM_MENU) != 0) - { - hints.functions |= MWM_FUNC_CLOSE; hints.decorations |= MWM_DECOR_MENU; - } + + if ((style & wxCLOSE_BOX) != 0) + hints.functions |= MWM_FUNC_CLOSE; if ((style & wxMINIMIZE_BOX) != 0) {