Posted to tcl by emiliano at Mon Dec 07 19:23:29 GMT 2009view pretty

Updated patch for bug 2864685, with feedback and code from patthoyts.
Menus shows sensible behaviour in both normal and tornoff states now.
Patch against HEAD.

Index: unix/tkUnixWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixWm.c,v
retrieving revision 1.74
diff -u -r1.74 tkUnixWm.c
--- unix/tkUnixWm.c	24 Nov 2009 15:06:23 -0000	1.74
+++ unix/tkUnixWm.c	7 Dec 2009 19:16:52 -0000
@@ -6604,6 +6604,19 @@
 	*maxHeightPtr = tmp;
     }
 }
+
+void
+TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
+{
+   if (parent == NULL) {
+   parent = Tk_Parent(tkwin);
+   while (!Tk_IsTopLevel(parent))
+       parent = Tk_Parent(tkwin);
+    }
+    XSetTransientForHint(Tk_Display(tkwin),
+        ((TkWindow *)tkwin)->wmInfoPtr->wrapperPtr->window,
+        ((TkWindow *)parent)->wmInfoPtr->wrapperPtr->window);
+}
 
 /*
  *----------------------------------------------------------------------
@@ -6634,6 +6647,7 @@
     WmInfo *wmPtr;
     XSetWindowAttributes atts;
     TkWindow *wrapperPtr;
+    Atom atom;
 
     if (!Tk_HasWrapper(tkwin)) {
 	return;
@@ -6646,10 +6660,17 @@
     if (transient) {
 	atts.override_redirect = True;
 	atts.save_under = True;
+	atom = Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU");
     } else {
 	atts.override_redirect = False;
 	atts.save_under = False;
+	atom = Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE_MENU");
+	TkSetTransientFor(tkwin, NULL);
     }
+    XChangeProperty(Tk_Display(tkwin), wrapperPtr->window,
+    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