- labels: --> 68. Win Window Operations
- assigned_to: nobody --> chengyemao
I have a problem with cursor change using Tkogl (opengl extension) under Windows.
Tkogl creates Tk_Window-window (A) and opengl-window (B) as a child of A.
B is not Tk_Window. B just posts some messages to its parent (A) so I have no
problem with bindings and with cursor change. But I can see the desired cursor (over B)
only when I move the mouse or press the button. As soon as I stop moving or release the button
- the cursor changes to IDC_ARROW.
It happens because of "mouseTimer" that is created in Tk_PointerEvent(hwnd, x, y)
(tkWinPointer.c line 149).
MouseTimerProc calls Tk_PointerEvent(NULL, pos.x, pos.y) (tkWinPointer.c line 239).
Note that hwnd is NULL, so Tk_PointerEvent "must" find hwnd.
hwnd = WindowFromPoint(pos); (tkWinPointer.c line 139).
WindowFromPoint returns hwnd of B (rightly) which is not Tk_Window.
When
tkwin = Tk_HWNDToWindow(hwnd); (tkWinPointer.c line 141)
so tkwin is NULL now.
After this
Tk_UpdatePointer(tkwin, pos.x, pos.y, state); (tkWinPointer.c line 145)
with tkwin==NULL will change cursor to "None".
I see two simple ways to avoid this problem -
1. Not to change cursor to "None" in UpdateCursor(winPtr) (TkPointer.c line 546) when
winPtr==NULL.
2. Replace
tkwin = Tk_HWNDToWindow(hwnd); (tkWinPointer.c line 141)
with
tkwin = NULL;
while (tkwin==NULL && hwnd!=NULL) {
tkwin = Tk_HWNDToWindow(hwnd);
hwnd = GetParent(hwnd);
}