;; iconfiy-window send a WM_CHANGE_STATE message (in an appropiate ;; format), to the root window of the specified screen. See ;; XIconifyWindow. (define (iconify-window window screen-number) (check-screen-number (window-display window) screen-number) (if (not (%iconify-window (display-Xdisplay (window-display window)) (window-Xwindow window) screen-number)) (error "cannot iconify window" window))) (import-lambda-definition %iconify-window (Xdisplay Xwindow scr-num) "scx_Iconify_Window") ;; withdraw-window unmaps the specified window and sends a synthetic ;; UnmapNotify event to the root window of the specified screen. See ;; XWithdrawWindow. (define (withdraw-window window screen-number) (check-screen-number screen-number) (if (not (%withdraw-window (display-Xdisplay (window-display window)) (window-Xwindow window) screen-number)) (error "cannot withdraw window" window))) (import-lambda-definition %withdraw-window (Xdisplay Xwindow scr-num) "scx_Withdraw_Window") ;; reconfigure-wm-window change attributes of the specified window ;; similar to configure-window, or sends a ConfigureRequestEvent to ;; the root window if that fails. See XReconfigureWMWindow. See ;; configure-window. (define (reconfigure-wm-window window screen-number . args) (check-screen-number screen-number) (if (not (%reconfigure-wm-window (display-Xdisplay (window-display window)) (window-Xwindow window) screen-number (named-args->alist args))) (error "cannot reconfigure window" window))) (import-lambda-definition %reconfigure-wm-window (Xdisplay Xwindow scrnum alist) "scx_Reconfigure_Wm_Window") ;; wm-command reads the WM_COMMAND property from the specified window ;; and returns is as a list of strings. See XGetCommand. (define (wm-command window) (vector->list (%wm-command (display-Xdisplay (window-display window)) (window-Xwindow window)))) (import-lambda-definition %wm-command (Xdisplay Xwindow) "scx_Wm_Command") ;; set-wm-command! sets the WM_COMMAND property (the command and ;; arguments used to invoke the application). The command has to be ;; specified as a list of string or symbols. See XSetCommand. (define (set-wm-command! window command) (%set-wm-command! (display-Xdisplay (window-display window)) (window-Xwindow window) (list->vector (map (lambda (x) (if (symbol? x) (symbol->string x) x)) command)))) (import-lambda-definition %set-wm-command (Xdisplay Xwindow command) "scx_Set_Wm_Command") ;; get-text-property returns the property specified by atom of the ;; specified window as a list of strings. See XGetTextProperty. (define (get-text-property window atom) (let ((res (%get-text-property (display-Xdisplay (window-display window)) (window-Xwindow window) (atom-Xatom atom)))) (cond ((eq? res #t) #f) ((eq? res #f) (error "cannot create string list from text property")) (else (vector->list res))))) (import-lambda-definition %get-text-property (Xdisplay Xwindow Xatom) "scx_Get_Text_Property") ;; set-text-property! sets the property specified by atom of the ;; specified window to value - a list of strings or symbols. (define (set-text-property! window value atom) (let ((res (%set-text-property! (display-Xdisplay (window-display window)) (window-Xwindow window) (list->vector value) (atom-Xatom atom)))) (if res res (error "cannot create text property from string list" value)))) (import-lambda-definition %set-text-property! (Xdisplay Xwindow value XAtom) "scx_Set_Text_Property") ;; wm-protocols function returns the list of atoms stored in the ;; WM_PROTOCOLS property on the specified window. These atoms describe ;; window manager protocols in which the owner of this window is ;; willing to participate. See XGetWMProtocols. (define (wm-protocols window) (let ((res (%wm-protocols (display-Xdisplay (window-display window)) (window-Xwindow window)))) (if res (map make-atom (vector->list res)) (error "cannot get WM protocols")))) (import-lambda-definition %wm-protocols (Xdisplay Xwindow) "scx_Wm_Protocols") ;; set-wm-protocols! sets the WM_PROTOCOLS property of the specified ;; window. protocols has to be a list of atoms. See XSetWMProtocols. (define (set-wm-protocols! window protocols) (let ((res (%set-wm-protocols! (display-Xdisplay (window-display window)) (window-Xwindow window) (list->vector (map atom-Xatom protocols))))) (if res res (error "cannot set WM protocols" protocols)))) (import-lambda-definition %set-wm-protocols! (Xdisplay Xwindow protocols) "scx_Set_Wm_Protocols") ;; wm-class returns the class hint for the specified window. See ;; XGetClassHint. (define (wm-class window) (let ((res (%wm-class (display-Xdisplay (window-display window)) (window-Xwindow window)))) (if res res (error "cannot get WM class hint")))) (import-lambda-definition %wm-class (Xdisplay Xwindow) "scx_Wm_Class") ;; set-wm-class! sets the class hint for the specified window. See ;; XSetClassHint. (define (set-wm-class! window name class) (%set-wm-class! (display-Xdisplay (window-display window)) (window-Xwindow window) (if (symbol? name) (symbol->string name) name) (if (symbol? class) (symbol->string class) class))) (import-lambda-definition %set-wm-class! (Xdisplay Xwindow name class) "scx_Set_Wm_Class") ;; wm-hints reads the window manager hints and returns them as an ;; alist mapping symbols to specific values. The hints are: 'input? ;; 'initial-state 'icon-pixmap 'icon-window 'icon-x 'icon-y 'icon-mask ;; 'window-group 'urgency. See XGetWMHints for a description. (define (wm-hints window) (let ((res (%wm-hints (display-Xdisplay (window-display window)) (window-Xwindow window))) (make-window* (lambda (Xwindow) (if (null? Xwindow) Xwindow (make-window Xwindow (window-display window) #f)))) (make-pixmap* (lambda (Xpixmap) (if (null? Xpixmap) Xpixmap (make-pixmap Xpixmap (window-display window) #f))))) (vector-set! res 2 (make-pixmap* (vector-ref res 2))) (vector-set! res 3 (make-window* (vector-ref res 3))) (vector-set! res 6 (make-pixmap* (vector-ref res 6))) (vector-set! res 7 (make-window* (vector-ref res 7))) (map cons '(input? initial-state icon-pixmap icon-window icon-x icon-y icon-mask window-group urgency) (vector->list res)))) (import-lambda-definition %wm-hints (Xdisplay Xwindow) "scx_Wm_Hints") ;; set-wm-hints! sets the specified window manager hints. The hints ;; must be specified together with their names. Either by giving two ;; parameter 'name value, or the last argument may be an alist, as ;; returned by wm-hints. See XSetWMHints. (define (set-wm-hints! window . args) (%set-wm-hints! (display-Xdisplay (window-display window)) (window-Xwindow window) (map (lambda (p) (case (car p) ((icon-pixmap icon-mask) (cons (car p) (pixmap-Xpixmap (cdr p)))) ((icon-window window-group) (cons (car p) (window-Xwindow (cdr p)))) (else p))) (named-args->alist args)))) (import-lambda-definition %set-wm-hints! (Xdisplay Xwindow args) "scx_Set_Wm_Hints") ;; transient-for returns the WM_TRANSIENT_FOR property for the ;; specified window. The value of that property is a window. See ;; XGetTransientForHint. (define (transient-for window) (make-window (%transient-for (display-Xdisplay (display-window window)) (window-Xwindow window)) (window-display window) #f)) (import-lambda-definition %transient-for (Xdisplay Xwindow) "scx_Transient_For") ;; set-transient-for! sets the WM_TRANSIENT_FOR property of the ;; specified window to the specified property-window. See ;; XSetTransientForHint. (define (set-transient-for! window property-window) (%set-transient-for (display-Xdisplay (window-display window)) (window-Xwindow window) (window-Xwindow property-window))) (import-lambda-definition %set-transient-for! (Xdisplay Xwindow Xpropertywindow) "scx_Set_Transient_For") ;; The following function a wrappers for the get/set-text-property ;; function. (define xa-wm-name (make-atom 39)) (define xa-wm-icon-name (make-atom 37)) (define xa-wm-client-machine (make-atom 36)) (define (wm-name w) (get-text-property w xa-wm-name)) (define (wm-icon-name w) (get-text-property w xa-wm-icon-name)) (define (wm-client-machine w) (get-text-property w xa-wm-client-machine)) (define (set-wm-name! w s) (set-text-property! w s xa-wm-name)) (define (set-wm-icon-name! w s) (set-text-property! w s xa-wm-icon-name)) (define (set-wm-client-machine! w s) (set-text-property! w s xa-wm-client-machine)) ;; wm-normal-hints/set-wm-normal-hints! get or set the size hints ;; stored in the WM_NORMAL_HINTS property on the specified window. The ;; hints are '(x y width height us-position us-size min-width ;; min-height max-width max-height width-inc height-inc min-aspect-x ;; min-aspect-y max-aspect-x max-aspect-y base-width base-height ;; gravity). See XGetWMNormalHints, XSetWMNormalHints. (define (wm-normal-hints window) (let* ((v (%wm-normal-hints (display-Xdisplay (window-display window)) (window-Xwindow window))) (alist (map cons '(x y width height us-position us-size min-width min-height max-width max-height width-inc height-inc min-aspect-x min-aspect-y max-aspect-x max-aspect-y base-width base-height gravity) (vector->list v)))) alist)) (import-lambda-definition %wm-normal-hints (Xdisplay Xwindow) "scx_Wm_Normal_Hints") (define (set-wm-normal-hints! window . args) (let ((alist (named-args->alist args))) (%set-wm-normal-hints! (display-Xdisplay (window-Xwindow window)) (window-Xwindow window) alist))) (import-lambda-definition %set-wm-normal-hints (Xdisplay Xwindow alist) "scx_Set_Wm_Normal_Hints") ;; icon-sizes returns the icon sizes specified by a window manager as ;; a list. If no icon sizes are specified the list is empty. An icon ;; size itself is a list consisting of integers meaning '(min-width ;; min-height max-width max-height width-inc height-inc). See ;; XGetIconSizes. (define (icon-sizes window) (let ((r (%icon-sizes (display-Xdisplay (window-display window)) (window-Xwindow window)))) (map vector->list (vector->list r)))) (import-lambda-definition %icon-sizes (Xdisplay Xwindow) "scx_Icon_Sizes") ;; set-icon-sizes! is used only by window managers to set the ;; supported icon sizes. See icon-sizes, XSetIconSizes. (define (set-icon-sizes! window icon-sizes) (%set-icon-sizes! (display-Xdisplay (window-display window)) (window-Xwindow window) (list->vector (map list->vector icon-sizes)))) (import-lambda-definition %set-icon-sizes! (Xdisplay Xwindow sizes) "scx_Set_Icon_Sizes")