summaryrefslogtreecommitdiffstats
path: root/mac
diff options
context:
space:
mode:
Diffstat (limited to 'mac')
-rw-r--r--mac/tkMac.h37
-rw-r--r--mac/tkMacCursor.c34
-rw-r--r--mac/tkMacEmbed.c180
-rw-r--r--mac/tkMacInt.h18
-rw-r--r--mac/tkMacMenu.c37
-rw-r--r--mac/tkMacSubwindows.c114
-rw-r--r--mac/tkMacWindowMgr.c61
-rw-r--r--mac/tkMacWm.c34
-rw-r--r--mac/tkMacXStubs.c2
9 files changed, 393 insertions, 124 deletions
diff --git a/mac/tkMac.h b/mac/tkMac.h
index ce41c81..e124903 100644
--- a/mac/tkMac.h
+++ b/mac/tkMac.h
@@ -15,6 +15,8 @@
#define _TKMAC
#include <Windows.h>
+#include <QDOffscreen.h>
+#include "tkInt.h"
/*
* "export" is a MetroWerks specific pragma. It flags the linker that
@@ -32,21 +34,46 @@
EXTERN QDGlobalsPtr tcl_macQdPtr;
+/*
+ * Structures and function types for handling Netscape-type in process
+ * embedding where Tk does not control the top-level
+ */
+typedef int (Tk_MacEmbedRegisterWinProc) (int winID, Tk_Window window);
+typedef GWorldPtr (Tk_MacEmbedGetGrafPortProc) (Tk_Window window);
+typedef int (Tk_MacEmbedMakeContainerExistProc) (Tk_Window window);
+typedef void (Tk_MacEmbedGetClipProc) (Tk_Window window, RgnHandle rgn);
+typedef void (Tk_MacEmbedGetOffsetInParentProc) (Tk_Window window, Point *ulCorner);
+
/*
- * The following functions are needed to create a shell, and so they must be exported
- * from the Tk library. However, these are not the final form of these interfaces, so
- * they are not currently supported as public interfaces.
+ * Mac Specific functions that are available to extension writers.
*/
+
+EXTERN void Tk_MacSetEmbedHandler _ANSI_ARGS_((
+ Tk_MacEmbedRegisterWinProc *registerWinProcPtr,
+ Tk_MacEmbedGetGrafPortProc *getPortProcPtr,
+ Tk_MacEmbedMakeContainerExistProc *containerExistProcPtr,
+ Tk_MacEmbedGetClipProc *getClipProc,
+ Tk_MacEmbedGetOffsetInParentProc *getOffsetProc));
+
+EXTERN void Tk_MacTurnOffMenus _ANSI_ARGS_ (());
+EXTERN void Tk_MacTkOwnsCursor _ANSI_ARGS_ ((int tkOwnsIt));
+
/*
* These functions are currently in tkMacInt.h. They are just copied over here
* so they can be exported.
*/
EXTERN void TkMacInitMenus _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN void TkMacInitAppleEvents _ANSI_ARGS_((Tcl_Interp *interp));
+EXTERN void TkMacInitAppleEvents _ANSI_ARGS_((Tcl_Interp *interp));
+
+EXTERN int TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr));
+EXTERN int TkMacConvertTkEvent _ANSI_ARGS_((EventRecord *eventPtr,
+ Window window));
+EXTERN void TkGenWMConfigureEvent _ANSI_ARGS_((Tk_Window tkwin,
+ int x, int y, int width, int height, int flags));
+EXTERN void TkMacInvalClipRgns _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkMacConvertEvent _ANSI_ARGS_((EventRecord *eventPtr));
#pragma export reset
diff --git a/mac/tkMacCursor.c b/mac/tkMacCursor.c
index f221189..805dac3 100644
--- a/mac/tkMacCursor.c
+++ b/mac/tkMacCursor.c
@@ -64,9 +64,16 @@ static struct CursorName {
static TkMacCursor * gCurrentCursor = NULL; /* A pointer to the current
* cursor. */
-static int gResizeOverride = false; /* A boolean indicating wether
+static int gResizeOverride = false; /* A boolean indicating whether
* we should use the resize
* cursor during installations. */
+static int gTkOwnsCursor = true; /* A boolean indicating whether
+ Tk owns the cursor. If not (for
+ instance, in the case where a Tk
+ window is embedded in another app's
+ window, and the cursor is out of
+ the tk window, we will not attempt
+ to adjust the cursor */
/*
* Declarations of procedures local to this file
@@ -348,6 +355,9 @@ void
TkpSetCursor(
TkpCursor cursor)
{
+ if (!gTkOwnsCursor) {
+ return;
+ }
if (cursor == None) {
gCurrentCursor = NULL;
} else {
@@ -358,3 +368,25 @@ TkpSetCursor(
TkMacInstallCursor(gResizeOverride);
}
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tk_MacTkOwnsCursor --
+ *
+ * Sets whether Tk has the right to adjust the cursor.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * May keep Tk from changing the cursor.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void Tk_MacTkOwnsCursor(
+ int tkOwnsIt)
+{
+ gTkOwnsCursor = tkOwnsIt;
+}
diff --git a/mac/tkMacEmbed.c b/mac/tkMacEmbed.c
index 7a73b54..91f06d6 100644
--- a/mac/tkMacEmbed.c
+++ b/mac/tkMacEmbed.c
@@ -53,6 +53,11 @@ typedef struct Container {
static Container *firstContainerPtr = NULL;
/* First in list of all containers
* managed by this process. */
+/*
+ * Globals defined in this file
+ */
+
+TkMacEmbedHandler *gMacEmbedHandler = NULL;
/*
* Prototypes for static procedures defined in this file:
@@ -74,9 +79,41 @@ static void EmbedStructureProc _ANSI_ARGS_((ClientData clientData,
XEvent *eventPtr));
static void EmbedWindowDeleted _ANSI_ARGS_((TkWindow *winPtr));
-/* WARNING - HACK */
-static void GenerateFocusEvents _ANSI_ARGS_((TkWindow *sourcePtr,
- TkWindow *destPtr));
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tk_MacSetEmbedHandler --
+ *
+ * Registers a handler for an in process form of embedding, like
+ * Netscape plugins, where Tk is loaded into the process, but does
+ * not control the main window
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * The embed handler is set.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+Tk_MacSetEmbedHandler(
+ Tk_MacEmbedRegisterWinProc *registerWinProc,
+ Tk_MacEmbedGetGrafPortProc *getPortProc,
+ Tk_MacEmbedMakeContainerExistProc *containerExistProc,
+ Tk_MacEmbedGetClipProc *getClipProc,
+ Tk_MacEmbedGetOffsetInParentProc *getOffsetProc)
+{
+ if (gMacEmbedHandler == NULL) {
+ gMacEmbedHandler = (TkMacEmbedHandler *) ckalloc(sizeof(TkMacEmbedHandler));
+ }
+ gMacEmbedHandler->registerWinProc = registerWinProc;
+ gMacEmbedHandler->getPortProc = getPortProc;
+ gMacEmbedHandler->containerExistProc = containerExistProc;
+ gMacEmbedHandler->getClipProc = getClipProc;
+ gMacEmbedHandler->getOffsetProc = getOffsetProc;
+}
/*
@@ -240,18 +277,6 @@ TkpUseWindow(
}
}
- /*
- * We should not get to this code until we start to allow
- * embedding in other applications.
- */
-
- if (containerPtr == NULL) {
- Tcl_AppendResult(interp, "The window ID ", string,
- " does not correspond to a valid Tk Window.",
- (char *) NULL);
- return TCL_ERROR;
- }
-
/*
* Make the embedded window.
*/
@@ -264,13 +289,27 @@ TkpUseWindow(
macWin->winPtr = winPtr;
winPtr->privatePtr = macWin;
+
+ /*
+ * The portPtr will be NULL for a Tk in Tk embedded window.
+ * It is none of our business what it is for a Tk not in Tk embedded window,
+ * but we will initialize it to NULL, and let the registerWinProc
+ * set it. In any case, you must always use TkMacGetDrawablePort
+ * to get the portPtr. It will correctly find the container's port.
+ */
+
+ macWin->portPtr = (GWorldPtr) NULL;
+
macWin->clipRgn = NewRgn();
macWin->aboveClipRgn = NewRgn();
macWin->referenceCount = 0;
macWin->flags = TK_CLIP_INVALID;
-
+ macWin->toplevel = macWin;
+ macWin->toplevel->referenceCount++;
+
winPtr->flags |= TK_EMBEDDED;
+
/*
* Make a copy of the TK_EMBEDDED flag, since sometimes
* we need this to get the port after the TkWindow structure
@@ -279,33 +318,67 @@ TkpUseWindow(
macWin->flags |= TK_EMBEDDED;
- /*
- * The portPtr will be NULL for an embedded window.
- * Always use TkMacGetDrawablePort to get the portPtr.
- * It will correctly find the container's port.
+ /*
+ * Now check whether it is embedded in another Tk widget. If not (the first
+ * case below) we see if there is an in-process embedding handler registered,
+ * and if so, let that fill in the rest of the macWin.
*/
-
- macWin->portPtr = (GWorldPtr) NULL;
-
- macWin->toplevel = macWin;
- macWin->xOff = parent->winPtr->privatePtr->xOff +
- parent->winPtr->changes.border_width +
- winPtr->changes.x;
- macWin->yOff = parent->winPtr->privatePtr->yOff +
- parent->winPtr->changes.border_width +
- winPtr->changes.y;
- macWin->toplevel->referenceCount++;
+ if (containerPtr == NULL) {
+ /*
+ * If someone has registered an in process embedding handler, then
+ * see if it can handle this window...
+ */
+
+ if (gMacEmbedHandler == NULL ||
+ gMacEmbedHandler->registerWinProc(result, (Tk_Window) winPtr) != TCL_OK) {
+ Tcl_AppendResult(interp, "The window ID ", string,
+ " does not correspond to a valid Tk Window.",
+ (char *) NULL);
+ return TCL_ERROR;
+ } else {
+ containerPtr = (Container *) ckalloc(sizeof(Container));
+
+ containerPtr->parentPtr = NULL;
+ containerPtr->embedded = (Window) macWin;
+ containerPtr->embeddedPtr = macWin->winPtr;
+ containerPtr->nextPtr = firstContainerPtr;
+ firstContainerPtr = containerPtr;
+
+ }
+ } else {
+
+ /*
+ * The window is embedded in another Tk window.
+ */
+
+ macWin->xOff = parent->winPtr->privatePtr->xOff +
+ parent->winPtr->changes.border_width +
+ winPtr->changes.x;
+ macWin->yOff = parent->winPtr->privatePtr->yOff +
+ parent->winPtr->changes.border_width +
+ winPtr->changes.y;
- /*
- * Finish filling up the container structure with the embedded window's
- * information.
- */
+
+ /*
+ * Finish filling up the container structure with the embedded window's
+ * information.
+ */
- containerPtr->embedded = (Window) macWin;
- containerPtr->embeddedPtr = macWin->winPtr;
+ containerPtr->embedded = (Window) macWin;
+ containerPtr->embeddedPtr = macWin->winPtr;
- /*
+ /*
+ * Create an event handler to clean up the Container structure when
+ * tkwin is eventually deleted.
+ */
+
+ Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
+ (ClientData) winPtr);
+
+ }
+
+ /*
* TODO: need general solution for visibility events.
*/
@@ -318,15 +391,19 @@ TkpUseWindow(
event.xvisibility.state = VisibilityUnobscured;
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- /*
- * Create an event handler to clean up the Container structure when
- * tkwin is eventually deleted.
+
+ /*
+ * TODO: need general solution for visibility events.
*/
-
- Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
- (ClientData) winPtr);
-
+ event.xany.serial = Tk_Display(winPtr)->request;
+ event.xany.send_event = False;
+ event.xany.display = Tk_Display(winPtr);
+
+ event.xvisibility.type = VisibilityNotify;
+ event.xvisibility.window = (Window) macWin;;
+ event.xvisibility.state = VisibilityUnobscured;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
return TCL_OK;
}
@@ -884,11 +961,10 @@ EmbedActivateProc(clientData, eventPtr)
Container *containerPtr = (Container *) clientData;
if (containerPtr->embeddedPtr != NULL) {
-
- if (eventPtr->type == ActivateNotify) {
- TkGenerateActivateEvents(containerPtr->embeddedPtr, 1);
+ if (eventPtr->type == ActivateNotify) {
+ TkGenerateActivateEvents(containerPtr->embeddedPtr,1);
} else if (eventPtr->type == DeactivateNotify) {
- TkGenerateActivateEvents(containerPtr->embeddedPtr, 0);
+ TkGenerateActivateEvents(containerPtr->embeddedPtr,0);
}
}
}
@@ -923,14 +999,14 @@ EmbedFocusProc(clientData, eventPtr)
XEvent event;
if (containerPtr->embeddedPtr != NULL) {
- display = Tk_Display(containerPtr->parentPtr);
+ display = Tk_Display(containerPtr->parentPtr);
event.xfocus.serial = LastKnownRequestProcessed(display);
event.xfocus.send_event = false;
event.xfocus.display = display;
event.xfocus.mode = NotifyNormal;
event.xfocus.window = containerPtr->embedded;
- if (eventPtr->type == FocusIn) {
+ if (eventPtr->type == FocusIn) {
/*
* The focus just arrived at the container. Change the X focus
* to move it to the embedded application, if there is one.
@@ -951,7 +1027,7 @@ EmbedFocusProc(clientData, eventPtr)
}
Tk_QueueWindowEvent(&event, TCL_QUEUE_MARK);
- }
+ }
}
/*
diff --git a/mac/tkMacInt.h b/mac/tkMacInt.h
index fcb8174..d4a34f0 100644
--- a/mac/tkMacInt.h
+++ b/mac/tkMacInt.h
@@ -73,6 +73,24 @@ typedef struct TkMacWindowList {
*/
/*
+ * This structure is for handling Netscape-type in process
+ * embedding where Tk does not control the top-level. It contains
+ * various functions that are needed by Mac specific routines, like
+ * TkMacGetDrawablePort. The definitions of the function types
+ * are in tclMac.h.
+ */
+
+typedef struct {
+ Tk_MacEmbedRegisterWinProc *registerWinProc;
+ Tk_MacEmbedGetGrafPortProc *getPortProc;
+ Tk_MacEmbedMakeContainerExistProc *containerExistProc;
+ Tk_MacEmbedGetClipProc *getClipProc;
+ Tk_MacEmbedGetOffsetInParentProc *getOffsetProc;
+} TkMacEmbedHandler;
+
+extern TkMacEmbedHandler *gMacEmbedHandler;
+
+/*
* Defines used for TkMacInvalidateWindow
*/
diff --git a/mac/tkMacMenu.c b/mac/tkMacMenu.c
index 33bb82b..3d58597 100644
--- a/mac/tkMacMenu.c
+++ b/mac/tkMacMenu.c
@@ -139,6 +139,8 @@ typedef struct TopLevelMenubarList {
#define MENUBAR_REDRAW_PENDING 1
+static int gNoTkMenus = 0; /* This is used by Tk_MacTurnOffMenus as the
+ * flag that Tk is not to draw any menus. */
RgnHandle tkMenuCascadeRgn = NULL;
/* The region to clip drawing to when the
* MDEF is up. */
@@ -1396,6 +1398,31 @@ TkpMenuNewEntry(
*----------------------------------------------------------------------
*
*
+ * Tk_MacTurnOffMenus --
+ *
+ * Turns off all the menu drawing code. This is more than just disabling
+ * the "menu" command, this means that Tk will NEVER touch the menubar.
+ * It is needed in the Plugin, where Tk does not own the menubar.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * A flag is set which will disable all menu drawing.
+ *
+ *----------------------------------------------------------------------
+ */
+
+EXTERN void
+Tk_MacTurnOffMenus()
+{
+ gNoTkMenus = 1;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ *
* DrawMenuBarWhenIdle --
*
* Update the menu bar next time there is an idle event.
@@ -1419,6 +1446,14 @@ DrawMenuBarWhenIdle(
Tcl_HashEntry *hashEntryPtr;
/*
+ * If we have been turned off, exit.
+ */
+
+ if (gNoTkMenus) {
+ return;
+ }
+
+ /*
* We need to clear the apple and help menus of any extra items.
*/
@@ -3991,4 +4026,6 @@ TkpMenuInit(void)
currentMenuBarInterp = NULL;
currentMenuBarName = NULL;
windowListPtr = NULL;
+ FixMDEF();
+
}
diff --git a/mac/tkMacSubwindows.c b/mac/tkMacSubwindows.c
index 65c1a7e..63c5e09 100644
--- a/mac/tkMacSubwindows.c
+++ b/mac/tkMacSubwindows.c
@@ -288,67 +288,76 @@ XResizeWindow(
display->request++;
SetPort((GrafPtr) destPort);
- if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
- /*
- * NOTE: we are not adding the new space to the update
- * region. It is currently assumed that Tk will need
- * to completely redraw anway.
- */
- SizeWindow((WindowRef) destPort,
- (short) width, (short) height, false);
- TkMacInvalidateWindow(macWin, TK_WINDOW_ONLY);
- TkMacInvalClipRgns(macWin->winPtr);
- } else {
- /* TODO: update all xOff & yOffs */
- int deltaX, deltaY, parentBorderwidth;
- MacDrawable *macParent = macWin->winPtr->parentPtr->privatePtr;
-
- /*
- * Find the Parent window -
- * For an embedded window this will be its container.
- */
-
- if (Tk_IsEmbedded(macWin->winPtr)) {
+ if (Tk_IsTopLevel(macWin->winPtr)) {
+ if (!Tk_IsEmbedded(macWin->winPtr)) {
+ /*
+ * NOTE: we are not adding the new space to the update
+ * region. It is currently assumed that Tk will need
+ * to completely redraw anway.
+ */
+ SizeWindow((WindowRef) destPort,
+ (short) width, (short) height, false);
+ TkMacInvalidateWindow(macWin, TK_WINDOW_ONLY);
+ TkMacInvalClipRgns(macWin->winPtr);
+ } else {
+ int deltaX, deltaY;
+
+ /*
+ * Find the Parent window -
+ * For an embedded window this will be its container.
+ */
TkWindow *contWinPtr;
contWinPtr = TkpGetOtherWindow(macWin->winPtr);
- if (contWinPtr == NULL) {
- panic("XMoveResizeWindow could not find container");
- }
- macParent = contWinPtr->privatePtr;
- /*
- * NOTE: Here we should handle out of process embedding.
- */
-
- } else {
- macParent = macWin->winPtr->parentPtr->privatePtr;
- if (macParent == NULL) {
- return; /* TODO: Probably should be a panic */
+ if (contWinPtr != NULL) {
+ MacDrawable *macParent = contWinPtr->privatePtr;
+
+ TkMacInvalClipRgns(macParent->winPtr);
+ TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);
+
+ deltaX = macParent->xOff +
+ macWin->winPtr->changes.x - macWin->xOff;
+ deltaY = macParent->yOff +
+ macWin->winPtr->changes.y - macWin->yOff;
+
+ UpdateOffsets(macWin->winPtr, deltaX, deltaY);
+ } else {
+ /*
+ * This is the case where we are embedded in
+ * another app. At this point, we are assuming that
+ * the changes.x,y is not maintained, if you need
+ * the info get it from Tk_GetRootCoords,
+ * and that the toplevel sits at 0,0 when it is drawn.
+ */
+
+ TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);
+ UpdateOffsets(macWin->winPtr, 0, 0);
}
+
+ }
+ } else {
+ /* TODO: update all xOff & yOffs */
+ int deltaX, deltaY, parentBorderwidth;
+ MacDrawable *macParent = macWin->winPtr->parentPtr->privatePtr;
+
+ if (macParent == NULL) {
+ return; /* TODO: Probably should be a panic */
}
- TkMacInvalClipRgns(macParent->winPtr);
+ TkMacInvalClipRgns(macParent->winPtr);
TkMacInvalidateWindow(macWin, TK_PARENT_WINDOW);
deltaX = - macWin->xOff;
deltaY = - macWin->yOff;
- /*
- * If macWin->winPtr is an embedded window, don't offset by its
- * parent's borderwidth...
- */
-
- if (!Tk_IsEmbedded(macWin->winPtr)) {
- parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width;
- } else {
- parentBorderwidth = 0;
- }
+ parentBorderwidth = macWin->winPtr->parentPtr->changes.border_width;
+
deltaX += macParent->xOff + parentBorderwidth +
macWin->winPtr->changes.x;
deltaY += macParent->yOff + parentBorderwidth +
macWin->winPtr->changes.y;
-
+
UpdateOffsets(macWin->winPtr, deltaX, deltaY);
}
}
@@ -744,6 +753,9 @@ TkMacUpdateClipRgn(
TkMacUpdateClipRgn(contWinPtr);
SectRgn(rgn,
contWinPtr->privatePtr->aboveClipRgn, rgn);
+ } else if (gMacEmbedHandler != NULL) {
+ gMacEmbedHandler->getClipProc((Tk_Window) winPtr, tmpRgn);
+ SectRgn(rgn, tmpRgn, rgn);
}
/*
@@ -883,6 +895,7 @@ TkMacGetDrawablePort(
Drawable drawable)
{
MacDrawable *macWin = (MacDrawable *) drawable;
+ GWorldPtr resultPort = NULL;
if (macWin == NULL) {
return NULL;
@@ -917,8 +930,13 @@ TkMacGetDrawablePort(
contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr);
if (contWinPtr != NULL) {
- return TkMacGetDrawablePort((Drawable) contWinPtr->privatePtr);
- } else {
+ resultPort = TkMacGetDrawablePort((Drawable) contWinPtr->privatePtr);
+ } else if (gMacEmbedHandler != NULL) {
+ resultPort = gMacEmbedHandler->getPortProc(
+ (Tk_Window) macWin->winPtr);
+ }
+
+ if (resultPort == NULL) {
panic("TkMacGetDrawablePort couldn't find container");
return NULL;
}
@@ -928,7 +946,7 @@ TkMacGetDrawablePort(
*/
}
-
+ return resultPort;
}
/*
diff --git a/mac/tkMacWindowMgr.c b/mac/tkMacWindowMgr.c
index 7c8206c..6ffaa2e 100644
--- a/mac/tkMacWindowMgr.c
+++ b/mac/tkMacWindowMgr.c
@@ -69,7 +69,8 @@ static int GenerateUpdateEvent _ANSI_ARGS_((EventRecord *eventPtr,
static void GenerateUpdates _ANSI_ARGS_((RgnHandle updateRgn,
TkWindow *winPtr));
static int GeneratePollingEvents _ANSI_ARGS_((void));
-static int GeneratePollingEvents2 _ANSI_ARGS_((Window window));
+static int GeneratePollingEvents2 _ANSI_ARGS_((Window window,
+ int adjustCursor));
static OSErr TellWindowDefProcToCalcRegions _ANSI_ARGS_((WindowRef wRef));
static int WindowManagerMouse _ANSI_ARGS_((EventRecord *theEvent,
Window window));
@@ -810,7 +811,7 @@ GeneratePollingEvents()
}
Tk_UpdatePointer(tkwin, whereGlobal.h, whereGlobal.v,
TkMacButtonKeyState());
-
+
/*
* Finally, we make sure the proper cursor is installed. The installation
* is polled to 1) make our resize hack work, and 2) make sure we have the
@@ -849,7 +850,8 @@ GeneratePollingEvents()
static int
GeneratePollingEvents2(
- Window window)
+ Window window,
+ int adjustCursor)
{
Tk_Window tkwin, rootwin;
WindowRef whichwindow, frontWin;
@@ -889,6 +891,7 @@ GeneratePollingEvents2(
}
}
+
/*
* The following call will generate the appropiate X events and
* adjust any state that Tk must remember.
@@ -899,15 +902,17 @@ GeneratePollingEvents2(
}
Tk_UpdatePointer(tkwin, whereGlobal.h, whereGlobal.v,
TkMacButtonKeyState());
-
+
/*
* Finally, we make sure the proper cursor is installed. The installation
* is polled to 1) make our resize hack work, and 2) make sure we have the
* proper cursor even if someone else changed the cursor out from under
* us.
*/
- TkMacInstallCursor(0);
-
+
+ if (adjustCursor) {
+ TkMacInstallCursor(0);
+ }
return true;
}
@@ -1214,7 +1219,7 @@ TkMacConvertEvent(
* TkMacConvertTkEvent --
*
* This function converts a Macintosh event into zero or more
- * Tcl events.
+ * Tcl events. It is intended for use in Netscape-style embedding.
*
* Results:
* Returns 1 if event added to Tcl queue, 0 otherwse.
@@ -1233,14 +1238,34 @@ TkMacConvertTkEvent(
int eventFound = false;
Point where;
+ /*
+ * By default, assume it is legal for us to set the cursor
+ */
+
+ Tk_MacTkOwnsCursor(1);
+
switch (eventPtr->what) {
case nullEvent:
+ /*
+ * We get NULL events only when the cursor is NOT over
+ * the plugin. Otherwise we get updateCursor events.
+ * We will not generate polling events or move the cursor
+ * in this case.
+ */
+
+ eventFound = false;
+ break;
case adjustCursorEvent:
- if (GeneratePollingEvents2(window)) {
+ if (GeneratePollingEvents2(window, 1)) {
eventFound = true;
}
break;
case updateEvt:
+ /*
+ * It is possibly not legal for us to set the cursor
+ */
+
+ Tk_MacTkOwnsCursor(0);
if (GenerateUpdateEvent(eventPtr, window)) {
eventFound = true;
}
@@ -1271,6 +1296,13 @@ TkMacConvertTkEvent(
eventFound |= GenerateKeyEvent(eventPtr, window);
break;
case activateEvt:
+ /*
+ * It is probably not legal for us to set the cursor
+ * here, since we don't know where the mouse is in the
+ * window that is being activated.
+ */
+
+ Tk_MacTkOwnsCursor(0);
eventFound |= GenerateActivateEvents(eventPtr, window);
eventFound |= GenerateFocusEvent(eventPtr, window);
break;
@@ -1291,10 +1323,18 @@ TkMacConvertTkEvent(
* Do clipboard conversion.
*/
switch ((eventPtr->message & osEvtMessageMask) >> 24) {
+ /*
+ * It is possibly not legal for us to set the cursor.
+ * Netscape sends us these events all the time...
+ */
+
+ Tk_MacTkOwnsCursor(0);
+
case mouseMovedMessage:
- if (GeneratePollingEvents2(window)) {
+ /* if (GeneratePollingEvents2(window, 0)) {
eventFound = true;
- }
+ } NEXT LINE IS TEMPORARY */
+ eventFound = false;
break;
case suspendResumeMessage:
if (!(eventPtr->message & resumeFlag)) {
@@ -1516,7 +1556,6 @@ TellWindowDefProcToCalcRegions(
* Assuming there are no errors we now call the window definition
* procedure to tell it to calculate the regions for the window.
*/
-
if (err == noErr) {
(void) CallWindowDefProc((UniversalProcPtr) *wdef,
GetWVariant(wRef), wRef, wCalcRgns, 0);
diff --git a/mac/tkMacWm.c b/mac/tkMacWm.c
index 56c4b8a..a8959f3 100644
--- a/mac/tkMacWm.c
+++ b/mac/tkMacWm.c
@@ -19,6 +19,7 @@
#include <Windows.h>
#include <ToolUtils.h>
+#include <tclMac.h>
#include "tkPort.h"
#include "tkInt.h"
#include "tkMacInt.h"
@@ -532,7 +533,7 @@ TkWmMapWindow(
*/
XMapWindow(winPtr->display, winPtr->window);
-
+
/*
* Now that the window is visable we can determine the offset
* from the window's content orgin to the window's decorative
@@ -2333,12 +2334,26 @@ Tk_GetRootCoords(
y += winPtr->changes.y + winPtr->changes.border_width;
} else {
+ Point theOffset;
- /*
- * NOTE: Here we should handle
- * out of process embedding.
- */
-
+ if (gMacEmbedHandler->getOffsetProc != NULL) {
+ /*
+ * We do not require that the changes.x & changes.y for
+ * a non-Tk master window be kept up to date. So we
+ * first subtract off the possibly bogus values that have
+ * been added on at the top of this pass through the loop,
+ * and then call out to the getOffsetProc to give us
+ * the correct offset.
+ */
+
+ x -= winPtr->changes.x + winPtr->changes.border_width;
+ y -= winPtr->changes.y + winPtr->changes.border_width;
+
+ gMacEmbedHandler->getOffsetProc((Tk_Window) winPtr, &theOffset);
+
+ x += theOffset.h;
+ y += theOffset.v;
+ }
break;
}
}
@@ -3861,6 +3876,13 @@ TkMacMakeRealWindowExist(
TkMacMakeRealWindowExist(contWinPtr->privatePtr->toplevel->winPtr);
macWin->flags |= TK_HOST_EXISTS;
return;
+ } else if (gMacEmbedHandler != NULL) {
+ if (gMacEmbedHandler->containerExistProc != NULL) {
+ if (gMacEmbedHandler->containerExistProc((Tk_Window) winPtr) != TCL_OK) {
+ panic("ContainerExistProc could not make container");
+ }
+ }
+ return;
} else {
panic("TkMacMakeRealWindowExist could not find container");
}
diff --git a/mac/tkMacXStubs.c b/mac/tkMacXStubs.c
index f1042c2..a109353 100644
--- a/mac/tkMacXStubs.c
+++ b/mac/tkMacXStubs.c
@@ -46,7 +46,7 @@
*/
static TkDisplay *gMacDisplay = NULL; /* Macintosh display. */
-static char *macScreenName = "Macintosh:0";
+static char *macScreenName = ":0";
/* Default name of macintosh display. */
/*