Tk Source Code

Artifact [a132a971]
Login

Artifact a132a9717afffe99db456b03719a11d23a908cab:

Attachment "menu.patch" to ticket [2864685f] added by dkf 2009-12-08 16:30:03.
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