Skip to content

Commit

Permalink
Add API entry point and scaffolding for Window.SetVisibleOnAllWorkspaces
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mrfabbri committed Nov 26, 2014
1 parent 4627bba commit 2402a31
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/window/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ void Window::Call(const std::string& method,
bool show;
if (arguments.GetBoolean(0, &show))
shell_->window()->SetShowInTaskbar(show);
} else if (method == "SetVisibleOnAllWorkspaces") {
bool all_workspaces;
if (arguments.GetBoolean(0, &all_workspaces))
shell_->window()->SetVisibleOnAllWorkspaces(all_workspaces);
} else if (method == "MoveTo") {
int x, y;
if (arguments.GetInteger(0, &x) &&
Expand Down
4 changes: 4 additions & 0 deletions src/api/window_bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ Window.prototype.setShowInTaskbar = function(flag) {
CallObjectMethod(this, 'SetShowInTaskbar', [ flag ]);
}

Window.prototype.setVisibleOnAllWorkspaces = function(flag) {
CallObjectMethod(this, 'SetVisibleOnAllWorkspaces', [ Boolean(flag) ]);
}

Window.prototype.requestAttention = function(flash) {
if (typeof flash == 'boolean') {
// boolean true is redirected as -1 value
Expand Down
4 changes: 4 additions & 0 deletions src/browser/native_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ void NativeWindow::InitFromManifest(base::DictionaryValue* manifest) {
!showInTaskbar) {
SetShowInTaskbar(false);
}
bool all_workspaces;
if (manifest->GetBoolean(switches::kmVisibleOnAllWorkspaces, &all_workspaces) && all_workspaces) {
SetVisibleOnAllWorkspaces(true);
}
bool fullscreen;
if (manifest->GetBoolean(switches::kmFullscreen, &fullscreen) && fullscreen) {
SetFullscreen(true);
Expand Down
1 change: 1 addition & 0 deletions src/browser/native_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class NativeWindow {
virtual void SetResizable(bool resizable) = 0;
virtual void SetAlwaysOnTop(bool top) = 0;
virtual void SetShowInTaskbar(bool show = true) = 0;
virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) = 0;
virtual void SetPosition(const std::string& position) = 0;
virtual void SetPosition(const gfx::Point& position) = 0;
virtual gfx::Point GetPosition() = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/browser/native_window_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ void NativeWindowAura::SetAlwaysOnTop(bool top) {
window_->SetAlwaysOnTop(top);
}

void NativeWindowAura::void NativeWindowAura::SetVisibleOnAllWorkspaces(bool all_workspaces) {
// @TODO @mrfabbri NOT IMPLEMENTED
}

void NativeWindowAura::OnWidgetBoundsChanged(views::Widget* widget, const gfx::Rect& new_bounds) {
int w = new_bounds.width();
int h = new_bounds.height();
Expand Down
1 change: 1 addition & 0 deletions src/browser/native_window_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class NativeWindowAura : public NativeWindow,
virtual void SetResizable(bool resizable) OVERRIDE;
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
virtual void SetShowInTaskbar(bool show = true) OVERRIDE;
virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) OVERRIDE;
virtual void SetPosition(const std::string& position) OVERRIDE;
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
virtual gfx::Point GetPosition() OVERRIDE;
Expand Down
4 changes: 4 additions & 0 deletions src/browser/native_window_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ void NativeWindowGtk::SetAlwaysOnTop(bool top) {
gtk_window_set_keep_above(window_, top ? TRUE : FALSE);
}

void NativeWindowGtk::SetVisibleOnAllWorkspaces(bool all_workspaces) {
// @TODO @mrfabbri NOT IMPLEMENTED
}

void NativeWindowGtk::SetShowInTaskbar(bool show) {
gtk_window_set_skip_taskbar_hint(window_, show ? FALSE : TRUE);
}
Expand Down
1 change: 1 addition & 0 deletions src/browser/native_window_gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class NativeWindowGtk : public NativeWindow {
virtual void SetResizable(bool resizable) OVERRIDE;
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
virtual void SetShowInTaskbar(bool show = true) OVERRIDE;
virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) OVERRIDE;
virtual void SetPosition(const std::string& position) OVERRIDE;
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
virtual gfx::Point GetPosition() OVERRIDE;
Expand Down
1 change: 1 addition & 0 deletions src/browser/native_window_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class NativeWindowCocoa : public NativeWindow {
virtual void SetResizable(bool resizable) OVERRIDE;
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
virtual void SetShowInTaskbar(bool show = true) OVERRIDE;
virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) OVERRIDE;
virtual void SetPosition(const std::string& position) OVERRIDE;
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
virtual gfx::Point GetPosition() OVERRIDE;
Expand Down
4 changes: 4 additions & 0 deletions src/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ - (void)drawRect:(NSRect)dirtyRect {
[window() setLevel:(top ? NSFloatingWindowLevel : NSNormalWindowLevel)];
}

void NativeWindowCocoa::SetVisibleOnAllWorkspaces(bool all_workspaces) {
// @TODO @mrfabbri NOT IMPLEMENTED
}

void NativeWindowCocoa::SetShowInTaskbar(bool show) {
ProcessSerialNumber psn = { 0, kCurrentProcess };
if (!show) {
Expand Down
3 changes: 3 additions & 0 deletions src/common/shell_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ const char kmKiosk[] = "kiosk";
// Make windows stays on the top of all other windows.
const char kmAlwaysOnTop[] = "always-on-top";

// Make window visible on all workspaces.
const char kmVisibleOnAllWorkspaces[] = "visible-on-all-workspaces";

// Whether we should support WebGL.
const char kmWebgl[] = "webgl";

Expand Down
1 change: 1 addition & 0 deletions src/common/shell_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern const char kmFullscreen[];
extern const char kmShowInTaskbar[];
extern const char kmKiosk[];
extern const char kmAlwaysOnTop[];
extern const char kmVisibleOnAllWorkspaces[];
extern const char kmInitialFocus[];

extern const char kmWebgl[];
Expand Down

0 comments on commit 2402a31

Please sign in to comment.