>From 12655a3b44d818e393f7b94cc1e51758b1f3b8fd Mon Sep 17 00:00:00 2001 From: Raffael Mancini Date: Wed, 4 Feb 2009 11:31:39 +0100 Subject: [PATCH] Enable rsizing windows in float group by dragging on bottom right corner Implemented window resizing by pressing button-3 on the window decoration Now using *min-frame-width variables and made simplifications Removed obsolete variable bump --- floating-group.lisp | 78 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 46 insertions(+), 32 deletions(-) diff --git a/floating-group.lisp b/floating-group.lisp index 3722b9e..05e64e1 100644 --- a/floating-group.lisp +++ b/floating-group.lisp @@ -182,38 +182,52 @@ (cond ;; Was the click on the window decoration? ((or (< x (xlib:drawable-x (window-xwin window))) - (> x (+ (xlib:drawable-width (window-xwin window)) - (xlib:drawable-x (window-xwin window)))) - (< y (xlib:drawable-y (window-xwin window))) - (> y (+ (xlib:drawable-height (window-xwin window)) - (xlib:drawable-y (window-xwin window))))) - (multiple-value-bind (relx rely) (xlib:query-pointer (window-parent window)) - (labels ((move-window-event-handler (&rest event-slots &key event-key &allow-other-keys) - (case event-key - (:button-release - :done) - (:motion-notify - (with-slots (parent) window - (xlib:with-state (parent) - (setf (xlib:drawable-x parent) (- (getf event-slots :x) relx) - (xlib:drawable-y parent) (- (getf event-slots :y) rely)))) - t)))) - (xlib:grab-pointer (screen-root screen) '(:button-release :pointer-motion)) - (unwind-protect - ;; Wait until the mouse button is released - (loop for ev = (xlib:process-event *display* - :handler #'move-window-event-handler - :timeout nil - :discard-p t) - until (eq ev :done)) - (ungrab-pointer)) - ;; don't forget to update the cache - (setf (window-x window) (xlib:drawable-x (window-parent window)) - (window-y window) (xlib:drawable-y (window-parent window))))))))) - - - - + (> x (+ (xlib:drawable-width (window-xwin window)) + (xlib:drawable-x (window-xwin window)))) + (< y (xlib:drawable-y (window-xwin window))) + (> y (+ (xlib:drawable-height (window-xwin window)) + (xlib:drawable-y (window-xwin window))))) + (multiple-value-bind (relx rely same-screen-p child state-mask) (xlib:query-pointer (window-parent window)) + (let ((initial-width (xlib:drawable-width (slot-value window 'parent))) + (initial-height (xlib:drawable-height (slot-value window 'parent)))) + (labels ((move-window-event-handler (&rest event-slots &key event-key &allow-other-keys) + (case event-key + (:button-release + :done) + (:motion-notify + (with-slots (parent) window + (xlib:with-state (parent) + ;; Either move or resize the window + (cond + ((find :button-1 (xlib:make-state-keys state-mask)) + (setf (xlib:drawable-x parent) (- (getf event-slots :x) relx) + (xlib:drawable-y parent) (- (getf event-slots :y) rely))) + ((find :button-3 (xlib:make-state-keys state-mask)) + (let ((w (+ initial-width + (- (getf event-slots :x) + relx + (xlib:drawable-x parent)))) + (h (+ initial-height + (- (getf event-slots :y) + rely + (xlib:drawable-y parent) + *float-window-title-height*)))) + ;; Don't let the window become too small + (float-window-move-resize window + :width (max w *min-frame-width*) + :height (max h *min-frame-height*))))))))))) + (xlib:grab-pointer (screen-root screen) '(:button-release :pointer-motion)) + (unwind-protect + ;; Wait until the mouse button is released + (loop for ev = (xlib:process-event *display* + :handler #'move-window-event-handler + :timeout nil + :discard-p t) + until (eq ev :done)) + (ungrab-pointer)) + ;; don't forget to update the cache + (setf (window-x window) (xlib:drawable-x (window-parent window)) + (window-y window) (xlib:drawable-y (window-parent window)))))))))) (defmethod group-button-press ((group float-group) x y where) (declare (ignore x y where)) -- 1.6.4