|
From: CL <clc...@gm...> - 2009-01-16 13:52:12
|
Hi Shef
Now I understand more about the problem you described.
Actually vPython uses client windows coordinates in its mouse
management, but it has the assumption that it is the top-level window
when restoring the mouse cursor position after dragging. Somehow it
will cause a crash in some cases. I've fixed that portion and I am not
able to crash it any more. (May be I am not trying hard enough 8-)
In windisplay.cpp
LRESULT
display::on_mouse( WPARAM wParam, LPARAM lParam)
...
if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width
- 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) {
mouse.report_setcursor( view_width/2, view_height/2 );
SetCursorPos( view_x + view_width/2, view_y + view_height/2 );
}
if (was_locked && !mouse.is_mouse_locked()) {
mouse.report_setcursor( old_x, old_y );
SetCursorPos( view_x + old_x, view_y + old_y );
}
...
Both SetCursorPos call will move the mouse to an incorrect coordinate.
It is because WM_MOVE message is not sending to vPython any more after
it is reparented. (also, may be window_x and window_y shall be used
instead of view_x, view_y).
Changing it to:
if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width
- 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) {
mouse.report_setcursor( view_width/2, view_height/2 );
//SetCursorPos( view_x + view_width/2, view_y + view_height/2 );
POINT pt;
pt.x = pt.y = 0;
ClientToScreen(widget_handle, &pt);
SetCursorPos( pt.x + view_width/2, pt.y + view_height/2 );
}
if (was_locked && !mouse.is_mouse_locked()) {
mouse.report_setcursor( old_x, old_y );
//SetCursorPos( view_x + old_x, view_y + old_y );
POINT pt;
pt.x = pt.y = 0;
ClientToScreen(widget_handle, &pt);
SetCursorPos( pt.x + old_x, pt.y + old_y );
}
Now the mouse cursor is correctly positioned after dragging, no matter
if it has been reparented or not. Seems no more crashes now.
CL
> >
> Looks something like VPython 5 is using absolute mouse coordinates instead
> of translating them to the position in the parent.
> > I tried SetWindowPos but it looks like it has no effect after the
> > scene window is created, so I change it to MoveWindow. It works very
> > well on my PC.
> >
> Now try this:
> - start the program
> - move the window more to the top of your screen
> - click and drag, from a bottom position in the VPython window, downwards
> in such a way that you virtual (you can't see the cursor) will leave the
> window,
> and I expect you get the following error:
> VPython ***CRITICAL ERROR***: ..\src\core\display_kernel.cpp:535:
> cvisual::display_kernel::world_to_view_transform: VPython degenerate
> projection: 1.#INF 1.#INF 0.57735 0.494872
>
> cheers,
> Stef
>
>
>
> Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.
> The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.
|