From 7d7c20f7161ac0b3b14cc53f3b62ac9d686068ca Mon Sep 17 00:00:00 2001 From: joten Date: Wed, 28 Jan 2015 20:12:57 +0100 Subject: [PATCH] Revised "Manager_activateMonitor" ... to allow setting absolute and relative values --- doc/CHANGES.md | 7 +++++-- doc/Default_hotkeys.md | 8 +++++--- src/Bar.ahk | 6 +++--- src/Config.ahk | 4 ++-- src/Manager.ahk | 20 +++++++++----------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index f3f2129..381d521 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -12,8 +12,9 @@ 2. `~` Renamed the function `View_toggleFloating` to `View_toggleFloatingWindow` 3. `~` Migrated the following functions to `View_setLayoutProperty`: `View_setGapWidth`, `View_setMFactor`, `View_setMX`, `View_setMY` and `View_rotateLayoutAxis` -4. `~` Revised the following functions to allow setting absolute and relative values: `Debug_setLogLevel`, `Monitor_activateView`, -`Monitor_setWindowTag`, `View_setLayout`, `View_setMFactor`, `View_shuffleWindow` +4. `~` Revised the following functions to allow setting absolute and relative values: `Debug_setLogLevel`, +`Manager_activateMonitor`, `Monitor_activateView`, `Monitor_setWindowTag`, `View_setLayout`, `View_setMFactor`, +`View_shuffleWindow` 5. `~` Revised the interface, i. e. the parameters, of the following functions for setting absolute and relative values -- but did not implement the functionality: `Monitor_toggleWindowTag`, `View_activateWindow` @@ -39,6 +40,8 @@ not implement the functionality: `Monitor_toggleWindowTag`, `View_activateWindow | | | `#+Up::View_shuffleWindow(-1)` | `#+Up::View_shuffleWindow(0, -1)` | | | | `#+Enter::View_shuffleWindow(0)` | `#+Enter::View_shuffleWindow(1)` | | | | `#+0::Monitor_setWindowTag(0)` | `#+0::Monitor_setWindowTag(10)` | +| | | `#.::Manager_activateMonitor(+1)` | `#.::Manager_activateMonitor(0, +1)` | +| | | `#,::Manager_activateMonitor(-1)` | `#,::Manager_activateMonitor(0, -1)` | | 5. | | `#Down::View_activateWindow(+1)` | `#Down::View_activateWindow(0, +1)` | | | | `#Up::View_activateWindow(-1)` | `#Up::View_activateWindow(0, -1)` | diff --git a/doc/Default_hotkeys.md b/doc/Default_hotkeys.md index 909b4c4..2ea6c82 100644 --- a/doc/Default_hotkeys.md +++ b/doc/Default_hotkeys.md @@ -211,10 +211,12 @@ for the active window, if it is not / is already set. ### Monitor management -`#.::Manager_activateMonitor(+1)` -> Activate the next monitor in a multi-monitor environment. +`#.::Manager_activateMonitor(0, +1)` +> Activate the next monitor in a multi-monitor environment. You may also +activate a specific monitor by using the first parameter, e. g. +`Manager_activateMonitor(1)` to activate the first monitor. -`#,::Manager_activateMonitor(-1)` +`#,::Manager_activateMonitor(0, -1)` > Activate the previous monitor in a multi-monitor environment. `#+.::Manager_setWindowMonitor(+1)` diff --git a/src/Bar.ahk b/src/Bar.ahk index 0613367..5c407d6 100644 --- a/src/Bar.ahk +++ b/src/Bar.ahk @@ -302,7 +302,7 @@ Bar_GuiClick: If (A_GuiEvent = "Normal") { If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) - Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) + Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6)) If (SubStr(A_GuiControl, -6) = "_layout") View_setLayout(-1) Else If (SubStr(A_GuiControl, -4) = "_view") @@ -317,7 +317,7 @@ Bar_GuiContextMenu: If (SubStr(A_GuiControl, -6) = "_layout") { If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) - Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) + Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6)) View_setLayout(0, +1) } Else If (SubStr(A_GuiControl, -4) = "_view") @@ -347,7 +347,7 @@ Bar_move(m) Bar_toggleCommandGui: If Not Bar_cmdGuiIsVisible If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) - Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor) + Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6)) Bar_toggleCommandGui() Return diff --git a/src/Config.ahk b/src/Config.ahk index 73b9ad2..85b1742 100644 --- a/src/Config.ahk +++ b/src/Config.ahk @@ -469,8 +469,8 @@ Config_UI_saveSession() { #^9::Monitor_toggleWindowTag(9) ;; Monitor management -#.::Manager_activateMonitor(+1) -#,::Manager_activateMonitor(-1) +#.::Manager_activateMonitor(0, +1) +#,::Manager_activateMonitor(0, -1) #+.::Manager_setWindowMonitor(+1) #+,::Manager_setWindowMonitor(-1) #^+.::Manager_setViewMonitor(+1) diff --git a/src/Manager.ahk b/src/Manager.ahk index 880b327..71ebf62 100644 --- a/src/Manager.ahk +++ b/src/Manager.ahk @@ -68,33 +68,31 @@ Manager_init() SetTimer, Bar_loop, %Config_readinInterval% } -Manager_activateMonitor(d) -{ +Manager_activateMonitor(i, d = 0) { Local aView, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId - If (Manager_monitorCount > 1) - { + If (Manager_monitorCount > 1) { aView := Monitor_#%Manager_aMonitor%_aView_#1 aWndId := View_getActiveWindow(Manager_aMonitor, aView) - If aWndId - { + If aWndId { WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor) View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId } ;; Manually set the active monitor. - Manager_aMonitor := Manager_loop(Manager_aMonitor, d, 1, Manager_monitorCount) + If (i = 0) + i := Manager_aMonitor + Manager_aMonitor := Manager_loop(i, d, 1, Manager_monitorCount) v := Monitor_#%Manager_aMonitor%_aView_#1 wndId := View_#%Manager_aMonitor%_#%v%_aWndId - If Not (wndId And WinExist("ahk_id" wndId)) - { + If Not (wndId And WinExist("ahk_id" wndId)) { If View_#%Manager_aMonitor%_#%v%_wndIds - wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";")-1) + wndId := SubStr(View_#%Manager_aMonitor%_#%v%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%v%_wndIds, ";") - 1) Else wndId := 0 } - Debug_logMessage("DEBUG[1] Manager_activateMonitor: Manager_aMonitor: " Manager_aMonitor ", d: " d ", wndId: " wndId, 1) + Debug_logMessage("DEBUG[1] Manager_activateMonitor: Manager_aMonitor: " Manager_aMonitor ", i: " i ", d: " d ", wndId: " wndId, 1) Manager_winActivate(wndId) } }