summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXCarbonEvents.c4
-rw-r--r--macosx/tkMacOSXEvent.h7
-rw-r--r--macosx/tkMacOSXInt.h38
-rw-r--r--macosx/tkMacOSXWindowEvent.c26
-rw-r--r--macosx/tkMacOSXXStubs.c119
5 files changed, 128 insertions, 66 deletions
diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c
index ef2e32d..a8b752c 100644
--- a/macosx/tkMacOSXCarbonEvents.c
+++ b/macosx/tkMacOSXCarbonEvents.c
@@ -60,7 +60,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.6 2005/11/27 02:36:14 das Exp $
+ * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.7 2005/12/01 06:24:16 hobbs Exp $
*/
#include "tkInt.h"
@@ -196,6 +196,7 @@ TkMacOSXInitCarbonEvents (
{kEventClassWindow, kEventWindowExpanded},
{kEventClassApplication, kEventAppHidden},
{kEventClassApplication, kEventAppShown},
+ {kEventClassApplication, kEventAppAvailableWindowBoundsChanged},
};
EventHandlerUPP handler = NewEventHandlerUPP(CarbonEventHandlerProc);
@@ -247,6 +248,7 @@ TkMacOSXInitCarbonEvents (
_TraceEventByName(CFSTR("kEventWindowExpanded"));
_TraceEventByName(CFSTR("kEventAppHidden"));
_TraceEventByName(CFSTR("kEventAppShown"));
+ _TraceEventByName(CFSTR("kEventAppAvailableWindowBoundsChanged"));
}
#endif /* TK_MAC_DEBUG_CARBON_EVENTS */
}
diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h
index 2d27faf..c52e1ec 100644
--- a/macosx/tkMacOSXEvent.h
+++ b/macosx/tkMacOSXEvent.h
@@ -50,7 +50,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.6 2005/11/27 02:36:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.7 2005/12/01 06:24:16 hobbs Exp $
*/
#ifndef _TKMACEVENT
@@ -99,5 +99,10 @@ MODULE_SCOPE int TkMacOSXKeycodeToUnicode(
MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer();
MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer();
+#if !defined(MAC_OS_X_VERSION_10_3) || \
+ (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3)
+/* Define constants only available on Mac OS X 10.3 or later */
+enum { kEventAppAvailableWindowBoundsChanged = 110 };
+#endif
#endif
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index efae92f..35a3ef7 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.11 2005/11/27 02:36:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.12 2005/12/01 06:24:16 hobbs Exp $
*/
#ifndef _TKMACINT
@@ -73,9 +73,10 @@ typedef struct TkMacOSXWindowList {
/*
* I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags
* This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the
- * TkWindow structure for the window, but in the MacWin. This way we can still tell
- * what the correct port is after the TKWindow structure has been freed. This
- * actually happens when you bind destroy of a toplevel to Destroy of a child.
+ * TkWindow structure for the window, but in the MacWin. This way we can
+ * still tell what the correct port is after the TKWindow structure has been
+ * freed. This actually happens when you bind destroy of a toplevel to
+ * Destroy of a child.
*/
/*
@@ -106,14 +107,14 @@ MODULE_SCOPE TkMacOSXEmbedHandler *gMacEmbedHandler;
/*
* Accessor for the privatePtr flags field for the TK_HOST_EXISTS field
*/
-
+
#define TkMacOSXHostToplevelExists(tkwin) \
(((TkWindow *) (tkwin))->privatePtr->toplevel->flags & TK_HOST_EXISTS)
/*
* Defines use for the flags argument to TkGenWMConfigureEvent.
*/
-
+
#define TK_LOCATION_CHANGED 1
#define TK_SIZE_CHANGED 2
#define TK_BOTH_CHANGED 3
@@ -122,11 +123,11 @@ MODULE_SCOPE TkMacOSXEmbedHandler *gMacEmbedHandler;
* Variables shared among various Mac Tk modules but are not
* exported to the outside world.
*/
-
+
/*
* Globals shared among Macintosh Tk
*/
-
+
MODULE_SCOPE MenuHandle tkAppleMenu; /* Handle to the Apple Menu */
MODULE_SCOPE MenuHandle tkFileMenu; /* Handles to menus */
MODULE_SCOPE MenuHandle tkEditMenu; /* Handles to menus */
@@ -137,20 +138,23 @@ MODULE_SCOPE int tkUseMenuCascadeRgn; /* If this is 1, clipping code
* tkMenuCascadeRgn will only
* be valid when the value of this
* variable is 1. */
-MODULE_SCOPE int tkPictureIsOpen; /* If this is 1, we are drawing to a picture
- * The clipping should then be done relative
- * to the bounds of the picture rather than the window
- * As of OS X.0.4, something is seriously wrong:
- * The clipping bounds only seem to work if the
- * top,left values are 0,0
- * The destination rectangle for CopyBits
- * should also have top,left values of 0,0
- */
+MODULE_SCOPE int tkPictureIsOpen; /* If this is 1, we are drawing to a
+ * picture The clipping should then be
+ * done relative to the bounds of the
+ * picture rather than the window As
+ * of OS X.0.4, something is seriously
+ * wrong: The clipping bounds only
+ * seem to work if the top,left values
+ * are 0,0 The destination rectangle
+ * for CopyBits should also have
+ * top,left values of 0,0
+ */
MODULE_SCOPE TkMacOSXWindowList *tkMacOSXWindowListPtr;
/* The list of toplevels */
MODULE_SCOPE Tcl_Encoding TkMacOSXCarbonEncoding;
+MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display);
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);
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 570c734..0fa938b 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.8 2005/11/27 02:36:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.9 2005/12/01 06:24:16 hobbs Exp $
*/
#include "tkMacOSXInt.h"
@@ -106,12 +106,12 @@ TkMacOSXProcessApplicationEvent(
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...
+ * 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;
@@ -154,6 +154,14 @@ TkMacOSXProcessApplicationEvent(
}
statusPtr->stopProcessing = 1;
break;
+ case kEventAppAvailableWindowBoundsChanged: {
+ TkDisplay *dispPtr = TkGetDisplayList();
+ TkMacOSXDisplayChanged(dispPtr->display);
+ /*
+ * Should we call ::tk::mac::OnDisplayChanged?
+ */
+ break;
+ }
default:
break;
}
@@ -239,11 +247,11 @@ TkMacOSXProcessWindowEvent(
return 0;
}
-/*
+/*
*----------------------------------------------------------------------
- *
+ *
* GenerateUpdateEvent --
- *
+ *
* Given a Macintosh window update event this function generates all the
* X update events needed by Tk.
*
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index 19beaeb..b47f41c 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.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: tkMacOSXXStubs.c,v 1.13 2005/11/27 02:36:15 das Exp $
+ * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.14 2005/12/01 06:24:16 hobbs Exp $
*/
#include "tkInt.h"
@@ -76,6 +76,46 @@ int _XInitImageFuncPtrs _ANSI_ARGS_((XImage *image));
/*
*----------------------------------------------------------------------
*
+ * TkMacOSXDisplayChanged --
+ *
+ * Called to set up initial screen info or when an event indicated
+ * display (screen) change.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * May change info regarding the screen.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkMacOSXDisplayChanged(Display *display)
+{
+ GDHandle graphicsDevice;
+ Screen *screen;
+
+ if (display == NULL || display->screens == NULL) {
+ return;
+ }
+ screen = display->screens;
+
+ graphicsDevice = GetMainDevice();
+ screen->root_depth = (*(*graphicsDevice)->gdPMap)->cmpSize *
+ (*(*graphicsDevice)->gdPMap)->cmpCount;
+ screen->height = (*graphicsDevice)->gdRect.bottom -
+ (*graphicsDevice)->gdRect.top;
+ screen->width = (*graphicsDevice)->gdRect.right -
+ (*graphicsDevice)->gdRect.left;
+
+ screen->mwidth = (screen->width * 254 + 360) / 720;
+ screen->mheight = (screen->height * 254 + 360) / 720;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpOpenDisplay --
*
* Create the Display structure and fill it with device
@@ -96,8 +136,8 @@ TkpOpenDisplay(
{
Display *display;
Screen *screen;
- GDHandle graphicsDevice;
int fd = 0;
+
if (gMacDisplay != NULL) {
if (strcmp(gMacDisplay->display->display_name, display_name) == 0) {
return gMacDisplay;
@@ -106,54 +146,57 @@ TkpOpenDisplay(
}
}
InitCursor();
-
- graphicsDevice = GetMainDevice();
+
display = (Display *) ckalloc(sizeof(Display));
+ screen = (Screen *) ckalloc(sizeof(Screen));
+ bzero(display, sizeof(Display));
+ bzero(screen, sizeof(Screen));
+
display->resource_alloc = MacXIdAlloc;
- screen = (Screen *) ckalloc(sizeof(Screen) * 2);
+ display->request = 0;
+ display->qlen = 0;
+ display->fd = fd;
+ display->screens = screen;
+ display->nscreens = 1;
display->default_screen = 0;
- display->request = 0;
- display->nscreens = 1;
- display->screens = screen;
- display->display_name = macScreenName;
- display->qlen = 0;
- display->fd = fd;
- display->proto_major_version = 10;
+ display->display_name = macScreenName;
+
Gestalt(gestaltQuickdrawVersion, (long*)&display->proto_minor_version);
+ display->proto_major_version = 10;
display->proto_minor_version -= gestaltMacOSXQD;
display->vendor = "Apple";
Gestalt(gestaltSystemVersion, (long*)&display->release);
-
- screen->root = ROOT_ID;
- screen->display = display;
- screen->root_depth = (*(*graphicsDevice)->gdPMap)->cmpSize *
- (*(*graphicsDevice)->gdPMap)->cmpCount;
- screen->height = (*graphicsDevice)->gdRect.bottom -
- (*graphicsDevice)->gdRect.top;
- screen->width = (*graphicsDevice)->gdRect.right -
- (*graphicsDevice)->gdRect.left;
-
- screen->mwidth = (screen->width * 254 + 360) / 720;
- screen->mheight = (screen->height * 254 + 360) / 720;
+
+ /*
+ * These screen bits never change
+ */
+ screen->root = ROOT_ID;
+ screen->display = display;
screen->black_pixel = 0x00000000;
screen->white_pixel = 0x00FFFFFF;
+
screen->root_visual = (Visual *) ckalloc(sizeof(Visual));
- screen->root_visual->visualid = 0;
- screen->root_visual->class = TrueColor;
- screen->root_visual->red_mask = 0x00FF0000;
- screen->root_visual->green_mask = 0x0000FF00;
- screen->root_visual->blue_mask = 0x000000FF;
+ screen->root_visual->visualid = 0;
+ screen->root_visual->class = TrueColor;
+ screen->root_visual->red_mask = 0x00FF0000;
+ screen->root_visual->green_mask = 0x0000FF00;
+ screen->root_visual->blue_mask = 0x000000FF;
screen->root_visual->bits_per_rgb = 24;
- screen->root_visual->map_entries = 256;
+ screen->root_visual->map_entries = 256;
+
+ /*
+ * Initialize screen bits that may change
+ */
+ TkMacOSXDisplayChanged(display);
gMacDisplay = (TkDisplay *) ckalloc(sizeof(TkDisplay));
-
+
/*
* This is the quickest way to make sure that all the *Init
* flags get properly initialized
*/
-
- bzero (gMacDisplay, sizeof (TkDisplay));
+
+ bzero(gMacDisplay, sizeof(TkDisplay));
gMacDisplay->display = display;
return gMacDisplay;
}
@@ -813,11 +856,11 @@ TkMacOSXXPutPixel(
b = (pixel & image->blue_mask);
if (image->obdata) {
/* Image from XGetImage, 16 bit color values */
- cPix . red = r << 8;
+ cPix . red = r << 8;
cPix . green = g << 8;
cPix . blue = b << 8;
} else {
- cPix . red = r;
+ cPix . red = r;
cPix . green = g;
cPix . blue = b;
}
@@ -924,7 +967,7 @@ XSetWindowColormap(
Debugger();
}
-Status
+Status
XStringListToTextProperty(
char** list,
int count,
@@ -933,7 +976,7 @@ XStringListToTextProperty(
Debugger();
return (Status) 0;
}
-void
+void
XSetWMClientMachine(
Display* display,
Window w,
@@ -941,7 +984,7 @@ XSetWMClientMachine(
{
Debugger();
}
-XIC
+XIC
XCreateIC(
void)
{