From 6868caad6daa5d3f688394e7df9e5cf8139b52ca Mon Sep 17 00:00:00 2001 From: sakurawald Date: Mon, 9 Dec 2024 12:14:17 +0800 Subject: [PATCH] feature: add `clickable` parameter for `window`. + let the `popup-window` made by `popup-message` un-clickable. --- src/ext/popup-message.lisp | 3 +++ src/ext/popup-window.lisp | 2 ++ src/mouse.lisp | 3 +-- src/window/window.lisp | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ext/popup-message.lisp b/src/ext/popup-message.lisp index 38e29043c..c3ee466a9 100644 --- a/src/ext/popup-message.lisp +++ b/src/ext/popup-message.lisp @@ -33,6 +33,9 @@ :buffer buffer :width width :height height + ;; NOTE: Simply ban the mouse-click event for a popup-window, to avoid the popup-window gain the mouse focus, being the only window as current-window in window-tree, causing lem unable to delete it. + ;; However, since the popup-message is a window used to display string, you can still use mouse-scroll to scroll the text. + :clickable nil :style style))) (buffer-start (window-view-point window)) (window-see window) diff --git a/src/ext/popup-window.lisp b/src/ext/popup-window.lisp index 6789c055b..f910c9979 100644 --- a/src/ext/popup-window.lisp +++ b/src/ext/popup-window.lisp @@ -308,6 +308,7 @@ (buffer (alexandria:required-argument :buffer)) (width (alexandria:required-argument :width)) (height (alexandria:required-argument :height)) + (clickable t) style) (let* ((style (ensure-style style)) (border-size (if (style-use-border style) +border-size+ 0)) @@ -335,6 +336,7 @@ :border-shape (style-shape style) :background-color (style-background-color style) :cursor-invisible (style-cursor-invisible style) + :clickable clickable :style style)))) (defun update-popup-window (&key (source-window (alexandria:required-argument :source-window)) diff --git a/src/mouse.lisp b/src/mouse.lisp index 61d8af326..2af09a253 100644 --- a/src/mouse.lisp +++ b/src/mouse.lisp @@ -179,8 +179,7 @@ (mouse-event-x mouse-event) (mouse-event-y mouse-event)) (when (and window - ;; NOTE: Simply ban the mouse-click event for a popup-window, to avoid the popup-window gain the mouse focus, being the only window as current-window in window-tree, causing lem unable to delete it. - (not (typep window 'lem/popup-window::popup-window))) + (window-clickable window)) (handle-mouse-button-down (window-buffer window) mouse-event :window window diff --git a/src/window/window.lisp b/src/window/window.lisp index 45e5627ae..c5d500066 100644 --- a/src/window/window.lisp +++ b/src/window/window.lisp @@ -105,6 +105,10 @@ (deleted :initform nil :accessor window-deleted-p) + (clickable + :initarg :clickable + :initform t + :reader window-clickable) (parameters :initform nil :accessor window-parameters)))