test_create_and_remove_desktop: Revert original focus#44
Open
stdedos wants to merge 1 commit into
Open
Conversation
When using `current_desktop.go()`, in 18363, the focus is not restored to the original window Signed-off-by: Stavros Ntentos <133706+stdedos@users.noreply.github.com>
stdedos
commented
Feb 29, 2024
| @@ -95,6 +95,7 @@ def test_create_and_remove_desktop(): | |||
|
|
|||
| time.sleep(1) # Got to wait for the animation before we can return | |||
Contributor
Author
There was a problem hiding this comment.
Do you think that could be replaced with
?
And/or overload the "future method" with time.sleep(1) on unsupporting platforms?
(However, I wouldn't know how to code that 😅)
Owner
|
Is this a problem for normal usage? e.g. When you change desktops using |
Contributor
Author
|
No, that's not it. Switching to a new desktop, "naturally" has no window to focus. If I just switch back-and-forth from desktops that have windows, it works. If I switch to an existing desktop that has no windows, it still works: Python 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.22.2 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from pyvda import (
...: AppView,
...: VirtualDesktop,
...: get_virtual_desktops,
...: get_apps_by_z_order,
...: )
...: import pprint
...: from win32gui import GetWindowText, GetForegroundWindow
...: import time
...:
In [2]:
...: pprint.pprint([GetWindowText(a.hwnd) for a in get_apps_by_z_order()])
...: print("Now focused on: ", end="")
...: print(GetWindowText(GetForegroundWindow()))
...: VirtualDesktop(3).go()
...: time.sleep(1)
...: pprint.pprint([GetWindowText(a.hwnd) for a in get_apps_by_z_order()])
...: print("Now focused on: ", end="")
...: print(GetWindowText(GetForegroundWindow()))
...: VirtualDesktop(1).go()
...: time.sleep(1)
...: pprint.pprint([GetWindowText(a.hwnd) for a in get_apps_by_z_order()])
...: print("Now focused on: ", end="")
...: print(GetWindowText(GetForegroundWindow()))
['IPython: E:pyvda/pyvda',
'Extensions - Refined GitHub - Google Chrome']
Now focused on: IPython: E:pyvda/pyvda
[]
Now focused on:
['IPython: E:pyvda/pyvda',
'Extensions - Refined GitHub - Google Chrome']
Now focused on: IPython: E:pyvda/pyvda |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using
current_desktop.go(), in 18363, the focus is not restored to the original windowSigned-off-by: Stavros Ntentos 133706+stdedos@users.noreply.github.com