mogenson/PaperWM.spoon

Configurable screen margin

slarwise opened this issue · 8 comments

Hi :) What do you think about making the screen margin, a.k.a. the margin where "off-screen" windows are placed, configurable? I think it looks pretty nice with a margin that is smaller than the window gap. Here is an example with window gap being 30 and the screen margin 10.

Screenshot 2023-09-23 at 13 56 03

I tested the minimum off screen margin empirically on my computer. Perhaps it changes with screen resolution. If so, maybe we could calculate it at runtime from a percent or fraction.

Aha I see. I'll try it on my external monitor and see if there's a difference.

Hi again, I set the screen margin to 10 instead of 40 like below. Measured the margin using the screen shot bullseye that shows the current pixel position (Cmd-Shift-4) and it looks like it is 10 pixels on both the built-in screen (1440 * 900) and my external monitor (2560 * 1440).

diff --git a/init.lua b/init.lua
index 9c69cef..7b8d5b9 100644
--- a/init.lua
+++ b/init.lua
@@ -317,7 +317,7 @@ end
 function PaperWM:tileSpace(space)
     -- MacOS doesn't allow windows to be moved off screen
     -- stack windows in a visible margin on either side
-    local screen_margin <const> = 40
+    local screen_margin <const> = 10

     if not space or Spaces.spaceType(space) ~= "user" then
         self.logger.e("current space invalid")

Hey, I'm traveling this week. But, I'll try out a margin of 10 on my personal Macbook Air, work Macbook Pro, and external monitor. If that margin works, I'm happy to make the change. Perhaps this value could also be user settable.

Awesome, thanks :)

@slarwise I took a look at this today and I misremembered the behavior of MacOS:

  • If you move a window full off-screen, MacOS will move the window's edge back on screen by 40 pixels.
  • But, if you move a window so it is still on-screen, but the window's edge is less than 40 pixels to the screen's edge, MacOS will leave it be.
  • I'm able to place a window and leave 1 pixel of the window's edge on screen without MacOS moving the window.
  • So a screen_margin of 1 seems to be the minimum. A value of 0 sends the window back to 40 pixels from the edge.

Take a look at #23 and see if it works for you.

Awesome, #23 works good for me! Thanks a lot :)

Great. Merged #23