From be8e4a68c3f03f173186a57ea20bb5abc6f7c55a Mon Sep 17 00:00:00 2001 From: joten Date: Sat, 31 Jan 2015 01:45:36 +0100 Subject: [PATCH] Integrated bar into Shell_SecondaryTrayWnd --- src/Bar.ahk | 10 +++---- src/Main.ahk | 4 +-- src/Manager.ahk | 4 +-- src/Monitor.ahk | 76 +++++++++++++++++++------------------------------ 4 files changed, 38 insertions(+), 56 deletions(-) diff --git a/src/Bar.ahk b/src/Bar.ahk index b99543b..a1fc9dc 100644 --- a/src/Bar.ahk +++ b/src/Bar.ahk @@ -23,7 +23,7 @@ Bar_init(m) { wndWidth := Config_barWidth wndWidth := Round(wndWidth * Config_scalingFactor) - If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) { + If (Config_verticalBarPos = "tray" And Monitor_#%m%_taskBarClass) { Bar_ctrlHeight := Round(Bar_ctrlHeight * Config_scalingFactor) Bar_height := Round(Bar_height * Config_scalingFactor) } @@ -123,7 +123,7 @@ Bar_init(m) { x1 := Config_horizontalBarPos Else If (Config_horizontalBarPos < 0) x1 := Monitor_#%m%_width - wndWidth / Config_scalingFactor + Config_horizontalBarPos - If Not (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) + If Not (Config_verticalBarPos = "tray" And Monitor_#%m%_taskBarClass) x1 += Monitor_#%m%_x x1 := Round(x1) @@ -137,8 +137,8 @@ Bar_init(m) { Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle% WinSet, Transparent, %Config_barTransparency%, %wndTitle% wndId := WinExist(wndTitle) - If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) { - trayWndId := WinExist("ahk_class Shell_TrayWnd") + If (Config_verticalBarPos = "tray" And Monitor_#%m%_taskBarClass) { + trayWndId := WinExist("ahk_class " Monitor_#%m%_taskBarClass) DllCall("SetParent", "UInt", wndId, "UInt", trayWndId) } Else { appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg") @@ -343,7 +343,7 @@ Bar_toggleCommandGui() { Bar_cmdGuiIsVisible := True x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W - If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray" And (Manager_taskBarPos = "top" Or Not Manager_aMonitor = Manager_taskBarMonitor)) + If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray") And (Manager_taskBarPos = "top" Or Not Monitor_#%Manager_aMonitor%_taskBarClass) y := Monitor_#%Manager_aMonitor%_y Else y := Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height - Bar_#0_#0H diff --git a/src/Main.ahk b/src/Main.ahk index 803518b..480a6fd 100644 --- a/src/Main.ahk +++ b/src/Main.ahk @@ -191,10 +191,10 @@ Main_reload() { Monitor_getWorkArea(A_Index) Bar_init(A_Index) + If Monitor_%A_Index%_taskBarClass And Not (Monitor_%A_Index%_showTaskBar = Config_showTaskBar) + Monitor_toggleTaskBar() } Bar_initCmdGui() - If Not (Manager_showTaskBar = Config_showTaskBar) - Monitor_toggleTaskBar() Bar_updateStatus() Bar_updateTitle() Loop, % Manager_monitorCount diff --git a/src/Manager.ahk b/src/Manager.ahk index 07b0371..ec0bcda 100644 --- a/src/Manager.ahk +++ b/src/Manager.ahk @@ -24,8 +24,6 @@ Manager_init() ; New/closed windows, active changed, Manager_windowsDirty := 0 Manager_aMonitor := 1 - Manager_taskBarMonitor := "" - Manager_showTaskBar := True doRestore := 0 If (Config_autoSaveSession = "ask") @@ -164,11 +162,11 @@ Manager_cleanup() Manager_hideShow := False ;; Restore window positions and sizes. - Manager_showTaskBar := True Loop, % Manager_monitorCount { m := A_Index Monitor_#%m%_showBar := False + Monitor_#%m%_showTaskBar := True Monitor_getWorkArea(m) Loop, % Config_viewCount { diff --git a/src/Monitor.ahk b/src/Monitor.ahk index 26d4637..fb5eb46 100644 --- a/src/Monitor.ahk +++ b/src/Monitor.ahk @@ -13,17 +13,16 @@ @version 9.0.0 */ -Monitor_init(m, doRestore) -{ +Monitor_init(m, doRestore) { Global Monitor_#%m%_aView_#1 := 1 Monitor_#%m%_aView_#2 := 1 Monitor_#%m%_showBar := Config_showBar + Monitor_#%m%_showTaskBar := Config_showTaskBar + Monitor_#%m%_taskBarClass := "" Loop, % Config_viewCount - { View_init(m, A_Index) - } If doRestore Config_restoreLayout(Main_autoLayout, m) Else @@ -121,8 +120,7 @@ Monitor_get(x, y) Return, m } -Monitor_getWorkArea(m) -{ +Monitor_getWorkArea(m) { Local bHeight, bTop, x, y Local monitor, monitorBottom, monitorLeft, monitorRight, monitorTop Local wndClasses, wndHeight, wndId, wndWidth, wndX, wndY @@ -136,40 +134,35 @@ Monitor_getWorkArea(m) Loop, PARSE, wndClasses, `; { wndId := WinExist("ahk_class " A_LoopField) - If wndId - { + If wndId { WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId% x := wndX + wndWidth / 2 y := wndY + wndHeight / 2 - If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) - { - If (A_LoopField = "Shell_TrayWnd") - Manager_taskBarMonitor := m + If (x >= monitorLeft && x <= monitorRight && y >= monitorTop && y <= monitorBottom) { + If (A_LoopField = "Shell_TrayWnd") Or (A_LoopField = "Shell_SecondaryTrayWnd") + Monitor_#%m%_taskBarClass := A_LoopField - If (wndHeight < wndWidth) - { ;; Horizontal - If (wndY <= monitorTop) - { ;; Top + If (wndHeight < wndWidth) { + ;; Horizontal + If (wndY <= monitorTop) { + ;; Top wndHeight += wndY - monitorTop monitorTop += wndHeight If (A_LoopField = "Shell_TrayWnd") Manager_taskBarPos := "top" - } - Else - { ;; Bottom + } Else { + ;; Bottom wndHeight := monitorBottom - wndY monitorBottom -= wndHeight } - } - Else - { ;; Vertical - If (wndX <= monitorLeft) - { ;; Left + } Else { + ;; Vertical + If (wndX <= monitorLeft) { + ;; Left wndWidth += wndX monitorLeft += wndWidth - } - Else - { ;; Right + } Else { + ;; Right wndWidth := monitorRight - wndX monitorRight -= wndWidth } @@ -179,15 +172,11 @@ Monitor_getWorkArea(m) } bHeight := Round(Bar_height / Config_scalingFactor) bTop := 0 - If Monitor_#%m%_showBar - { - If (Config_verticalBarPos = "top" Or (Config_verticalBarPos = "tray" And Not m = Manager_taskBarMonitor)) - { + If Monitor_#%m%_showBar { + If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray") And Not Monitor_#%m%_taskBarClass { bTop := monitorTop monitorTop += bHeight - } - Else If (Config_verticalBarPos = "bottom") - { + } Else If (Config_verticalBarPos = "bottom") { bTop := monitorBottom - bHeight monitorBottom -= bHeight } @@ -291,24 +280,19 @@ Monitor_toggleNotifyIconOverflowWindow() } } -Monitor_toggleTaskBar() -{ +Monitor_toggleTaskBar() { Local m m := Manager_aMonitor - If (m = Manager_taskBarMonitor) - { - Manager_showTaskBar := Not Manager_showTaskBar + If Monitor_#%m%_taskBarClass { + Monitor_#%m%_showTaskBar := Not Monitor_#%m%_showTaskBar Manager_hideShow := True - If Not Manager_showTaskBar - { + If Not Monitor_#%m%_showTaskBar { WinHide, Start ahk_class Button - WinHide, ahk_class Shell_TrayWnd - } - Else - { + WinHide, % "ahk_class " Monitor_#%m%_taskBarClass + } Else { WinShow, Start ahk_class Button - WinShow, ahk_class Shell_TrayWnd + WinShow, % "ahk_class " Monitor_#%m%_taskBarClass } Manager_hideShow := False Monitor_getWorkArea(m)