summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXSubwindows.c
diff options
context:
space:
mode:
authorculler <culler>2019-04-17 14:05:33 (GMT)
committerculler <culler>2019-04-17 14:05:33 (GMT)
commit7eaee2f2e59cbbb043964d94313d3f22a6d877a5 (patch)
tree234a219579591d68652019df28397ade8a81a33e /macosx/tkMacOSXSubwindows.c
parent9b521b370e0520f6a489be15b65269a33761501a (diff)
downloadtk-7eaee2f2e59cbbb043964d94313d3f22a6d877a5.zip
tk-7eaee2f2e59cbbb043964d94313d3f22a6d877a5.tar.gz
tk-7eaee2f2e59cbbb043964d94313d3f22a6d877a5.tar.bz2
Mitigate future merge conflict headaches.
Diffstat (limited to 'macosx/tkMacOSXSubwindows.c')
-rw-r--r--macosx/tkMacOSXSubwindows.c115
1 files changed, 61 insertions, 54 deletions
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 805d58f..06aaa9d 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -65,7 +65,7 @@ XDestroyWindow(
TkMacOSXSelDeadWindow(macWin->winPtr);
macWin->toplevel->referenceCount--;
- if (!Tk_IsTopLevel(macWin->winPtr) ) {
+ if (!Tk_IsTopLevel(macWin->winPtr)) {
TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
if (macWin->winPtr->parentPtr != NULL) {
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
@@ -151,19 +151,18 @@ XMapWindow(
NSWindow *win = TkMacOSXDrawableWindow(window);
/*
- * We want to activate Tk when a toplevel is mapped
- * but we must not supply YES here. This is because
- * during Tk initialization the root window is mapped
- * before applicationDidFinishLaunching returns. Forcing
- * the app to activate too early can make the menu bar
- * unresponsive.
+ * We want to activate Tk when a toplevel is mapped but we must not
+ * supply YES here. This is because during Tk initialization the
+ * root window is mapped before applicationDidFinishLaunching
+ * returns. Forcing the app to activate too early can make the menu
+ * bar unresponsive.
*/
TkMacOSXApplyWindowAttributes(macWin->winPtr, win);
[win setExcludedFromWindowsMenu:NO];
[NSApp activateIgnoringOtherApps:NO];
[[win contentView] setNeedsDisplay:YES];
- if ( [win canBecomeKeyWindow] ) {
+ if ([win canBecomeKeyWindow]) {
[win makeKeyAndOrderFront:NSApp];
} else {
[win orderFrontRegardless];
@@ -185,7 +184,8 @@ XMapWindow(
*/
TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr);
- TkMacOSXInvalClipRgns((Tk_Window)contWinPtr);
+
+ TkMacOSXInvalClipRgns((Tk_Window) contWinPtr);
TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
}
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);
@@ -203,12 +203,9 @@ XMapWindow(
event.xmap.event = window;
event.xmap.override_redirect = macWin->winPtr->atts.override_redirect;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
} else {
-
/*
* Rebuild the parent's clipping region and display the window.
- *
*/
TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr->parentPtr);
@@ -298,6 +295,7 @@ XUnmapWindow(
if (!Tk_IsEmbedded(winPtr) &&
winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
NSWindow *win = TkMacOSXDrawableWindow(window);
+
[win orderOut:nil];
}
TkMacOSXInvalClipRgns((Tk_Window) winPtr);
@@ -316,15 +314,15 @@ XUnmapWindow(
event.xunmap.from_configure = false;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
} else {
-
/*
* Rebuild the visRgn clip region for the parent so it will be allowed
* to draw in the space from which this subwindow was removed.
*/
if (parentPtr && parentPtr->privatePtr->visRgn) {
- TkMacOSXInvalidateViewRegion(TkMacOSXDrawableView(parentPtr->privatePtr),
- parentPtr->privatePtr->visRgn);
+ TkMacOSXInvalidateViewRegion(
+ TkMacOSXDrawableView(parentPtr->privatePtr),
+ parentPtr->privatePtr->visRgn);
}
TkMacOSXInvalClipRgns((Tk_Window) parentPtr);
TkMacOSXUpdateClipRgn(parentPtr);
@@ -357,11 +355,14 @@ XResizeWindow(
unsigned int height)
{
MacDrawable *macWin = (MacDrawable *) window;
+
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *w = macWin->winPtr->wmInfoPtr->window;
+
if (w) {
NSRect r = [w contentRectForFrameRect:[w frame]];
+
r.origin.y += r.size.height - height;
r.size.width = width;
r.size.height = height;
@@ -377,8 +378,8 @@ XResizeWindow(
*
* XMoveResizeWindow --
*
- * Move or resize a given X window. See X windows documentation
- * for further details.
+ * Move or resize a given X window. See X windows documentation for
+ * further details.
*
* Results:
* None.
@@ -402,22 +403,24 @@ XMoveResizeWindow(
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *w = macWin->winPtr->wmInfoPtr->window;
- if (w) {
- /* We explicitly convert everything to doubles so we don't get
+ if (w) {
+ /*
+ * We explicitly convert everything to doubles so we don't get
* surprised (again) by what happens when you do arithmetic with
* unsigned ints.
*/
- CGFloat X = (CGFloat)x;
- CGFloat Y = (CGFloat)y;
- CGFloat Width = (CGFloat)width;
- CGFloat Height = (CGFloat)height;
- CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent;
- CGFloat YOff = (CGFloat)macWin->winPtr->wmInfoPtr->yInParent;
- NSRect r = NSMakeRect(X + XOff,
- tkMacOSXZeroScreenHeight - Y - YOff - Height,
- Width, Height);
+ CGFloat X = (CGFloat) x;
+ CGFloat Y = (CGFloat) y;
+ CGFloat Width = (CGFloat) width;
+ CGFloat Height = (CGFloat) height;
+ CGFloat XOff = (CGFloat) macWin->winPtr->wmInfoPtr->xInParent;
+ CGFloat YOff = (CGFloat) macWin->winPtr->wmInfoPtr->yInParent;
+ NSRect r = NSMakeRect(
+ X + XOff, tkMacOSXZeroScreenHeight - Y - YOff - Height,
+ Width, Height);
+
[w setFrame:[w frameRectForContentRect:r] display:YES];
}
} else {
@@ -430,8 +433,7 @@ XMoveResizeWindow(
*
* XMoveWindow --
*
- * Move a given X window. See X windows documentation for further
- * details.
+ * Move a given X window. See X windows documentation for further details.
*
* Results:
* None.
@@ -453,8 +455,10 @@ XMoveWindow(
display->request++;
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *w = macWin->winPtr->wmInfoPtr->window;
+
if (w) {
- [w setFrameTopLeftPoint:NSMakePoint(x, tkMacOSXZeroScreenHeight - y)];
+ [w setFrameTopLeftPoint: NSMakePoint(
+ x, tkMacOSXZeroScreenHeight - y)];
}
} else {
MoveResizeWindow(macWin);
@@ -495,7 +499,6 @@ MoveResizeWindow(
if (contWinPtr) {
macParent = contWinPtr->privatePtr;
} else {
-
/*
* Here we should handle out of process embedding. At this point,
* we are assuming that the changes.x,y is not maintained, if you
@@ -504,7 +507,6 @@ MoveResizeWindow(
*/
}
} else {
-
/*
* TODO: update all xOff & yOffs
*/
@@ -596,7 +598,6 @@ XRaiseWindow(
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
TkWmRestackToplevel(macWin->winPtr, Above, NULL);
} else {
-
/*
* TODO: this should generate damage
*/
@@ -631,7 +632,6 @@ XLowerWindow(
if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
TkWmRestackToplevel(macWin->winPtr, Below, NULL);
} else {
-
/*
* TODO: this should generate damage
*/
@@ -694,14 +694,16 @@ XConfigureWindow(
TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
TkMacOSXWinBounds(winPtr, &bounds);
r = NSMakeRect(bounds.left,
- [view bounds].size.height - bounds.bottom,
- bounds.right - bounds.left, bounds.bottom - bounds.top);
+ [view bounds].size.height - bounds.bottom,
+ bounds.right - bounds.left, bounds.bottom - bounds.top);
[view setNeedsDisplayInRect:r];
}
}
- /* TkGenWMMoveRequestEvent(macWin->winPtr,
- macWin->winPtr->changes.x, macWin->winPtr->changes.y); */
+#if 0
+ TkGenWMMoveRequestEvent(macWin->winPtr,
+ macWin->winPtr->changes.x, macWin->winPtr->changes.y);
+#endif
}
/*
@@ -723,14 +725,14 @@ XConfigureWindow(
void
TkMacOSXSetDrawingEnabled(
- TkWindow *winPtr,
- int flag)
+ TkWindow *winPtr,
+ int flag)
{
TkWindow *childPtr;
MacDrawable *macWin = winPtr->privatePtr;
if (macWin) {
- if (flag ) {
+ if (flag) {
macWin->flags &= ~TK_DO_NOT_DRAW;
} else {
macWin->flags |= TK_DO_NOT_DRAW;
@@ -738,8 +740,8 @@ TkMacOSXSetDrawingEnabled(
}
/*
- * Set the flag for all children & their descendants, excluding
- * Toplevels. (??? Do we need to exclude Toplevels?)
+ * Set the flag for all children & their descendants, excluding Toplevels.
+ * (??? Do we need to exclude Toplevels?)
*/
childPtr = winPtr->childList;
@@ -903,7 +905,6 @@ TkMacOSXUpdateClipRgn(
}
CFRelease(rgn);
} else {
-
/*
* An unmapped window has empty clip regions to prevent any
* (erroneous) drawing into it or its children from becoming
@@ -933,8 +934,8 @@ TkMacOSXUpdateClipRgn(
* TkMacOSXVisableClipRgn --
*
* This function returns the Macintosh clipping region for the given
- * window. The caller is responsible for disposing of the returned
- * region via TkDestroyRegion().
+ * window. The caller is responsible for disposing of the returned region
+ * via TkDestroyRegion().
*
* Results:
* The region.
@@ -952,7 +953,7 @@ TkMacOSXVisableClipRgn(
if (winPtr->privatePtr->flags & TK_CLIP_INVALID) {
TkMacOSXUpdateClipRgn(winPtr);
}
- return (TkRegion)HIShapeCreateMutableCopy(winPtr->privatePtr->visRgn);
+ return (TkRegion) HIShapeCreateMutableCopy(winPtr->privatePtr->visRgn);
}
/*
@@ -972,7 +973,12 @@ TkMacOSXVisableClipRgn(
*/
static OSStatus
-InvalViewRect(int msg, HIShapeRef rgn, const CGRect *rect, void *ref) {
+InvalViewRect(
+ int msg,
+ HIShapeRef rgn,
+ const CGRect *rect,
+ void *ref)
+{
static CGAffineTransform t;
NSView *view = ref;
@@ -1052,7 +1058,7 @@ TkMacOSXInvalidateWindow(
*----------------------------------------------------------------------
*/
-NSWindow*
+NSWindow *
TkMacOSXDrawableWindow(
Drawable drawable)
{
@@ -1070,6 +1076,7 @@ TkMacOSXDrawableWindow(
result = macWin->winPtr->wmInfoPtr->window;
} else if (macWin->toplevel && (macWin->toplevel->flags & TK_EMBEDDED)) {
TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+
if (contWinPtr) {
result = TkMacOSXDrawableWindow((Drawable) contWinPtr->privatePtr);
}
@@ -1123,7 +1130,7 @@ TkMacOSXGetDrawablePort(
*----------------------------------------------------------------------
*/
-NSView*
+NSView *
TkMacOSXDrawableView(
MacDrawable *macWin)
{
@@ -1137,6 +1144,7 @@ TkMacOSXDrawableView(
result = macWin->toplevel->view;
} else {
TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
+
if (contWinPtr) {
result = TkMacOSXDrawableView(contWinPtr->privatePtr);
}
@@ -1164,7 +1172,6 @@ void *
TkMacOSXGetRootControl(
Drawable drawable)
{
-
/*
* will probably need to fix this up for embedding
*/
@@ -1281,7 +1288,8 @@ TkMacOSXWinBounds(
TkWindow *winPtr,
void *bounds)
{
- Rect *b = (Rect *)bounds;
+ Rect *b = (Rect *) bounds;
+
b->left = winPtr->privatePtr->xOff;
b->top = winPtr->privatePtr->yOff;
b->right = b->left + winPtr->changes.width;
@@ -1345,7 +1353,6 @@ UpdateOffsets(
TkWindow *childPtr;
if (winPtr->privatePtr == NULL) {
-
/*
* We haven't called Tk_MakeWindowExist for this window yet. The offset
* information will be postponed and calulated at that time. (This will