void TkMacInvalClipRgns( TkWindow *winPtr) { TkWindow *childPtr; /* * If already marked we can stop because all * decendants will also already be marked. */ if (winPtr->privatePtr->flags & TK_CLIP_INVALID) { return; } winPtr->privatePtr->flags |= TK_CLIP_INVALID; /* * Invalidate clip regions for all children & * their decendants - unless the child is a toplevel. */ childPtr = winPtr->childList; while (childPtr != NULL) { if (!Tk_IsTopLevel(childPtr) && Tk_IsMapped(childPtr)) { TkMacInvalClipRgns(childPtr); } childPtr = childPtr->nextPtr; } /* * Also, if the window is a container, mark its embedded window */ if (Tk_IsContainer(winPtr)) { childPtr = TkpGetOtherWindow(winPtr); if (childPtr != NULL && Tk_IsMapped(childPtr)) { TkMacInvalClipRgns(childPtr); } /* * NOTE: Here we should handle out of process embedding. */ } }
void XMapWindow( Display* display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; XEvent event; GWorldPtr destPort; /* * Under certain situations it's possible for this function to be * called before the toplevel window it's associated with has actually * been mapped. In that case we need to create the real Macintosh * window now as this function as well as other X functions assume that * the portPtr is valid. */ if (!TkMacHostToplevelExists(macWin->toplevel->winPtr)) { TkMacMakeRealWindowExist(macWin->toplevel->winPtr); } destPort = TkMacGetDrawablePort(window); display->request++; macWin->winPtr->flags |= TK_MAPPED; if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { ShowWindow((WindowRef) destPort); } /* * We only need to send the MapNotify event * for toplevel windows. */ event.xany.serial = display->request; event.xany.send_event = False; event.xany.display = display; event.xmap.window = window; event.xmap.type = MapNotify; event.xmap.event = window; event.xmap.override_redirect = macWin->winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } else { TkMacInvalClipRgns(macWin->winPtr->parentPtr); } /* * Generate damage for that area of the window */ SetGWorld(destPort, NULL); TkMacUpdateClipRgn(macWin->winPtr); TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); }
void XConfigureWindow( Display* display, /* Display. */ Window w, /* Window. */ unsigned int value_mask, XWindowChanges* values) { MacDrawable *macWin = (MacDrawable *) w; TkWindow *winPtr = macWin->winPtr; display->request++; /* * Change the shape and/or position of the window. */ if (value_mask & (CWX|CWY|CWWidth|CWHeight)) { XMoveResizeWindow(display, w, winPtr->changes.x, winPtr->changes.y, winPtr->changes.width, winPtr->changes.height); } /* * Change the stacking order of the window. Tk actuall keeps all * the information we need for stacking order. All we need to do * is make sure the clipping regions get updated and generate damage * that will ensure things get drawn correctly. */ if (value_mask & CWStackMode) { Rect bounds; GWorldPtr destPort; destPort = TkMacGetDrawablePort(w); if (destPort != NULL) { SetPort((GrafPtr) destPort); TkMacInvalClipRgns(winPtr->parentPtr); TkMacWinBounds(winPtr, &bounds); InvalRect(&bounds); } } /* TkGenWMMoveRequestEvent(macWin->winPtr, macWin->winPtr->changes.x, macWin->winPtr->changes.y); */ }
void XUnmapWindow( Display* display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; XEvent event; GWorldPtr destPort; destPort = TkMacGetDrawablePort(window); display->request++; macWin->winPtr->flags &= ~TK_MAPPED; if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { HideWindow((WindowRef) destPort); } /* * We only need to send the UnmapNotify event * for toplevel windows. */ event.xany.serial = display->request; event.xany.send_event = False; event.xany.display = display; event.xunmap.type = UnmapNotify; event.xunmap.window = window; event.xunmap.event = window; event.xunmap.from_configure = false; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } else { /* * Generate damage for that area of the window. */ SetGWorld(destPort, NULL); TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); /* TODO: may not be valid */ TkMacInvalClipRgns(macWin->winPtr->parentPtr); } }
void XMoveWindow( Display* display, /* Display. */ Window window, /* Window. */ int x, int y) { MacDrawable *macWin = (MacDrawable *) window; GWorldPtr destPort; destPort = TkMacGetDrawablePort(window); if (destPort == NULL) { return; } SetPort((GrafPtr) destPort); if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { /* * NOTE: we are not adding the new space to the update * region. It is currently assumed that Tk will need * to completely redraw anway. */ tkMacMoveWindow((WindowRef) destPort, x, y); /* TODO: is the following right? */ TkMacInvalidateWindow(macWin, TK_WINDOW_ONLY); TkMacInvalClipRgns(macWin->winPtr); } else { int deltaX, deltaY, parentBorderwidth; Rect bounds; MacDrawable *macParent; /* * Find the Parent window - * For an embedded window this will be its container. */ if (Tk_IsEmbedded(macWin->winPtr)) { TkWindow *contWinPtr; contWinPtr = TkpGetOtherWindow(macWin->winPtr); if (contWinPtr == NULL) { panic("XMoveWindow could not find container"); } macParent = contWinPtr->privatePtr; /* * NOTE: Here we should handle out of process embedding. */ } else { macParent = macWin->winPtr->parentPtr->privatePtr; if (macParent == NULL) { return; /* TODO: Probably should be a panic */ } } TkMacInvalClipRgns(macParent->winPtr); TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); deltaX = - macWin->xOff; deltaY = - macWin->yOff; /* * If macWin->winPtr is an embedded window, don't offset by its * parent's borderwidth... */ if (!Tk_IsEmbedded(macWin->winPtr)) { parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width; } else { parentBorderwidth = 0; } deltaX += macParent->xOff + parentBorderwidth + macWin->winPtr->changes.x; deltaY += macParent->yOff + parentBorderwidth + macWin->winPtr->changes.y; UpdateOffsets(macWin->winPtr, deltaX, deltaY); TkMacWinBounds(macWin->winPtr, &bounds); InvalRect(&bounds); } }
void XDestroyWindow( Display* display, /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; GWorldPtr destPort; /* * Remove any dangling pointers that may exist if * the window we are deleting is being tracked by * the grab code. */ TkPointerDeadWindow(macWin->winPtr); macWin->toplevel->referenceCount--; if (Tk_IsTopLevel(macWin->winPtr)) { DisposeRgn(macWin->clipRgn); DisposeRgn(macWin->aboveClipRgn); /* * Delete the Mac window and remove it from the windowTable. * The window could be NULL if the window was never mapped. * However, we don't do this for embedded windows, they don't * go in the window list, and they do not own their portPtr's. */ if (!(Tk_IsEmbedded(macWin->winPtr))) { destPort = TkMacGetDrawablePort(window); if (destPort != NULL) { TkMacWindowList *listPtr, *prevPtr; TkMacUnregisterMacWindow(destPort); DisposeWindow((WindowRef) destPort); for (listPtr = tkMacWindowListPtr, prevPtr = NULL; tkMacWindowListPtr != NULL; prevPtr = listPtr, listPtr = listPtr->nextPtr) { if (listPtr->winPtr == macWin->winPtr) { if (prevPtr == NULL) { tkMacWindowListPtr = listPtr->nextPtr; } else { prevPtr->nextPtr = listPtr->nextPtr; } ckfree((char *) listPtr); break; } } } } macWin->portPtr = NULL; /* * Delay deletion of a toplevel data structure untill all * children have been deleted. */ if (macWin->toplevel->referenceCount == 0) { ckfree((char *) macWin->toplevel); } } else { destPort = TkMacGetDrawablePort(window); if (destPort != NULL) { SetGWorld(destPort, NULL); TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); } if (macWin->winPtr->parentPtr != NULL) { TkMacInvalClipRgns(macWin->winPtr->parentPtr); } DisposeRgn(macWin->clipRgn); DisposeRgn(macWin->aboveClipRgn); if (macWin->toplevel->referenceCount == 0) { ckfree((char *) macWin->toplevel); } ckfree((char *) macWin); } }
void XResizeWindow( Display* display, /* Display. */ Window window, /* Window. */ unsigned int width, unsigned int height) { MacDrawable *macWin = (MacDrawable *) window; GWorldPtr destPort; destPort = TkMacGetDrawablePort(window); if (destPort == NULL) { return; } display->request++; SetPort((GrafPtr) destPort); if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { /* * NOTE: we are not adding the new space to the update * region. It is currently assumed that Tk will need * to completely redraw anway. */ SizeWindow((WindowRef) destPort, (short) width, (short) height, false); TkMacInvalidateWindow(macWin, TK_WINDOW_ONLY); TkMacInvalClipRgns(macWin->winPtr); } else { int deltaX, deltaY; /* * Find the Parent window - * For an embedded window this will be its container. */ TkWindow *contWinPtr; contWinPtr = TkpGetOtherWindow(macWin->winPtr); if (contWinPtr != NULL) { MacDrawable *macParent = contWinPtr->privatePtr; TkMacInvalClipRgns(macParent->winPtr); TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); deltaX = macParent->xOff + macWin->winPtr->changes.x - macWin->xOff; deltaY = macParent->yOff + macWin->winPtr->changes.y - macWin->yOff; UpdateOffsets(macWin->winPtr, deltaX, deltaY); } else { /* * This is the case where we are embedded in * another app. At this point, we are assuming that * the changes.x,y is not maintained, if you need * the info get it from Tk_GetRootCoords, * and that the toplevel sits at 0,0 when it is drawn. */ TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); UpdateOffsets(macWin->winPtr, 0, 0); } } } else { /* TODO: update all xOff & yOffs */ int deltaX, deltaY, parentBorderwidth; MacDrawable *macParent = macWin->winPtr->parentPtr->privatePtr; if (macParent == NULL) { return; /* TODO: Probably should be a panic */ } TkMacInvalClipRgns(macParent->winPtr); TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW); deltaX = - macWin->xOff; deltaY = - macWin->yOff; parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width; deltaX += macParent->xOff + parentBorderwidth + macWin->winPtr->changes.x; deltaY += macParent->yOff + parentBorderwidth + macWin->winPtr->changes.y; UpdateOffsets(macWin->winPtr, deltaX, deltaY); } }