[PATCH 1/2] Bugfix in x-cycle.jl. Previously the focus change by pointer motion was ignored after x-cycle. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/sawfish Archives
]
- Subject: [PATCH 1/2] Bugfix in x-cycle.jl. Previously the focus change by pointer motion was ignored after x-cycle.
- From: Teika kazura <teika@xxxxxxx>
- Date: Fri, 6 Mar 2015 10:04:20 +0900
This was due to the use of timer; Librep's timer is not a thread, but related to event-loop in an esoteric manner.
---
lisp/sawfish/wm/commands/x-cycle.jl | 11 ++++++-----
lisp/sawfish/wm/focus.jl | 24 +++++++++++++++++-------
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/lisp/sawfish/wm/commands/x-cycle.jl b/lisp/sawfish/wm/commands/x-cycle.jl
index 47c579a..3a48736 100644
--- a/lisp/sawfish/wm/commands/x-cycle.jl
+++ b/lisp/sawfish/wm/commands/x-cycle.jl
@@ -289,15 +289,16 @@
(catch 'x-cycle-exit
;; do the first step
(cycle-next windows step)
- (setq focus-ignore-pointer-events t)
+ ;; Record current time + 0.1 sec.
+ (setq focus-xcycle-timestamp
+ (cons (current-time)
+ (+ 100000 (current-utime))))
+
(recursive-edit))
(when (fluid x-cycle-current)
(display-window (fluid x-cycle-current))))
(remove-message)
- (ungrab-keyboard)
- (make-timer (lambda ()
- (setq focus-ignore-pointer-events nil))
- 0 100)))))
+ (ungrab-keyboard)))))
(when tail-command
;; make sure that the command operates on the newly-focused
diff --git a/lisp/sawfish/wm/focus.jl b/lisp/sawfish/wm/focus.jl
index 3ca0886..3e1ec93 100644
--- a/lisp/sawfish/wm/focus.jl
+++ b/lisp/sawfish/wm/focus.jl
@@ -16,7 +16,7 @@
;; You should have received a copy of the GNU General Public License
;; along with sawfish; see the file COPYING. If not, write to
-;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301 USA.
(define-structure sawfish.wm.focus
@@ -62,10 +62,20 @@
:type boolean
:group focus)
-
- ;; Only used by x-cycle.jl
- (defvar focus-ignore-pointer-events nil
- "When true, pointer in/out events don't cause focus changes.")
+ (defvar focus-xcycle-timestamp (cons (current-time) (current-utime))
+ ;; current-utime can overflow librep's integer, which is 30-bit if minimal.
+ ;; To be safe, current-time is used, too.
+ "Used only to support x-cycle.jl.")
+
+ (define (ignore-pointer-events)
+ ;; Only necessary to support x-cycle.jl
+ ;; Returns t if current-time is later than focus-xcycle-timestamp
+ (prog1
+ (and focus-xcycle-timestamp
+ (or (> (current-utime) (cdr focus-xcycle-timestamp))
+ (time-later-p (current-time) (car focus-xcycle-timestamp))
+ ))
+ (setq focus-xcycle-timestamp nil)))
(define focus-within-click-event (make-fluid nil)
"When true, the current command is being called from within
@@ -253,14 +263,14 @@ EVENT-NAME)', where EVENT-NAME may be one of the following symbols:
;;; hooks
(define (focus-enter-fun w mode)
- (unless focus-ignore-pointer-events
+ (unless (ignore-pointer-events)
(cond ((desktop-window-p w)
(focus-invoke-mode w 'enter-root mode))
((windowp w)
(focus-invoke-mode w 'pointer-in mode)))))
(define (focus-leave-fun w mode)
- (unless focus-ignore-pointer-events
+ (unless (ignore-pointer-events)
(cond ((desktop-window-p w)
(focus-invoke-mode w 'leave-root mode))
((windowp w)
--
2.0.4
----Next_Part(Fri_Mar_13_16_04_14_2015_728)----
--
Sawfish ML