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

  1. Updated patch for bug 2864685, with feedback and code from patthoyts.
  2. Menus shows sensible behaviour in both normal and tornoff states now.
  3. Patch against HEAD.
  4.  
  5. Index: unix/tkUnixWm.c
  6. ===================================================================
  7. RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixWm.c,v
  8. retrieving revision 1.74
  9. diff -u -r1.74 tkUnixWm.c
  10. --- unix/tkUnixWm.c 24 Nov 2009 15:06:23 -0000 1.74
  11. +++ unix/tkUnixWm.c 7 Dec 2009 19:16:52 -0000
  12. @@ -6604,6 +6604,19 @@
  13. *maxHeightPtr = tmp;
  14. }
  15. }
  16. +
  17. +void
  18. +TkSetTransientFor(Tk_Window tkwin, Tk_Window parent)
  19. +{
  20. + if (parent == NULL) {
  21. + parent = Tk_Parent(tkwin);
  22. + while (!Tk_IsTopLevel(parent))
  23. + parent = Tk_Parent(tkwin);
  24. + }
  25. + XSetTransientForHint(Tk_Display(tkwin),
  26. + ((TkWindow *)tkwin)->wmInfoPtr->wrapperPtr->window,
  27. + ((TkWindow *)parent)->wmInfoPtr->wrapperPtr->window);
  28. +}
  29.  
  30. /*
  31. *----------------------------------------------------------------------
  32. @@ -6634,6 +6647,7 @@
  33. WmInfo *wmPtr;
  34. XSetWindowAttributes atts;
  35. TkWindow *wrapperPtr;
  36. + Atom atom;
  37.  
  38. if (!Tk_HasWrapper(tkwin)) {
  39. return;
  40. @@ -6646,10 +6660,17 @@
  41. if (transient) {
  42. atts.override_redirect = True;
  43. atts.save_under = True;
  44. + atom = Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU");
  45. } else {
  46. atts.override_redirect = False;
  47. atts.save_under = False;
  48. + atom = Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE_MENU");
  49. + TkSetTransientFor(tkwin, NULL);
  50. }
  51. + XChangeProperty(Tk_Display(tkwin), wrapperPtr->window,
  52. + Tk_InternAtom((Tk_Window) tkwin, "_NET_WM_WINDOW_TYPE"),
  53. + XA_ATOM, 32, PropModeReplace,
  54. + (unsigned char *) &atom, 1);
  55.  
  56. /*
  57. * The override-redirect and save-under bits must be set on the wrapper
  58.