static int GenerateButtonEvent(MouseEventData * medPtr) { Tk_Window tkwin; int dummy; TkDisplay *dispPtr; #if UNUSED /* * ButtonDown events will always occur in the front * window. ButtonUp events, however, may occur anywhere * on the screen. ButtonUp events should only be sent * to Tk if in the front window or during an implicit grab. */ if ((medPtr->activeNonFloating == NULL) || ((!(TkpIsWindowFloating(medPtr->whichWin)) && (medPtr->activeNonFloating != medPtr->whichWin)) && TkMacOSXGetCapture() == NULL)) { return false; } #endif dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window); if (tkwin != NULL) { tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v, &dummy, &dummy); } Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state); return true; }
static int GeneratePollingEvents(MouseEventData * medPtr) { Tk_Window tkwin, rootwin, grabWin; int local_x, local_y; TkDisplay *dispPtr; grabWin = TkMacOSXGetCapture(); if ((!TkpIsWindowFloating(medPtr->whichWin) && (medPtr->activeNonFloating != medPtr->whichWin))) { /* * If the window for this event is not floating, and is not the * active non-floating window, don't generate polling events. * We don't send events to backgrounded windows. So either send * it to the grabWin, or NULL if there is no grabWin. */ tkwin = grabWin; } else { /* * First check whether the toplevel containing this mouse * event is the grab window. If not, then send the event * to the grab window. Otherwise, set tkWin to the subwindow * which most closely contains the mouse event. */ dispPtr = TkGetDisplayList(); rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window); if ((rootwin == NULL) || ((grabWin != NULL) && (rootwin != grabWin))) { tkwin = grabWin; } else { tkwin = Tk_TopCoordsToWindow(rootwin, medPtr->local.h, medPtr->local.v, &local_x, &local_y); } } /* * The following call will generate the appropiate X events and * adjust any state that Tk must remember. */ Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state); return true; }
void Tk_PointerEvent( HWND hwnd, /* Window for coords, or NULL for the root * window. */ int x, int y) /* Coords relative to hwnd, or screen if hwnd * is NULL. */ { POINT pos; int state; Tk_Window tkwin; pos.x = x; pos.y = y; /* * Convert client coords to root coords if we were given a window. */ if (hwnd) { ClientToScreen(hwnd, &pos); } /* * If the mouse is captured, Windows will report all pointer events to the * capture window. So, we need to determine which window the mouse is * really over and change the event. Note that the computed hwnd may point * to a window not owned by Tk, or a toplevel decorative frame, so tkwin * can be NULL. */ if (captured || hwnd == NULL) { hwnd = WindowFromPoint(pos); } tkwin = Tk_HWNDToWindow(hwnd); state = TkWinGetModifierState(); Tk_UpdatePointer(tkwin, pos.x, pos.y, state); if ((captured || tkwin) && !mouseTimerSet) { mouseTimerSet = 1; mouseTimer = Tcl_CreateTimerHandler(MOUSE_TIMER_INTERVAL, MouseTimerProc, NULL); } }