ch11ng / exwm

Emacs X Window Manager
2.85k stars 137 forks source link

1 pixel border around screen #940

Open walseb opened 6 months ago

walseb commented 6 months ago

Hello!

Has anyone noticed a 1 pixel border on all sides of the screen when using EXWM?

For me, it's only really visible when switching to a light theme while in a dark web browser or other dark colored buffer.

Since it changes color depending on themes, it hints at it being an emacs created border decoration.

Does anyone else see it? Is there any way to remove it?

I haven't found anything online regarding it.

Thank you!

minad commented 6 months ago

Yes, I also see a line at the bottom of the screen, when switching from a light to a dark theme. The effect is only visible when I start Emacs with a light background.

walseb commented 6 months ago

That's interesting, I see it on all sides. It's a bit annoying when using a light theme, but is thankfully not visible when using a dark theme.

Stebalien commented 6 months ago
  1. Can you post your (frame-parameters) and (frame-geometry)?
  2. What toolkit (gtk, lucid, no tookit)?
  3. Does enabling the exwm-background module ((exwm-background-enable)) make a difference?
minad commented 6 months ago

I use Lucid. I just checked the output of:

(pp `((frame-geometry . ,(frame-geometry))
      (frame-monitor-geometry . ,(frame-monitor-geometry))))

The problem is the external-border-size:

((frame-geometry
  (outer-position 0 . 0)
  (outer-size 2560 . 1440)
  (external-border-size 0 . 1)
  (outer-border-width . 0)
  (title-bar-size 0 . -1)
  (menu-bar-external . t)
  (menu-bar-size 0 . 0)
  (tab-bar-size 2558 . 21)
  (tool-bar-external)
  (tool-bar-position . top)
  (tool-bar-size 0 . 0)
  (internal-border-width . 1))
 (frame-monitor-geometry 0 0 2560 1440))

I've set x-no-window-manager=t in my early-init.el. Enabling the background module doesn't make a difference. The color of the line at the bottom is influenced by the *background Xresources, which I store depending on the selected theme, such that the next time Emacs starts up, the frame background doesn't flicker.

minad commented 6 months ago

@walseb

Is there any way to remove it?

To answer that question - in my setup, I can remove the border when I evaluate the following:

(progn
  (tab-bar-mode -1)
  (pcase-let ((`(,x ,y ,w ,h) (frame-monitor-geometry)))
    (set-frame-size nil w h t))
  (tab-bar-mode 1))

I use the tab-bar for workspaces. The tab-bar has to be disabled first since otherwise one ends up with a frame which is too high (monitor height + tab bar height). Maybe this works for you too?

In order to figure out the reason of the initially wrong computation, I have to create a minimal example first.

Stebalien commented 6 months ago

Hm. I have a similar issue, but I only see 5 pixels at the bottom, not all the way around. In my case, it's because I'm changing the tab-bar face's font size too early on startup (or something like that).

Deleting the current frame seems to "fix" it. So does delaying:

So does setting auto-resize-tab-bars to grow-only, but that causes the tab-bar to be too large.

Stebalien commented 6 months ago

Taking the fringe into account and keeping the tab-bar visible, the following seems to work:

(defun fix-frame-size (&optional frame)
  (pcase-let ((`(,x ,y ,w ,h) (frame-monitor-geometry frame)))
    (set-frame-size frame
                    (- w (frame-fringe-width frame))
                    (- h (tab-bar-height frame t)) t)))

(technically one probably needs to take the menu bar, tool bar, scroll bar, etc. into account)

walseb commented 6 months ago

Hello!

Thanks for the replies!

I tried both of your code blocks. They removed the border on the right hand side and the bottom, but a one pixel border on the left side of my screen and the top still remain.

Here's the output of running:

(pp `((frame-geometry . ,(frame-geometry))
      (frame-monitor-geometry . ,(frame-monitor-geometry))))
((frame-geometry (outer-position 0 . 0) (outer-size 1920 . 1080)
                (external-border-size -2 . -2)
                (outer-border-width . 0) (title-bar-size 0 . 2)
                (menu-bar-external . t) (menu-bar-size 0 . 0)
                (tab-bar-size 0 . 0) (tool-bar-external)
                (tool-bar-position . top) (tool-bar-size 0 . 0)
                (internal-border-width . 1))
(frame-monitor-geometry 0 0 1920 1080))
walseb commented 6 months ago

Actually, the above is what I get when I run it after applying the set-frame-size functions. This is what I get when I run it before running those:

((frame-geometry (outer-position 0 . 0) (outer-size 1920 . 1080)
         (external-border-size 0 . 0) (outer-border-width . 0)
         (title-bar-size 0 . 0) (menu-bar-external . t)
         (menu-bar-size 0 . 0) (tab-bar-size 0 . 0)
         (tool-bar-external) (tool-bar-position . top)
         (tool-bar-size 0 . 0) (internal-border-width . 1))
(frame-monitor-geometry 0 0 1920 1080))
walseb commented 6 months ago

It seems the issue was with internal-border-width.

Simply running Emacs with

emacs --internal-border=0 --border-width=0

solved the issue entirely for me. I have now reclaimed one slice of pixels in each direction!

You might be able to use modify-frame-parameters to achieve this, but I didn't understand what input it expected.

Does this solve the issue for anyone else?

I think this issue should be added to the Wiki. I will create a PR.

walseb commented 6 months ago

It seems like the Wiki change just went through, no need to create a PR.

I added it here https://github.com/ch11ng/exwm/wiki#border-in-corners-of-screen. If there's a better place to add it, please tell me or feel free to change it.

minad commented 6 months ago

Sebastian Wålinder @.***> writes:

It seems the issue was with internal-border-width.

Simply running Emacs with

emacs --internal-border=0 --border-width=0

solved the issue entirely for me. I have now reclaimed one slice of pixels in each direction!

In my case the problem is not solved by these settings (they should be th default?). The pixel offset at the bottom remains. I assume the problem there is a bug in an Emacs frame size computation.

walseb commented 5 months ago

Sebastian Wålinder @.***> writes: It seems the issue was with internal-border-width. Simply running Emacs with emacs --internal-border=0 --border-width=0 solved the issue entirely for me. I have now reclaimed one slice of pixels in each direction! In my case the problem is not solved by these settings (they should be th default?). The pixel offset at the bottom remains. I assume the problem there is a bug in an Emacs frame size computation.

That's strange, it works perfectly for me with those start parameters. I'm running Emacs 30, lucid, on NixOS without any special GTK settings. On the wiki I just inserted a link to this issue.

walseb commented 5 months ago

Are you managing your minibuffer using exwm? I tried (setq exwm-workspace-minibuffer-position 'top) just now, and running exwm-workspace-detach-minibuffer caused a massive border at the top appear. Same thing happens at the bottom of the frame when I set it to (setq exwm-workspace-minibuffer-position 'bottom)

minad commented 5 months ago

@walseb No, I don't. When I tried it, I didn't have success and also observed some problems. It would be nice to try this again, since this would allow me to hide the minibuffer while it is not active. Otoh the echo area is also hidden.

Stebalien commented 1 month ago

As of today (9a2088bdd928b384beca3c95c2719843f74924a0) I can't seem to reproduce this issue. Although I can't be sure it's actually fixed.