summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXButton.c21
-rw-r--r--macosx/tkMacOSXCarbonEvents.c70
-rw-r--r--macosx/tkMacOSXDebug.c2
-rw-r--r--macosx/tkMacOSXDebug.h2
-rw-r--r--macosx/tkMacOSXDialog.c12
-rw-r--r--macosx/tkMacOSXDraw.c292
-rw-r--r--macosx/tkMacOSXEntry.c4
-rw-r--r--macosx/tkMacOSXEvent.c10
-rw-r--r--macosx/tkMacOSXEvent.h4
-rw-r--r--macosx/tkMacOSXFont.c5
-rw-r--r--macosx/tkMacOSXHLEvents.c4
-rw-r--r--macosx/tkMacOSXInit.c4
-rw-r--r--macosx/tkMacOSXInt.h13
-rw-r--r--macosx/tkMacOSXKeyEvent.c19
-rw-r--r--macosx/tkMacOSXMenu.c17
-rw-r--r--macosx/tkMacOSXMenus.c16
-rw-r--r--macosx/tkMacOSXMouseEvent.c1053
-rw-r--r--macosx/tkMacOSXScale.c5
-rw-r--r--macosx/tkMacOSXScrlbr.c5
-rw-r--r--macosx/tkMacOSXSubwindows.c62
-rw-r--r--macosx/tkMacOSXTest.c7
-rw-r--r--macosx/tkMacOSXWindowEvent.c53
-rw-r--r--macosx/tkMacOSXWm.c499
-rw-r--r--macosx/tkMacOSXWm.h2
24 files changed, 1230 insertions, 951 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c
index 59fcc3f..597b310 100644
--- a/macosx/tkMacOSXButton.c
+++ b/macosx/tkMacOSXButton.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: tkMacOSXButton.c,v 1.12 2005/05/14 20:48:14 das Exp $
+ * RCS: @(#) $Id: tkMacOSXButton.c,v 1.13 2005/08/09 07:39:19 das Exp $
*/
#include "tkButton.h"
@@ -913,7 +913,6 @@ TkMacOSXDrawControl(
Rect paneRect;
Rect cntrRect;
-
winPtr = (TkWindow *)butPtr->tkwin;
paneRect.left = winPtr->privatePtr->xOff;
@@ -971,15 +970,15 @@ TkMacOSXDrawControl(
Tk_Font font;
int len;
- if ((mbPtr->info.image == NULL) && (mbPtr->info.bitmap == None)
- || (mbPtr->info.compound != COMPOUND_NONE)) {
- len = TkFontGetFirstTextLayout(butPtr->textLayout,
- &font, (char*) controlTitle);
- controlTitle[len] = 0;
- } else {
- len = 0;
- controlTitle[0] = 0;
- }
+ if (((mbPtr->info.image == NULL) && (mbPtr->info.bitmap == None))
+ || (mbPtr->info.compound != COMPOUND_NONE)) {
+ len = TkFontGetFirstTextLayout(butPtr->textLayout,
+ &font, (char*) controlTitle);
+ controlTitle[len] = 0;
+ } else {
+ len = 0;
+ controlTitle[0] = 0;
+ }
if (bcmp(mbPtr->controlTitle, controlTitle, len+1)) {
CFStringRef cf;
cf = CFStringCreateWithCString(NULL,
diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c
index 359aed6..daeea6b 100644
--- a/macosx/tkMacOSXCarbonEvents.c
+++ b/macosx/tkMacOSXCarbonEvents.c
@@ -52,10 +52,13 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3 2005/08/09 07:39:20 das Exp $
*/
#include "tkInt.h"
#include "tkMacOSXInt.h"
+#include "tkMacOSXEvent.h"
static EventHandlerRef ApplicationCarbonEventHandler;
@@ -90,51 +93,22 @@ AppEventHandlerProc (
EventRef inEvent,
void *inUserData)
{
- Tcl_CmdInfo dummy;
- Tcl_Interp *interp = (Tcl_Interp *) inUserData;
-
- /*
- * This is a bit of a hack. We get "show" events both when we come back
- * from being hidden, and whenever we are activated. I only want to run the
- * "show" proc when we have been hidden already, not as a substitute for
- * <Activate>. So I use this toggle...
- */
-
- static int toggleHide = 0;
-
- switch(GetEventKind (inEvent))
- {
- case kEventAppHidden:
- /*
- * Don't bother if we don't have an interp or
- * the show preferences procedure doesn't exist.
- */
- toggleHide = 1;
-
- if ((interp == NULL) ||
- (Tcl_GetCommandInfo(interp,
- "::tk::mac::OnHide", &dummy)) == 0) {
- return eventNotHandledErr;
- }
- Tcl_GlobalEval(interp, "::tk::mac::OnHide");
- break;
- case kEventAppShown:
- if (toggleHide == 1) {
- toggleHide = 0;
- if ((interp == NULL) ||
- (Tcl_GetCommandInfo(interp,
- "::tk::mac::OnShow", &dummy)) == 0) {
- return eventNotHandledErr;
- }
- Tcl_GlobalEval(interp, "::tk::mac::OnShow");
- }
- break;
- default:
- break;
+ OSStatus result = eventNotHandledErr;
+ TkMacOSXEvent macEvent;
+ MacEventStatus eventStatus;
+
+ macEvent.eventRef = inEvent;
+ macEvent.eClass = GetEventClass(macEvent.eventRef);
+ macEvent.eKind = GetEventKind(macEvent.eventRef);
+ macEvent.interp = (Tcl_Interp *) inUserData;
+ bzero(&eventStatus, sizeof(eventStatus));
+ TkMacOSXProcessEvent(&macEvent,&eventStatus);
+ if (!eventStatus.stopProcessing) {
+ result = noErr;
}
- return eventNotHandledErr;
+ return result;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -152,18 +126,20 @@ AppEventHandlerProc (
*----------------------------------------------------------------------
*/
-void
+MODULE_SCOPE void
TkMacOSXInitCarbonEvents (
Tcl_Interp *interp)
{
const EventTypeSpec inAppEventTypes[] = {
{kEventClassApplication, kEventAppHidden},
- {kEventClassApplication, kEventAppShown}};
- int inNumTypes = sizeof (inAppEventTypes) / sizeof (EventTypeSpec);
+ {kEventClassApplication, kEventAppShown},
+ {kEventClassWindow, kEventWindowExpanded},
+ };
InstallEventHandler(GetApplicationEventTarget(),
NewEventHandlerUPP(AppEventHandlerProc),
- inNumTypes, inAppEventTypes, (void *) interp,
+ GetEventTypeCount(inAppEventTypes),
+ inAppEventTypes, (void *) interp,
&ApplicationCarbonEventHandler);
}
diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c
index 674d5a3..fa430eb 100644
--- a/macosx/tkMacOSXDebug.c
+++ b/macosx/tkMacOSXDebug.c
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.4 2005/08/09 07:39:20 das Exp $
*/
#include "tkMacOSXDebug.h"
diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h
index 0b3185d..1e659af 100644
--- a/macosx/tkMacOSXDebug.h
+++ b/macosx/tkMacOSXDebug.h
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.3 2005/08/09 07:39:20 das Exp $
*/
#ifndef _TKMACDEBUG
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 78e1360..b12cc67 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -9,7 +9,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.13 2005/05/14 20:48:14 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.14 2005/08/09 07:39:20 das Exp $
*/
#include <Carbon/Carbon.h>
@@ -882,13 +882,13 @@ NavServicesGetFile(
!= noErr ) {
fprintf(stderr,"AEGetDescData failed %d\n", err );
} else {
- if (err = FSRefMakePath(&fsRef, (unsigned char*) pathPtr, 1024) ) {
+ if ((err = FSRefMakePath(&fsRef, (unsigned char*) pathPtr, 1024))) {
fprintf(stderr,"FSRefMakePath failed, %d\n", err );
} else {
if (isOpen == SAVE_FILE) {
CFStringRef saveNameRef;
char saveName [1024];
- if (saveNameRef = NavDialogGetSaveFileName(dialogRef)) {
+ if ((saveNameRef = NavDialogGetSaveFileName(dialogRef))) {
if (CFStringGetCString(saveNameRef, saveName,
1024, kCFStringEncodingUTF8)) {
if (strlen(pathPtr) + strlen(saveName) < 1023) {
@@ -1004,7 +1004,7 @@ OpenFileFilterProc(
fileName[len] = '\0';
fileNamePtr = (unsigned char*) fileName;
- } else if (theItem->descriptorType = typeFSRef) {
+ } else if ((theItem->descriptorType = typeFSRef)) {
OSStatus err;
FSRef *theRef = (FSRef *) *theItem->dataHandle;
HFSUniStr255 uniFileName;
@@ -1079,7 +1079,7 @@ OpenEventProc(
chosenItem = (NavMenuItemSpec *) callBackParams->eventData.eventDataParms.param;
ofd->curType = chosenItem->menuType;
} else if (callBackSelector == kNavCBAdjustRect
- || callBackSelector & otherEvent != 0) {
+ || (callBackSelector & otherEvent) != 0) {
while (Tcl_DoOneEvent(TCL_IDLE_EVENTS
| TCL_DONT_WAIT
| TCL_WINDOW_EVENTS)) {
@@ -1247,7 +1247,7 @@ TkAboutDlg()
DisposeDialog(aboutDlog);
aboutDlog = NULL;
- SelectWindow(FrontNonFloatingWindow());
+ SelectWindow(ActiveNonFloatingWindow());
return;
}
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index fff5370..ac1e407 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.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: tkMacOSXDraw.c,v 1.5 2004/11/11 01:24:32 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.6 2005/08/09 07:39:20 das Exp $
*/
#include "tclInt.h"
@@ -44,6 +44,9 @@ static PixPatHandle gPenPat = NULL;
static int useCGDrawing = 1;
static int tkMacOSXCGAntiAliasLimit = 1;
+static int useThemedToplevel = 0;
+static int useThemedFrame = 0;
+
/*
* Prototypes for functions used only in this file.
*/
@@ -55,14 +58,14 @@ void TkMacOSXReleaseCGContext(MacDrawable *macWin, CGrafPtr destPort,
CGContextRef *context);
static inline double radians(double degrees) { return degrees * PI / 180.0f; }
-int
+MODULE_SCOPE int
TkMacOSXInitCGDrawing(interp, enable, limit)
Tcl_Interp *interp;
int enable;
int limit;
{
static Boolean initialized = FALSE;
-
+
if (!initialized) {
if (Tcl_CreateNamespace(interp, "::tk::mac", NULL, NULL) == NULL) {
Tcl_ResetResult(interp);
@@ -73,13 +76,25 @@ TkMacOSXInitCGDrawing(interp, enable, limit)
Tcl_ResetResult(interp);
}
useCGDrawing = enable;
-
+
if (Tcl_LinkVar(interp, "::tk::mac::CGAntialiasLimit",
(char *) &tkMacOSXCGAntiAliasLimit,
TCL_LINK_INT) != TCL_OK) {
Tcl_ResetResult(interp);
}
tkMacOSXCGAntiAliasLimit = limit;
+
+ /*
+ * Piggy-back the themed drawing var init here.
+ */
+ if (Tcl_LinkVar(interp, "::tk::mac::useThemedToplevel",
+ (char *) &useThemedToplevel, TCL_LINK_BOOLEAN) != TCL_OK) {
+ Tcl_ResetResult(interp);
+ }
+ if (Tcl_LinkVar(interp, "::tk::mac::useThemedFrame",
+ (char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) {
+ Tcl_ResetResult(interp);
+ }
}
return TCL_OK;
}
@@ -152,7 +167,7 @@ XCopyArea(
SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
(short) (srcDraw->yOff + src_y),
(short) (srcDraw->xOff + src_x + width),
- (short) (srcDraw->yOff + src_y + height));
+ (short) (srcDraw->yOff + src_y + height));
if (tkPictureIsOpen) {
dstPtr = &srcRect;
} else {
@@ -160,7 +175,7 @@ XCopyArea(
SetRect(&dstRect, (short) (dstDraw->xOff + dest_x),
(short) (dstDraw->yOff + dest_y),
(short) (dstDraw->xOff + dest_x + width),
- (short) (dstDraw->yOff + dest_y + height));
+ (short) (dstDraw->yOff + dest_y + height));
}
TkMacOSXSetUpClippingRgn(dst);
/*
@@ -188,7 +203,7 @@ XCopyArea(
RgnHandle clipRgn = (RgnHandle)
((TkpClipMask*)gc->clip_mask)->value.region;
- int xOffset, yOffset;
+ int xOffset = 0, yOffset = 0;
if (tmpRgn == NULL) {
tmpRgn = NewRgn();
}
@@ -565,12 +580,12 @@ XFillRectangles(
void
XDrawLines(
- Display* display, /* Display. */
- Drawable d, /* Draw on this. */
- GC gc, /* Use this GC. */
- XPoint* points, /* Array of points. */
- int npoints, /* Number of points. */
- int mode) /* Line drawing mode. */
+ Display* display, /* Display. */
+ Drawable d, /* Draw on this. */
+ GC gc, /* Use this GC. */
+ XPoint* points, /* Array of points. */
+ int npoints, /* Number of points. */
+ int mode) /* Line drawing mode. */
{
MacDrawable *macWin = (MacDrawable *) d;
CGrafPtr saveWorld;
@@ -582,54 +597,56 @@ XDrawLines(
display->request++;
if (npoints < 2) {
- return; /* TODO: generate BadValue error. */
+ return; /* TODO: generate BadValue error. */
}
GetGWorld(&saveWorld, &saveDevice);
SetGWorld(destPort, NULL);
-
+
TkMacOSXSetUpClippingRgn(d);
if (useCGDrawing) {
- CGContextRef outContext;
-
- TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
-
- CGContextBeginPath(outContext);
- CGContextMoveToPoint(outContext, (float)(macWin->xOff + points[0].x),
- (float)(macWin->yOff + points[0].y));
-
- for (i = 1; i < npoints; i++) {
- if(mode==CoordModeOrigin) {
- CGContextAddLineToPoint(outContext,
- (float) (macWin->xOff + points[i].x),
- (float) (macWin->yOff + points[i].y));
- } else {
+ CGContextRef outContext;
+ float prevx, prevy;
+
+ TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
+
+ CGContextBeginPath(outContext);
+ prevx = (float) (macWin->xOff + points[0].x);
+ prevy = (float) (macWin->yOff + points[0].y);
+ CGContextMoveToPoint(outContext, prevx, prevy);
+
+ for (i = 1; i < npoints; i++) {
+ if (mode == CoordModeOrigin) {
CGContextAddLineToPoint(outContext,
- (float)(macWin->xOff + points[i].x),
- (float)(macWin->yOff + points[i].y));
- }
- }
-
- CGContextStrokePath(outContext);
- TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
+ (float) (macWin->xOff + points[i].x),
+ (float) (macWin->yOff + points[i].y));
+ } else {
+ prevx += (float) points[i].x;
+ prevy += (float) points[i].y;
+ CGContextAddLineToPoint(outContext, prevx, prevy);
+ }
+ }
+
+ CGContextStrokePath(outContext);
+ TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
} else {
- TkMacOSXSetUpGraphicsPort(gc, destPort);
-
- ShowPen();
-
- PenPixPat(gPenPat);
- MoveTo((short) (macWin->xOff + points[0].x),
- (short) (macWin->yOff + points[0].y));
- for (i = 1; i < npoints; i++) {
- if (mode == CoordModeOrigin) {
- LineTo((short) (macWin->xOff + points[i].x),
- (short) (macWin->yOff + points[i].y));
- } else {
- Line((short) (macWin->xOff + points[i].x),
- (short) (macWin->yOff + points[i].y));
- }
- }
- HidePen();
+ TkMacOSXSetUpGraphicsPort(gc, destPort);
+
+ ShowPen();
+
+ PenPixPat(gPenPat);
+ MoveTo((short) (macWin->xOff + points[0].x),
+ (short) (macWin->yOff + points[0].y));
+ for (i = 1; i < npoints; i++) {
+ if (mode == CoordModeOrigin) {
+ LineTo((short) (macWin->xOff + points[i].x),
+ (short) (macWin->yOff + points[i].y));
+ } else {
+ Line((short) (macWin->xOff + points[i].x),
+ (short) (macWin->yOff + points[i].y));
+ }
+ }
+ HidePen();
}
SetGWorld(saveWorld, saveDevice);
@@ -726,13 +743,13 @@ void XDrawSegments(
void
XFillPolygon(
- Display* display, /* Display. */
- Drawable d, /* Draw on this. */
- GC gc, /* Use this GC. */
- XPoint* points, /* Array of points. */
- int npoints, /* Number of points. */
- int shape, /* Shape to draw. */
- int mode) /* Drawing mode. */
+ Display* display, /* Display. */
+ Drawable d, /* Draw on this. */
+ GC gc, /* Use this GC. */
+ XPoint* points, /* Array of points. */
+ int npoints, /* Number of points. */
+ int shape, /* Shape to draw. */
+ int mode) /* Drawing mode. */
{
MacDrawable *macWin = (MacDrawable *) d;
PolyHandle polygon;
@@ -748,51 +765,51 @@ XFillPolygon(
SetGWorld(destPort, NULL);
TkMacOSXSetUpClippingRgn(d);
-
+
if (useCGDrawing) {
- CGContextRef outContext;
-
- TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
-
- CGContextBeginPath(outContext);
- CGContextMoveToPoint(outContext, (float) (macWin->xOff + points[0].x),
- (float) (macWin->yOff + points[0].y));
- for (i = 1; i < npoints; i++) {
-
- if (mode == CoordModePrevious) {
- CGContextAddLineToPoint(outContext, (float)points[i].x,
- (float) points[i].y);
- } else {
+ CGContextRef outContext;
+ float prevx, prevy;
+
+ TkMacOSXSetUpCGContext(macWin, destPort, gc, &outContext);
+
+ CGContextBeginPath(outContext);
+ prevx = (float) (macWin->xOff + points[0].x);
+ prevy = (float) (macWin->yOff + points[0].y);
+ CGContextMoveToPoint(outContext, prevx, prevy);
+ for (i = 1; i < npoints; i++) {
+ if (mode == CoordModeOrigin) {
CGContextAddLineToPoint(outContext,
- (float)(macWin->xOff + points[i].x),
- (float)(macWin->yOff + points[i].y));
- }
- }
+ (float)(macWin->xOff + points[i].x),
+ (float)(macWin->yOff + points[i].y));
+ } else {
+ prevx += (float) points[i].x;
+ prevy += (float) points[i].y;
+ CGContextAddLineToPoint(outContext, prevx, prevy);
+ }
+ }
CGContextEOFillPath(outContext);
- TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
+ TkMacOSXReleaseCGContext(macWin, destPort, &outContext);
} else {
- TkMacOSXSetUpGraphicsPort(gc, destPort);
-
- PenNormal();
- polygon = OpenPoly();
-
- MoveTo((short) (macWin->xOff + points[0].x),
- (short) (macWin->yOff + points[0].y));
- for (i = 1; i < npoints; i++) {
- if (mode == CoordModePrevious) {
- Line((short) (macWin->xOff + points[i].x),
- (short) (macWin->yOff + points[i].y));
- } else {
- LineTo((short) (macWin->xOff + points[i].x),
- (short) (macWin->yOff + points[i].y));
- }
- }
-
- ClosePoly();
-
- FillCPoly(polygon, gPenPat);
-
- KillPoly(polygon);
+ TkMacOSXSetUpGraphicsPort(gc, destPort);
+
+ PenNormal();
+ polygon = OpenPoly();
+
+ MoveTo((short) (macWin->xOff + points[0].x),
+ (short) (macWin->yOff + points[0].y));
+ for (i = 1; i < npoints; i++) {
+ if (mode == CoordModeOrigin) {
+ LineTo((short) (macWin->xOff + points[i].x),
+ (short) (macWin->yOff + points[i].y));
+ } else {
+ Line((short) (macWin->xOff + points[i].x),
+ (short) (macWin->yOff + points[i].y));
+ }
+ }
+
+ ClosePoly();
+ FillCPoly(polygon, gPenPat);
+ KillPoly(polygon);
}
SetGWorld(saveWorld, saveDevice);
}
@@ -1695,7 +1712,8 @@ TkMacOSXSetUpGraphicsPort(
*/
}
}
- /*
+
+/*
*----------------------------------------------------------------------
*
* TkMacOSXSetUpGraphicsPort --
@@ -1986,7 +2004,7 @@ InvertByte(
/*
*----------------------------------------------------------------------
*
- * TkpDrawpHighlightBorder --
+ * TkpDrawHighlightBorder --
*
* This procedure draws a rectangular ring around the outside of
* a widget to indicate that it has received the input focus.
@@ -2025,3 +2043,71 @@ TkpDrawHighlightBorder (
}
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDrawFrame --
+ *
+ * This procedure draws the rectangular frame area. If the user
+ * has request themeing, it draws with a the background theme.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpDrawFrame (Tk_Window tkwin, Tk_3DBorder border,
+ int highlightWidth, int borderWidth, int relief)
+{
+ if (useThemedToplevel && Tk_IsTopLevel(tkwin)) {
+ /*
+ * Currently only support themed toplevels, until we can better
+ * factor this to handle individual windows (blanket theming of
+ * frames will work for very few UIs).
+ */
+ Rect bounds;
+ Point origin;
+ CGrafPtr saveWorld;
+ GDHandle saveDevice;
+ XGCValues gcValues;
+ GC gc;
+ Pixmap pixmap;
+ Display *display = Tk_Display(tkwin);
+
+ pixmap = Tk_GetPixmap(display, Tk_WindowId(tkwin),
+ Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
+
+ gc = Tk_GetGC(tkwin, 0, &gcValues);
+ TkMacOSXWinBounds((TkWindow *) tkwin, &bounds);
+ origin.v = -bounds.top;
+ origin.h = -bounds.left;
+ bounds.top = bounds.left = 0;
+ bounds.right = Tk_Width(tkwin);
+ bounds.bottom = Tk_Height(tkwin);
+
+ GetGWorld(&saveWorld, &saveDevice);
+ SetGWorld(TkMacOSXGetDrawablePort(pixmap), 0);
+ ApplyThemeBackground(kThemeBackgroundWindowHeader, &bounds,
+ kThemeStateActive, 32 /* depth */, true /* inColor */);
+ QDSetPatternOrigin(origin);
+ EraseRect(&bounds);
+ SetGWorld(saveWorld, saveDevice);
+
+ XCopyArea(display, pixmap, Tk_WindowId(tkwin),
+ gc, 0, 0, bounds.right, bounds.bottom, 0, 0);
+ Tk_FreePixmap(display, pixmap);
+ Tk_FreeGC(display, gc);
+ } else {
+ Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin),
+ border, highlightWidth, highlightWidth,
+ Tk_Width(tkwin) - 2 * highlightWidth,
+ Tk_Height(tkwin) - 2 * highlightWidth,
+ borderWidth, relief);
+ }
+}
diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c
index ee67eb3..b6b4585 100644
--- a/macosx/tkMacOSXEntry.c
+++ b/macosx/tkMacOSXEntry.c
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXEntry.c,v 1.4 2005/08/09 07:39:20 das Exp $
*/
#include "tk.h"
@@ -151,7 +153,7 @@ TkpDrawEntryBorderAndFocus(Entry *entryPtr, Drawable d, int isSpinbox)
GC bgGC;
Tk_Window tkwin = entryPtr->tkwin;
ThemeDrawState drawState;
- int oldWidth;
+ int oldWidth = 0;
/*
* I use 6 as the borderwidth. 2 of the 5 go into the actual frame the
diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c
index d343e99..d638906 100644
--- a/macosx/tkMacOSXEvent.c
+++ b/macosx/tkMacOSXEvent.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.5 2004/02/16 00:19:42 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.6 2005/08/09 07:39:20 das Exp $
*/
#include <stdio.h>
@@ -30,8 +30,6 @@
static int TkMacOSXProcessAppleEvent(
TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr);
-static int TkMacOSXProcessEvent(
- TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr);
static int ReceiveAndProcessEvent (void);
@@ -184,7 +182,7 @@ TkMacOSXProcessAppleEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr)
*----------------------------------------------------------------------
*/
-static int
+int
TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr)
{
switch (eventPtr->eClass) {
@@ -219,8 +217,7 @@ TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr)
break;
}
return 0;
-}
-
+}
/*
*----------------------------------------------------------------------
@@ -260,6 +257,7 @@ ReceiveAndProcessEvent()
} else {
macEvent.eClass = GetEventClass(macEvent.eventRef);
macEvent.eKind = GetEventKind(macEvent.eventRef);
+ macEvent.interp = NULL;
bzero(&eventStatus, sizeof(eventStatus));
TkMacOSXProcessEvent(&macEvent,&eventStatus);
if (!eventStatus.stopProcessing) {
diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h
index 4c5ad59..37b98d1 100644
--- a/macosx/tkMacOSXEvent.h
+++ b/macosx/tkMacOSXEvent.h
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.4 2005/08/09 07:39:20 das Exp $
*/
#ifndef _TKMACEVENT
@@ -74,10 +76,12 @@ typedef struct {
EventRef eventRef;
UInt32 eClass; /* Defines the class of event : see CarbonEvents.h */
UInt32 eKind; /* Defines the kind of the event : see CarbonEvents.h */
+ Tcl_Interp *interp; /* Interp to handle events in */
} TkMacOSXEvent;
int TkMacOSXCountAndProcessMacEvents _ANSI_ARGS_(());
void tkMacOSXFlushWindows _ANSI_ARGS_(());
+int TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr);
int TkMacOSXProcessMouseEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr);
int TkMacOSXProcessWindowEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr);
int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent * e, MacEventStatus * statusPtr);
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 443b0a2..9b85d1f 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.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: tkMacOSXFont.c,v 1.8 2005/05/29 10:32:30 das Exp $
+ * RCS: @(#) $Id: tkMacOSXFont.c,v 1.9 2005/08/09 07:39:20 das Exp $
*/
#include <Carbon/Carbon.h>
@@ -2260,7 +2260,8 @@ TkMacOSXAntialiasedTextVariableProc(clientData, interp, name1, name2, flags)
return (char *) NULL;
}
-int TkMacOSXUseAntialiasedText(interp, enable)
+MODULE_SCOPE int
+TkMacOSXUseAntialiasedText(interp, enable)
Tcl_Interp *interp;
int enable;
{
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c
index cb624aa..6fc5ea1 100644
--- a/macosx/tkMacOSXHLEvents.c
+++ b/macosx/tkMacOSXHLEvents.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: tkMacOSXHLEvents.c,v 1.8 2005/05/14 20:48:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXHLEvents.c,v 1.9 2005/08/09 07:39:20 das Exp $
*/
#include "tkMacOSXPort.h"
@@ -71,7 +71,7 @@ TkMacOSXInitAppleEvents(
AEEventHandlerUPP OappHandlerUPP, RappHandlerUPP, OdocHandlerUPP,
PrintHandlerUPP, QuitHandlerUPP, ScriptHandlerUPP,
PrefsHandlerUPP;
-
+
/*
* Install event handlers for the core apple events.
*/
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 41c3552..bf651ca 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.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: tkMacOSXInit.c,v 1.13 2005/05/29 07:00:26 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInit.c,v 1.14 2005/08/09 07:39:21 das Exp $
*/
#include "tkInt.h"
@@ -417,7 +417,7 @@ TkpDisplayWarning(msg, title)
*----------------------------------------------------------------------
*/
-void
+MODULE_SCOPE void
TkMacOSXDefaultStartupScript(void)
{
CFBundleRef bundleRef;
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 2f33604..38b9b29 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -9,7 +9,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.7 2005/03/15 02:11:56 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.8 2005/08/09 07:39:21 das Exp $
*/
#ifndef _TKMACINT
@@ -151,11 +151,12 @@ extern TkMacOSXWindowList *tkMacOSXWindowListPtr;
extern Tcl_Encoding TkMacOSXCarbonEncoding;
-extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);
-extern void TkMacOSXInitCarbonEvents (Tcl_Interp *interp);
-extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias);
-extern void TkMacOSXDefaultStartupScript(void);
-extern int TkMacOSXGenerateFocusEvent( Window window, int activeFlag);
+MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);
+MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp);
+MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias);
+MODULE_SCOPE void TkMacOSXDefaultStartupScript(void);
+MODULE_SCOPE int TkMacOSXGenerateFocusEvent( Window window, int activeFlag);
+MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr);
#include "tkIntPlatDecls.h"
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index 3742399..a9cc17a 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.10 2005/08/09 07:39:21 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -172,7 +174,9 @@ int TkMacOSXProcessKeyboardEvent(
* handler.
*/
- if (IsMenuKeyEvent(NULL, eventPtr->eventRef,
+ if ((eventPtr->eKind == kEventRawKeyDown
+ || eventPtr->eKind == kEventRawKeyRepeat)
+ && IsMenuKeyEvent(NULL, eventPtr->eventRef,
kMenuEventQueryOnly, &menuRef, &menuItemIndex)) {
MenuCommand menuCmd;
@@ -425,16 +429,19 @@ GenerateKeyEvent(
static int
InitKeyData(KeyEventData * keyEventDataPtr)
{
+ int x, y;
memset (keyEventDataPtr, 0, sizeof(*keyEventDataPtr));
- keyEventDataPtr->whichWindow = FrontNonFloatingWindow();
+ keyEventDataPtr->whichWindow = ActiveNonFloatingWindow();
if (keyEventDataPtr->whichWindow == NULL) {
return false;
}
- GetMouse(&keyEventDataPtr->local);
- keyEventDataPtr->global = keyEventDataPtr->local;
- LocalToGlobal(&keyEventDataPtr->global);
- keyEventDataPtr->state = TkMacOSXButtonKeyState();
+ XQueryPointer(NULL, None, NULL, NULL, &x, &y,
+ NULL, NULL, &keyEventDataPtr->state);
+ keyEventDataPtr->global.v = x;
+ keyEventDataPtr->global.v = y;
+ keyEventDataPtr->local = keyEventDataPtr->global;
+ GlobalToLocal(&keyEventDataPtr->local);
return true;
}
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index e1ee0ed..4db2bf3 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.18 2005/05/15 21:09:34 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.19 2005/08/09 07:39:21 das Exp $
*/
#include "tkMacOSXInt.h"
#include "tkMenubutton.h"
@@ -1284,9 +1284,11 @@ ReconfigureMacintoshMenu(
ReconfigureIndividualMenu(menuPtr, macMenuHdl, 0);
+ /* Not necessary in Carbon:
if (menuPtr->menuFlags & MENU_APPLE_MENU) {
AppendResMenu(macMenuHdl, 'DRVR');
}
+ */
if (GetMenuID(macMenuHdl) == currentHelpMenuID) {
MenuItemIndex helpIndex;
HMGetHelpMenu(&helpMenuHdl,&helpIndex);
@@ -1958,7 +1960,7 @@ TkpSetMainMenubar(
}
macWindowPtr = GetWindowFromPort(winPort);
- frontNonFloating = FrontNonFloatingWindow();
+ frontNonFloating = ActiveNonFloatingWindow();
if ((macWindowPtr == NULL) || (macWindowPtr != frontNonFloating)) {
return;
}
@@ -3660,9 +3662,6 @@ MenuSelectEvent(
TkMenu *menuPtr) /* the menu we have selected. */
{
XVirtualEvent event;
- Point where;
- CGrafPtr port;
- Rect bounds;
event.type = VirtualEvent;
event.serial = menuPtr->display->request;
@@ -3674,12 +3673,8 @@ MenuSelectEvent(
event.subwindow = None;
event.time = TkpGetMS();
- GetMouse(&where);
- GetPort(&port);
- GetPortBounds(port,&bounds);
- event.x_root = where.h + bounds.left;
- event.y_root = where.v + bounds.top;
- event.state = TkMacOSXButtonKeyState();
+ XQueryPointer(NULL, None, NULL, NULL,
+ &event.x_root, &event.y_root, NULL, NULL, &event.state);
event.same_screen = true;
event.name = Tk_GetUid("MenuSelect");
event.user_data = NULL;
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 117a298..a8a57c1 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.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: tkMacOSXMenus.c,v 1.6 2004/09/03 14:09:05 dkf Exp $
+ * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.7 2005/08/09 07:39:21 das Exp $
*/
#include "tk.h"
@@ -104,7 +104,7 @@ TkMacOSXHandleMenuSelect(
break;
case kCloseItem:
/* Send close event */
- window = TkMacOSXGetXWindow(FrontNonFloatingWindow());
+ window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
dispPtr = TkGetDisplayList();
tkwin = Tk_IdToWindow(dispPtr->display, window);
TkGenWMDestroyEvent(tkwin);
@@ -229,7 +229,7 @@ GenerateEditEvent(
Window window;
TkDisplay *dispPtr;
- window = TkMacOSXGetXWindow(FrontNonFloatingWindow());
+ window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
dispPtr = TkGetDisplayList();
tkwin = Tk_IdToWindow(dispPtr->display, window);
tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr;
@@ -246,13 +246,13 @@ GenerateEditEvent(
event.subwindow = None;
event.time = TkpGetMS();
- GetMouse(&where);
+ XQueryPointer(NULL, None, NULL, NULL,
+ &event.x_root, &event.y_root, NULL, NULL, &event.state);
+ where.h = event.x_root;
+ where.v = event.y_root;
+ GlobalToLocal(&where);
tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v,
&event.x, &event.y);
- LocalToGlobal(&where);
- event.x_root = where.h;
- event.y_root = where.v;
- event.state = TkMacOSXButtonKeyState();
event.same_screen = true;
event.user_data = NULL;
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 0346fbf..163e232 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -2,7 +2,7 @@
* tkMacOSXMouseEvent.c --
*
* This file implements functions that decode & handle mouse events
- * on MacOS X.
+ * on MacOS X.
*
* Copyright 2001, Apple Computer, Inc.
*
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.13 2005/08/09 07:39:21 das Exp $
*/
#include "tkInt.h"
@@ -60,20 +62,21 @@
#include "tkMacOSXDebug.h"
typedef struct {
- WindowRef whichWin;
- WindowRef activeNonFloating;
+ WindowRef whichWin;
+ WindowRef activeNonFloating;
WindowPartCode windowPart;
- Point global;
- Point local;
+ Point global;
+ Point local;
unsigned int state;
- long delta;
+ long delta;
+ Window window;
} MouseEventData;
/*
* Declarations of static variables used in this file.
*/
-static int gEatButtonUp = 0; /* 1 if we need to eat the next * up event */
+static int gEatButtonUp = 0; /* 1 if we need to eat the next * up event */
/*
* Declarations of functions used only in this file.
@@ -82,8 +85,10 @@ static int gEatButtonUp = 0; /* 1 if we need to eat the next * up event */
static void BringWindowForward _ANSI_ARGS_((WindowRef wRef));
static int GeneratePollingEvents(MouseEventData * medPtr);
static int GenerateMouseWheelEvent(MouseEventData * medPtr);
-static int HandleInGoAway(Tk_Window tkwin, WindowRef winPtr, Point where);
-static OSErr HandleInCollapse(WindowRef win);
+static int GenerateButtonEvent(MouseEventData * medPtr);
+static int GenerateToolbarButtonEvent(MouseEventData * medPtr);
+static int HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin);
+static unsigned int ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers);
extern int TkMacOSXGetEatButtonUp();
extern void TkMacOSXSetEatButtonUp(int f);
@@ -93,93 +98,88 @@ extern void TkMacOSXSetEatButtonUp(int f);
*
* TkMacOSXProcessMouseEvent --
*
- * This routine processes the event in eventPtr, and
- * generates the appropriate Tk events from it.
+ * This routine processes the event in eventPtr, and
+ * generates the appropriate Tk events from it.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
+ * Additional events may be place on the Tk event queue.
*
*----------------------------------------------------------------------
*/
-
+
int
TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
{
- WindowRef frontWindow;
- Tk_Window tkwin;
- Point where, where2;
- int xOffset, yOffset;
- TkDisplay * dispPtr;
- Window window;
- int status,err;
+ Tk_Window tkwin;
+ Point where, where2;
+ int xOffset, yOffset, result;
+ TkDisplay * dispPtr;
+ OSStatus status;
MouseEventData mouseEventData, * medPtr = &mouseEventData;
- KeyMap keyMap;
- long modif;
switch (eventPtr->eKind) {
- case kEventMouseUp:
- case kEventMouseDown:
- case kEventMouseMoved:
- case kEventMouseDragged:
- case kEventMouseWheelMoved:
- break;
- default:
- return 0;
- break;
+ case kEventMouseUp:
+ case kEventMouseDown:
+ case kEventMouseMoved:
+ case kEventMouseDragged:
+ case kEventMouseWheelMoved:
+ break;
+ default:
+ return 0;
+ break;
}
status = GetEventParameter(eventPtr->eventRef,
- kEventParamMouseLocation,
- typeQDPoint, NULL,
- sizeof(where), NULL,
- &where);
+ kEventParamMouseLocation,
+ typeQDPoint, NULL,
+ sizeof(where), NULL,
+ &where);
if (status != noErr) {
- fprintf (stderr, "Failed to retrieve mouse location,%d\n", status);
- return 0;
- }
- medPtr->state = 0;
- GetKeys(keyMap);
- modif = EndianS32_BtoN(*(long*)(&keyMap[1]));
-
- if (modif & 2) {
- medPtr->state |= LockMask;
+ GetGlobalMouse(&where);
}
- if (modif & 1) {
- medPtr->state |= ShiftMask;
- }
- if (modif & 8) {
- medPtr->state |= ControlMask;
- }
- if (modif & 32768) {
- medPtr->state |= Mod1Mask; /* command key */
+ status = GetEventParameter(eventPtr->eventRef,
+ kEventParamWindowRef,
+ typeWindowRef, NULL,
+ sizeof(WindowRef), NULL,
+ &medPtr->whichWin);
+ if (status == noErr) {
+ status = GetEventParameter(eventPtr->eventRef,
+ kEventParamWindowPartCode,
+ typeWindowPartCode, NULL,
+ sizeof(WindowPartCode), NULL,
+ &medPtr->windowPart);
}
- if (modif & 4) {
- medPtr->state |= Mod2Mask; /* option key */
+ if (status != noErr) {
+ medPtr->windowPart = FindWindow(where, &medPtr->whichWin);
}
- if (eventPtr->eKind == kEventMouseDown
- || eventPtr->eKind == kEventMouseDragged ) {
- EventMouseButton mouseButton;
- status = GetEventParameter(eventPtr->eventRef,
- kEventParamMouseButton,
- typeMouseButton, NULL,
- sizeof(mouseButton), NULL,&mouseButton);
- if (status != noErr ) {
- fprintf (stderr, "Failed to retrieve mouse button, %d\n", status);
- statusPtr->err = 1;
- return 0;
- }
- medPtr->state |= 1 << ((mouseButton-1)+8);
+ medPtr->window = TkMacOSXGetXWindow(medPtr->whichWin);
+ if (medPtr->whichWin != NULL && medPtr->window == None) {
+ return 0;
}
-
- medPtr->windowPart = FindWindow(where, &medPtr->whichWin);
- window = TkMacOSXGetXWindow(medPtr->whichWin);
- if (medPtr->whichWin != NULL && window == None) {
- return 0;
+ medPtr->state = ButtonModifiers2State(GetCurrentEventButtonState(),
+ GetCurrentEventKeyModifiers());
+ medPtr->global = where;
+ status = GetEventParameter(eventPtr->eventRef,
+ kEventParamWindowMouseLocation,
+ typeQDPoint, NULL,
+ sizeof(Point), NULL,
+ &medPtr->local);
+ if (status == noErr) {
+ if (medPtr->whichWin) {
+ Rect widths;
+ GetWindowStructureWidths(medPtr->whichWin, &widths);
+ medPtr->local.h -= widths.left;
+ medPtr->local.v -= widths.top;
+ }
+ } else {
+ medPtr->local = where;
+ if (medPtr->whichWin) {
+ QDGlobalToLocalPoint(GetWindowPort(medPtr->whichWin),
+ &medPtr->local);
+ }
}
-
- frontWindow = FrontWindow();
medPtr->activeNonFloating = ActiveNonFloatingWindow();
/*
@@ -189,314 +189,232 @@ TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr)
*/
if (eventPtr->eKind == kEventMouseUp) {
- if (TkMacOSXGetEatButtonUp()) {
- TkMacOSXSetEatButtonUp(false);
- return false;
- }
- return TkGenerateButtonEvent(where.h, where.v,
- window, medPtr->state);
+ if (TkMacOSXGetEatButtonUp()) {
+ TkMacOSXSetEatButtonUp(false);
+ return false;
+ }
+ return GenerateButtonEvent(medPtr);
}
if (eventPtr->eKind == kEventMouseWheelMoved) {
- status = GetEventParameter(eventPtr->eventRef,
- kEventParamMouseWheelDelta,
- typeLongInteger, NULL,
- sizeof(medPtr->delta), NULL,&medPtr->delta);
- if (status != noErr ) {
- fprintf (stderr,
- "Failed to retrieve mouse wheel delta, %d\n", status);
- statusPtr->err = 1;
- return false;
- }
+ status = GetEventParameter(eventPtr->eventRef,
+ kEventParamMouseWheelDelta,
+ typeLongInteger, NULL,
+ sizeof(long), NULL, &medPtr->delta);
+ if (status != noErr ) {
+ fprintf (stderr,
+ "Failed to retrieve mouse wheel delta, %d\n", (int)status);
+ statusPtr->err = 1;
+ return false;
+ }
}
-
- dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, window);
-
- if (eventPtr->eKind != kEventMouseDown ) {
- /*
- * MouseMoved, MouseDragged or kEventMouseWheelMoved
- */
-
- medPtr->global = where;
- medPtr->local = where;
- /*
- * We must set the port to the right window -- the one
- * we are actually going to use -- before finding
- * the local coordinates, otherwise we will have completely
- * wrong local x,y!
- *
- * I'm pretty sure this window is medPtr->whichWin, unless
- * perhaps there is a grab. Certainly 'frontWindow' or
- * 'medPtr->activeNonFloating' are wrong.
- */
- SetPortWindowPort(medPtr->whichWin);
- GlobalToLocal(&medPtr->local);
- if (eventPtr->eKind == kEventMouseWheelMoved ) {
- return GenerateMouseWheelEvent(medPtr);
- } else {
- return GeneratePollingEvents(medPtr);
- }
- }
-
- if (medPtr->whichWin && eventPtr->eKind == kEventMouseDown) {
- ProcessSerialNumber frontPsn, ourPsn;
- Boolean flag;
- err = GetFrontProcess(&frontPsn);
- if (err != noErr) {
- fprintf(stderr, "GetFrontProcess failed, %d\n", err);
- statusPtr->err = 1;
- return 1;
- }
-
- GetCurrentProcess(&ourPsn);
- err = SameProcess(&frontPsn, &ourPsn, &flag);
- if (err != noErr) {
- fprintf(stderr, "SameProcess failed, %d\n", err);
- statusPtr->err = 1;
- return 1;
- } else {
- if (!flag) {
- err = SetFrontProcess(&ourPsn);
- if (err != noErr) {
- fprintf(stderr,"SetFrontProcess failed,%d\n", err);
- statusPtr->err = 1;
- return 1;
- }
- }
- }
+ dispPtr = TkGetDisplayList();
+ tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
+
+ if (eventPtr->eKind != kEventMouseDown) {
+ /*
+ * MouseMoved, MouseDragged or kEventMouseWheelMoved
+ */
+
+ if (eventPtr->eKind == kEventMouseWheelMoved) {
+ return GenerateMouseWheelEvent(medPtr);
+ } else {
+ return GeneratePollingEvents(medPtr);
+ }
}
if (medPtr->whichWin) {
- /*
- * We got a mouse down in a window
- * See if this is the activate click
- * This click moves the window forward. We don't want
- * the corresponding mouse-up to be reported to the application
- * or else it will mess up some Tk scripts.
- */
-
- if (!(TkpIsWindowFloating(medPtr->whichWin))
- && (medPtr->whichWin != medPtr->activeNonFloating)) {
- Tk_Window grabWin = TkMacOSXGetCapture();
- if ((grabWin == NULL)) {
- int grabState = TkGrabState((TkWindow*)tkwin);
- if (grabState != TK_GRAB_NONE && grabState != TK_GRAB_IN_TREE) {
- /* Now we want to set the focus to the local grabWin */
- TkMacOSXSetEatButtonUp(true);
- grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr);
- BringWindowForward(GetWindowFromPort(TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)));
- statusPtr->stopProcessing = 1;
- return false;
- }
- }
- if ((grabWin != NULL) && (grabWin != tkwin)) {
- TkWindow * tkw, * grb;
- tkw = (TkWindow *)tkwin;
- grb = (TkWindow *)grabWin;
- /* Now we want to set the focus to the global grabWin */
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(GetWindowFromPort(TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)));
- statusPtr->stopProcessing = 1;
- return false;
- }
-
- /*
- * Clicks in the stoplights on a MacOS X title bar are processed
- * directly even for background windows. Do that here.
- */
-
- switch (medPtr->windowPart) {
- case inGoAway:
- return HandleInGoAway(tkwin, medPtr->whichWin, where);
- break;
- case inCollapseBox:
- err = HandleInCollapse(medPtr->whichWin);
- if (err == noErr) {
- statusPtr->err = 1;
- }
- statusPtr->stopProcessing = 1;
- return false;
- break;
- case inZoomIn:
- return false;
- break;
- case inZoomOut:
- return false;
- break;
- default:
- TkMacOSXSetEatButtonUp(true);
- BringWindowForward(medPtr->whichWin);
- return false;
- }
- }
- }
-
- switch (medPtr->windowPart) {
- case inDrag:
- {
- CGrafPtr saveWorld;
- GDHandle saveDevice;
- GWorldPtr dstPort;
-
- GetGWorld(&saveWorld, &saveDevice);
- dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
- SetGWorld(dstPort, NULL);
-
- DragWindow(medPtr->whichWin, where, NULL);
- where2.h = where2.v = 0;
- LocalToGlobal(&where2);
- if (EqualPt(where, where2)) {
- SetGWorld (saveWorld, saveDevice);
- return false;
- }
- TkMacOSXWindowOffset(medPtr->whichWin, &xOffset, &yOffset);
- where2.h -= xOffset;
- where2.v -= yOffset;
- TkGenWMConfigureEvent(tkwin, where2.h, where2.v,
- -1, -1, TK_LOCATION_CHANGED);
- SetGWorld(saveWorld, saveDevice);
- return true;
- break;
- }
- case inContent:
- return TkGenerateButtonEvent(where.h, where.v,
- window, medPtr->state);
- break;
- case inGrow:
- /*
- * Generally the content region is the domain of Tk
- * sub-windows. However, one exception is the grow
- * region. A button down in this area will be handled
- * by the window manager. Note: this means that Tk
- * may not get button down events in this area!
- */
- if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
- return true;
- } else {
- return TkGenerateButtonEvent(where.h,
- where.v, window, medPtr->state);
- }
- break;
- case inGoAway:
- return HandleInGoAway(tkwin, medPtr->whichWin, where);
- break;
- case inMenuBar:
- {
- int oldMode;
- KeyMap theKeys;
-
- GetKeys(theKeys);
- oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
- TkMacOSXClearMenubarActive();
-
- /*
- * Handle -postcommand
- */
-
- TkMacOSXPreprocessMenu();
- TkMacOSXHandleMenuSelect(MenuSelect(where),
- EndianS32_BtoN(*(long*)(&theKeys[1])) & 4);
- Tcl_SetServiceMode(oldMode);
- return true; /* TODO: may not be on event on queue. */
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TkMacOSXZoomToplevel(medPtr->whichWin, where,
- medPtr->windowPart) == true) {
- return true;
+ /*
+ * We got a mouse down in a window
+ * See if this is the activate click
+ * This click moves the window forward. We don't want
+ * the corresponding mouse-up to be reported to the application
+ * or else it will mess up some Tk scripts.
+ */
+
+ if (!(TkpIsWindowFloating(medPtr->whichWin))
+ && (medPtr->whichWin != medPtr->activeNonFloating)) {
+ Tk_Window grabWin = TkMacOSXGetCapture();
+ if ((grabWin == NULL)) {
+ int grabState = TkGrabState((TkWindow*)tkwin);
+ if (grabState != TK_GRAB_NONE && grabState != TK_GRAB_IN_TREE) {
+ /* Now we want to set the focus to the local grabWin */
+ TkMacOSXSetEatButtonUp(true);
+ grabWin = (Tk_Window) (((TkWindow*)tkwin)->dispPtr->grabWinPtr);
+ BringWindowForward(GetWindowFromPort(TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)));
+ statusPtr->stopProcessing = 1;
+ return false;
+ }
+ }
+ if ((grabWin != NULL) && (grabWin != tkwin)) {
+ TkWindow * tkw, * grb;
+ tkw = (TkWindow *)tkwin;
+ grb = (TkWindow *)grabWin;
+ /* Now we want to set the focus to the global grabWin */
+ TkMacOSXSetEatButtonUp(true);
+ BringWindowForward(GetWindowFromPort(TkMacOSXGetDrawablePort(((TkWindow*)grabWin)->window)));
+ statusPtr->stopProcessing = 1;
+ return false;
+ }
+
+ /*
+ * Clicks in the stoplights on a MacOS X title bar are processed
+ * directly even for background windows. Do that here.
+ */
+ if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
+ return result;
} else {
+ TkMacOSXSetEatButtonUp(true);
+ BringWindowForward(medPtr->whichWin);
return false;
}
- break;
- case inCollapseBox:
- err = HandleInCollapse(medPtr->whichWin);
- if (err == noErr) {
- statusPtr->err = 1;
- }
- statusPtr->stopProcessing = 1;
- break;
- default:
- return false;
- break;
+ }
+ }
+
+
+ if ((result = HandleWindowTitlebarMouseDown(medPtr, tkwin)) != -1) {
+ return result;
+ }
+ switch (medPtr->windowPart) {
+ case inDrag: {
+ CGrafPtr saveWorld;
+ GDHandle saveDevice;
+ GWorldPtr dstPort;
+
+ GetGWorld(&saveWorld, &saveDevice);
+ dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin));
+ SetGWorld(dstPort, NULL);
+
+ DragWindow(medPtr->whichWin, where, NULL);
+ where2.h = where2.v = 0;
+ LocalToGlobal(&where2);
+ if (EqualPt(where, where2)) {
+ SetGWorld (saveWorld, saveDevice);
+ return false;
+ }
+ TkMacOSXWindowOffset(medPtr->whichWin, &xOffset, &yOffset);
+ where2.h -= xOffset;
+ where2.v -= yOffset;
+ TkGenWMConfigureEvent(tkwin, where2.h, where2.v,
+ -1, -1, TK_LOCATION_CHANGED);
+ SetGWorld(saveWorld, saveDevice);
+ return true;
+ break;
+ }
+ case inContent:
+ return GenerateButtonEvent(medPtr);
+ break;
+ case inGrow:
+ /*
+ * Generally the content region is the domain of Tk
+ * sub-windows. However, one exception is the grow
+ * region. A button down in this area will be handled
+ * by the window manager. Note: this means that Tk
+ * may not get button down events in this area!
+ */
+ if (TkMacOSXGrowToplevel(medPtr->whichWin, where) == true) {
+ return true;
+ } else {
+ return GenerateButtonEvent(medPtr);
+ }
+ break;
+ case inMenuBar: {
+ int oldMode;
+
+ oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
+ TkMacOSXClearMenubarActive();
+
+ /*
+ * Handle -postcommand
+ */
+
+ TkMacOSXPreprocessMenu();
+ TkMacOSXHandleMenuSelect(MenuSelect(where),
+ medPtr->state & Mod2Mask);
+ Tcl_SetServiceMode(oldMode);
+ return true; /* TODO: may not be on event on queue. */
+ break;
+ }
+ default:
+ return false;
+ break;
}
return 0;
}
-
+
/*
*----------------------------------------------------------------------
*
- * HandleInGoAway --
+ * HandleWindowTitlebarMouseDown --
*
- * Tracks the cursor in the go away box and deletes the window
- * if the button stays depressed on button up.
+ * Handle clicks in window titlebar.
*
* Results:
- * True if no errors - false otherwise.
+ * 1 if event was handled, 0 if event was not handled,
+ * -1 if MouseDown was not in window titlebar.
*
* Side effects:
- * The window tkwin may be destroyed.
+ * Additional events may be place on the Tk event queue.
*
*----------------------------------------------------------------------
*/
-int
-HandleInGoAway(Tk_Window tkwin, WindowRef win, Point where)
-{
- if (TrackGoAway(win, where)) {
- if (tkwin == NULL) {
- return false;
- }
- TkGenWMDestroyEvent(tkwin);
- return true;
- }
- return false;
-}
-/*
- *----------------------------------------------------------------------
- *
- * HandleInCollapse --
- *
- * Tracks the cursor in the collapse box and colapses the window
- * if the button stays depressed on button up.
- *
- * Results:
- * Error return from CollapseWindow
- *
- * Side effects:
- * The window win may be collapsed.
- *
- *----------------------------------------------------------------------
- */
-OSErr
-HandleInCollapse(WindowRef win)
+int
+HandleWindowTitlebarMouseDown(MouseEventData * medPtr, Tk_Window tkwin)
{
- OSErr err;
+ int result = 0;
- err = CollapseWindow(win,
- !IsWindowCollapsed(win));
- if (err != noErr) {
- fprintf(stderr,"CollapseWindow failed,%d\n", err);
+ switch (medPtr->windowPart) {
+ case inGoAway:
+ if (TrackGoAway(medPtr->whichWin, medPtr->global)) {
+ if (tkwin) {
+ TkGenWMDestroyEvent(tkwin);
+ result = 1;
+ }
+ }
+ break;
+ case inCollapseBox:
+ if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
+ if (tkwin) {
+ TkpWmSetState((TkWindow *)tkwin, IconicState);;
+ result = 1;
+ }
+ }
+ break;
+ case inZoomIn:
+ case inZoomOut:
+ if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
+ result = TkMacOSXZoomToplevel(medPtr->whichWin, medPtr->windowPart);
+ }
+ break;
+ case inToolbarButton:
+ if (TrackBox(medPtr->whichWin, medPtr->global, medPtr->windowPart)) {
+ result = GenerateToolbarButtonEvent(medPtr);
+ }
+ break;
+ default:
+ result = -1;
+ break;
}
- return err;
-}
+ return result;
+}
+
/*
*----------------------------------------------------------------------
*
* GeneratePollingEvents --
*
- * This function polls the mouse position and generates X Motion,
- * Enter & Leave events. The cursor is also updated at this
- * time.
+ * This function polls the mouse position and generates X Motion,
+ * Enter & Leave events. The cursor is also updated at this
+ * time.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * The cursor may be changed.
+ * Additional events may be place on the Tk event queue.
+ * The cursor may be changed.
*
*----------------------------------------------------------------------
*/
@@ -505,7 +423,6 @@ static int
GeneratePollingEvents(MouseEventData * medPtr)
{
Tk_Window tkwin, rootwin, grabWin;
- Window window;
int local_x, local_y;
TkDisplay *dispPtr;
@@ -513,34 +430,33 @@ GeneratePollingEvents(MouseEventData * medPtr)
grabWin = TkMacOSXGetCapture();
if ((!TkpIsWindowFloating(medPtr->whichWin)
- && (medPtr->activeNonFloating != medPtr->whichWin))) {
- /*
- * If the window for this event is not floating, and is not the
- * active non-floating window, don't generate polling events.
- * We don't send events to backgrounded windows. So either send
- * it to the grabWin, or NULL if there is no grabWin.
- */
-
- tkwin = grabWin;
+ && (medPtr->activeNonFloating != medPtr->whichWin))) {
+ /*
+ * If the window for this event is not floating, and is not the
+ * active non-floating window, don't generate polling events.
+ * We don't send events to backgrounded windows. So either send
+ * it to the grabWin, or NULL if there is no grabWin.
+ */
+
+ tkwin = grabWin;
} else {
- /*
- * First check whether the toplevel containing this mouse
- * event is the grab window. If not, then send the event
- * to the grab window. Otherwise, set tkWin to the subwindow
- * which most closely contains the mouse event.
- */
+ /*
+ * First check whether the toplevel containing this mouse
+ * event is the grab window. If not, then send the event
+ * to the grab window. Otherwise, set tkWin to the subwindow
+ * which most closely contains the mouse event.
+ */
- window = TkMacOSXGetXWindow(medPtr->whichWin);
- dispPtr = TkGetDisplayList();
- rootwin = Tk_IdToWindow(dispPtr->display, window);
- if ((rootwin == NULL)
- || ((grabWin != NULL) && (rootwin != grabWin))) {
- tkwin = grabWin;
- } else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &local_x, &local_y);
- }
+ dispPtr = TkGetDisplayList();
+ rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
+ if ((rootwin == NULL)
+ || ((grabWin != NULL) && (rootwin != grabWin))) {
+ tkwin = grabWin;
+ } else {
+ tkwin = Tk_TopCoordsToWindow(rootwin,
+ medPtr->local.h, medPtr->local.v,
+ &local_x, &local_y);
+ }
}
/*
@@ -549,62 +465,100 @@ GeneratePollingEvents(MouseEventData * medPtr)
*/
Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v,
- medPtr->state);
+ medPtr->state);
return true;
}
-
-/*
+/*
*----------------------------------------------------------------------
*
* 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. We also set state
+ * so Tk thinks the button is currently up.
*
* Results:
- * None.
- *
+ * None.
+ *
* Side effects:
- * The window is brought forward.
- *
+ * The window is brought forward.
+ *
*----------------------------------------------------------------------
- */
-
-static void
+ */
+
+static void
BringWindowForward(WindowRef wRef)
-{
+{
+ do {
+ ProcessSerialNumber frontPsn, ourPsn = {0, kCurrentProcess};
+ Boolean flag;
+ int err;
+
+ err = GetFrontProcess(&frontPsn);
+ if (err != noErr) {
+ fprintf(stderr, "GetFrontProcess failed, %d\n", err);
+ break;
+ }
+ err = SameProcess(&frontPsn, &ourPsn, &flag);
+ if (err != noErr) {
+ fprintf(stderr, "SameProcess failed, %d\n", err);
+ break;
+ } else {
+ if (!flag) {
+ err = SetFrontProcess(&ourPsn);
+ if (err != noErr) {
+ fprintf(stderr,"SetFrontProcess failed,%d\n", err);
+ break;
+ }
+ }
+ }
+ } while (0);
+
if (!TkpIsWindowFloating(wRef)) {
- if (IsValidWindowPtr(wRef))
- SelectWindow(wRef);
+ if (IsValidWindowPtr(wRef))
+ SelectWindow(wRef);
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GenerateMouseWheelEvent --
+ *
+ * Generates a "MouseWheel" Tk event.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Places a mousewheel event on the event queue.
+ *
+ *----------------------------------------------------------------------
+ */
static int
GenerateMouseWheelEvent(MouseEventData * medPtr)
{
Tk_Window tkwin, rootwin, grabWin;
- Window window;
int local_x, local_y;
TkDisplay *dispPtr;
TkWindow *winPtr;
XEvent xEvent;
if ((!TkpIsWindowFloating(medPtr->whichWin)
- && (medPtr->activeNonFloating != medPtr->whichWin))) {
- tkwin = NULL;
+ && (medPtr->activeNonFloating != medPtr->whichWin))) {
+ tkwin = NULL;
} else {
- window = TkMacOSXGetXWindow(medPtr->whichWin);
- dispPtr = TkGetDisplayList();
- rootwin = Tk_IdToWindow(dispPtr->display, window);
- if (rootwin == NULL) {
- tkwin = NULL;
- } else {
- tkwin = Tk_TopCoordsToWindow(rootwin,
- medPtr->local.h, medPtr->local.v,
- &local_x, &local_y);
- }
+ dispPtr = TkGetDisplayList();
+ rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
+ if (rootwin == NULL) {
+ tkwin = NULL;
+ } else {
+ tkwin = Tk_TopCoordsToWindow(rootwin,
+ medPtr->local.h, medPtr->local.v,
+ &local_x, &local_y);
+ }
}
/*
@@ -615,12 +569,12 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
grabWin = TkMacOSXGetCapture();
if ((tkwin == NULL) && (grabWin != NULL)) {
- tkwin = grabWin;
+ tkwin = grabWin;
}
if (!tkwin) {
return true;
}
- winPtr = ( TkWindow *)tkwin;
+ winPtr = (TkWindow *) tkwin;
xEvent.type = MouseWheelEvent;
xEvent.xkey.keycode = medPtr->delta;
xEvent.xbutton.state = TkMacOSXButtonKeyState();
@@ -632,18 +586,18 @@ GenerateMouseWheelEvent(MouseEventData * medPtr)
return true;
}
-
+
/*
*----------------------------------------------------------------------
*
* TkMacOSXGetEatButtonUp --
*
* Results:
- * Returns the flag indicating if we need to eat the
- * next mouse up event
+ * Returns the flag indicating if we need to eat the
+ * next mouse up event
*
* Side effects:
- * None.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -654,36 +608,39 @@ TkMacOSXGetEatButtonUp()
}
/*
+ *----------------------------------------------------------------------
+ *
* TkMacOSXSetEatButtonUp --
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * Sets the flag indicating if we need to eat the
- * next mouse up event
+ * Sets the flag indicating if we need to eat the
+ * next mouse up event
*
+ *----------------------------------------------------------------------
*/
void
TkMacOSXSetEatButtonUp(int f)
{
gEatButtonUp = f;
}
-
+
/*
*----------------------------------------------------------------------
*
* TkMacOSXButtonKeyState --
*
- * Returns the current state of the button & modifier keys.
+ * Returns the current state of the button & modifier keys.
*
* Results:
- * A bitwise inclusive OR of a subset of the following:
- * Button1Mask, ShiftMask, LockMask, ControlMask, Mod?Mask,
- * Mod?Mask.
+ * A bitwise inclusive OR of a subset of the following:
+ * Button1Mask, ShiftMask, LockMask, ControlMask, Mod?Mask,
+ * Mod?Mask.
*
* Side effects:
- * None.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -691,36 +648,62 @@ TkMacOSXSetEatButtonUp(int f)
unsigned int
TkMacOSXButtonKeyState()
{
- unsigned int state = 0;
- KeyMap theKeys;
- long modif;
-
- if (Button() & !gEatButtonUp) {
- state |= Button1Mask;
+ UInt32 buttonState = 0, keyModifiers;
+ EventRef ev = GetCurrentEvent();
+
+ if (!gEatButtonUp) {
+ buttonState = ev ? GetCurrentEventButtonState() : GetCurrentButtonState();
}
-
- GetKeys(theKeys);
+ keyModifiers = ev ? GetCurrentEventKeyModifiers() : GetCurrentKeyModifiers();
- modif = EndianS32_BtoN(*(long*)(&theKeys[1]));
+ return ButtonModifiers2State(buttonState, keyModifiers);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ButtonModifiers2State --
+ *
+ * Converts Carbon mouse button state and modifier values into a Tk
+ * button/modifier state.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
- if (modif & 2) {
- state |= LockMask;
+static unsigned int
+ButtonModifiers2State(UInt32 buttonState, UInt32 keyModifiers)
+{
+ unsigned int state;
+
+ /* Tk supports at most 5 buttons */
+ state = (buttonState & ((1<<5) - 1)) << 8;
+
+ if (keyModifiers & alphaLock) {
+ state |= LockMask;
}
-
- if (modif & 1) {
- state |= ShiftMask;
+ if (keyModifiers & shiftKey) {
+ state |= ShiftMask;
}
-
- if (modif & 8) {
- state |= ControlMask;
+ if (keyModifiers & controlKey) {
+ state |= ControlMask;
}
-
- if (modif & 32768) {
- state |= Mod1Mask; /* command key */
+ if (keyModifiers & cmdKey) {
+ state |= Mod1Mask; /* command key */
}
-
- if (modif & 4) {
- state |= Mod2Mask; /* option key */
+ if (keyModifiers & optionKey) {
+ state |= Mod2Mask; /* option key */
+ }
+ if (keyModifiers & kEventKeyModifierNumLockMask) {
+ state |= Mod3Mask;
+ }
+ if (keyModifiers & kEventKeyModifierFnMask) {
+ state |= Mod4Mask;
}
return state;
@@ -731,16 +714,16 @@ TkMacOSXButtonKeyState()
*
* XQueryPointer --
*
- * Check the current state of the mouse. This is not a complete
- * implementation of this function. It only computes the root
- * coordinates and the current mask.
+ * Check the current state of the mouse. This is not a complete
+ * implementation of this function. It only computes the root
+ * coordinates and the current mask.
*
* Results:
- * Sets root_x_return, root_y_return, and mask_return. Returns
- * true on success.
+ * Sets root_x_return, root_y_return, and mask_return. Returns
+ * true on success.
*
* Side effects:
- * None.
+ * None.
*
*----------------------------------------------------------------------
*/
@@ -757,83 +740,175 @@ XQueryPointer(
int* win_y_return,
unsigned int* mask_return)
{
- Point where;
- CGrafPtr port;
- GDHandle dev;
-
- GetGWorld(&port,&dev);
- GetMouse(&where);
- LocalToGlobal(&where);
-
- *root_x_return = where.h;
- *root_y_return = where.v;
- *mask_return = TkMacOSXButtonKeyState();
+ if (root_x_return && root_y_return) {
+ Point where;
+ EventRef ev;
+ OSStatus status;
+
+ if ((ev = GetCurrentEvent())) {
+ status = GetEventParameter(ev,
+ kEventParamMouseLocation,
+ typeQDPoint, NULL,
+ sizeof(where), NULL,
+ &where);
+ }
+ if (!ev || status != noErr) {
+ GetGlobalMouse(&where);
+ }
+
+ *root_x_return = where.h;
+ *root_y_return = where.v;
+ }
+ if (mask_return) {
+ *mask_return = TkMacOSXButtonKeyState();
+ }
return True;
}
-
-
+
/*
*----------------------------------------------------------------------
*
* TkGenerateButtonEvent --
*
- * Given a global x & y position and the button key status this
- * procedure generates the appropiate X button event. It also
- * handles the state changes needed to implement implicit grabs.
+ * Given a global x & y position and the button key status this
+ * procedure generates the appropiate X button event. It also
+ * handles the state changes needed to implement implicit grabs.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- * Grab state may also change.
+ * Additional events may be place on the Tk event queue.
+ * Grab state may also change.
*
*----------------------------------------------------------------------
*/
int
TkGenerateButtonEvent(
- int x, /* X location of mouse */
- int y, /* Y location of mouse */
- Window window, /* X Window containing button event. */
- unsigned int state) /* Button Key state suitable for X event */
+ int x, /* X location of mouse */
+ int y, /* Y location of mouse */
+ Window window, /* X Window containing button event. */
+ unsigned int state) /* Button Key state suitable for X event */
+{
+ MouseEventData med;
+
+ bzero(&med, sizeof(MouseEventData));
+ med.state = state;
+ med.window = window;
+ med.global.h = x;
+ med.global.v = y;
+ FindWindow(med.global, &med.whichWin);
+ med.activeNonFloating = ActiveNonFloatingWindow();
+ med.local = med.global;
+ QDGlobalToLocalPoint(GetWindowPort(med.whichWin), &med.local);
+
+ return GenerateButtonEvent(&med);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GenerateButtonEvent --
+ *
+ * Generate an X button event from a MouseEventData structure.
+ * Handles the state changes needed to implement implicit grabs.
+ *
+ * Results:
+ * True if event(s) are generated - false otherwise.
+ *
+ * Side effects:
+ * Additional events may be place on the Tk event queue.
+ * Grab state may also change.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+GenerateButtonEvent(MouseEventData * medPtr)
{
- WindowRef whichWin, frontWin;
- Point where;
Tk_Window tkwin;
int dummy;
TkDisplay *dispPtr;
/*
* ButtonDown events will always occur in the front
- * window. ButtonUp events, however, may occur anywhere
+ * window. ButtonUp events, however, may occur anywhere
* on the screen. ButtonUp events should only be sent
* to Tk if in the front window or during an implicit grab.
*/
-
- where.h = x;
- where.v = y;
- FindWindow(where, &whichWin);
- frontWin = FrontNonFloatingWindow();
-
- if (0 && ((frontWin == NULL) || ((!(TkpIsWindowFloating(whichWin))
- && (frontWin != whichWin))
- && TkMacOSXGetCapture() == NULL))) {
- return false;
+ if (0
+ && ((medPtr->activeNonFloating == NULL)
+ || ((!(TkpIsWindowFloating(medPtr->whichWin))
+ && (medPtr->activeNonFloating != medPtr->whichWin))
+ && TkMacOSXGetCapture() == NULL))) {
+ return false;
}
dispPtr = TkGetDisplayList();
- tkwin = Tk_IdToWindow(dispPtr->display, window);
-
- /* SetPortWindowPort(ActiveNonFloatingWindow()); */
- SetPortWindowPort(whichWin);
- GlobalToLocal(&where);
+ tkwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
+
if (tkwin != NULL) {
- tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v,
- &dummy, &dummy);
+ tkwin = Tk_TopCoordsToWindow(tkwin, medPtr->local.h, medPtr->local.v,
+ &dummy, &dummy);
+ }
+
+ Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state);
+
+ return true;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GenerateToolbarButtonEvent --
+ *
+ * Generates a "ToolbarButton" virtual event.
+ * This can be used to manage disappearing toolbars.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Places a virtual event on the event queue.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+GenerateToolbarButtonEvent(MouseEventData * medPtr)
+{
+ Tk_Window rootwin, tkwin = NULL;
+ TkDisplay *dispPtr;
+ TkWindow *winPtr;
+ XVirtualEvent event;
+
+ dispPtr = TkGetDisplayList();
+ rootwin = Tk_IdToWindow(dispPtr->display, medPtr->window);
+ if (rootwin) {
+ tkwin = Tk_TopCoordsToWindow(rootwin,
+ medPtr->local.h, medPtr->local.v, &event.x, &event.y);
+ }
+ if (!tkwin) {
+ return true;
}
- Tk_UpdatePointer(tkwin, x, y, state);
+ winPtr = (TkWindow *)tkwin;
+ event.type = VirtualEvent;
+ event.serial = LastKnownRequestProcessed(winPtr->display);
+ event.send_event = false;
+ event.display = winPtr->display;
+ event.event = winPtr->window;
+ event.root = XRootWindow(winPtr->display, 0);
+ event.subwindow = None;
+ event.time = TkpGetMS();
+
+ event.x_root = medPtr->global.h;
+ event.y_root = medPtr->global.v;
+ event.state = medPtr->state;
+ event.same_screen = true;
+ event.name = Tk_GetUid("ToolbarButton");
+ Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
return true;
}
diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c
index d0d8de8..fd111f2 100644
--- a/macosx/tkMacOSXScale.c
+++ b/macosx/tkMacOSXScale.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: tkMacOSXScale.c,v 1.4 2005/03/24 07:16:13 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXScale.c,v 1.5 2005/08/09 07:39:21 das Exp $
*/
#include "tkScale.h"
@@ -416,7 +416,7 @@ MacScaleEventProc(clientData, eventPtr)
return;
}
- part = TrackControl(macScalePtr->scaleHandle, where, (void *) -1);
+ part = TrackControl(macScalePtr->scaleHandle, where, scaleActionProc);
/*
* Update the value for the widget.
@@ -428,7 +428,6 @@ MacScaleEventProc(clientData, eventPtr)
* The TrackControl call will "eat" the ButtonUp event. We now
* generate a ButtonUp event so Tk will unset implicit grabs etc.
*/
- GetMouse(&where);
XQueryPointer(NULL, None, &dummyWin, &dummyWin, &x,
&y, &dummy, &dummy, &state);
TkGenerateButtonEvent(x, y, Tk_WindowId(macScalePtr->info.tkwin), state);
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 0a5876d..f5e3b44 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.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: tkMacOSXScrlbr.c,v 1.13 2005/06/03 17:06:22 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.14 2005/08/09 07:39:21 das Exp $
*/
#include "tkScrollbar.h"
@@ -269,7 +269,7 @@ TkpDisplayScrollbar(
* If we are foremost then make us active.
*/
- frontNonFloating = FrontNonFloatingWindow();
+ frontNonFloating = ActiveNonFloatingWindow();
if ((windowRef == FrontWindow()) || TkpIsWindowFloating(windowRef)) {
macScrollPtr->macFlags |= ACTIVE;
@@ -877,7 +877,6 @@ ScrollbarBindProc(
* The TrackControl call will "eat" the ButtonUp event. We now
* generate a ButtonUp event so Tk will unset implicit grabs etc.
*/
- GetMouse(&where);
XQueryPointer(NULL, None, &window, &window, &x,
&y, &dummy, &dummy, &state);
window = Tk_WindowId(scrollPtr->tkwin);
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 0ffc534..6f85a9a 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -9,7 +9,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.8 2005/03/15 02:11:56 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.9 2005/08/09 07:39:21 das Exp $
*/
#include "tkInt.h"
@@ -20,6 +20,7 @@
#include <Carbon/Carbon.h>
#include "tkMacOSXInt.h"
#include "tkMacOSXDebug.h"
+#include "tkMacOSXWm.h"
/*
* Temporary region that can be reused.
@@ -64,8 +65,7 @@ XDestroyWindow(
TkPointerDeadWindow(macWin->winPtr);
macWin->toplevel->referenceCount--;
-
-
+
if (Tk_IsTopLevel(macWin->winPtr)) {
WindowRef winRef;
/*
@@ -85,7 +85,7 @@ XDestroyWindow(
if (TkpIsWindowFloating (winRef)) {
Window window;
- window = TkMacOSXGetXWindow(FrontNonFloatingWindow());
+ window = TkMacOSXGetXWindow(ActiveNonFloatingWindow());
if (window != None) {
TkMacOSXGenerateFocusEvent(window, 1);
}
@@ -251,7 +251,18 @@ XMapWindow(
FixMappingFlags(macWin->winPtr, 1);
if (Tk_IsTopLevel(macWin->winPtr)) {
if (!Tk_IsEmbedded(macWin->winPtr)) {
- ShowWindow(GetWindowFromPort(destPort));
+ /*
+ * XXX This should be ShowSheetWindow for kSheetWindowClass
+ * XXX windows that have a wmPtr->master parent set.
+ */
+ WindowRef wRef = GetWindowFromPort(destPort);
+ if ((TkMacOSXWindowClass(macWin->winPtr) == kSheetWindowClass)
+ && (macWin->winPtr->wmInfoPtr->master != None)) {
+ ShowSheetWindow(wRef,
+ GetWindowFromPort(TkMacOSXGetDrawablePort(macWin->winPtr->wmInfoPtr->master)));
+ } else {
+ ShowWindow(wRef);
+ }
}
/*
@@ -312,8 +323,19 @@ XUnmapWindow(
macWin->flags &= ~TK_MAPPED_IN_PARENT;
FixMappingFlags(macWin->winPtr, 0);
if (Tk_IsTopLevel(macWin->winPtr)) {
- if (!Tk_IsEmbedded(macWin->winPtr)) {
- HideWindow(GetWindowFromPort(destPort));
+ if (!Tk_IsEmbedded(macWin->winPtr)
+ && macWin->winPtr->wmInfoPtr->hints.initial_state != IconicState) {
+ /*
+ * XXX This should be HideSheetWindow for kSheetWindowClass
+ * XXX windows that have a wmPtr->master parent set.
+ */
+ WindowRef wref = GetWindowFromPort(destPort);
+ if ((TkMacOSXWindowClass(macWin->winPtr) == kSheetWindowClass)
+ && (macWin->winPtr->wmInfoPtr->master != None)) {
+ HideSheetWindow(wref);
+ } else {
+ HideWindow(wref);
+ }
}
/*
@@ -323,7 +345,7 @@ XUnmapWindow(
event.xany.serial = display->request;
event.xany.send_event = False;
event.xany.display = display;
-
+
event.xunmap.type = UnmapNotify;
event.xunmap.window = window;
event.xunmap.event = window;
@@ -380,7 +402,6 @@ XResizeWindow(
* region. It is currently assumed that Tk will need
* to completely redraw anway.
*/
-
if (havePort) {
SetPort(destPort);
SizeWindow(GetWindowFromPort(destPort),
@@ -401,7 +422,7 @@ XResizeWindow(
if (contWinPtr != NULL) {
MacDrawable *macParent = contWinPtr->privatePtr;
-
+
if (havePort) {
SetPort(destPort);
TkMacOSXInvalClipRgns(macParent->winPtr);
@@ -574,13 +595,13 @@ XMoveResizeWindow(
return; /* TODO: Probably should be a panic */
}
}
-
- if (havePort) {
- SetPort( destPort);
+
+ if (havePort) {
+ SetPort( destPort);
TkMacOSXInvalClipRgns(macParent->winPtr);
TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW);
- }
-
+ }
+
deltaX = - macWin->xOff;
deltaY = - macWin->yOff;
@@ -647,7 +668,6 @@ XMoveWindow(
* region. It is currently assumed that Tk will need
* to completely redraw anway.
*/
-
if (havePort) {
SetPort(destPort);
MoveWindowStructure( GetWindowFromPort(destPort), x, y);
@@ -871,7 +891,7 @@ TkMacOSXUpdateClipRgn(
RgnHandle rgn;
int x, y;
TkWindow *win2Ptr;
-
+
if (winPtr == NULL) {
return;
}
@@ -1015,7 +1035,6 @@ RgnHandle
TkMacOSXVisableClipRgn(
TkWindow *winPtr)
{
-
if (winPtr->privatePtr->flags & TK_CLIP_INVALID) {
TkMacOSXUpdateClipRgn(winPtr);
}
@@ -1287,10 +1306,11 @@ TkMacOSXWinBounds(
bounds->left = (short) winPtr->privatePtr->xOff;
bounds->top = (short) winPtr->privatePtr->yOff;
bounds->right = (short) (winPtr->privatePtr->xOff +
- winPtr->changes.width);
+ winPtr->changes.width);
bounds->bottom = (short) (winPtr->privatePtr->yOff +
- winPtr->changes.height);
-}
+ winPtr->changes.height);
+}
+
/*
*----------------------------------------------------------------------
*
diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c
index 02cad5f..90cf964 100644
--- a/macosx/tkMacOSXTest.c
+++ b/macosx/tkMacOSXTest.c
@@ -10,10 +10,11 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXTest.c,v 1.2 2002/08/31 06:12:30 das Exp $
+ * RCS: @(#) $Id: tkMacOSXTest.c,v 1.3 2005/08/09 07:39:21 das Exp $
*/
#include <tcl.h>
+#include <Carbon/Carbon.h>
/*
* Forward declarations of procedures defined later in this file:
@@ -21,7 +22,7 @@
int TkplatformtestInit _ANSI_ARGS_((Tcl_Interp *interp));
static int DebuggerCmd _ANSI_ARGS_((ClientData dummy,
- Tcl_Interp *interp, int argc, char **argv));
+ Tcl_Interp *interp, int argc, CONST char **argv));
/*
*----------------------------------------------------------------------
@@ -75,7 +76,7 @@ DebuggerCmd(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Not used. */
int argc, /* Not used. */
- char **argv) /* Not used. */
+ CONST char **argv) /* Not used. */
{
Debugger();
return TCL_OK;
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index dbb94cc..b5633e7 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.6 2005/08/09 07:39:21 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -99,6 +101,16 @@ TkMacOSXProcessApplicationEvent(
TkMacOSXEvent *eventPtr,
MacEventStatus *statusPtr)
{
+ Tcl_CmdInfo dummy;
+
+ /*
+ * This is a bit of a hack. We get "show" events both when we come back
+ * from being hidden, and whenever we are activated. I only want to run the
+ * "show" proc when we have been hidden already, not as a substitute for
+ * <Activate>. So I use this toggle...
+ */
+ static int toggleHide = 0;
+
switch (eventPtr->eKind) {
case kEventAppActivated:
tkMacOSXAppInFront = true;
@@ -115,6 +127,34 @@ TkMacOSXProcessApplicationEvent(
case kEventAppTerminated:
case kEventAppFrontSwitched:
break;
+ case kEventAppHidden:
+ /*
+ * Don't bother if we don't have an interp or
+ * the show preferences procedure doesn't exist.
+ */
+ toggleHide = 1;
+ if ((eventPtr->interp == NULL) ||
+ (Tcl_GetCommandInfo(eventPtr->interp,
+ "::tk::mac::OnHide", &dummy)) == 0) {
+ break;
+ }
+ Tcl_GlobalEval(eventPtr->interp, "::tk::mac::OnHide");
+ statusPtr->stopProcessing = 1;
+ break;
+ case kEventAppShown:
+ if (toggleHide == 1) {
+ toggleHide = 0;
+ if ((eventPtr->interp == NULL) ||
+ (Tcl_GetCommandInfo(eventPtr->interp,
+ "::tk::mac::OnShow", &dummy)) == 0) {
+ break;
+ }
+ Tcl_GlobalEval(eventPtr->interp, "::tk::mac::OnShow");
+ }
+ statusPtr->stopProcessing = 1;
+ break;
+ default:
+ break;
}
return 0;
}
@@ -150,6 +190,7 @@ TkMacOSXProcessWindowEvent(
case kEventWindowActivated:
case kEventWindowDeactivated:
case kEventWindowUpdate:
+ case kEventWindowExpanded:
break;
default:
return 0;
@@ -181,6 +222,16 @@ TkMacOSXProcessWindowEvent(
eventFound = true;
}
break;
+ case kEventWindowExpanded: {
+ TkDisplay *dispPtr;
+ TkWindow *winPtr;
+ dispPtr = TkGetDisplayList();
+ winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
+ if (winPtr) {
+ TkpWmSetState(winPtr, NormalState);
+ }
+ break;
+ }
}
return 0;
}
@@ -394,7 +445,7 @@ GenerateActivateEvents(
*----------------------------------------------------------------------
*/
-int
+MODULE_SCOPE int
TkMacOSXGenerateFocusEvent(
Window window, /* Root X window for event. */
int activeFlag )
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 4ca74d7..0d6ca96 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.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: tkMacOSXWm.c,v 1.18 2005/05/14 20:48:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWm.c,v 1.19 2005/08/09 07:39:21 das Exp $
*/
#include <Carbon/Carbon.h>
@@ -188,9 +188,8 @@ static int WmWithdrawCmd _ANSI_ARGS_((Tk_Window tkwin,
static void WmUpdateGeom _ANSI_ARGS_((WmInfo *wmPtr,
TkWindow *winPtr));
static int TkMacOSXWinStyle _ANSI_ARGS_((Tcl_Interp *interp,
- TkWindow *winPtr, int objc, Tcl_Obj * CONST
- objv[]));
-
+ TkWindow *winPtr, int objc,
+ Tcl_Obj * CONST objv[]));
/*
*--------------------------------------------------------------
@@ -215,7 +214,7 @@ TkWmNewWindow(
TkWindow *winPtr) /* Newly-created top-level window. */
{
WmInfo *wmPtr;
-
+
wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo));
wmPtr->winPtr = winPtr;
wmPtr->reparent = None;
@@ -323,7 +322,7 @@ TkWmMapWindow(
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
Point where = {0, 0};
- int xOffset, yOffset;
+ int xOffset, yOffset;
int firstMap = false;
MacDrawable *macWin;
@@ -338,7 +337,7 @@ TkWmMapWindow(
if (!TkMacOSXHostToplevelExists(winPtr)) {
TkMacOSXMakeRealWindowExist(winPtr);
}
-
+
/*
* Generate configure event when we first map the window.
*/
@@ -349,7 +348,7 @@ TkWmMapWindow(
where.v -= yOffset;
TkGenWMConfigureEvent((Tk_Window) winPtr,
where.h, where.v, -1, -1, TK_LOCATION_CHANGED);
-
+
/*
* This is the first time this window has ever been mapped.
* Store all the window-manager-related information for the
@@ -359,17 +358,17 @@ TkWmMapWindow(
if (wmPtr->titleUid == NULL) {
wmPtr->titleUid = winPtr->nameUid;
}
-
+
if (!Tk_IsEmbedded(winPtr)) {
TkSetWMName(winPtr, wmPtr->titleUid);
}
TkWmSetClass(winPtr);
-
+
if (wmPtr->iconName != NULL) {
XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName);
}
-
+
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
}
if (wmPtr->hints.initial_state == WithdrawnState) {
@@ -996,7 +995,8 @@ static void WmAttrGetTitlePath(WindowRef macWindow, Tcl_Obj *result)
*
*----------------------------------------------------------------------
*/
-static void WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result)
+static void
+WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result)
{
float fval;
if (GetWindowAlpha(macWindow, &fval) != noErr) {
@@ -1021,11 +1021,13 @@ static void WmAttrGetAlpha(WindowRef macWindow, Tcl_Obj *result)
*
*----------------------------------------------------------------------
*/
-static void WmAttrGetNotifyStatus(Tcl_Obj *result)
+static void
+WmAttrGetNotifyStatus(Tcl_Obj *result)
{
Tcl_AppendObjToObj(result,
Tcl_NewBooleanObj((tkMacOSXWmAttrNotifyVal != 0)));
}
+
/*
*----------------------------------------------------------------------
* WmAttrGetNotifyStatus --
@@ -1041,7 +1043,8 @@ static void WmAttrGetNotifyStatus(Tcl_Obj *result)
*
*----------------------------------------------------------------------
*/
-static void WmAttrSetNotifyStatus(int state)
+static void
+WmAttrSetNotifyStatus(int state)
{
static NMRec notifyRec;
@@ -2222,7 +2225,18 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
atts.override_redirect = (boolean) ? True : False;
Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect,
&atts);
- wmPtr->style = (boolean) ? plainDBox : documentProc;
+ /*
+ * FIX: We need an UpdateWrapper equivalent to make this 100% correct
+ */
+ if (boolean) {
+ wmPtr->style = plainDBox;
+ } else {
+ if (wmPtr->master != None) {
+ wmPtr->style = floatZoomGrowProc; // override && transient
+ } else {
+ wmPtr->style = documentProc;
+ }
+ }
return TCL_OK;
}
@@ -2401,11 +2415,11 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
static int
WmResizableCmd(tkwin, winPtr, interp, objc, objv)
-Tk_Window tkwin; /* Main window of the application. */
-TkWindow *winPtr; /* Toplevel to work with */
-Tcl_Interp *interp; /* Current interpreter. */
-int objc; /* Number of arguments. */
-Tcl_Obj *CONST objv[]; /* Argument objects. */
+ Tk_Window tkwin; /* Main window of the application. */
+ TkWindow *winPtr; /* Toplevel to work with */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int width, height;
@@ -2429,18 +2443,30 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
}
if (width) {
wmPtr->flags &= ~WM_WIDTH_NOT_RESIZABLE;
+ wmPtr->attributes |= kWindowHorizontalZoomAttribute;
} else {
wmPtr->flags |= WM_WIDTH_NOT_RESIZABLE;
+ wmPtr->attributes &= ~kWindowHorizontalZoomAttribute;
}
if (height) {
wmPtr->flags &= ~WM_HEIGHT_NOT_RESIZABLE;
+ wmPtr->attributes |= kWindowVerticalZoomAttribute;
} else {
wmPtr->flags |= WM_HEIGHT_NOT_RESIZABLE;
+ wmPtr->attributes &= ~kWindowVerticalZoomAttribute;
+ }
+ /*
+ * XXX: Need a ChangeWindowAttributes
+ */
+ if (width || height) {
+ wmPtr->attributes |= kWindowResizableAttribute;
+ } else {
+ wmPtr->attributes &= ~kWindowResizableAttribute;
}
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (wmPtr->scrollWinPtr != NULL) {
- TkScrollbarEventuallyRedraw(
- (TkScrollbar *) wmPtr->scrollWinPtr->instanceData);
+ TkScrollbarEventuallyRedraw((TkScrollbar *)
+ wmPtr->scrollWinPtr->instanceData);
}
WmUpdateGeom(wmPtr, winPtr);
return TCL_OK;
@@ -2800,11 +2826,11 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
static int
WmTransientCmd(tkwin, winPtr, interp, objc, objv)
-Tk_Window tkwin; /* Main window of the application. */
-TkWindow *winPtr; /* Toplevel to work with */
-Tcl_Interp *interp; /* Current interpreter. */
-int objc; /* Number of arguments. */
-Tcl_Obj *CONST objv[]; /* Argument objects. */
+ Tk_Window tkwin; /* Main window of the application. */
+ TkWindow *winPtr; /* Toplevel to work with */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Tk_Window master;
@@ -2828,7 +2854,12 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
ckfree(wmPtr->masterWindowName);
}
wmPtr->masterWindowName = NULL;
- wmPtr->style = documentProc;
+ /* XXX UpdateWrapper */
+ if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
+ wmPtr->style = plainDBox;
+ } else {
+ wmPtr->style = documentProc;
+ }
} else {
if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) {
return TCL_ERROR;
@@ -2860,7 +2891,12 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
wmPtr->master = Tk_WindowId(master);
wmPtr->masterWindowName = ckalloc((unsigned) length+1);
strcpy(wmPtr->masterWindowName, argv3);
- wmPtr->style = plainDBox;
+ /* XXX UpdateWrapper */
+ if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
+ wmPtr->style = plainDBox;
+ } else {
+ wmPtr->style = floatZoomGrowProc;
+ }
}
return TCL_OK;
}
@@ -2884,11 +2920,11 @@ Tcl_Obj *CONST objv[]; /* Argument objects. */
static int
WmWithdrawCmd(tkwin, winPtr, interp, objc, objv)
-Tk_Window tkwin; /* Main window of the application. */
-TkWindow *winPtr; /* Toplevel to work with */
-Tcl_Interp *interp; /* Current interpreter. */
-int objc; /* Number of arguments. */
-Tcl_Obj *CONST objv[]; /* Argument objects. */
+ Tk_Window tkwin; /* Main window of the application. */
+ TkWindow *winPtr; /* Toplevel to work with */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int objc; /* Number of arguments. */
+ Tcl_Obj *CONST objv[]; /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -2916,7 +2952,7 @@ WmInfo *wmPtr;
TkWindow *winPtr;
{
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3079,7 +3115,7 @@ Tk_UnsetGrid(
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3165,7 +3201,7 @@ TopLevelReqProc(
wmPtr = winPtr->wmInfoPtr;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3563,7 +3599,7 @@ ParseGeometry(
wmPtr->flags = flags;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tk_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
return TCL_OK;
@@ -3841,7 +3877,7 @@ Tk_TopCoordsToWindow(
* Container windows cannot have children. So if it is a container,
* look there, otherwise inspect the children.
*/
-
+
if (Tk_IsContainer(winPtr)) {
childPtr = TkpGetOtherWindow(winPtr);
if (childPtr != NULL) {
@@ -3851,7 +3887,7 @@ Tk_TopCoordsToWindow(
childPtr->changes.width) &&
(y > childPtr->changes.y &&
y < childPtr->changes.y +
- childPtr->changes.height)) {
+ childPtr->changes.height)) {
nextPtr = childPtr;
}
}
@@ -3859,9 +3895,7 @@ Tk_TopCoordsToWindow(
/*
* NOTE: Here we should handle out of process embedding.
*/
-
} else {
-
for (childPtr = winPtr->childList; childPtr != NULL;
childPtr = childPtr->nextPtr) {
if (!Tk_IsMapped(childPtr) ||
@@ -4101,15 +4135,14 @@ TkWmRestackToplevel(
* above or below *all* siblings. */
{
WmInfo *wmPtr;
-
+
WindowRef macWindow, otherMacWindow, frontWindow, tmpWindow;
wmPtr = winPtr->wmInfoPtr;
-
+
/*
* Get the mac window. Make sure it exists & is mapped.
*/
-
if (winPtr->window == None) {
Tk_MakeWindowExist((Tk_Window) winPtr);
}
@@ -4124,7 +4157,7 @@ TkWmRestackToplevel(
TkWmMapWindow(winPtr);
}
macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));
-
+
/*
* Get the window in which a raise or lower is in relation to.
*/
@@ -4139,10 +4172,9 @@ TkWmRestackToplevel(
} else {
otherMacWindow = NULL;
}
-
- frontWindow = FrontNonFloatingWindow();
-
+ frontWindow = ActiveNonFloatingWindow();
+
if (aboveBelow == Above) {
if (macWindow == frontWindow) {
/*
@@ -4375,12 +4407,7 @@ TkGetPointerCoords(
* on which lookup is to be done. */
int *xPtr, int *yPtr) /* Store pointer coordinates here. */
{
- Point where;
-
- GetMouse(&where);
- LocalToGlobal(&where);
- *xPtr = where.h;
- *yPtr = where.v;
+ XQueryPointer(NULL, None, NULL, NULL, xPtr, yPtr, NULL, NULL, NULL);
}
/*
@@ -4410,7 +4437,7 @@ InitialWindowBounds(
int x, y;
static int defaultX = 5;
static int defaultY = 45;
-
+
if (!(winPtr->wmInfoPtr->sizeHintsFlags & (USPosition | PPosition))) {
/*
* We will override the program & hopefully place the
@@ -4431,7 +4458,7 @@ InitialWindowBounds(
x = winPtr->wmInfoPtr->x;
y = winPtr->wmInfoPtr->y;
}
-
+
geometry->left = x;
geometry->top = y;
geometry->right = x + winPtr->changes.width;
@@ -4510,7 +4537,6 @@ TkMacOSXGrowToplevel(
GetPortBounds(GetWindowPort(whichWindow), &portRect );
if (where.h > (portRect.right - 16) &&
where.v > (portRect.bottom - 16)) {
-
Window window;
TkWindow *winPtr;
WmInfo *wmPtr;
@@ -4521,7 +4547,7 @@ TkMacOSXGrowToplevel(
dispPtr = TkGetDisplayList();
winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window);
wmPtr = winPtr->wmInfoPtr;
-
+
/* TODO: handle grid size options. */
if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) &&
(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) {
@@ -4539,14 +4565,14 @@ TkMacOSXGrowToplevel(
bounds.top = (wmPtr->minHeight < 64) ? 64 : wmPtr->minHeight;
bounds.bottom = (wmPtr->maxHeight < 64) ? 64 : wmPtr->maxHeight;
}
-
+
growResult = GrowWindow(whichWindow, start, &bounds);
if (growResult != 0) {
SizeWindow(whichWindow,
LoWord(growResult), HiWord(growResult), true);
SetPort( GetWindowPort(whichWindow));
- InvalWindowRect(whichWindow,&portRect); /* TODO: may not be needed */
+ InvalWindowRect(whichWindow,&portRect); /* TODO: may not be needed */
TkMacOSXInvalClipRgns(winPtr);
TkGenWMConfigureEvent((Tk_Window) winPtr, -1, -1,
(int) LoWord(growResult), (int) HiWord(growResult),
@@ -4686,7 +4712,6 @@ TkMacOSXGetXWindow(
int
TkMacOSXZoomToplevel(
WindowRef whichWindow, /* The Macintosh window to zoom. */
- Point where, /* The current mouse position. */
short zoomPart) /* Either inZoomIn or inZoomOut */
{
Window window;
@@ -4698,9 +4723,6 @@ TkMacOSXZoomToplevel(
Rect portRect;
SetPort( GetWindowPort(whichWindow));
- if (!TrackBox(whichWindow, where, zoomPart)) {
- return false;
- }
/*
* We should now zoom the window (as long as it's one of ours). We
@@ -4760,10 +4782,9 @@ TkMacOSXZoomToplevel(
* TkUnsupported1Cmd --
*
* This procedure is invoked to process the
- * "::tk::unsupported::MacWindowStyle" Tcl command.
+ * "::tk::unsupported::MacWindowStyle" Tcl command.
* This command allows you to set the style of decoration
- * for a Macintosh window, and to manipulate Mac specific window
- * types.
+ * for a Macintosh window.
*
* Results:
* A standard Tcl result.
@@ -4774,7 +4795,7 @@ TkMacOSXZoomToplevel(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
+/* ARGSUSED */
int
TkUnsupported1ObjCmd(
ClientData clientData, /* Main window associated with
@@ -4787,49 +4808,42 @@ TkUnsupported1ObjCmd(
"style", NULL
};
enum SubCmds {
- STYLE
+ TKMWS_STYLE
};
Tk_Window tkwin = (Tk_Window) clientData;
TkWindow *winPtr;
int index;
if (objc < 3) {
- Tcl_WrongNumArgs(interp, 1, objv,
- "option window ?arg ...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?");
return TCL_ERROR;
}
- winPtr = (TkWindow *) Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), tkwin);
+ winPtr = (TkWindow *) Tk_NameToWindow(interp,
+ Tcl_GetString(objv[2]), tkwin);
if (winPtr == NULL) {
return TCL_ERROR;
}
if (!(winPtr->flags & TK_TOP_LEVEL)) {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't a top-level window", (char *) NULL);
+ "\" isn't a top-level window", (char *) NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option",
- 0, &index) != TCL_OK) {
+ 0, &index) != TCL_OK) {
return TCL_ERROR;
}
- switch ((enum SubCmds) index) {
- case STYLE:
+ if (((enum SubCmds) index) == TKMWS_STYLE) {
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?class attributes?");
return TCL_ERROR;
}
return TkMacOSXWinStyle(interp, winPtr, objc, objv);
- default:
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "unknown or ambiguous option \"",
- Tcl_GetString(objv[1]),
- "\": must be style",
- (char *) NULL);
- return TCL_ERROR;
}
+ /* won't be reached */
+ return TCL_ERROR;
}
/*
@@ -4838,7 +4852,7 @@ TkUnsupported1ObjCmd(
* TkMacOSXWinStyle --
*
* This procedure is invoked to process the
- * "::tk::unsupported::MacWindowStyle style" subcommand.
+ * "::tk::unsupported::MacWindowStyle style" subcommand.
* This command allows you to set the style of decoration
* for a Macintosh window.
*
@@ -4862,64 +4876,70 @@ TkMacOSXWinStyle(
int intValue;
};
static CONST struct StrIntMap styleMap[] = {
- { "documentProc", documentProc },
- { "noGrowDocProc", documentProc },
- { "dBoxProc", dBoxProc },
- { "plainDBox", plainDBox },
- { "altDBoxProc", altDBoxProc },
- { "movableDBoxProc", movableDBoxProc },
- { "zoomDocProc", zoomDocProc },
- { "zoomNoGrow", zoomNoGrow },
- { "floatProc", floatGrowProc },
- { "floatGrowProc", floatGrowProc },
- { "floatZoomProc", floatZoomGrowProc },
- { "floatZoomGrowProc", floatZoomGrowProc },
- { "floatSideProc", floatSideGrowProc },
- { "floatSideGrowProc", floatSideGrowProc },
- { "floatSideZoomProc", floatSideZoomGrowProc },
- { "floatSideZoomGrowProc", floatSideZoomGrowProc },
- { NULL, 0 }
+ { "documentProc", documentProc },
+ { "noGrowDocProc", documentProc },
+ { "dBoxProc", dBoxProc },
+ { "plainDBox", plainDBox },
+ { "altDBoxProc", altDBoxProc },
+ { "movableDBoxProc", movableDBoxProc },
+ { "zoomDocProc", zoomDocProc },
+ { "zoomNoGrow", zoomNoGrow },
+ { "floatProc", floatGrowProc },
+ { "floatGrowProc", floatGrowProc },
+ { "floatZoomProc", floatZoomGrowProc },
+ { "floatZoomGrowProc", floatZoomGrowProc },
+ { "floatSideProc", floatSideGrowProc },
+ { "floatSideGrowProc", floatSideGrowProc },
+ { "floatSideZoomProc", floatSideZoomGrowProc },
+ { "floatSideZoomGrowProc", floatSideZoomGrowProc },
+ { NULL, 0 }
};
static CONST struct StrIntMap classMap[] = {
- { "alert", kAlertWindowClass },
- { "moveableAlert", kMovableAlertWindowClass },
- { "modal", kModalWindowClass },
- { "moveableModal", kMovableModalWindowClass },
- { "floating", kFloatingWindowClass },
- { "document", kDocumentWindowClass },
- { "help", kHelpWindowClass },
- { "sheet", kSheetWindowClass },
- { "toolbar", kToolbarWindowClass },
- { "plain", kPlainWindowClass },
- { "overlay", kOverlayWindowClass },
- { "sheetAlert", kSheetAlertWindowClass },
- { "altPlain", kAltPlainWindowClass },
- { "drawer", kDrawerWindowClass },
- { NULL, 0 }
+ { "alert", kAlertWindowClass },
+ { "moveableAlert", kMovableAlertWindowClass },
+ { "modal", kModalWindowClass },
+ { "moveableModal", kMovableModalWindowClass },
+ { "floating", kFloatingWindowClass },
+ { "document", kDocumentWindowClass },
+ { "utility", kUtilityWindowClass },
+ { "help", kHelpWindowClass },
+ { "sheet", kSheetWindowClass },
+ { "toolbar", kToolbarWindowClass },
+ { "plain", kPlainWindowClass },
+ { "overlay", kOverlayWindowClass },
+ { "sheetAlert", kSheetAlertWindowClass },
+ { "altPlain", kAltPlainWindowClass },
+ { "drawer", kDrawerWindowClass },
+ { NULL, 0 }
};
static CONST struct StrIntMap compositeAttrMap[] = {
- { "none", kWindowNoAttributes },
- { "standardDocument", kWindowStandardDocumentAttributes },
- { "standardFloating", kWindowStandardFloatingAttributes },
- { NULL, 0 }
+ { "none", kWindowNoAttributes },
+ { "standardDocument", kWindowStandardDocumentAttributes },
+ { "standardFloating", kWindowStandardFloatingAttributes },
+ { NULL, 0 }
};
static CONST struct StrIntMap attrMap[] = {
- { "closeBox", kWindowCloseBoxAttribute },
- { "horizontalZoom", kWindowHorizontalZoomAttribute },
- { "verticalZoom", kWindowVerticalZoomAttribute },
- { "collapseBox", kWindowCollapseBoxAttribute },
- { "resizable", kWindowResizableAttribute },
- { "sideTitlebar", kWindowSideTitlebarAttribute },
- { "toolbarButton", kWindowToolbarButtonAttribute },
- { "metal", kWindowMetalAttribute },
- { "noActivates", kWindowNoActivatesAttribute },
- { "noUpdates", kWindowNoUpdatesAttribute },
- { "compositing", kWindowCompositingAttribute },
- { "noShadow", kWindowNoShadowAttribute },
- { "hideOnSuspend", kWindowHideOnSuspendAttribute },
- { "standardHandler", kWindowStandardHandlerAttribute },
- { "hideOnFullScreen", kWindowHideOnFullScreenAttribute},
- { NULL, 0 }
+ { "closeBox", kWindowCloseBoxAttribute },
+ { "fullZoom", kWindowHorizontalZoomAttribute | kWindowVerticalZoomAttribute },
+ { "horizontalZoom", kWindowHorizontalZoomAttribute },
+ { "verticalZoom", kWindowVerticalZoomAttribute },
+ { "collapseBox", kWindowCollapseBoxAttribute },
+ { "resizable", kWindowResizableAttribute },
+ { "sideTitlebar", kWindowSideTitlebarAttribute },
+ { "toolbarButton", kWindowToolbarButtonAttribute },
+ { "metal", kWindowMetalAttribute },
+ { "noActivates", kWindowNoActivatesAttribute },
+ { "noUpdates", kWindowNoUpdatesAttribute },
+ { "compositing", kWindowCompositingAttribute },
+ { "noShadow", kWindowNoShadowAttribute },
+ { "hideOnSuspend", kWindowHideOnSuspendAttribute },
+ { "standardHandler", kWindowStandardHandlerAttribute },
+ { "hideOnFullScreen", kWindowHideOnFullScreenAttribute },
+ { "inWindowMenu", kWindowInWindowMenuAttribute },
+ { "ignoreClicks", kWindowIgnoreClicksAttribute },
+ { "standardDocument", kWindowStandardDocumentAttributes },
+ { "standardFloating", kWindowStandardFloatingAttributes },
+ { NULL, 0 }
};
int index, i;
WmInfo *wmPtr = winPtr->wmInfoPtr;
@@ -4929,14 +4949,14 @@ TkMacOSXWinStyle(
for (i = 0; styleMap[i].strValue != NULL; i++) {
if (wmPtr->style == styleMap[i].intValue) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(styleMap[i].strValue, -1));
+ Tcl_NewStringObj(styleMap[i].strValue, -1));
return TCL_OK;
}
}
Tcl_Panic("invalid style");
} else {
Tcl_Obj *attributeList, *newResult = NULL;
- int usesComposite;
+ int usesComposite;
for (i = 0; classMap[i].strValue != NULL; i++) {
if (wmPtr->macClass == classMap[i].intValue) {
@@ -4949,30 +4969,30 @@ TkMacOSXWinStyle(
}
attributeList = Tcl_NewListObj(0, NULL);
- usesComposite = 0;
-
+ usesComposite = 0;
+
for (i = 0; compositeAttrMap[i].strValue != NULL; i++) {
if (wmPtr->attributes == compositeAttrMap[i].intValue) {
Tcl_ListObjAppendElement(interp, attributeList,
- Tcl_NewStringObj(compositeAttrMap[i].strValue, -1));
- usesComposite = 1;
- break;
+ Tcl_NewStringObj(compositeAttrMap[i].strValue, -1));
+ usesComposite = 1;
+ break;
}
}
- if (!usesComposite) {
- for (i = 0; attrMap[i].strValue != NULL; i++) {
+ if (!usesComposite) {
+ for (i = 0; attrMap[i].strValue != NULL; i++) {
if (wmPtr->attributes & attrMap[i].intValue) {
- Tcl_ListObjAppendElement(interp, attributeList,
- Tcl_NewStringObj(attrMap[i].strValue, -1));
+ Tcl_ListObjAppendElement(interp, attributeList,
+ Tcl_NewStringObj(attrMap[i].strValue, -1));
}
- }
- }
+ }
+ }
Tcl_ListObjAppendElement(interp, newResult, attributeList);
- Tcl_SetObjResult(interp, newResult);
+ Tcl_SetObjResult(interp, newResult);
}
} else if (objc == 4) {
if (Tcl_GetIndexFromObjStruct(interp, objv[3], styleMap,
- sizeof(struct StrIntMap), "style", 0, &index) != TCL_OK) {
+ sizeof(struct StrIntMap), "style", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
wmPtr->style = styleMap[index].intValue;
@@ -4983,28 +5003,26 @@ TkMacOSXWinStyle(
int oldAttributes = wmPtr->attributes;
if (Tcl_GetIndexFromObjStruct(interp, objv[3], classMap,
- sizeof(struct StrIntMap), "class", 0, &index) != TCL_OK) {
+ sizeof(struct StrIntMap), "class", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
- wmPtr->macClass = classMap[index].intValue;
- if (Tcl_ListObjGetElements(interp, objv[4], &attrObjc, &attrObjv) !=
- TCL_OK) {
- wmPtr->macClass = oldClass;
+ if (Tcl_ListObjGetElements(interp, objv[4], &attrObjc, &attrObjv)
+ != TCL_OK) {
return TCL_ERROR;
}
+ wmPtr->macClass = classMap[index].intValue;
wmPtr->attributes = kWindowNoAttributes;
for (i = 0; i < attrObjc; i++) {
- if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], compositeAttrMap,
- sizeof(struct StrIntMap), "attribute", 0, &index)
- == TCL_OK) {
- wmPtr->attributes |= compositeAttrMap[index].intValue;
- } else if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i],
- attrMap,
- sizeof(struct StrIntMap), "attribute", 0, &index)
- == TCL_OK) {
- Tcl_ResetResult (interp);
- wmPtr->attributes |= attrMap[index].intValue;
- } else {
+ if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i],
+ compositeAttrMap, sizeof(struct StrIntMap),
+ "attribute", 0, &index) == TCL_OK) {
+ wmPtr->attributes |= compositeAttrMap[index].intValue;
+ } else if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i],
+ attrMap, sizeof(struct StrIntMap),
+ "attribute", 0, &index) == TCL_OK) {
+ Tcl_ResetResult (interp);
+ wmPtr->attributes |= attrMap[index].intValue;
+ } else {
wmPtr->macClass = oldClass;
wmPtr->attributes = oldAttributes;
return TCL_ERROR;
@@ -5012,7 +5030,7 @@ TkMacOSXWinStyle(
}
wmPtr->style = -1;
}
-
+
return TCL_OK;
}
@@ -5056,7 +5074,7 @@ TkpMakeMenuWindow(
* TkMacOSXMakeRealWindowExist --
*
* This function finally creates the real Macintosh window that
- * the Mac actually understands.
+ * the Mac actually understands.
*
* Results:
* None.
@@ -5066,8 +5084,8 @@ TkpMakeMenuWindow(
*
*----------------------------------------------------------------------
*/
-
-void
+
+void
TkMacOSXMakeRealWindowExist(
TkWindow *winPtr) /* Tk window. */
{
@@ -5081,16 +5099,16 @@ TkMacOSXMakeRealWindowExist(
TkMacOSXWindowList *listPtr;
if (TkMacOSXHostToplevelExists(winPtr)) {
- return;
+ return;
}
-
+
macWin = (MacDrawable *) winPtr->window;
/*
* If this is embedded, make sure its container's toplevel exists,
* then return...
*/
-
+
if (Tk_IsEmbedded(winPtr)) {
TkWindow *contWinPtr;
@@ -5113,55 +5131,66 @@ TkMacOSXMakeRealWindowExist(
/*
* NOTE: Here we should handle out of process embedding.
*/
-
+
}
-
+
InitialWindowBounds(winPtr, &geometry);
-
+
if (wmPtr->style == -1) {
- OSStatus err;
- /*
- * There seems to be a bug in CreateNewWindow: If I set the
- * window geometry to be the too small for the structure region,
- * then the whole window is positioned incorrectly.
- * Adding this here makes the positioning work, and the size will
- * get overwritten when you actually map the contents of the window.
- */
-
- geometry.right += 64;
- geometry.bottom += 24;
- err = CreateNewWindow(wmPtr->macClass, wmPtr->attributes,
- &geometry, &newWindow);
- if (err != noErr) {
- newWindow = NULL;
- }
-
+ OSStatus err;
+ /*
+ * There seems to be a bug in CreateNewWindow: If I set the
+ * window geometry to be the too small for the structure region,
+ * then the whole window is positioned incorrectly.
+ * Adding this here makes the positioning work, and the size will
+ * get overwritten when you actually map the contents of the window.
+ */
+
+ geometry.right += 64;
+ geometry.bottom += 24;
+ err = CreateNewWindow(wmPtr->macClass, wmPtr->attributes,
+ &geometry, &newWindow);
+ if (err != noErr) {
+ newWindow = NULL;
+ }
+
} else {
- newWindow = NewCWindow(NULL, &geometry, "\ptemp", false,
- (short) wmPtr->style, (WindowRef) -1, true, 0);
+ newWindow = NewCWindow(NULL, &geometry, "\ptemp", false,
+ (short) wmPtr->style, (WindowRef) -1, true, 0);
}
-
+
if (newWindow == NULL) {
Tcl_Panic("couldn't allocate new Mac window");
}
if (CreateRootControl(newWindow,&rootControl) != noErr ) {
Tcl_Panic("couldn't create root control for new Mac window");
}
-
+
/*
* Add this window to the list of toplevel windows.
*/
-
+
listPtr = (TkMacOSXWindowList *) ckalloc(sizeof(TkMacOSXWindowList));
listPtr->nextPtr = tkMacOSXWindowListPtr;
listPtr->winPtr = winPtr;
tkMacOSXWindowListPtr = listPtr;
-
- macWin->grafPtr = GetWindowPort ( newWindow );
+
+ macWin->grafPtr = GetWindowPort(newWindow);
macWin->rootControl = rootControl;
MoveWindowStructure(newWindow, geometry.left, geometry.top);
SetPort(GetWindowPort(newWindow));
-
+
+ if ((wmPtr->master != None) && winPtr->atts.override_redirect) {
+ /*
+ * If we are transient and overrideredirect, use the utility class
+ * to ensure we are topmost (for dropdowns).
+ */
+ WindowGroupRef group = GetWindowGroupOfClass(kUtilityWindowClass);
+ if (group != NULL) {
+ SetWindowGroup(newWindow, group);
+ }
+ }
+
if (!windowHashInit) {
Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS);
windowHashInit = true;
@@ -5172,7 +5201,7 @@ TkMacOSXMakeRealWindowExist(
Tcl_Panic("same macintosh window allocated twice!");
}
Tcl_SetHashValue(valueHashPtr, macWin);
-
+
macWin->flags |= TK_HOST_EXISTS;
}
@@ -5240,7 +5269,7 @@ void
TkMacOSXUnregisterMacWindow(
WindowRef macWinPtr) /* Reference to a Mac Window */
{
- Tcl_HashEntry *entryPtr;
+ Tcl_HashEntry *entryPtr;
if (!windowHashInit) {
Tcl_Panic("TkMacOSXUnregisterMacWindow: unmapping before inited");
}
@@ -5386,23 +5415,19 @@ TkpWmSetState(winPtr, state)
if (state == WithdrawnState) {
Tk_UnmapWindow((Tk_Window) winPtr);
} else if (state == IconicState) {
+ /*
+ * The window always gets unmapped. If we can show the
+ * icon version of the window we also collapse it.
+ */
+ if (IsWindowCollapsable(macWin) && !IsWindowCollapsed(macWin)) {
+ CollapseWindow(macWin, true);
+ }
Tk_UnmapWindow((Tk_Window) winPtr);
- /*
- * The window always gets unmapped. However, if we can show the
- * icon version of the window (collapsed) we make the window visable
- * and then collapse it.
- *
- * TODO: This approach causes flashing!
- */
-
- if (IsWindowCollapsable(macWin)) {
- ShowWindow(macWin);
- CollapseWindow( macWin, true);
- }
-
} else if (state == NormalState) {
Tk_MapWindow((Tk_Window) winPtr);
- CollapseWindow((WindowPtr) macWin, false);
+ if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) {
+ CollapseWindow((WindowPtr) macWin, false);
+ }
} else if (state == ZoomState) {
/* TODO: need to support zoomed windows */
}
@@ -5440,6 +5465,40 @@ TkpIsWindowFloating(WindowRef wRef)
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXWindowClass --
+ *
+ * Returns OS X window class of window
+ *
+ * Results:
+ * 1 or 0 depending on window's floating attribute.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE WindowClass
+TkMacOSXWindowClass(TkWindow *winPtr)
+{
+ WindowRef wRef;
+ WindowClass class;
+
+ if (winPtr == NULL) {
+ return 0;
+ }
+ wRef = GetWindowFromPort(TkMacOSXGetDrawablePort(winPtr->window));
+ if (wRef == NULL) {
+ return 0;
+ }
+
+ GetWindowClass(wRef, &class);
+ return class;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkMacOSXWindowOffset --
*
* Determines the x and y offset from the orgin of the toplevel
diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h
index fb17959..3284c6d 100644
--- a/macosx/tkMacOSXWm.h
+++ b/macosx/tkMacOSXWm.h
@@ -49,6 +49,8 @@
* acting in its behalf permission to use and distribute the
* software in accordance with the terms specified in this
* license.
+ *
+ * RCS: @(#) $Id: tkMacOSXWm.h,v 1.4 2005/08/09 07:39:22 das Exp $
*/
#ifndef _TKMACWM