Renamed the previously moved functions

(window-related)
This commit is contained in:
joten 2015-01-25 19:16:30 +01:00
parent c7b6c0a388
commit 71e4025a09
10 changed files with 100 additions and 95 deletions

View file

@ -8,7 +8,12 @@
### 9.0.0
1. `~` Renamed the function `Manager_toggleDecor` to `Window_toggleDecor`
| # | Configuration variables | Hotkeys |
| --:| ----------------------- | -------------------------------- |
| 1. | | `-` `#+d::Manager_toggleDecor()` |
| | | `+` `#+d::Window_toggleDecor()` |
### 8.4.0

View file

@ -25,7 +25,7 @@ an integer >= 0, 0 means the currently active view)?
5. Is the window decorated (0 = no, 1 = yes)? If not, the window title bar is
removed.
6. Should the title text be hidden in the bug.n bar (0 = no, 1 = yes)?
7. A special single window action (`Close` or `Maximize` or blank).
7. A special single window action (`close` or `maximize` or blank).
The general format of a rule added to `Config.ini` is as follows:
`Config_rule=<class>;<title>;<window style>;<is managed>;<monitor>;<views /
@ -59,11 +59,11 @@ The following `Config.ini` line replaces rule number 11 in the default
configuration, putting windows of 'Mozilla Firefox' on view 5, keeping the
title bar visible and maximizing them.
`Config_rule_#11=MozillaWindowClass;.*Mozilla Firefox;;1;0;16;0;1;0;Maximize`
`Config_rule_#11=MozillaWindowClass;.*Mozilla Firefox;;1;0;16;0;1;0;maximize`
#### Mozilla Thunderbird
The following `Config.ini` line adds a rule, putting windows of 'Mozilla
Thunderbird' on view 4, keeping the title bar visible and maximizing them.
`Config_rule=MozillaWindowClass;.*Mozilla Thunderbird;;1;0;8;0;1;0;Maximize`
`Config_rule=MozillaWindowClass;.*Mozilla Thunderbird;;1;0;8;0;1;0;maximize`

View file

@ -276,8 +276,8 @@ reason as above.
Config_rule_#8=CalcFrame;.*;;1;0;0;1;1;0;
Config_rule_#9=MozillaDialogClass;.*;;1;0;0;1;1;0;
Config_rule_#10=_sp;_sp;;1;0;0;1;0;1;
Config_rule_#11=MozillaWindowClass;.*Mozilla Firefox;;1;0;0;0;1;0;Maximize
Config_rule_#12=Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;Maximize
Config_rule_#11=MozillaWindowClass;.*Mozilla Firefox;;1;0;0;0;1;0;maximize
Config_rule_#12=Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;maximize
`Config_ruleCount=12`
> This variable will be automatically set to the total number of active rules

View file

@ -36,7 +36,7 @@ quitting bug.n.
`#c::Manager_closeWindow()`
> Close the active window.
`#+d::Manager_toggleDecor()`
`#+d::Window_toggleDecor()`
> Show / Hide the title bar of the active window.
`#+f::View_toggleFloating()`

View file

@ -89,8 +89,8 @@ Config_init()
Config_rule_#8 := "CalcFrame;.*;;1;0;0;1;1;0;"
Config_rule_#9 := "MozillaDialogClass;.*;;1;0;0;1;1;0;"
Config_rule_#10 := "_sp;_sp;;1;0;0;1;0;1;"
Config_rule_#11 := "MozillaWindowClass;.*Mozilla Firefox;;1;0;0;0;1;0;Maximize"
Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;Maximize"
Config_rule_#11 := "MozillaWindowClass;.*Mozilla Firefox;;1;0;0;0;1;0;maximize"
Config_rule_#12 := "Chrome_WidgetWin_1;.*;;1;0;0;0;1;0;maximize"
;; @TODO [v9] Config_rule_#13 := "Chrome_WidgetWin_1;.*;0x80000000;0;0;0;1;1;0;" -- else pop-up windows are treated as new main windows, since #12 overrides #2
Config_ruleCount := 12 ;; This variable has to be set to the total number of active rules above.
@ -391,7 +391,7 @@ Config_saveSession(original, target)
#+Up::View_shuffleWindow(-1)
#+Enter::View_shuffleWindow(0)
#c::Manager_closeWindow()
#+d::Manager_toggleDecor()
#+d::Window_toggleDecor()
#+f::View_toggleFloating()
#+m::Manager_moveWindow()
#+s::Manager_sizeWindow()

View file

@ -127,14 +127,14 @@ Debug_logWindowInfo(wndId)
isDecorated := " "
WinGet, wndStyle, Style, ahk_id %wndId%
WinGetPos, wndX, wndY, wndW, wndH, ahk_id %wndId%
If Manager_isGhost(wndId)
If Window_isGhost(wndId)
isGhost := "*"
Else
isGhost := " "
DetectHiddenWindows, %detect_state%
;; Intentionally don't detect hidden windows here to see what Manager_hungTest does
If Manager_isHung(wndId)
If Window_isHung(wndId)
isResponsive := " "
Else
isResponsive := "*"

