From 7edcafa467269b15e0e967e9fe9ee08c6696b8a7 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 12 Feb 2002 18:15:20 +0000 Subject: [PATCH 1/1] Removed some debug code from window headers; added some debug code to try to figure out capture problems git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14161 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/window.h | 2 +- include/wx/gtk1/window.h | 2 +- include/wx/motif/window.h | 1 - include/wx/msw/window.h | 2 +- include/wx/os2/window.h | 2 +- include/wx/window.h | 2 +- include/wx/x11/app.h | 2 ++ include/wx/x11/window.h | 3 +-- src/univ/menu.cpp | 5 +++++ src/x11/app.cpp | 13 +++++++++++ src/x11/window.cpp | 45 +++++++++++++++++++++++++++++++++------ 11 files changed, 65 insertions(+), 14 deletions(-) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index a0d1a66f2e..bceb28c0a2 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -239,7 +239,7 @@ public: virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); - + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index a0d1a66f2e..bceb28c0a2 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -239,7 +239,7 @@ public: virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); - + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index d4cabf0cbc..9284faf764 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -314,7 +314,6 @@ protected: virtual void DoSetClientSize(int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height); virtual bool DoPopupMenu(wxMenu *menu, int x, int y); - virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 0df7b55a36..feccccf607 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -437,7 +437,7 @@ protected: virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); - + // move the window to the specified location and resize it: this is called // from both DoSetSize() and DoSetClientSize() and would usually just call // ::MoveWindow() except for composite controls which will want to arrange diff --git a/include/wx/os2/window.h b/include/wx/os2/window.h index 66bdc201c6..3580d86bca 100644 --- a/include/wx/os2/window.h +++ b/include/wx/os2/window.h @@ -526,7 +526,7 @@ protected: virtual void DoCaptureMouse(void); virtual void DoReleaseMouse(void); - + // move the window to the specified location and resize it: this is called // from both DoSetSize() and DoSetClientSize() and would usually just call // ::WinSetWindowPos() except for composite controls which will want to arrange diff --git a/include/wx/window.h b/include/wx/window.h index bdc20dfc5c..af98d65c85 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -923,7 +923,7 @@ protected: // capture/release the mouse, used by Capture/ReleaseMouse() virtual void DoCaptureMouse() = 0; virtual void DoReleaseMouse() = 0; - + // retrieve the position/size of the window virtual void DoGetPosition( int *x, int *y ) const = 0; virtual void DoGetSize( int *width, int *height ) const = 0; diff --git a/include/wx/x11/app.h b/include/wx/x11/app.h index 621cf13a33..39a94cbe30 100644 --- a/include/wx/x11/app.h +++ b/include/wx/x11/app.h @@ -76,6 +76,8 @@ public: // Processes an X event. virtual void ProcessXEvent(WXEvent* event); + virtual void OnAssert(const wxChar *file, int line, const wxChar *msg); + protected: bool m_showOnInit; diff --git a/include/wx/x11/window.h b/include/wx/x11/window.h index a92d8c0741..6693eaf517 100644 --- a/include/wx/x11/window.h +++ b/include/wx/x11/window.h @@ -168,10 +168,9 @@ protected: int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height); - virtual void DoCaptureMouse(); virtual void DoReleaseMouse(); - + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index e5bf6a9e66..c87393282d 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -1837,6 +1837,7 @@ int wxMenuBar::GetMenuFromPoint(const wxPoint& pos) const void wxMenuBar::SelectMenu(size_t pos) { SetFocus(); + wxLogDebug("Capturing mouse from wxMenuBar::SelectMenu"); CaptureMouse(); DoSelectMenu(pos); @@ -1925,6 +1926,7 @@ void wxMenuBar::OnLeftDown(wxMouseEvent& event) } else // on item { + wxLogDebug("Capturing mouse from wxMenuBar::OnLeftDown"); CaptureMouse(); // show it as selected @@ -2286,7 +2288,10 @@ void wxMenuBar::OnDismissMenu(bool dismissMenuBar) void wxMenuBar::OnDismiss() { if ( GetCapture() ) + { + wxLogDebug("Releasing mouse from wxMenuBar::OnDismiss"); GetCapture()->ReleaseMouse(); + } if ( m_current != -1 ) { diff --git a/src/x11/app.cpp b/src/x11/app.cpp index c21c217a82..31ad42aae9 100644 --- a/src/x11/app.cpp +++ b/src/x11/app.cpp @@ -755,6 +755,19 @@ wxApp::GetStdIcon(int which) const } } +void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg) +{ + // While the GUI isn't working that well, just print out the + // message. +#if 0 + wxAppBase::OnAssert(file, line, msg); +#else + wxString msg2; + msg2.Printf("At file %s:%d: %s", file, line, msg); + wxLogDebug(msg2); +#endif +} + // ---------------------------------------------------------------------------- // accessors for C modules // ---------------------------------------------------------------------------- diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 041217aa9e..486f63816c 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -259,17 +259,22 @@ bool wxWindowX11::Enable(bool enable) bool wxWindowX11::Show(bool show) { - if ( !wxWindowBase::Show(show) ) - return FALSE; + wxWindowBase::Show(show); Window xwin = (Window) GetXWindow(); Display *xdisp = (Display*) GetXDisplay(); if (show) { + wxString msg; + msg.Printf("Mapping window of type %s", GetClassInfo()->GetClassName()); + wxLogDebug(msg); XMapWindow(xdisp, xwin); } else { + wxString msg; + msg.Printf("Unmapping window of type %s", GetClassInfo()->GetClassName()); + wxLogDebug(msg); XUnmapWindow(xdisp, xwin); } @@ -292,10 +297,21 @@ void wxWindowX11::Lower() void wxWindowX11::DoCaptureMouse() { - g_captureWindow = (wxWindow*) this; + if ((g_captureWindow != NULL) && (g_captureWindow != this)) + { + wxASSERT_MSG(FALSE, "Trying to capture before mouse released."); + + // Core dump now + int *tmp = NULL; + (*tmp) = 1; + return; + } + if ( m_winCaptured ) return; + g_captureWindow = (wxWindow*) this; + if (GetMainWindow()) { int res = XGrabPointer(wxGlobalDisplay(), (Window) GetMainWindow(), @@ -309,10 +325,19 @@ void wxWindowX11::DoCaptureMouse() if (res != GrabSuccess) { - wxLogDebug("Failed to grab pointer."); + wxString msg; + msg.Printf("Failed to grab pointer for window %s", this->GetClassInfo()->GetClassName()); + wxLogDebug(msg); + if (res == GrabNotViewable) + { + wxLogDebug("This is not a viewable window - perhaps not shown yet?"); + } + g_captureWindow = NULL; return; } + wxLogDebug("Grabbed pointer"); +#if 0 res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, (Window) GetMainWindow(), FALSE, @@ -321,14 +346,16 @@ void wxWindowX11::DoCaptureMouse() GrabModeAsync, None, None); - + if (res != GrabSuccess) { wxLogDebug("Failed to grab mouse buttons."); XUngrabPointer(wxGlobalDisplay(), CurrentTime); return; } +#endif +#if 0 res = XGrabKeyboard(wxGlobalDisplay(), (Window) GetMainWindow(), #if 0 ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask, @@ -343,11 +370,14 @@ void wxWindowX11::DoCaptureMouse() { wxLogDebug("Failed to grab keyboard."); XUngrabPointer(wxGlobalDisplay(), CurrentTime); +#if 0 XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, (Window) GetMainWindow()); +#endif return; } - +#endif + m_winCaptured = TRUE; } } @@ -363,10 +393,13 @@ void wxWindowX11::DoReleaseMouse() if ( wMain ) { XUngrabPointer(wxGlobalDisplay(), wMain); +#if 0 XUngrabButton(wxGlobalDisplay(), AnyButton, AnyModifier, wMain); XUngrabKeyboard(wxGlobalDisplay(), CurrentTime); +#endif } + wxLogDebug("Ungrabbed pointer"); m_winCaptured = FALSE; } -- 2.45.2