From 76075c217d62ae600da3460ef62687966d6e3fbc Mon Sep 17 00:00:00 2001 From: Philippe Brochard Date: Thu, 7 Jun 2012 23:49:01 +0200 Subject: [PATCH] (define-toolbar-hooks): Add auto-hide toolbar (show/hide on mouse motion event). --- ChangeLog | 2 ++ contrib/toolbar.lisp | 37 +++++++++++++++++++++++++++++-------- src/clfswm-internal.lisp | 3 ++- src/xlib-util.lisp | 1 + 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index acaf844..e0ffc64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * contrib/toolbar.lisp (define-toolbar-hooks): Add auto-hide clickable toolbar. + (define-toolbar-hooks): Add auto-hide toolbar (show/hide on mouse + motion event). 2012-06-06 Philippe Brochard diff --git a/contrib/toolbar.lisp b/contrib/toolbar.lisp index 9df8750..1e6552e 100644 --- a/contrib/toolbar.lisp +++ b/contrib/toolbar.lisp @@ -146,6 +146,8 @@ (use-event-hook :exposure) (use-event-hook :button-press) +(use-event-hook :motion-notify) +(use-event-hook :leave-notify) (defun toolbar-add-exposure-hook (toolbar) @@ -170,10 +172,27 @@ (stop-button-event) (throw 'exit-handle-event nil))))))) +(defun toolbar-add-hide-motion-hook (toolbar) + (define-event-hook :motion-notify (root-x root-y) + (unless (compress-motion-notify) + (when (toolbar-in-sensibility-zone-p toolbar root-x root-y) + (map-window (toolbar-window toolbar)) + (raise-window (toolbar-window toolbar)) + (refresh-toolbar toolbar) + (throw 'exit-handle-event nil))))) + +(defun toolbar-add-hide-leave-hook (toolbar) + (define-event-hook :leave-notify (window) + (when (xlib:window-equal (toolbar-window toolbar) window) + (hide-window window) + (throw 'exit-handle-event nil)))) + (defun define-toolbar-hooks (toolbar) (toolbar-add-exposure-hook toolbar) (case (toolbar-autohide toolbar) - (:click (toolbar-add-hide-button-press-hook toolbar)))) + (:click (toolbar-add-hide-button-press-hook toolbar)) + (:motion (toolbar-add-hide-motion-hook toolbar) + (toolbar-add-hide-leave-hook toolbar)))) @@ -222,7 +241,7 @@ :border (when (plusp (toolbar-border-size toolbar)) (get-color *toolbar-window-border*)) :colormap (xlib:screen-default-colormap *screen*) - :event-mask '(:exposure :key-press)) + :event-mask '(:exposure :key-press :leave-window)) (toolbar-gc toolbar) (xlib:create-gcontext :drawable (toolbar-window toolbar) :foreground (get-color *toolbar-window-foreground*) :background (get-color *toolbar-window-background*) @@ -231,10 +250,11 @@ (push (toolbar-window toolbar) windows-list) (setf (window-transparency (toolbar-window toolbar)) *toolbar-window-transparency*) (push (list #'is-toolbar-window-p nil) *never-managed-window-list*) - (unless (toolbar-autohide toolbar) - (map-window (toolbar-window toolbar)) - (raise-window (toolbar-window toolbar)) - (refresh-toolbar toolbar)) + (map-window (toolbar-window toolbar)) + (raise-window (toolbar-window toolbar)) + (refresh-toolbar toolbar);) + (when (toolbar-autohide toolbar) + (hide-window (toolbar-window toolbar))) (xlib:display-finish-output *display*) (define-toolbar-hooks toolbar)))))))) @@ -250,7 +270,8 @@ (close-toolbar toolbar))) -(defun add-toolbar (root-x root-y direction size placement &rest modules) +(defun add-toolbar (root-x root-y direction size placement modules + &key (autohide *toolbar-default-autohide*)) "Add a new toolbar. root-x, root-y: root coordinates direction: one of :horiz or :vert @@ -259,7 +280,7 @@ :direction direction :size size :thickness *toolbar-default-thickness* :placement placement - :autohide *toolbar-default-autohide* + :autohide autohide :refresh-delay *toolbar-default-refresh-delay* :border-size *toolbar-default-border-size* :modules modules))) diff --git a/src/clfswm-internal.lisp b/src/clfswm-internal.lisp index 2606087..a3017d6 100644 --- a/src/clfswm-internal.lisp +++ b/src/clfswm-internal.lisp @@ -1488,7 +1488,8 @@ managed." (wm-state (window-state win))) (unless (or (eql (xlib:window-override-redirect win) :on) (eql win *no-focus-window*) - (is-notify-window-p win)) + (is-notify-window-p win) + (never-managed-window-p win)) (when (or (eql map-state :viewable) (eql wm-state +iconic-state+)) (format t "Processing ~S: type=~A ~S~%" (xlib:wm-name win) (window-type win) win) diff --git a/src/xlib-util.lisp b/src/xlib-util.lisp index b77ad4c..a1731ad 100644 --- a/src/xlib-util.lisp +++ b/src/xlib-util.lisp @@ -36,6 +36,7 @@ :colormap-change :focus-change :enter-window + :leave-window :exposure) "The events to listen for on managed windows.") -- 2.11.4.GIT