ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

Floating windows are too big #771

Open loafofpiecrust opened 4 years ago

loafofpiecrust commented 4 years ago

When I get floating dialogs, they start out the correct size in the center of the screen. Then, without any interaction they resize to the size of the whole frame (around 1920x1080) with the top-left corner still in place, making floating windows a terrible pain to use. Could this be related to #214? How should I debug this? Maybe there's a hook that I have resetting the window size.

I'm using DOOM with EXWM, and managing workspaces only with persp, rather than separate frames. Emacs version: observed on 27.0.90 and native-comp (28.0.50)

dakra commented 4 years ago

Just wanted to add that I had the same issue but for me it only happened with the Emacs 28 native-comp branch and that is actually the reason why I'm back right now on the "normal" Emacs 28 master branch and not native-comp.

loafofpiecrust commented 4 years ago

Alright! I built Emacs master and it seems to work okay so this must be specific to native-comp. That branch also seems to have similar problems with a posframe window with (parent . nil).

dakra commented 4 years ago

FYI, I recently switched back to the native-comp branch and to avoid this issue you can just not native-compile exwm and xcb as a workaround until this issue is fixed.

  (add-to-list 'comp-deferred-compilation-black-list "/exwm.*\\.el")
  (add-to-list 'comp-deferred-compilation-black-list "/xcb.*\\.el")
loafofpiecrust commented 4 years ago

That sounds like a good solution, but I can't get it to actually fix the problem for me. I switched back to native-comp on doom emacs, and use the following in my packages.el file:

(package! xelb :recipe (:no-byte-compile t :no-native-compile t))
(package! exwm :recipe (:no-byte-compile t :no-native-compile t))

Which I think should equate to the snippet you gave. I also added those two lines to my config.el and init.el to no avail. Popup windows still expand too large.

dakra commented 4 years ago

Check that you actually removed the native-comp files from eln-cache before starting Emacs with the new config.

If the .eln files for exwm/xelb are already there they will still load regardless of the value of comp-deferred-compilation-black-list.

loafofpiecrust commented 4 years ago

After clearing out my emacs directories ~/.config/emacs/.local, and rebuilding all my packages, there are no .elc or .eln files for exwm or xelb. Yet I still have this problem with popups. Maybe there's another way to check whether I have loaded the native compiled version or the elisp version? For reference, I tried with the latest commit to the native-comp branch, and with the latest commit as of August 6.

dakra commented 4 years ago

Hmm, strange. I'm at commit 67c5369156 from September 4th. And just to make sure, my comp-deferred-compilation-black-list looks like: ("init\\.el" "/xcb.*\\.el" "/exwm.*\\.el").

akirakyle commented 4 years ago

I'm also seeing the same behavior and am running the native-comp branch. Setting comp-deferred-compilation-black-list to ("init\\.el" "/xcb.*\\.el" "/exwm.*\\.el") also has not helped me either. I wonder if the generally improved performance of native-comp has perhaps exposed some race condition?

dakra commented 4 years ago

I just tried it again with the latest native-comp master. When I don't exclude both xcb and exwm I get this issue described here but when I don't compile them it works.

Maybe you set the black list too late? I have this in my config

(use-package comp
  :config
  (setq comp-deferred-compilation t)
  ;; Don't try to native compile these files
  (add-to-list 'comp-deferred-compilation-black-list "/exwm.*\\.el")
  (add-to-list 'comp-deferred-compilation-black-list "/xcb.*\\.el")
  (add-to-list 'comp-deferred-compilation-black-list "init\\.el"))

And also make sure that you removed the already compiled .eln files for exwm and xcb. So for me they're currently in .emacs.d/eln-cache/28.0.50-x86_64-pc-linux-gnu-cfb9403e84a6e99e5ac1bea6ab4abade.

Obviously this all is just a work around and would be nice if it gets fixed inside exwm.

dakra commented 4 years ago

Just an update that after I upgraded to the new version I also get the same bug now regardless of what's in the black-list :(

dickoa commented 4 years ago

I also had the same issue and couldn't fix it using all the approaches mentioned here. I will go back to emacs 28 (latest build on master) until this is solved.

akirakyle commented 4 years ago

Not sure what changed, but I just updated to the latest commit e5b052d60d905209c6cefcf18c620167ed946301 and I'm not experiencing this issue anymore. I still have exwm*.el and xcb*.el added to comp-deferred-compilation-black-list.

dickoa commented 4 years ago

It's also working for me since the commit e5b052d60d905209c6cefcf18c620167ed946301, thanks for pointing this out @akirakyle I'm back to gccemacs now!

dakra commented 4 years ago

I also have a working version now with the latest commit. And you don't even have to exclude exwm in comp-deferred-compilation-black-list. Works also with native compiled exwm, xcb :)

teu5us commented 4 years ago

Floats are fine for me on NixOS (emacs native-comp branch) if I install exwm through nix and not through doom

gdindi commented 2 years ago

Hi, I am experiencing the same problem: floatingdialog boxes (like the save file dialog in Firefox) are too big. I can resize them with super + mouse, but I have to do this every time and it is tedious. I am using emacs's master branch and I cofigure it like this ./configure --with-native-compilation --with-xwidgets I have adapted the suggested workaround like this: (setq native-comp-deferred-compilation t) (add-to-list 'native-comp-deferred-compilation-deny-list "/exwm.\.el") (add-to-list 'native-comp-deferred-compilation-deny-list "/xcb.\.el") (add-to-list 'native-comp-deferred-compilation-deny-list "init\.el") I have checked that the compiled files do not appear in the eln-cache directory. But the problem persists. Isn't there a way to force a floating window to have a particular size? Maybe this could be enforced using exwm-floating-setup-hook? Thanks for any idea you may have.

mtekman commented 2 years ago

Isn't there a way to force a floating window to have a particular size? Maybe this could be enforced using exwm-floating-setup-hook?

Perhaps a bit off topic (and feel free to remove this comment if it's too much of a plug), but I have a library that works with floating windows in exwm, and one if it's features is placement rules for windows by name

https://gitlab.com/mtekman/exwm-float.el

gdindi commented 2 years ago

Nice. I'll have a look at it.

gdindi commented 2 years ago

Using exwm-float.el and this

(add-hook 'exwm-floating-setup-hook
          (lambda ()
            (exwm-layout-hide-mode-line)
            (exwm-float-resize 400 400)))

Seems to do the trick for the "save-as" dialog in Firefox. I will experiment with other applications and report if useful.

gdindi commented 2 years ago

Well, actually, it does not work with other applications. And furthermore, if I want to disable tab-bar-mode for floating frames, it does not work at all. I don't understand why. But here is what I found that is OK for my workflow.

I have extracted this from exwm-float.el

(defun my/resize-floating-frame (width height)
  (interactive "nWidth: \nnHeight: ")
    (let ((floating-container (frame-parameter exwm--floating-frame
                                               'exwm-container)))
      (exwm--set-geometry floating-container nil nil width height)
      (exwm--set-geometry exwm--id nil nil width height)
      (xcb:flush exwm--connection)))

(exwm-input-set-key (kbd "s-x r") (lambda () (interactive) (my/resize-floating-frame 500 500)))

With that, I can resize the frames which don't have the right size, and, their size becomes correct the next time the same kind of frame pops up (save as dialogs, file selection, etc.). When I say «correct» size, I dont mean the size I manually selected when calling the function above, but the default size that the application tries to use (as one would get in a floating WM).

It's a shame that I don't understand how this things work!

I can now use the following hook without issues:

(defun my/remove-tab-bar-and-mode-line ()
  (toggle-frame-tab-bar) ;; No tab bars on floating frames
  (exwm-layout-hide-mode-line))

(add-hook 'exwm-floating-setup-hook #'my/remove-tab-bar-and-mode-line)

And I don't need to disable native comp for exwm, xcb or anything else.

I hope this helps anybody who may face similar problems.

gdindi commented 2 years ago

Hello, Just another iteration on this. I have been investigating and I found that in exwm-floating--set-floating line 297 in the call to (set-frame-size frame frame-width frame-height t) sometimes frame-height is greater than my screen size. I sometimes use a dual screen setup with 2 different sizes and one monitor on top of the other, so maybe this is the cause of the mismatch.

Anyway, the workaround that I finally adopted consists in resizing the frame in the exwm-floating-setup-hook like this:

(defun my/adjust-floating-frame-size ()
  "Ensure that the current floating exwm frame does not exceed the size of the screen"
  (let* ((frame (selected-frame))
         (width (frame-pixel-width frame))
         (height (frame-pixel-height frame))
         (w1 (elt (elt exwm-workspace--workareas 0) 2))
         (h1 (elt (elt exwm-workspace--workareas 0) 3))
         (w2 (elt (elt exwm-workspace--workareas 1) 2))
         (h2 (elt (elt exwm-workspace--workareas 1) 3))
         (max-width (min w1 w2))
         (max-height (min h1 h2))
         (final-height (min height max-height))
         (final-width (min width max-width)))
    (set-frame-size frame final-width final-height t)))
(add-hook 'exwm-floating-setup-hook #'my/adjust-floating-frame-size 100)

Note that this has to be the last function in the hook for it to work.

Not pretty, but I can work like that.

However, looking at the code of exwm-floating--set-floating I don't understand why the size is not correctly computed.

gdindi commented 1 year ago

This seems to have been corrected in 0.27.

Hello, Just another iteration on this. I have been investigating and I found that in exwm-floating--set-floating line 297 in the call to (set-frame-size frame frame-width frame-height t) sometimes frame-height is greater than my screen size. I sometimes use a dual screen setup with 2 different sizes and one monitor on top of the other, so maybe this is the cause of the mismatch.

Anyway, the workaround that I finally adopted consists in resizing the frame in the exwm-floating-setup-hook like this:

(defun my/adjust-floating-frame-size ()
  "Ensure that the current floating exwm frame does not exceed the size of the screen"
  (let* ((frame (selected-frame))
         (width (frame-pixel-width frame))
         (height (frame-pixel-height frame))
         (w1 (elt (elt exwm-workspace--workareas 0) 2))
         (h1 (elt (elt exwm-workspace--workareas 0) 3))
         (w2 (elt (elt exwm-workspace--workareas 1) 2))
         (h2 (elt (elt exwm-workspace--workareas 1) 3))
         (max-width (min w1 w2))
         (max-height (min h1 h2))
         (final-height (min height max-height))
         (final-width (min width max-width)))
    (set-frame-size frame final-width final-height t)))
(add-hook 'exwm-floating-setup-hook #'my/adjust-floating-frame-size 100)

Note that this has to be the last function in the hook for it to work.

Not pretty, but I can work like that.

However, looking at the code of exwm-floating--set-floating I don't understand why the size is not correctly computed.

This seems to have been corrected in 0.27.