Skip to content

Windows 10: NVDA does not report which desktop I am on when I switch amongst multiple desktops #5641

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

Closed
pranavlal opened this issue Dec 30, 2015 · 18 comments · Fixed by #8259 or #14932
Labels
app/windows-interface Interactions between NVDA and the default Windows GUI
Milestone

Comments

@pranavlal
Copy link

NVDA does not report which desktop I am on when I switch among multiple desktops in windows 10 Professional. To duplicate this, do the following. From with windows 10:

  1. Get to the desktop with windows+d or to the task bar with windows+m.
  2. Hit windows+ctrl+d to create a new desktop.
    Note:
    You will not be told that a new desktop has been created. I believe sighted users do not get a notification either but there is reference to the "show desktop" button appearing.
  3. Use control+windows+right arrow to switch to the next desktop.

You will not hear any output from NVDA. I would expect NVDA to say something like desktop1, desktop 2 etc.
Note:
You can hit ctrl+windows+left arrow to switch to a previous desktop but NVDA will not speak which desktop I am on.

As regards the use case for such a notification:

  1. I may not remember what state I left that desktop in therefore it is handy to know that the desktop has changed.
  2. I may want to skip that desktop and go to another desktop so the notification will help with rapid navigation.

I am using windows 10 professional 64bit and NVDA 2015.4.

@jcsteh
Copy link
Contributor

jcsteh commented Jan 3, 2016 via email

@pranavlal
Copy link
Author

pranavlal commented Jan 4, 2016

Hi,

See https://github.com/Ciantic/VirtualDesktopAccessor

For a library that lets you access which desktop you are on. The trouble is that it asks for 64bit python.

@ehollig
Copy link
Collaborator

ehollig commented Aug 16, 2017

Is there a way to get the name of the current desktop in Windows 10,1703? With Narrator, if I switch between desktop, Narrator correctly announces the name of the desktop. Example: Desktop 1, Desktop 2, etc. CC @jcsteh

@jcsteh
Copy link
Contributor

jcsteh commented Aug 16, 2017

Interesting. As far as I recall, Narrator didn't previously do this, so this is new if I'm correct. I still can't find any public APIs to get the current desktop name, nor can I see any way to do it with UIA (but that doesn't mean there isn't something I don't know about). They're possibly using the undocumented APIs used by the VirtualDesktopAccessor project linked above.

I took a quick look at VirtualDesktopAccessor. It's all COM interfaces, so we could wrap them with Python comtypes with a bit of work. However, it's probably just easier to use the library. I'd prefer not to have a separate dll if possible, though we'd want to prefix the exported names from the dll if we built it into nvdaHelperLocalWin10. Note that the actual functions (even the code) are in dllmain.h.

@jcsteh
Copy link
Contributor

jcsteh commented Apr 16, 2018

You can now get the name of the desktop using IAccessible (or presumably UIA). It's exposed as the name of the desktop window. It also fires a nameChange event when it changes.

The tricky part is how to map this in NVDA. We choose to only use a Window NVDAObject for the desktop window, as we don't want to deal with the client IAccessible. To work around that, we can either implement an IAccessible overlay to capture the nameChange event or special case the desktop nameChange event in IAccessibleHandler. No big deal. The problem is that if there is a foreground change (which there often is, but not always), the desktop name gets silenced before it can speak because we cancel speech for foreground events. To make matters more confusing, there won't be a foreground event if switching desktops ends up keeping you in the same app, which can happen if you were focused on the desktop itself (e.g. Windows+m in both desktops).

We could re-visit the cancelSpeech in event_foreground, but that's probably risky. Otherwise, I guess we'll have to special case this somehow in eventHandler. My original thought was to have the event that reports the desktop change get executed after the foreground event. It feels pretty weird to fire a desktop change event after foreground, though. Perhaps a better idea is to set things up so that event_foreground always fires for desktop changes and it handles the desktop name change if there was one.

@jcsteh
Copy link
Contributor

jcsteh commented Apr 19, 2020

Reopening, since this was reverted (#9629) before it ever got into the release.

@jcsteh jcsteh removed this from the 2019.2 milestone Apr 19, 2020
@jcsteh
Copy link
Contributor

jcsteh commented Apr 19, 2020

I suspect the reason #8259 was causing problems for some users is that even though we were disabling the change handling for <= Windows 10 May 2019, the Desktop IAccessible object's name property still would have called accName on the Desktop IAccessible. That means we probably could have called it in some cases, even on Windows 10 builds where this caused freezes. I'm going to submit a revised PR which deals with this.

@feerrenrut feerrenrut added the app/windows-interface Interactions between NVDA and the default Windows GUI label May 1, 2020
josephsl added a commit to josephsl/nvda that referenced this issue Sep 6, 2021
Use:
* controlTypes.Role.WINDOW
* winVersion.getWinVer/WIN10_1903
@marrie
Copy link

marrie commented Jan 31, 2022

You can now rename desktops by right clicking on said desktop. Problem: nvda does not read the name of the desktops you are on. I hear "desktop 1, desktop 2, etc.

  1. launch a virtual desktop with win control D.
  2. you will hear desktop 2 in my case.
  3. navigate back and forth with win control left and right.
  4. you will hear "desktop 1, desktop 2"
  5. navigate to the task bar with win plus t
  6. shift tab and click the show task view button
  7. navigate to the desktops button
  8. click the show desktops button.
  9. now right click the desktops and you will see a rename desktop item.
    This is when NVDA does not read the names of the desktops you set up. I could have a work desktop and a streaming desktop but they will be called desktop 1 and desktop 2 respectively.

@josephsl
Copy link
Collaborator

josephsl commented Jan 31, 2022 via email

@marrie
Copy link

marrie commented Feb 1, 2022 via email

@josephsl
Copy link
Collaborator

Hi,

Sorry for the late response.

About desktop title being part of Explorer title bar: no as desktop switch announcements are handled by something other than File Explorer, specifically CSRSS (client/server runtime subsystem a.k.a. Windows subsystem process). Basically, when virtual desktop switches occur in more recent Windows 10 releases and on Windows 11, CSRSS fires a name change event on a desktop object it houses before others can raise focus events. As virtual desktop title comes from CSRSS, File Explorer title bar method will not work (sorry).

Thanks.

@marrie
Copy link

marrie commented Sep 22, 2022 via email

@josephsl
Copy link
Collaborator

josephsl commented May 7, 2023

Hi,

2023 update: I'm picking this up again - based on work from @jcsteh, I'm editing event handler to bring name change handler early in execute event function, as well as simplifying Jamie's work by creating a new function (again from Jamie's work) that will handle virtual desktop switches. the resulting work closely resembles Jamie's pull request (#11031) but way simpler in my opinion as it will not construct a dedicated IAccessible object for handling virtual desktop announcements unless the need arises in the future. I will indeed give credit to Jamie throughout the Git commit stream.

Thanks.

josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
… to handle possible virtual desktop switches. Re nvaccess#5641.

Original work by Jamie Teh (Mozilla): define a dedicated function to handle posible (and real) Windows 10/11 virtual desktop switche announcements. This function checks to make sure this is Widows 10 or later, and if yes, announces desktop name as defined in the event handler module, and clears this string once announcements are done. The actual event responsible for placing virtual desktop name in event handler is name change event from CSRSS (client/server runtime subsystem/Windows subsystem) process, specificlaly desktop object. Handling name change event will be done as part of handling gain focus event, specifically when doing pre-gain focus routine.
josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
…e event coming from CSRSS/desktop object and treat as a possible virtual desktop switch. Re nvaccess#5641.

Original idea from Jamie Teh (Mozilla): in 'execute event' function, detect namechange coming from CSRSS/desktop object and treat it as a possible virtual desktop name change before handling focus events. If it turns out this is indeed a virtual desktop switch, set virtual desktop name, then queue handle possible virtual desktop switch routine (250 milliseconds) so desktop switches can be announced when opening/closing/switching virtual desktops while focused on the desktop.
josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
…irtual desktop switches after handling new foreground event. Re nvaccess#5641.

Credit: Jamie Teh (Mozilla): handle possible virtual desktop switch announcements after handling new foreground announcement in 'do pre gain focus' routine. This allows virtual desktop names to be announced between actual desktop switch and handling gain focus event, more noticeable when creating new virtual desktops.
josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
… to Windows 10 Version 1903 and later. Re nvaccess#5641.

