- Keep a reference to each window's expected monitor. Using the screen position can cause windows to switch sides under the right circumstances.

- Some comments to help keep the onShellMessage function straight.
- Repositioned SetWinDelay calls to get better effect for everything.
- Fixed a bug where a windows activation of a window on another monitor would cause weird behavior.
This commit is contained in:
Joshua Fuhs 2012-06-25 19:13:52 -04:00
parent 986669f69a
commit b36b640aad
3 changed files with 14 additions and 14 deletions

View file

@ -331,6 +331,7 @@ Manager_manage(pm, pv, wndId) {
Monitor_moveWindow(m, wndId)
Manager_managedWndIds .= wndId ";"
Manager_#%wndId%_monitor := m
Manager_#%wndId%_tags := tags
Manager_#%wndId%_isDecorated := isDecorated
Manager_#%wndId%_isFloating := isFloating
@ -439,9 +440,7 @@ Manager_onShellMessage(wParam, lParam) {
isChanged := False
If a Or isChanged {
SetWinDelay, 0
View_arrange(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
SetWinDelay, 10
Bar_updateView(Manager_aMonitor, Monitor_#%Manager_aMonitor%_aView_#1)
}
@ -454,19 +453,24 @@ Manager_onShellMessage(wParam, lParam) {
If wndIds {
If (Config_onActiveHiddenWnds = "view") {
; Grab the first of such windows and make it visible.
; All others get forgotten (until the next round?)
wndId := SubStr(wndIds, 1, InStr(wndIds, ";") - 1)
Loop, % Config_viewCount
If (Manager_#%wndId%_tags & 1 << A_Index - 1) {
Manager_aMonitor := Manager_#%wndId%_monitor
Monitor_activateView(A_Index)
Break
}
} Else {
StringTrimRight, wndIds, wndIds, 1
StringSplit, wndId, wndIds, `;
; Otherwise re-hide them.
If (Config_onActiveHiddenWnds = "hide") {
Loop, % wndId0
WinHide, % "ahk_id " wndId%A_Index%
} Else If (Config_onActiveHiddenWnds = "tag") {
; Or tag all of them for the current view.
t := Monitor_#%Manager_aMonitor%_aView_#1
Loop, % wndId0 {
wndId := wndId%A_Index%
@ -661,6 +665,7 @@ Manager_unmanage(wndId) {
View_delWnd( Manager_aMonitor, A_Index, wndId )
Bar_updateView(Manager_aMonitor, A_Index)
}
Manager_#%wndId%_monitor :=
Manager_#%wndId%_tags :=
Manager_#%wndId%_isDecorated :=
Manager_#%wndId%_isFloating :=

View file

@ -81,10 +81,12 @@ Monitor_activateView(v) {
Loop, PARSE, wndIds, `;
If Not (Manager_#%A_LoopField%_tags & (1 << v - 1))
WinHide, ahk_id %A_LoopField%
SetWinDelay, 10
DetectHiddenWindows, On
View_arrange(m, v)
DetectHiddenWindows, Off
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
SetWinDelay, 0
Loop, PARSE, wndIds, `;
WinShow, ahk_id %A_LoopField%
SetWinDelay, 10
@ -177,19 +179,9 @@ Monitor_getWorkArea(m) {
}
Monitor_moveWindow(m, wndId) {
Local fX, fY, monitor, wndHeight, wndWidth, wndX, wndY
Global
WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId%
monitor := Monitor_get(wndX+wndWidth/2, wndY+wndHeight/2)
If Not (m = monitor) {
; move the window to the target monitor and scale it, if it does not fit on the monitor
fX := Monitor_#%m%_width / Monitor_#%monitor%_width
fY := Monitor_#%m%_height / Monitor_#%monitor%_height
If (wndX-Monitor_#%monitor%_x+wndWidth > Monitor_#%m%_width) Or (wndY-Monitor_#%monitor%_y+wndHeight > Monitor_#%m%_height)
Manager_winMove(wndId, Monitor_#%m%_x+fX*(wndX-Monitor_#%monitor%_x), Monitor_#%m%_y+fY*(wndY-Monitor_#%monitor%_y), fX*wndWidth, fY*wndHeight)
Else
Manager_winMove(wndId, Monitor_#%m%_x+(wndX-Monitor_#%monitor%_x), Monitor_#%m%_y+(wndY-Monitor_#%monitor%_y), wndWidth, wndHeight)
}
Manager_#%wndId%_monitor = m
}
Monitor_setWindowTag(t) {

View file

@ -109,12 +109,15 @@ View_delWnd(m, v, wndId) {
View_arrange(m, v) {
Local fn, l, wndIds
; All window actions are performed on independent windows. A delay won't help.
SetWinDelay, 0
l := View_#%m%_#%v%_layout_#1
fn := Config_layoutFunction_#%l%
View_getTiledWndIds(m, v, wndIds)
View_arrange_%fn%(m, v, wndIds)
View_updateLayout(m, v)
Bar_updateLayout(m)
SetWinDelay, 10
}
View_getTiledWndIds(m, v, ByRef tiledWndIds) {