Skip to content
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

Implemented Window Switch Manager #881

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

LexiconCode
Copy link
Member

@LexiconCode LexiconCode commented Feb 26, 2021

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

#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)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • 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.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests pass.

Maintainer/Reviewer Checklist

  • Basic functionality has been tested and works as claimed.
  • New documentation is clear and complete.
  • Code is clear and readable.

@LexiconCode LexiconCode self-assigned this Feb 26, 2021
@LexiconCode LexiconCode added Caster Core Spec Issues for Caster Specs that are not part of the application or language specific grammar/ccr New Feature A new feature that is not currently implemented. labels Feb 26, 2021
@LexiconCode

This comment has been minimized.

@LexiconCode LexiconCode force-pushed the windows_switch_manager branch 2 times, most recently from 8eb33a6 to de5e030 Compare March 1, 2021 02:21
@LexiconCode LexiconCode added WIP An work in progress Complete Pull request is complete and tested as defined by Contributor Testing Required Requesting testers before merge and removed WIP An work in progress labels Apr 18, 2021
@kendonB
Copy link
Collaborator

kendonB commented Jan 21, 2022

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'

@LexiconCode
Copy link
Member Author

LexiconCode commented Jan 21, 2022

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.

@drmfinlay
Copy link
Member

@LexiconCode I think I must have missed this PR. It looks quite useful, even for Dragon users.

Obviously you haven't worked on it in a while, but I would like to suggest updating the <windows> list in the grammar's process_begin() method instead of with an engine timer. Lists like this only need to be updated when the user starts speaking. Also avoids the above problem with Win32Window.is_valid.

@LexiconCode
Copy link
Member Author

LexiconCode commented May 25, 2024

That's some great feedback, I really didn't like using an engine timer wasting cycles.

@drmfinlay
Copy link
Member

Thanks! I'm not sure which grammar the rule is part of though.

Also, the is_valid property is not needed here, since get_all_windows() only returns valid windows. is_visible is probably sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Caster Core Spec Issues for Caster Specs that are not part of the application or language specific grammar/ccr Complete Pull request is complete and tested as defined by Contributor New Feature A new feature that is not currently implemented. Testing Required Requesting testers before merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants