client.scm 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. ;; *** manipulate toplevel windows ***********************************
  2. ;; iconfiy-window send a WM_CHANGE_STATE message (in an appropiate
  3. ;; format), to the root window of the specified screen. See
  4. ;; XIconifyWindow.
  5. ;; returns #f on error.
  6. (import-xlib-function iconify-window (display window screen-num)
  7. "scx_Iconify_Window")
  8. ;; withdraw-window unmaps the specified window and sends a synthetic
  9. ;; UnmapNotify event to the root window of the specified screen. See
  10. ;; XWithdrawWindow.
  11. ;; returns #f on error.
  12. (import-xlib-function withdraw-window (display window scr-num)
  13. "scx_Withdraw_Window")
  14. ;; reconfigure-wm-window changes attributes of the specified window
  15. ;; similar to configure-window, or sends a ConfigureRequestEvent to
  16. ;; the root window if that fails. See XReconfigureWMWindow. See
  17. ;; configure-window.
  18. ;; returns #f on error.
  19. (import-xlib-function reconfigure-wm-window
  20. (display window scr-num changes)
  21. "scx_Reconfigure_Wm_Window")
  22. ;; *** set or read a window's WM_* properties ************************
  23. ;; get-wm-command reads the WM_COMMAND property from the specified
  24. ;; window and returns it as a list of strings. See XGetCommand.
  25. ;; returns #f on error.
  26. (import-xlib-function get-wm-command (display window)
  27. "scx_Get_Wm_Command")
  28. ;; set-wm-command! sets the WM_COMMAND property (the command and
  29. ;; arguments used to invoke the application). The command has to be
  30. ;; specified as a list of strings. See XSetCommand.
  31. (import-xlib-function set-wm-command! (display window command)
  32. "scx_Set_Wm_Command")
  33. ;; get-wm-protocols function returns the list of atoms stored in the
  34. ;; WM_PROTOCOLS property on the specified window, or #f if this
  35. ;; property does not exist or has a bas format. These atoms describe
  36. ;; window manager protocols in which the owner of this window is
  37. ;; willing to participate. See XGetWMProtocols.
  38. ;; returns #f on error.
  39. (import-xlib-function get-wm-protocols (display window)
  40. "scx_Get_Wm_Protocols")
  41. ;; set-wm-protocols! sets the WM_PROTOCOLS property of the specified
  42. ;; window. protocols has to be a list of atoms. See XSetWMProtocols.
  43. ;; returns #f on error.
  44. (import-xlib-function set-wm-protocols! (display window protocols)
  45. "scx_Set_Wm_Protocols")
  46. ;; get-wm-class returns the class hint for the specified window. That
  47. ;; is a pair of strings (name . class) See XGetClassHint.
  48. ;; returns #f on error.
  49. (import-xlib-function get-wm-class (display window)
  50. "scx_Get_Wm_Class")
  51. ;; set-wm-class! sets the class hint for the specified window. See
  52. ;; XSetClassHint.
  53. ;; returns #f on error.
  54. (import-xlib-function set-wm-class! (display window name class)
  55. "scx_Set_Wm_Class")
  56. ;; *** set or read a window's WM_HINTS property **********************
  57. (define-enumerated-type initial-state :initial-state
  58. initial-state? initial-states initial-state-name initial-state-index
  59. (withdrawn normal initial-state-2 iconic initial-state-4))
  60. (define-exported-binding "scx-initial-state" :initial-state)
  61. (define-exported-binding "scx-initial-states" initial-states)
  62. (define-enumerated-type wm-hint :wm-hint
  63. wm-hint? wm-hints wm-hint-name wm-hint-index
  64. (input? initial-state icon-pixmap icon-window icon-position icon-mask
  65. window-group wm-hint-7 urgency))
  66. (define-exported-binding "scx-wm-hint" :wm-hint)
  67. (define-exported-binding "scx-wm-hints" wm-hints)
  68. (define-syntax make-wm-hint-alist
  69. (syntax-rules
  70. ()
  71. ((make-wm-hint-alist (attr arg) rest ...)
  72. (cons (cons (wm-hint attr) arg)
  73. (make-wm-hint-alist rest ...)))
  74. ((make-wm-hint-alist)
  75. '())))
  76. ;; get-wm-hints reads the window manager hints and returns them as an
  77. ;; alist mapping wm-hint types to specific values. See wm-hint. See
  78. ;; XGetWMHints for a description.
  79. (import-xlib-function get-wm-hints (display window)
  80. "scx_Get_Wm_Hints")
  81. ;; set-wm-hints! sets the specified window manager hints. The hints
  82. ;; must be specified as an alist of wm-hint values (see above) mapping
  83. ;; to the appropiate values. See XSetWMHints.
  84. (import-xlib-function set-wm-hints! (display window wm-hint-alist)
  85. "scx_Set_Wm_Hints")
  86. ;; get-transient-for returns the WM_TRANSIENT_FOR property for the
  87. ;; specified window. The value of that property is a window. See
  88. ;; XGetTransientForHint.
  89. (import-xlib-function get-transient-for (display window)
  90. "scx_Get_Transient_For")
  91. ;; set-transient-for! sets the WM_TRANSIENT_FOR property of the
  92. ;; specified window to the specified property-window. See
  93. ;; XSetTransientForHint.
  94. (import-xlib-function set-transient-for! (display window prop_window)
  95. "scx_Set_Transient_For")
  96. ;; get-text-property returns the property specified by atom of the
  97. ;; specified window as a property record. See get-window-property. See
  98. ;; XGetTextProperty.
  99. (import-xlib-function get-text-property (display window atom)
  100. "scx_Get_Text_Property")
  101. ;; set-text-property! sets the property specified by atom of the
  102. ;; specified window to value - a property record.
  103. (import-xlib-function set-text-property! (display window value atom)
  104. "scx_Set_Text_Property")
  105. (define (property->string-list property)
  106. (string->string-list (property:data property)))
  107. (define xa-string 31) ;; defined in Xatom.h
  108. (define (string-list->property strings)
  109. (make-property xa-string (property-format char)
  110. (string-list->string strings)))
  111. ;; The following function a wrappers for the get/set-text-property
  112. ;; function.
  113. (define xa-wm-name 39)
  114. (define xa-wm-icon-name 37)
  115. (define xa-wm-client-machine 36)
  116. (define (get-wm-name display w)
  117. (get-text-property display w xa-wm-name))
  118. (define (get-wm-icon-name display w)
  119. (get-text-property display w xa-wm-icon-name))
  120. (define (get-wm-client-machine display w)
  121. (get-text-property display w xa-wm-client-machine))
  122. (define (set-wm-name! display w s)
  123. (set-text-property! display w s xa-wm-name))
  124. (define (set-wm-icon-name! display w s)
  125. (set-text-property! display w s xa-wm-icon-name))
  126. (define (set-wm-client-machine! display w s)
  127. (set-text-property! display w s xa-wm-client-machine))
  128. ;; an enumerated type for XSizeHints used by get-wm-normal-hints and
  129. ;; set-wm-normal-hints!
  130. (define-enumerated-type size-hint :size-hint
  131. size-hint?
  132. size-hints
  133. size-hint-name
  134. size-hint-index
  135. ;; aspect should have the form ((min-x . min-y) . (max-x . max-y))
  136. ;; for win-gravity see gravity in create-window.
  137. ;; the other hints must be pairs of integers - (x . y) or (width . height)
  138. ;; us-position, us-size .....!!??
  139. (us-position us-size position size min-size max-size resize-inc aspect
  140. base-size win-gravity))
  141. (define-exported-binding "scx-size-hint" :size-hint)
  142. (define-exported-binding "scx-size-hints" size-hints)
  143. (define-syntax make-size-hint-alist
  144. (syntax-rules
  145. ()
  146. ((make-size-hint-alist (attr arg) rest ...)
  147. (cons (cons (size-hint attr) arg)
  148. (make-size-hint-alist rest ...)))
  149. ((make-size-hint-alist)
  150. '())))
  151. ;; get-wm-normal-hints/set-wm-normal-hints! get or set the size hints
  152. ;; stored in the WM_NORMAL_HINTS property on the specified window. The
  153. ;; hints are '(x y width height us-position us-size min-width
  154. ;; min-height max-width max-height width-inc height-inc min-aspect-x
  155. ;; min-aspect-y max-aspect-x max-aspect-y base-width base-height
  156. ;; gravity). See XGetWMNormalHints, XSetWMNormalHints.
  157. (import-xlib-function get-wm-normal-hints (display window)
  158. "scx_Get_Wm_Normal_Hints")
  159. (import-xlib-function set-wm-normal-hints! (display window alist)
  160. "scx_Set_Wm_Normal_Hints")
  161. ;; get-icon-sizes returns the icon sizes specified by a window manager
  162. ;; as a list. See XGetIconSizes.
  163. (define-record-type icon-size :icon-size
  164. (make-icon-size min-width min-height max-width max-height width-inc
  165. height-inc)
  166. icon-size?
  167. (min-width icon-size:min-width set-icon-size:min-width!)
  168. (min-height icon-size:min-height set-icon-size:min-height!)
  169. (max-width icon-size:max-width set-icon-size:max-width!)
  170. (max-height icon-size:max-height set-icon-size:max-height!)
  171. (width-inc icon-size:width-inc set-icon-size:width-inc!)
  172. (height-inc icon-size:height-inc set-icon-size:height-inc!))
  173. (define-exported-binding "scx-icon-size" :icon-size)
  174. (import-xlib-function get-icon-sizes (display window)
  175. "scx_Get_Icon_Sizes")
  176. ;; set-icon-sizes! is used only by window managers to set the
  177. ;; supported icon sizes. See icon-sizes, XSetIconSizes.
  178. (import-xlib-function set-icon-sizes! (display window sizes)
  179. "scx_Set_Icon_Sizes")