View file

@ -199,10 +199,10 @@ Manager_cleanup()
Manager_hideShow := True
Loop, PARSE, wndIds, `;
{
Manager_winShow(A_LoopField)
Window_show(A_LoopField)
If Not Config_showBorder
Manager_winSet("Style", "+0x40000", A_LoopField)
Manager_winSet("Style", "+0xC00000", A_LoopField)
Window_set(A_LoopField, "Style", "+0x40000")
Window_set(A_LoopField, "Style", "+0xC00000")
}
;; Show the task bar.
@ -222,8 +222,8 @@ Manager_cleanup()
View_arrange(m, A_Index, True)
}
}
Manager_winSet("AlwaysOnTop", "On", aWndId)
Manager_winSet("AlwaysOnTop", "Off", aWndId)
Window_set(aWndId, "AlwaysOnTop", "On")
Window_set(aWndId, "AlwaysOnTop", "Off")
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_REMOVE := 0x1), "UInt", &Bar_appBarData)
;; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
@ -243,7 +243,7 @@ Manager_closeWindow() {
} Else {
View_activateWindow(1)
}
Manager_winClose(aWndId)
Window_close(aWndId)
}
}
@ -271,7 +271,7 @@ Manager_getWindowInfo()
} Else
rule .= ";0;"
If (aWndMinMax = 1)
rule .= "Maximize"
rule .= "maximize"
text .= "`nprocess:`t" aWndProcessName "`nstyle:`t" aWndStyle "`nmetrics:`tx: " aWndX ", y: " aWndY ", width: " aWndWidth ", height: " aWndHeight "`ntags:`t" Manager_#%aWndId%_tags
If Manager_#%aWndId%_isFloating
text .= " (floating)"
@ -337,8 +337,8 @@ Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hi
If (isManaged)
{
If (action = "Close" Or action = "Maximize")
Manager_win%action%(wndId)
If (action = "close" Or action = "maximize")
Window_%action%(wndId)
Manager_managedWndIds .= wndId ";"
Monitor_moveWindow(m, wndId)
@ -348,9 +348,9 @@ Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hi
Manager_#%wndId%_area := 0
If Not Config_showBorder
Manager_winSet("Style", "-0x40000", wndId)
Window_set(wndId, "Style", "-0x40000")
If Not Manager_#%wndId%_isDecorated
Manager_winSet("Style", "-0xC00000", wndId)
Window_set(wndId, "Style", "-0xC00000")
a := Manager_#%wndId%_tags & (1 << (Monitor_#%m%_aView_#1 - 1))
If a
@ -362,7 +362,7 @@ Manager__setWinProperties(wndId, isManaged, m, tags, isDecorated, isFloating, hi
Else
{
Manager_hideShow := True
Manager_winHide(wndId)
Window_hide(wndId)
Manager_hideShow := False
}
}
@ -384,10 +384,10 @@ Manager_manage(preferredMonitor, preferredView, wndId)
Return
body := 0
If Manager_isGhost(wndId)
If Window_isGhost(wndId)
{
Debug_logMessage("DEBUG[2] A window has given up the ghost (Ghost wndId: " . wndId . ")", 2)
body := Manager_findHung(wndId)
body := Window_findHung(wndId)
If body
{
isManaged := InStr(Manager_managedWndIds, body ";")
@ -445,9 +445,9 @@ Manager_maximizeWindow()
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating()
Manager_winSet("Top", "", aWndId)
Window_set(aWndId, "Top", "")
Manager_winMove(aWndId, Monitor_#%Manager_aMonitor%_x, Monitor_#%Manager_aMonitor%_y, Monitor_#%Manager_aMonitor%_width, Monitor_#%Manager_aMonitor%_height)
Window_move(aWndId, Monitor_#%Manager_aMonitor%_x, Monitor_#%Manager_aMonitor%_y, Monitor_#%Manager_aMonitor%_width, Monitor_#%Manager_aMonitor%_height)
}
Manager_moveWindow()
@ -459,7 +459,7 @@ Manager_moveWindow()
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating()
Manager_winSet("Top", "", aWndId)
Window_set(aWndId, "Top", "")
WM_SYSCOMMAND = 0x112
SC_MOVE = 0xF010
@ -606,7 +606,7 @@ Manager_onShellMessage(wParam, lParam) {
{
Loop, % wndId0
{
Manager_winHide(wndId%A_Index%)
Window_hide(wndId%A_Index%)
}
}
Else If (Config_onActiveHiddenWnds = "tag")
@ -833,7 +833,7 @@ Manager_sizeWindow()
l := View_#%Manager_aMonitor%_#%v%_layout_#1
If Not Manager_#%aWndId%_isFloating And Not (Config_layoutFunction_#%l% = "")
View_toggleFloating()
Manager_winSet("Top", "", aWndId)
Window_set(aWndId, "Top", "")
WM_SYSCOMMAND = 0x112
SC_SIZE = 0xF000
@ -868,7 +868,7 @@ Manager_sync(ByRef wndIds = "")
If flag
a := flag
}
Else If Not Manager_isHung(wndId%A_Index%)
Else If Not Window_isHung(wndId%A_Index%)
{
;; This is a window that is already managed but was brought into focus by something.
;; Maybe it would be useful to do something with it.
@ -1076,7 +1076,7 @@ Manager__restoreWindowState(filename)
hideTitle := items%j%
Manager__setWinProperties(i, isManaged, m, v, isDecorated, isFloating, hideTitle )
;Manager_winHide(i)
;Window_hide(i)
candidate_set := candidate_set . i . ";"
}
@ -1166,7 +1166,7 @@ Manager_unmanage(wndId) {
View_activateWindow(1)
;; Do our best to make sure that any unmanaged windows are left visible.
Manager_winShow(wndId)
Window_show(wndId)
a := Manager_#%wndId%_tags & 1 << Monitor_#%Manager_aMonitor%_aView_#1 - 1
Loop, % Config_viewCount
{

View file

@ -78,7 +78,7 @@ Monitor_activateView(v)
Loop, PARSE, wndIds, `;
{
If Not (Manager_#%A_LoopField%_tags & (1 << v - 1))
Manager_winHide(A_LoopField)
Window_hide(A_LoopField)
}
SetWinDelay, 10
DetectHiddenWindows, On
@ -268,7 +268,7 @@ Monitor_setWindowTag(t)
Else
{
Manager_hideShow := True
Manager_winHide(aWndId)
Window_hide(aWndId)
Manager_hideShow := False
If Config_dynamicTiling
View_arrange(Manager_aMonitor, aView)
@ -352,7 +352,7 @@ Monitor_toggleWindowTag(t)
If (t = Monitor_#%Manager_aMonitor%_aView_#1)
{
Manager_hideShow := True
Manager_winHide(aWndId)
Window_hide(aWndId)
Manager_hideShow := False
wndId := SubStr(View_#%Manager_aMonitor%_#%t%_wndIds, 1, InStr(View_#%Manager_aMonitor%_#%t%_wndIds, ";")-1)
Manager_winActivate(wndId)

View file

@ -53,7 +53,7 @@ View_activateWindow(d)
If (wndId0 > 1)
{
If Manager_#%aWndId%_isFloating
Manager_winSet("Bottom", "", aWndId)
Window_set(aWndId, "Bottom", "")
Loop, % wndId0
{
If (wndId%A_Index% = aWndId)
@ -73,8 +73,8 @@ View_activateWindow(d)
{
Debug_logMessage("DEBUG[2] Next wndId index: " . j, 2, False)
wndId := wndId%j%
Manager_winSet("AlwaysOnTop", "On", wndId)
Manager_winSet("AlwaysOnTop", "Off", wndId)
Window_set(wndId, "AlwaysOnTop", "On")
Window_set(wndId, "AlwaysOnTop", "Off")
;; If there are hung windows on the screen, we still want to be able to cycle through them.
failure := Manager_winActivate(wndId)
@ -325,7 +325,7 @@ View_getTiledWndIds(m, v)
StringTrimRight, wndIds, View_#%m%_#%v%_wndIds, 1
Loop, PARSE, wndIds, `;
{
If Not Manager_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Manager_isHung(A_LoopField)
If Not Manager_#%A_LoopField%_isFloating And WinExist("ahk_id " A_LoopField) and Not Window_isHung(A_LoopField)
{
n += 1
tiledWndIds .= A_LoopField ";"
@ -356,7 +356,7 @@ View_moveWindow(i=0, d=0) {
If (Config_layoutFunction_#%l% = "tile" And InStr(Manager_managedWndIds, aWndId ";") And Not (i = 0 And d = 0) And i <= View_#%m%_#%v%_area_#0) {
If (i = 0)
i := Manager_loop(Manager_#%aWndId%_area, d, 1, View_#%m%_#%v%_area_#0)
Manager_winMove(aWndId, View_#%m%_#%v%_area_#%i%_x, View_#%m%_#%v%_area_#%i%_y, View_#%m%_#%v%_area_#%i%_width, View_#%m%_#%v%_area_#%i%_height)
Window_move(aWndId, View_#%m%_#%v%_area_#%i%_x, View_#%m%_#%v%_area_#%i%_y, View_#%m%_#%v%_area_#%i%_width, View_#%m%_#%v%_area_#%i%_height)
Manager_#%aWndId%_area := i
If Config_mouseFollowsFocus {
WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId%
@ -719,7 +719,7 @@ View_stackWindows(arrayName, startPos, len, d, axis, x, y, w, h, padding)
Loop, % len
{
Manager_winMove(%arrayName%%i%, wndX, wndY, wndW, wndH)
Window_move(%arrayName%%i%, wndX, wndY, wndW, wndH)
i += d
wndX += dx
wndY += dy

View file

@ -13,8 +13,32 @@
@version 9.0.0
*/
Window_activate(wndId) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_activate: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinActivate, ahk_id %wndId%
WinGet, aWndId, ID, A
If (wndId != aWndId)
Return, 1
Else
Return, 0
}
}
Window_close(wndId) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_close: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinClose, ahk_id %wndId%
Return, 0
}
}
;; Given a ghost window, try to find its body. This is only known to work on Windows 7
Manager_findHung(ghostWndId) {
Window_findHung(ghostWndId) {
Global Config_ghostWndSubString
WinGetTitle, ghostWndTitle, ahk_id %ghostWndId%
@ -33,7 +57,17 @@ Manager_findHung(ghostWndId) {
Return, 0
}
Manager_isGhost(wndId) {
Window_hide(wndId) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_hide: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinHide, ahk_id %wndId%
Return, 0
}
}
Window_isGhost(wndId) {
Local wndClass, wndProc
WinGet, wndProc, ProcessName, ahk_id %wndId%
@ -46,7 +80,7 @@ Manager_isGhost(wndId) {
;; 0 - Not hung
;; 1 - Hung
Manager_isHung(wndId) {
Window_isHung(wndId) {
Local detectSetting, result, WM_NULL
WM_NULL = 0
@ -72,29 +106,9 @@ Window_isProg(wndId) {
Return, 0
}
Manager_winClose(wndId) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Manager_winClose: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinClose, ahk_id %wndId%
Return, 0
}
}
Manager_winHide(wndId) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Manager_winHide: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinHide, ahk_id %wndId%
Return, 0
}
}
Manager_winMaximize(wndId) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Manager_winMaximize: Potentially hung window " . wndId, 2)
Window_maximize(wndId) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_maximize: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinMaximize, ahk_id %wndId%
@ -102,9 +116,9 @@ Manager_winMaximize(wndId) {
}
}
Manager_winMove(wndId, x, y, width, height) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Manager_winMove: Potentially hung window " . wndId, 2)
Window_move(wndId, x, y, width, height) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_move: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinGet, wndMin, MinMax, ahk_id %wndId%
@ -116,7 +130,7 @@ Manager_winMove(wndId, x, y, width, height) {
WM_EXITSIZEMOVE = 0x0232
SendMessage, WM_ENTERSIZEMOVE, , , , ahk_id %wndId%
If ErrorLevel {
Debug_logMessage("DEBUG[2] Manager_winMove: Potentially hung window " . wndId, 1)
Debug_logMessage("DEBUG[2] Window_move: Potentially hung window " . wndId, 1)
Return, 1
} Else {
WinMove, ahk_id %wndId%, , %x%, %y%, %width%, %height%
@ -125,9 +139,9 @@ Manager_winMove(wndId, x, y, width, height) {
}
}
Manager_winSet(type, value, wndId) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Manager_winSet: Potentially hung window " . wndId, 2)
Window_set(wndId, type, value) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_set: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinSet, %type%, %value%, ahk_id %wndId%
@ -135,9 +149,9 @@ Manager_winSet(type, value, wndId) {
}
}
Manager_winShow(wndId) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Manager_winShow: Potentially hung window " . wndId, 2)
Window_show(wndId) {
If Window_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_show: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinShow, ahk_id %wndId%
@ -145,7 +159,7 @@ Manager_winShow(wndId) {
}
}
Manager_toggleDecor(wndId = 0) {
Window_toggleDecor(wndId = 0) {
Global
If (wndId = 0)
@ -153,21 +167,7 @@ Manager_toggleDecor(wndId = 0) {
Manager_#%wndId%_isDecorated := Not Manager_#%wndId%_isDecorated
If Manager_#%wndId%_isDecorated
Manager_winSet("Style", "+0xC00000", wndId)
Window_set(wndId, "Style", "+0xC00000")
Else
Manager_winSet("Style", "-0xC00000", wndId)
}
Window_activate(wndId) {
If Manager_isHung(wndId) {
Debug_logMessage("DEBUG[2] Window_activate: Potentially hung window " . wndId, 2)
Return, 1
} Else {
WinActivate, ahk_id %wndId%
WinGet, aWndId, ID, A
If (wndId != aWndId)
Return, 1
Else
Return, 0
}
Window_set(wndId, "Style", "-0xC00000")
}