A note from Jamie Teh (Mozila): virtual desktop switch announcement works more effectively in Windows 10 Version 1903 (May 2019 Update) and later, therefore restrict virtual desktop announcement to that feature update and later.
josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
…r virtual desktop name field and handle possible desktop switch function. Re nvaccess#5641
josephsl added a commit to josephsl/nvda that referenced this issue May 7, 2023
…riable to detect Windows 10 1903 and later. Re nvaccess#5641.

In addition to placing winVersion module import at the top of the file, use a dedicated flag to indicate support for virtual desktop switch announcements in Windows 10 Version 1903 (May 2019 Update) and later.
josephsl added a commit to josephsl/nvda that referenced this issue May 31, 2023
…e and announcement check variables private. Re nvaccess#5641.

Reviewed by Sean Budd (NV Access): make virtual desktop name and can nanouncement virtual desktop name variables private - at the moment no add-on appears to need this functionality but this can change if requested by add-on authors.
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
… to handle possible virtual desktop switches. Re nvaccess#5641.

Original work by Jamie Teh (Mozilla): define a dedicated function to handle posible (and real) Windows 10/11 virtual desktop switche announcements. This function checks to make sure this is Widows 10 or later, and if yes, announces desktop name as defined in the event handler module, and clears this string once announcements are done. The actual event responsible for placing virtual desktop name in event handler is name change event from CSRSS (client/server runtime subsystem/Windows subsystem) process, specificlaly desktop object. Handling name change event will be done as part of handling gain focus event, specifically when doing pre-gain focus routine.
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
…e event coming from CSRSS/desktop object and treat as a possible virtual desktop switch. Re nvaccess#5641.

Original idea from Jamie Teh (Mozilla): in 'execute event' function, detect namechange coming from CSRSS/desktop object and treat it as a possible virtual desktop name change before handling focus events. If it turns out this is indeed a virtual desktop switch, set virtual desktop name, then queue handle possible virtual desktop switch routine (250 milliseconds) so desktop switches can be announced when opening/closing/switching virtual desktops while focused on the desktop.
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
…irtual desktop switches after handling new foreground event. Re nvaccess#5641.

Credit: Jamie Teh (Mozilla): handle possible virtual desktop switch announcements after handling new foreground announcement in 'do pre gain focus' routine. This allows virtual desktop names to be announced between actual desktop switch and handling gain focus event, more noticeable when creating new virtual desktops.
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
… to Windows 10 Version 1903 and later. Re nvaccess#5641.

A note from Jamie Teh (Mozila): virtual desktop switch announcement works more effectively in Windows 10 Version 1903 (May 2019 Update) and later, therefore restrict virtual desktop announcement to that feature update and later.
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
…r virtual desktop name field and handle possible desktop switch function. Re nvaccess#5641
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
…riable to detect Windows 10 1903 and later. Re nvaccess#5641.

In addition to placing winVersion module import at the top of the file, use a dedicated flag to indicate support for virtual desktop switch announcements in Windows 10 Version 1903 (May 2019 Update) and later.
josephsl added a commit to josephsl/nvda that referenced this issue Jun 3, 2023
…e and announcement check variables private. Re nvaccess#5641.

Reviewed by Sean Budd (NV Access): make virtual desktop name and can nanouncement virtual desktop name variables private - at the moment no add-on appears to need this functionality but this can change if requested by add-on authors.
seanbudd added a commit that referenced this issue Jun 5, 2023
…#14932)

Fixes #5641

Summary of the issue:
In Windows 10 and later, NVDA does not announce virtual desktop names wen they are opened, switched, and closed.

Description of user facing changes
NVDA will announce names of virtual desktops when opening, switching, and closing them.

Description of development approach
Event handler is extended to include a virtual desktop switch handler and an extension to execute event to catch a name change event coming from CSRSS.

---

commits:

* Event handler: update copyright header. Re #5641

* Event handler/virtual desktops announcement: use a dedicated function to handle possible virtual desktop switches. Re #5641.

Original work by Jamie Teh (Mozilla): define a dedicated function to handle posible (and real) Windows 10/11 virtual desktop switche announcements. This function checks to make sure this is Widows 10 or later, and if yes, announces desktop name as defined in the event handler module, and clears this string once announcements are done. The actual event responsible for placing virtual desktop name in event handler is name change event from CSRSS (client/server runtime subsystem/Windows subsystem) process, specificlaly desktop object. Handling name change event will be done as part of handling gain focus event, specifically when doing pre-gain focus routine.

