Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse doesn't work in normal-state #1

Open
walseb opened this issue Jun 2, 2020 · 3 comments
Open

Mouse doesn't work in normal-state #1

walseb opened this issue Jun 2, 2020 · 3 comments

Comments

@walseb
Copy link
Owner

walseb commented Jun 2, 2020

As mentioned here, mouse clicks don't work in normal-state. This is because normal-state in this package runs this: (setq-local exwm-input-line-mode-passthrough t) which disables all exwm binds. The solution to this would be to send fake mouse presses in exwm-firefox-evil-mode-map when clicking, etc.

I will put this issue on my todo list as it has annoyed me too, so it will probably be fixed in a week or two. In the meantime, if anyone wants to submit a pull request for this, please do!

@lucasgruss
Copy link

Hi,
First of all thanks for writing this package !
As for sending fake mouse clicks, a discussion can be found here. While this could be a possible solution, I believe it might be simpler to advise the function mouse-drag-region before the call with (setq exwm-input-line-mode-passthrough nil) then advise with (setq exwm-input-line-mode-passthrough t) after it.

What is your opinion on the issue ?
I'll try to give it a go and send a pull request if I manage to fix it

@walseb
Copy link
Owner Author

walseb commented Jun 10, 2020

Yeah that sounds like a better solution but does mouse-drag-region block until the user is done dragging? If so simply wrapping it inside a unwind-protect should work. Otherwise you would have to run the exwm-input-line-mode-passthrough setters after a start-drag and a end-drag event, which is risky because what if end-drag never happens? For example if keyboard-quit is fired while dragging or any other reason why the end event was never sent to emacs. Then the user would have (setq exwm-input-line-mode-passthrough t) in normal mode which is very confusing. I guess I just don't know how the mouse functions work in emacs, but feel free to submit a PR so I can take a look

@lucasgruss
Copy link

Hi,
it's been a little while but I managed to find a hack around this issue, but it involves EXWM itself and not EXWM-firefox, so I would not consider this issue fixed.

In exwm-input.el, changing the definition of exwm-input--on-ButtonPress-line-mode to :

(defun exwm-input--on-ButtonPress-line-mode (buffer button-event)
  "Handle button events in line mode.
BUFFER is the `exwm-mode' buffer the event was generated
on. BUTTON-EVENT is the X event converted into an Emacs event.

The return value is used as event_mode to release the original
button event."
  (with-current-buffer buffer
    (let ((read-event (exwm-input--mimic-read-event button-event)))
      (exwm--log "%s" read-event)
      (if (and read-event
               (exwm-input--event-passthrough-p read-event))
          ;; The event should be forwarded to emacs
          (progn
            (exwm-input--cache-event read-event)
            (exwm-input--unread-event button-event)

            xcb:Allow:ReplayPointer)
        ;; The event should be replayed
        xcb:Allow:ReplayPointer))))

does the trick. So xcb:Allow:SyncPointer was swapped with xcb:Allow:ReplayPointer in the (if case then else).

Pros :

  • quick fix
  • mouse works perfectly (no need to handle button release)

Cons :

  • necessary to modify EXWM itself
  • echo area still shows "mouse-drag-region must be bound to an event with parameters"
  • it removes the possibility to pass mouse click to emacs

I will try to improve the solution or even submit an issue to the exwm folks when I have a little more free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants