forked from nwjs/nw.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Window.SetVisibleOnAllWorkspaces API
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
- Loading branch information
Showing
13 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<html> | ||
<head> | ||
<title> Always on Visible Workspace Test - window #1 </title> | ||
</head> | ||
<body style="background-color:rgba(0,0,0,0);"> | ||
<div id="test-contents"> | ||
<h3>Window #1</h3> | ||
<p>This window is <span id="workspaces_status">visible on all workspaces</span></p> | ||
<div> | ||
<a href="" id="visible-on-all-workspaces">Visible on all workspaces</a> | ||
<p>Makes the window visible on all workspaces simultaneously.</p> | ||
</div> | ||
<div> | ||
<a href="" id="only-on-this-desktop">Only on this workspace</a> | ||
<p>Makes the window visible only on this workspace.</p> | ||
</div> | ||
<p id="output"></p> | ||
</div> | ||
<script> | ||
|
||
var os = require('os'); | ||
if (/(darwin|linux)/.test(os.platform())) { | ||
testSetVisibleOnAllWorkspaces(); | ||
} else { | ||
notSupported(); | ||
} | ||
|
||
function testSetVisibleOnAllWorkspaces() { | ||
var gui = require('nw.gui'); | ||
var win = gui.Window.get(); | ||
|
||
function setVisibleOnAllWorkspaces(all_workspaces){ | ||
win.setVisibleOnAllWorkspaces(all_workspaces); | ||
|
||
updateStatusText(all_workspaces); | ||
|
||
document.getElementById("output").innerHTML += | ||
'called Window.setVisibleOnAllWorkspaces(' + all_workspaces + ');<br/>\n'; | ||
} | ||
|
||
function updateStatusText(all_workspaces) { | ||
var statusEl = document.getElementById('workspaces_status'); | ||
var statusText = all_workspaces ? 'visible on all workspaces' : 'visible only on this workspace'; | ||
statusEl.innerText = statusText; | ||
} | ||
|
||
updateStatusText(gui.App.manifest.window['visible-on-all-workspaces']); | ||
|
||
document.getElementById('visible-on-all-workspaces').onclick = function (e) { setVisibleOnAllWorkspaces(true); e.preventDefault(); }; | ||
document.getElementById('only-on-this-desktop').onclick = function (e) { setVisibleOnAllWorkspaces(false); e.preventDefault(); }; | ||
|
||
gui.Window.open('./index2.html', { | ||
position: 'center', | ||
x: win.x+20, | ||
y: win.y+20 | ||
}); | ||
} | ||
|
||
function notSupported() { | ||
document.getElementById('test-contents').innerHTML = | ||
"Test not supported on this platform"; | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
41 changes: 41 additions & 0 deletions
41
tests/manual_tests/always_on_visible_workspace/index2.html
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<title> Always on Visible Workspace Test - window #2 </title> | ||
</head> | ||
<body style="background-color:rgba(0,0,0,0);"> | ||
<h3>Window #2</h3> | ||
<p>This window is <span id="workspaces_status">visible on all workspaces</span></p> | ||
<div> | ||
<a href="" id="visible-on-all-workspaces">Visible on all workspaces</a> | ||
<p>Makes the window visible on all workspaces simultaneously.</p> | ||
</div> | ||
<div> | ||
<a href="" id="only-on-this-desktop">Only on this workspace</a> | ||
<p>Makes the window visible only on this workspace.</p> | ||
</div> | ||
<p id="output"></p> | ||
<script> | ||
var gui = require('nw.gui'); | ||
var win = gui.Window.get(); | ||
|
||
function setVisibleOnAllWorkspaces(all_workspaces){ | ||
win.setVisibleOnAllWorkspaces(all_workspaces); | ||
|
||
updateStatusText(all_workspaces); | ||
|
||
document.getElementById("output").innerHTML += | ||
'called Window.setVisibleOnAllWorkspaces(' + all_workspaces + ');<br/>\n'; | ||
} | ||
|
||
function updateStatusText(all_workspaces) { | ||
var statusEl = document.getElementById('workspaces_status'); | ||
var statusText = all_workspaces ? 'visible on all workspaces' : 'visible only on this workspace'; | ||
statusEl.innerText = statusText; | ||
} | ||
|
||
document.getElementById('visible-on-all-workspaces').onclick = function (e) { setVisibleOnAllWorkspaces(true); e.preventDefault(); }; | ||
document.getElementById('only-on-this-desktop').onclick = function (e) { setVisibleOnAllWorkspaces(false); e.preventDefault(); }; | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "nw-always-on-visible-workspace-test", | ||
"main": "index.html", | ||
"window": { | ||
"always-on-visible-workspace": true | ||
}, | ||
"dependencies": {} | ||
} |