[bugfix] unable to save arrangement

This commit is contained in:
Klesh Wong 2021-07-08 20:22:36 +08:00
parent e50aebe4d6
commit 76a0ca0e8f
3 changed files with 16 additions and 7 deletions

View File

@ -3,3 +3,6 @@ indent_size=4
[dwmbar]
indent_size=4
[*.ahk]
indent_size=4

View File

@ -1,10 +1,4 @@
; WINDOWS MANAGER
; global RATIO := 0.618
global RATIO := 0.382
global ID_SEEN := Object()
global ARRANGEMENT := Object()
global ARRANGEMENT_PATH := A_AppData . "\arrangement.json"
global PADDING := 10
; =========================
; KEY BINDING
@ -37,6 +31,13 @@ global PADDING := 10
; =========================
InitWindowManager() {
LogDebug("InitWindowManager")
global RATIO := 0.618
global RATIO := 0.382
global ID_SEEN := Object()
global ARRANGEMENT := Object()
global ARRANGEMENT_PATH := A_AppData . "\arrangement.json"
global PADDING := 10
LoadArrangement()
SetTimer, AdjustNewWindow, 1000
}
@ -112,20 +113,24 @@ MoveActiveWinByDirection(direction) {
wy := wy + PADDING
wh := wh - PADDING * 2
WinMove, A,, wx - l, wy - t, ww + l + r, wh + t + b
LogDebug(Format("move {1} to {2}", activeWinId, direction))
SaveActiveWindowDirection(direction)
}
SaveArrangement() {
LogDebug("SaveArrangement start")
global ARRANGEMENT
global ARRANGEMENT_PATH
file := FileOpen(ARRANGEMENT_PATH, "w")
file.Write(JSON.Dump(ARRANGEMENT,, 2))
file.Close()
LogDebug("SaveArrangement end")
}
LoadArrangement() {
global ARRANGEMENT
global ARRANGEMENT_PATH
LogDebug("LoadArrangement start " .ARRANGEMENT_PATH)
try {
FileRead, temp, %ARRANGEMENT_PATH%
ARRANGEMENT := JSON.Load(temp)
@ -144,6 +149,7 @@ LoadArrangement() {
if not IsObject(ARRANGEMENT["whitelist"]) {
ARRANGEMENT["whitelist"] := Object()
}
LogDebug("LoadArrangement end")
}
GetActiveWindowPath() {

View File

@ -7,7 +7,7 @@ CoordMode, Mouse, Screen ; mouse coordinates relative to the screen
; =========================
; DEBUGGING
; =========================
global DEBUGGING := false
global DEBUGGING := true
ToggleDebugging() {
global DEBUGGING