Re: mouse not dragging a float window.

Eric S Fraga <[email protected]> Thu, 01 Sep 2022 15:26:25 +0100
Newsgroups gmane.comp.window-managers.stumpwm.devel
Organization On the Interweb somewhere
Message-ID <[email protected]>
Hello all,

Just in case anybody is interested, for completeness, below is the
equivalent code for resizing floating windows using the keyboard.  I now
no longer care about mouse support whether with :super or whatever! ;-)

eric

--8<---------------cut here---------------start------------->8---
;; function to resize windows around using the keyboard, similar to
;; the moving of windows defined just above.  The esf-resize-window
;; function adjusts the width and height of the current window by the
;; number of pixels given.  The function is invoked by the keystrokes
;; in the interactive keymap, esf-resize, which is called up by
;; invoking it as a command.  Finally, I map C-t R to esf-resize.  The
;; function & keymap could be improved by giving some visual feedback
;; to indicate that we are still in a move operation but I don't know
;; how to do that (yet).

(defcommand (esf-resize-window float-group) (dw dh)
  ((:number "dW = ") (:number "dH = "))
  (let* ((window (current-window))
         (parent (window-parent window))
         (w (xlib:drawable-width parent))
         (h (xlib:drawable-height parent)))
    (float-window-move-resize window
                              :width (+ w dw)
                              :height (- (+ h dh) ;desired height
                                         ;; but correct height to
                                         ;; ignore title bar height
                                         *float-window-title-height*))))

(defun esf-resize-setup ())
;; the actual interactive keymap for resizing the window.   )Default is
;; 10 pixels in either direction or 100 with Shift on the same keys.
;; I use arrow and vi resizement keys.
(define-interactive-keymap (esf-resize float-group)
    (:on-enter #'esf-resize-setup)
  ((kbd "Up") "esf-resize-window 0 -10")
  ((kbd "S-Up") "esf-resize-window 0 -100")
  ((kbd "k") "esf-resize-window 0 -10")
  ((kbd "K") "esf-resize-window 0 -100")
  ((kbd "Down") "esf-resize-window 0 10")
  ((kbd "S-Down") "esf-resize-window 0 100")
  ((kbd "j") "esf-resize-window 0 10")
  ((kbd "J") "esf-resize-window 0 100")
  ((kbd "Left") "esf-resize-window -10 0")
  ((kbd "S-Left") "esf-resize-window -100 0")
  ((kbd "h") "esf-resize-window -10 0")
  ((kbd "H") "esf-resize-window -100 0")
  ((kbd "Right") "esf-resize-window 10 0")
  ((kbd "S-Right") "esf-resize-window 100 0")
  ((kbd "l") "esf-resize-window 10 0")
  ((kbd "L") "esf-resize-window 100 0"))

;; bind the interactive keymap to a key in the float group
(define-key stumpwm::*float-group-root-map* (kbd "R")  "esf-resize")
--8<---------------cut here---------------end--------------->8---

-- 
Eric S Fraga via gnus (Emacs 29.0.50 2022-08-16) on Debian 11.4