diff --git a/scheme/xlib/wm.scm b/scheme/xlib/wm.scm index b9760fd..6d9cefe 100644 --- a/scheme/xlib/wm.scm +++ b/scheme/xlib/wm.scm @@ -201,3 +201,35 @@ (import-lambda-definition %set-pointer-mapping (Xdisplay map) "scx_Set_Pointer_Mapping") + +;; WM_STATE property + +(define (get-wm-state window) + (let* ((dpy (window-display window)) + (a (intern-atom dpy "WM_STATE")) + (v.t.f (get-property window a #f))) + (if (and v.t.f + (eq? (cadr v.t.f) a) + (>= (vector-length (car v.t.f)) 2)) + (let ((v (car v.t.f))) + (list (integer->wm-state (vector-ref v 0)) + (make-window (vector-ref v 1) dpy #f))) + #f))) + +(define (set-wm-state window wm-state icon-window) + (let* ((dpy (window-display window)) + (a (intern-atom dpy "WM_STATE"))) + (change-property window a a 32 + (list->vector (list (wm-state->integer wm-state) + (window-Xwindow icon-window)))))) + +(define-enumerated-type wm-state :wm-state + wm-state? wm-states wm-state-name wm-state-index + (withdrawn normal wm-state-2 iconic)) + +(define (integer->wm-state i) + (vector-ref wm-states i)) + +(define (wm-state->integer s) + (wm-state-index s)) +