summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorhobbs <hobbs>2005-11-30 01:02:55 (GMT)
committerhobbs <hobbs>2005-11-30 01:02:55 (GMT)
commit12e3724cff854097e33aacfde2f9d8ae89ad8b06 (patch)
tree890ac33201f8bc8ac2d2f6254f8c3912d6f86886 /macosx
parent0805428fc70c423c555452caba933228486c7c5d (diff)
downloadtk-12e3724cff854097e33aacfde2f9d8ae89ad8b06.zip
tk-12e3724cff854097e33aacfde2f9d8ae89ad8b06.tar.gz
tk-12e3724cff854097e33aacfde2f9d8ae89ad8b06.tar.bz2
* macosx/tkMacOSXXStubs.c (TkpOpenDisplay, TkMacOSXDisplayChanged):
* macosx/tkMacOSXCarbonEvents.c (TkMacOSXInitCarbonEvents): * macosx/tkMacOSXWindowEvent.c (TkMacOSXProcessApplicationEvent): * macosx/tkMacOSXInt.h: Trap kEventAppAvailableWindowBoundsChanged event to watch for change in display size and adjust internal state appropriately.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXCarbonEvents.c3
-rw-r--r--macosx/tkMacOSXInt.h22
-rw-r--r--macosx/tkMacOSXWindowEvent.c28
-rw-r--r--macosx/tkMacOSXXStubs.c113
4 files changed, 110 insertions, 56 deletions
diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c
index 855ab7b..196002a 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.3.2.5 2005/11/27 02:36:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.6 2005/11/30 01:02:55 hobbs Exp $
*/
#include "tkInt.h"
@@ -196,6 +196,7 @@ TkMacOSXInitCarbonEvents (
{kEventClassWindow, kEventWindowExpanded},
{kEventClassApplication, kEventAppHidden},
{kEventClassApplication, kEventAppShown},
+ {kEventClassApplication, kEventAppAvailableWindowBoundsChanged},
};
EventHandlerUPP handler = NewEventHandlerUPP(CarbonEventHandlerProc);
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 514680a..a6c90f8 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.3.2.6 2005/11/27 02:36:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.7 2005/11/30 01:02:55 hobbs Exp $
*/
#ifndef _TKMACINT
@@ -137,15 +137,15 @@ extern int tkUseMenuCascadeRgn; /* If this is 1, clipping code
* tkMenuCascadeRgn will only
* be valid when the value of this
* variable is 1. */
-extern 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
- */
+extern 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
+ */
extern TkMacOSXWindowList *tkMacOSXWindowListPtr;
/* The list of toplevels */
@@ -166,6 +166,8 @@ extern void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol);
symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), STRINGIFY(_##symbol));\
}
+extern void TkMacOSXDisplayChanged(Display *display);
+
#include "tkIntPlatDecls.h"
#endif /* _TKMACINT */
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index a653b02..b6c039a 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -54,7 +54,7 @@
* software in accordance with the terms specified in this
* license.
*
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.5 2005/11/27 02:36:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.6 2005/11/30 01:02:55 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;
@@ -129,10 +129,10 @@ TkMacOSXProcessApplicationEvent(
statusPtr->stopProcessing = 1;
break;
case kEventAppHidden:
- /*
- * Don't bother if we don't have an interp or
- * the show preferences procedure doesn't exist.
- */
+ /*
+ * 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,
@@ -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;
}
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index eea58fc..592c760 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.2.2.9 2005/11/27 02:36:46 das Exp $
+ * RCS: @(#) $Id: tkMacOSXXStubs.c,v 1.2.2.10 2005/11/30 01:02:55 hobbs Exp $
*/
#include "tkInt.h"
@@ -74,6 +74,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
@@ -94,8 +134,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;
@@ -104,54 +144,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;
}
@@ -931,7 +974,7 @@ XStringListToTextProperty(
Debugger();
return (Status) 0;
}
-void
+void
XSetWMClientMachine(
Display* display,
Window w,
@@ -939,7 +982,7 @@ XSetWMClientMachine(
{
Debugger();
}
-XIC
+XIC
XCreateIC(
void)
{