Skip to content

Commit

Permalink
Allow caching to be controlled in the config file (and in a more fine…
Browse files Browse the repository at this point in the history
…-grained way)

Add cache_workspaces and cache_windows to the config to individually control what gets cached, but still allow the command-line flag to override the settings and disable the cache entirely.
Why?
Caching window positions can be a bit unreliable for things like browser windows (which will all have the same WM_CLASS and window title on start-up so may not match between runs/logins when cortile encounters the window).
  • Loading branch information
mark-cooke committed Dec 21, 2024
1 parent 96a0edd commit 72877b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var (
)

type Configuration struct {
CacheWorkspaces bool `toml:"cache_workspaces"` // Cache workspace properties (Tiling enablement, Current layout, proportions)
CacheWindows bool `toml:"cache_windows"` // Cache window properties ( Positions, Dimensions)
TilingEnabled bool `toml:"tiling_enabled"` // Tile windows on startup
TilingLayout string `toml:"tiling_layout"` // Initial tiling layout
TilingCycle []string `toml:"tiling_cycle"` // Cycle layout order
Expand Down
6 changes: 6 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
# Initial tiling activation, will be cached afterwards (true | false).
tiling_enabled = true

# Cache Workspace Tiling enablement, current layouts, etc
cache_workspaces = true

# Do not cache window positions
cache_windows = false

# Initial tiling layout, will be cached afterwards ("vertical-left" | "vertical-right" | "horizontal-top" | "horizontal-bottom" | "maximized" | "fullscreen").
tiling_layout = "vertical-right"

Expand Down
4 changes: 2 additions & 2 deletions desktop/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (ws *Workspace) Restore(flag uint8) {
}

func (ws *Workspace) Write() {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWorkspaces {
return
}

Expand All @@ -261,7 +261,7 @@ func (ws *Workspace) Write() {
}

func (ws *Workspace) Read() *Workspace {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWorkspaces {
return ws
}

Expand Down
4 changes: 2 additions & 2 deletions store/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (c *Client) Update() {
}

func (c *Client) Write() {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWindows {
return
}

Expand All @@ -368,7 +368,7 @@ func (c *Client) Write() {
}

func (c *Client) Read() *Client {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWindows {
return c
}

Expand Down

0 comments on commit 72877b1

Please sign in to comment.