Conversation
| local right_gap = getGap("right") | ||
| local top_gap = getGap("top") | ||
| local bottom_gap = getGap("bottom") | ||
| local left_gap = getGap("left") + (PaperWM.screen_edge_margins.left or 0) |
There was a problem hiding this comment.
This doesn't look like it will work when PaperWM.screen_edge_margins is a single number (eg PaperWM.screen_edge_margins = 0). Please implement a getEdgeMargin() helper function like getGap().
There was a problem hiding this comment.
Good point!
Btw, would love to hear what you think about this: I didn't implement a numeric PaperWM.screen_edge_margins here. It seemed like a feature that would nudge the user towards a less desirable outcome. Ideally left / right should be kept at 0, otherwise windows would "peek out" from the left.
(In any case, I can implement it, but it might take me a few weeks)
There was a problem hiding this comment.
I'm not sure I follow. In your addition to the README you said PaperWM.screeen_edge_margins could be a single number for the same margin on all sides, or a table with separate margins for each side.
Set
PaperWM.screen_edge_marginsto define additional margins around the screen edges. For example:PaperWM.screen_edge_margins = 0 -- 0px margin on all sides (default) -- or PaperWM.screen_edge_margins = { top = 50, right = 20, bottom = 50, left = 20 } -- Specific margins per side
Let's say a user takes the first option add adds the following to their config:
PaperWM.screen_edge_margin = 5Then this line (local left_gap = getGap("left") + (PaperWM.screen_edge_margins.left or 0) will crash with the following exception:
lua:1: attempt to index field 'screen_edge_margins' (a number value)
You need a helper function (similar to getGap()) that will check the type of PaperWM.screen_edge_margins before trying to index it as a table.
Next, what do you mean by windows would "peak out" from the left if the left and right screen edge margins are not 0? The canvas frame is only a smaller subset of the screen frame and a window will never be tiled beyond the edge of the canvas frame. We could add defensive checks that the user values for margins are not negative, or so large that opposite margins overlap.
Finally, take your time to edit. There is no rush.
|
|
||
| -- center window | ||
| focused_frame.x = screen_frame.x + (screen_frame.w // 2) - | ||
| local screen_x = screen_frame.x + self.screen_edge_margins.left |
There was a problem hiding this comment.
How about using getCanvas() here and center the window on the canvas.
|
Thanks for the feedback! As luck would have it, I don't have a MacBook anymore (at least not for the next few weeks) so I can't do these changes quite yet. If anyone would like to help out feel free! |
| local right_gap = getGap("right") | ||
| local top_gap = getGap("top") | ||
| local bottom_gap = getGap("bottom") | ||
| local left_gap = getGap("left") + (PaperWM.screen_edge_margins.left or 0) |
There was a problem hiding this comment.
I'm not sure I follow. In your addition to the README you said PaperWM.screeen_edge_margins could be a single number for the same margin on all sides, or a table with separate margins for each side.
Set
PaperWM.screen_edge_marginsto define additional margins around the screen edges. For example:PaperWM.screen_edge_margins = 0 -- 0px margin on all sides (default) -- or PaperWM.screen_edge_margins = { top = 50, right = 20, bottom = 50, left = 20 } -- Specific margins per side
Let's say a user takes the first option add adds the following to their config:
PaperWM.screen_edge_margin = 5Then this line (local left_gap = getGap("left") + (PaperWM.screen_edge_margins.left or 0) will crash with the following exception:
lua:1: attempt to index field 'screen_edge_margins' (a number value)
You need a helper function (similar to getGap()) that will check the type of PaperWM.screen_edge_margins before trying to index it as a table.
Next, what do you mean by windows would "peak out" from the left if the left and right screen edge margins are not 0? The canvas frame is only a smaller subset of the screen frame and a window will never be tiled beyond the edge of the canvas frame. We could add defensive checks that the user values for margins are not negative, or so large that opposite margins overlap.
Finally, take your time to edit. There is no rush.
Great work with PaperWM.spoon! I've been a loyal user of PaperWM on my GNOME laptop and I'm so happy to have the same on MacOS as well.
Context
I have a big screen (27") and I don't want to use all of it. I want to give it some margins to not use the whole screen.
I have another ultrawide monitor that is too wide for me. I want margins on the right side of the screen.
Solution
This implements
screen_edge_margins.Caveats:
leftscreen edge margin of > 0 will make windows peek out a bit more. Eg, ifscreen_margin = 1, andscreen_edge_margins = { left = 16 }, windows will peek out a total of 17 pixels.Notes:
rightmargin is fun on an ultrawide since it makes the "center" closer to the left!Prior art
GNOME PaperWM has this feature as "horizontal margin" (and "top margin" and "bottom margin").