Skip to content

Add workspace API #5362

Open
Open

Description

@zcbenz

All major platforms now support workspaces (virtual desktops), we should probably add a set of workspace related API, so it can:

  • get the workspace of window;
  • list available workspaces;
  • choose which workspace to put the new window;
  • move windows between workspaces.

Activity

  1. matthiasg commented on Apr 9, 2017

    @matthiasg

    On windows 10 (creators update), a new window I opened (not the main window), also is present on all virtual windows desktops when always on top is set. This might be a windows issue of course, but should be tested when more control is made possible

  2. pelallemant commented on Feb 5, 2018

    @pelallemant

    Hello.

    How is going this issue ? There are still problems on atom which uses electron: each time we open a new atom window, it is created on the previous atom window's worspace instead of the current workspace. It seems this issue is needed for them to fix that problem.

  3. lawnzapper commented on Feb 28, 2018

    @lawnzapper

    I managed to solve this with a workaround for my specific case where I need to open/move my app on my current workspace. ( tested on macOs High Sierra, electron 1.7.9)
    Just set window visible in all workspaces, then show it, then set visible on all workspaces back as false

    mainWindow.setVisibleOnAllWorkspaces(true);
    mainWindow.show();
    mainWindow.setVisibleOnAllWorkspaces(true);
    
  4. andrew-morris-orbis commented on Mar 14, 2018

    @andrew-morris-orbis

    @lawnzapper sounds like you meant:

    mainWindow.setVisibleOnAllWorkspaces(true);
    mainWindow.show();
    mainWindow.setVisibleOnAllWorkspaces(false);
  5. lawnzapper commented on Mar 14, 2018

    @lawnzapper

    @andrew-morris-orbis oh yeah sorry!

  6. spoike commented on Mar 27, 2018

    @spoike

    @lawnzapper's method doesn't work when you're opening the window while on a fullscreen app in macOS High Sierra.

  7. kasper9n commented on Jul 2, 2019

    @kasper9n

    @zcbenz It would also be nice to fire an event when the user switches to a different workspace. Maybe add that to your issue description?

    In my scenario, I'd like to hide a window whenever the user switches workspace.

  8. RoderickQiu commented on Apr 1, 2020

    @RoderickQiu

    So is this feature still being working around on Windows as Microsoft truly has related APIs?

  9. rpsfonseca commented on Apr 24, 2020

    @rpsfonseca

    The behaviour where one opens an Electron app in one Desktop (in macOS), then goes into another desktop, the app calls the window.show() and the user is brought to the Desktop where the app is running, does not happen on Windows 10.
    Is it impossible to that now, or is there a workaround for this?

  10. joaomlemos commented on Jul 20, 2020

    @joaomlemos

    @rpsfonseca - I think you're looking for a workaround like this #5362 (comment)

  11. zcbenz commented on Nov 18, 2020

    @zcbenz
    ContributorAuthor

    So on macOS, the workspaces related APIs are private, using them would get the apps rejected by App Store. Of course not every app goes to App Store, but still due to this we are very unlikely to provide workspace APIs in Electron until Apple provides public APIs.

  12. dinvlad commented on Dec 1, 2021

    @dinvlad

    Any updates on this for Windows?

  13. xgdgsc commented on Jun 16, 2022

    @xgdgsc

    Why not just provide empty functions on macOS and add them later if Apple provide the API? Please support the majority of users first.

  14. UlyssesZh commented on Sep 22, 2022

    @UlyssesZh

    Any updates on this for Linux desktops?

  15. gavofyork commented on Mar 3, 2023

    @gavofyork

    Any updates on this for OS X?

  16. bpasero commented on Oct 11, 2023

    @bpasero
    Contributor

    Currently VS Code cannot properly restore OS workspace layouts for windows on any platform. Users have to reconfigure workspaces after restart.

    fyi @codebytere

  17. codebytere commented on Oct 11, 2023

    @codebytere
    Member

    @bpasero when did this start? is there an error message or other information you're seeing when this happens?

  18. bpasero commented on Oct 11, 2023

    @bpasero
    Contributor

    @codebytere to clarify, there is no error as far as I can tell. The ask here is how would an Electron application that supports multiple windows be able to restore the windows to their OS spaces/workspaces after a restart? We restore window locations on screen and sizes because we can get that information from Electron, but as far as I can tell, I cannot figure out which workspaces where setup and how to restore them.

  19. Mugane commented on Feb 1, 2024

    @Mugane

    8 years. EIGHT. YEARS.

  20. yangm97 commented on Feb 21, 2024

    @yangm97

    8 years. EIGHT. YEARS.

    🎂🥳🥳🥳

  21. gdamiaN538 commented on Feb 29, 2024

    @gdamiaN538
  22. sami-azzam commented on Apr 8, 2024

    @sami-azzam

    Can someone please take a look at this?

  23. vojtabohm commented on Jul 17, 2024

    @vojtabohm

    Is this abandoned completely or?

  24. iyobo commented on Aug 20, 2024

    @iyobo

    This could be as simple as having every window expose a workspaceID string or something for the workspace it is on. We can figure out how to work with that for our apps, but please do give us something to work with.

    Thanks 🙏

  25. winetree94 commented on Oct 24, 2024

    @winetree94

    here's my solutions

    For bringing a window from another Virtual Desktop to the current Virtual Desktop in Windows:

    const windows = BrowserWindow.getAllWindows();
    windows.forEach((window) => {
      window.setSkipTaskbar(true);
      window.hide();
    });
    windows.forEach((window) => {
      window.show();
    });
    windows.forEach((window) => {
      window.setSkipTaskbar(false);
      window.focus();
    });

    For bringing a window from another Workspace to the current Workspace in macOS:

    const windows = BrowserWindow.getAllWindows();
    windows.forEach((window) => {
      window.setAlwaysOnTop(true);
      window.setVisibleOnAllWorkspaces(true);
    });
    await new Promise((resolve) => setTimeout(resolve, 500));
    windows.forEach((window) => {
      window.setAlwaysOnTop(false);
      window.setVisibleOnAllWorkspaces(false);
      window.focus();
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions