No changes, just move mouse capturing bookkeeping data out of wxWindow.
All mouse capture-related data doesn't have to be declared in wxWindow itself and can just be global in wincmn.cpp, so move it there, this will facilitate further changes as they won't require recompiling everything any more. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1830,15 +1830,6 @@ private:
|
|||||||
// base for dialog unit conversion, i.e. average character size
|
// base for dialog unit conversion, i.e. average character size
|
||||||
wxSize GetDlgUnitBase() const;
|
wxSize GetDlgUnitBase() const;
|
||||||
|
|
||||||
// the stack of windows which have captured the mouse
|
|
||||||
static struct WXDLLIMPEXP_FWD_CORE wxWindowNext *ms_winCaptureNext;
|
|
||||||
|
|
||||||
// the window that currently has mouse capture
|
|
||||||
static wxWindow *ms_winCaptureCurrent;
|
|
||||||
|
|
||||||
// indicates if execution is inside CaptureMouse/ReleaseMouse
|
|
||||||
static bool ms_winCaptureChanging;
|
|
||||||
|
|
||||||
|
|
||||||
// number of Freeze() calls minus the number of Thaw() calls: we're frozen
|
// number of Freeze() calls minus the number of Thaw() calls: we're frozen
|
||||||
// (i.e. not being updated) if it is positive
|
// (i.e. not being updated) if it is positive
|
||||||
|
@@ -3202,21 +3202,32 @@ wxHitTest wxWindowBase::DoHitTest(wxCoord x, wxCoord y) const
|
|||||||
// mouse capture
|
// mouse capture
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct WXDLLEXPORT wxWindowNext
|
// Private data used for mouse capture tracking.
|
||||||
|
namespace wxMouseCapture
|
||||||
|
{
|
||||||
|
|
||||||
|
// the stack of windows which have captured the mouse
|
||||||
|
struct WindowNext
|
||||||
{
|
{
|
||||||
wxWindow *win;
|
wxWindow *win;
|
||||||
wxWindowNext *next;
|
WindowNext *next;
|
||||||
} *wxWindowBase::ms_winCaptureNext = NULL;
|
} *next = NULL;
|
||||||
wxWindow *wxWindowBase::ms_winCaptureCurrent = NULL;
|
|
||||||
bool wxWindowBase::ms_winCaptureChanging = false;
|
// the window that currently has mouse capture
|
||||||
|
wxWindow *current = NULL;
|
||||||
|
|
||||||
|
// indicates if execution is inside CaptureMouse/ReleaseMouse
|
||||||
|
bool changing = false;
|
||||||
|
|
||||||
|
} // wxMouseCapture
|
||||||
|
|
||||||
void wxWindowBase::CaptureMouse()
|
void wxWindowBase::CaptureMouse()
|
||||||
{
|
{
|
||||||
wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast<void*>(this));
|
wxLogTrace(wxT("mousecapture"), wxT("CaptureMouse(%p)"), static_cast<void*>(this));
|
||||||
|
|
||||||
wxASSERT_MSG( !ms_winCaptureChanging, wxT("recursive CaptureMouse call?") );
|
wxASSERT_MSG( !wxMouseCapture::changing, wxT("recursive CaptureMouse call?") );
|
||||||
|
|
||||||
ms_winCaptureChanging = true;
|
wxMouseCapture::changing = true;
|
||||||
|
|
||||||
wxWindow *winOld = GetCapture();
|
wxWindow *winOld = GetCapture();
|
||||||
if ( winOld )
|
if ( winOld )
|
||||||
@@ -3224,47 +3235,47 @@ void wxWindowBase::CaptureMouse()
|
|||||||
((wxWindowBase*) winOld)->DoReleaseMouse();
|
((wxWindowBase*) winOld)->DoReleaseMouse();
|
||||||
|
|
||||||
// save it on stack
|
// save it on stack
|
||||||
wxWindowNext *item = new wxWindowNext;
|
wxMouseCapture::WindowNext *item = new wxMouseCapture::WindowNext;
|
||||||
item->win = winOld;
|
item->win = winOld;
|
||||||
item->next = ms_winCaptureNext;
|
item->next = wxMouseCapture::next;
|
||||||
ms_winCaptureNext = item;
|
wxMouseCapture::next = item;
|
||||||
}
|
}
|
||||||
//else: no mouse capture to save
|
//else: no mouse capture to save
|
||||||
|
|
||||||
DoCaptureMouse();
|
DoCaptureMouse();
|
||||||
ms_winCaptureCurrent = (wxWindow*)this;
|
wxMouseCapture::current = (wxWindow*)this;
|
||||||
|
|
||||||
ms_winCaptureChanging = false;
|
wxMouseCapture::changing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowBase::ReleaseMouse()
|
void wxWindowBase::ReleaseMouse()
|
||||||
{
|
{
|
||||||
wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast<void*>(this));
|
wxLogTrace(wxT("mousecapture"), wxT("ReleaseMouse(%p)"), static_cast<void*>(this));
|
||||||
|
|
||||||
wxASSERT_MSG( !ms_winCaptureChanging, wxT("recursive ReleaseMouse call?") );
|
wxASSERT_MSG( !wxMouseCapture::changing, wxT("recursive ReleaseMouse call?") );
|
||||||
|
|
||||||
wxASSERT_MSG( GetCapture() == this,
|
wxASSERT_MSG( GetCapture() == this,
|
||||||
"attempt to release mouse, but this window hasn't captured it" );
|
"attempt to release mouse, but this window hasn't captured it" );
|
||||||
wxASSERT_MSG( ms_winCaptureCurrent == this,
|
wxASSERT_MSG( wxMouseCapture::current == this,
|
||||||
"attempt to release mouse, but this window hasn't captured it" );
|
"attempt to release mouse, but this window hasn't captured it" );
|
||||||
|
|
||||||
ms_winCaptureChanging = true;
|
wxMouseCapture::changing = true;
|
||||||
|
|
||||||
DoReleaseMouse();
|
DoReleaseMouse();
|
||||||
ms_winCaptureCurrent = NULL;
|
wxMouseCapture::current = NULL;
|
||||||
|
|
||||||
if ( ms_winCaptureNext )
|
if ( wxMouseCapture::next )
|
||||||
{
|
{
|
||||||
((wxWindowBase*)ms_winCaptureNext->win)->DoCaptureMouse();
|
((wxWindowBase*)wxMouseCapture::next->win)->DoCaptureMouse();
|
||||||
ms_winCaptureCurrent = ms_winCaptureNext->win;
|
wxMouseCapture::current = wxMouseCapture::next->win;
|
||||||
|
|
||||||
wxWindowNext *item = ms_winCaptureNext;
|
wxMouseCapture::WindowNext *item = wxMouseCapture::next;
|
||||||
ms_winCaptureNext = item->next;
|
wxMouseCapture::next = item->next;
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
//else: stack is empty, no previous capture
|
//else: stack is empty, no previous capture
|
||||||
|
|
||||||
ms_winCaptureChanging = false;
|
wxMouseCapture::changing = false;
|
||||||
|
|
||||||
wxLogTrace(wxT("mousecapture"),
|
wxLogTrace(wxT("mousecapture"),
|
||||||
(const wxChar *) wxT("After ReleaseMouse() mouse is captured by %p"),
|
(const wxChar *) wxT("After ReleaseMouse() mouse is captured by %p"),
|
||||||
@@ -3290,22 +3301,22 @@ void wxWindowBase::NotifyCaptureLost()
|
|||||||
{
|
{
|
||||||
// don't do anything if capture lost was expected, i.e. resulted from
|
// don't do anything if capture lost was expected, i.e. resulted from
|
||||||
// a wx call to ReleaseMouse or CaptureMouse:
|
// a wx call to ReleaseMouse or CaptureMouse:
|
||||||
if ( ms_winCaptureChanging )
|
if ( wxMouseCapture::changing )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if the capture was lost unexpectedly, notify every window that has
|
// if the capture was lost unexpectedly, notify every window that has
|
||||||
// capture (on stack or current) about it and clear the stack:
|
// capture (on stack or current) about it and clear the stack:
|
||||||
|
|
||||||
if ( ms_winCaptureCurrent )
|
if ( wxMouseCapture::current )
|
||||||
{
|
{
|
||||||
DoNotifyWindowAboutCaptureLost(ms_winCaptureCurrent);
|
DoNotifyWindowAboutCaptureLost(wxMouseCapture::current);
|
||||||
ms_winCaptureCurrent = NULL;
|
wxMouseCapture::current = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( ms_winCaptureNext )
|
while ( wxMouseCapture::next )
|
||||||
{
|
{
|
||||||
wxWindowNext *item = ms_winCaptureNext;
|
wxMouseCapture::WindowNext *item = wxMouseCapture::next;
|
||||||
ms_winCaptureNext = item->next;
|
wxMouseCapture::next = item->next;
|
||||||
|
|
||||||
DoNotifyWindowAboutCaptureLost(item->win);
|
DoNotifyWindowAboutCaptureLost(item->win);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user