stumpwmでfloating windowを使う

今のstumpwmのバージョンは0.9.8

いつからかstumpwmでfloating windowが使えるようになってた
floating windowはfloating groupの中で使える

gnew-floatコマンドでfloating groupを作る
フレームをマウスの左ボタンで移動、右ボタンで大きさの変更が出来る

色々と機能が足りない
このバージョンとgithubの最新のコードを見るにまだ作りかけらしい

このままだと不便だからキーボードから簡易的な操作を出来るようにした

(in-package :stumpwm)

(defun win-left ()
  0)

(defun win-top ()
  (let ((mode-line (head-mode-line (current-head))))
    (if mode-line
        (mode-line-height mode-line)
        0)))

(defun win-right ()
  (- (screen-width (current-screen))
     (window-width (current-window))))

(defun win-bottom ()
  (- (screen-height (current-screen))
     (window-height (current-window))))

(defcommand move-topleft () ()
            "ウィンドウを左上に移動"
            (float-window-move-resize (current-window)
                                      :x (win-left)
                                      :y (win-top)))

(defcommand move-topright () ()
            "ウィンドウを右上に移動"
            (float-window-move-resize (current-window)
                                      :x (win-right)
                                      :y (win-top)))

(defcommand move-bottomleft () ()
            "ウィンドウを左下に移動"
            (float-window-move-resize (current-window)
                                      :x (win-left)
                                      :y (win-bottom)))

(defcommand move-bottomright () ()
            "ウィンドウを右下に移動"
            (float-window-move-resize (current-window)
                                      :x (win-right)
                                      :y (win-bottom)))

(let ((toggle)
      x
      y
      width
      height)
  (defcommand maximum-window () ()
              "ウィンドウを最大化"
              (let ((window (current-window)))
                (cond (toggle
                       (float-window-move-resize
                        window
                        :x x
                        :y y
                        :width width
                        :height height))
                      (t
                       (setq x (window-x window))
                       (setq y (window-y window))
                       (setq width (window-width window))
                       (setq height (window-height window))
                       (when (< (screen-width (current-screen))
                                (+ x width))
                         (setf (window-width window)
                               (- (screen-width (current-screen)) x)))
                       (when (< (screen-height (current-screen))
                                (+ y height))
                         (setf (window-height window)
                               (- (screen-height (current-screen)) y)))
                       (let ((new-x (win-left))
                             (new-y (win-top)))
                         (float-window-move-resize
                          window
                          :x new-x
                          :y new-y
                          :width (- (screen-width (current-screen)) new-x)
                          :height (- (screen-height (current-screen))
                                     12
                                     new-y)))))
                (setq toggle (not toggle)))))


(define-key *top-map* (kbd "s-y") "move-topleft")
(define-key *top-map* (kbd "s-u") "move-topright")
(define-key *top-map* (kbd "s-b") "move-bottomleft")
(define-key *top-map* (kbd "s-n") "move-bottomright")
(define-key *top-map* (kbd "s-x") "maximum-window")

superキーとy,u,b,nでウィンドウを端に移動
superキーとxで画面を最大化、最大化しているときは元に戻すようにしている