summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog29
-rw-r--r--generic/tkInt.h16
-rw-r--r--generic/tkMenu.c60
-rw-r--r--unix/tkUnixWm.c171
4 files changed, 166 insertions, 110 deletions
diff --git a/ChangeLog b/ChangeLog
index 8440f49..e3d0178 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,23 +1,30 @@
+2009-12-09 Donal K. Fellows <dkf@users.sf.net>
+
+ * unix/tkUnixWm.c (TkpMakeMenuWindow): Improve the determining of what
+ * generic/tkMenu.c (ConfigureMenu): EWMH hint to use so that we
+ distinguish between dropdown menus (children of menubars) and what are
+ presumably popup menus.
+
2009-12-08 Pat Thoyts <patthoyts@users.sourceforge.net>
- * unix/tkUnixWm.c: [Bug 2864685] Apply suitable extended window
- manager hints to the menus so that modern unix window managers
- can use the correct animation modes.
+ * unix/tkUnixWm.c: [Bug 2864685]: Apply suitable extended window
+ manager hints to the menus so that modern unix window managers can use
+ the correct animation modes.
2009-12-02 Jan Nijtmans <nijtmans@users.sf.net>
- * win/configure: (regenerated)
- * win/Makefile.in: Use tktest86.dll for all tests.
- * win/tkWinInt.h: mark various functions MODULE_SCOPE
- * generic/tkInt.decls: make TkWinChildProc available in private
- stub table. [Bug #220600] and [Bug #220690].
+ * win/configure: (regenerated)
+ * win/Makefile.in: Use tktest86.dll for all tests.
+ * win/tkWinInt.h: Mark various functions MODULE_SCOPE
+ * generic/tkInt.decls: [Bugs 220600, 220690]: Make TkWinChildProc
+ available in private stub table.
* generic/tkIntPlatDecls.h: (regenerated)
- * generic/tkStubInit.c: (regenerated)
+ * generic/tkStubInit.c: (regenerated)
2009-11-30 Jan Nijtmans <nijtmans@users.sf.net>
- * win/Makefile.in: Better dependancies in case of static
- build. Generate tktest86.dll and tktest86.lib.
+ * win/Makefile.in: Better dependancies in case of static build.
+ Generate tktest86.dll and tktest86.lib.
2009-11-29 Jan Nijtmans <nijtmans@users.sf.net>
diff --git a/generic/tkInt.h b/generic/tkInt.h
index a145ab7..81e3967 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -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: tkInt.h,v 1.113 2009/12/02 21:16:44 nijtmans Exp $
+ * RCS: $Id: tkInt.h,v 1.114 2009/12/09 10:45:30 dkf Exp $
*/
#ifndef _TKINT
@@ -772,7 +772,8 @@ typedef struct TkWindow {
* Information used by tkGeometry.c for geometry management.
*/
- const Tk_GeomMgr *geomMgrPtr; /* Information about geometry manager for this
+ const Tk_GeomMgr *geomMgrPtr;
+ /* Information about geometry manager for this
* window. */
ClientData geomData; /* Argument for geometry manager functions. */
int reqWidth, reqHeight; /* Arguments from last call to
@@ -791,7 +792,8 @@ typedef struct TkWindow {
struct TkWmInfo *wmInfoPtr; /* For top-level windows (and also for special
* Unix menubar and wrapper windows), points
* to structure with wm-related info (see
- * tkWm.c). For other windows, this is NULL. */
+ * tkWm.c). For other windows, this is
+ * NULL. */
/*
* Information used by widget classes.
@@ -821,6 +823,14 @@ typedef struct TkWindow {
} TkWindow;
/*
+ * Flags passed to TkpMakeMenuWindow's 'transient' argument.
+ */
+
+#define TK_MAKE_MENU_TEAROFF 0 /* Only non-transient case. */
+#define TK_MAKE_MENU_POPUP 1
+#define TK_MAKE_MENU_DROPDOWN 2
+
+/*
* The following structure is used with TkMakeEnsemble to create ensemble
* commands and optionally to create sub-ensembles.
*/
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index d46f622..479dd0c 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.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: tkMenu.c,v 1.52 2009/09/07 07:29:04 das Exp $
+ * RCS: @(#) $Id: tkMenu.c,v 1.53 2009/12/09 10:45:30 dkf Exp $
*/
/*
@@ -341,8 +341,9 @@ static void DestroyMenuHashTable(ClientData clientData,
Tcl_Interp *interp);
static void DestroyMenuInstance(TkMenu *menuPtr);
static void DestroyMenuEntry(char *memPtr);
-static int GetIndexFromCoords(Tcl_Interp *interp, TkMenu *menuPtr,
- const char *string, int *indexPtr);
+static int GetIndexFromCoords(Tcl_Interp *interp,
+ TkMenu *menuPtr, const char *string,
+ int *indexPtr);
static int MenuDoYPosition(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *objPtr);
static int MenuDoXPosition(Tcl_Interp *interp,
@@ -405,8 +406,8 @@ TkCreateMenuCmd(
Tcl_Interp *interp) /* Interpreter we are creating the command
* in. */
{
- TkMenuOptionTables *optionTablesPtr =
- (TkMenuOptionTables *) ckalloc(sizeof(TkMenuOptionTables));
+ TkMenuOptionTables *optionTablesPtr = (TkMenuOptionTables *)
+ ckalloc(sizeof(TkMenuOptionTables));
optionTablesPtr->menuOptionTable =
Tk_CreateOptionTable(interp, tkMenuConfigSpecs);
@@ -475,8 +476,8 @@ MenuCmd(
toplevel = 1;
for (i = 2; i < (objc - 1); i++) {
- if (Tcl_GetIndexFromObj(NULL, objv[i], typeStringList, NULL, 0, &index)
- != TCL_ERROR) {
+ if (Tcl_GetIndexFromObj(NULL, objv[i], typeStringList, NULL, 0,
+ &index) != TCL_ERROR) {
if ((Tcl_GetIndexFromObj(NULL, objv[i + 1], menuTypeStrings, NULL,
0, &index) == TCL_OK) && (index == MENUBAR)) {
toplevel = 0;
@@ -579,7 +580,7 @@ MenuCmd(
&& ((cascadeListPtr->menuPtr->masterMenuPtr
== cascadeListPtr->menuPtr)))) {
newObjv[0] = Tcl_NewStringObj("-menu", -1);
- newObjv[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), -1);
+ newObjv[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin),-1);
Tcl_IncrRefCount(newObjv[0]);
Tcl_IncrRefCount(newObjv[1]);
ConfigureMenuEntry(cascadeListPtr, 2, newObjv);
@@ -712,7 +713,7 @@ MenuWidgetObjCmd(
goto error;
}
- if (MenuAddOrInsert(interp, menuPtr, NULL, objc-2, objv+2) != TCL_OK) {
+ if (MenuAddOrInsert(interp, menuPtr, NULL, objc-2, objv+2) != TCL_OK){
goto error;
}
break;
@@ -885,7 +886,8 @@ MenuWidgetObjCmd(
}
case MENU_INSERT:
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "index type ?-option value ...?");
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "index type ?-option value ...?");
goto error;
}
if (MenuAddOrInsert(interp,menuPtr,objv[2],objc-3,objv+3) != TCL_OK) {
@@ -1222,6 +1224,7 @@ DestroyMenuInstance(
menuPtr->optionTablesPtr->menuOptionTable, menuPtr->tkwin);
if (menuPtr->tkwin != NULL) {
Tk_Window tkwin = menuPtr->tkwin;
+
menuPtr->tkwin = NULL;
Tk_DestroyWindow(tkwin);
}
@@ -1431,13 +1434,13 @@ DestroyMenuEntry(
if (mePtr->type == CASCADE_ENTRY) {
if (menuPtr->masterMenuPtr != menuPtr) {
TkMenu *destroyThis = NULL;
+ TkMenuReferences *menuRefPtr = mePtr->childMenuRefPtr;
+
/*
* The menu as a whole is a clone. We must delete the clone of the
* cascaded menu for the particular entry we are destroying.
*/
- TkMenuReferences *menuRefPtr = mePtr->childMenuRefPtr;
-
if (menuRefPtr != NULL) {
destroyThis = menuRefPtr->menuPtr;
@@ -1595,13 +1598,31 @@ ConfigureMenu(
*/
if (menuListPtr->menuType == MASTER_MENU) {
- TkpMakeMenuWindow(menuListPtr->tkwin, 1);
+ int typeFlag = TK_MAKE_MENU_POPUP;
+ Tk_Window tkwin = menuPtr->tkwin;
+
+ /*
+ * Work out if we are the child of a menubar or a popup.
+ */
+
+ while (1) {
+ Tk_Window parent = Tk_Parent(tkwin);
+
+ if (Tk_Class(parent) != Tk_Class(menuPtr->tkwin)) {
+ break;
+ }
+ tkwin = parent;
+ }
+ if (((TkMenu*) tkwin)->menuType == MENUBAR) {
+ typeFlag = TK_MAKE_MENU_DROPDOWN;
+ }
+
+ TkpMakeMenuWindow(menuListPtr->tkwin, typeFlag);
} else if (menuListPtr->menuType == TEAROFF_MENU) {
- TkpMakeMenuWindow(menuListPtr->tkwin, 0);
+ TkpMakeMenuWindow(menuListPtr->tkwin, TK_MAKE_MENU_TEAROFF);
}
}
-
/*
* Depending on the -tearOff option, make sure that there is or isn't
* an initial tear-off entry at the beginning of the menu.
@@ -1612,8 +1633,8 @@ ConfigureMenu(
|| (menuListPtr->entries[0]->type != TEAROFF_ENTRY)) {
if (MenuNewEntry(menuListPtr, 0, TEAROFF_ENTRY) == NULL) {
for (cleanupPtr = menuPtr->masterMenuPtr;
- cleanupPtr != menuListPtr;
- cleanupPtr = cleanupPtr->nextInstancePtr) {
+ cleanupPtr != menuListPtr;
+ cleanupPtr = cleanupPtr->nextInstancePtr) {
Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr);
ckfree((char *) cleanupPtr->errorStructPtr);
cleanupPtr->errorStructPtr = NULL;
@@ -2258,8 +2279,8 @@ MenuNewEntry(
* Create a new array of entries with an empty slot for the new entry.
*/
- newEntries = (TkMenuEntry **) ckalloc((unsigned)
- ((menuPtr->numEntries+1)*sizeof(TkMenuEntry *)));
+ newEntries = (TkMenuEntry **)
+ ckalloc((unsigned) (menuPtr->numEntries+1)*sizeof(TkMenuEntry *));
for (i = 0; i < index; i++) {
newEntries[i] = menuPtr->entries[i];
}
@@ -2361,6 +2382,7 @@ MenuAddOrInsert(
}
if (index < 0) {
const char *indexString = Tcl_GetString(indexPtr);
+
Tcl_AppendResult(interp, "bad index \"", indexString, "\"", NULL);
return TCL_ERROR;
}
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 7b47a51..4d3bd4d 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.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: tkUnixWm.c,v 1.75 2009/12/08 20:34:23 patthoyts Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.76 2009/12/09 10:45:30 dkf Exp $
*/
#include "tkUnixInt.h"
@@ -291,17 +291,18 @@ typedef struct TkWmInfo {
static void TopLevelReqProc(ClientData dummy, Tk_Window tkwin);
static void RemapWindows(TkWindow *winPtr, TkWindow *parentPtr);
-static void MenubarReqProc(ClientData clientData, Tk_Window tkwin);
+static void MenubarReqProc(ClientData clientData,
+ Tk_Window tkwin);
static const Tk_GeomMgr wmMgrType = {
- "wm", /* name */
- TopLevelReqProc, /* requestProc */
- NULL, /* lostSlaveProc */
+ "wm", /* name */
+ TopLevelReqProc, /* requestProc */
+ NULL, /* lostSlaveProc */
};
static const Tk_GeomMgr menubarMgrType = {
- "menubar", /* name */
- MenubarReqProc, /* requestProc */
- NULL, /* lostSlaveProc */
+ "menubar", /* name */
+ MenubarReqProc, /* requestProc */
+ NULL, /* lostSlaveProc */
};
/*
@@ -355,12 +356,12 @@ static void WaitForConfigureNotify(TkWindow *winPtr,
static int WaitForEvent(Display *display,
WmInfo *wmInfoPtr, int type, XEvent *eventPtr);
static void WaitForMapNotify(TkWindow *winPtr, int mapped);
-static Tk_RestrictAction
- WaitRestrictProc(ClientData clientData,
+static Tk_RestrictAction WaitRestrictProc(ClientData clientData,
XEvent *eventPtr);
static void WrapperEventProc(ClientData clientData,
XEvent *eventPtr);
-static void WmWaitMapProc(ClientData clientData, XEvent *eventPtr);
+static void WmWaitMapProc(ClientData clientData,
+ XEvent *eventPtr);
static int WmAspectCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
@@ -370,8 +371,8 @@ static int WmAttributesCmd(Tk_Window tkwin, TkWindow *winPtr,
static int WmClientCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
-static int WmColormapwindowsCmd(Tk_Window tkwin, TkWindow *winPtr,
- Tcl_Interp *interp, int objc,
+static int WmColormapwindowsCmd(Tk_Window tkwin,
+ TkWindow *winPtr, Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
static int WmCommandCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
@@ -427,8 +428,8 @@ static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr,
static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
-static int WmOverrideredirectCmd(Tk_Window tkwin,TkWindow *winPtr,
- Tcl_Interp *interp, int objc,
+static int WmOverrideredirectCmd(Tk_Window tkwin,
+ TkWindow *winPtr, Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
static int WmPositionfromCmd(Tk_Window tkwin, TkWindow *winPtr,
Tcl_Interp *interp, int objc,
@@ -695,8 +696,8 @@ TkWmMapWindow(
unsigned long pid = (unsigned long) getpid();
Atom atom;
- XSetWMClientMachine(winPtr->display, wmPtr->wrapperPtr->window,
- &textProp);
+ XSetWMClientMachine(winPtr->display,
+ wmPtr->wrapperPtr->window, &textProp);
XFree((char *) textProp.value);
/*
@@ -926,7 +927,7 @@ TkWmDeadWindow(
wmPtr2->numTransients--;
}
Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
- StructureNotifyMask, WmWaitMapProc, (ClientData) winPtr);
+ StructureNotifyMask, WmWaitMapProc, winPtr);
wmPtr->masterPtr = NULL;
}
ckfree((char *) wmPtr);
@@ -1008,7 +1009,8 @@ Tk_WmObjCmd(
enum options {
WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FORGET,
- WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
+ WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP,
+ WMOPT_ICONBITMAP,
WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME, WMOPT_ICONPHOTO,
WMOPT_ICONPOSITION, WMOPT_ICONWINDOW, WMOPT_MANAGE, WMOPT_MAXSIZE,
WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT, WMOPT_POSITIONFROM,
@@ -1030,6 +1032,7 @@ Tk_WmObjCmd(
if ((argv1[0] == 't') && (strncmp(argv1, "tracing", (size_t) length) == 0)
&& (length >= 3)) {
int wmTracing;
+
if ((objc != 2) && (objc != 3)) {
Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
return TCL_ERROR;
@@ -2112,7 +2115,8 @@ WmIconbitmapCmd(
if (objc == 3) {
if (wmPtr->hints.flags & IconPixmapHint) {
Tcl_SetResult(interp, (char *)
- Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),
+ Tk_NameOfBitmap(winPtr->display,
+ wmPtr->hints.icon_pixmap),
TCL_STATIC);
}
return TCL_OK;
@@ -2162,6 +2166,7 @@ WmIconifyCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
+
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
@@ -2676,7 +2681,7 @@ WmManageCmd(
* Flags (above) must be set before calling TkMapTopFrame (below).
*/
- TkMapTopFrame (frameWin);
+ TkMapTopFrame(frameWin);
} else if (Tk_IsTopLevel(frameWin)) {
/*
* Already managed by wm - ignore it.
@@ -3001,7 +3006,7 @@ WmProtocolCmd(
} else {
prevPtr->nextPtr = protPtr->nextPtr;
}
- Tcl_EventuallyFree((ClientData) protPtr, TCL_DYNAMIC);
+ Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
break;
}
}
@@ -3230,18 +3235,18 @@ WmStackorderCmd(
if (windows == NULL) {
Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL);
return TCL_ERROR;
- } else {
- for (window_ptr = windows; *window_ptr ; window_ptr++) {
- if (*window_ptr == winPtr) {
- index1 = (window_ptr - windows);
- }
- if (*window_ptr == winPtr2) {
- index2 = (window_ptr - windows);
- }
+ }
+
+ for (window_ptr = windows; *window_ptr ; window_ptr++) {
+ if (*window_ptr == winPtr) {
+ index1 = (window_ptr - windows);
+ }
+ if (*window_ptr == winPtr2) {
+ index2 = (window_ptr - windows);
}
- /* ASSERT: index1 != -1 && index2 != -2 [Bug 1789819] */
- ckfree((char *) windows);
}
+ /* ASSERT: index1 != -1 && index2 != -2 [Bug 1789819] */
+ ckfree((char *) windows);
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
&index) != TCL_OK) {
@@ -3453,7 +3458,7 @@ WmTransientCmd(
masterPtr->wmInfoPtr->numTransients--;
Tk_DeleteEventHandler((Tk_Window) masterPtr, StructureNotifyMask,
- WmWaitMapProc, (ClientData) winPtr);
+ WmWaitMapProc, winPtr);
/*
* FIXME: Need a call like Win32's UpdateWrapper() so we can
@@ -3512,13 +3517,12 @@ WmTransientCmd(
if (wmPtr->masterPtr != NULL) {
wmPtr->masterPtr->wmInfoPtr->numTransients--;
Tk_DeleteEventHandler((Tk_Window) wmPtr->masterPtr,
- StructureNotifyMask,
- WmWaitMapProc, (ClientData) winPtr);
+ StructureNotifyMask, WmWaitMapProc, winPtr);
}
masterPtr->wmInfoPtr->numTransients++;
Tk_CreateEventHandler((Tk_Window) masterPtr,
- StructureNotifyMask, WmWaitMapProc, (ClientData) winPtr);
+ StructureNotifyMask, WmWaitMapProc, winPtr);
wmPtr->masterPtr = masterPtr;
}
@@ -3602,7 +3606,7 @@ WmUpdateGeom(
TkWindow *winPtr)
{
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3617,7 +3621,7 @@ WmWaitMapProc(
ClientData clientData, /* Pointer to window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
TkWindow *masterPtr = winPtr->wmInfoPtr->masterPtr;
if (masterPtr == NULL) {
@@ -3744,7 +3748,7 @@ Tk_SetGrid(
wmPtr->sizeHintsFlags |= PBaseSize|PResizeInc;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -3812,7 +3816,7 @@ Tk_UnsetGrid(
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -4303,14 +4307,14 @@ PropertyEvent(
*/
static const unsigned WrapperEventMask =
- (StructureNotifyMask | PropertyChangeMask);
+ (StructureNotifyMask | PropertyChangeMask);
static void
WrapperEventProc(
ClientData clientData, /* Information about toplevel window. */
XEvent *eventPtr) /* Event that just happened. */
{
- WmInfo *wmPtr = (WmInfo *) clientData;
+ WmInfo *wmPtr = clientData;
XEvent mapEvent;
TkDisplay *dispPtr = wmPtr->winPtr->dispPtr;
@@ -4397,10 +4401,11 @@ TopLevelReqProc(
Tk_Window tkwin) /* Information about window. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- WmInfo *wmPtr;
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
- if ((wmPtr = winPtr->wmInfoPtr) == NULL)
+ if (wmPtr == NULL) {
return;
+ }
if ((wmPtr->width >= 0) && (wmPtr->height >= 0)) {
/*
@@ -4420,7 +4425,7 @@ TopLevelReqProc(
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
@@ -4459,7 +4464,7 @@ static void
UpdateGeometryInfo(
ClientData clientData) /* Pointer to the window's record. */
{
- register TkWindow *winPtr = (TkWindow *) clientData;
+ register TkWindow *winPtr = clientData;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int x, y, width, height, min, max;
unsigned long serial;
@@ -4629,7 +4634,7 @@ UpdateGeometryInfo(
height += wmPtr->menuHeight;
if (wmPtr->flags & WM_MOVE_PENDING) {
if ((x + wmPtr->xInParent == winPtr->changes.x) &&
- (y + wmPtr->yInParent + wmPtr->menuHeight == winPtr->changes.y)
+ (y+wmPtr->yInParent+wmPtr->menuHeight == winPtr->changes.y)
&& (width == wmPtr->wrapperPtr->changes.width)
&& (height == wmPtr->wrapperPtr->changes.height)) {
/*
@@ -5167,7 +5172,7 @@ WaitForEvent(
info.type = type;
info.eventPtr = eventPtr;
info.foundEvent = 0;
- oldRestrictProc = Tk_RestrictEvents(WaitRestrictProc, (ClientData) &info,
+ oldRestrictProc = Tk_RestrictEvents(WaitRestrictProc, &info,
&oldRestrictData);
Tcl_GetTime(&timeout);
@@ -5212,7 +5217,7 @@ WaitRestrictProc(
ClientData clientData, /* Pointer to WaitRestrictInfo structure. */
XEvent *eventPtr) /* Event that is about to be handled. */
{
- WaitRestrictInfo *infoPtr = (WaitRestrictInfo *) clientData;
+ WaitRestrictInfo *infoPtr = clientData;
if (eventPtr->type == ReparentNotify) {
return TK_PROCESS_EVENT;
@@ -5454,7 +5459,7 @@ ParseGeometry(
wmPtr->flags = flags;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
return TCL_OK;
@@ -5944,9 +5949,9 @@ Tk_MoveToplevelWindow(
if (!(wmPtr->flags & WM_NEVER_MAPPED)) {
if (wmPtr->flags & WM_UPDATE_PENDING) {
- Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr);
+ Tcl_CancelIdleCall(UpdateGeometryInfo, winPtr);
}
- UpdateGeometryInfo((ClientData) winPtr);
+ UpdateGeometryInfo(winPtr);
}
}
@@ -6634,8 +6639,8 @@ TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
*
* TkpMakeMenuWindow --
*
- * Configure the window to be either a pull-down (or pop-up) menu, or as
- * a toplevel (torn-off) menu or palette.
+ * Configure the window to be either a pull-down menu, a pop-up menu, or
+ * as a toplevel (torn-off) menu or palette.
*
* Results:
* None.
@@ -6649,11 +6654,14 @@ TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
void
TkpMakeMenuWindow(
Tk_Window tkwin, /* New window. */
- int transient) /* 1 means menu is only posted briefly as a
- * popup or pulldown or cascade. 0 means menu
- * is always visible, e.g. as a torn-off menu.
+ int typeFlag) /* TK_MAKE_MENU_DROPDOWN means menu is only
+ * posted briefly as a pulldown or cascade,
+ * TK_MAKE_MENU_POPUP means it is a popup.
+ * TK_MAKE_MENU_TEAROFF means menu is always
+ * visible, e.g. as a torn-off menu.
* Determines whether save_under and
- * override_redirect should be set. */
+ * override_redirect should be set, plus how
+ * to flag it for the window manager. */
{
WmInfo *wmPtr;
XSetWindowAttributes atts;
@@ -6668,20 +6676,25 @@ TkpMakeMenuWindow(
CreateWrapper(wmPtr);
}
wrapperPtr = wmPtr->wrapperPtr;
- if (transient) {
- atts.override_redirect = True;
- atts.save_under = True;
- atom = Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU");
- } else {
+ if (typeFlag == TK_MAKE_MENU_TEAROFF) {
atts.override_redirect = False;
atts.save_under = False;
atom = Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE_MENU");
TkSetTransientFor(tkwin, NULL);
+ } else {
+ atts.override_redirect = True;
+ atts.save_under = True;
+ if (typeFlag == TK_MAKE_MENU_DROPDOWN) {
+ atom = Tk_InternAtom((Tk_Window) tkwin,
+ "_NET_WM_TYPE_DROPDOWN_MENU");
+ } else {
+ atom = Tk_InternAtom((Tk_Window) tkwin,
+ "_NET_WM_WINDOW_TYPE_POPUP_MENU");
+ }
}
XChangeProperty(Tk_Display(tkwin), wrapperPtr->window,
- Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE"),
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &atom, 1);
+ Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE"),
+ XA_ATOM, 32, PropModeReplace, (unsigned char *) &atom, 1);
/*
* The override-redirect and save-under bits must be set on the wrapper
@@ -6792,7 +6805,7 @@ CreateWrapper(
*/
Tk_CreateEventHandler((Tk_Window) wmPtr->wrapperPtr,
- WrapperEventMask, WrapperEventProc, (ClientData) wmPtr);
+ WrapperEventMask, WrapperEventProc, wmPtr);
}
/*
@@ -6861,9 +6874,13 @@ TkUnixSetMenubar(
Tk_Window parent;
TkWindow *menubarPtr = (TkWindow *) menubar;
- /* Could be a Frame (i.e. not a toplevel) */
- if (wmPtr == NULL)
+ /*
+ * Could be a Frame (i.e. not a toplevel).
+ */
+
+ if (wmPtr == NULL) {
return;
+ }
if (wmPtr->menubar != NULL) {
/*
@@ -6885,7 +6902,7 @@ TkUnixSetMenubar(
Tk_WindowId(wmPtr->menubar), Tk_WindowId(parent), 0, 0);
}
Tk_DeleteEventHandler(wmPtr->menubar, StructureNotifyMask,
- MenubarDestroyProc, (ClientData) wmPtr->menubar);
+ MenubarDestroyProc, wmPtr->menubar);
Tk_ManageGeometry(wmPtr->menubar, NULL, NULL);
}
@@ -6911,14 +6928,14 @@ TkUnixSetMenubar(
menubarPtr->wmInfoPtr = wmPtr;
Tk_MoveResizeWindow(menubar, 0, 0, Tk_Width(tkwin), wmPtr->menuHeight);
Tk_MapWindow(menubar);
- Tk_CreateEventHandler(menubar, StructureNotifyMask, MenubarDestroyProc,
- (ClientData) menubar);
- Tk_ManageGeometry(menubar, &menubarMgrType, (ClientData) wmPtr);
+ Tk_CreateEventHandler(menubar, StructureNotifyMask,
+ MenubarDestroyProc, menubar);
+ Tk_ManageGeometry(menubar, &menubarMgrType, wmPtr);
menubarPtr->flags |= TK_REPARENTED;
}
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) tkwin);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, tkwin);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -6957,7 +6974,7 @@ MenubarDestroyProc(
wmPtr->menuHeight = 0;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) wmPtr->winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, wmPtr->winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}
@@ -6985,7 +7002,7 @@ MenubarReqProc(
* for tkwin's toplevel. */
Tk_Window tkwin) /* Handle for menubar window. */
{
- WmInfo *wmPtr = (WmInfo *) clientData;
+ WmInfo *wmPtr = clientData;
wmPtr->menuHeight = Tk_ReqHeight(tkwin);
if (wmPtr->menuHeight <= 0) {
@@ -6993,7 +7010,7 @@ MenubarReqProc(
}
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, (ClientData) wmPtr->winPtr);
+ Tcl_DoWhenIdle(UpdateGeometryInfo, wmPtr->winPtr);
wmPtr->flags |= WM_UPDATE_PENDING;
}
}