Posted to tcl by patthoyts at Wed Apr 09 13:26:48 GMT 2008view raw

  1. ? doc/man.macros
  2. Index: unix/tkUnixWm.c
  3. ===================================================================
  4. RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixWm.c,v
  5. retrieving revision 1.55
  6. diff -u -r1.55 tkUnixWm.c
  7. --- unix/tkUnixWm.c 27 Feb 2007 14:52:57 -0000 1.55
  8. +++ unix/tkUnixWm.c 27 Apr 2007 18:06:17 -0000
  9. @@ -350,6 +350,7 @@
  10. static void SetNetWmState(TkWindow*, const char *atomName, int on);
  11. static void CheckNetWmState(WmInfo *, Atom *atoms, int numAtoms);
  12. static void UpdateNetWmState(WmInfo *);
  13. +static void TkpWmSetDesktop(TkWindow *winPtr, int desktop);
  14. static void WaitForConfigureNotify(TkWindow *winPtr,
  15. unsigned long serial);
  16. static int WaitForEvent(Display *display,
  17. @@ -452,6 +453,9 @@
  18. Tcl_Interp *interp, int objc,
  19. Tcl_Obj *CONST objv[]);
  20. static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr);
  21. +static int WmDesktopCmd(Tk_Window tkwin, TkWindow *winPtr,
  22. + Tcl_Interp *interp, int objc,
  23. + Tcl_Obj *CONST objv[]);
  24.  
  25. /*
  26. *--------------------------------------------------------------
  27. @@ -998,7 +1002,7 @@
  28. Tk_Window tkwin = (Tk_Window) clientData;
  29. static CONST char *optionStrings[] = {
  30. "aspect", "attributes", "client", "colormapwindows",
  31. - "command", "deiconify", "focusmodel", "frame",
  32. + "command", "deiconify", "desktop", "focusmodel", "frame",
  33. "geometry", "grid", "group", "iconbitmap",
  34. "iconify", "iconmask", "iconname",
  35. "iconphoto", "iconposition",
  36. @@ -1008,8 +1012,8 @@
  37. "withdraw", NULL };
  38. enum options {
  39. WMOPT_ASPECT, WMOPT_ATTRIBUTES, WMOPT_CLIENT, WMOPT_COLORMAPWINDOWS,
  40. - WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_FOCUSMODEL, WMOPT_FRAME,
  41. - WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
  42. + WMOPT_COMMAND, WMOPT_DEICONIFY, WMOPT_DESKTOP, WMOPT_FOCUSMODEL,
  43. + WMOPT_FRAME, WMOPT_GEOMETRY, WMOPT_GRID, WMOPT_GROUP, WMOPT_ICONBITMAP,
  44. WMOPT_ICONIFY, WMOPT_ICONMASK, WMOPT_ICONNAME,
  45. WMOPT_ICONPHOTO, WMOPT_ICONPOSITION,
  46. WMOPT_ICONWINDOW, WMOPT_MAXSIZE, WMOPT_MINSIZE, WMOPT_OVERRIDEREDIRECT,
  47. @@ -1086,6 +1090,8 @@
  48. return WmCommandCmd(tkwin, winPtr, interp, objc, objv);
  49. case WMOPT_DEICONIFY:
  50. return WmDeiconifyCmd(tkwin, winPtr, interp, objc, objv);
  51. + case WMOPT_DESKTOP:
  52. + return WmDesktopCmd(tkwin, winPtr, interp, objc, objv);
  53. case WMOPT_FOCUSMODEL:
  54. return WmFocusmodelCmd(tkwin, winPtr, interp, objc, objv);
  55. case WMOPT_FRAME:
  56. @@ -1704,6 +1710,70 @@
  57. /*
  58. *----------------------------------------------------------------------
  59. *
  60. + * WmDesktopCmd --
  61. + *
  62. + * This function is invoked to process the "wm desktop" Tcl command.
  63. + * See the user documentation for details on what it does.
  64. + *
  65. + * Results:
  66. + * A standard Tcl result.
  67. + *
  68. + * Side effects:
  69. + * See the user documentation.
  70. + *
  71. + *----------------------------------------------------------------------
  72. + */
  73. +
  74. +static int
  75. +WmDesktopCmd(
  76. + Tk_Window tkwin, /* Main window of the application. */
  77. + TkWindow *winPtr, /* Toplevel to work with */
  78. + Tcl_Interp *interp, /* Current interpreter. */
  79. + int objc, /* Number of arguments. */
  80. + Tcl_Obj *CONST objv[]) /* Argument objects. */
  81. +{
  82. + register WmInfo *wmPtr = winPtr->wmInfoPtr;
  83. + int result = TCL_OK;
  84. +
  85. + if (objc < 3 || objc > 4) {
  86. + Tcl_WrongNumArgs(interp, 2, objv, "window desktop ?value?");
  87. + return TCL_ERROR;
  88. + }
  89. + if (objc == 4) {
  90. + int desktop = 0;
  91. + if (Tcl_GetIntFromObj(interp, objv[3], &desktop) != TCL_OK) {
  92. + return TCL_ERROR;
  93. + }
  94. + TkpWmSetDesktop(winPtr, desktop);
  95. + } else {
  96. + TkWindow *wrapperPtr = wmPtr->wrapperPtr;
  97. + Atom atom = Tk_InternAtom((Tk_Window)wmPtr->winPtr, "_NET_WM_DESKTOP");
  98. + Atom actualType;
  99. + int actualFormat;
  100. + unsigned long numItems, bytesAfter;
  101. + unsigned char *propertyValue = 0;
  102. + long maxLength = 1024;
  103. +
  104. + if (XGetWindowProperty(
  105. + wrapperPtr->display, wrapperPtr->window, atom,
  106. + 0l, maxLength, False, XA_CARDINAL,
  107. + &actualType, &actualFormat, &numItems, &bytesAfter,
  108. + &propertyValue) == Success) {
  109. + if ((actualType == XA_CARDINAL) && (actualFormat == 32) && (numItems == 1)) {
  110. + Tcl_SetObjResult(interp, Tcl_NewIntObj(*(int *)propertyValue));
  111. + } else {
  112. + Tcl_SetResult(interp, "invalid desktop property returned", TCL_STATIC);
  113. + result = TCL_ERROR;
  114. + }
  115. + XFree(propertyValue);
  116. + }
  117. + }
  118. + return result;
  119. +}
  120. +
  121. +/*
  122. + *----------------------------------------------------------------------
  123. + *
  124. * WmFocusmodelCmd --
  125. *
  126. * This function is invoked to process the "wm focusmodel" Tcl command.
  127. @@ -7020,6 +7090,48 @@
  128. }
  129.  
  130. /*
  131. + *----------------------------------------------------------------------
  132. + *
  133. + * TkpWmSetDesktop --
  134. + *
  135. + * Request the window manager to set the desktop for this window.
  136. + *
  137. + * Results:
  138. + * None
  139. + *
  140. + * Side effects:
  141. + * May cause the window to change desktops.
  142. + *
  143. + *----------------------------------------------------------------------
  144. + */
  145. +
  146. +static void
  147. +TkpWmSetDesktop(
  148. + TkWindow *winPtr,
  149. + int desktop)
  150. +{
  151. + Tk_Window tkwin = (Tk_Window)winPtr;
  152. + Atom messageType = Tk_InternAtom(tkwin, "_NET_WM_DESKTOP");
  153. + XEvent e;
  154. +
  155. + if (!winPtr->wmInfoPtr->wrapperPtr) {
  156. + return;
  157. + }
  158. +
  159. + e.xany.type = ClientMessage;
  160. + e.xany.window = winPtr->wmInfoPtr->wrapperPtr->window;
  161. + e.xclient.message_type = messageType;
  162. + e.xclient.format = 32;
  163. + e.xclient.data.l[0] = desktop;
  164. + e.xclient.data.l[1] = 0l;
  165. + e.xclient.data.l[2] = e.xclient.data.l[3] = e.xclient.data.l[4] = 0l;
  166. +
  167. + XSendEvent(winPtr->display,
  168. + RootWindow(winPtr->display, winPtr->screenNum), 0,
  169. + SubstructureNotifyMask|SubstructureRedirectMask, &e);
  170. +}
  171. +
  172. +/*
  173. * Local Variables:
  174. * mode: c
  175. * c-basic-offset: 4