-
-
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
11 changed files
with
208 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
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,9 @@ | ||
JavaScript port of Weston's demo client "simple-shm". | ||
|
||
- `yarn install` | ||
- `yarn start` | ||
|
||
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 | ||
|
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,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>New Application</title> | ||
<style> | ||
* { margin:0; padding:0; } | ||
html, body { width:100%; height:100%; } | ||
canvas { height: 100vh; width: 100vw; display:block; } | ||
</style> | ||
</head> | ||
<body> | ||
<script type="module" src="src/fullscreen-compositor.ts"></script> | ||
<canvas id="output"></canvas> | ||
</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,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>Greenfield Canvas Compositor Demo</title> | ||
<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); | ||
} | ||
</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> | ||
</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,36 @@ | ||
{ | ||
"name": "@gfld/example-canvas-compositor", | ||
"version": "1.0.0-rc1", | ||
"type": "module", | ||
"description": "HTML5 Wayland Demo Web Client Simple Shm", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/udevbe/greenfield.git" | ||
}, | ||
"keywords": [ | ||
"wayland", | ||
"html5", | ||
"client", | ||
"demo", | ||
"web" | ||
], | ||
"author": "Erik De Rijcke <[email protected]> (http://www.udev.be)", | ||
"license": "AGPL-3.0", | ||
"bugs": { | ||
"url": "https://github.com/udevbe/greenfield/issues" | ||
}, | ||
"homepage": "https://github.com/udevbe/greenfield#readme", | ||
"scripts": { | ||
"start": "yarn run vite dev", | ||
"build": "yarn run vite build", | ||
"preview": "yarn run vite preview" | ||
}, | ||
"dependencies": { | ||
"@gfld/compositor": "workspace:^" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.5.2", | ||
"vite": "^5.3.1", | ||
"vite-plugin-glsl": "^1.3.0" | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
examples/compositor/fullscreen/src/fullscreen-compositor.ts
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,52 @@ | ||
import { CompositorClient, createAppLauncher, createCompositorSession, initWasm } from '@gfld/compositor' | ||
|
||
const wasmLibs = initWasm() | ||
|
||
const urlSearchParams = new URLSearchParams(window.location.search); | ||
const appType = urlSearchParams.get('type') | ||
const appURL = urlSearchParams.get('url') | ||
|
||
async function main() { | ||
if(appType === null) { | ||
console.error('Missing type search param') | ||
return | ||
} | ||
if(appType !== 'remote' && appType !== 'web') { | ||
console.error('Missing type search param') | ||
return | ||
} | ||
if(appURL === null) { | ||
console.error('Missing URL search param') | ||
return | ||
} | ||
|
||
await wasmLibs | ||
|
||
// create new compositor context | ||
const session = await createCompositorSession({ mode: 'fullscreen' }) | ||
|
||
const appLauncher = createAppLauncher(session, appType) | ||
|
||
session.userShell.events.surfaceTitleUpdated = (compositorSurface, title) => { | ||
window.document.title = title | ||
} | ||
|
||
session.userShell.events.notify = (variant: string, message: string) => window.alert(message) | ||
|
||
// Get an HTML5 canvas for use as an output for the compositor. Multiple outputs can be used. | ||
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 = appLauncher.launch(new URL(appURL), (childAppContext) => { | ||
// handle child context here | ||
}) | ||
|
||
// handle app context here | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "Node16", | ||
"target": "es2018", | ||
"module": "esnext", | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"sourceMap": true, | ||
"outDir": "dist", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
] | ||
}, | ||
"include": ["src"] | ||
} |
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,22 @@ | ||
import { defineConfig } from "vite"; | ||
|
||
export default defineConfig({ | ||
base: "./", | ||
build: { | ||
rollupOptions: { | ||
input: { | ||
app: './app.html' | ||
} | ||
} | ||
}, | ||
server: { | ||
host: 'localhost', | ||
port: 8080, | ||
strictPort: true, | ||
cors: false, | ||
headers: { | ||
'Cross-Origin-Opener-Policy': 'same-origin', | ||
'Cross-Origin-Embedder-Policy': 'require-corp', | ||
}, | ||
} | ||
}); |
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 |
---|---|---|
|
@@ -2,7 +2,8 @@ | |
"workspaces": [ | ||
"libs/*", | ||
"packages/*", | ||
"examples/webapps/*" | ||
"examples/webapps/*", | ||
"examples/compositor/*" | ||
], | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
|
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