Revised "Manager_activateMonitor"

... to allow setting absolute and relative values
This commit is contained in:
joten 2015-01-28 20:12:57 +01:00
parent 8455ec1b60
commit 7d7c20f716
5 changed files with 24 additions and 21 deletions

View file

@ -12,8 +12,9 @@
2. `~` Renamed the function `View_toggleFloating` to `View_toggleFloatingWindow` 2. `~` Renamed the function `View_toggleFloating` to `View_toggleFloatingWindow`
3. `~` Migrated the following functions to `View_setLayoutProperty`: `View_setGapWidth`, `View_setMFactor`, `View_setMX`, 3. `~` Migrated the following functions to `View_setLayoutProperty`: `View_setGapWidth`, `View_setMFactor`, `View_setMX`,
`View_setMY` and `View_rotateLayoutAxis` `View_setMY` and `View_rotateLayoutAxis`
4. `~` Revised the following functions to allow setting absolute and relative values: `Debug_setLogLevel`, `Monitor_activateView`, 4. `~` Revised the following functions to allow setting absolute and relative values: `Debug_setLogLevel`,
`Monitor_setWindowTag`, `View_setLayout`, `View_setMFactor`, `View_shuffleWindow` `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 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` 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)` | | | | `#+Up::View_shuffleWindow(-1)` | `#+Up::View_shuffleWindow(0, -1)` |
| | | `#+Enter::View_shuffleWindow(0)` | `#+Enter::View_shuffleWindow(1)` | | | | `#+Enter::View_shuffleWindow(0)` | `#+Enter::View_shuffleWindow(1)` |
| | | `#+0::Monitor_setWindowTag(0)` | `#+0::Monitor_setWindowTag(10)` | | | | `#+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)` | | 5. | | `#Down::View_activateWindow(+1)` | `#Down::View_activateWindow(0, +1)` |
| | | `#Up::View_activateWindow(-1)` | `#Up::View_activateWindow(0, -1)` | | | | `#Up::View_activateWindow(-1)` | `#Up::View_activateWindow(0, -1)` |

View file

@ -211,10 +211,12 @@ for the active window, if it is not / is already set.
### Monitor management ### Monitor management
`#.::Manager_activateMonitor(+1)` `#.::Manager_activateMonitor(0, +1)`
> Activate the next monitor in a multi-monitor environment. > 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. > Activate the previous monitor in a multi-monitor environment.
`#+.::Manager_setWindowMonitor(+1)` `#+.::Manager_setWindowMonitor(+1)`

View file

@ -302,7 +302,7 @@ Bar_GuiClick:
If (A_GuiEvent = "Normal") If (A_GuiEvent = "Normal")
{ {
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) 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") If (SubStr(A_GuiControl, -6) = "_layout")
View_setLayout(-1) View_setLayout(-1)
Else If (SubStr(A_GuiControl, -4) = "_view") Else If (SubStr(A_GuiControl, -4) = "_view")
@ -317,7 +317,7 @@ Bar_GuiContextMenu:
If (SubStr(A_GuiControl, -6) = "_layout") If (SubStr(A_GuiControl, -6) = "_layout")
{ {
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) 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) View_setLayout(0, +1)
} }
Else If (SubStr(A_GuiControl, -4) = "_view") Else If (SubStr(A_GuiControl, -4) = "_view")
@ -347,7 +347,7 @@ Bar_move(m)
Bar_toggleCommandGui: Bar_toggleCommandGui:
If Not Bar_cmdGuiIsVisible If Not Bar_cmdGuiIsVisible
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor) 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() Bar_toggleCommandGui()
Return Return

View file

@ -469,8 +469,8 @@ Config_UI_saveSession() {
#^9::Monitor_toggleWindowTag(9) #^9::Monitor_toggleWindowTag(9)
;; Monitor management ;; Monitor management
#.::Manager_activateMonitor(+1) #.::Manager_activateMonitor(0, +1)
#,::Manager_activateMonitor(-1) #,::Manager_activateMonitor(0, -1)
#+.::Manager_setWindowMonitor(+1) #+.::Manager_setWindowMonitor(+1)
#+,::Manager_setWindowMonitor(-1) #+,::Manager_setWindowMonitor(-1)
#^+.::Manager_setViewMonitor(+1) #^+.::Manager_setViewMonitor(+1)

View file

@ -68,33 +68,31 @@ Manager_init()
SetTimer, Bar_loop, %Config_readinInterval% SetTimer, Bar_loop, %Config_readinInterval%
} }
Manager_activateMonitor(d) Manager_activateMonitor(i, d = 0) {
{
Local aView, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId Local aView, aWndHeight, aWndId, aWndWidth, aWndX, aWndY, v, wndId
If (Manager_monitorCount > 1) If (Manager_monitorCount > 1) {
{
aView := Monitor_#%Manager_aMonitor%_aView_#1 aView := Monitor_#%Manager_aMonitor%_aView_#1
aWndId := View_getActiveWindow(Manager_aMonitor, aView) aWndId := View_getActiveWindow(Manager_aMonitor, aView)
If aWndId If aWndId {
{
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor) If (Monitor_get(aWndX + aWndWidth / 2, aWndY + aWndHeight / 2) = Manager_aMonitor)
View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId View_#%Manager_aMonitor%_#%aView%_aWndId := aWndId
} }
;; Manually set the active monitor. ;; 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 v := Monitor_#%Manager_aMonitor%_aView_#1
wndId := View_#%Manager_aMonitor%_#%v%_aWndId 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 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 Else
wndId := 0 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) Manager_winActivate(wndId)
} }
} }