diff options
author | das <das> | 2007-12-18 18:21:29 (GMT) |
---|---|---|
committer | das <das> | 2007-12-18 18:21:29 (GMT) |
commit | be55f56a1e6843f4a67dbf48ff88008c9d5c1f6f (patch) | |
tree | 9955e412e61973061382f7bcd8b31ce10831c4e2 /macosx | |
parent | 966ff06117278ef28754933ca7c39695f8177acd (diff) | |
download | tk-be55f56a1e6843f4a67dbf48ff88008c9d5c1f6f.zip tk-be55f56a1e6843f4a67dbf48ff88008c9d5c1f6f.tar.gz tk-be55f56a1e6843f4a67dbf48ff88008c9d5c1f6f.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')
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 25 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 37 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 111 |
3 files changed, 138 insertions, 35 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index bf1e3ae..2340e92 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.22 2007/07/09 08:32:12 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.23 2007/12/18 18:21:30 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -555,6 +555,29 @@ BringWindowForward( ChkErr(GetWindowModality, frontWindow, &frontWindowModality, NULL); } if (frontWindowModality != kWindowModalityAppModal) { + Window window = TkMacOSXGetXWindow(wRef); + + if (window != None) { + TkDisplay *dispPtr = TkGetDisplayList(); + TkWindow * winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, + window); + + if (winPtr && winPtr->wmInfoPtr && + winPtr->wmInfoPtr->master != None) { + TkWindow *masterWinPtr = (TkWindow *)Tk_IdToWindow( + dispPtr->display, winPtr->wmInfoPtr->master); + + if (masterWinPtr && masterWinPtr->window != None && + TkMacOSXHostToplevelExists(masterWinPtr)) { + WindowRef masterMacWin = + TkMacOSXDrawableWindow(masterWinPtr->window); + + if (masterMacWin) { + BringToFront(masterMacWin); + } + } + } + } SelectWindow(wRef); } else { frontWindowOnly = 0; diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index c06dbda..0b46f7c 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.21 2007/11/09 06:26:56 das Exp $ + * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.22 2007/12/18 18:21:31 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -109,7 +109,42 @@ XDestroyWindow( if (winRef) { TkMacOSXWindowList *listPtr, *prevPtr; + WindowGroupRef group; + + if (GetWindowProperty(winRef, 'Tk ', 'TsGp', sizeof(group), + NULL, &group) == noErr) { + TkDisplay *dispPtr = TkGetDisplayList(); + ItemCount i = CountWindowGroupContents(group, + kWindowGroupContentsReturnWindows); + + while (i > 0) { + WindowRef macWin; + + ChkErr(GetIndexedWindow, group, i--, 0, &macWin); + if (macWin) { + WindowGroupRef newGroup = NULL; + Window window = TkMacOSXGetXWindow(macWin); + + if (window != None) { + TkWindow * winPtr = (TkWindow *)Tk_IdToWindow( + dispPtr->display, window); + + if (winPtr && winPtr->wmInfoPtr) { + newGroup = GetWindowGroupOfClass( + winPtr->wmInfoPtr->macClass); + } + } + if (!newGroup) { + newGroup = GetWindowGroupOfClass( + kDocumentWindowClass); + } + ChkErr(SetWindowGroup, macWin, newGroup); + } + } + ChkErr(SetWindowGroupOwner, group, NULL); + ChkErr(ReleaseWindowGroup, group); + } TkMacOSXUnregisterMacWindow(winRef); DisposeWindow(winRef); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a25512e..bbc458f 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.7.2.45 2007/11/09 06:26:57 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.46 2007/12/18 18:21:31 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -67,7 +67,7 @@ static int wmTracing = 0; static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin); -static Tk_GeomMgr wmMgrType = { +static /* const */ Tk_GeomMgr wmMgrType = { "wm", /* name */ TopLevelReqProc, /* requestProc */ (Tk_GeomLostSlaveProc *) NULL, /* lostSlaveProc */ @@ -176,6 +176,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); #if 0 @@ -868,11 +869,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); } @@ -6062,55 +6062,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; } /* |