Tk
view release on metacpan or search on metacpan
pTk/mTk/generic/tkFocus.c view on Meta::CPAN
if ((focusWinPtr != NULL) && (focusWinPtr->mainPtr == winPtr->mainPtr)) {
/*
* Map the x and y coordinates to make sense in the context of
* the focus window, if possible (make both -1 if the map-from
* and map-to windows don't share the same screen).
*/
if ((focusWinPtr->display != winPtr->display)
|| (focusWinPtr->screenNum != winPtr->screenNum)) {
eventPtr->xkey.x = -1;
eventPtr->xkey.y = -1;
} else {
Tk_GetVRootGeometry((Tk_Window) focusWinPtr, &vRootX, &vRootY,
&vRootWidth, &vRootHeight);
Tk_GetRootCoords((Tk_Window) focusWinPtr, &focusX, &focusY);
eventPtr->xkey.x = eventPtr->xkey.x_root - vRootX - focusX;
eventPtr->xkey.y = eventPtr->xkey.y_root - vRootY - focusY;
}
eventPtr->xkey.window = focusWinPtr->window;
return focusWinPtr;
}
/*
* The event doesn't belong to us. Perhaps, due to embedding, it
* really belongs to someone else. Give the embedding code a chance
* to redirect the event.
*/
TkpRedirectKeyEvent(winPtr, eventPtr);
return (TkWindow *) NULL;
}
/*
*----------------------------------------------------------------------
*
* TkFocusDeadWindow --
*
* This procedure is invoked when it is determined that
* a window is dead. It cleans up focus-related information
* about the window.
*
* Results:
* None.
*
* Side effects:
* Various things get cleaned up and recycled.
*
*----------------------------------------------------------------------
*/
void
TkFocusDeadWindow(winPtr)
register TkWindow *winPtr; /* Information about the window
* that is being deleted. */
{
ToplevelFocusInfo *tlFocusPtr, *prevPtr;
DisplayFocusInfo *displayFocusPtr;
TkDisplay *dispPtr = winPtr->dispPtr;
/*
* Certain special windows like those used for send and clipboard
* have no mainPtr.
*/
if (winPtr->mainPtr == NULL)
return;
/*
* Search for focus records that refer to this window either as
* the top-level window or the current focus window.
*/
displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
for (prevPtr = NULL, tlFocusPtr = winPtr->mainPtr->tlFocusPtr;
tlFocusPtr != NULL;
prevPtr = tlFocusPtr, tlFocusPtr = tlFocusPtr->nextPtr) {
if (winPtr == tlFocusPtr->topLevelPtr) {
/*
* The top-level window is the one being deleted: free
* the focus record and release the focus back to PointerRoot
* if we acquired it implicitly.
*/
if (dispPtr->implicitWinPtr == winPtr) {
if (dispPtr->focusDebug) {
printf("releasing focus to root after %s died\n",
tlFocusPtr->topLevelPtr->pathName);
}
dispPtr->implicitWinPtr = NULL;
displayFocusPtr->focusWinPtr = NULL;
dispPtr->focusPtr = NULL;
}
if (displayFocusPtr->focusWinPtr == tlFocusPtr->focusWinPtr) {
displayFocusPtr->focusWinPtr = NULL;
dispPtr->focusPtr = NULL;
}
if (prevPtr == NULL) {
winPtr->mainPtr->tlFocusPtr = tlFocusPtr->nextPtr;
} else {
prevPtr->nextPtr = tlFocusPtr->nextPtr;
}
ckfree((char *) tlFocusPtr);
break;
} else if (winPtr == tlFocusPtr->focusWinPtr) {
/*
* The deleted window had the focus for its top-level:
* move the focus to the top-level itself.
*/
tlFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr;
if ((displayFocusPtr->focusWinPtr == winPtr)
&& !(tlFocusPtr->topLevelPtr->flags & TK_ALREADY_DEAD)) {
if (dispPtr->focusDebug) {
printf("forwarding focus to %s after %s died\n",
tlFocusPtr->topLevelPtr->pathName,
winPtr->pathName);
}
GenerateFocusEvents(displayFocusPtr->focusWinPtr,
tlFocusPtr->topLevelPtr);
displayFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr;
dispPtr->focusPtr = tlFocusPtr->topLevelPtr;
( run in 1.142 second using v1.01-cache-2.11-cpan-84e82930d8c )