[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Problem in wxWidgets 2.6.3...


Alex Bligh wrote:
Gerry Iles wrote:
Errr, wxFindWindowAtPoint(er) does recurse so presumably we need -1 as
the last param...

Yes indeed, sorry. I am looking at some dragmgr.cpp subtlety that
appears to be working by accident...

Could you check my logic on this. Current code in dragmgr.cpp:

// Determine if the pointer is over the target window, or any of its children wxWindow* WindowUnderPoint = ::wxFindWindowAtPoint(WinoilMousePos, FALSE, -1);
BOOL AreOverTargetWnd = (WindowUnderPoint == TargetWindow);

if (!AreOverTargetWnd)
	// We're not immediately over the background of the window, but may be over
	// a child-window of our window!

	// Get the mouse position in client coords
	wxPoint ClientPoint;
	ClientPoint.x = WinoilMousePos.x;
	ClientPoint.y = WinoilMousePos.y;
	ClientPoint = TargetWindow->ScreenToClient(ClientPoint);

wxWindow* ChildWindowUnderPoint = ::wxChildWindowFromPoint(TargetWindow, ClientPoint);
	AreOverTargetWnd = (ChildWindowUnderPoint != NULL &&
							ChildWindowUnderPoint == WindowUnderPoint);

Firstly, the ScreenToClient() is wrong - the call takes and has
always taken screen coords not client coords. If this was working,
it was only by accident (perhaps due to the other bug).

Secondly, ChildWindowUnderPoint == WindowUnderPoint seems unnecessary.
The routine has returned that a child window of the target window
exists which is the deepest window that contains the mouse pointer.
So it's a drag hit. Why do we care whether or not the child window
is also the one we found before?