From d67c7482e9c6ba59ebeea5c8fe9d7dc3a48fc63f Mon Sep 17 00:00:00 2001 From: joten Date: Sun, 1 Feb 2015 20:02:08 +0100 Subject: [PATCH] Revised the rule layout --- doc/CHANGES.md | 3 +++ doc/Configuring_rules.md | 4 ++-- doc/Default_configuration.md | 6 +++--- src/Config.ahk | 12 ++++++------ src/Manager.ahk | 22 ++++++++-------------- src/Window.ahk | 7 +++++++ 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index f216317..025588a 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -18,6 +18,8 @@ 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`. 6. `~` Revised the bar color scheme. +7. `~` Revised the rule layout. The third parameter is not compared to the window style anymore, but is a function name, which is +called with the window ID as a paramater, when applying the rule. | # | Configuration variables | `-` Hotkey functions | `+` Hotkey functions | | --:| ------------------------- | --------------------------------------- | ----------------------------------------------------- | @@ -62,6 +64,7 @@ not implement the functionality: `Monitor_toggleWindowTag`, `View_activateWindow | | `+` `Config_fontColor_#1` | | | | | `+` `Config_fontColor_#2` | | | | | `+` `Config_fontColor_#3` | | | +| 7. | `~` `Config_rule_#2` | | | ### 8.4.0 diff --git a/doc/Configuring_rules.md b/doc/Configuring_rules.md index a20c5fd..eb8aa73 100644 --- a/doc/Configuring_rules.md +++ b/doc/Configuring_rules.md @@ -11,7 +11,7 @@ following information: 1. class (as a regular expression) 2. title (as a regular expression) -3. window style (as a hexadecimal number or blank) +3. arbitrary criterion (as a function name, e. g. "Window_isPopup", or blank) With the second part you can give bug.n the following information on how to handle the identified windows: @@ -28,7 +28,7 @@ removed. 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=;;<window style>;<is managed>;<monitor>;<views / +`Config_rule=<class>;<title>;<function name>;<is managed>;<monitor>;<views / tags>;<is floating>;<is decorated>;<hide title>;<action on a single window>` (all in one line, ";" is not allowed as a character in the field values) diff --git a/doc/Default_configuration.md b/doc/Default_configuration.md index c2e0f43..9c9b725 100644 --- a/doc/Default_configuration.md +++ b/doc/Default_configuration.md @@ -272,9 +272,9 @@ view, not floating (i. e. tiled), the window title bar is not visible, the title is not hidden on the bug.n status bar and no window action is taken, when the window first is created. -`Config_rule_#2=.*;.*;0x80000000;0;0;0;1;1;1;` -> Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating -and the titles are hidden. +`Config_rule_#2=.*;.*;Window_isPopup;0;0;0;1;1;1;` +> Pop-up windows (style WS_POPUP) will not be managed, are floating and the +titles are hidden. `Config_rule_#3=SWT_Window0;.*;;1;0;0;0;0;0;` > Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but diff --git a/src/Config.ahk b/src/Config.ahk index 351db8f..fef9e7e 100644 --- a/src/Config.ahk +++ b/src/Config.ahk @@ -78,12 +78,12 @@ Config_init() { Config_viewFollowsTagged := False Config_viewMargins := "0;0;0;0" - ;; Config_rule_#<i> := '<class>;<title>;<style>;<is managed>;<m>;<tags>;<is floating>;<is decorated>;<hide title>;<action>' - Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;" ;; default rule - Config_rule_#2 := ".*;.*;0x80000000;0;0;0;1;1;1;" ;; Pop-up windows (style WS_POPUP=0x80000000) will not be managed, are floating and the titles are hidden. - Config_rule_#3 := "SWT_Window0;.*;;1;0;0;0;0;0;" ;; Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but should be excluded from the second rule. - Config_rule_#4 := "QWidget;.*;;1;0;0;0;0;0;" ;; ... also windows created by QT (QWidget) - Config_rule_#5 := "Xming;.*;;1;0;0;0;0;0;" ;; ... and Xming windows + ;; Config_rule_#<i> := '<class>;<title>;<function name>;<is managed>;<m>;<tags>;<is floating>;<is decorated>;<hide title>;<action>' + Config_rule_#1 := ".*;.*;;1;0;0;0;0;0;" ;; default rule + Config_rule_#2 := ".*;.*;Window_isPopup;0;0;0;1;1;1;" ;; Pop-up windows (style WS_POPUP) will not be managed, are floating and the titles are hidden. + Config_rule_#3 := "SWT_Window0;.*;;1;0;0;0;0;0;" ;; Windows created by Java (SWT) e. g. Eclipse have the style WS_POPUP, but should be excluded from the second rule. + Config_rule_#4 := "QWidget;.*;;1;0;0;0;0;0;" ;; ... also windows created by QT (QWidget) + Config_rule_#5 := "Xming;.*;;1;0;0;0;0;0;" ;; ... and Xming windows Config_rule_#6 := "MsiDialog(No)?CloseClass;.*;;1;0;0;1;1;0;" Config_rule_#7 := "AdobeFlashPlayerInstaller;.*;;1;0;0;1;0;1;" Config_rule_#8 := "CalcFrame;.*;;1;0;0;1;1;0;" diff --git a/src/Manager.ahk b/src/Manager.ahk index a619af2..dabf34c 100644 --- a/src/Manager.ahk +++ b/src/Manager.ahk @@ -95,9 +95,8 @@ Manager_activateMonitor(i, d = 0) { } } -Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating, ByRef isDecorated, ByRef hideTitle, ByRef action) -{ - Local mouseX, mouseY, wndClass, wndHeight, wndStyle, wndTitle, wndWidth, wndX, wndY +Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating, ByRef isDecorated, ByRef hideTitle, ByRef action) { + Local mouseX, mouseY, wndClass, wndHeight, wndTitle, wndWidth, wndX, wndY Local rule0, rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule8, rule9, rule10 isManaged := True @@ -111,14 +110,11 @@ Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating WinGetClass, wndClass, ahk_id %wndId% WinGetTitle, wndTitle, ahk_id %wndId% WinGetPos, wndX, wndY, wndWidth, wndHeight, ahk_id %wndId% - WinGet, wndStyle, Style, ahk_id %wndId% - If wndClass And wndTitle And Not (wndX < -4999) And Not (wndY < -4999) - { - Loop, % Config_ruleCount - { + If wndClass And wndTitle And Not (wndX < -4999) And Not (wndY < -4999) { + Loop, % Config_ruleCount { StringSplit, rule, Config_rule_#%A_index%, `; - If RegExMatch(wndClass . ";" . wndTitle, rule1 . ";" . rule2) And (rule3 = "" Or wndStyle & rule3) - { ;; The last matching rule is returned. + If RegExMatch(wndClass . ";" . wndTitle, rule1 . ";" . rule2) And (rule3 = "" Or %rule3%(wndId)) { + ;; The last matching rule is returned. isManaged := rule4 m := rule5 tags := rule6 @@ -128,9 +124,7 @@ Manager_applyRules(wndId, ByRef isManaged, ByRef m, ByRef tags, ByRef isFloating action := rule10 } } - } - Else - { + } Else { isManaged := False If wndTitle hideTitle := True @@ -223,7 +217,7 @@ Manager_getWindowInfo() WinGet, aWndMinMax, MinMax, ahk_id %aWndId% WinGetPos, aWndX, aWndY, aWndWidth, aWndHeight, ahk_id %aWndId% text := "ID: " aWndId "`nclass:`t" aWndClass "`ntitle:`t" aWndTitle - rule := "Config_rule=" aWndClass ";" aWndTitle ";" aWndStyle + rule := "Config_rule=" aWndClass ";" aWndTitle ";" If InStr(Manager_managedWndIds, aWndId ";") rule .= ";1" Else diff --git a/src/Window.ahk b/src/Window.ahk index c36fe5a..41718e3 100644 --- a/src/Window.ahk +++ b/src/Window.ahk @@ -96,6 +96,13 @@ Window_isHung(wndId) { Return, 0 } +Window_isPopup(wndId) { + WS_POPUP = 0x80000000 + WinGet, wndStyle, Style, ahk_id %wndId% + + Return, wndStyle & WS_POPUP +} + Window_isProg(wndId) { WinGetClass, wndClass, ahk_id %wndId% WinGetTitle, wndTitle, ahk_id %wndId%