mirror of
https://github.com/ch11ng/exwm.git
synced 2024-11-27 13:07:59 +01:00
Warp mouse pointer only when necessary.
Remove last call to `exwm--make-emacs-idle-for'. Remove `exwm--make-emacs-idle-for'. Should close https://github.com/ch11ng/exwm/issues/39.
This commit is contained in:
parent
5222dc17d6
commit
f1b6eb3382
4 changed files with 30 additions and 25 deletions
|
@ -258,7 +258,7 @@
|
||||||
(with-slots (root-x root-y win-x win-y)
|
(with-slots (root-x root-y win-x win-y)
|
||||||
(xcb:+request-unchecked+reply exwm--connection
|
(xcb:+request-unchecked+reply exwm--connection
|
||||||
(make-instance 'xcb:QueryPointer :window id))
|
(make-instance 'xcb:QueryPointer :window id))
|
||||||
(select-frame-set-input-focus frame) ;raise and focus it
|
(exwm-workspace--select-frame frame)
|
||||||
(setq width (frame-pixel-width frame)
|
(setq width (frame-pixel-width frame)
|
||||||
height (frame-pixel-height frame))
|
height (frame-pixel-height frame))
|
||||||
(unless type
|
(unless type
|
||||||
|
|
|
@ -117,13 +117,12 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
|
||||||
(progn
|
(progn
|
||||||
(when exwm--floating-frame
|
(when exwm--floating-frame
|
||||||
(redirect-frame-focus exwm--floating-frame nil)
|
(redirect-frame-focus exwm--floating-frame nil)
|
||||||
(select-frame-set-input-focus exwm--floating-frame t))
|
(exwm-workspace--select-frame exwm--floating-frame t))
|
||||||
(exwm--log "Set focus on #x%x" exwm--id)
|
(exwm--log "Set focus on #x%x" exwm--id)
|
||||||
(exwm-input--set-focus exwm--id))
|
(exwm-input--set-focus exwm--id))
|
||||||
(when (eq (selected-window) exwm-input--focus-window)
|
(when (eq (selected-window) exwm-input--focus-window)
|
||||||
(exwm--log "Focus on %s" exwm-input--focus-window)
|
(exwm--log "Focus on %s" exwm-input--focus-window)
|
||||||
(select-frame-set-input-focus (window-frame exwm-input--focus-window)
|
(exwm-workspace--select-frame (window-frame exwm-input--focus-window) t)
|
||||||
t)
|
|
||||||
(dolist (pair exwm--id-buffer-alist)
|
(dolist (pair exwm--id-buffer-alist)
|
||||||
(with-current-buffer (cdr pair)
|
(with-current-buffer (cdr pair)
|
||||||
(when (and exwm--floating-frame
|
(when (and exwm--floating-frame
|
||||||
|
|
|
@ -88,10 +88,32 @@
|
||||||
(defvar exwm-workspace--current nil "Current active workspace.")
|
(defvar exwm-workspace--current nil "Current active workspace.")
|
||||||
(defvar exwm-workspace-current-index 0 "Index of current active workspace.")
|
(defvar exwm-workspace-current-index 0 "Index of current active workspace.")
|
||||||
|
|
||||||
(defun exwm-workspace-switch (index &optional force)
|
(defun exwm-workspace--select-frame (frame &optional norecord)
|
||||||
|
;; Move mouse when necessary
|
||||||
|
(let* ((position (mouse-pixel-position))
|
||||||
|
(x (+ (cadr position) (car (frame-position (car position)))))
|
||||||
|
(y (+ (cddr position) (cdr (frame-position (car position)))))
|
||||||
|
(edges (frame-edges frame)))
|
||||||
|
(if (or (not (memq frame exwm-workspace--list))
|
||||||
|
(and x
|
||||||
|
(>= x (nth 0 edges))
|
||||||
|
(> (nth 2 edges) x)
|
||||||
|
(>= y (nth 1 edges))
|
||||||
|
(> (nth 3 edges) y)))
|
||||||
|
(progn (select-frame frame)
|
||||||
|
(raise-frame frame)
|
||||||
|
(x-focus-frame frame))
|
||||||
|
(select-frame-set-input-focus frame norecord)
|
||||||
|
(when (or (>= x (nth 2 edges)) (>= y (nth 3 edges)))
|
||||||
|
(setq x (/ (- (nth 2 edges) (nth 0 edges)) 2)
|
||||||
|
y (/ (- (nth 3 edges) (nth 1 edges)) 2))
|
||||||
|
(set-mouse-pixel-position frame x y)))))
|
||||||
|
|
||||||
|
(defun exwm-workspace-switch (index &optional force selected)
|
||||||
"Switch to workspace INDEX. Query for INDEX if it's not specified.
|
"Switch to workspace INDEX. Query for INDEX if it's not specified.
|
||||||
|
|
||||||
The optional FORCE option is for internal use only."
|
The optional FORCE option is for internal use only. The optional
|
||||||
|
SELECTED option indicates that the frame is already selected."
|
||||||
(interactive
|
(interactive
|
||||||
(list
|
(list
|
||||||
(unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
|
(unless (and (eq major-mode 'exwm-mode) exwm--fullscreen) ;it's invisible
|
||||||
|
@ -110,19 +132,8 @@ The optional FORCE option is for internal use only."
|
||||||
(let ((frame (elt exwm-workspace--list index)))
|
(let ((frame (elt exwm-workspace--list index)))
|
||||||
(setq exwm-workspace--current frame
|
(setq exwm-workspace--current frame
|
||||||
exwm-workspace-current-index index)
|
exwm-workspace-current-index index)
|
||||||
(select-frame-set-input-focus frame)
|
(unless selected
|
||||||
;; Move mouse when necessary
|
(exwm-workspace--select-frame frame))
|
||||||
(let ((position (mouse-pixel-position))
|
|
||||||
x y w h)
|
|
||||||
(unless (eq frame (car position))
|
|
||||||
(setq x (cadr position)
|
|
||||||
y (cddr position)
|
|
||||||
w (frame-pixel-width frame)
|
|
||||||
h (frame-pixel-height frame))
|
|
||||||
(when (or (> x w) (> y h))
|
|
||||||
(setq x (/ w 2)
|
|
||||||
y (/ h 2)))
|
|
||||||
(set-mouse-pixel-position frame x y)))
|
|
||||||
(setq default-minibuffer-frame frame)
|
(setq default-minibuffer-frame frame)
|
||||||
;; Hide windows in other workspaces by preprending a space
|
;; Hide windows in other workspaces by preprending a space
|
||||||
(dolist (i exwm--id-buffer-alist)
|
(dolist (i exwm--id-buffer-alist)
|
||||||
|
@ -135,7 +146,6 @@ The optional FORCE option is for internal use only."
|
||||||
(set-frame-parameter frame 'exwm--urgency nil)
|
(set-frame-parameter frame 'exwm--urgency nil)
|
||||||
;; Update switch workspace history
|
;; Update switch workspace history
|
||||||
(exwm-workspace--update-switch-history)
|
(exwm-workspace--update-switch-history)
|
||||||
(exwm--make-emacs-idle-for 0.1) ;FIXME
|
|
||||||
;; Update _NET_CURRENT_DESKTOP
|
;; Update _NET_CURRENT_DESKTOP
|
||||||
(xcb:+request exwm--connection
|
(xcb:+request exwm--connection
|
||||||
(make-instance 'xcb:ewmh:set-_NET_CURRENT_DESKTOP
|
(make-instance 'xcb:ewmh:set-_NET_CURRENT_DESKTOP
|
||||||
|
@ -148,7 +158,7 @@ The optional FORCE option is for internal use only."
|
||||||
(exwm--log "Focus on workspace %s" index)
|
(exwm--log "Focus on workspace %s" index)
|
||||||
(when (and index (/= index exwm-workspace-current-index))
|
(when (and index (/= index exwm-workspace-current-index))
|
||||||
(exwm--log "Workspace was switched unexpectedly")
|
(exwm--log "Workspace was switched unexpectedly")
|
||||||
(exwm-workspace-switch index))))
|
(exwm-workspace-switch index nil t))))
|
||||||
|
|
||||||
(defun exwm-workspace-move-window (index &optional id)
|
(defun exwm-workspace-move-window (index &optional id)
|
||||||
"Move window ID to workspace INDEX."
|
"Move window ID to workspace INDEX."
|
||||||
|
|
4
exwm.el
4
exwm.el
|
@ -187,10 +187,6 @@
|
||||||
xcb:EventMask:SubstructureRedirect)))
|
xcb:EventMask:SubstructureRedirect)))
|
||||||
(xcb:flush exwm--connection))
|
(xcb:flush exwm--connection))
|
||||||
|
|
||||||
(defun exwm--make-emacs-idle-for (seconds)
|
|
||||||
"Put Emacs in idle state for SECONDS seconds."
|
|
||||||
(with-timeout (seconds) (read-event)))
|
|
||||||
|
|
||||||
(defun exwm-reset ()
|
(defun exwm-reset ()
|
||||||
"Reset window to standard state: non-fullscreen, line-mode."
|
"Reset window to standard state: non-fullscreen, line-mode."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Reference in a new issue