[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] [dwmbar]
indent_size=4 indent_size=4
[*.ahk]
indent_size=4

View File

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

View File

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