diff options
author | das <das> | 2005-08-09 07:39:17 (GMT) |
---|---|---|
committer | das <das> | 2005-08-09 07:39:17 (GMT) |
commit | 98ee99c4ea859910fb13d480bfb6d70fe49fc7ab (patch) | |
tree | 11ef5d94364dc21d07c4385f19dd7d1f05b2e847 /macosx/tkMacOSXWindowEvent.c | |
parent | a33da75b8587cfad8d92ba670a716663fc557192 (diff) | |
download | tk-98ee99c4ea859910fb13d480bfb6d70fe49fc7ab.zip tk-98ee99c4ea859910fb13d480bfb6d70fe49fc7ab.tar.gz tk-98ee99c4ea859910fb13d480bfb6d70fe49fc7ab.tar.bz2 |
* macosx/tkMacOSXCarbonEvents.c (AppEventHandlerProc): handle carbon
events sent directly to application event target via the general
TkMacOSXProcessEvent() in the same way as events posted to the event
loop. Moved existing app event handlers to tkMacOSXWindowEvent.c.
(TkMacOSXInitCarbonEvents): register our application event handler for
kEventWindowExpanded events to deal with uncollapsing from the dock.
* macosx/tkMacOSXEvent.h: made TkMacOSXProcessEvent() non-static, added
* macosx/tkMacOSXEvent.c: new interp field to TkMacOSXEvent struct for
use by app event handler.
* macosx/tkMacOSXMouseEvent.c (TkMacOSXProcessMouseEvent): retrieve
current window, partCode, modifiers and local cursor position from
carbon mouse event if possible. Use new static GenerateButtonEvent()
taking a MouseEventData struct instead of TkGenerateButtonEvent() to
avoid recomputing already known values. Move process activation on
MouseDown into BringWindowForward() to allow clicking on window titlebar
widgets without activating process. Move code dealing with clicks in
window titelbar into separate function HandleWindowTitlebarMouseDown()
to avoid code duplication. Avoid repeated calls to TkMacOSXGetXWindow()
by storing result in MouseEventData struct.
(TkMacOSXButtonKeyState, XQueryPointer): try to get button and modifier
state from currently processed carbon event (to avoid unnecessary IPC
with the window server), otherwise use modern carbon API to get this
info instead of Button() and GetKeys(); only retrieve info caller asks
for (via non-NULL ptr passed to XQueryPointer).
(ButtonModifiers2State): new static function converting carbon button
and modifier state into tk state, allows detection of more than 3 mouse
buttons (tk supports up to 5) and of NumLock and Fn modifier keys
(NumLock is mapped to Mod3 and Fn to Mod4).
* macosx/tkMacOSXWindowEvent.c (TkMacOSXProcessApplicationEvent): handle
kEventWindowExpanded event to deal with window uncollapsing from the
dock by generating tk Map event, handle kEventAppHidden and
kEventAppShown events (moved here from tkMacOSXCarbonEvents.c).
* macosx/tkMacOSXSubwindows.c (XUnmapWindow): only hide window when
it is not iconified to avoid window flashing on collapse.
* macosx/tkMacOSXWm.c: replaced Tk_DoWhenIdle() by Tcl_DoWhenIdle().
(TkMacOSXZoomToplevel): remove call to TrackBox(), now done in
HandleWindowTitlebarMouseDown() in tkMacOSXMouseEvent.c.
(TkpWmSetState): avoid window flashing on collapse by unmapping after
calling CollapseWindow(); only uncollapse window if it is collapsed.
* generic/tkInt.decls: changed TkMacOSXZoomToplevel() signature.
* generic/tkIntPlatDecls.h:
* macosx/tkMacOSXKeyEvent.c (TkMacOSXProcessKeyboardEvent): only call
GetMenuItemCommandID() on KeyDown or KeyRepeat events.
* macosx/tkMacOSXMenu.c (ReconfigureMacintoshMenu): remove call to
obsolete AppendResMenu() API.
* macosx/tkMacOSXKeyEvent.c: replaced all direct uses of expensive
* macosx/tkMacOSXMenu.c: GetMouse() and TkMacOSXButtonKeyState()
* macosx/tkMacOSXMenus.c: APIs by calls to XQueryPointer()
* macosx/tkMacOSXMouseEvent.c:
* macosx/tkMacOSXScale.c:
* macosx/tkMacOSXScrlbr.c:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXDialog.c: replaced use of FrontNonFloatingWindow()
* macosx/tkMacOSXKeyEvent.c: by ActiveNonFloatingWindow() as
* macosx/tkMacOSXMenu.c: recommended by Carbon docs.
* macosx/tkMacOSXMenus.c:
* macosx/tkMacOSXSubwindows.c:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXDialog.c: fixed warnings
* macosx/tkMacOSXTest.c:
* macosx/tkMacOSXCarbonEvents.c: added CVS Id line to file header.
* macosx/tkMacOSXDebug.c:
* macosx/tkMacOSXDebug.h:
* macosx/tkMacOSXEntry.c:
* macosx/tkMacOSXEvent.h:
* macosx/tkMacOSXKeyEvent.c:
* macosx/tkMacOSXMouseEvent.c:
* macosx/tkMacOSXWindowEvent.c:
* macosx/tkMacOSXWm.h:
* macosx/tkMacOSXInt.h: declare macosx internal procs as MODULE_SCOPE.
* macosx/tkMacOSXCarbonEvents.c:
* macosx/tkMacOSXDraw.c:
* macosx/tkMacOSXFont.c:
* macosx/tkMacOSXHLEvents.c:
* macosx/tkMacOSXInit.c:
* macosx/tkMacOSXWindowEvent.c
* library/bgerror.tcl: sync with core-8-4-branch changes of 2005-07-28.
* macosx/tkMacOSXDraw.c:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXMouseEvent.c:
* generic/tkFrame.c: sync with core-8-4-branch changes of 2005-07-27.
* generic/tkIntDecls.h:
* generic/tkStubInit.c:
* generic/tkFrame.c:
* win/tkWinDraw.c:
* unix/tkUnixDraw.c:
* macosx/tkMacOSXDraw.c:
* macosx/tkMacOSXInt.h:
* macosx/tkMacOSXWm.c:
* macosx/tkMacOSXSubwindows.c:
* macosx/tkMacOSXButton.c: sync with core-8-4-branch.
* macosx/tkMacOSXEntry.c:
* macosx/tkMacOSXScale.c:
* library/demos/menu.tcl: removed errant '}'.
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 53 |
1 files changed, 52 insertions, 1 deletions
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 ) |