-
Notifications
You must be signed in to change notification settings - Fork 0
Add "Remember for this session" option to display-change prompt #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -453,28 +453,108 @@ Manager_moveWindow() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_onDisplayChange(a, wParam, uMsg, lParam) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Local doChange := (Config_monitorDisplayChangeMessages = "on") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Global Config_monitorDisplayChangeMessages, Manager_displayChangeSessionChoice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Debug_logMessage("DEBUG[1] Manager_onDisplayChange( a: " . a . ", uMsg: " . uMsg . ", wParam: " . wParam . ", lParam: " . lParam . " )", 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If !(Config_monitorDisplayChangeMessages = "on" || Config_monitorDisplayChangeMessages = "off" || Config_monitorDisplayChangeMessages = 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MsgBox, 291, , % "Would you like to reset the monitor configuration?`n'No' will only rearrange all active views.`n'Cancel' will result in no change." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IfMsgBox Yes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doChange := True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Else IfMsgBox No | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Loop, % Manager_monitorCount { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| View_arrange(A_Index, Monitor_#%A_Index%_aView_#1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar_updateView(A_Index, Monitor_#%A_Index%_aView_#1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar_updateStatus() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar_updateTitle() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| decision := Manager_displayChangeDecide(Config_monitorDisplayChangeMessages, Manager_displayChangeSessionChoice) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (decision = "prompt") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangePrompt(choice, remember) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangeRecordSessionChoice(choice, remember) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| decision := Manager_displayChangeDecide(Config_monitorDisplayChangeMessages, choice) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (doChange) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangeApply(decision) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; Returns the action to take for a WM_DISPLAYCHANGE event, given the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; persistent config setting and any session-only override the user picked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; via the "remember this decision for this session" checkbox. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; "reset" -> Manager_resetMonitorConfiguration (re-detect monitors) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; "rearrange" -> redraw active views without re-detecting monitors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; "ignore" -> no-op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; "prompt" -> caller should show the dialog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangeDecide(configValue, sessionChoice) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (sessionChoice = "yes") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return "reset" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (sessionChoice = "no") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return "rearrange" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (sessionChoice = "cancel") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return "ignore" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (configValue = "on") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return "reset" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (configValue = "off" || configValue = 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return "ignore" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return "prompt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangeApply(decision) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Global Manager_monitorCount | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (decision = "reset") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_resetMonitorConfiguration() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } Else If (decision = "rearrange") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Loop, % Manager_monitorCount { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| i := A_Index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| View_arrange(i, Monitor_#%i%_aView_#1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar_updateView(i, Monitor_#%i%_aView_#1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar_updateStatus() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bar_updateTitle() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangeRecordSessionChoice(choice, remember) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Global Manager_displayChangeSessionChoice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If (remember) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangeSessionChoice := choice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Manager_displayChangePrompt(ByRef choice, ByRef remember) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Global MgrDispChange_choice, MgrDispChange_remember, MgrDispChange_done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MgrDispChange_choice := "cancel" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MgrDispChange_remember := False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MgrDispChange_done := False | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:New, +OwnDialogs +AlwaysOnTop +ToolWindow, bug.n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:Add, Text, , Would you like to reset the monitor configuration?`n'No' will only rearrange all active views.`n'Cancel' will result in no change. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:Add, Checkbox, vMgrDispChange_remember, Remember this decision for this session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnYes Default w80, &Yes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnNo x+10 w80, &No | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnCancel x+10 w80, &Cancel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Gui, MgrDispChange:Show | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| While (!MgrDispChange_done) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sleep, 50 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| choice := MgrDispChange_choice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| remember := MgrDispChange_remember | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+514
to
+531
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MgrDispChange_choice := "cancel" | |
| MgrDispChange_remember := False | |
| MgrDispChange_done := False | |
| Gui, MgrDispChange:New, +OwnDialogs +AlwaysOnTop +ToolWindow, bug.n | |
| Gui, MgrDispChange:Add, Text, , Would you like to reset the monitor configuration?`n'No' will only rearrange all active views.`n'Cancel' will result in no change. | |
| Gui, MgrDispChange:Add, Checkbox, vMgrDispChange_remember, Remember this decision for this session | |
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnYes Default w80, &Yes | |
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnNo x+10 w80, &No | |
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnCancel x+10 w80, &Cancel | |
| Gui, MgrDispChange:Show | |
| While (!MgrDispChange_done) | |
| Sleep, 50 | |
| choice := MgrDispChange_choice | |
| remember := MgrDispChange_remember | |
| Static promptOpen := False | |
| if (promptOpen) { | |
| choice := "cancel" | |
| remember := False | |
| Return | |
| } | |
| promptOpen := True | |
| Try { | |
| MgrDispChange_choice := "cancel" | |
| MgrDispChange_remember := False | |
| MgrDispChange_done := False | |
| Gui, MgrDispChange:New, +OwnDialogs +AlwaysOnTop +ToolWindow, bug.n | |
| Gui, MgrDispChange:Add, Text, , Would you like to reset the monitor configuration?`n'No' will only rearrange all active views.`n'Cancel' will result in no change. | |
| Gui, MgrDispChange:Add, Checkbox, vMgrDispChange_remember, Remember this decision for this session | |
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnYes Default w80, &Yes | |
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnNo x+10 w80, &No | |
| Gui, MgrDispChange:Add, Button, gMgrDispChange_btnCancel x+10 w80, &Cancel | |
| Gui, MgrDispChange:Show | |
| While (!MgrDispChange_done) | |
| Sleep, 50 | |
| choice := MgrDispChange_choice | |
| remember := MgrDispChange_remember | |
| } Finally { | |
| promptOpen := False | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,129 @@ | ||||||||
| /* | ||||||||
| Tests for the WM_DISPLAYCHANGE decision logic and session-choice | ||||||||
| recording in src/Manager.ahk. | ||||||||
|
|
||||||||
| The dialog itself (Manager_displayChangePrompt) is a Gui modal and is | ||||||||
| not exercised here — these tests cover the pure decision function | ||||||||
| (Manager_displayChangeDecide) and the session-storage helper | ||||||||
| (Manager_displayChangeRecordSessionChoice) that together drive what | ||||||||
| happens when the user ticks "Remember this decision for this session". | ||||||||
| */ | ||||||||
|
|
||||||||
| class TestManagerDisplayChange | ||||||||
| { | ||||||||
| ;; --- Manager_displayChangeDecide: persistent config, no session override --- | ||||||||
|
|
||||||||
| Decide_PromptWhenAskAndNoSession() | ||||||||
| { | ||||||||
| Yunit.Assert(Manager_displayChangeDecide("ask", "") = "prompt" | ||||||||
| , "config=ask + no session choice should prompt; got " . Manager_displayChangeDecide("ask", "")) | ||||||||
| } | ||||||||
|
|
||||||||
| Decide_ResetWhenConfigOn() | ||||||||
| { | ||||||||
| Yunit.Assert(Manager_displayChangeDecide("on", "") = "reset" | ||||||||
| , "config=on should reset; got " . Manager_displayChangeDecide("on", "")) | ||||||||
| } | ||||||||
|
|
||||||||
| Decide_IgnoreWhenConfigOff() | ||||||||
| { | ||||||||
| Yunit.Assert(Manager_displayChangeDecide("off", "") = "ignore" | ||||||||
| , "config=off should ignore; got " . Manager_displayChangeDecide("off", "")) | ||||||||
| } | ||||||||
|
|
||||||||
| Decide_IgnoreWhenConfigZero() | ||||||||
| { | ||||||||
| ;; Legacy: numeric 0 is accepted as a synonym for "off" (Manager.ahk:692). | ||||||||
|
||||||||
| ;; Legacy: numeric 0 is accepted as a synonym for "off" (Manager.ahk:692). | |
| ;; Legacy: numeric 0 is accepted as a synonym for "off" in the | |
| ;; Manager_displayChangeDecide branch that treats 0 as off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old
MsgBox, 291had default button #2 ("No"). This custom Gui setsDefaulton the Yes button, which changes behavior (pressing Enter now triggers reset instead of rearrange). Consider movingDefaultto the No button to preserve the previous safer default.