Skip to content

Commit

Permalink
feat: use global and primary edge margin #27
Browse files Browse the repository at this point in the history
  • Loading branch information
leukipp committed Dec 10, 2023
1 parent 1c88456 commit 27b0c81
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
39 changes: 20 additions & 19 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@ var (
)

type Configuration struct {
TilingEnabled bool `toml:"tiling_enabled"` // Tile windows on startup
TilingLayout string `toml:"tiling_layout"` // Initial tiling layout
TilingGui int `toml:"tiling_gui"` // Time duration of gui
TilingIcon [][]string `toml:"tiling_icon"` // Menu entries of systray
WindowIgnore [][]string `toml:"window_ignore"` // Regex to ignore windows
WindowMastersMax int `toml:"window_masters_max"` // Maximum number of allowed masters
WindowSlavesMax int `toml:"window_slaves_max"` // Maximum number of allowed slaves
WindowGapSize int `toml:"window_gap_size"` // Gap size between windows
WindowDecoration bool `toml:"window_decoration"` // Show window decorations
Proportion float64 `toml:"proportion"` // Master-slave area initial proportion
ProportionStep float64 `toml:"proportion_step"` // Master-slave area step size proportion
ProportionMin float64 `toml:"proportion_min"` // Window size minimum proportion
EdgeMargin []int `toml:"edge_margin"` // Margin values of tiling area
EdgeCornerSize int `toml:"edge_corner_size"` // Size of square defining edge corners
EdgeCenterSize int `toml:"edge_center_size"` // Length of rectangle defining edge centers
Colors map[string][]int `toml:"colors"` // List of color values for gui elements
Keys map[string]string `toml:"keys"` // Event bindings for keyboard shortcuts
Corners map[string]string `toml:"corners"` // Event bindings for hot-corner actions
Systray map[string]string `toml:"systray"` // Event bindings for systray icon
TilingEnabled bool `toml:"tiling_enabled"` // Tile windows on startup
TilingLayout string `toml:"tiling_layout"` // Initial tiling layout
TilingGui int `toml:"tiling_gui"` // Time duration of gui
TilingIcon [][]string `toml:"tiling_icon"` // Menu entries of systray
WindowIgnore [][]string `toml:"window_ignore"` // Regex to ignore windows
WindowMastersMax int `toml:"window_masters_max"` // Maximum number of allowed masters
WindowSlavesMax int `toml:"window_slaves_max"` // Maximum number of allowed slaves
WindowGapSize int `toml:"window_gap_size"` // Gap size between windows
WindowDecoration bool `toml:"window_decoration"` // Show window decorations
Proportion float64 `toml:"proportion"` // Master-slave area initial proportion
ProportionStep float64 `toml:"proportion_step"` // Master-slave area step size proportion
ProportionMin float64 `toml:"proportion_min"` // Window size minimum proportion
EdgeMargin []int `toml:"edge_margin"` // Margin values of tiling area
EdgeMarginPrimary []int `toml:"edge_margin_primary"` // Margin values of primary tiling area
EdgeCornerSize int `toml:"edge_corner_size"` // Size of square defining edge corners
EdgeCenterSize int `toml:"edge_center_size"` // Length of rectangle defining edge centers
Colors map[string][]int `toml:"colors"` // List of color values for gui elements
Keys map[string]string `toml:"keys"` // Event bindings for keyboard shortcuts
Corners map[string]string `toml:"corners"` // Event bindings for hot-corner actions
Systray map[string]string `toml:"systray"` // Event bindings for systray icon
}

func InitConfig() {
Expand Down
5 changes: 4 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ proportion_min = 0.2

##################################### Edge #####################################

# Additional margin of the tiling area ([top, right, bottom, left]).
# Margin of the tiling area ([top, right, bottom, left]).
edge_margin = [0, 0, 0, 0]

# Margin of the tiling area on primary screen ([top, right, bottom, left]).
edge_margin_primary = [0, 0, 0, 0]

# Width and height of a hot-corner area within the edge corners (0 - 100).
edge_corner_size = 10

Expand Down
15 changes: 10 additions & 5 deletions store/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,16 @@ func DesktopDimensions(screenNum uint) (x, y, w, h int) {
x, y, w, h = desktop.Pieces()

// Add desktop margin
if desktop.Primary {
x += common.Config.EdgeMargin[3]
y += common.Config.EdgeMargin[0]
w -= common.Config.EdgeMargin[1] + common.Config.EdgeMargin[3]
h -= common.Config.EdgeMargin[2] + common.Config.EdgeMargin[0]
margin := common.Config.EdgeMargin
if desktop.Primary && len(common.Config.EdgeMarginPrimary) > 0 {
margin = common.Config.EdgeMarginPrimary
}

if len(margin) == 4 {
x += margin[3]
y += margin[0]
w -= margin[1] + margin[3]
h -= margin[2] + margin[0]
}

return
Expand Down

0 comments on commit 27b0c81

Please sign in to comment.