* Event handler/virtual desktop switch announcements: detect name change event coming from CSRSS/desktop object and treat as a possible virtual desktop switch. Re #5641.

Original idea from Jamie Teh (Mozilla): in 'execute event' function, detect namechange coming from CSRSS/desktop object and treat it as a possible virtual desktop name change before handling focus events. If it turns out this is indeed a virtual desktop switch, set virtual desktop name, then queue handle possible virtual desktop switch routine (250 milliseconds) so desktop switches can be announced when opening/closing/switching virtual desktops while focused on the desktop.

* Event handler/virtual desktop switch announcements: handle possible virtual desktop switches after handling new foreground event. Re #5641.

Credit: Jamie Teh (Mozilla): handle possible virtual desktop switch announcements after handling new foreground announcement in 'do pre gain focus' routine. This allows virtual desktop names to be announced between actual desktop switch and handling gain focus event, more noticeable when creating new virtual desktops.

* Event handler/virtual desktop switch announcement: limit announcement to Windows 10 Version 1903 and later. Re #5641.

A note from Jamie Teh (Mozila): virtual desktop switch announcement works more effectively in Windows 10 Version 1903 (May 2019 Update) and later, therefore restrict virtual desktop announcement to that feature update and later.

* Event handler/virtual desktop switch announcement and surrounding code: lint

* Event handler/virtual desktop switch announcement: use formatted string literals when logging exceptions with execute event routine.

* Event handler/virtual desktop switch announcement: add typing info for virtual desktop name field and handle possible desktop switch function. Re #5641

* Event handler/virtual desktop switch announcement: use a dedicated variable to detect Windows 10 1903 and later. Re #5641.

In addition to placing winVersion module import at the top of the file, use a dedicated flag to indicate support for virtual desktop switch announcements in Windows 10 Version 1903 (May 2019 Update) and later.

* Event handler: move virtual desktop constants to the top of the file.

Reported by several testers: in some cases, NVDA fails to start due to type hint scope issue if a constant is placed between functions. Therefore, move virtual desktops handling to top fo the file next to other constants and data structures.

* Event handler: lint (Flake8 ET126)

* Event handler/virtual desktop announcements: make virtual desktop name and announcement check variables private. Re #5641.

Reviewed by Sean Budd (NV Access): make virtual desktop name and can nanouncement virtual desktop name variables private - at the moment no add-on appears to need this functionality but this can change if requested by add-on authors.

* update changes

---------

Co-authored-by: Sean Budd <sean@nvaccess.org>
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Jun 5, 2023
@ondrosik
Copy link
Contributor

ondrosik commented Jul 2, 2023

Now NVDA reports the desktop name before focused window what is little annoiyng for me. I prefer to hear focused window first. BTW note that on Windows 11 it works as I expectd - first focused window, then focused desktop. Do you think that current state is better?

@josephsl
Copy link
Collaborator

josephsl commented Jul 2, 2023

Hi,

Virtual desktop switch event is raised not by desktop but rather by Windows itself, specifically a part of Windows that controls user interface display and related functions. in fact, as soon as one presses Control+Windows+left/right arrow, virtual desktop name change event is received by NVDA, and then focus and foreground change events occur. This is actually what causes NVDA (and Narrator) to announce virtual desktop names before focused control name, and this happens on both Windows 10 and 11.

I think the experience you are referring to came about thanks to Windows App Essentials add-on. Starting from version 23.06, Windows App Essentials add-on closely resembles NVDA 2023.2 - it will announce virtual desktop name before focused control, which follows the event flow described above. So in some ways, what NVDA does could be considered correct behavior (of course some event sequences can cause problems, so developers must think about balancing things).

Hope this helps. Thanks.

@XLTechie
Copy link
Collaborator

XLTechie commented Jul 2, 2023 via email

@marrie
Copy link

marrie commented Jul 2, 2023 via email

@ondrosik
Copy link
Contributor

ondrosik commented Jul 4, 2023

I understand the logic behind it, it is probably my personal preference to not hear the desktop number first, because I know how I am organized and I mostly want to hear the focused window first. Currently in latest snapshots I press nvda+t to quickly hear the focused window. I noticed that narrator does this too, the info about win 11 is from another person, I will werifi that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment