emacs-exwm / exwm

Emacs X Window Manager
https://elpa.gnu.org/packages/exwm.html
GNU General Public License v3.0
278 stars 14 forks source link

EXWM 0.31 positions frames in a really weird way when with multiple monitors #81

Closed qespr closed 1 month ago

qespr commented 1 month ago

Probably not a xelb problem since 0.30 depended on xelb 0.20 as well and things kinda worked.

I have 6 monitors, after updating to EXWM 0.31, frames start positioned with significant offset instead of abiding by command in exwm-randr-screen-change-hook. This used to sometimes happen in 0.28, and 0.30 but could be fixed by moving some monitor slightly in arandr (some race condition?). This workaround no longer works in 0.31 and Emacs frames move in really weird directions, almost random it seems.

I have them ordered as shown in the picture which works (almost) flawlessly in EXWM 0.28 and 0.30 workingLayout

The command (also generated by arandr) is: xrandr --output DVI-D-0 --mode 1920x1080 --pos 1680x0 --rotate normal --output HDMI-0 --mode 1600x900 --pos 3600x180 --rotate normal --output HDMI-1 --primary --mode 1920x1080 --pos 1680x1080 --rotate normal --output DP-0 --off --output DP-1 --off --output DP-2 --mode 1366x768 --pos 314x312 --rotate normal --output DP-3 --off --output VGA-1-0 --mode 1920x1080 --pos 3600x1080 --rotate normal --output DVI-1-0 --mode 1680x1050 --pos 0x1080 --rotate normal

Sometimes EXWM 0.28 and 0.30 also started broken like this: screenshotBroken28 But after moving some screen in arandr, it corrected itself: Screenshot28Fixed With 0.31 it is no longer the case, frames are positioned in very weird places: broken3 broken2 broken4

Here is minimal config that works for all monitors in EXWM 0.30

(require 'package)
(package-initialize)
(setq user-emacs-directory "/home/{user}/.microWm/")
(setq user-init-file "/home/{user}/.microWm/init.el")

(add-to-list 'package-archives
         '("melpa" . "https://melpa.org/packages/") t)

(require 'exwm)
(require 'exwm-randr)

(setq exwm-workspace-number 12)
(setq current-randr-command "xrandr --output DVI-D-0 --mode 1920x1080 --pos 1680x0 --rotate normal --output HDMI-0 --mode 1600x900 --pos 3600x180 --rotate normal --output HDMI-1 --primary --mode 1920x1080 --pos 1680x1080 --rotate normal --output DP-0 --off --output DP-1 --off --output DP-2 --mode 1366x768 --pos 314x312 --rotate normal --output DP-3 --off --output VGA-1-0 --mode 1920x1080 --pos 3600x1080 --rotate normal --output DVI-1-0 --mode 1680x1050 --pos 0x1080 --rotate normal")
(setq exwm-randr-workspace-monitor-plist '(0 "DVI-1-0" ;Fujistsu left bottom 1680x1650
                      1 "DVI-1-0"
                      2 "HDMI-1" ;Fujistsu center bottom FHD
                      3 "HDMI-1"
                      4 "VGA-1-0" ;Hp right bottom FHD
                      5 "VGA-1-0"
                      6 "DP-2"    ;AOC left top 1366x768
                      7 "DP-2"
                      8 "DVI-D-0" ;Acer center top FHD
                      9 "DVI-D-0"
                      10 "HDMI-0" ;Benq right top 1600x900
                      11 "HDMI-0"
                      ))
(add-hook 'exwm-randr-screen-change-hook
          (lambda ()
            (start-process-shell-command
         "xrandr" nil current-randr-command)))
(exwm-randr-mode 1)
;;(exwm-randr-enable) ;;for 0.30 and lower
;; Disable menu-bar, tool-bar and scroll-bar to increase the usable space.
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

(ido-mode 1)
(setq ido-show-dot-for-dired t)

;; Global keybindings can be defined with `exwm-input-global-keys'.
(setq exwm-input-global-keys
      `(
        ;; Bind "s-r" to exit char-mode and fullscreen mode.
        ([?\s-r] . exwm-reset)
        ;; Bind "s-w" to switch workspace interactively.
        ([?\s-w] . exwm-workspace-switch)
        ;; Bind "s-&" to launch applications ('M-&' also works if the output
        ;; buffer does not bother you).
        (,(kbd "s-;") . (lambda (command)
              (interactive (list (read-shell-command "$ ")))
              (start-process-shell-command command nil command)))))
(exwm-enable)

(custom-set-variables
 '(package-selected-packages '(exwm xelb compat)))
(custom-set-faces
 )

I checked the docs and I don't think anything should be changed except for enabling the minor mode.

Emacs version: "29.3" EXWM: 0.31 Xelb: 0.20 Package installed from elpa Os: GNU/Linux Mint 21.2

Stebalien commented 1 month ago

Are you using any compositors (picom)?

qespr commented 1 month ago

No, honestly I didn't even know what compositor was until I looked it up now. But I can give it a try if it might help.

Stebalien commented 1 month ago

Nah, I just brought it up because the latest release of picom had a bug that sounded like what you described.

I'm not really sure what change in EXWM could have caused, this, to be honest.

qespr commented 1 month ago

Are you seeing any warnings/messages?

If you mean some warning/error buffer then no

What if you connect just one external monitor? To external monitors?

Well they're all external, it's a desktop, but weird things happen. With one screen only it works fine but there is a fat black line on the bottom.

When I use just 2 monitors with same resolution next to to each other, everything is fine, I can put them both on the left or right. correct1 But if I put them above each other, one frame is gone and the monitor is just black: wrong2 And with HDMI-1 on top (frame with arandr is gone somewhere): wrongAbove This still makes some kind of sense, but when I put them next to each other and cover one with the other a little, the one that's higher will cut off the lower one by the amount of overlap cutoff When I put them all next to each other, the order is broken and some get cut off: nope If I keep only 3 monitors, all with same resolution and next to each other it's also broken (result the same with any order of monitors) 3fucked2

Stebalien commented 1 month ago

What happens if you run the following snippet?

(dolist (frame (frame-list))
  (when-let ((geo (frame-parameter frame 'exwm-geometry)))
    (redisplay t)
    (with-slots (width height) geo
      (set-frame-size frame
                      (- width (frame-fringe-width frame))
                      (- height (tab-bar-height frame t)) t))))

I'm asking because I've seen some issues where Emacs will fail to properly make frames full-screen.

Stebalien commented 1 month ago

The most relevant changes in 0.31 were dd9c11125f5f917076ac2d6cec955f837c387891 and dad0668fc8162effe5eb66d821606ad80484484f.

So, what happens if you call exwm-randr-refresh? I'm wondering if this is related to issues receiving randr events.

qespr commented 1 month ago

What happens if you run the following snippet?

Nothing

So, what happens if you call exwm-randr-refresh? I'm wondering if this is related to issues receiving randr events.

Yup, everything is fixed and seems to be working. I feel like I should have thought of that. It really seems that the issue will be receiving randr events. Thanks very much for help, I don't know what I'd do without EXWM.

In case anyone would need it, I put this my init:

(run-with-timer 5 nil #'exwm-randr-refresh)
Stebalien commented 1 month ago

Re-opening because this is definitely a bug.

Stebalien commented 1 month ago

Actually, could you test with https://github.com/emacs-exwm/exwm/commit/f00b5ca655a0471a10d21a3e75b1a442a8d28941? Just evaling the modified exwm-randr--on-Notify function should be enough.

qespr commented 1 month ago

Works perfectly and when put into init, WM starts correctly right away

Stebalien commented 1 month ago

@minad how would you feel about a 0.32 release?

minad commented 1 month ago

@Stebalien Great, so it turns out that this issue has already been fixed. Tagging a new release 0.32 sounds good. EXWM seems solid in its current form. I can do this later today.

minad commented 1 month ago

Done: