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

Multiple Desktop Support [$250 awarded] #2523

Closed
tommoor opened this issue Oct 27, 2014 · 20 comments
Closed

Multiple Desktop Support [$250 awarded] #2523

tommoor opened this issue Oct 27, 2014 · 20 comments
Assignees
Labels

Comments

@tommoor
Copy link

tommoor commented Oct 27, 2014

Currently it seems there is no way in node-webkit to address multiple desktops on OSX and probably other platforms too. My particular usecase is that we'd like to create a hovering window that is always at the top right of your screen, even when moving between desktops.

Right now the way node-webkit works the current desktop is the only one that is accessible and all coordinates are relative to that. It appears you can move a window onto another desktop but without any knowledge of which the user is looking at this is useless?

This could be allowed using the new Screen geometry API as one option, a possible API would be to include a few new parameters per screen and include virtual desktops in this listing:

screen {
  id : int,
  isVirtual: true,
  isCurrent: true
  isPrimary: false
}

Alternatively / in addition, how about an event when the user moves between desktops? The event could include details of the current / primary desktop.

Let me know if anyone else is interested in this, willing to put down a good bounty once an approach is agreed on 😄

Possibly related to: #2384

The $250 bounty on this issue has been claimed at Bountysource.

@tommoor
Copy link
Author

tommoor commented Oct 27, 2014

@jtg-gg @rogerwang I'd be interested to know your thoughts in particular.

@tommoor tommoor changed the title OSX Multiple Desktops Multiple Desktop Support Oct 27, 2014
@jtg-gg
Copy link
Member

jtg-gg commented Oct 30, 2014

@tommoor primary desktop usually the one with bound x,y 0,0
and for, "isCurrent", can't you compare the bound with the current window pos ?

@tommoor
Copy link
Author

tommoor commented Oct 30, 2014

I guess the bit of information that is missing is which desktop is the user currently looking at / active on? I need to keep the window in their view.

@tommoor
Copy link
Author

tommoor commented Oct 30, 2014

Here's an illustration of what I mean 😄 The window opened by nw main should always display top right of the desktop user is on. I don't believe there is anyway to get this info right now.

image

@mrfabbri
Copy link
Member

mrfabbri commented Nov 7, 2014

Hi @tommoor , if I understand it correctly you would like to specify the behaviour of a window following along the active space like in the gif below?

float-on-active-space_480p

@tommoor
Copy link
Author

tommoor commented Nov 7, 2014

Exactly like that! although in this case it would be a window created with win.open - not the primary/main window.

@mrfabbri
Copy link
Member

mrfabbri commented Nov 7, 2014

[a little brainstorming follows…] In terms of API on OS X you have Window Collection Behaviours (in NSWindow class which, if I didn't get itwrong translates in node-webkit land to Window API and eventually to NativeWindowCocoa ) to specify how a window behaves in relation to spaces:

  • the window is associated with one space (desktop) at a time (the default);
  • the window appears on all spaces (desktops), which is the case shown in the gif above;
  • the window moves to the active space (desktop) when it is activated (i.e. when the user switches active space, to get back to the app he has to make the app active again, e.g. click on the app icon in the dock), which I find kind of a narrow use case.

Also in the example above the window is floating atop (i.e. window.setAlwaysOnTop(true)), otherwise when switching spaces the app would fall back into ordering.

So, mimicking setAlwaysOnTop() I think it would make sense to have a high level setOnAllDesktops(boolean) method on the Window API object.

@tommoor
Copy link
Author

tommoor commented Nov 7, 2014

This API would suit my personal usecase very well. I was trying to think of a way that this could be implemented in a broader sense but now that you've suggested this it would be fantastic for us.

Is your GIF above mocked or did you actually get it working in this way?

@mrfabbri
Copy link
Member

mrfabbri commented Nov 7, 2014

Yep, it's actually "working", although without exposing an API, just a -somewhat- quick and dirty proof of concept, overwriting the default behaviour directly in Objective-C.

@tommoor
Copy link
Author

tommoor commented Nov 7, 2014

Very cool. @jtg-gg @rogerwang what are your thoughts on this api / idea?

@mrfabbri
Copy link
Member

mrfabbri commented Nov 8, 2014

On a related note, Chrome Apps recently added a similar API AppWindow.setVisibleOnAllWorkspaces() [Mac and Linux only, as there is no builtin support for multiple workspaces on Windows] https://codereview.chromium.org/469993003/ .=

@tommoor
Copy link
Author

tommoor commented Nov 9, 2014

@mrfabbri perhaps it makes sense to copy this terminology then for the API in node-webkit...

@mrfabbri
Copy link
Member

mrfabbri commented Nov 9, 2014

@tommoor it makes great sense [and not a far fetch from the reasoning above] /cc @rogerwang=

@rogerwang rogerwang self-assigned this Nov 10, 2014
@mrfabbri
Copy link
Member

@rogerwang If the proposed API (i.e. introducing a setVisibleOnAllWorkspaces(boolean) on the window API object in the vein of setAlwaysOnTop(boolean)) is ok I can sketch an implementation in the next days (Mac OS X first, then Linux, I don't think a reliable solution can be provided for Windows – no OS support for multiple workspaces just third party extensions). /cc @tommoor

@tommoor
Copy link
Author

tommoor commented Nov 21, 2014

@mrfabbri @rogerwang would love to see this move forward, I don't think it makes sense on Windows either as there is no concept of multiple desktops built in right?

@rogerwang rogerwang changed the title Multiple Desktop Support Multiple Desktop Support [$250] Nov 24, 2014
mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Nov 26, 2014
For platforms that support multiple workspaces (currently Mac and Linux), this allows node-webkit windows to be visible on all workspaces simultaneously.

- Add the `SetVisibleOnAllWorkspaces` method to the `Window` API object.
- Add placeholder (empty) methods on platform specific window implementations.
- Add configuration support via boolean `window` subfield `visible-on-all-workspaces` in manifest file  (see https://github.com/rogerwang/node-webkit/wiki/Manifest-format#window-subfields ).

API proposal, Issue and ongoing discussion: nwjs#2523
mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Nov 26, 2014
@mrfabbri
Copy link
Member

@rogerwang @tommoor I added an initial implementation of the proposed API in the fix-2523 branch: https://github.com/mrfabbri/node-webkit/tree/fix-2523 with a working Mac OS X implementation.

var gui = require('nw.gui');
var win = gui.Window.get();
win.setVisibleOnAllWorkspaces(true);
// now the window is visible on all workspaces
win.setVisibleOnAllWorkspaces(false);
// now the window is visible only on the current workspace

The window subfield in the manifest file is "visible-on-all-workspaces".

PS: here it is a debug build for OS X with setVisibleOnAllWorkspaces https://dl.dropboxusercontent.com/u/281690/node-webkit-multiple-workspaces.zip

mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Nov 28, 2014
mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Nov 28, 2014
For platforms that support multiple workspaces (currently Mac and Linux), this allows node-webkit windows to be visible on all workspaces simultaneously.

- Add `SetVisibleOnAllWorkspaces` method to the `Window` API object.
- Add implementation for Mac OS X.
- Add implementation for Aura (Linux).
- Add configuration support via boolean `'window'` subfield `'visible-on-all-workspaces'` in manifest file (see https://github.com/rogerwang/node-webkit/wiki/Manifest-format#window-subfields ).
- Add manual test for `SetVisibleOnAllWorkspaces` method to the `Window` API object.

see nwjs#2523
@mrfabbri
Copy link
Member

@rogerwang I added a full (Mac OS X and Linux) implementation for Window.setVisibleOnAllWorkspaces() in fix-2523. I'd like your feedbacks on the following issues (I'll try to stay brief).

The implementation for Aura (Linux) relies on SetVisibleOnAllWorkspaces() of views::Widget. On Windows (being no concept of workspaces) this translates in a call to an empty method (so it produces no actual effect), as reported in desktop_window_tree_host_win.cc:

void DesktopWindowTreeHostWin::SetVisibleOnAllWorkspaces(bool always_visible) {
  // Windows does not have the concept of workspaces.
}

I see two options:

  1. leaving Window.setVisibleOnAllWorkspaces() accessible on all platforms and, in case, introducing Window.canSetVisibleOnAllWorkspaces() (this is the approach taken in the Chrome Apps API and, in practice, in the current implementation)
  2. having Window.setVisibleOnAllWorkspaces() available only on Linux and Mac OS X (like Menu.createMacBuiltin() is available only on Mac OS X).

As for the recent changes introduced by the Aura graphics stack NativeWindowGtk is not more used so no implementation has been introduced in native_window_gtk.h and native_window_gtk.cc.

I added a manual test showing API usage via manifest file (boolean 'window' subfield 'visible-on-all-workspaces') and Window.setVisibleOnAllWorkspaces().

/cc @tommoor @jtg-gg

@tommoor
Copy link
Author

tommoor commented Dec 1, 2014

👍 please give us a reply here roger!

On Fri, Nov 28, 2014 at 12:50 PM, Marco Fabbri notifications@github.com
wrote:

@rogerwang I added a full (Mac OS X and Linux) implementation for Window.setVisibleOnAllWorkspaces() in fix-2523. I'd like your feedbacks on the following issues (I'll try to stay brief).
The implementation for Aura (Linux) relies on SetVisibleOnAllWorkspaces() of views::Widget. On Windows (being no concept of workspaces) this translates in a call to an empty method (so it produces no actual effect), as reported in desktop_window_tree_host_win.cc:
void DesktopWindowTreeHostWin::SetVisibleOnAllWorkspaces(bool always_visible) {
// Windows does not have the concept of workspaces.
}
I see two options:

  1. leaving Window.setVisibleOnAllWorkspaces() accessible on all platforms and, in case, introducing Window.canSetVisibleOnAllWorkspaces() (this is the approach taken in the Chrome Apps API and, in practice, in the current implementation)
  2. having Window.setVisibleOnAllWorkspaces() available only on Linux and Mac OS X (like Menu.createMacBuiltin() is available only on Mac OS X).
    As for the recent changes introduced by the Aura graphics stack NativeWindowGtk is not more used so no implementation has been introduced in native_window_gtk.h and native_window_gtk.cc.
    I added a manual test showing API usage via manifest file (boolean 'window' subfield 'visible-on-all-workspaces') and Window.setVisibleOnAllWorkspaces.

/cc @tommoor @jtg-gg

Reply to this email directly or view it on GitHub:
#2523 (comment)

@rogerwang
Copy link
Member

Option 1 is good. Thanks.

@mrfabbri
Copy link
Member

mrfabbri commented Dec 1, 2014

@rogerwang great! Adding Window.canSetVisibleOnAllWorkspaces() and sending a PR.

mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Dec 1, 2014
For platforms that support multiple workspaces (currently Mac and Linux), this allows node-webkit windows to be visible on all workspaces simultaneously.

- Add `SetVisibleOnAllWorkspaces` method to the `Window` API object.
- Add implementation for Mac OS X.
- Add implementation for Aura (Linux).
- Add configuration support via boolean `'window'` subfield `'visible-on-all-workspaces'` in manifest file (see https://github.com/rogerwang/node-webkit/wiki/Manifest-format#window-subfields ).
- Add manual test for `SetVisibleOnAllWorkspaces` method to the `Window` API object.

see nwjs#2523
mrfabbri added a commit to mrfabbri/node-webkit that referenced this issue Dec 1, 2014
For platforms that support multiple workspaces (currently Mac and Linux), this allows node-webkit windows to be visible on all workspaces simultaneously.

- Add `SetVisibleOnAllWorkspaces` method to `Window` API objects.
- Add implementation for Mac OS X.
- Add implementation for Aura (Linux).
- Add configuration support via boolean `'window'` subfield `'visible-on-all-workspaces'` in manifest file (see https://github.com/rogerwang/node-webkit/wiki/Manifest-format#window-subfields ).
- Add `Window.canSetVisibleOnAllWorkspaces()` API method returning a a boolean
indicating if the platform (currently OS X and Linux) support `Window` API object
method  `setVisibleOnAllWorkspace()`.
- Add manual test for `SetVisibleOnAllWorkspaces` method to the `Window` API object.

FIX nwjs#2523
@rogerwang rogerwang changed the title Multiple Desktop Support [$250] Multiple Desktop Support Dec 12, 2014
@rogerwang rogerwang changed the title Multiple Desktop Support Multiple Desktop Support [$250 awarded] Feb 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants