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

Split window X application windows #22

Open
ethanmoss1 opened this issue Feb 26, 2024 · 5 comments
Open

Split window X application windows #22

ethanmoss1 opened this issue Feb 26, 2024 · 5 comments

Comments

@ethanmoss1
Copy link

ethanmoss1 commented Feb 26, 2024

The issue I have currently is that when running my interactive function to split a window and then switch to the other window it seems to flip the buffers and keep the focus on the original X window.

The function doesn't do anything crazy, its just does what I would normally do with 2 keybindings but in one. The funny thing is if I run these two commands using M-x split-window-* RET and M-x other-window RET it works how you would expect it.

Also other function such as 'find-file-other-window' work fine when focused on an X Application.

(defun split-window-right-and-focus ()
  (interactive)
  (split-window-right)
  (other-window 1))

I've used other split window function in place but all seem to have the same issue.

(F) = user focus

+-------------------+                                      +-------------------+
|                   |                                      |        |          |
|         (F)       |                                      |        |    (F)   |
|     x window      | --> Split-window-right-and-focus --> | buffer | x window |
|                   |                                      |        |          |
|                   |                                      |        |          |
+-------------------+                                      +-------------------+

Understandably you cant have two windows of the same X application but the movement of the window should be the same as any other buffer?

Currently I've fixed this 'issue' my amending the function to check the major mode an act accordingly. Annoyingly I have to now switch to the other window myself, oh the horror!.

(defun split-window-right-and-focus ()
  (interactive)
    (if (string-equal major-mode "exwm-mode")
        (split-window-right)
      (split-window-right)
      (other-window 1)))
@Stebalien
Copy link
Contributor

I can confirm. It should leave the X window behind. I'm guessing this is a "time of check" bug in the EXWM focusing logic. If you run (progn (split-window-right) (sit-for 0.1) (other-window 1)) it works just fine.

@ethanmoss1
Copy link
Author

ethanmoss1 commented Feb 26, 2024

Thanks, I've updated my personal function. If anyone's interested I've changed it to the following.

(defun split-window-right-and-focus ()
  (interactive)
  (if (string-equal major-mode "exwm-mode")
      (progn
        (split-window-right)
        (sit-for 0.1)
        (other-window 1))
    (split-window-right)
    (other-window 1)))

I can see this issue potentially cropping up again with anyone trying manipulate windows quickly, Ill close this as completed for now.

EDIT: use this instead;

(defun split-window-right-and-focus ()
  (interactive)
    (split-window-right)
    (redisplay)
    (other-window 1))

@Stebalien
Copy link
Contributor

Awesome! But this is definitely a bug so I'm going to leave it open till we can fix it.

@Stebalien Stebalien reopened this Feb 26, 2024
@nagy
Copy link

nagy commented Feb 28, 2024

This might save you 100ms : ch11ng/exwm#685 (comment)

@ethanmoss1
Copy link
Author

This might save you 100ms : ch11ng/exwm#685 (comment)

Thank you, I've updated the function with the redisplay workaround

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

3 participants