From 27b0c81872a826665e6e833e002a24b3f3f1d84e Mon Sep 17 00:00:00 2001 From: leukipp Date: Sun, 10 Dec 2023 20:11:43 +0100 Subject: [PATCH] feat: use global and primary edge margin #27 --- common/config.go | 39 ++++++++++++++++++++------------------- config.toml | 5 ++++- store/root.go | 15 ++++++++++----- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/common/config.go b/common/config.go index 8df7ec8..c76db48 100644 --- a/common/config.go +++ b/common/config.go @@ -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() { diff --git a/config.toml b/config.toml index 0fca132..ee964bb 100644 --- a/config.toml +++ b/config.toml @@ -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 diff --git a/store/root.go b/store/root.go index c1b04aa..8f80b4a 100644 --- a/store/root.go +++ b/store/root.go @@ -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