summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog25
-rw-r--r--macosx/tkMacOSXButton.c4
-rw-r--r--macosx/tkMacOSXDialog.c14
-rw-r--r--macosx/tkMacOSXEmbed.c107
-rw-r--r--macosx/tkMacOSXInt.h3
-rw-r--r--macosx/tkMacOSXMouseEvent.c81
-rw-r--r--macosx/tkMacOSXScrlbr.c13
-rw-r--r--macosx/tkMacOSXSubwindows.c10
-rw-r--r--macosx/tkMacOSXWindowEvent.c264
9 files changed, 281 insertions, 240 deletions
diff --git a/ChangeLog b/ChangeLog
index 55e2991..0f22b1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2007-05-09 Daniel Steffen <das@users.sourceforge.net>
+
+ * generic/tkFileFilter.c (AddClause): OSType endianness fixes.
+
+ * library/palette.tcl (tk::RecolorTree): handle color options with
+ empty value, fixes error due to emtpy -selectforeground (reported on
+ tcl-mac by Russel E. Owen).
+
+ * macosx/tkMacOSXWindowEvent.c: ensure window is brought to the front
+ * macosx/tkMacOSXMouseEvent.c: at the start of a window drag (except
+ * macosx/tkMacOSXInt.h: when cmd key is down); formatting and
+ whitespace fixes.
+
+ * macosx/tkMacOSXDialog.c (Tk_GetSaveFileObjCmd): add -filetypes option
+ processing.
+
+ * macosx/tkMacOSXEmbed.c (TkpMakeWindow, TkpUseWindow): fix sending of
+ Visibility event for embedded windows (fixes frame-3.9 hang).
+
+ * macosx/tkMacOSXScrlbr.c (ScrollbarBindProc): fix testsuite
+ * macosx/tkMacOSXSubwindows.c (TkMacOSXUpdateClipRgn): crashes by
+ adding sanity checks.
+
+ * macosx/tkMacOSXButton.c: fix debug msg typo.
+
2007-04-29 Daniel Steffen <das@users.sourceforge.net>
* generic/tkCanvas.c: allow -selectforeground option to be None; add
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 65e1043..5180734 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXButton.c,v 1.2.2.15 2007/04/29 02:26:47 das Exp $
+ * RCS: @(#) $Id: tkMacOSXButton.c,v 1.2.2.16 2007/05/09 12:57:45 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -825,7 +825,7 @@ TkMacOSXInitControl(
mbPtr->params.procID, controlReference);
if (!mbPtr->control) {
- TkMacOSXDbgMsg("failed to create control of type %d\n", procID);
+ TkMacOSXDbgMsg("Failed to create control of type %d\n", procID);
return 1;
}
if (ChkErr(EmbedControl, mbPtr->control,mbPtr->userPane) != noErr ) {
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 538056a..c496cbf 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.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: tkMacOSXDialog.c,v 1.4.2.13 2007/04/29 02:26:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.4.2.14 2007/05/09 12:57:46 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -424,9 +424,14 @@ Tk_GetSaveFileObjCmd(
InitFileDialogs();
}
+ TkInitFileFilters(&ofd.fl);
+ ofd.curType = 0;
+ ofd.usePopup = 0;
+
for (i = 1; i < objc; i += 2) {
char *choice, *string;
int index, choiceLen;
+ char *types;
if (Tcl_GetIndexFromObj(interp, objv[i], saveOptionStrings, "option",
TCL_EXACT, &index) != TCL_OK) {
@@ -442,7 +447,10 @@ Tk_GetSaveFileObjCmd(
case SAVE_DEFAULT:
break;
case SAVE_FILETYPES:
- /* Currently unimplemented - what would we do here anyway? */
+ types = Tcl_GetString(objv[i + 1]);
+ if (TkGetFileFilters(interp, &ofd.fl, types, 0) != TCL_OK) {
+ goto end;
+ }
break;
case SAVE_INITDIR:
choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
@@ -480,8 +488,6 @@ Tk_GetSaveFileObjCmd(
}
}
- TkInitFileFilters(&ofd.fl);
- ofd.usePopup = 0;
if (initialDesc.descriptorType == typeFSRef) {
initialPtr = &initialDesc;
}
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 4c6c69c..aaa38bc 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.2.2.5 2007/04/29 02:26:48 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.2.2.6 2007/05/09 12:57:46 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -135,49 +135,49 @@ TkpMakeWindow(
*/
if (Tk_IsEmbedded(winPtr)) {
- return (Window) winPtr->privatePtr;
- }
-
- /*
- * Allocate sub window
- */
-
- macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable));
- if (macWin == NULL) {
- winPtr->privatePtr = NULL;
- return None;
- }
- macWin->winPtr = winPtr;
- winPtr->privatePtr = macWin;
- macWin->clipRgn = NewRgn();
- macWin->aboveClipRgn = NewRgn();
- macWin->drawRgn = NewRgn();
- macWin->referenceCount = 0;
- macWin->flags = TK_CLIP_INVALID;
-
- macWin->grafPtr = NULL;
- macWin->context = NULL;
- if (Tk_IsTopLevel(macWin->winPtr)) {
+ macWin = winPtr->privatePtr;
+ } else {
/*
- *This will be set when we are mapped.
+ * Allocate sub window
*/
- macWin->xOff = 0;
- macWin->yOff = 0;
- macWin->toplevel = macWin;
- } else {
- macWin->xOff = winPtr->parentPtr->privatePtr->xOff +
- winPtr->parentPtr->changes.border_width +
- winPtr->changes.x;
- macWin->yOff = winPtr->parentPtr->privatePtr->yOff +
- winPtr->parentPtr->changes.border_width +
- winPtr->changes.y;
- macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel;
- }
- macWin->toplevel->referenceCount++;
+ macWin = (MacDrawable *) ckalloc(sizeof(MacDrawable));
+ if (macWin == NULL) {
+ winPtr->privatePtr = NULL;
+ return None;
+ }
+ macWin->winPtr = winPtr;
+ winPtr->privatePtr = macWin;
+ macWin->clipRgn = NewRgn();
+ macWin->aboveClipRgn = NewRgn();
+ macWin->drawRgn = NewRgn();
+ macWin->referenceCount = 0;
+ macWin->flags = TK_CLIP_INVALID;
+
+ macWin->grafPtr = NULL;
+ macWin->context = NULL;
+ if (Tk_IsTopLevel(macWin->winPtr)) {
+ /*
+ *This will be set when we are mapped.
+ */
+ macWin->xOff = 0;
+ macWin->yOff = 0;
+ macWin->toplevel = macWin;
+ } else {
+ macWin->xOff = winPtr->parentPtr->privatePtr->xOff +
+ winPtr->parentPtr->changes.border_width +
+ winPtr->changes.x;
+ macWin->yOff = winPtr->parentPtr->privatePtr->yOff +
+ winPtr->parentPtr->changes.border_width +
+ winPtr->changes.y;
+ macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel;
+ }
+ macWin->toplevel->referenceCount++;
+ }
/*
* TODO: need general solution for visibility events.
*/
+
event.xany.serial = Tk_Display(winPtr)->request;
event.xany.send_event = False;
event.xany.display = Tk_Display(winPtr);
@@ -225,7 +225,6 @@ TkpUseWindow(
TkWindow *usePtr;
MacDrawable *parent, *macWin;
Container *containerPtr;
- XEvent event;
if (winPtr->window != None) {
Tcl_AppendResult(interp, "can't modify container after widget is "
@@ -235,7 +234,7 @@ TkpUseWindow(
/*
* Decode the container pointer, and look for it among the
- *list of available containers.
+ * list of available containers.
*
* N.B. For now, we are limiting the containers to be in the same Tk
* application as tkwin, since otherwise they would not be in our list
@@ -380,34 +379,6 @@ TkpUseWindow(
}
- /*
- * TODO: need general solution for visibility events.
- */
-
-
- event.xany.serial = Tk_Display(winPtr)->request;
- event.xany.send_event = False;
- event.xany.display = Tk_Display(winPtr);
-
- event.xvisibility.type = VisibilityNotify;
- event.xvisibility.window = (Window) macWin;;
- event.xvisibility.state = VisibilityUnobscured;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
-
- /*
- * TODO: need general solution for visibility events.
- */
-
- event.xany.serial = Tk_Display(winPtr)->request;
- event.xany.send_event = False;
- event.xany.display = Tk_Display(winPtr);
-
- event.xvisibility.type = VisibilityNotify;
- event.xvisibility.window = (Window) macWin;;
- event.xvisibility.state = VisibilityUnobscured;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
return TCL_OK;
}
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 538157a..ffc7bff 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -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: tkMacOSXInt.h,v 1.3.2.16 2007/04/29 02:26:49 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.17 2007/05/09 12:57:46 das Exp $
*/
#ifndef _TKMACINT
@@ -304,6 +304,7 @@ MODULE_SCOPE void TkMacOSXInstallWindowCarbonEventHandler(Tcl_Interp *interp,
MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, WindowRef window,
int fullscreen, Tcl_Interp *interp);
MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, int active);
+MODULE_SCOPE void TkMacOSXBringWindowForward(WindowRef wRef);
MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module,
const char* symbol);
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index bc8dff8..a44118d 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.18 2007/04/29 02:26:49 das Exp $
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.19 2007/05/09 12:57:46 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -304,29 +304,31 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
*/
if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
return result;
- } else
- /*
- * Only windows with the kWindowNoActivatesAttribute can
- * receive mouse events in the background.
- */
- if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes &
- kWindowNoActivatesAttribute)) {
- /*
- * Allow background window dragging & growing with Command down
- */
- if (!((medPtr->windowPart == inDrag ||
- medPtr->windowPart == inGrow) &&
- medPtr->state & Mod1Mask)) {
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(medPtr->whichWin, isFrontProcess);
- }
+ } else {
/*
- * Allow dragging & growing of windows that were/are in the
- * background.
+ * Only windows with the kWindowNoActivatesAttribute can
+ * receive mouse events in the background.
*/
- if (!(medPtr->windowPart == inDrag ||
- medPtr->windowPart == inGrow)) {
- return false;
+ if (!(((TkWindow *)tkwin)->wmInfoPtr->attributes &
+ kWindowNoActivatesAttribute)) {
+ /*
+ * Allow background window dragging & growing with Command
+ * down.
+ */
+ if (!((medPtr->windowPart == inDrag ||
+ medPtr->windowPart == inGrow) &&
+ medPtr->state & Mod1Mask)) {
+ TkMacOSXSetEatButtonUp(true);
+ BringWindowForward(medPtr->whichWin, isFrontProcess);
+ }
+ /*
+ * Allow dragging & growing of windows that were/are in the
+ * background.
+ */
+ if (!(medPtr->windowPart == inDrag ||
+ medPtr->windowPart == inGrow)) {
+ return false;
+ }
}
}
} else {
@@ -513,8 +515,7 @@ GeneratePollingEvents(MouseEventData * medPtr)
*
* BringWindowForward --
*
- * Bring this background window to the front. We also set state
- * so Tk thinks the button is currently up.
+ * Bring this background window to the front.
*
* Results:
* None.
@@ -546,6 +547,38 @@ BringWindowForward(
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXBringWindowForward --
+ *
+ * Bring this background window to the front (wrapper around
+ * BringWindowForward()).
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The window is brought forward.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkMacOSXBringWindowForward(
+ WindowRef wRef)
+{
+ OSStatus err;
+ ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess};
+ Boolean isFrontProcess = true;
+
+ err = ChkErr(GetFrontProcess, &frontPsn);
+ if (err == noErr) {
+ ChkErr(SameProcess, &frontPsn, &ourPsn, &isFrontProcess);
+ }
+ BringWindowForward(wRef, isFrontProcess);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* GenerateMouseWheelEvent --
*
* Generates a "MouseWheel" Tk event.
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 0fa6561..4d2cb07 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.5.2.11 2007/04/29 02:26:50 das Exp $
+ * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.5.2.12 2007/05/09 12:57:46 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -846,7 +846,9 @@ ScrollbarBindProc(
* Workaround for Carbon bug where the scrollbar down arrow
* sometimes gets "stuck" after the mousebutton has been released.
*/
- TkMacOSXSetUpClippingRgn(Tk_WindowId(scrollPtr->tkwin));
+ if (scrollPtr->tkwin) {
+ TkMacOSXSetUpClippingRgn(Tk_WindowId(scrollPtr->tkwin));
+ }
Draw1Control(macScrollPtr->sbHandle);
}
TkMacOSXTrackingLoop(0);
@@ -855,8 +857,11 @@ ScrollbarBindProc(
* The HandleControlClick call will "eat" the ButtonUp event. We now
* generate a ButtonUp event so Tk will unset implicit grabs etc.
*/
- window = Tk_WindowId(scrollPtr->tkwin);
- TkGenerateButtonEventForXPointer(window);
+
+ if (scrollPtr->tkwin) {
+ window = Tk_WindowId(scrollPtr->tkwin);
+ TkGenerateButtonEventForXPointer(window);
+ }
if (portChanged) {
QDSwapPort(savePort, NULL);
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 18dc2ec..564ad77 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.14 2007/04/29 02:26:50 das Exp $
+ * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.2.2.15 2007/05/09 12:57:47 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -844,8 +844,10 @@ TkMacOSXUpdateClipRgn(
if (!Tk_IsTopLevel(winPtr)) {
TkMacOSXUpdateClipRgn(winPtr->parentPtr);
TkMacOSXCheckTmpRgnEmpty(1);
- SectRgn(rgn,
- winPtr->parentPtr->privatePtr->aboveClipRgn, rgn);
+ if (winPtr->parentPtr) {
+ SectRgn(rgn,
+ winPtr->parentPtr->privatePtr->aboveClipRgn, rgn);
+ }
win2Ptr = winPtr->nextPtr;
while (win2Ptr != NULL) {
@@ -1115,7 +1117,7 @@ TkMacOSXGetDrawablePort(
* of the time, this is harmless... However, we really need to
* find why the embedding loses.
*/
- DebugStr("\pTkMacOSXGetDrawablePort couldn't find container");
+ TkMacOSXDbgMsg("Couldn't find container");
return NULL;
}
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 86fc381..2002739 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.18 2007/04/29 02:26:50 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.19 2007/05/09 12:57:47 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -266,10 +266,10 @@ TkMacOSXProcessWindowEvent(
dispPtr = TkGetDisplayList();
winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
- if (window != None) {
- switch (eventPtr->eKind) {
- case kEventWindowActivated:
- case kEventWindowDeactivated: {
+ switch (eventPtr->eKind) {
+ case kEventWindowActivated:
+ case kEventWindowDeactivated:
+ if (window != None) {
int activate = (eventPtr->eKind == kEventWindowActivated);
eventFound |= GenerateActivateEvents(window, activate);
@@ -278,146 +278,144 @@ TkMacOSXProcessWindowEvent(
TkMacOSXEnterExitFullscreen(winPtr, activate);
}
statusPtr->stopProcessing = 1;
- break;
}
- case kEventWindowUpdate:
- if (GenerateUpdateEvent(window)) {
- eventFound = true;
- statusPtr->stopProcessing = 1;
- }
- break;
- case kEventWindowExpanded:
- if (winPtr) {
- TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
- ZoomState : NormalState);
- }
- break;
- case kEventWindowBoundsChanged:
- if (winPtr) {
- WmInfo *wmPtr = winPtr->wmInfoPtr;
- UInt32 attr;
- Rect bounds;
- int x = -1, y = -1, width = -1, height = -1, flags = 0;
-
- ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamAttributes, typeUInt32,
- NULL, sizeof(attr), NULL, &attr);
- ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamCurrentBounds, typeQDRectangle,
- NULL, sizeof(bounds), NULL, &bounds);
- if (attr & kWindowBoundsChangeOriginChanged) {
- x = bounds.left - wmPtr->xInParent;
- y = bounds.top - wmPtr->yInParent;
- flags |= TK_LOCATION_CHANGED;
- }
- if (attr & kWindowBoundsChangeSizeChanged) {
- width = bounds.right - bounds.left;
- height = bounds.bottom - bounds.top;
- flags |= TK_SIZE_CHANGED;
- }
- TkGenWMConfigureEvent((Tk_Window)winPtr, x, y, width,
- height, flags);
- if (attr & kWindowBoundsChangeUserResize ||
- attr & kWindowBoundsChangeUserDrag) {
- TkMacOSXRunTclEventLoop();
- }
- if (wmPtr->attributes & kWindowResizableAttribute) {
- HIViewRef growBoxView;
-
- err = HIViewFindByID(HIViewGetRoot(whichWindow),
- kHIViewWindowGrowBoxID, &growBoxView);
- if (err == noErr) {
- ChkErr(HIViewSetNeedsDisplay, growBoxView, true);
- }
- }
+ break;
+ case kEventWindowUpdate:
+ if (window != None && GenerateUpdateEvent(window)) {
+ eventFound = true;
+ statusPtr->stopProcessing = 1;
+ }
+ break;
+ case kEventWindowExpanded:
+ if (winPtr) {
+ TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
+ ZoomState : NormalState);
+ }
+ break;
+ case kEventWindowBoundsChanged:
+ if (winPtr) {
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ UInt32 attr;
+ Rect bounds;
+ int x = -1, y = -1, width = -1, height = -1, flags = 0;
+
+ ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamAttributes, typeUInt32,
+ NULL, sizeof(attr), NULL, &attr);
+ ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamCurrentBounds, typeQDRectangle,
+ NULL, sizeof(bounds), NULL, &bounds);
+ if (attr & kWindowBoundsChangeOriginChanged) {
+ x = bounds.left - wmPtr->xInParent;
+ y = bounds.top - wmPtr->yInParent;
+ flags |= TK_LOCATION_CHANGED;
}
- break;
- case kEventWindowDragStarted:
- if (winPtr) {
- TkMacOSXTrackingLoop(1);
+ if (attr & kWindowBoundsChangeSizeChanged) {
+ width = bounds.right - bounds.left;
+ height = bounds.bottom - bounds.top;
+ flags |= TK_SIZE_CHANGED;
}
- break;
- case kEventWindowDragCompleted:
- if (winPtr) {
- Rect maxBounds, bounds, strWidths;
- int h = 0, v = 0;
-
- TkMacOSXTrackingLoop(0);
- ChkErr(GetWindowGreatestAreaDevice, whichWindow,
- kWindowDragRgn, NULL, &maxBounds);
- ChkErr(GetWindowBounds, whichWindow, kWindowStructureRgn,
- &bounds);
- ChkErr(GetWindowStructureWidths, whichWindow, &strWidths);
- if (bounds.left > maxBounds.right - strWidths.left) {
- h = maxBounds.right
- - (strWidths.left ? strWidths.left : 40)
- - bounds.left;
- } else if (bounds.right < maxBounds.left
- + strWidths.right) {
- h = maxBounds.left
- + (strWidths.right ? strWidths.right : 40)
- - bounds.right;
- }
- if (bounds.top > maxBounds.bottom - strWidths.top) {
- v = maxBounds.bottom
- - (strWidths.top ? strWidths.top : 40)
- - bounds.top;
- } else if (bounds.bottom < maxBounds.top
- + strWidths.bottom) {
- v = maxBounds.top
- + (strWidths.bottom ? strWidths.bottom : 40)
- - bounds.bottom;
- } else if (strWidths.top && bounds.top < maxBounds.top) {
- v = maxBounds.top - bounds.top;
- }
- if (h || v) {
- OffsetRect(&bounds, h, v);
- ChkErr(SetWindowBounds, whichWindow,
- kWindowStructureRgn, &bounds);
- }
+ TkGenWMConfigureEvent((Tk_Window)winPtr, x, y, width,
+ height, flags);
+ if (attr & kWindowBoundsChangeUserResize ||
+ attr & kWindowBoundsChangeUserDrag) {
+ TkMacOSXRunTclEventLoop();
}
- break;
- case kEventWindowConstrain:
- if (winPtr) {
- if (winPtr->wmInfoPtr->flags & WM_FULLSCREEN &&
- TkMacOSXMakeFullscreen(winPtr, whichWindow, 1,
- NULL) == TCL_OK) {
- statusPtr->stopProcessing = 1;
+ if (wmPtr->attributes & kWindowResizableAttribute) {
+ HIViewRef growBoxView;
+
+ err = HIViewFindByID(HIViewGetRoot(whichWindow),
+ kHIViewWindowGrowBoxID, &growBoxView);
+ if (err == noErr) {
+ ChkErr(HIViewSetNeedsDisplay, growBoxView, true);
}
}
- break;
- case kEventWindowGetRegion:
- if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) {
- WindowRegionCode code;
+ }
+ break;
+ case kEventWindowDragStarted:
+ TkMacOSXTrackingLoop(1);
+ if (!(TkMacOSXModifierState() & cmdKey)) {
+ TkMacOSXBringWindowForward(whichWindow);
+ }
+ break;
+ case kEventWindowDragCompleted: {
+ Rect maxBounds, bounds, strWidths;
+ int h = 0, v = 0;
+
+ TkMacOSXTrackingLoop(0);
+ ChkErr(GetWindowGreatestAreaDevice, whichWindow,
+ kWindowDragRgn, NULL, &maxBounds);
+ ChkErr(GetWindowBounds, whichWindow, kWindowStructureRgn,
+ &bounds);
+ ChkErr(GetWindowStructureWidths, whichWindow, &strWidths);
+ if (bounds.left > maxBounds.right - strWidths.left) {
+ h = maxBounds.right
+ - (strWidths.left ? strWidths.left : 40)
+ - bounds.left;
+ } else if (bounds.right < maxBounds.left
+ + strWidths.right) {
+ h = maxBounds.left
+ + (strWidths.right ? strWidths.right : 40)
+ - bounds.right;
+ }
+ if (bounds.top > maxBounds.bottom - strWidths.top) {
+ v = maxBounds.bottom
+ - (strWidths.top ? strWidths.top : 40)
+ - bounds.top;
+ } else if (bounds.bottom < maxBounds.top
+ + strWidths.bottom) {
+ v = maxBounds.top
+ + (strWidths.bottom ? strWidths.bottom : 40)
+ - bounds.bottom;
+ } else if (strWidths.top && bounds.top < maxBounds.top) {
+ v = maxBounds.top - bounds.top;
+ }
+ if (h || v) {
+ OffsetRect(&bounds, h, v);
+ ChkErr(SetWindowBounds, whichWindow,
+ kWindowStructureRgn, &bounds);
+ }
+ break;
+ }
+ case kEventWindowConstrain:
+ if (winPtr && (winPtr->wmInfoPtr->flags & WM_FULLSCREEN) &&
+ TkMacOSXMakeFullscreen(winPtr, whichWindow, 1,
+ NULL) == TCL_OK) {
+ statusPtr->stopProcessing = 1;
+ }
+ break;
+ case kEventWindowGetRegion:
+ if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) {
+ WindowRegionCode code;
+
+ statusPtr->stopProcessing = (CallNextEventHandler(
+ eventPtr->callRef, eventPtr->eventRef) == noErr);
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamWindowRegionCode, typeWindowRegionCode,
+ NULL, sizeof(code), NULL, &code);
+ if (err == noErr && code == kWindowOpaqueRgn) {
+ RgnHandle rgn;
- statusPtr->stopProcessing = (CallNextEventHandler(
- eventPtr->callRef, eventPtr->eventRef) == noErr);
err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamWindowRegionCode, typeWindowRegionCode,
- NULL, sizeof(code), NULL, &code);
- if (err == noErr && code == kWindowOpaqueRgn) {
- RgnHandle rgn;
-
- err = ChkErr(GetEventParameter, eventPtr->eventRef,
- kEventParamRgnHandle, typeQDRgnHandle, NULL,
- sizeof(rgn), NULL, &rgn);
- if (err == noErr) {
- SetEmptyRgn(rgn);
- statusPtr->stopProcessing = 1;
- }
+ kEventParamRgnHandle, typeQDRgnHandle, NULL,
+ sizeof(rgn), NULL, &rgn);
+ if (err == noErr) {
+ SetEmptyRgn(rgn);
+ statusPtr->stopProcessing = 1;
}
}
- break;
- case kEventWindowDrawContent:
- if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) {
- CGrafPtr port;
+ }
+ break;
+ case kEventWindowDrawContent:
+ if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) {
+ CGrafPtr port;
- GetPort(&port);
- ClearPort(port);
- }
- break;
- }
+ GetPort(&port);
+ ClearPort(port);
+ }
+ break;
}
+
return 0;
}