-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start adding fullscreen compositor demo
- Loading branch information
Showing
7 changed files
with
437 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
JavaScript port of Weston's demo client "simple-shm". | ||
About | ||
= | ||
|
||
Example of a compositor running a single remote GTK4 demo application. The GTK4 demo application is expected to be | ||
provided externally by e.g. `packages/compositor-proxy-cli` in this repo. | ||
|
||
Running | ||
= | ||
|
||
- `yarn install` | ||
- `yarn start` | ||
- Go to `http://localhost:8080` | ||
|
||
The demo-compositor will now be able to launch this demo webapp. | ||
|
||
Type `web://localhost:9002` in the compositor URL bar and press enter to launch it | ||
The remote application can be installed as a [Progressive Web App](https://en.wikipedia.org/wiki/Progressive_web_app) by browsers that support it. | ||
When installed as a PWA the application will still be running remotely but will be integrated as a local application. | ||
|
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 |
---|---|---|
@@ -1,43 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>Greenfield Canvas Compositor Demo</title> | ||
<meta charset="UTF-8"> | ||
<title>New Application</title> | ||
<link rel="manifest" href="/app.webmanifest"> | ||
<style> | ||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
background-color: #f0f0f0; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
gap: 20px; | ||
} | ||
|
||
.tile { | ||
width: 200px; | ||
height: 200px; | ||
background-color: #4CAF50; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
color: white; | ||
font-size: 20px; | ||
font-family: Arial, sans-serif; | ||
border-radius: 10px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | ||
} | ||
* { margin:0; padding:0; } | ||
html, body { width:100%; height:100%; } | ||
canvas { height: 100vh; width: 100vw; display:block; } | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<button class="tile" onclick="window.open('app.html?type=remote&url=http%3Alocalhost%3A8081%2Fgtk4-demo', '_blank', 'popup')">gtk4-demo</button> | ||
<button class="tile" onclick="window.open('app.html?type=remote&url=http%3Alocalhost%3A8081%2Fkwrite', '_blank', 'popup')">KWrite</button> | ||
<button class="tile" onclick="window.open('app.html?type=remote&url=http%3Alocalhost%3A8081%2Fxterm', '_blank', 'popup')">xterm</button> | ||
</div> | ||
<script type="module" src="src/index.ts"></script> | ||
<canvas id="output"></canvas> | ||
</body> | ||
</html> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,11 @@ | ||
{ | ||
"name": "gtk4-demo", | ||
"display": "standalone", | ||
"start_url": ".", | ||
"icons": [ | ||
{ | ||
"src": "GTK_logo.svg", | ||
"sizes": "any" | ||
} | ||
] | ||
} |
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,40 @@ | ||
import { createAppLauncher, createCompositorSession, initWasm } from '@gfld/compositor' | ||
|
||
const wasmLibs = initWasm() | ||
|
||
async function main() { | ||
await wasmLibs | ||
|
||
// create new compositor context | ||
const session = await createCompositorSession({ mode: 'fullscreen' }) | ||
// notify user of errors | ||
session.userShell.events.notify = (variant: string, message: string) => window.alert(message) | ||
|
||
// Get an HTML5 canvas for use as an output for the compositor. | ||
const canvas = document.getElementById('output') as HTMLCanvasElement | ||
// hook up the canvas to our compositor | ||
session.userShell.actions.initScene(() => ({ canvas, id: canvas.id })) | ||
// make compositor global protocol objects available to client | ||
session.globals.register() | ||
|
||
const appContext = createAppLauncher(session, 'remote').launch(new URL('http://localhost:8081/gtk4-demo'), (childAppContext) => { | ||
childAppContext.onStateChange = (state) => { | ||
// log child app state | ||
console.log(`Child app is ${state}`) | ||
} | ||
}) | ||
|
||
// log app state | ||
appContext.onStateChange = (state) => { | ||
console.log(`App state is ${state}`) | ||
} | ||
|
||
appContext.onNameChanged = (name) => { | ||
window.document.title = name | ||
} | ||
window.document.title = appContext.name | ||
} | ||
|
||
window.onload = () => { | ||
main() | ||
} |
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
Oops, something went wrong.