summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWm.c
diff options
context:
space:
mode:
authordas <das>2007-12-12 23:44:21 (GMT)
committerdas <das>2007-12-12 23:44:21 (GMT)
commiteab645efcaf1952d13741e71ca0568212af825b5 (patch)
tree40bd58482b0bf7ee90a5ccb229822b551da0f0ec /macosx/tkMacOSXWm.c
parent1f1ea982a78eacbb0d096ed73ca61e5fe2ba5add (diff)
downloadtk-eab645efcaf1952d13741e71ca0568212af825b5.zip
tk-eab645efcaf1952d13741e71ca0568212af825b5.tar.gz
tk-eab645efcaf1952d13741e71ca0568212af825b5.tar.bz2
* macosx/tkMacOSXWm.c (ApplyMasterOverrideChanges): Revert 2007-10-26
change to window class of transient toplevels that are not also overrideredirect. [Bug 1845899] * macosx/tkMacOSXWm.c (ApplyMasterOverrideChanges): Implement more * macosx/tkMacOSXMouseEvent.c (BringWindowForward): X11-like transient * macosx/tkMacOSXSubwindows.c (XDestroyWindow): behaviour by adding transient windows to a window group owned by the master window, this ensures transients always remain in front of and are collapsed with the master; bring master to front when selecting transient windows; restore default window group of transients if master destroyed. [Bug 1845899]
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r--macosx/tkMacOSXWm.c109
1 files changed, 77 insertions, 32 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index d4f6502..8f728e1 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXWm.c,v 1.61 2007/11/09 06:23:29 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.62 2007/12/12 23:44:21 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -170,6 +170,7 @@ static void ApplyWindowClassAttributeChanges(TkWindow *winPtr,
WindowRef macWindow, WindowClass oldClass,
WindowAttributes oldAttributes, int create);
static void ApplyMasterOverrideChanges(TkWindow *winPtr, WindowRef macWindow);
+static WindowGroupRef WmGetWindowGroup(TkWindow *winPtr);
static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr);
static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr);
static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin);
@@ -852,11 +853,10 @@ static int WmSetAttribute(
if (boolean) {
wmPtr->flags |= WM_TOPMOST;
- group = GetWindowGroupOfClass(kUtilityWindowClass);
} else {
wmPtr->flags &= ~WM_TOPMOST;
- group = GetWindowGroupOfClass(wmPtr->macClass);
}
+ group = WmGetWindowGroup(winPtr);
if (group && group != GetWindowGroup(macWindow)) {
ChkErr(SetWindowGroup, macWindow, group);
}
@@ -6040,55 +6040,100 @@ ApplyMasterOverrideChanges(
WmInfo *wmPtr = winPtr->wmInfoPtr;
WindowClass oldClass = wmPtr->macClass;
WindowAttributes oldAttributes = wmPtr->attributes;
- const int wasOverrideredirect = (oldClass == kSimpleWindowClass &&
- oldAttributes == kWindowNoActivatesAttribute);
- const int wasTransient = (oldClass == kPlainWindowClass &&
- oldAttributes == kWindowNoAttributes);
- const int wasDefault = (oldClass == kDocumentWindowClass);
/*
* FIX: We need an UpdateWrapper equivalent to make this 100% correct
*/
+
if (winPtr->atts.override_redirect) {
- if (wasDefault || (wmPtr->master != None && wasTransient)) {
+ if (oldClass == kDocumentWindowClass) {
wmPtr->macClass = kSimpleWindowClass;
wmPtr->attributes = kWindowNoAttributes;
}
wmPtr->attributes |= kWindowNoActivatesAttribute;
} else {
- if (wmPtr->master != None) {
- if (wasDefault || wasOverrideredirect) {
- wmPtr->macClass = kPlainWindowClass;
- wmPtr->attributes = kWindowNoAttributes;
- }
- } else {
- if (wasTransient || wasOverrideredirect) {
- wmPtr->macClass = kDocumentWindowClass;
- wmPtr->attributes = kWindowStandardDocumentAttributes
- | kWindowLiveResizeAttribute;
- }
+ if (oldClass == kSimpleWindowClass &&
+ oldAttributes == kWindowNoActivatesAttribute) {
+ wmPtr->macClass = kDocumentWindowClass;
+ wmPtr->attributes = kWindowStandardDocumentAttributes
+ | kWindowLiveResizeAttribute;
}
wmPtr->attributes &= ~kWindowNoActivatesAttribute;
}
- if (!macWindow) {
- if (winPtr->window == None) {
- return;
- }
- if (!TkMacOSXHostToplevelExists(winPtr)) {
- return;
- }
+ if (!macWindow && winPtr->window != None &&
+ TkMacOSXHostToplevelExists(winPtr)) {
macWindow = TkMacOSXDrawableWindow(winPtr->window);
}
if (macWindow) {
- Tcl_Obj *val;
+ WindowGroupRef group;
ApplyWindowClassAttributeChanges(winPtr, macWindow, oldClass,
oldAttributes, 0);
- val = Tcl_NewBooleanObj(winPtr->atts.override_redirect &&
- wmPtr->master != None);
- WmSetAttribute(winPtr, macWindow, NULL, WMATT_TOPMOST, val);
- Tcl_DecrRefCount(val);
+
+ if (winPtr->atts.override_redirect && wmPtr->master != None) {
+ wmPtr->flags |= WM_TOPMOST;
+ } else {
+ wmPtr->flags &= ~WM_TOPMOST;
+ }
+ group = WmGetWindowGroup(winPtr);
+ if (group && group != GetWindowGroup(macWindow)) {
+ ChkErr(SetWindowGroup, macWindow, group);
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * WmGetWindowGroup --
+ *
+ * Gets the window group a toplevel should be placed in.
+ *
+ * Results:
+ * A WindowGroupRef.
+ *
+ * Side effects:
+ * A transient window group for the master (if any) may be created.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static WindowGroupRef
+WmGetWindowGroup(
+ TkWindow *winPtr)
+{
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ WindowGroupRef group = NULL;
+
+ if (wmPtr->flags & WM_TOPMOST) {
+ group = GetWindowGroupOfClass(kUtilityWindowClass);
+ } else if (wmPtr->master != None) {
+ TkDisplay *dispPtr = TkGetDisplayList();
+ TkWindow *masterWinPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display,
+ wmPtr->master);
+
+ if (masterWinPtr && masterWinPtr->window != None &&
+ TkMacOSXHostToplevelExists(masterWinPtr)) {
+ WindowRef masterMacWin =
+ TkMacOSXDrawableWindow(masterWinPtr->window);
+
+ if (masterMacWin && GetWindowProperty(masterMacWin, 'Tk ', 'TsGp',
+ sizeof(group), NULL, &group) != noErr) {
+ ChkErr(CreateWindowGroup, 0, &group);
+ if (group) {
+ ChkErr(SetWindowGroupParent, group,
+ GetWindowGroup(masterMacWin));
+ ChkErr(SetWindowGroupOwner, group, masterMacWin);
+ ChkErr(SetWindowProperty, masterMacWin, 'Tk ', 'TsGp',
+ sizeof(group), &group);
+ }
+ }
+ }
+ }
+ if (!group) {
+ group = GetWindowGroupOfClass(wmPtr->macClass);
}
+ return group;
}
/*