about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--exwm-input.el44
-rw-r--r--exwm-manage.el20
2 files changed, 37 insertions, 27 deletions
diff --git a/exwm-input.el b/exwm-input.el
index 042467b96125..eb287925a5a7 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -114,7 +114,14 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
   (when exwm-input--focus-window
     (with-current-buffer (window-buffer exwm-input--focus-window)
       (if (eq major-mode 'exwm-mode)
-          (progn
+          (if (not (eq exwm--frame exwm-workspace--current))
+              ;; Do not focus X windows on other workspace
+              (progn
+                (set-frame-parameter exwm--frame 'exwm--urgency t)
+                (setq exwm-workspace--switch-history-outdated t)
+                (force-mode-line-update)
+                ;; The application may have changed its input focus
+                (exwm-workspace-switch exwm-workspace-current-index t))
             (when exwm--floating-frame
               (redirect-frame-focus exwm--floating-frame nil)
               (select-frame-set-input-focus exwm--floating-frame t))
@@ -180,7 +187,9 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
              (exwm-floating--start-moveresize event))
             (t
              ;; Click to focus
-             (select-window (get-buffer-window (exwm--id->buffer event) t))
+             (let ((window (get-buffer-window (exwm--id->buffer event) t)))
+               (unless (eq window (selected-window))
+                 (select-window window)))
              ;; The event should be replayed
              (setq mode xcb:Allow:ReplayPointer))))
     (xcb:+request exwm--connection
@@ -360,21 +369,22 @@ It's updated in several occasions, and only used by `exwm-input--set-focus'.")
          (keycode (xcb:keysyms:keysym->keycode exwm--connection (car keysym)))
          (id (exwm--buffer->id (window-buffer (selected-window)))))
     (when keycode
-      (xcb:+request exwm--connection
-          (make-instance 'xcb:SendEvent
-                         :propagate 0 :destination id
-                         :event-mask xcb:EventMask:NoEvent
-                         :event (xcb:marshal
-                                 (make-instance 'xcb:KeyPress
-                                                :detail keycode
-                                                :time xcb:Time:CurrentTime
-                                                :root exwm--root :event id
-                                                :child 0
-                                                :root-x 0 :root-y 0
-                                                :event-x 0 :event-y 0
-                                                :state (cadr keysym)
-                                                :same-screen 1)
-                                 exwm--connection))))
+      (dolist (class '(xcb:KeyPress xcb:KeyRelease))
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:SendEvent
+                           :propagate 0 :destination id
+                           :event-mask xcb:EventMask:NoEvent
+                           :event (xcb:marshal
+                                   (make-instance class
+                                                  :detail keycode
+                                                  :time xcb:Time:CurrentTime
+                                                  :root exwm--root :event id
+                                                  :child 0
+                                                  :root-x 0 :root-y 0
+                                                  :event-x 0 :event-y 0
+                                                  :state (cadr keysym)
+                                                  :same-screen 1)
+                                   exwm--connection)))))
     (xcb:flush exwm--connection)))
 
 ;;;###autoload
diff --git a/exwm-manage.el b/exwm-manage.el
index e7682cda88e1..d83fc447d632 100644
--- a/exwm-manage.el
+++ b/exwm-manage.el
@@ -145,16 +145,16 @@ corresponding buffer.")
           (make-instance 'xcb:ConfigureWindow
                          :window id :value-mask xcb:ConfigWindow:BorderWidth
                          :border-width 0))
-      (xcb:+request exwm--connection ;grab buttons for set focus/move/resize
-          (make-instance 'xcb:GrabButton
-                         :owner-events 0 :grab-window id
-                         :event-mask xcb:EventMask:ButtonPress
-                         :pointer-mode xcb:GrabMode:Sync
-                         :keyboard-mode xcb:GrabMode:Async
-                         :confine-to xcb:Window:None
-                         :cursor xcb:Cursor:None
-                         :button xcb:ButtonIndex:Any
-                         :modifiers xcb:ModMask:Any))
+      (dolist (button       ;grab buttons to set focus / move / resize
+               (list xcb:ButtonIndex:1 xcb:ButtonIndex:2 xcb:ButtonIndex:3))
+        (xcb:+request-checked+request-check exwm--connection
+            (make-instance 'xcb:GrabButton
+                           :owner-events 0 :grab-window id
+                           :event-mask xcb:EventMask:ButtonPress
+                           :pointer-mode xcb:GrabMode:Sync
+                           :keyboard-mode xcb:GrabMode:Async
+                           :confine-to xcb:Window:None :cursor xcb:Cursor:None
+                           :button button :modifiers xcb:ModMask:Any)))
       (xcb:+request exwm--connection    ;update _NET_CLIENT_LIST
           (make-instance 'xcb:ewmh:set-_NET_CLIENT_LIST
                          :window exwm--root