diff options
author | culler <culler> | 2019-11-08 06:51:55 (GMT) |
---|---|---|
committer | culler <culler> | 2019-11-08 06:51:55 (GMT) |
commit | 26733057747b9f7db38abe7f8c3a75132a8881f6 (patch) | |
tree | 22d69df81d09e0c21d9bbff005fdf4fef90ed232 /macosx | |
parent | 5a3617067387db921c9984395fbe013d68dc1d24 (diff) | |
download | tk-26733057747b9f7db38abe7f8c3a75132a8881f6.zip tk-26733057747b9f7db38abe7f8c3a75132a8881f6.tar.gz tk-26733057747b9f7db38abe7f8c3a75132a8881f6.tar.bz2 |
Reimplement TkWmStackorderToplevel to make it straightforward and shorter and behave the same on macOS as on unix and Windows.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXWm.c | 56 |
1 files changed, 13 insertions, 43 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index dda6c19..dfe3a26 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6621,7 +6621,7 @@ WmStackorderToplevelWrapperMap( Tcl_HashEntry *hPtr; int newEntry; - if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) + if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { hPtr = Tcl_CreateHashEntry(table, (char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry); @@ -6642,8 +6642,8 @@ WmStackorderToplevelWrapperMap( * This procedure returns the stack order of toplevel windows. * * Results: - * An array of pointers to tk window objects in stacking order or else - * NULL if there was an error. + * A NULL terminated array of pointers to tk window objects in stacking + * order or else NULL if there was an error. * * Side effects: * None. @@ -6658,52 +6658,22 @@ TkWmStackorderToplevel( TkWindow *childWinPtr, **windows, **windowPtr; Tcl_HashTable table; Tcl_HashEntry *hPtr; - Tcl_HashSearch search; - - /* - * Map mac windows to a TkWindow of the wrapped toplevel. - */ + NSArray *macWindows = [NSApp orderedWindows]; + NSArray* backToFront = [[macWindows reverseObjectEnumerator] allObjects]; + NSInteger windowCount = [macWindows count]; + windows = windowPtr = ckalloc((windowCount + 1) * sizeof(TkWindow *)); Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); - windows = ckalloc((table.numEntries+1) * sizeof(TkWindow *)); - - /* - * Special cases: If zero or one toplevels were mapped there is no need to - * enumerate Windows. - */ - - switch (table.numEntries) { - case 0: - windows[0] = NULL; - goto done; - case 1: - hPtr = Tcl_FirstHashEntry(&table, &search); - windows[0] = Tcl_GetHashValue(hPtr); - windows[1] = NULL; - goto done; - } - - NSArray *macWindows = [NSApp orderedWindows]; - NSInteger windowCount = [macWindows count]; - - if (!windowCount) { - ckfree(windows); - windows = NULL; - } else { - windowPtr = windows + table.numEntries; - *windowPtr-- = NULL; - for (NSWindow *w in macWindows) { - hPtr = Tcl_FindHashEntry(&table, (char*) w); - if (hPtr != NULL) { - childWinPtr = Tcl_GetHashValue(hPtr); - *windowPtr-- = childWinPtr; - } + for (NSWindow *w in backToFront) { + hPtr = Tcl_FindHashEntry(&table, (char*) w); + if (hPtr != NULL) { + childWinPtr = Tcl_GetHashValue(hPtr); + *windowPtr++ = childWinPtr; } } - - done: + *windowPtr = NULL; Tcl_DeleteHashTable(&table); return windows; } |