Implemented Window Switch Manager
Description
Window Switch Manager to swap windows by saying words in their title. In addition a command to restore the last minimized window.
Commands:
"window switch <windows>" -> switch to the window with the given word in its
title. If multiple windows have that word in
their title, then you can say more words in the
window's title to disambiguate which one you
mean. If you don't, the caster messaging window will be
foregrounded instead with info on which windows
are ambiguously being matched by your keywords.
"window switch refresh" -> manually reload the list of windows. Useful while
developing if you don't want to use the timer. Command disabled
"window switch show" -> output information about which keywords can
be used on their own to switch windows and which
require multiple words.
"""
Commands have been renamed minimize win window minimize following the object verb model.
Related Issue
https://github.com/dictation-toolbox/Caster/issues/797
Motivation and Context
Motivation is to make it easy for users to switch windows by voice.
How Has This Been Tested
This is been tested on Windows 10 but should be cross-platform. The list of Windows is rebuilt every 2 seconds using a dragonfly timer updating open_windows_dictlist This allows for weighted commands rather than parsing free dictation. Testing on other systems would be beneficial as seeing if there's any impact on performance.
Types of changes
- [ ] Docs change / refactoring / dependency upgrade
- [ ] Bug fix (non-breaking change which fixes an issue or bug)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [x] Renamed existing command phrases (we discourage this without a strong rationale).
Checklist
- [ ] My code implements all the features I wish to merge in this pull request.
- [x] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests pass.
Maintainer/Reviewer Checklist
- [x] Basic functionality has been tested and works as claimed.
- [ ] New documentation is clear and complete.
- [x] Code is clear and readable.
Some work needs to be done to print out correctly unmatched commands for window titles.
Done - Waiting for any feedback before merge.
I get this one every two seconds (likely due to the refresh):
Traceback (most recent call last):
File "/home/kendonb/.local/lib/python3.8/site-packages/dragonfly/engines/base/timer.py", line 91, in call
self.function()
File "/home/kendonb/caster/castervoice/rules/core/navigation_rules/window_mgmt_rule_support.py", line 47, in refresh_open_windows_dictlist
for window in (x for x in Window.get_all_windows() if
File "/home/kendonb/caster/castervoice/rules/core/navigation_rules/window_mgmt_rule_support.py", line 48, in <genexpr>
x.is_valid and
AttributeError: 'X11Window' object has no attribute 'is_valid'
Thanks for testing this on Linux.
is_valid is Win32Window property for Windows only. It appears every two seconds because it refreshes grabbing all the windows and checks Windows to make sure they're valid.
The code should be able to be adjusted to check for OS in this case.