mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-16 13:08:13 +00:00
Compare commits
460 Commits
dxgi-hlsl
...
idd-defaul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e6f21f91e | ||
|
|
f9ecddab98 | ||
|
|
fad7af7740 | ||
|
|
6c70e36cb1 | ||
|
|
dca54a79fd | ||
|
|
113199b6dd | ||
|
|
7d33b93a50 | ||
|
|
bf77128053 | ||
|
|
124b4742e0 | ||
|
|
569619384c | ||
|
|
1d7cb35de8 | ||
|
|
e082acbe44 | ||
|
|
ab6e2c89d5 | ||
|
|
7a3833782c | ||
|
|
96367e83f1 | ||
|
|
c99f516b29 | ||
|
|
2647678b0f | ||
|
|
40d606890b | ||
|
|
fddcb7f2d4 | ||
|
|
48ab317fa0 | ||
|
|
08e54fd1b1 | ||
|
|
b504627145 | ||
|
|
4585362f54 | ||
|
|
e123e02e15 | ||
|
|
85e728b59e | ||
|
|
042450a708 | ||
|
|
9009217366 | ||
|
|
d006dbb547 | ||
|
|
c4f3936d98 | ||
|
|
118e300f2f | ||
|
|
19989ce9fb | ||
|
|
e1a2fa790d | ||
|
|
daa78bcf47 | ||
|
|
e2bc1856b6 | ||
|
|
30869c1c9c | ||
|
|
9e8cb2f919 | ||
|
|
70e0c356fc | ||
|
|
8c3a2d01bc | ||
|
|
eff8555f9b | ||
|
|
c873aa4c4e | ||
|
|
5c1d604a22 | ||
|
|
67e1574d20 | ||
|
|
94550e09b4 | ||
|
|
9d48e70983 | ||
|
|
48dc7a90f9 | ||
|
|
4ff5ce02d7 | ||
|
|
b7e3ef6824 | ||
|
|
870eb8c670 | ||
|
|
d02d46283c | ||
|
|
d5ee54e23e | ||
|
|
41d3e7a981 | ||
|
|
e75c7cff46 | ||
|
|
e81462176a | ||
|
|
d00f12875c | ||
|
|
b6ceb72855 | ||
|
|
13ae3441cf | ||
|
|
b83d70a068 | ||
|
|
2d28d27e90 | ||
|
|
e6b3b7fa76 | ||
|
|
9220c85e85 | ||
|
|
2c370847e7 | ||
|
|
e1170f8e01 | ||
|
|
41d2210624 | ||
|
|
037a61a1c7 | ||
|
|
c6eda7e3a0 | ||
|
|
ff8650829c | ||
|
|
df6d22455e | ||
|
|
52849bc1d7 | ||
|
|
155540a8f7 | ||
|
|
6e00dedc2b | ||
|
|
3da40f046d | ||
|
|
e816847fb1 | ||
|
|
eec9aa3ae3 | ||
|
|
f07dd827ae | ||
|
|
08064efb7f | ||
|
|
01cae959d8 | ||
|
|
da154a5591 | ||
|
|
a85b666238 | ||
|
|
eff1e4d7ea | ||
|
|
4affd03c2d | ||
|
|
a1cc58c9f2 | ||
|
|
9a6e03114e | ||
|
|
0feaa716c5 | ||
|
|
5f9649b4a2 | ||
|
|
e40610ea77 | ||
|
|
d5839c7efd | ||
|
|
2a2250b9bd | ||
|
|
16a283717a | ||
|
|
5a4a2529af | ||
|
|
403bf87d6d | ||
|
|
e1a585ad6f | ||
|
|
7c2e0ec4e9 | ||
|
|
33600682cf | ||
|
|
60bda2befc | ||
|
|
04a55e1419 | ||
|
|
ca98b5b1fd | ||
|
|
c156044423 | ||
|
|
85ceae91bf | ||
|
|
f8f05c36b8 | ||
|
|
05bf816b45 | ||
|
|
3f35b0b0af | ||
|
|
f7e0b9746a | ||
|
|
b7d044de5d | ||
|
|
28b653b112 | ||
|
|
26848ba70a | ||
|
|
482f66ab9b | ||
|
|
8d9806bb0e | ||
|
|
fa661aed64 | ||
|
|
2c648b99ad | ||
|
|
6a6cfadbf2 | ||
|
|
11c86273d2 | ||
|
|
60d7c84972 | ||
|
|
cb304115f6 | ||
|
|
c349f704d6 | ||
|
|
add45347b5 | ||
|
|
f15d72cdfe | ||
|
|
54d811e098 | ||
|
|
9593301511 | ||
|
|
c2a19f5e76 | ||
|
|
d8baa62c6a | ||
|
|
81162b460e | ||
|
|
852eb6bf69 | ||
|
|
4b11743f18 | ||
|
|
656d01a694 | ||
|
|
a4406ac867 | ||
|
|
57a2f68931 | ||
|
|
f4df3f0ec7 | ||
|
|
4e951184f1 | ||
|
|
be4782b062 | ||
|
|
b17c66d6bb | ||
|
|
94fbbad21c | ||
|
|
63a9365377 | ||
|
|
cadcfe4b39 | ||
|
|
3b883bf9fe | ||
|
|
b58171c3e1 | ||
|
|
7afb9b93eb | ||
|
|
6396ff1e9c | ||
|
|
db1dda00c8 | ||
|
|
5b07286c65 | ||
|
|
6dad0de8b8 | ||
|
|
35c975d334 | ||
|
|
530e83e7bf | ||
|
|
40a4debfda | ||
|
|
75f07cb28c | ||
|
|
f26fa17bc1 | ||
|
|
648fca7caa | ||
|
|
868504d22d | ||
|
|
cb423730e4 | ||
|
|
86de1c9ac6 | ||
|
|
d839a45d0b | ||
|
|
9ffb800e93 | ||
|
|
91e8440c9d | ||
|
|
15eff234ec | ||
|
|
6a4edfc6b6 | ||
|
|
bf59e45118 | ||
|
|
9cc99e7db9 | ||
|
|
af5a48deca | ||
|
|
b1b6da32ce | ||
|
|
17b24cc8ff | ||
|
|
7248b666ea | ||
|
|
2084a9fee3 | ||
|
|
a2a771f94e | ||
|
|
b526eb3da0 | ||
|
|
7a88a49f1c | ||
|
|
ce23cff12e | ||
|
|
09df8c41aa | ||
|
|
0db9d3a27b | ||
|
|
4f2eb984d3 | ||
|
|
8b198091ce | ||
|
|
62c075cfb5 | ||
|
|
bea198735a | ||
|
|
a421329d9a | ||
|
|
5382a94945 | ||
|
|
4278a10fe1 | ||
|
|
35e6a6e81a | ||
|
|
afbd844be8 | ||
|
|
7c285a45fb | ||
|
|
968fd42d46 | ||
|
|
66ac453c98 | ||
|
|
27fe47cbe2 | ||
|
|
aefbebff9c | ||
|
|
9174b1ae0f | ||
|
|
f6b7ea11c8 | ||
|
|
2c50ce4dbd | ||
|
|
f6b0752e45 | ||
|
|
50fee59b29 | ||
|
|
554f5bf75d | ||
|
|
b43f572af0 | ||
|
|
d9f2df361d | ||
|
|
6dcf178879 | ||
|
|
ea00b623ed | ||
|
|
711c932380 | ||
|
|
be52a86a9a | ||
|
|
420eaebb71 | ||
|
|
551298ed5b | ||
|
|
41008add12 | ||
|
|
32d1b8063e | ||
|
|
b0227a8ff8 | ||
|
|
a1c713556d | ||
|
|
a0cf34df73 | ||
|
|
fbb489b9b6 | ||
|
|
03ca20d3e4 | ||
|
|
7e9e38faa5 | ||
|
|
0fd6f59bbb | ||
|
|
661efd107e | ||
|
|
f6094de919 | ||
|
|
77f6054f0a | ||
|
|
c169d4ab23 | ||
|
|
e25492a3a3 | ||
|
|
4e8201da07 | ||
|
|
6a0a635781 | ||
|
|
3ea37b86e3 | ||
|
|
d060e375ea | ||
|
|
7305ce36af | ||
|
|
c04f84b85c | ||
|
|
d21bdebc52 | ||
|
|
695cbc2d61 | ||
|
|
2067b21d47 | ||
|
|
9bc82ab1b4 | ||
|
|
82c9df54c5 | ||
|
|
c48bd35b3a | ||
|
|
ecd3692e1e | ||
|
|
23b773ad80 | ||
|
|
a626a1142d | ||
|
|
e70718600c | ||
|
|
0990c59eff | ||
|
|
fb1d96e147 | ||
|
|
7f515c54b3 | ||
|
|
20972cfd9b | ||
|
|
dc9065b62f | ||
|
|
13b9756e80 | ||
|
|
d902afa3dc | ||
|
|
6e37305765 | ||
|
|
dd6c79594b | ||
|
|
ce9ed5da5d | ||
|
|
fdad5daff8 | ||
|
|
8d25469d27 | ||
|
|
8c5d1d47ee | ||
|
|
90398bc04f | ||
|
|
989fe2bb0b | ||
|
|
7a41169104 | ||
|
|
0b4322d921 | ||
|
|
b251b22a64 | ||
|
|
90b27ae1f7 | ||
|
|
4d388d6b9b | ||
|
|
a88783e5b7 | ||
|
|
da820769e8 | ||
|
|
d5b32225f4 | ||
|
|
778c21070c | ||
|
|
cae410d4de | ||
|
|
064a605208 | ||
|
|
279357e205 | ||
|
|
98aade2ec9 | ||
|
|
4acea9fa25 | ||
|
|
01efbc62c4 | ||
|
|
ed512f5943 | ||
|
|
4a4f72ba38 | ||
|
|
eb31815b46 | ||
|
|
545e736389 | ||
|
|
6a72633674 | ||
|
|
9123984ecc | ||
|
|
d81395b672 | ||
|
|
bfadf0a427 | ||
|
|
03662f45a7 | ||
|
|
a4e761bedc | ||
|
|
beb8de922d | ||
|
|
e247f1fc7b | ||
|
|
4463ca15f6 | ||
|
|
97d91a32c8 | ||
|
|
2d41cda640 | ||
|
|
a894348530 | ||
|
|
ad7ac6540f | ||
|
|
0184ddeedd | ||
|
|
b87d8d2f33 | ||
|
|
5c4540ed8b | ||
|
|
c7f1aadb9e | ||
|
|
57ac020c8c | ||
|
|
71b826458d | ||
|
|
4408359597 | ||
|
|
2f3ca443cf | ||
|
|
66049cf763 | ||
|
|
a6dc8a9db3 | ||
|
|
dc4d93f50a | ||
|
|
3b43dcb80d | ||
|
|
9de047d9cb | ||
|
|
1098b7e6bd | ||
|
|
055d5527ef | ||
|
|
b1313980fb | ||
|
|
319241b597 | ||
|
|
b0b851dd4b | ||
|
|
60b01566e1 | ||
|
|
4076377820 | ||
|
|
0b210a280d | ||
|
|
a4fede01f3 | ||
|
|
071e4323fa | ||
|
|
be82b7e578 | ||
|
|
c07b72883a | ||
|
|
462d8187b6 | ||
|
|
4523b9ba00 | ||
|
|
cae4b2f4f9 | ||
|
|
72b25b99bc | ||
|
|
e376e6fb53 | ||
|
|
34e8a2255e | ||
|
|
adaf40e2bf | ||
|
|
84dd68dd2b | ||
|
|
738a04d0bc | ||
|
|
2316a5e64d | ||
|
|
47ad93f48d | ||
|
|
c5cbb8aa46 | ||
|
|
ad00aaacd0 | ||
|
|
1b75ae0762 | ||
|
|
5b3cc4cd48 | ||
|
|
7247fadad8 | ||
|
|
c2237f29ae | ||
|
|
e5a9c0242f | ||
|
|
537218d6ae | ||
|
|
f05151c9a6 | ||
|
|
b776b00a67 | ||
|
|
4b4e07875d | ||
|
|
6104956a27 | ||
|
|
3668040892 | ||
|
|
8cd002f1b2 | ||
|
|
22d949c411 | ||
|
|
43a3fb0db3 | ||
|
|
8d27d9e2e2 | ||
|
|
660b4b8ec8 | ||
|
|
4911e129f8 | ||
|
|
d3ee5bddde | ||
|
|
0ce4c34c37 | ||
|
|
584de4133f | ||
|
|
3330f83af6 | ||
|
|
5d4c1d348c | ||
|
|
750cab83a3 | ||
|
|
e61678ef1b | ||
|
|
6357df1a7a | ||
|
|
1f4395570c | ||
|
|
accf300c6c | ||
|
|
a0fd03d328 | ||
|
|
929e88b9d3 | ||
|
|
7bea919352 | ||
|
|
96b5892c31 | ||
|
|
b14aad7118 | ||
|
|
7321ca6768 | ||
|
|
cd6485f2ed | ||
|
|
7bcad37568 | ||
|
|
ba8075a9fd | ||
|
|
3bad3837b4 | ||
|
|
084ebe5035 | ||
|
|
d480b674ca | ||
|
|
10e30eec57 | ||
|
|
38b6b0ac40 | ||
|
|
503efdd0d8 | ||
|
|
75e10688d4 | ||
|
|
ec88a52fe2 | ||
|
|
a28deae569 | ||
|
|
cf51503a54 | ||
|
|
aa42751743 | ||
|
|
9a53880b9b | ||
|
|
a3b51220ed | ||
|
|
17fce1cf78 | ||
|
|
9f3f8cc5bd | ||
|
|
0524980cb4 | ||
|
|
a0f5907cb6 | ||
|
|
0a9784d09d | ||
|
|
120e063a10 | ||
|
|
f59ef4422a | ||
|
|
417c9cf092 | ||
|
|
852825a97e | ||
|
|
cce12508cc | ||
|
|
43f9a4c0e1 | ||
|
|
ee5c02f72a | ||
|
|
55fa5cc851 | ||
|
|
b70811dcb9 | ||
|
|
3c1405719c | ||
|
|
f6befb4567 | ||
|
|
62aef5a240 | ||
|
|
4f508d320a | ||
|
|
29f1434270 | ||
|
|
27f3af8221 | ||
|
|
cb849b287c | ||
|
|
8630fd20ad | ||
|
|
0057cf5377 | ||
|
|
e31874b809 | ||
|
|
a2443cf926 | ||
|
|
eaaef65791 | ||
|
|
11542d7ace | ||
|
|
138a0aee53 | ||
|
|
7a30736ac4 | ||
|
|
174b51b144 | ||
|
|
aa9dbe654d | ||
|
|
d592f13f88 | ||
|
|
905fea57f0 | ||
|
|
3a6afd04d2 | ||
|
|
c0e09e13a5 | ||
|
|
3843afa927 | ||
|
|
49bdf046fe | ||
|
|
8605df8c8d | ||
|
|
d847c2c144 | ||
|
|
6492c47e1e | ||
|
|
86e8e99107 | ||
|
|
dcde981a17 | ||
|
|
c54a09ca25 | ||
|
|
5bba4dfab5 | ||
|
|
3af2cf54d6 | ||
|
|
4aba15f31c | ||
|
|
a455078e0f | ||
|
|
f8586fd063 | ||
|
|
ad13928c73 | ||
|
|
f991f994f0 | ||
|
|
772e0e3b4a | ||
|
|
fd79bb1333 | ||
|
|
d6519c4486 | ||
|
|
9fefbae749 | ||
|
|
fa561c121e | ||
|
|
c2e3c37bab | ||
|
|
54bd08c3cb | ||
|
|
eb2796d40b | ||
|
|
748c9c177e | ||
|
|
cc48257aeb | ||
|
|
3838e1f996 | ||
|
|
881aa9e179 | ||
|
|
9a2638bfa0 | ||
|
|
8d7d5ba8fd | ||
|
|
09b6fee360 | ||
|
|
561c45bcb9 | ||
|
|
5f613b09d6 | ||
|
|
30c577beeb | ||
|
|
6c7f3c4197 | ||
|
|
139e98ac3b | ||
|
|
d02e3730b2 | ||
|
|
ea5b6b4026 | ||
|
|
6329779893 | ||
|
|
1da50d220e | ||
|
|
3106d0e3e2 | ||
|
|
d44fc36fc4 | ||
|
|
c29404eea6 | ||
|
|
c665044bfa | ||
|
|
578d98fd22 | ||
|
|
b3879ff1d7 | ||
|
|
f6b2cec841 | ||
|
|
626f5eb32e | ||
|
|
29c797d7b6 | ||
|
|
3625207801 | ||
|
|
25d6dd3ba2 | ||
|
|
1e30539fb2 | ||
|
|
52410beea7 | ||
|
|
c591f7a8ae | ||
|
|
21cd380cad | ||
|
|
e225f66cee | ||
|
|
2206752b66 | ||
|
|
0510d06c4b | ||
|
|
699d95818d | ||
|
|
fffac35300 | ||
|
|
35b0f8edf3 | ||
|
|
544164f637 | ||
|
|
b94166177f | ||
|
|
69b984aa2c | ||
|
|
c100df4037 | ||
|
|
47329ebd89 | ||
|
|
5d7469d23e |
@@ -1,3 +1,9 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report bugs in Looking Glass (only confirmed bugs and feature requests please)
|
||||
|
||||
---
|
||||
|
||||
### Issues are for Bug Reports and Feature Requests Only!
|
||||
|
||||
If you are looking for help or support please use one of the following methods
|
||||
@@ -64,3 +70,4 @@ https://www.youtube.com/watch?v=EqxxJK9Yo64
|
||||
```
|
||||
PASTE FULL BACKTRACE HERE
|
||||
```
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
9
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Looking Glass on Level1Tech's Forum
|
||||
url: https://forum.level1techs.com/c/software/lookingGlass/142
|
||||
about: Ask for help by creating a New Topic on the Level1Tech's forum
|
||||
- name: Looking Glass Discord Server
|
||||
url: https://discord.gg/52SMupxkvt
|
||||
about: Ask for help in the Looking Glass discord server
|
||||
|
||||
70
.github/workflows/build.yml
vendored
70
.github/workflows/build.yml
vendored
@@ -2,7 +2,7 @@ name: build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
client:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -15,12 +15,6 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install libdecor PPA
|
||||
run: sudo add-apt-repository ppa:christianrauch/libdecoration
|
||||
if: ${{ matrix.wayland_shell == 'libdecor' }}
|
||||
- name: Install PipeWire repository
|
||||
run: |
|
||||
echo 'deb [trusted=yes] https://pipewire-ubuntu.quantum5.workers.dev ./' | sudo tee /etc/apt/sources.list.d/pipewire.list
|
||||
- name: Update apt
|
||||
run: |
|
||||
sudo apt-get update
|
||||
@@ -32,6 +26,7 @@ jobs:
|
||||
libgl-dev libgles-dev \
|
||||
libx11-dev libxss-dev libxi-dev libxinerama-dev libxcursor-dev libxpresent-dev \
|
||||
libwayland-dev libxkbcommon-dev \
|
||||
libfontconfig-dev \
|
||||
libsamplerate0-dev libpipewire-0.3-dev libpulse-dev \
|
||||
$([ '${{ matrix.wayland_shell }}' = libdecor ] && echo 'libdecor-0-dev libdbus-1-dev') \
|
||||
$([ '${{ matrix.compiler.cc }}' = clang ] && echo 'clang-tools')
|
||||
@@ -76,16 +71,13 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install PipeWire repository
|
||||
run: |
|
||||
echo 'deb [trusted=yes] https://pipewire-ubuntu.quantum5.workers.dev ./' | sudo tee /etc/apt/sources.list.d/pipewire.list
|
||||
- name: Update apt
|
||||
run: |
|
||||
sudo apt-get update
|
||||
- name: Install Linux host dependencies
|
||||
run: |
|
||||
sudo apt-get install binutils-dev libxcb-xfixes0-dev \
|
||||
libpipewire-0.3-dev
|
||||
sudo apt-get install binutils-dev libglib2.0-dev libxcb-xfixes0-dev \
|
||||
libpipewire-0.3-dev libxcb-shm0-dev
|
||||
- name: Configure Linux host
|
||||
run: |
|
||||
mkdir host/build
|
||||
@@ -128,11 +120,33 @@ jobs:
|
||||
makensis -DIVSHMEM platform/Windows/installer.nsi
|
||||
|
||||
host-windows-native:
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2025
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install NSIS
|
||||
shell: powershell
|
||||
run: |
|
||||
winget install -e --id NSIS.NSIS --silent --accept-source-agreements --accept-package-agreements
|
||||
$paths = @(
|
||||
(Join-Path ${env:ProgramFiles} 'NSIS\Bin'),
|
||||
(Join-Path ${env:ProgramFiles(x86)} 'NSIS\Bin')
|
||||
) | Where-Object { Test-Path $_ }
|
||||
|
||||
if ($paths.Count -eq 0) {
|
||||
Write-Error "NSIS 'Bin' folder not found after install."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$paths | ForEach-Object {
|
||||
Add-Content -Path $env:GITHUB_PATH -Value $_
|
||||
}
|
||||
|
||||
Write-Host "makensis location(s): $($paths -join ', ')"
|
||||
- name: Test NSIS
|
||||
run: |
|
||||
makensis /VERSION
|
||||
- name: Configure Windows host for native MinGW-w64
|
||||
run: |
|
||||
mkdir host\build
|
||||
@@ -147,6 +161,36 @@ jobs:
|
||||
cd host\build
|
||||
makensis -DBUILD_32BIT platform\Windows\installer.nsi
|
||||
|
||||
idd:
|
||||
runs-on: windows-2022
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
with:
|
||||
msbuild-architecture: x64
|
||||
- name: Install NuGet packages
|
||||
run: |
|
||||
cd idd
|
||||
nuget restore LGIdd.sln
|
||||
- name: Build IDD
|
||||
run: |
|
||||
cd idd
|
||||
msbuild.exe LGIdd.sln /t:Build /p:Configuration=Release /p:Platform=x64
|
||||
- name: Build NSIS Installer
|
||||
run: |
|
||||
cd idd\x64\Release\LGIdd
|
||||
makensis -DBUILD_32BIT installer.nsi
|
||||
- name: Build NSIS installer with IVSHMEM drivers
|
||||
run: |
|
||||
cd idd\x64\Release
|
||||
Invoke-WebRequest https://dl.quantum2.xyz/ivshmem.tar.gz -OutFile ivshmem.tar.gz
|
||||
tar -xzvf ivshmem.tar.gz
|
||||
cd LGIdd
|
||||
makensis -DBUILD_32BIT -DIVSHMEM installer.nsi
|
||||
|
||||
obs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
|
||||
22
.github/workflows/pr-check.yml
vendored
22
.github/workflows/pr-check.yml
vendored
@@ -3,16 +3,36 @@ on: pull_request
|
||||
jobs:
|
||||
authors:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Check AUTHORS file
|
||||
id: check-authors
|
||||
run: |
|
||||
user="$(curl -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -s https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r .user.login)"
|
||||
echo "user=$user" >> "$GITHUB_OUTPUT"
|
||||
echo "Checking if GitHub user $user is in AUTHORS file..."
|
||||
if grep -q -E '> \('"$user"'\)' AUTHORS; then
|
||||
echo "$user found in AUTHORS file, all good!"
|
||||
else
|
||||
echo "$user not found in AUTHORS file."
|
||||
echo "Please add yourself to the AUTHORS file and try again."
|
||||
exit 1
|
||||
echo "not-found=yes" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: 'Not found: Create review requesting changes'
|
||||
if: ${{ steps.check-authors.outputs.not-found }}
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
github.rest.pulls.createReview({
|
||||
owner: context.issue.owner,
|
||||
repo: context.issue.repo,
|
||||
pull_number: context.issue.number,
|
||||
event: "REQUEST_CHANGES",
|
||||
body: "@${{ steps.check-authors.outputs.user }} not found in AUTHORS file.\n" +
|
||||
"Please add yourself to the AUTHORS file and try again."
|
||||
});
|
||||
- name: 'Not found: Fail job'
|
||||
if: ${{ steps.check-authors.outputs.not-found }}
|
||||
run: exit 1
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -11,7 +11,11 @@ module/modules.order
|
||||
__pycache__
|
||||
*.py[co]
|
||||
*/.vs
|
||||
*.user
|
||||
idd/Debug
|
||||
idd/x64
|
||||
idd/LGIdd/x64
|
||||
idd/LGIdd/Debug
|
||||
idd/*/x64
|
||||
idd/*/Debug
|
||||
idd/*/VersionInfo.h
|
||||
idd/*/VERSION
|
||||
idd/packages
|
||||
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -9,7 +9,7 @@
|
||||
url = https://github.com/cimgui/cimgui.git
|
||||
[submodule "repos/wayland-protocols"]
|
||||
path = repos/wayland-protocols
|
||||
url = https://gitlab.freedesktop.org/wayland/wayland-protocols.git
|
||||
url = https://github.com/quantum5/wayland-protocols.git
|
||||
[submodule "repos/nanosvg"]
|
||||
path = repos/nanosvg
|
||||
url = https://github.com/memononen/nanosvg.git
|
||||
|
||||
34
.woodpecker/idd.yaml
Normal file
34
.woodpecker/idd.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
labels:
|
||||
platform: windows/amd64
|
||||
|
||||
matrix:
|
||||
BUILD_TYPE:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
when:
|
||||
- event: push
|
||||
branch: master
|
||||
repo: gnif/LookingGlass
|
||||
|
||||
clone:
|
||||
- name: clone
|
||||
image: woodpeckerci/plugin-git
|
||||
pull: false
|
||||
settings:
|
||||
tags: true
|
||||
|
||||
steps:
|
||||
- name: idd
|
||||
image: lg-vs2022:latest
|
||||
pull: true
|
||||
environment:
|
||||
VS_PATH: "\"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2022\\\\\""
|
||||
entrypoint:
|
||||
- cmd
|
||||
- /C
|
||||
- >
|
||||
%VS_PATH%\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 &&
|
||||
msbuild /restore idd\LGIdd.sln /p:Configuration=${BUILD_TYPE} /p:RestorePackagesConfig=true /p:Platform=x64 /p:SignMode=Off /m &&
|
||||
IF EXIST C:\artifacts\build.cmd (cmd /C C:\artifacts\build.cmd)
|
||||
7
AUTHORS
7
AUTHORS
@@ -67,3 +67,10 @@ Daniel Cordero <looking-glass@0xdc.io> (0xdc)
|
||||
esi <git@esibun.net> (esibun)
|
||||
MakiseKurisu <saberconer@gmail.com> (MakiseKurisu)
|
||||
Zenithal <i@zenithal.me> (ZenithalHourlyRate)
|
||||
Kamplom <6284968128@protonmail.ch> (kamplom)
|
||||
Jacob McNamee <jacob@jacobmcnamee.com> (jacobmcnamee)
|
||||
Marco Antonio J. Costa <marco.antonio.costa@gmail.com> (majcosta)
|
||||
rs189 <35667100+rs189@users.noreply.github.com> (rs189)
|
||||
Jérôme Poulin <jeromepoulin@gmail.com> (ticpu)
|
||||
Marco Rodolfi <marco.rodolfi@tuta.io> (RodoMa92)
|
||||
Stewart Borle <stewi1014@gmail.com> (stewi1014)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(looking-glass-client C CXX)
|
||||
|
||||
get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE)
|
||||
@@ -42,25 +42,12 @@ add_feature_info(ENABLE_ASAN ENABLE_ASAN "AddressSanitizer support.")
|
||||
option(ENABLE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
|
||||
add_feature_info(ENABLE_UBSAN ENABLE_UBSAN "UndefinedBehaviorSanitizer support.")
|
||||
|
||||
option(ENABLE_X11 "Build with X11 support" ON)
|
||||
add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.")
|
||||
|
||||
option(ENABLE_WAYLAND "Build with Wayland support" ON)
|
||||
add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland support.")
|
||||
|
||||
option(ENABLE_LIBDECOR "Build with libdecor support" OFF)
|
||||
add_feature_info(ENABLE_LIBDECOR ENABLE_LIBDECOR "libdecor support.")
|
||||
|
||||
option(ENABLE_PIPEWIRE "Build with PipeWire audio output support" ON)
|
||||
add_feature_info(ENABLE_PIPEWIRE ENABLE_PIPEWIRE "PipeWire audio support.")
|
||||
|
||||
option(ENABLE_PULSEAUDIO "Build with PulseAudio audio output support" ON)
|
||||
add_feature_info(ENABLE_PULSEAUDIO ENABLE_PULSEAUDIO "PulseAudio audio support.")
|
||||
|
||||
if (NOT ENABLE_X11 AND NOT ENABLE_WAYLAND)
|
||||
message(FATAL_ERROR "Either ENABLE_X11 or ENABLE_WAYLAND must be on")
|
||||
endif()
|
||||
|
||||
add_compile_options(
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
@@ -126,6 +113,7 @@ set(SOURCES
|
||||
src/main.c
|
||||
src/core.c
|
||||
src/app.c
|
||||
src/message.c
|
||||
src/audio.c
|
||||
src/config.c
|
||||
src/keybind.c
|
||||
@@ -137,6 +125,7 @@ set(SOURCES
|
||||
src/eglutil.c
|
||||
src/overlay_utils.c
|
||||
src/render_queue.c
|
||||
src/evdev.c
|
||||
|
||||
src/overlay/splash.c
|
||||
src/overlay/alert.c
|
||||
@@ -150,6 +139,8 @@ set(SOURCES
|
||||
|
||||
# Force cimgui to build as a static library.
|
||||
set(IMGUI_STATIC "yes" CACHE STRING "Build as a static library")
|
||||
add_definitions("-DCIMGUI_USE_OPENGL2=1")
|
||||
add_definitions("-DCIMGUI_USE_OPENGL3=1")
|
||||
|
||||
add_subdirectory("${PROJECT_TOP}/resources" "${CMAKE_BINARY_DIR}/resources")
|
||||
add_subdirectory("${PROJECT_TOP}/common" "${CMAKE_BINARY_DIR}/common" )
|
||||
@@ -160,6 +151,7 @@ add_subdirectory("${PROJECT_TOP}/repos/cimgui" "${CMAKE_BINARY_DIR}/cimgui" E
|
||||
add_subdirectory(displayservers)
|
||||
add_subdirectory(renderers)
|
||||
|
||||
configure_file("${PROJECT_TOP}/resources/looking-glass-client.desktop.in" "${CMAKE_BINARY_DIR}/resources/looking-glass-client.desktop" @ONLY)
|
||||
add_executable(looking-glass-client ${SOURCES})
|
||||
|
||||
target_compile_definitions(looking-glass-client PRIVATE CIMGUI_DEFINE_ENUMS_AND_STRUCTS=1)
|
||||
@@ -190,4 +182,10 @@ install(TARGETS looking-glass-client
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT binary)
|
||||
|
||||
install(FILES "${CMAKE_BINARY_DIR}/resources/looking-glass-client.desktop"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
|
||||
install(FILES "${PROJECT_TOP}/resources/lg-logo.svg"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps"
|
||||
RENAME "looking-glass.svg")
|
||||
|
||||
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(audiodevs LANGUAGES C)
|
||||
|
||||
set(AUDIODEV_H "${CMAKE_BINARY_DIR}/include/dynamic/audiodev.h")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(audiodev_PipeWire LANGUAGES C)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -48,6 +48,7 @@ struct PipeWire
|
||||
{
|
||||
struct pw_stream * stream;
|
||||
struct spa_io_rate_match * rateMatch;
|
||||
struct pw_time time;
|
||||
|
||||
int channels;
|
||||
int sampleRate;
|
||||
@@ -91,6 +92,14 @@ static void pipewire_onPlaybackProcess(void * userdata)
|
||||
{
|
||||
struct pw_buffer * pbuf;
|
||||
|
||||
#if PW_CHECK_VERSION(0, 3, 50)
|
||||
if (pw_stream_get_time_n(pw.playback.stream, &pw.playback.time,
|
||||
sizeof(pw.playback.time)) < 0)
|
||||
#else
|
||||
if (pw_stream_get_time(pw.playback.stream, &pw.playback.time) < 0)
|
||||
#endif
|
||||
DEBUG_ERROR("pw_stream_get_time failed");
|
||||
|
||||
if (!(pbuf = pw_stream_dequeue_buffer(pw.playback.stream)))
|
||||
{
|
||||
DEBUG_WARN("out of buffers");
|
||||
@@ -115,6 +124,7 @@ static void pipewire_onPlaybackProcess(void * userdata)
|
||||
return;
|
||||
}
|
||||
|
||||
pbuf->size = frames;
|
||||
sbuf->datas[0].chunk->offset = 0;
|
||||
sbuf->datas[0].chunk->stride = pw.playback.stride;
|
||||
sbuf->datas[0].chunk->size = frames * pw.playback.stride;
|
||||
@@ -158,6 +168,12 @@ static bool pipewire_init(void)
|
||||
pw_init(NULL, NULL);
|
||||
|
||||
pw.loop = pw_loop_new(NULL);
|
||||
#if PW_CHECK_VERSION(1, 3, 81)
|
||||
pw.context = pw_context_new(
|
||||
pw.loop,
|
||||
NULL,
|
||||
0);
|
||||
#else
|
||||
pw.context = pw_context_new(
|
||||
pw.loop,
|
||||
pw_properties_new(
|
||||
@@ -166,6 +182,7 @@ static bool pipewire_init(void)
|
||||
NULL
|
||||
),
|
||||
0);
|
||||
#endif
|
||||
if (!pw.context)
|
||||
{
|
||||
DEBUG_ERROR("Failed to create a context");
|
||||
@@ -248,6 +265,7 @@ static void pipewire_playbackSetup(int channels, int sampleRate,
|
||||
|
||||
struct pw_properties * props =
|
||||
pw_properties_new(
|
||||
PW_KEY_APP_NAME , "Looking Glass",
|
||||
PW_KEY_NODE_NAME , "Looking Glass",
|
||||
PW_KEY_MEDIA_TYPE , "Audio",
|
||||
PW_KEY_MEDIA_CATEGORY, "Playback",
|
||||
@@ -401,20 +419,32 @@ static void pipewire_playbackMute(bool mute)
|
||||
pw_thread_loop_unlock(pw.thread);
|
||||
}
|
||||
|
||||
static size_t pipewire_playbackLatency(void)
|
||||
static uint64_t pipewire_playbackLatency(void)
|
||||
{
|
||||
struct pw_time time = { 0 };
|
||||
|
||||
pw_thread_loop_lock(pw.thread);
|
||||
#if PW_CHECK_VERSION(0, 3, 50)
|
||||
if (pw_stream_get_time_n(pw.playback.stream, &time, sizeof(time)) < 0)
|
||||
#else
|
||||
if (pw_stream_get_time(pw.playback.stream, &time) < 0)
|
||||
#endif
|
||||
DEBUG_ERROR("pw_stream_get_time failed");
|
||||
pw_thread_loop_unlock(pw.thread);
|
||||
if (pw.playback.time.rate.num == 0)
|
||||
return 0;
|
||||
|
||||
return time.delay + time.queued / pw.playback.stride;
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
||||
// diff in ns
|
||||
int64_t diff = SPA_TIMESPEC_TO_NSEC(&ts) - pw.playback.time.now;
|
||||
|
||||
// elapsed frames
|
||||
int64_t elapsed =
|
||||
(pw.playback.time.rate.denom * diff) /
|
||||
(pw.playback.time.rate.num * SPA_NSEC_PER_SEC);
|
||||
|
||||
const int64_t buffered = pw.playback.time.buffered + pw.playback.time.queued;
|
||||
int64_t latency = (buffered * 1000 / pw.playback.sampleRate) +
|
||||
((pw.playback.time.delay - elapsed) * 1000 *
|
||||
pw.playback.time.rate.num / pw.playback.time.rate.denom);
|
||||
|
||||
return max(0, -latency);
|
||||
#else
|
||||
return pw.playback.time.delay + pw.playback.time.queued / pw.playback.stride;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void pipewire_recordStopStream(void)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(audiodev_PulseAudio LANGUAGES C)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(displayservers LANGUAGES C)
|
||||
|
||||
set(DISPLAYSERVER_H "${CMAKE_BINARY_DIR}/include/dynamic/displayservers.h")
|
||||
@@ -18,6 +18,16 @@ function(add_displayserver name)
|
||||
add_subdirectory(${name})
|
||||
endfunction()
|
||||
|
||||
option(ENABLE_X11 "Build with X11 support" ON)
|
||||
add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.")
|
||||
|
||||
option(ENABLE_WAYLAND "Build with Wayland support" ON)
|
||||
add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland support.")
|
||||
|
||||
if (NOT ENABLE_X11 AND NOT ENABLE_WAYLAND)
|
||||
message(FATAL_ERROR "Either ENABLE_X11 or ENABLE_WAYLAND must be on")
|
||||
endif()
|
||||
|
||||
# Add/remove displayservers here!
|
||||
if (ENABLE_WAYLAND)
|
||||
add_displayserver(Wayland)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(displayserver_Wayland LANGUAGES C)
|
||||
|
||||
find_package(PkgConfig)
|
||||
@@ -8,19 +8,7 @@ pkg_check_modules(DISPLAYSERVER_Wayland REQUIRED IMPORTED_TARGET
|
||||
xkbcommon
|
||||
)
|
||||
|
||||
set(DISPLAYSERVER_Wayland_OPT_PKGCONFIG_LIBRARIES "")
|
||||
set(displayserver_Wayland_SHELL_SRC "")
|
||||
|
||||
if (ENABLE_LIBDECOR)
|
||||
pkg_check_modules(DISPLAYSERVER_Wayland_LIBDECOR REQUIRED IMPORTED_TARGET
|
||||
libdecor-0
|
||||
)
|
||||
list(APPEND DISPLAYSERVER_Wayland_OPT_PKGCONFIG_LIBRARIES PkgConfig::DISPLAYSERVER_Wayland_LIBDECOR)
|
||||
list(APPEND displayserver_Wayland_SHELL_SRC shell_libdecor.c)
|
||||
add_compile_definitions(ENABLE_LIBDECOR)
|
||||
else()
|
||||
list(APPEND displayserver_Wayland_SHELL_SRC shell_xdg.c)
|
||||
endif()
|
||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||
|
||||
add_library(displayserver_Wayland STATIC
|
||||
activation.c
|
||||
@@ -36,66 +24,19 @@ add_library(displayserver_Wayland STATIC
|
||||
registry.c
|
||||
wayland.c
|
||||
window.c
|
||||
${displayserver_Wayland_SHELL_SRC}
|
||||
)
|
||||
|
||||
add_subdirectory(protocol)
|
||||
add_subdirectory(desktops)
|
||||
|
||||
target_link_libraries(displayserver_Wayland
|
||||
PkgConfig::DISPLAYSERVER_Wayland
|
||||
${DISPLAYSERVER_Wayland_OPT_PKGCONFIG_LIBRARIES}
|
||||
lg_common
|
||||
wayland_protocol
|
||||
wayland_desktops
|
||||
)
|
||||
|
||||
target_include_directories(displayserver_Wayland
|
||||
PRIVATE
|
||||
src
|
||||
.
|
||||
)
|
||||
|
||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||
|
||||
macro(wayland_generate protocol_file output_file)
|
||||
add_custom_command(OUTPUT "${output_file}.h"
|
||||
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
|
||||
DEPENDS "${protocol_file}"
|
||||
VERBATIM)
|
||||
|
||||
add_custom_command(OUTPUT "${output_file}.c"
|
||||
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c"
|
||||
DEPENDS "${protocol_file}"
|
||||
VERBATIM)
|
||||
|
||||
target_sources(displayserver_Wayland PRIVATE "${output_file}.h" "${output_file}.c")
|
||||
endmacro()
|
||||
|
||||
set(WAYLAND_PROTOCOLS_BASE "${PROJECT_TOP}/repos/wayland-protocols")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/wayland")
|
||||
include_directories("${CMAKE_BINARY_DIR}/wayland")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-shell-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/stable/presentation-time/presentation-time.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-presentation-time-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-viewporter-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-decoration-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-relative-pointer-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-pointer-constraints-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-keyboard-shortcuts-inhibit-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-idle-inhibit-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-output/xdg-output-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-output-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/staging/xdg-activation/xdg-activation-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-activation-v1-client-protocol")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -376,7 +376,7 @@ static void clipboardReadCancel(struct ClipboardRead * data)
|
||||
static void clipboardReadCallback(uint32_t events, void * opaque)
|
||||
{
|
||||
struct ClipboardRead * data = opaque;
|
||||
if (events & EPOLLERR)
|
||||
if (events & EPOLLERR)
|
||||
{
|
||||
clipboardReadCancel(data);
|
||||
return;
|
||||
@@ -475,6 +475,7 @@ void waylandCBRequest(LG_ClipboardData type)
|
||||
close(data->fd);
|
||||
free(data->buf);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
|
||||
wlCb.currentRead = data;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
58
client/displayservers/Wayland/desktops/CMakeLists.txt
Normal file
58
client/displayservers/Wayland/desktops/CMakeLists.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(wayland_desktops LANGUAGES C)
|
||||
|
||||
set(DESKTOP_H "${CMAKE_BINARY_DIR}/include/dynamic/wayland_desktops.h")
|
||||
set(DESKTOP_C "${CMAKE_BINARY_DIR}/src/wayland_desktops.c")
|
||||
|
||||
file(WRITE ${DESKTOP_H} "#include \"interface/desktop.h\"\n\n")
|
||||
file(APPEND ${DESKTOP_H} "extern struct WL_DesktopOps * WL_Desktops[];\n\n")
|
||||
|
||||
file(WRITE ${DESKTOP_C} "#include \"interface/desktop.h\"\n\n")
|
||||
file(APPEND ${DESKTOP_C} "#include <stddef.h>\n\n")
|
||||
|
||||
set(DESKTOPS "_")
|
||||
set(DESKTOPS_LINK "_")
|
||||
function(add_desktop name)
|
||||
set(DESKTOPS "${DESKTOPS};${name}" PARENT_SCOPE)
|
||||
set(DESKTOPS_LINK "${DESKTOPS_LINK};wayland_desktop_${name}" PARENT_SCOPE)
|
||||
add_subdirectory(${name})
|
||||
endfunction()
|
||||
|
||||
# Add/remove desktops here!
|
||||
|
||||
# the first entry here is the default
|
||||
add_desktop(xdg)
|
||||
|
||||
pkg_check_modules(LIBDECOR IMPORTED_TARGET libdecor-0)
|
||||
if(LIBDECOR_FOUND)
|
||||
option(ENABLE_LIBDECOR "Build with libdecor support" ON)
|
||||
else()
|
||||
option(ENABLE_LIBDECOR "Build with libdecor support" OFF)
|
||||
endif()
|
||||
add_feature_info(ENABLE_LIBDECOR ENABLE_LIBDECOR "libdecor support.")
|
||||
if (ENABLE_LIBDECOR)
|
||||
add_desktop(libdecor)
|
||||
endif()
|
||||
|
||||
list(REMOVE_AT DESKTOPS 0)
|
||||
list(REMOVE_AT DESKTOPS_LINK 0)
|
||||
|
||||
list(LENGTH DESKTOPS DESKTOP_COUNT)
|
||||
file(APPEND ${DESKTOP_H} "#define WL_DESKTOP_COUNT ${DESKTOP_COUNT}\n")
|
||||
|
||||
foreach(desktop ${DESKTOPS})
|
||||
file(APPEND ${DESKTOP_C} "extern struct WL_DesktopOps WLD_${desktop};\n")
|
||||
endforeach()
|
||||
|
||||
file(APPEND ${DESKTOP_C} "\nconst struct WL_DesktopOps * WL_Desktops[] =\n{\n")
|
||||
foreach(desktop ${DESKTOPS})
|
||||
file(APPEND ${DESKTOP_C} " &WLD_${desktop},\n")
|
||||
endforeach()
|
||||
file(APPEND ${DESKTOP_C} " NULL\n};")
|
||||
|
||||
add_library(wayland_desktops STATIC ${DESKTOP_C})
|
||||
target_link_libraries(wayland_desktops ${DESKTOPS_LINK})
|
||||
target_include_directories(wayland_desktops
|
||||
PRIVATE
|
||||
../
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(wayland_desktop_libdecor LANGUAGES C)
|
||||
|
||||
add_library(wayland_desktop_libdecor STATIC
|
||||
libdecor.c
|
||||
)
|
||||
|
||||
target_link_libraries(wayland_desktop_libdecor
|
||||
lg_common
|
||||
wayland_protocol
|
||||
PkgConfig::LIBDECOR
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"../../"
|
||||
)
|
||||
281
client/displayservers/Wayland/desktops/libdecor/libdecor.c
Normal file
281
client/displayservers/Wayland/desktops/libdecor/libdecor.c
Normal file
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "interface/desktop.h"
|
||||
#include "wayland-xdg-shell-client-protocol.h"
|
||||
|
||||
#include "wayland.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include <libdecor.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
// Maximum number of fds we can process at once in waylandWait
|
||||
#define MAX_EPOLL_EVENTS 10
|
||||
|
||||
typedef struct LibDecorState
|
||||
{
|
||||
bool configured;
|
||||
struct libdecor * libdecor;
|
||||
struct libdecor_frame * libdecorFrame;
|
||||
|
||||
int32_t width, height;
|
||||
bool needsResize;
|
||||
bool fullscreen;
|
||||
bool borderless;
|
||||
uint32_t resizeSerial;
|
||||
}
|
||||
LibDecorState;
|
||||
|
||||
static LibDecorState state = {0};
|
||||
|
||||
struct libdecor_configuration
|
||||
{
|
||||
uint32_t serial;
|
||||
|
||||
bool has_window_state;
|
||||
enum libdecor_window_state window_state;
|
||||
|
||||
bool has_size;
|
||||
int window_width;
|
||||
int window_height;
|
||||
};
|
||||
|
||||
static void libdecorHandleError(struct libdecor * context, enum libdecor_error error,
|
||||
const char *message)
|
||||
{
|
||||
DEBUG_ERROR("Got libdecor error (%d): %s", error, message);
|
||||
}
|
||||
|
||||
static void libdecorFrameConfigure(struct libdecor_frame * frame,
|
||||
struct libdecor_configuration * configuration, void * opaque)
|
||||
{
|
||||
if (!state.configured)
|
||||
{
|
||||
xdg_surface_ack_configure(libdecor_frame_get_xdg_surface(frame), configuration->serial);
|
||||
state.configured = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
if (libdecor_configuration_get_content_size(configuration, frame, &width, &height))
|
||||
{
|
||||
state.width = width;
|
||||
state.height = height;
|
||||
|
||||
struct libdecor_state * s = libdecor_state_new(width, height);
|
||||
libdecor_frame_commit(state.libdecorFrame, s, NULL);
|
||||
libdecor_state_free(s);
|
||||
}
|
||||
|
||||
enum libdecor_window_state windowState;
|
||||
if (libdecor_configuration_get_window_state(configuration, &windowState))
|
||||
state.fullscreen = windowState & LIBDECOR_WINDOW_STATE_FULLSCREEN;
|
||||
|
||||
state.resizeSerial = configuration->serial;
|
||||
waylandNeedsResize();
|
||||
}
|
||||
|
||||
static void libdecorFrameClose(struct libdecor_frame * frame, void * opaque)
|
||||
{
|
||||
app_handleCloseEvent();
|
||||
}
|
||||
|
||||
static void libdecorFrameCommit(struct libdecor_frame * frame, void * opaque)
|
||||
{
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
static struct libdecor_interface libdecorListener =
|
||||
{
|
||||
libdecorHandleError,
|
||||
};
|
||||
|
||||
static struct libdecor_frame_interface libdecorFrameListener =
|
||||
{
|
||||
libdecorFrameConfigure,
|
||||
libdecorFrameClose,
|
||||
libdecorFrameCommit,
|
||||
};
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static void libdecorCallback(uint32_t events, void * opaque)
|
||||
{
|
||||
libdecor_dispatch(state.libdecor, 0);
|
||||
}
|
||||
|
||||
static bool libdecor_shellInit(
|
||||
struct wl_display * display, struct wl_surface * surface,
|
||||
const char * title, const char * appId, bool fullscreen,
|
||||
bool maximize, bool borderless, bool resizable)
|
||||
{
|
||||
state.libdecor = libdecor_new(display, &libdecorListener);
|
||||
state.libdecorFrame = libdecor_decorate(state.libdecor, surface,
|
||||
&libdecorFrameListener, NULL);
|
||||
|
||||
libdecor_frame_set_app_id(state.libdecorFrame, appId);
|
||||
libdecor_frame_set_title(state.libdecorFrame, title);
|
||||
libdecor_frame_map(state.libdecorFrame);
|
||||
|
||||
if (fullscreen)
|
||||
libdecor_frame_set_fullscreen(state.libdecorFrame, NULL);
|
||||
|
||||
if (maximize)
|
||||
libdecor_frame_set_maximized(state.libdecorFrame);
|
||||
|
||||
if (borderless)
|
||||
libdecor_frame_set_visibility(state.libdecorFrame, false);
|
||||
state.borderless = borderless;
|
||||
|
||||
if (resizable)
|
||||
libdecor_frame_set_capabilities(state.libdecorFrame,
|
||||
LIBDECOR_ACTION_RESIZE);
|
||||
else
|
||||
libdecor_frame_unset_capabilities(state.libdecorFrame,
|
||||
LIBDECOR_ACTION_RESIZE);
|
||||
|
||||
while (!state.configured)
|
||||
libdecor_dispatch(state.libdecor, 0);
|
||||
|
||||
if (!waylandPollRegister(libdecor_get_fd(state.libdecor),
|
||||
libdecorCallback, NULL, EPOLLIN))
|
||||
{
|
||||
DEBUG_ERROR("Failed register display to epoll: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void libdecor_shellAckConfigureIfNeeded(void)
|
||||
{
|
||||
if (state.resizeSerial)
|
||||
{
|
||||
xdg_surface_ack_configure(
|
||||
libdecor_frame_get_xdg_surface(state.libdecorFrame), state.resizeSerial);
|
||||
state.resizeSerial = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void libdecor_setFullscreen(bool fs)
|
||||
{
|
||||
if (fs)
|
||||
libdecor_frame_set_fullscreen(state.libdecorFrame, NULL);
|
||||
else
|
||||
libdecor_frame_unset_fullscreen(state.libdecorFrame);
|
||||
|
||||
if (!state.borderless)
|
||||
libdecor_frame_set_visibility(state.libdecorFrame, !fs);
|
||||
}
|
||||
|
||||
static bool libdecor_getFullscreen(void)
|
||||
{
|
||||
return state.fullscreen;
|
||||
}
|
||||
|
||||
static void libdecor_minimize(void)
|
||||
{
|
||||
libdecor_frame_set_minimized(state.libdecorFrame);
|
||||
}
|
||||
|
||||
static void libdecor_shellResize(int w, int h)
|
||||
{
|
||||
if (!libdecor_frame_is_floating(state.libdecorFrame))
|
||||
return;
|
||||
|
||||
state.width = w;
|
||||
state.height = h;
|
||||
|
||||
struct libdecor_state * s = libdecor_state_new(w, h);
|
||||
libdecor_frame_commit(state.libdecorFrame, s, NULL);
|
||||
libdecor_state_free(s);
|
||||
|
||||
waylandNeedsResize();
|
||||
}
|
||||
|
||||
static void libdecor_setSize(int w, int h)
|
||||
{
|
||||
state.width = w;
|
||||
state.height = h;
|
||||
}
|
||||
|
||||
static void libdecor_getSize(int * w, int * h)
|
||||
{
|
||||
*w = state.width;
|
||||
*h = state.height;
|
||||
}
|
||||
|
||||
static bool libdecor_registryGlobalHandler(void * data,
|
||||
struct wl_registry * registry, uint32_t name, const char * interface,
|
||||
uint32_t version)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool libdecor_pollInit(struct wl_display * display)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void libdecor_pollWait(struct wl_display * display, int epollFd,
|
||||
unsigned int time)
|
||||
{
|
||||
libdecor_dispatch(state.libdecor, 0);
|
||||
|
||||
struct epoll_event events[MAX_EPOLL_EVENTS];
|
||||
int count;
|
||||
if ((count = epoll_wait(epollFd, events, MAX_EPOLL_EVENTS, time)) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
DEBUG_INFO("epoll failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
struct WaylandPoll * poll = events[i].data.ptr;
|
||||
if (!poll->removed)
|
||||
poll->callback(events[i].events, poll->opaque);
|
||||
}
|
||||
}
|
||||
|
||||
WL_DesktopOps WLD_libdecor =
|
||||
{
|
||||
.name = "libdecor",
|
||||
.compositor = "gnome-shell",
|
||||
.shellInit = libdecor_shellInit,
|
||||
.shellAckConfigureIfNeeded = libdecor_shellAckConfigureIfNeeded,
|
||||
.setFullscreen = libdecor_setFullscreen,
|
||||
.getFullscreen = libdecor_getFullscreen,
|
||||
.minimize = libdecor_minimize,
|
||||
.shellResize = libdecor_shellResize,
|
||||
.setSize = libdecor_setSize,
|
||||
.getSize = libdecor_getSize,
|
||||
.registryGlobalHandler = libdecor_registryGlobalHandler,
|
||||
.pollInit = libdecor_pollInit,
|
||||
.pollWait = libdecor_pollWait
|
||||
};
|
||||
15
client/displayservers/Wayland/desktops/xdg/CMakeLists.txt
Normal file
15
client/displayservers/Wayland/desktops/xdg/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(wayland_desktop_xdg LANGUAGES C)
|
||||
|
||||
add_library(wayland_desktop_xdg STATIC
|
||||
xdg.c
|
||||
)
|
||||
|
||||
target_link_libraries(wayland_desktop_xdg
|
||||
lg_common
|
||||
wayland_protocol
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"../../"
|
||||
)
|
||||
322
client/displayservers/Wayland/desktops/xdg/xdg.c
Normal file
322
client/displayservers/Wayland/desktops/xdg/xdg.c
Normal file
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wayland.h"
|
||||
#include "wayland-xdg-shell-client-protocol.h"
|
||||
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
// Maximum number of fds we can process at once in waylandWait
|
||||
#define MAX_EPOLL_EVENTS 10
|
||||
|
||||
typedef struct XDGState
|
||||
{
|
||||
bool configured;
|
||||
|
||||
struct xdg_wm_base * wmBase;
|
||||
struct xdg_surface * surface;
|
||||
struct xdg_toplevel * toplevel;
|
||||
struct zxdg_decoration_manager_v1 * decorationManager;
|
||||
struct zxdg_toplevel_decoration_v1 * toplevelDecoration;
|
||||
|
||||
int32_t width, height;
|
||||
uint32_t resizeSerial;
|
||||
bool fullscreen;
|
||||
bool floating;
|
||||
bool resizable;
|
||||
int displayFd;
|
||||
}
|
||||
XDGState;
|
||||
|
||||
static XDGState state = {0};
|
||||
|
||||
// XDG WM base listeners.
|
||||
|
||||
static void xdgWmBasePing(void * data, struct xdg_wm_base * xdgWmBase, uint32_t serial)
|
||||
{
|
||||
xdg_wm_base_pong(xdgWmBase, serial);
|
||||
}
|
||||
|
||||
static const struct xdg_wm_base_listener xdgWmBaseListener = {
|
||||
.ping = xdgWmBasePing,
|
||||
};
|
||||
|
||||
// XDG Surface listeners.
|
||||
|
||||
static void xdgSurfaceConfigure(void * data, struct xdg_surface * xdgSurface,
|
||||
uint32_t serial)
|
||||
{
|
||||
if (state.configured)
|
||||
{
|
||||
state.resizeSerial = serial;
|
||||
waylandNeedsResize();
|
||||
}
|
||||
else
|
||||
{
|
||||
xdg_surface_ack_configure(xdgSurface, serial);
|
||||
state.configured = true;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct xdg_surface_listener xdgSurfaceListener = {
|
||||
.configure = xdgSurfaceConfigure,
|
||||
};
|
||||
|
||||
// XDG Toplevel listeners.
|
||||
|
||||
static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel,
|
||||
int32_t width, int32_t height, struct wl_array * states)
|
||||
{
|
||||
state.width = width;
|
||||
state.height = height;
|
||||
state.fullscreen = false;
|
||||
state.floating = true;
|
||||
|
||||
enum xdg_toplevel_state * s;
|
||||
wl_array_for_each(s, states)
|
||||
{
|
||||
switch (*s)
|
||||
{
|
||||
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
||||
state.fullscreen = true;
|
||||
// fallthrough
|
||||
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
||||
case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_TOP:
|
||||
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
|
||||
state.floating = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void xdgToplevelClose(void * data, struct xdg_toplevel * xdgToplevel)
|
||||
{
|
||||
app_handleCloseEvent();
|
||||
}
|
||||
|
||||
static const struct xdg_toplevel_listener xdgToplevelListener = {
|
||||
.configure = xdgToplevelConfigure,
|
||||
.close = xdgToplevelClose,
|
||||
};
|
||||
|
||||
bool xdg_shellInit(struct wl_display * display, struct wl_surface * surface,
|
||||
const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless,
|
||||
bool resizable)
|
||||
{
|
||||
if (!state.wmBase)
|
||||
{
|
||||
DEBUG_ERROR("Compositor missing xdg_wm_base, will not proceed");
|
||||
return false;
|
||||
}
|
||||
|
||||
xdg_wm_base_add_listener(state.wmBase, &xdgWmBaseListener, NULL);
|
||||
|
||||
state.surface = xdg_wm_base_get_xdg_surface(state.wmBase, surface);
|
||||
xdg_surface_add_listener(state.surface, &xdgSurfaceListener, NULL);
|
||||
|
||||
state.toplevel = xdg_surface_get_toplevel(state.surface);
|
||||
xdg_toplevel_add_listener(state.toplevel, &xdgToplevelListener, NULL);
|
||||
xdg_toplevel_set_title(state.toplevel, title);
|
||||
xdg_toplevel_set_app_id(state.toplevel, appId);
|
||||
|
||||
if (fullscreen)
|
||||
xdg_toplevel_set_fullscreen(state.toplevel, NULL);
|
||||
|
||||
if (maximize)
|
||||
xdg_toplevel_set_maximized(state.toplevel);
|
||||
|
||||
if (!resizable)
|
||||
{
|
||||
xdg_toplevel_set_min_size(state.toplevel, state.width, state.height);
|
||||
xdg_toplevel_set_max_size(state.toplevel, state.width, state.height);
|
||||
}
|
||||
state.resizable = resizable;
|
||||
|
||||
if (state.decorationManager)
|
||||
{
|
||||
state.toplevelDecoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
|
||||
state.decorationManager, state.toplevel);
|
||||
if (state.toplevelDecoration)
|
||||
{
|
||||
zxdg_toplevel_decoration_v1_set_mode(state.toplevelDecoration,
|
||||
borderless ?
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void xdg_shellAckConfigureIfNeeded(void)
|
||||
{
|
||||
if (state.resizeSerial)
|
||||
{
|
||||
xdg_surface_ack_configure(state.surface, state.resizeSerial);
|
||||
state.resizeSerial = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void xdg_setFullscreen(bool fs)
|
||||
{
|
||||
if (fs)
|
||||
xdg_toplevel_set_fullscreen(state.toplevel, NULL);
|
||||
else
|
||||
xdg_toplevel_unset_fullscreen(state.toplevel);
|
||||
}
|
||||
|
||||
static bool xdg_getFullscreen(void)
|
||||
{
|
||||
return state.fullscreen;
|
||||
}
|
||||
|
||||
static void xdg_minimize(void)
|
||||
{
|
||||
xdg_toplevel_set_minimized(state.toplevel);
|
||||
}
|
||||
|
||||
static void xdg_shellResize(int w, int h)
|
||||
{
|
||||
if (!state.floating || !state.resizable)
|
||||
return;
|
||||
|
||||
state.width = w;
|
||||
state.height = h;
|
||||
xdg_surface_set_window_geometry(state.surface, 0, 0, w, h);
|
||||
|
||||
waylandNeedsResize();
|
||||
}
|
||||
|
||||
static void xdg_setSize(int w, int h)
|
||||
{
|
||||
state.width = w;
|
||||
state.height = h;
|
||||
}
|
||||
|
||||
static void xdg_getSize(int * w, int * h)
|
||||
{
|
||||
*w = state.width;
|
||||
*h = state.height;
|
||||
}
|
||||
|
||||
static bool xdg_registryGlobalHandler(void * data,
|
||||
struct wl_registry * registry, uint32_t name, const char * interface,
|
||||
uint32_t version)
|
||||
{
|
||||
if (!strcmp(interface, xdg_wm_base_interface.name))
|
||||
{
|
||||
state.wmBase = wl_registry_bind(registry, name,
|
||||
&xdg_wm_base_interface, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name))
|
||||
{
|
||||
state.decorationManager = wl_registry_bind(registry, name,
|
||||
&zxdg_decoration_manager_v1_interface, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void waylandDisplayCallback(uint32_t events, void * opaque)
|
||||
{
|
||||
struct wl_display * display = (struct wl_display *)opaque;
|
||||
if (events & EPOLLERR)
|
||||
wl_display_cancel_read(display);
|
||||
else
|
||||
wl_display_read_events(display);
|
||||
wl_display_dispatch_pending(display);
|
||||
}
|
||||
|
||||
static bool xdg_pollInit(struct wl_display * display)
|
||||
{
|
||||
state.displayFd = wl_display_get_fd(display);
|
||||
if (!waylandPollRegister(state.displayFd, waylandDisplayCallback,
|
||||
display, EPOLLIN))
|
||||
{
|
||||
DEBUG_ERROR("Failed register display to epoll: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void xdg_pollWait(struct wl_display * display, int epollFd,
|
||||
unsigned int time)
|
||||
{
|
||||
while (wl_display_prepare_read(display))
|
||||
wl_display_dispatch_pending(display);
|
||||
wl_display_flush(display);
|
||||
|
||||
struct epoll_event events[MAX_EPOLL_EVENTS];
|
||||
int count;
|
||||
if ((count = epoll_wait(epollFd, events, MAX_EPOLL_EVENTS, time)) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
DEBUG_INFO("epoll failed: %s", strerror(errno));
|
||||
wl_display_cancel_read(display);
|
||||
return;
|
||||
}
|
||||
|
||||
bool sawDisplay = false;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
struct WaylandPoll * poll = events[i].data.ptr;
|
||||
if (!poll->removed)
|
||||
poll->callback(events[i].events, poll->opaque);
|
||||
if (poll->fd == state.displayFd)
|
||||
sawDisplay = true;
|
||||
}
|
||||
|
||||
if (!sawDisplay)
|
||||
wl_display_cancel_read(display);
|
||||
}
|
||||
|
||||
WL_DesktopOps WLD_xdg =
|
||||
{
|
||||
.name = "xdg",
|
||||
.compositor = "",
|
||||
.shellInit = xdg_shellInit,
|
||||
.shellAckConfigureIfNeeded = xdg_shellAckConfigureIfNeeded,
|
||||
.setFullscreen = xdg_setFullscreen,
|
||||
.getFullscreen = xdg_getFullscreen,
|
||||
.minimize = xdg_minimize,
|
||||
.shellResize = xdg_shellResize,
|
||||
.setSize = xdg_setSize,
|
||||
.getSize = xdg_getSize,
|
||||
.registryGlobalHandler = xdg_registryGlobalHandler,
|
||||
.pollInit = xdg_pollInit,
|
||||
.pollWait = xdg_pollWait
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -89,18 +89,25 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface, const struct
|
||||
if (wlWm.needsResize)
|
||||
{
|
||||
bool skipResize = false;
|
||||
wl_egl_window_resize(wlWm.eglWindow, wl_fixed_to_int(wlWm.width * wlWm.scale),
|
||||
wl_fixed_to_int(wlWm.height * wlWm.scale), 0, 0);
|
||||
|
||||
if (wlWm.width == 0 || wlWm.height == 0)
|
||||
int width, height;
|
||||
wlWm.desktop->getSize(&width, &height);
|
||||
wl_egl_window_resize(wlWm.eglWindow, wl_fixed_to_int(width * wlWm.scale),
|
||||
wl_fixed_to_int(height * wlWm.scale), 0, 0);
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
skipResize = true;
|
||||
else if (wlWm.fractionalScale)
|
||||
{
|
||||
wl_surface_set_buffer_scale(wlWm.surface, 1);
|
||||
if (!wlWm.viewport)
|
||||
wlWm.viewport = wp_viewporter_get_viewport(wlWm.viewporter, wlWm.surface);
|
||||
wp_viewport_set_source(wlWm.viewport, 0, 0, wlWm.width * wlWm.scale, wlWm.height * wlWm.scale);
|
||||
wp_viewport_set_destination(wlWm.viewport, wlWm.width, wlWm.height);
|
||||
wp_viewport_set_source(
|
||||
wlWm.viewport,
|
||||
wl_fixed_from_int(-1), wl_fixed_from_int(-1),
|
||||
wl_fixed_from_int(-1), wl_fixed_from_int(-1)
|
||||
);
|
||||
wp_viewport_set_destination(wlWm.viewport, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,18 +127,18 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface, const struct
|
||||
}
|
||||
|
||||
struct wl_region * region = wl_compositor_create_region(wlWm.compositor);
|
||||
wl_region_add(region, 0, 0, wlWm.width, wlWm.height);
|
||||
wl_region_add(region, 0, 0, width, height);
|
||||
wl_surface_set_opaque_region(wlWm.surface, region);
|
||||
wl_region_destroy(region);
|
||||
|
||||
app_handleResizeEvent(wlWm.width, wlWm.height, wl_fixed_to_double(wlWm.scale),
|
||||
app_handleResizeEvent(width, height, wl_fixed_to_double(wlWm.scale),
|
||||
(struct Border) {0, 0, 0, 0});
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
wlWm.needsResize = skipResize;
|
||||
}
|
||||
|
||||
waylandShellAckConfigureIfNeeded();
|
||||
wlWm.desktop->shellAckConfigureIfNeeded();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -209,7 +209,7 @@ done:
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static int getCharcode(uint32_t key)
|
||||
int waylandGetCharCode(int key)
|
||||
{
|
||||
key += 8; // xkb scancode is evdev scancode + 8
|
||||
xkb_keysym_t sym = xkb_state_key_get_one_sym(wlWm.xkbState, key);
|
||||
@@ -232,7 +232,7 @@ static void keyboardEnterHandler(void * data, struct wl_keyboard * keyboard,
|
||||
|
||||
uint32_t * key;
|
||||
wl_array_for_each(key, keys)
|
||||
app_handleKeyPress(*key, getCharcode(*key));
|
||||
app_handleKeyPress(*key);
|
||||
}
|
||||
|
||||
static void keyboardLeaveHandler(void * data, struct wl_keyboard * keyboard,
|
||||
@@ -253,9 +253,9 @@ static void keyboardKeyHandler(void * data, struct wl_keyboard * keyboard,
|
||||
return;
|
||||
|
||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||
app_handleKeyPress(key, getCharcode(key));
|
||||
app_handleKeyPress(key);
|
||||
else
|
||||
app_handleKeyRelease(key, getCharcode(key));
|
||||
app_handleKeyRelease(key);
|
||||
|
||||
if (!wlWm.xkbState || !app_isOverlayMode() || state != WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||
return;
|
||||
@@ -590,10 +590,13 @@ void waylandWarpPointer(int x, int y, bool exiting)
|
||||
return;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
wlWm.desktop->getSize(&width, &height);
|
||||
|
||||
if (x < 0) x = 0;
|
||||
else if (x >= wlWm.width) x = wlWm.width - 1;
|
||||
else if (x >= width) x = width - 1;
|
||||
if (y < 0) y = 0;
|
||||
else if (y >= wlWm.height) y = wlWm.height - 1;
|
||||
else if (y >= height) y = height - 1;
|
||||
|
||||
struct wl_region * region = wl_compositor_create_region(wlWm.compositor);
|
||||
wl_region_add(region, x, y, 1, 1);
|
||||
|
||||
64
client/displayservers/Wayland/interface/desktop.h
Normal file
64
client/displayservers/Wayland/interface/desktop.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_WAYLAND_DESKTOP_H_
|
||||
#define _H_WAYLAND_DESKTOP_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
typedef struct WL_DesktopOps
|
||||
{
|
||||
// the friendly name
|
||||
const char * name;
|
||||
|
||||
// the compositor process name to match
|
||||
const char * compositor;
|
||||
|
||||
bool (*shellInit)(
|
||||
struct wl_display * display, struct wl_surface * surface,
|
||||
const char * title, const char * appId, bool fullscreen, bool maximize,
|
||||
bool borderless, bool resizable);
|
||||
|
||||
void (*shellAckConfigureIfNeeded)(void);
|
||||
|
||||
void (*setFullscreen)(bool fs);
|
||||
|
||||
bool (*getFullscreen)(void);
|
||||
|
||||
void (*minimize)(void);
|
||||
|
||||
void (*shellResize)(int w, int h);
|
||||
|
||||
void (*setSize)(int w, int h);
|
||||
|
||||
void (*getSize)(int * w, int * h);
|
||||
|
||||
bool (*registryGlobalHandler)(
|
||||
void * data, struct wl_registry * registry,
|
||||
uint32_t name, const char * interface, uint32_t version);
|
||||
|
||||
bool (*pollInit)(struct wl_display * display);
|
||||
|
||||
void (*pollWait)(struct wl_display * display, int epollFd, unsigned int time);
|
||||
}
|
||||
WL_DesktopOps;
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -30,23 +30,6 @@
|
||||
#include "common/debug.h"
|
||||
#include "common/locking.h"
|
||||
|
||||
#ifdef ENABLE_LIBDECOR
|
||||
#include <libdecor.h>
|
||||
#endif
|
||||
|
||||
#define EPOLL_EVENTS 10 // Maximum number of fds we can process at once in waylandWait
|
||||
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
static void waylandDisplayCallback(uint32_t events, void * opaque)
|
||||
{
|
||||
if (events & EPOLLERR)
|
||||
wl_display_cancel_read(wlWm.display);
|
||||
else
|
||||
wl_display_read_events(wlWm.display);
|
||||
wl_display_dispatch_pending(wlWm.display);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool waylandPollInit(void)
|
||||
{
|
||||
wlWm.epollFd = epoll_create1(EPOLL_CLOEXEC);
|
||||
@@ -61,58 +44,12 @@ bool waylandPollInit(void)
|
||||
LG_LOCK_INIT(wlWm.pollLock);
|
||||
LG_LOCK_INIT(wlWm.pollFreeLock);
|
||||
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
wlWm.displayFd = wl_display_get_fd(wlWm.display);
|
||||
if (!waylandPollRegister(wlWm.displayFd, waylandDisplayCallback, NULL, EPOLLIN))
|
||||
{
|
||||
DEBUG_ERROR("Failed register display to epoll: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return wlWm.desktop->pollInit(wlWm.display);
|
||||
}
|
||||
|
||||
void waylandWait(unsigned int time)
|
||||
{
|
||||
#ifdef ENABLE_LIBDECOR
|
||||
libdecor_dispatch(wlWm.libdecor, 0);
|
||||
#else
|
||||
while (wl_display_prepare_read(wlWm.display))
|
||||
wl_display_dispatch_pending(wlWm.display);
|
||||
wl_display_flush(wlWm.display);
|
||||
#endif
|
||||
|
||||
struct epoll_event events[EPOLL_EVENTS];
|
||||
int count;
|
||||
if ((count = epoll_wait(wlWm.epollFd, events, EPOLL_EVENTS, time)) < 0)
|
||||
{
|
||||
if (errno != EINTR)
|
||||
DEBUG_INFO("epoll failed: %s", strerror(errno));
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
wl_display_cancel_read(wlWm.display);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
bool sawDisplay = false;
|
||||
#endif
|
||||
for (int i = 0; i < count; ++i) {
|
||||
struct WaylandPoll * poll = events[i].data.ptr;
|
||||
if (!poll->removed)
|
||||
poll->callback(events[i].events, poll->opaque);
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
if (poll->fd == wlWm.displayFd)
|
||||
sawDisplay = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
if (!sawDisplay)
|
||||
wl_display_cancel_read(wlWm.display);
|
||||
#endif
|
||||
|
||||
wlWm.desktop->pollWait(wlWm.display, wlWm.epollFd, time);
|
||||
INTERLOCKED_SECTION(wlWm.pollFreeLock,
|
||||
{
|
||||
struct WaylandPoll * node;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -109,10 +109,17 @@ void waylandPresentationFrame(void)
|
||||
return;
|
||||
|
||||
struct FrameData * data = malloc(sizeof(*data));
|
||||
if (!data)
|
||||
{
|
||||
DEBUG_ERROR("out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
if (clock_gettime(wlWm.clkId, &data->sent))
|
||||
{
|
||||
DEBUG_ERROR("clock_gettime failed: %s\n", strerror(errno));
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
|
||||
struct wp_presentation_feedback * feedback = wp_presentation_feedback(wlWm.presentation, wlWm.surface);
|
||||
|
||||
71
client/displayservers/Wayland/protocol/CMakeLists.txt
Normal file
71
client/displayservers/Wayland/protocol/CMakeLists.txt
Normal file
@@ -0,0 +1,71 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(wayland_protocol LANGUAGES C)
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(WAYLAND REQUIRED IMPORTED_TARGET
|
||||
wayland-client
|
||||
wayland-cursor
|
||||
xkbcommon
|
||||
)
|
||||
|
||||
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
|
||||
|
||||
add_library(wayland_protocol STATIC
|
||||
)
|
||||
|
||||
macro(wayland_generate protocol_file output_file)
|
||||
add_custom_command(OUTPUT "${output_file}.h"
|
||||
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h"
|
||||
DEPENDS "${protocol_file}"
|
||||
VERBATIM)
|
||||
|
||||
add_custom_command(OUTPUT "${output_file}.c"
|
||||
COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c"
|
||||
DEPENDS "${protocol_file}"
|
||||
VERBATIM)
|
||||
|
||||
target_sources(wayland_protocol PRIVATE "${output_file}.h" "${output_file}.c")
|
||||
endmacro()
|
||||
|
||||
set(WAYLAND_PROTOCOLS_BASE "${PROJECT_TOP}/repos/wayland-protocols")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/wayland")
|
||||
include_directories("${CMAKE_BINARY_DIR}/wayland")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-shell-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/stable/presentation-time/presentation-time.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-presentation-time-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-viewporter-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-decoration-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-relative-pointer-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-pointer-constraints-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-keyboard-shortcuts-inhibit-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-idle-inhibit-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-output/xdg-output-unstable-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-output-unstable-v1-client-protocol")
|
||||
wayland_generate(
|
||||
"${WAYLAND_PROTOCOLS_BASE}/staging/xdg-activation/xdg-activation-v1.xml"
|
||||
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-activation-v1-client-protocol")
|
||||
|
||||
target_link_libraries(wayland_protocol
|
||||
PkgConfig::WAYLAND
|
||||
)
|
||||
|
||||
target_include_directories(wayland_protocol
|
||||
PUBLIC
|
||||
"${CMAKE_BINARY_DIR}/wayland"
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -40,13 +40,6 @@ static void registryGlobalHandler(void * data, struct wl_registry * registry,
|
||||
wlWm.compositor = wl_registry_bind(wlWm.registry, name,
|
||||
// we only need v3 to run, but v4 can use eglSwapBuffersWithDamageKHR
|
||||
&wl_compositor_interface, version > 4 ? 4 : version);
|
||||
#ifndef ENABLE_LIBDECOR
|
||||
else if (!strcmp(interface, xdg_wm_base_interface.name))
|
||||
wlWm.xdgWmBase = wl_registry_bind(wlWm.registry, name, &xdg_wm_base_interface, 1);
|
||||
else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name))
|
||||
wlWm.xdgDecorationManager = wl_registry_bind(wlWm.registry, name,
|
||||
&zxdg_decoration_manager_v1_interface, 1);
|
||||
#endif
|
||||
else if (!strcmp(interface, wp_presentation_interface.name))
|
||||
wlWm.presentation = wl_registry_bind(wlWm.registry, name,
|
||||
&wp_presentation_interface, 1);
|
||||
@@ -75,6 +68,9 @@ static void registryGlobalHandler(void * data, struct wl_registry * registry,
|
||||
else if (!strcmp(interface, xdg_activation_v1_interface.name))
|
||||
wlWm.xdgActivation = wl_registry_bind(wlWm.registry, name,
|
||||
&xdg_activation_v1_interface, 1);
|
||||
else if (wlWm.desktop->registryGlobalHandler(
|
||||
data, registry, name, interface, version))
|
||||
return;
|
||||
}
|
||||
|
||||
static void registryGlobalRemoveHandler(void * data,
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wayland.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include <libdecor.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
struct libdecor_configuration {
|
||||
uint32_t serial;
|
||||
|
||||
bool has_window_state;
|
||||
enum libdecor_window_state window_state;
|
||||
|
||||
bool has_size;
|
||||
int window_width;
|
||||
int window_height;
|
||||
};
|
||||
|
||||
static void libdecorHandleError(struct libdecor * context, enum libdecor_error error,
|
||||
const char *message)
|
||||
{
|
||||
DEBUG_ERROR("Got libdecor error (%d): %s", error, message);
|
||||
}
|
||||
|
||||
static void libdecorFrameConfigure(struct libdecor_frame * frame,
|
||||
struct libdecor_configuration * configuration, void * opaque)
|
||||
{
|
||||
if (!wlWm.configured)
|
||||
{
|
||||
xdg_surface_ack_configure(libdecor_frame_get_xdg_surface(frame), configuration->serial);
|
||||
wlWm.configured = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
if (libdecor_configuration_get_content_size(configuration, frame, &width, &height))
|
||||
{
|
||||
wlWm.width = width;
|
||||
wlWm.height = height;
|
||||
|
||||
struct libdecor_state * state = libdecor_state_new(wlWm.width, wlWm.height);
|
||||
libdecor_frame_commit(wlWm.libdecorFrame, state, NULL);
|
||||
libdecor_state_free(state);
|
||||
}
|
||||
|
||||
enum libdecor_window_state windowState;
|
||||
if (libdecor_configuration_get_window_state(configuration, &windowState))
|
||||
wlWm.fullscreen = windowState & LIBDECOR_WINDOW_STATE_FULLSCREEN;
|
||||
|
||||
wlWm.needsResize = true;
|
||||
wlWm.resizeSerial = configuration->serial;
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
|
||||
static void libdecorFrameClose(struct libdecor_frame * frame, void * opaque)
|
||||
{
|
||||
app_handleCloseEvent();
|
||||
}
|
||||
|
||||
static void libdecorFrameCommit(struct libdecor_frame * frame, void * opaque)
|
||||
{
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
static struct libdecor_interface libdecorListener = {
|
||||
libdecorHandleError,
|
||||
};
|
||||
|
||||
static struct libdecor_frame_interface libdecorFrameListener = {
|
||||
libdecorFrameConfigure,
|
||||
libdecorFrameClose,
|
||||
libdecorFrameCommit,
|
||||
};
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static void libdecorCallback(uint32_t events, void * opaque)
|
||||
{
|
||||
libdecor_dispatch(wlWm.libdecor, 0);
|
||||
}
|
||||
|
||||
bool waylandShellInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable)
|
||||
{
|
||||
wlWm.libdecor = libdecor_new(wlWm.display, &libdecorListener);
|
||||
wlWm.libdecorFrame = libdecor_decorate(wlWm.libdecor, wlWm.surface, &libdecorFrameListener, NULL);
|
||||
|
||||
libdecor_frame_set_app_id(wlWm.libdecorFrame, "looking-glass-client");
|
||||
libdecor_frame_set_title(wlWm.libdecorFrame, title);
|
||||
libdecor_frame_map(wlWm.libdecorFrame);
|
||||
|
||||
if (resizable)
|
||||
libdecor_frame_set_capabilities(wlWm.libdecorFrame, LIBDECOR_ACTION_RESIZE);
|
||||
else
|
||||
libdecor_frame_unset_capabilities(wlWm.libdecorFrame, LIBDECOR_ACTION_RESIZE);
|
||||
|
||||
while (!wlWm.configured)
|
||||
libdecor_dispatch(wlWm.libdecor, 0);
|
||||
|
||||
if (!waylandPollRegister(libdecor_get_fd(wlWm.libdecor), libdecorCallback, NULL, EPOLLIN))
|
||||
{
|
||||
DEBUG_ERROR("Failed register display to epoll: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void waylandShellAckConfigureIfNeeded(void)
|
||||
{
|
||||
if (wlWm.resizeSerial)
|
||||
{
|
||||
xdg_surface_ack_configure(libdecor_frame_get_xdg_surface(wlWm.libdecorFrame), wlWm.resizeSerial);
|
||||
wlWm.resizeSerial = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void waylandSetFullscreen(bool fs)
|
||||
{
|
||||
if (fs)
|
||||
libdecor_frame_set_fullscreen(wlWm.libdecorFrame, NULL);
|
||||
else
|
||||
libdecor_frame_unset_fullscreen(wlWm.libdecorFrame);
|
||||
|
||||
libdecor_frame_set_visibility(wlWm.libdecorFrame, !fs);
|
||||
}
|
||||
|
||||
bool waylandGetFullscreen(void)
|
||||
{
|
||||
return wlWm.fullscreen;
|
||||
}
|
||||
|
||||
void waylandMinimize(void)
|
||||
{
|
||||
libdecor_frame_set_minimized(wlWm.libdecorFrame);
|
||||
}
|
||||
|
||||
void waylandShellResize(int w, int h)
|
||||
{
|
||||
if (!libdecor_frame_is_floating(wlWm.libdecorFrame))
|
||||
return;
|
||||
|
||||
wlWm.width = w;
|
||||
wlWm.height = h;
|
||||
|
||||
struct libdecor_state * state = libdecor_state_new(w, h);
|
||||
libdecor_frame_commit(wlWm.libdecorFrame, state, NULL);
|
||||
libdecor_state_free(state);
|
||||
|
||||
wlWm.needsResize = true;
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "wayland.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
// XDG WM base listeners.
|
||||
|
||||
static void xdgWmBasePing(void * data, struct xdg_wm_base * xdgWmBase, uint32_t serial)
|
||||
{
|
||||
xdg_wm_base_pong(xdgWmBase, serial);
|
||||
}
|
||||
|
||||
static const struct xdg_wm_base_listener xdgWmBaseListener = {
|
||||
.ping = xdgWmBasePing,
|
||||
};
|
||||
|
||||
// XDG Surface listeners.
|
||||
|
||||
static void xdgSurfaceConfigure(void * data, struct xdg_surface * xdgSurface,
|
||||
uint32_t serial)
|
||||
{
|
||||
if (wlWm.configured)
|
||||
{
|
||||
wlWm.needsResize = true;
|
||||
wlWm.resizeSerial = serial;
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
xdg_surface_ack_configure(xdgSurface, serial);
|
||||
wlWm.configured = true;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct xdg_surface_listener xdgSurfaceListener = {
|
||||
.configure = xdgSurfaceConfigure,
|
||||
};
|
||||
|
||||
// XDG Toplevel listeners.
|
||||
|
||||
static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel,
|
||||
int32_t width, int32_t height, struct wl_array * states)
|
||||
{
|
||||
wlWm.width = width;
|
||||
wlWm.height = height;
|
||||
wlWm.fullscreen = false;
|
||||
wlWm.floating = true;
|
||||
|
||||
enum xdg_toplevel_state * state;
|
||||
wl_array_for_each(state, states)
|
||||
{
|
||||
switch (*state)
|
||||
{
|
||||
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
||||
wlWm.fullscreen = true;
|
||||
// fallthrough
|
||||
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
||||
case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_TOP:
|
||||
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
|
||||
wlWm.floating = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void xdgToplevelClose(void * data, struct xdg_toplevel * xdgToplevel)
|
||||
{
|
||||
app_handleCloseEvent();
|
||||
}
|
||||
|
||||
static const struct xdg_toplevel_listener xdgToplevelListener = {
|
||||
.configure = xdgToplevelConfigure,
|
||||
.close = xdgToplevelClose,
|
||||
};
|
||||
|
||||
bool waylandShellInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable)
|
||||
{
|
||||
if (!wlWm.xdgWmBase)
|
||||
{
|
||||
DEBUG_ERROR("Compositor missing xdg_wm_base, will not proceed");
|
||||
return false;
|
||||
}
|
||||
|
||||
xdg_wm_base_add_listener(wlWm.xdgWmBase, &xdgWmBaseListener, NULL);
|
||||
|
||||
wlWm.xdgSurface = xdg_wm_base_get_xdg_surface(wlWm.xdgWmBase, wlWm.surface);
|
||||
xdg_surface_add_listener(wlWm.xdgSurface, &xdgSurfaceListener, NULL);
|
||||
|
||||
wlWm.xdgToplevel = xdg_surface_get_toplevel(wlWm.xdgSurface);
|
||||
xdg_toplevel_add_listener(wlWm.xdgToplevel, &xdgToplevelListener, NULL);
|
||||
xdg_toplevel_set_title(wlWm.xdgToplevel, title);
|
||||
xdg_toplevel_set_app_id(wlWm.xdgToplevel, "looking-glass-client");
|
||||
|
||||
if (fullscreen)
|
||||
xdg_toplevel_set_fullscreen(wlWm.xdgToplevel, NULL);
|
||||
|
||||
if (maximize)
|
||||
xdg_toplevel_set_maximized(wlWm.xdgToplevel);
|
||||
|
||||
if (wlWm.xdgDecorationManager)
|
||||
{
|
||||
wlWm.xdgToplevelDecoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
|
||||
wlWm.xdgDecorationManager, wlWm.xdgToplevel);
|
||||
if (wlWm.xdgToplevelDecoration)
|
||||
{
|
||||
zxdg_toplevel_decoration_v1_set_mode(wlWm.xdgToplevelDecoration,
|
||||
borderless ?
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void waylandShellAckConfigureIfNeeded(void)
|
||||
{
|
||||
if (wlWm.resizeSerial)
|
||||
{
|
||||
xdg_surface_ack_configure(wlWm.xdgSurface, wlWm.resizeSerial);
|
||||
wlWm.resizeSerial = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void waylandSetFullscreen(bool fs)
|
||||
{
|
||||
if (fs)
|
||||
xdg_toplevel_set_fullscreen(wlWm.xdgToplevel, NULL);
|
||||
else
|
||||
xdg_toplevel_unset_fullscreen(wlWm.xdgToplevel);
|
||||
}
|
||||
|
||||
bool waylandGetFullscreen(void)
|
||||
{
|
||||
return wlWm.fullscreen;
|
||||
}
|
||||
|
||||
void waylandMinimize(void)
|
||||
{
|
||||
xdg_toplevel_set_minimized(wlWm.xdgToplevel);
|
||||
}
|
||||
|
||||
void waylandShellResize(int w, int h)
|
||||
{
|
||||
if (!wlWm.floating)
|
||||
return;
|
||||
|
||||
wlWm.width = w;
|
||||
wlWm.height = h;
|
||||
xdg_surface_set_window_geometry(wlWm.xdgSurface, 0, 0, w, h);
|
||||
|
||||
wlWm.needsResize = true;
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -24,10 +24,13 @@
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <wayland-client.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/option.h"
|
||||
|
||||
#include "dynamic/wayland_desktops.h"
|
||||
|
||||
static struct Option waylandOptions[] =
|
||||
{
|
||||
{
|
||||
@@ -68,22 +71,69 @@ static bool waylandProbe(void)
|
||||
return getenv("WAYLAND_DISPLAY") != NULL;
|
||||
}
|
||||
|
||||
static bool getCompositor(char * dst, size_t size)
|
||||
{
|
||||
int fd = wl_display_get_fd(wlWm.display);
|
||||
struct ucred ucred;
|
||||
socklen_t len = sizeof(struct ucred);
|
||||
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1)
|
||||
{
|
||||
DEBUG_ERROR("Failed to get the pid of the socket");
|
||||
return false;
|
||||
}
|
||||
|
||||
char path[64];
|
||||
snprintf(path, sizeof(path), "/proc/%d/comm", ucred.pid);
|
||||
FILE *fp = fopen(path, "r");
|
||||
if (!fp)
|
||||
{
|
||||
DEBUG_ERROR("Failed to open %s", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fgets(dst, size, fp))
|
||||
{
|
||||
DEBUG_ERROR("Failed to read %s", path);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
dst[strlen(dst) - 1] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool waylandInit(const LG_DSInitParams params)
|
||||
{
|
||||
memset(&wlWm, 0, sizeof(wlWm));
|
||||
wlWm.desktop = WL_Desktops[0];
|
||||
|
||||
wlWm.display = wl_display_connect(NULL);
|
||||
if (!wlWm.display)
|
||||
return false;
|
||||
|
||||
// select the desktop interface based on the compositor process name
|
||||
char compositor[1024];
|
||||
if (getCompositor(compositor, sizeof(compositor)))
|
||||
{
|
||||
DEBUG_INFO("Compositor: %s", compositor);
|
||||
for(int i = 0; i < WL_DESKTOP_COUNT; ++i)
|
||||
if (strcmp(WL_Desktops[i]->compositor, compositor) == 0)
|
||||
{
|
||||
wlWm.desktop = WL_Desktops[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
DEBUG_WARN("Compositor: UNKNOWN");
|
||||
DEBUG_INFO("Selected : %s", wlWm.desktop->name);
|
||||
|
||||
wl_list_init(&wlWm.surfaceOutputs);
|
||||
|
||||
wlWm.warpSupport = option_get_bool("wayland", "warpSupport");
|
||||
wlWm.useFractionalScale = option_get_bool("wayland", "fractionScale");
|
||||
|
||||
wlWm.width = params.w;
|
||||
wlWm.height = params.h;
|
||||
|
||||
if (!waylandPollInit())
|
||||
return false;
|
||||
|
||||
@@ -108,7 +158,9 @@ static bool waylandInit(const LG_DSInitParams params)
|
||||
if (!waylandInputInit())
|
||||
return false;
|
||||
|
||||
if (!waylandWindowInit(params.title, params.fullscreen, params.maximize, params.borderless, params.resizable))
|
||||
wlWm.desktop->setSize(params.w, params.h);
|
||||
if (!waylandWindowInit(params.title, params.appId, params.fullscreen, params.maximize,
|
||||
params.borderless, params.resizable))
|
||||
return false;
|
||||
|
||||
if (!waylandEGLInit(params.w, params.h))
|
||||
@@ -119,9 +171,6 @@ static bool waylandInit(const LG_DSInitParams params)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
wlWm.width = params.w;
|
||||
wlWm.height = params.h;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -156,6 +205,28 @@ static bool waylandGetProp(LG_DSProperty prop, void * ret)
|
||||
return false;
|
||||
}
|
||||
|
||||
void waylandNeedsResize(void)
|
||||
{
|
||||
wlWm.needsResize = true;
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
|
||||
static void waylandSetFullscreen(bool fs)
|
||||
{
|
||||
wlWm.desktop->setFullscreen(fs);
|
||||
}
|
||||
|
||||
static bool waylandGetFullscreen(void)
|
||||
{
|
||||
return wlWm.desktop->getFullscreen();
|
||||
}
|
||||
|
||||
static void waylandMinimize(void)
|
||||
{
|
||||
wlWm.desktop->minimize();
|
||||
}
|
||||
|
||||
struct LG_DisplayServerOps LGDS_Wayland =
|
||||
{
|
||||
.name = "Wayland",
|
||||
@@ -192,6 +263,7 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
||||
.uncapturePointer = waylandUncapturePointer,
|
||||
.grabKeyboard = waylandGrabKeyboard,
|
||||
.ungrabKeyboard = waylandUngrabKeyboard,
|
||||
.getCharCode = waylandGetCharCode,
|
||||
.warpPointer = waylandWarpPointer,
|
||||
.realignPointer = waylandRealignPointer,
|
||||
.isValidPointerPos = waylandIsValidPointerPos,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -37,11 +37,10 @@
|
||||
#include "common/countedbuffer.h"
|
||||
#include "common/ringbuffer.h"
|
||||
#include "interface/displayserver.h"
|
||||
#include "interface/desktop.h"
|
||||
|
||||
#include "wayland-xdg-shell-client-protocol.h"
|
||||
#include "wayland-presentation-time-client-protocol.h"
|
||||
#include "wayland-viewporter-client-protocol.h"
|
||||
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||
#include "wayland-keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
|
||||
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
|
||||
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
|
||||
@@ -100,6 +99,8 @@ struct WaylandDSState
|
||||
bool pointerInSurface;
|
||||
bool focusedOnSurface;
|
||||
|
||||
WL_DesktopOps * desktop;
|
||||
|
||||
struct wl_display * display;
|
||||
struct wl_surface * surface;
|
||||
struct wl_registry * registry;
|
||||
@@ -107,13 +108,9 @@ struct WaylandDSState
|
||||
struct wl_shm * shm;
|
||||
struct wl_compositor * compositor;
|
||||
|
||||
int32_t width, height;
|
||||
wl_fixed_t scale;
|
||||
bool fractionalScale;
|
||||
bool needsResize;
|
||||
bool fullscreen;
|
||||
bool floating;
|
||||
uint32_t resizeSerial;
|
||||
bool configured;
|
||||
bool warpSupport;
|
||||
double cursorX, cursorY;
|
||||
@@ -134,17 +131,6 @@ struct WaylandDSState
|
||||
RingBuffer photonTimings;
|
||||
GraphHandle photonGraph;
|
||||
|
||||
#ifdef ENABLE_LIBDECOR
|
||||
struct libdecor * libdecor;
|
||||
struct libdecor_frame * libdecorFrame;
|
||||
#else
|
||||
struct xdg_wm_base * xdgWmBase;
|
||||
struct xdg_surface * xdgSurface;
|
||||
struct xdg_toplevel * xdgToplevel;
|
||||
struct zxdg_decoration_manager_v1 * xdgDecorationManager;
|
||||
struct zxdg_toplevel_decoration_v1 * xdgToplevelDecoration;
|
||||
#endif
|
||||
|
||||
const char * cursorThemeName;
|
||||
int cursorSize;
|
||||
int cursorScale;
|
||||
@@ -291,6 +277,7 @@ void waylandUncapturePointer(void);
|
||||
void waylandRealignPointer(void);
|
||||
void waylandWarpPointer(int x, int y, bool exiting);
|
||||
void waylandGuestPointerUpdated(double x, double y, double localX, double localY);
|
||||
int waylandGetCharCode(int key);
|
||||
|
||||
// output module
|
||||
bool waylandOutputInit(void);
|
||||
@@ -314,16 +301,8 @@ void waylandPresentationFree(void);
|
||||
bool waylandRegistryInit(void);
|
||||
void waylandRegistryFree(void);
|
||||
|
||||
// shell module
|
||||
bool waylandShellInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable);
|
||||
void waylandShellAckConfigureIfNeeded(void);
|
||||
void waylandSetFullscreen(bool fs);
|
||||
bool waylandGetFullscreen(void);
|
||||
void waylandMinimize(void);
|
||||
void waylandShellResize(int w, int h);
|
||||
|
||||
// window module
|
||||
bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable);
|
||||
bool waylandWindowInit(const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable);
|
||||
void waylandWindowFree(void);
|
||||
void waylandWindowUpdateScale(void);
|
||||
void waylandSetWindowSize(int x, int y);
|
||||
@@ -331,3 +310,4 @@ bool waylandIsValidPointerPos(int x, int y);
|
||||
bool waylandWaitFrame(void);
|
||||
void waylandSkipFrame(void);
|
||||
void waylandStopWaitFrame(void);
|
||||
void waylandNeedsResize(void);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -85,7 +85,7 @@ static const struct wl_surface_listener wlSurfaceListener = {
|
||||
.leave = wlSurfaceLeaveHandler,
|
||||
};
|
||||
|
||||
bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless, bool resizable)
|
||||
bool waylandWindowInit(const char * title, const char * appId, bool fullscreen, bool maximize, bool borderless, bool resizable)
|
||||
{
|
||||
wlWm.scale = wl_fixed_from_int(1);
|
||||
|
||||
@@ -112,7 +112,8 @@ bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool
|
||||
|
||||
wl_surface_add_listener(wlWm.surface, &wlSurfaceListener, NULL);
|
||||
|
||||
if (!waylandShellInit(title, fullscreen, maximize, borderless, resizable))
|
||||
if (!wlWm.desktop->shellInit(wlWm.display, wlWm.surface,
|
||||
title, appId, fullscreen, maximize, borderless, resizable))
|
||||
return false;
|
||||
|
||||
wl_surface_commit(wlWm.surface);
|
||||
@@ -127,12 +128,14 @@ void waylandWindowFree(void)
|
||||
|
||||
void waylandSetWindowSize(int x, int y)
|
||||
{
|
||||
waylandShellResize(x, y);
|
||||
wlWm.desktop->shellResize(x, y);
|
||||
}
|
||||
|
||||
bool waylandIsValidPointerPos(int x, int y)
|
||||
{
|
||||
return x >= 0 && x < wlWm.width && y >= 0 && y < wlWm.height;
|
||||
int width, height;
|
||||
wlWm.desktop->getSize(&width, &height);
|
||||
return x >= 0 && x < width && y >= 0 && y < height;
|
||||
}
|
||||
|
||||
static void frameHandler(void * opaque, struct wl_callback * callback, unsigned int data)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(displayserver_X11 LANGUAGES C)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -60,40 +60,40 @@ static void x11CBSelectionIncr(const XPropertyEvent e);
|
||||
static void x11CBSelectionNotify(const XSelectionEvent e);
|
||||
static void x11CBXFixesSelectionNotify(const XFixesSelectionNotifyEvent e);
|
||||
|
||||
bool x11CBEventThread(const XEvent xe)
|
||||
bool x11CBEventThread(const XEvent * xe)
|
||||
{
|
||||
switch(xe.type)
|
||||
switch(xe->type)
|
||||
{
|
||||
case SelectionRequest:
|
||||
x11CBSelectionRequest(xe.xselectionrequest);
|
||||
x11CBSelectionRequest(xe->xselectionrequest);
|
||||
return true;
|
||||
|
||||
case SelectionClear:
|
||||
x11CBSelectionClear(xe.xselectionclear);
|
||||
x11CBSelectionClear(xe->xselectionclear);
|
||||
return true;
|
||||
|
||||
case SelectionNotify:
|
||||
x11CBSelectionNotify(xe.xselection);
|
||||
x11CBSelectionNotify(xe->xselection);
|
||||
return true;
|
||||
|
||||
case PropertyNotify:
|
||||
if (xe.xproperty.state != PropertyNewValue)
|
||||
if (xe->xproperty.state != PropertyNewValue)
|
||||
break;
|
||||
|
||||
if (xe.xproperty.atom == x11atoms.SEL_DATA)
|
||||
if (xe->xproperty.atom == x11atoms.SEL_DATA)
|
||||
{
|
||||
if (x11cb.lowerBound == 0)
|
||||
return true;
|
||||
|
||||
x11CBSelectionIncr(xe.xproperty);
|
||||
x11CBSelectionIncr(xe->xproperty);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (xe.type == x11.eventBase + XFixesSelectionNotify)
|
||||
if (xe->type == x11.eventBase + XFixesSelectionNotify)
|
||||
{
|
||||
XFixesSelectionNotifyEvent * sne = (XFixesSelectionNotifyEvent *)&xe;
|
||||
XFixesSelectionNotifyEvent * sne = (XFixesSelectionNotifyEvent *)xe;
|
||||
x11CBXFixesSelectionNotify(*sne);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "interface/displayserver.h"
|
||||
|
||||
bool x11CBEventThread(const XEvent xe);
|
||||
bool x11CBEventThread(const XEvent * xe);
|
||||
|
||||
bool x11CBInit(void);
|
||||
void x11CBNotice(LG_ClipboardData type);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -71,9 +71,9 @@ static bool wm_i3_init(void)
|
||||
return false;
|
||||
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
char path[sizeof(addr.sun_path)];
|
||||
char * path = (char *)&addr.sun_path;
|
||||
int pathLen;
|
||||
if ((pathLen = fread(path, 1, sizeof(path), fd)) <= 0)
|
||||
if ((pathLen = fread(path, 1, sizeof(addr.sun_path), fd)) <= 0)
|
||||
{
|
||||
pclose(fd);
|
||||
return false;
|
||||
@@ -91,7 +91,6 @@ static bool wm_i3_init(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
|
||||
if (connect(i3.sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
{
|
||||
DEBUG_ERROR("Failed to connect to the i3 IPC socket");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -229,7 +229,7 @@ static void x11CheckEWMHSupport(void)
|
||||
x11.ewmhHasFocusEvent = true;
|
||||
}
|
||||
|
||||
DEBUG_INFO("EWMH-complient window manager detected: %s", wmName);
|
||||
DEBUG_INFO("EWMH-compliant window manager detected: %s", wmName);
|
||||
x11.ewmhSupport = true;
|
||||
|
||||
if (strcmp(wmName, "i3") == 0)
|
||||
@@ -343,7 +343,7 @@ static bool x11Init(const LG_DSInitParams params)
|
||||
XClassHint hint =
|
||||
{
|
||||
.res_name = strdup(params.title),
|
||||
.res_class = strdup("looking-glass-client")
|
||||
.res_class = strdup(params.appId)
|
||||
};
|
||||
XSetClassHint(x11.display, x11.window, &hint);
|
||||
free(hint.res_name);
|
||||
@@ -699,7 +699,7 @@ static bool x11Init(const LG_DSInitParams params)
|
||||
XMoveWindow(x11.display, x11.window, params.x, params.y);
|
||||
|
||||
if (params.fullscreen)
|
||||
x11SetFullscreen(true);
|
||||
x11.doFullscreenOnExpose = true;
|
||||
|
||||
XSetLocaleModifiers(""); // Load XMODIFIERS
|
||||
x11.xim = XOpenIM(x11.display, 0, 0, 0);
|
||||
@@ -897,7 +897,7 @@ static int x11EventThread(void * unused)
|
||||
XNextEvent(x11.display, &xe);
|
||||
|
||||
// call the clipboard handling code
|
||||
if (x11CBEventThread(xe))
|
||||
if (x11CBEventThread(&xe))
|
||||
continue;
|
||||
|
||||
switch(xe.type)
|
||||
@@ -946,6 +946,11 @@ static int x11EventThread(void * unused)
|
||||
{
|
||||
atomic_store(&x11.lastWMEvent, microtime());
|
||||
x11.invalidateAll = true;
|
||||
if (x11.doFullscreenOnExpose)
|
||||
{
|
||||
x11SetFullscreen(true);
|
||||
x11.doFullscreenOnExpose = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1082,8 +1087,9 @@ static void setFocus(bool focused, double x, double y)
|
||||
app_handleFocusEvent(focused);
|
||||
}
|
||||
|
||||
static int getCharcode(int detail)
|
||||
static int x11GetCharCode(int detail)
|
||||
{
|
||||
detail += x11.minKeycode;
|
||||
if (detail < x11.minKeycode || detail > x11.maxKeycode)
|
||||
return 0;
|
||||
|
||||
@@ -1224,8 +1230,7 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIDeviceEvent *device = cookie->data;
|
||||
app_handleKeyPress(device->detail - x11.minKeycode,
|
||||
getCharcode(device->detail));
|
||||
app_handleKeyPress(device->detail - x11.minKeycode);
|
||||
|
||||
if (!x11.xic || !app_isOverlayMode())
|
||||
return;
|
||||
@@ -1275,8 +1280,7 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIDeviceEvent *device = cookie->data;
|
||||
app_handleKeyRelease(device->detail - x11.minKeycode,
|
||||
getCharcode(device->detail));
|
||||
app_handleKeyRelease(device->detail - x11.minKeycode);
|
||||
|
||||
if (!x11.xic || !app_isOverlayMode())
|
||||
return;
|
||||
@@ -1305,8 +1309,7 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIRawEvent *raw = cookie->data;
|
||||
app_handleKeyPress(raw->detail - x11.minKeycode,
|
||||
getCharcode(raw->detail));
|
||||
app_handleKeyPress(raw->detail - x11.minKeycode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1316,8 +1319,7 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIRawEvent *raw = cookie->data;
|
||||
app_handleKeyRelease(raw->detail - x11.minKeycode,
|
||||
getCharcode(raw->detail));
|
||||
app_handleKeyRelease(raw->detail - x11.minKeycode);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2012,6 +2014,7 @@ struct LG_DisplayServerOps LGDS_X11 =
|
||||
.ungrabPointer = x11UngrabPointer,
|
||||
.capturePointer = x11CapturePointer,
|
||||
.uncapturePointer = x11UncapturePointer,
|
||||
.getCharCode = x11GetCharCode,
|
||||
.grabKeyboard = x11GrabKeyboard,
|
||||
.ungrabKeyboard = x11UngrabKeyboard,
|
||||
.warpPointer = x11WarpPointer,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -71,6 +71,7 @@ struct X11DSState
|
||||
|
||||
_Atomic(uint64_t) lastWMEvent;
|
||||
bool invalidateAll;
|
||||
bool doFullscreenOnExpose;
|
||||
|
||||
int xpresentOp;
|
||||
bool jitRender;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -59,8 +59,8 @@ void app_handleButtonPress(int button);
|
||||
void app_handleButtonRelease(int button);
|
||||
void app_handleWheelMotion(double motion);
|
||||
void app_handleKeyboardTyped(const char * typed);
|
||||
void app_handleKeyPress(int scancode, int charcode);
|
||||
void app_handleKeyRelease(int scancode, int charcode);
|
||||
void app_handleKeyPress(int scancode);
|
||||
void app_handleKeyRelease(int scancode);
|
||||
void app_handleKeyboardModifiers(bool ctrl, bool shift, bool alt, bool super);
|
||||
void app_handleKeyboardLEDs(bool numLock, bool capsLock, bool scrollLock);
|
||||
void app_handleEnterEvent(bool entered);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
51
client/include/evdev.h
Normal file
51
client/include/evdev.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* initialize configuration options
|
||||
*/
|
||||
void evdev_earlyInit(void);
|
||||
|
||||
/**
|
||||
* start the evdev layer
|
||||
*/
|
||||
bool evdev_start(void);
|
||||
|
||||
/**
|
||||
* stop the evdev layer
|
||||
*/
|
||||
void evdev_stop(void);
|
||||
|
||||
/**
|
||||
* grab the keyboard for exclusive access
|
||||
*/
|
||||
void evdev_grabKeyboard(void);
|
||||
|
||||
/**
|
||||
* ungrab the keyboard
|
||||
*/
|
||||
void evdev_ungrabKeyboard(void);
|
||||
|
||||
/**
|
||||
* returns true if input should only be processed by evdev
|
||||
*/
|
||||
bool evdev_isExclusive(void);
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -84,6 +84,7 @@ LG_DSPointer;
|
||||
typedef struct LG_DSInitParams
|
||||
{
|
||||
const char * title;
|
||||
const char * appId;
|
||||
int x, y, w, h;
|
||||
bool center;
|
||||
bool fullscreen;
|
||||
@@ -182,6 +183,9 @@ struct LG_DisplayServerOps
|
||||
void (*capturePointer)(void);
|
||||
void (*uncapturePointer)(void);
|
||||
|
||||
/* get the character code for the provided scancode */
|
||||
int (*getCharCode)(int sc);
|
||||
|
||||
/* exiting = true if the warp is to leave the window */
|
||||
void (*warpPointer)(int x, int y, bool exiting);
|
||||
|
||||
@@ -252,6 +256,7 @@ struct LG_DisplayServerOps
|
||||
DEBUG_ASSERT((x)->ungrabPointer ); \
|
||||
DEBUG_ASSERT((x)->capturePointer ); \
|
||||
DEBUG_ASSERT((x)->uncapturePointer ); \
|
||||
DEBUG_ASSERT((x)->getCharCode ); \
|
||||
DEBUG_ASSERT((x)->warpPointer ); \
|
||||
DEBUG_ASSERT((x)->realignPointer ); \
|
||||
DEBUG_ASSERT((x)->isValidPointerPos ); \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -76,6 +76,8 @@ typedef struct LG_RendererFormat
|
||||
bool hdrPQ; // if the HDR content is PQ mapped
|
||||
unsigned int screenWidth; // actual width of the host
|
||||
unsigned int screenHeight; // actual height of the host
|
||||
unsigned int dataWidth; // the width of the packed data
|
||||
unsigned int dataHeight; // the height of the packed data
|
||||
unsigned int frameWidth; // width of frame transmitted
|
||||
unsigned int frameHeight; // height of frame transmitted
|
||||
unsigned int stride; // scanline width (zero if compresed)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(renderers LANGUAGES C)
|
||||
|
||||
set(RENDERER_H "${CMAKE_BINARY_DIR}/include/dynamic/renderers.h")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(renderer_EGL LANGUAGES C CXX)
|
||||
|
||||
find_package(PkgConfig)
|
||||
@@ -56,6 +56,7 @@ build_shaders(
|
||||
shader/damage.vert
|
||||
shader/damage.frag
|
||||
shader/basic.vert
|
||||
shader/convert_24bit.frag
|
||||
shader/ffx_cas.frag
|
||||
shader/ffx_fsr1_easu.frag
|
||||
shader/ffx_fsr1_rcas.frag
|
||||
@@ -87,6 +88,7 @@ add_library(renderer_EGL STATIC
|
||||
postprocess.c
|
||||
ffx.c
|
||||
filter.c
|
||||
filter_24bit.c
|
||||
filter_ffx_cas.c
|
||||
filter_ffx_fsr1.c
|
||||
filter_downscale.c
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -100,7 +100,7 @@ static bool cursorTexInit(struct CursorTex * t,
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(t->shader,
|
||||
vertex_code, vertex_size, fragment_code, fragment_size, false))
|
||||
vertex_code, vertex_size, fragment_code, fragment_size, false, NULL))
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the cursor shader");
|
||||
return false;
|
||||
@@ -277,7 +277,7 @@ struct CursorState egl_cursorRender(EGL_Cursor * cursor,
|
||||
}
|
||||
|
||||
egl_textureSetup(cursor->mono.texture, EGL_PF_BGRA,
|
||||
cursor->width, cursor->height, sizeof(xor[0]));
|
||||
cursor->width, cursor->height, cursor->width, sizeof(xor[0]));
|
||||
egl_textureUpdate(cursor->mono.texture, (uint8_t *)xor, true);
|
||||
}
|
||||
// fall through
|
||||
@@ -285,7 +285,7 @@ struct CursorState egl_cursorRender(EGL_Cursor * cursor,
|
||||
case LG_CURSOR_COLOR:
|
||||
{
|
||||
egl_textureSetup(cursor->norm.texture, EGL_PF_BGRA,
|
||||
cursor->width, cursor->height, cursor->stride);
|
||||
cursor->width, cursor->height, cursor->width, cursor->stride);
|
||||
egl_textureUpdate(cursor->norm.texture, data, true);
|
||||
break;
|
||||
}
|
||||
@@ -311,9 +311,9 @@ struct CursorState egl_cursorRender(EGL_Cursor * cursor,
|
||||
}
|
||||
|
||||
egl_textureSetup(cursor->norm.texture, EGL_PF_BGRA,
|
||||
cursor->width, cursor->height, sizeof(and[0]));
|
||||
cursor->width, cursor->height, cursor->width, sizeof(and[0]));
|
||||
egl_textureSetup(cursor->mono.texture, EGL_PF_BGRA,
|
||||
cursor->width, cursor->height, sizeof(xor[0]));
|
||||
cursor->width, cursor->height, cursor->width, sizeof(xor[0]));
|
||||
egl_textureUpdate(cursor->norm.texture, (uint8_t *)and, true);
|
||||
egl_textureUpdate(cursor->mono.texture, (uint8_t *)xor, true);
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -77,7 +77,7 @@ bool egl_damageInit(EGL_Damage ** damage)
|
||||
if (!egl_shaderCompile((*damage)->shader,
|
||||
b_shader_damage_vert, b_shader_damage_vert_size,
|
||||
b_shader_damage_frag, b_shader_damage_frag_size,
|
||||
false))
|
||||
false, NULL))
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the damage shader");
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -114,13 +114,13 @@ static bool egl_initDesktopShader(
|
||||
if (!egl_shaderCompile(shader->shader,
|
||||
vertex_code , vertex_size,
|
||||
fragment_code, fragment_size,
|
||||
useDMA))
|
||||
useDMA, NULL))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
shader->uTransform = egl_shaderGetUniform(shader->shader, "transform" );
|
||||
shader->uDesktopSize = egl_shaderGetUniform(shader->shader, "desktopSize" );
|
||||
shader->uTransform = egl_shaderGetUniform(shader->shader, "transform" );
|
||||
shader->uScaleAlgo = egl_shaderGetUniform(shader->shader, "scaleAlgo" );
|
||||
shader->uNVGain = egl_shaderGetUniform(shader->shader, "nvGain" );
|
||||
shader->uCBMode = egl_shaderGetUniform(shader->shader, "cbMode" );
|
||||
@@ -206,6 +206,9 @@ bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop_, EGLDisplay * display,
|
||||
return false;
|
||||
}
|
||||
|
||||
// this MUST be first
|
||||
egl_postProcessAdd(desktop->pp, &egl_filter24bitOps);
|
||||
|
||||
egl_postProcessAdd(desktop->pp, &egl_filterDownscaleOps);
|
||||
egl_postProcessAdd(desktop->pp, &egl_filterFFXCASOps );
|
||||
egl_postProcessAdd(desktop->pp, &egl_filterFFXFSR1Ops );
|
||||
@@ -337,6 +340,14 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
|
||||
pixFmt = EGL_PF_RGBA16F;
|
||||
break;
|
||||
|
||||
case FRAME_TYPE_BGR_32:
|
||||
pixFmt = EGL_PF_BGR_32;
|
||||
break;
|
||||
|
||||
case FRAME_TYPE_RGB_24:
|
||||
pixFmt = EGL_PF_RGB_24;
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG_ERROR("Unsupported frame format");
|
||||
return false;
|
||||
@@ -350,9 +361,10 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
|
||||
if (!egl_textureSetup(
|
||||
desktop->texture,
|
||||
pixFmt,
|
||||
format.frameWidth,
|
||||
format.frameHeight,
|
||||
format.pitch
|
||||
desktop->format.dataWidth,
|
||||
desktop->format.dataHeight,
|
||||
desktop->format.stride,
|
||||
desktop->format.pitch
|
||||
))
|
||||
{
|
||||
DEBUG_ERROR("Failed to setup the desktop texture");
|
||||
@@ -365,9 +377,9 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
|
||||
bool egl_desktopUpdate(EGL_Desktop * desktop, const FrameBuffer * frame, int dmaFd,
|
||||
const FrameDamageRect * damageRects, int damageRectsCount)
|
||||
{
|
||||
if (desktop->useDMA && dmaFd >= 0)
|
||||
if (likely(desktop->useDMA && dmaFd >= 0))
|
||||
{
|
||||
if (egl_textureUpdateFromDMA(desktop->texture, frame, dmaFd))
|
||||
if (likely(egl_textureUpdateFromDMA(desktop->texture, frame, dmaFd)))
|
||||
{
|
||||
atomic_store(&desktop->processFrame, true);
|
||||
return true;
|
||||
@@ -403,8 +415,8 @@ bool egl_desktopUpdate(EGL_Desktop * desktop, const FrameBuffer * frame, int dma
|
||||
return false;
|
||||
}
|
||||
|
||||
if (egl_textureUpdateFromFrame(desktop->texture, frame,
|
||||
damageRects, damageRectsCount))
|
||||
if (likely(egl_textureUpdateFromFrame(desktop->texture, frame,
|
||||
damageRects, damageRectsCount)))
|
||||
{
|
||||
atomic_store(&desktop->processFrame, true);
|
||||
return true;
|
||||
@@ -425,25 +437,28 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
||||
{
|
||||
EGL_Texture * tex;
|
||||
int width, height;
|
||||
bool dma;
|
||||
|
||||
if (desktop->useSpice)
|
||||
if (unlikely(desktop->useSpice))
|
||||
{
|
||||
tex = desktop->spiceTexture;
|
||||
width = desktop->spiceWidth;
|
||||
height = desktop->spiceHeight;
|
||||
dma = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tex = desktop->texture;
|
||||
width = desktop->width;
|
||||
height = desktop->height;
|
||||
dma = desktop->useDMA;
|
||||
}
|
||||
|
||||
if (outputWidth == 0 && outputHeight == 0)
|
||||
if (unlikely(outputWidth == 0 || outputHeight == 0))
|
||||
DEBUG_FATAL("outputWidth || outputHeight == 0");
|
||||
|
||||
enum EGL_TexStatus status;
|
||||
if ((status = egl_textureProcess(tex)) != EGL_TEX_STATUS_OK)
|
||||
if (unlikely((status = egl_textureProcess(tex)) != EGL_TEX_STATUS_OK))
|
||||
{
|
||||
if (status != EGL_TEX_STATUS_NOTREADY)
|
||||
DEBUG_ERROR("Failed to process the desktop texture");
|
||||
@@ -458,12 +473,19 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
||||
if (atomic_exchange(&desktop->processFrame, false) ||
|
||||
egl_postProcessConfigModified(desktop->pp))
|
||||
egl_postProcessRun(desktop->pp, tex, desktop->mesh,
|
||||
width, height, outputWidth, outputHeight, desktop->useDMA);
|
||||
width, height, outputWidth, outputHeight, dma);
|
||||
|
||||
unsigned int finalSizeX, finalSizeY;
|
||||
EGL_Texture * texture = egl_postProcessGetOutput(desktop->pp,
|
||||
&finalSizeX, &finalSizeY);
|
||||
|
||||
if (unlikely(!texture))
|
||||
{
|
||||
texture = tex;
|
||||
finalSizeX = width;
|
||||
finalSizeY = height;
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
egl_resetViewport(desktop->egl);
|
||||
|
||||
@@ -498,7 +520,7 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
||||
&desktop->dmaShader : &desktop->shader;
|
||||
|
||||
const float mapHDRGain =
|
||||
desktop->maxCLL / desktop->peakLuminance;
|
||||
(float)desktop->maxCLL / desktop->peakLuminance;
|
||||
|
||||
EGL_Uniform uniforms[] =
|
||||
{
|
||||
@@ -572,6 +594,7 @@ void egl_desktopSpiceConfigure(EGL_Desktop * desktop, int width, int height)
|
||||
EGL_PF_BGRA,
|
||||
width,
|
||||
height,
|
||||
width,
|
||||
width * 4
|
||||
))
|
||||
{
|
||||
@@ -593,9 +616,9 @@ void egl_desktopSpiceDrawFill(EGL_Desktop * desktop, int x, int y, int width,
|
||||
for(int x = 0; x < width; ++x)
|
||||
line[x] = color;
|
||||
|
||||
for(; y < height; ++y)
|
||||
for(int dy = 0; dy < height; ++dy)
|
||||
egl_textureUpdateRect(desktop->spiceTexture,
|
||||
x, y, width, 1, sizeof(line), (uint8_t *)line, false);
|
||||
x, y + dy, width, 1, width, sizeof(line), (uint8_t *)line, false);
|
||||
|
||||
atomic_store(&desktop->processFrame, true);
|
||||
}
|
||||
@@ -604,11 +627,12 @@ void egl_desktopSpiceDrawBitmap(EGL_Desktop * desktop, int x, int y, int width,
|
||||
int height, int stride, uint8_t * data, bool topDown)
|
||||
{
|
||||
egl_textureUpdateRect(desktop->spiceTexture,
|
||||
x, y, width, height, stride, data, topDown);
|
||||
x, y, width, height, width, stride, data, topDown);
|
||||
atomic_store(&desktop->processFrame, true);
|
||||
}
|
||||
|
||||
void egl_desktopSpiceShow(EGL_Desktop * desktop, bool show)
|
||||
{
|
||||
desktop->useSpice = show;
|
||||
atomic_store(&desktop->processFrame, true);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -296,7 +296,7 @@ bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6]
|
||||
|
||||
void egl_desktopRectsRender(EGL_DesktopRects * rects)
|
||||
{
|
||||
if (!rects->count)
|
||||
if (unlikely(!rects->count))
|
||||
return;
|
||||
|
||||
glBindVertexArray(rects->vao);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "interface/renderer.h"
|
||||
|
||||
#include "common/util.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/KVMFR.h"
|
||||
#include "common/option.h"
|
||||
@@ -580,7 +581,7 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
|
||||
this->formatValid = true;
|
||||
|
||||
/* this event runs in a second thread so we need to init it here */
|
||||
if (!this->frameContext)
|
||||
if (unlikely(!this->frameContext))
|
||||
{
|
||||
static EGLint attrs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
@@ -600,7 +601,7 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
|
||||
}
|
||||
}
|
||||
|
||||
if (this->scalePointer)
|
||||
if (likely(this->scalePointer))
|
||||
{
|
||||
float scale = max(1.0f, (float)format.screenWidth / this->width);
|
||||
egl_cursorSetScale(this->cursor, scale);
|
||||
@@ -623,7 +624,8 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int d
|
||||
struct Inst * this = UPCAST(struct Inst, renderer);
|
||||
|
||||
uint64_t start = nanotime();
|
||||
if (!egl_desktopUpdate(this->desktop, frame, dmaFd, damageRects, damageRectsCount))
|
||||
if (unlikely(!egl_desktopUpdate(
|
||||
this->desktop, frame, dmaFd, damageRects, damageRectsCount)))
|
||||
{
|
||||
DEBUG_INFO("Failed to to update the desktop");
|
||||
return false;
|
||||
@@ -632,12 +634,17 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame, int d
|
||||
|
||||
INTERLOCKED_SECTION(this->desktopDamageLock, {
|
||||
struct DesktopDamage * damage = this->desktopDamage + this->desktopDamageIdx;
|
||||
if (damage->count == -1 || damageRectsCount == 0 ||
|
||||
damage->count + damageRectsCount >= KVMFR_MAX_DAMAGE_RECTS)
|
||||
if (unlikely(
|
||||
damage->count == -1 ||
|
||||
damageRectsCount == 0 ||
|
||||
damage->count + damageRectsCount >= KVMFR_MAX_DAMAGE_RECTS))
|
||||
{
|
||||
damage->count = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(damage->rects + damage->count, damageRects, damageRectsCount * sizeof(FrameDamageRect));
|
||||
memcpy(damage->rects + damage->count, damageRects,
|
||||
damageRectsCount * sizeof(FrameDamageRect));
|
||||
damage->count += damageRectsCount;
|
||||
}
|
||||
});
|
||||
@@ -1056,14 +1063,14 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
|
||||
accumulated->count = 0;
|
||||
|
||||
INTERLOCKED_SECTION(this->desktopDamageLock, {
|
||||
if (!renderAll)
|
||||
if (likely(!renderAll))
|
||||
{
|
||||
for (int i = 0; i < bufferAge; ++i)
|
||||
{
|
||||
struct DesktopDamage * damage = this->desktopDamage +
|
||||
IDX_AGO(this->desktopDamageIdx, i, DESKTOP_DAMAGE_COUNT);
|
||||
|
||||
if (damage->count < 0)
|
||||
if (unlikely(damage->count < 0))
|
||||
{
|
||||
renderAll = true;
|
||||
break;
|
||||
@@ -1087,7 +1094,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
|
||||
this->desktopDamage[this->desktopDamageIdx].count = 0;
|
||||
});
|
||||
|
||||
if (!renderAll)
|
||||
if (likely(!renderAll))
|
||||
{
|
||||
double matrix[6];
|
||||
egl_screenToDesktopMatrix(matrix,
|
||||
@@ -1101,7 +1108,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
|
||||
int count = this->overlayHistoryCount[idx];
|
||||
struct Rect * damage = this->overlayHistory[idx];
|
||||
|
||||
if (count < 0)
|
||||
if (unlikely(count < 0))
|
||||
{
|
||||
renderAll = true;
|
||||
break;
|
||||
@@ -1114,11 +1121,12 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
|
||||
);
|
||||
}
|
||||
|
||||
accumulated->count = rectsMergeOverlapping(accumulated->rects, accumulated->count);
|
||||
accumulated->count = rectsMergeOverlapping(accumulated->rects,
|
||||
accumulated->count);
|
||||
}
|
||||
++this->overlayHistoryIdx;
|
||||
|
||||
if (this->destRect.w > 0 && this->destRect.h > 0)
|
||||
if (likely(this->destRect.w > 0 && this->destRect.h > 0))
|
||||
{
|
||||
if (egl_desktopRender(this->desktop,
|
||||
this->destRect.w, this->destRect.h,
|
||||
@@ -1136,41 +1144,39 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
|
||||
|
||||
renderLetterBox(this);
|
||||
|
||||
hasOverlay |= egl_damageRender(this->damage, rotate, newFrame ? desktopDamage : NULL);
|
||||
hasOverlay |= invalidateWindow;
|
||||
hasOverlay |=
|
||||
egl_damageRender(this->damage, rotate, newFrame ? desktopDamage : NULL) |
|
||||
invalidateWindow;
|
||||
|
||||
struct Rect damage[KVMFR_MAX_DAMAGE_RECTS + MAX_OVERLAY_RECTS + 2];
|
||||
int damageIdx = app_renderOverlay(damage, MAX_OVERLAY_RECTS);
|
||||
|
||||
switch (damageIdx)
|
||||
if (unlikely(damageIdx != 0))
|
||||
{
|
||||
case 0: // no overlay
|
||||
break;
|
||||
case -1: // full damage
|
||||
if (damageIdx == -1)
|
||||
hasOverlay = true;
|
||||
// fallthrough
|
||||
default:
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||
|
||||
for (int i = 0; i < damageIdx; ++i)
|
||||
damage[i].y = this->height - damage[i].y - damage[i].h;
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
|
||||
|
||||
for (int i = 0; i < damageIdx; ++i)
|
||||
damage[i].y = this->height - damage[i].y - damage[i].h;
|
||||
}
|
||||
|
||||
if (damageIdx >= 0 && cursorState.visible)
|
||||
if (likely(damageIdx >= 0 && cursorState.visible))
|
||||
damage[damageIdx++] = cursorState.rect;
|
||||
|
||||
int overlayHistoryIdx = this->overlayHistoryIdx % DESKTOP_DAMAGE_COUNT;
|
||||
if (hasOverlay)
|
||||
if (unlikely(hasOverlay))
|
||||
this->overlayHistoryCount[overlayHistoryIdx] = -1;
|
||||
else
|
||||
{
|
||||
if (damageIdx > 0)
|
||||
memcpy(this->overlayHistory[overlayHistoryIdx], damage, damageIdx * sizeof(struct Rect));
|
||||
if (unlikely(damageIdx > 0))
|
||||
memcpy(this->overlayHistory[overlayHistoryIdx],
|
||||
damage, damageIdx * sizeof(struct Rect));
|
||||
this->overlayHistoryCount[overlayHistoryIdx] = damageIdx;
|
||||
}
|
||||
|
||||
if (!hasOverlay && !this->hadOverlay)
|
||||
if (unlikely(!hasOverlay && !this->hadOverlay))
|
||||
{
|
||||
if (this->cursorLast.visible)
|
||||
damage[damageIdx++] = this->cursorLast.rect;
|
||||
@@ -1197,7 +1203,9 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
|
||||
this->cursorLast = cursorState;
|
||||
|
||||
preSwap(udata);
|
||||
app_eglSwapBuffers(this->display, this->surface, damage, this->noSwapDamage ? 0 : damageIdx);
|
||||
app_eglSwapBuffers(this->display, this->surface, damage,
|
||||
this->noSwapDamage ? 0 : damageIdx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -37,7 +37,10 @@ typedef enum EGL_PixelFormat
|
||||
EGL_PF_RGBA,
|
||||
EGL_PF_BGRA,
|
||||
EGL_PF_RGBA10,
|
||||
EGL_PF_RGBA16F
|
||||
EGL_PF_RGBA16F,
|
||||
EGL_PF_BGR_32,
|
||||
EGL_PF_RGB_24,
|
||||
EGL_PF_RGB_24_32
|
||||
}
|
||||
EGL_PixelFormat;
|
||||
|
||||
@@ -60,13 +63,17 @@ typedef struct EGL_TexSetup
|
||||
/* the height of the texture in pixels */
|
||||
size_t height;
|
||||
|
||||
/* the stide of the texture in bytes */
|
||||
/* the row length of the texture in pixels */
|
||||
size_t stride;
|
||||
|
||||
/* the row length of the texture in bytes */
|
||||
size_t pitch;
|
||||
}
|
||||
EGL_TexSetup;
|
||||
|
||||
typedef enum EGL_FilterType
|
||||
{
|
||||
EGL_FILTER_TYPE_INTERNAL,
|
||||
EGL_FILTER_TYPE_EFFECT,
|
||||
EGL_FILTER_TYPE_UPSCALE,
|
||||
EGL_FILTER_TYPE_DOWNSCALE
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -72,16 +72,17 @@ typedef struct EGL_FilterOps
|
||||
* useDMA will be true if the texture provided needs to use samplerExternalOES
|
||||
*/
|
||||
bool (*setup)(EGL_Filter * filter, enum EGL_PixelFormat pixFmt,
|
||||
unsigned int width, unsigned int height, bool useDMA);
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int desktopWidth, unsigned int desktopHeight, bool useDMA);
|
||||
|
||||
/* set the output resolution hint for the filter
|
||||
* this is optional and only a hint */
|
||||
void (*setOutputResHint)(EGL_Filter * filter,
|
||||
unsigned int x, unsigned int y);
|
||||
|
||||
/* returns the output resolution of the filter */
|
||||
/* returns the output resolution and pixel format of the filter */
|
||||
void (*getOutputRes)(EGL_Filter * filter,
|
||||
unsigned int *x, unsigned int *y);
|
||||
unsigned int *x, unsigned int *y, enum EGL_PixelFormat *pixFmt);
|
||||
|
||||
/* prepare the shader for use
|
||||
* A filter can return false to bypass it */
|
||||
@@ -104,6 +105,12 @@ typedef struct EGL_Filter
|
||||
}
|
||||
EGL_Filter;
|
||||
|
||||
static inline void egl_filterEarlyInit(const EGL_FilterOps * ops)
|
||||
{
|
||||
if (ops->earlyInit)
|
||||
ops->earlyInit();
|
||||
}
|
||||
|
||||
static inline bool egl_filterInit(const EGL_FilterOps * ops, EGL_Filter ** filter)
|
||||
{
|
||||
if (!ops->init(filter))
|
||||
@@ -121,24 +128,30 @@ static inline void egl_filterFree(EGL_Filter ** filter)
|
||||
|
||||
static inline bool egl_filterImguiConfig(EGL_Filter * filter)
|
||||
{
|
||||
return filter->ops.imguiConfig(filter);
|
||||
if (filter->ops.imguiConfig)
|
||||
return filter->ops.imguiConfig(filter);
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void egl_filterSaveState(EGL_Filter * filter)
|
||||
{
|
||||
filter->ops.saveState(filter);
|
||||
if (filter->ops.saveState)
|
||||
filter->ops.saveState(filter);
|
||||
}
|
||||
|
||||
static inline void egl_filterLoadState(EGL_Filter * filter)
|
||||
{
|
||||
filter->ops.loadState(filter);
|
||||
if (filter->ops.loadState)
|
||||
filter->ops.loadState(filter);
|
||||
}
|
||||
|
||||
static inline bool egl_filterSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
unsigned int desktopWidth, unsigned int desktopHeight,
|
||||
bool useDMA)
|
||||
{
|
||||
return filter->ops.setup(filter, pixFmt, width, height, useDMA);
|
||||
return filter->ops.setup(filter, pixFmt, width, height,
|
||||
desktopWidth, desktopHeight, useDMA);
|
||||
}
|
||||
|
||||
static inline void egl_filterSetOutputResHint(EGL_Filter * filter,
|
||||
@@ -149,9 +162,9 @@ static inline void egl_filterSetOutputResHint(EGL_Filter * filter,
|
||||
}
|
||||
|
||||
static inline void egl_filterGetOutputRes(EGL_Filter * filter,
|
||||
unsigned int *x, unsigned int *y)
|
||||
unsigned int *x, unsigned int *y, enum EGL_PixelFormat *pixFmt)
|
||||
{
|
||||
return filter->ops.getOutputRes(filter, x, y);
|
||||
return filter->ops.getOutputRes(filter, x, y, pixFmt);
|
||||
}
|
||||
|
||||
static inline bool egl_filterPrepare(EGL_Filter * filter)
|
||||
|
||||
221
client/renderers/EGL/filter_24bit.c
Normal file
221
client/renderers/EGL/filter_24bit.c
Normal file
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "filter.h"
|
||||
#include "framebuffer.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "common/array.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/option.h"
|
||||
#include "cimgui.h"
|
||||
|
||||
#include "basic.vert.h"
|
||||
#include "convert_24bit.frag.h"
|
||||
|
||||
|
||||
typedef struct EGL_Filter24bit
|
||||
{
|
||||
EGL_Filter base;
|
||||
|
||||
bool enable;
|
||||
EGL_PixelFormat format;
|
||||
int useDMA;
|
||||
unsigned int width, height;
|
||||
unsigned int desktopWidth, desktopHeight;
|
||||
bool prepared;
|
||||
|
||||
EGL_Uniform uOutputSize;
|
||||
|
||||
EGL_Shader * shader;
|
||||
EGL_Framebuffer * fb;
|
||||
GLuint sampler[2];
|
||||
}
|
||||
EGL_Filter24bit;
|
||||
|
||||
static bool egl_filter24bitInit(EGL_Filter ** filter)
|
||||
{
|
||||
EGL_Filter24bit * this = calloc(1, sizeof(*this));
|
||||
if (!this)
|
||||
{
|
||||
DEBUG_ERROR("Failed to allocate ram");
|
||||
return false;
|
||||
}
|
||||
|
||||
this->useDMA = -1;
|
||||
|
||||
if (!egl_shaderInit(&this->shader))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the shader");
|
||||
goto error_this;
|
||||
}
|
||||
|
||||
if (!egl_framebufferInit(&this->fb))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the framebuffer");
|
||||
goto error_shader;
|
||||
}
|
||||
|
||||
glGenSamplers(ARRAY_LENGTH(this->sampler), this->sampler);
|
||||
glSamplerParameteri(this->sampler[0], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(this->sampler[0], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glSamplerParameteri(this->sampler[0], GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(this->sampler[0], GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(this->sampler[1], GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(this->sampler[1], GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(this->sampler[1], GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(this->sampler[1], GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE);
|
||||
|
||||
*filter = &this->base;
|
||||
return true;
|
||||
|
||||
error_shader:
|
||||
egl_shaderFree(&this->shader);
|
||||
|
||||
error_this:
|
||||
free(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void egl_filter24bitFree(EGL_Filter * filter)
|
||||
{
|
||||
EGL_Filter24bit * this = UPCAST(EGL_Filter24bit, filter);
|
||||
|
||||
egl_shaderFree(&this->shader);
|
||||
egl_framebufferFree(&this->fb);
|
||||
glDeleteSamplers(ARRAY_LENGTH(this->sampler), this->sampler);
|
||||
free(this);
|
||||
}
|
||||
|
||||
static bool egl_filter24bitSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
unsigned int desktopWidth, unsigned int desktopHeight,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_Filter24bit * this = UPCAST(EGL_Filter24bit, filter);
|
||||
|
||||
if (pixFmt != EGL_PF_BGR_32 && pixFmt != EGL_PF_RGB_24_32)
|
||||
return false;
|
||||
|
||||
if (this->useDMA != useDMA || this->format != pixFmt)
|
||||
{
|
||||
EGL_ShaderDefine defines[] =
|
||||
{
|
||||
{"OUTPUT", pixFmt == EGL_PF_BGR_32 ? "fragColor.bgra" : "fragColor.rgba" },
|
||||
{0}
|
||||
};
|
||||
|
||||
if (!egl_shaderCompile(this->shader,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_convert_24bit_frag, b_shader_convert_24bit_frag_size,
|
||||
useDMA, defines)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
this->uOutputSize.type = EGL_UNIFORM_TYPE_2F;
|
||||
this->uOutputSize.location =
|
||||
egl_shaderGetUniform(this->shader, "outputSize");
|
||||
|
||||
this->useDMA = useDMA;
|
||||
this->prepared = false;
|
||||
}
|
||||
|
||||
if (this->prepared &&
|
||||
this->width == width &&
|
||||
this->height == height &&
|
||||
this->desktopWidth == desktopWidth &&
|
||||
this->desktopHeight == desktopHeight)
|
||||
return true;
|
||||
|
||||
if (!egl_framebufferSetup(this->fb, EGL_PF_BGRA, desktopWidth, desktopHeight))
|
||||
return false;
|
||||
|
||||
this->format = pixFmt;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->desktopWidth = desktopWidth;
|
||||
this->desktopHeight = desktopHeight;
|
||||
this->prepared = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void egl_filter24bitGetOutputRes(EGL_Filter * filter,
|
||||
unsigned int *width, unsigned int *height, enum EGL_PixelFormat *pixFmt)
|
||||
{
|
||||
EGL_Filter24bit * this = UPCAST(EGL_Filter24bit, filter);
|
||||
*width = this->desktopWidth;
|
||||
*height = this->desktopHeight;
|
||||
*pixFmt = EGL_PF_BGRA;
|
||||
}
|
||||
|
||||
static bool egl_filter24bitPrepare(EGL_Filter * filter)
|
||||
{
|
||||
EGL_Filter24bit * this = UPCAST(EGL_Filter24bit, filter);
|
||||
|
||||
if (this->prepared)
|
||||
return true;
|
||||
|
||||
this->uOutputSize.f[0] = this->desktopWidth;
|
||||
this->uOutputSize.f[1] = this->desktopHeight;
|
||||
egl_shaderSetUniforms(this->shader, &this->uOutputSize, 1);
|
||||
|
||||
this->prepared = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static EGL_Texture * egl_filter24bitRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, EGL_Texture * texture)
|
||||
{
|
||||
EGL_Filter24bit * this = UPCAST(EGL_Filter24bit, filter);
|
||||
|
||||
egl_framebufferBind(this->fb);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
egl_textureBind(texture);
|
||||
|
||||
glBindSampler(0, this->sampler[0]);
|
||||
|
||||
egl_shaderUse(this->shader);
|
||||
egl_filterRectsRender(this->shader, rects);
|
||||
|
||||
return egl_framebufferGetTexture(this->fb);
|
||||
}
|
||||
|
||||
EGL_FilterOps egl_filter24bitOps =
|
||||
{
|
||||
.id = "24bit",
|
||||
.name = "24bit",
|
||||
.type = EGL_FILTER_TYPE_INTERNAL,
|
||||
.earlyInit = NULL,
|
||||
.init = egl_filter24bitInit,
|
||||
.free = egl_filter24bitFree,
|
||||
.imguiConfig = NULL,
|
||||
.saveState = NULL,
|
||||
.loadState = NULL,
|
||||
.setup = egl_filter24bitSetup,
|
||||
.getOutputRes = egl_filter24bitGetOutputRes,
|
||||
.prepare = egl_filter24bitPrepare,
|
||||
.run = egl_filter24bitRun
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -299,6 +299,7 @@ static bool egl_filterDownscaleImguiConfig(EGL_Filter * filter)
|
||||
|
||||
static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
unsigned int desktopWidth, unsigned int desktopHeight,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_FilterDownscale * this = UPCAST(EGL_FilterDownscale, filter);
|
||||
@@ -315,7 +316,7 @@ static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_downscale_frag,
|
||||
b_shader_downscale_frag_size,
|
||||
useDMA)
|
||||
useDMA, NULL)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
@@ -326,7 +327,7 @@ static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
b_shader_basic_vert, b_shader_basic_vert_size,
|
||||
b_shader_downscale_linear_frag,
|
||||
b_shader_downscale_linear_frag_size,
|
||||
useDMA)
|
||||
useDMA, NULL)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
@@ -337,7 +338,7 @@ static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
b_shader_basic_vert, b_shader_basic_vert_size,
|
||||
b_shader_downscale_lanczos2_frag,
|
||||
b_shader_downscale_lanczos2_frag_size,
|
||||
useDMA)
|
||||
useDMA, NULL)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
@@ -369,11 +370,12 @@ static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
}
|
||||
|
||||
static void egl_filterDownscaleGetOutputRes(EGL_Filter * filter,
|
||||
unsigned int *width, unsigned int *height)
|
||||
unsigned int *width, unsigned int *height, enum EGL_PixelFormat *pixFmt)
|
||||
{
|
||||
EGL_FilterDownscale * this = UPCAST(EGL_FilterDownscale, filter);
|
||||
*width = this->width;
|
||||
*height = this->height;
|
||||
*pixFmt = this->pixFmt;
|
||||
}
|
||||
|
||||
static bool egl_filterDownscalePrepare(EGL_Filter * filter)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -209,6 +209,7 @@ static bool egl_filterFFXCASImguiConfig(EGL_Filter * filter)
|
||||
|
||||
static bool egl_filterFFXCASSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
unsigned int desktopWidth, unsigned int desktopHeight,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
|
||||
@@ -221,7 +222,7 @@ static bool egl_filterFFXCASSetup(EGL_Filter * filter,
|
||||
if (!egl_shaderCompile(this->shader,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_cas_frag, b_shader_ffx_cas_frag_size,
|
||||
useDMA)
|
||||
useDMA, NULL)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
@@ -253,11 +254,12 @@ static bool egl_filterFFXCASSetup(EGL_Filter * filter,
|
||||
}
|
||||
|
||||
static void egl_filterFFXCASGetOutputRes(EGL_Filter * filter,
|
||||
unsigned int *width, unsigned int *height)
|
||||
unsigned int *width, unsigned int *height, enum EGL_PixelFormat *pixFmt)
|
||||
{
|
||||
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
|
||||
*width = this->width;
|
||||
*height = this->height;
|
||||
*pixFmt = this->pixFmt;
|
||||
}
|
||||
|
||||
static bool egl_filterFFXCASPrepare(EGL_Filter * filter)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -127,7 +127,7 @@ static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
|
||||
if (!egl_shaderCompile(this->rcas,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_fsr1_rcas_frag, b_shader_ffx_fsr1_rcas_frag_size,
|
||||
false)
|
||||
false, NULL)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the Rcas shader");
|
||||
@@ -323,6 +323,7 @@ static void egl_filterFFXFSR1SetOutputResHint(EGL_Filter * filter,
|
||||
|
||||
static bool egl_filterFFXFSR1Setup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
unsigned int desktopWidth, unsigned int desktopHeight,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_FilterFFXFSR1 * this = UPCAST(EGL_FilterFFXFSR1, filter);
|
||||
@@ -335,7 +336,7 @@ static bool egl_filterFFXFSR1Setup(EGL_Filter * filter,
|
||||
if (!egl_shaderCompile(this->easu,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_fsr1_easu_frag, b_shader_ffx_fsr1_easu_frag_size,
|
||||
useDMA)
|
||||
useDMA, NULL)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the Easu shader");
|
||||
@@ -382,11 +383,12 @@ static bool egl_filterFFXFSR1Setup(EGL_Filter * filter,
|
||||
}
|
||||
|
||||
static void egl_filterFFXFSR1GetOutputRes(EGL_Filter * filter,
|
||||
unsigned int *width, unsigned int *height)
|
||||
unsigned int *width, unsigned int *height, enum EGL_PixelFormat *pixFmt)
|
||||
{
|
||||
EGL_FilterFFXFSR1 * this = UPCAST(EGL_FilterFFXFSR1, filter);
|
||||
*width = this->width;
|
||||
*height = this->height;
|
||||
*pixFmt = this->pixFmt;
|
||||
}
|
||||
|
||||
static bool egl_filterFFXFSR1Prepare(EGL_Filter * filter)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
extern EGL_FilterOps egl_filter24bitOps;
|
||||
extern EGL_FilterOps egl_filterDownscaleOps;
|
||||
extern EGL_FilterOps egl_filterFFXCASOps;
|
||||
extern EGL_FilterOps egl_filterFFXFSR1Ops;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -43,6 +43,7 @@ bool egl_framebufferInit(EGL_Framebuffer ** fb)
|
||||
if (!egl_textureInit(&this->tex, NULL, EGL_TEXTYPE_BUFFER))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the texture");
|
||||
free(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -64,14 +65,14 @@ void egl_framebufferFree(EGL_Framebuffer ** fb)
|
||||
bool egl_framebufferSetup(EGL_Framebuffer * this, enum EGL_PixelFormat pixFmt,
|
||||
unsigned int width, unsigned int height)
|
||||
{
|
||||
if (!egl_textureSetup(this->tex, pixFmt, width, height, 0))
|
||||
if (!egl_textureSetup(this->tex, pixFmt, width, height, 0, 0))
|
||||
{
|
||||
DEBUG_ERROR("Failed to setup the texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
GLuint tex;
|
||||
egl_textureGet(this->tex, &tex, NULL, NULL);
|
||||
egl_textureGet(this->tex, &tex, NULL, NULL, NULL);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -48,7 +48,7 @@ static const EGL_FilterOps * EGL_Filters[] =
|
||||
|
||||
struct EGL_PostProcess
|
||||
{
|
||||
Vector filters;
|
||||
Vector filters, internalFilters;
|
||||
EGL_Texture * output;
|
||||
unsigned int outputX, outputY;
|
||||
_Atomic(bool) modified;
|
||||
@@ -85,7 +85,7 @@ void egl_postProcessEarlyInit(void)
|
||||
option_register(options);
|
||||
|
||||
for (int i = 0; i < ARRAY_LENGTH(EGL_Filters); ++i)
|
||||
EGL_Filters[i]->earlyInit();
|
||||
egl_filterEarlyInit(EGL_Filters[i]);
|
||||
}
|
||||
|
||||
static void loadPreset(struct EGL_PostProcess * this, const char * name);
|
||||
@@ -464,7 +464,8 @@ static void configUI(void * opaque, int * id)
|
||||
static size_t mouseIdx = -1;
|
||||
static bool moving = false;
|
||||
static size_t moveIdx = 0;
|
||||
bool doMove = false;
|
||||
|
||||
bool doMove = false;
|
||||
|
||||
ImVec2 window, pos;
|
||||
igGetWindowPos(&window);
|
||||
@@ -518,9 +519,16 @@ static void configUI(void * opaque, int * id)
|
||||
{
|
||||
EGL_Filter * tmp = filters[moveIdx];
|
||||
if (mouseIdx > moveIdx) // moving down
|
||||
memmove(filters + moveIdx, filters + moveIdx + 1, (mouseIdx - moveIdx) * sizeof(EGL_Filter *));
|
||||
memmove(
|
||||
filters + moveIdx,
|
||||
filters + moveIdx + 1,
|
||||
(mouseIdx - moveIdx) * sizeof(EGL_Filter *));
|
||||
else // moving up
|
||||
memmove(filters + mouseIdx + 1, filters + mouseIdx, (moveIdx - mouseIdx) * sizeof(EGL_Filter *));
|
||||
memmove(
|
||||
filters + mouseIdx + 1,
|
||||
filters + mouseIdx,
|
||||
(moveIdx - mouseIdx) * sizeof(EGL_Filter *));
|
||||
|
||||
filters[mouseIdx] = tmp;
|
||||
}
|
||||
|
||||
@@ -540,16 +548,24 @@ bool egl_postProcessInit(EGL_PostProcess ** pp)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!vector_create(&this->filters, sizeof(EGL_Filter *), ARRAY_LENGTH(EGL_Filters)))
|
||||
if (!vector_create(&this->filters,
|
||||
sizeof(EGL_Filter *), ARRAY_LENGTH(EGL_Filters)))
|
||||
{
|
||||
DEBUG_ERROR("Failed to allocate the filter list");
|
||||
goto error_this;
|
||||
}
|
||||
|
||||
if (!vector_create(&this->internalFilters,
|
||||
sizeof(EGL_Filter *), ARRAY_LENGTH(EGL_Filters)))
|
||||
{
|
||||
DEBUG_ERROR("Failed to allocate the filter list");
|
||||
goto error_filters;
|
||||
}
|
||||
|
||||
if (!egl_desktopRectsInit(&this->rects, 1))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the desktop rects");
|
||||
goto error_filters;
|
||||
goto error_internal;
|
||||
}
|
||||
|
||||
loadPresetList(this);
|
||||
@@ -559,6 +575,9 @@ bool egl_postProcessInit(EGL_PostProcess ** pp)
|
||||
*pp = this;
|
||||
return true;
|
||||
|
||||
error_internal:
|
||||
vector_destroy(&this->internalFilters);
|
||||
|
||||
error_filters:
|
||||
vector_destroy(&this->filters);
|
||||
|
||||
@@ -579,6 +598,10 @@ void egl_postProcessFree(EGL_PostProcess ** pp)
|
||||
egl_filterFree(filter);
|
||||
vector_destroy(&this->filters);
|
||||
|
||||
vector_forEachRef(filter, &this->internalFilters)
|
||||
egl_filterFree(filter);
|
||||
vector_destroy(&this->internalFilters);
|
||||
|
||||
free(this->presetDir);
|
||||
if (this->presets)
|
||||
stringlist_free(&this->presets);
|
||||
@@ -595,7 +618,10 @@ bool egl_postProcessAdd(EGL_PostProcess * this, const EGL_FilterOps * ops)
|
||||
if (!egl_filterInit(ops, &filter))
|
||||
return false;
|
||||
|
||||
vector_push(&this->filters, &filter);
|
||||
if (ops->type == EGL_FILTER_TYPE_INTERNAL)
|
||||
vector_push(&this->internalFilters, &filter);
|
||||
else
|
||||
vector_push(&this->filters, &filter);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -616,7 +642,9 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
|
||||
//TODO: clean this up
|
||||
GLuint _unused;
|
||||
if (egl_textureGet(tex, &_unused, &sizeX, &sizeY) != EGL_TEX_STATUS_OK)
|
||||
EGL_PixelFormat pixFmt;
|
||||
if (egl_textureGet(tex, &_unused,
|
||||
&sizeX, &sizeY, &pixFmt) != EGL_TEX_STATUS_OK)
|
||||
return false;
|
||||
|
||||
if (atomic_exchange(&this->modified, false))
|
||||
@@ -638,25 +666,35 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
|
||||
EGL_Filter * filter;
|
||||
EGL_Texture * texture = tex;
|
||||
vector_forEach(filter, &this->filters)
|
||||
|
||||
const Vector * lists[] =
|
||||
{
|
||||
egl_filterSetOutputResHint(filter, targetX, targetY);
|
||||
&this->internalFilters,
|
||||
&this->filters,
|
||||
NULL
|
||||
};
|
||||
|
||||
if (!egl_filterSetup(filter, tex->format.pixFmt, sizeX, sizeY, useDMA) ||
|
||||
!egl_filterPrepare(filter))
|
||||
continue;
|
||||
for(const Vector ** filters = lists; *filters; ++filters)
|
||||
vector_forEach(filter, *filters)
|
||||
{
|
||||
egl_filterSetOutputResHint(filter, targetX, targetY);
|
||||
|
||||
texture = egl_filterRun(filter, &filterRects, texture);
|
||||
egl_filterGetOutputRes(filter, &sizeX, &sizeY);
|
||||
if (!egl_filterSetup(filter, pixFmt, sizeX, sizeY,
|
||||
desktopWidth, desktopHeight, useDMA) ||
|
||||
!egl_filterPrepare(filter))
|
||||
continue;
|
||||
|
||||
if (lastFilter)
|
||||
egl_filterRelease(lastFilter);
|
||||
texture = egl_filterRun(filter, &filterRects, texture);
|
||||
egl_filterGetOutputRes(filter, &sizeX, &sizeY, &pixFmt);
|
||||
|
||||
lastFilter = filter;
|
||||
if (lastFilter)
|
||||
egl_filterRelease(lastFilter);
|
||||
|
||||
// the first filter to run will convert to a normal texture
|
||||
useDMA = false;
|
||||
}
|
||||
lastFilter = filter;
|
||||
|
||||
// the first filter to run will convert to a normal texture
|
||||
useDMA = false;
|
||||
}
|
||||
|
||||
this->output = texture;
|
||||
this->outputX = sizeX;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "shader.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/stringutils.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -65,7 +66,8 @@ void egl_shaderFree(EGL_Shader ** shader)
|
||||
}
|
||||
|
||||
bool egl_shaderLoad(EGL_Shader * this,
|
||||
const char * vertex_file, const char * fragment_file, bool useDMA)
|
||||
const char * vertex_file, const char * fragment_file, bool useDMA,
|
||||
const EGL_ShaderDefine * defines)
|
||||
{
|
||||
char * vertex_code, * fragment_code;
|
||||
size_t vertex_size, fragment_size;
|
||||
@@ -89,7 +91,7 @@ bool egl_shaderLoad(EGL_Shader * this,
|
||||
|
||||
bool ret = egl_shaderCompile(this,
|
||||
vertex_code, vertex_size, fragment_code, fragment_size,
|
||||
useDMA);
|
||||
useDMA, defines);
|
||||
|
||||
free(vertex_code);
|
||||
free(fragment_code);
|
||||
@@ -210,30 +212,39 @@ static bool shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
|
||||
bool egl_shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
size_t vertex_size, const char * fragment_code, size_t fragment_size,
|
||||
bool useDMA)
|
||||
bool useDMA, const EGL_ShaderDefine * defines)
|
||||
{
|
||||
bool result = false;
|
||||
char * processed = NULL;
|
||||
char * newCode = NULL;
|
||||
|
||||
if (useDMA)
|
||||
{
|
||||
const char * search = "sampler2D";
|
||||
const char * replace = "samplerExternalOES";
|
||||
const char search[] = "sampler2D";
|
||||
const char replace[] = "samplerExternalOES";
|
||||
|
||||
const char * src = fragment_code;
|
||||
const char * offset = NULL;
|
||||
int instances = 0;
|
||||
while((src = strstr(src, search)))
|
||||
|
||||
while((offset = memsearch(
|
||||
fragment_code, fragment_size,
|
||||
search , sizeof(search)-1,
|
||||
offset)))
|
||||
{
|
||||
++instances;
|
||||
src += strlen(search);
|
||||
offset += sizeof(search)-1;
|
||||
}
|
||||
|
||||
const int diff = (strlen(replace) - strlen(search)) * instances;
|
||||
char * newCode = malloc(fragment_size + diff + 1);
|
||||
const int diff = (sizeof(replace) - sizeof(search)) * instances;
|
||||
const int newLen = fragment_size + diff;
|
||||
newCode = malloc(newLen + 1);
|
||||
if (!newCode)
|
||||
{
|
||||
DEBUG_ERROR("Out of memory");
|
||||
return false;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
src = fragment_code;
|
||||
const char * src = fragment_code;
|
||||
char * dst = newCode;
|
||||
for(int i = 0; i < instances; ++i)
|
||||
{
|
||||
@@ -242,28 +253,104 @@ bool egl_shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
|
||||
memcpy(dst, src, offset);
|
||||
dst += offset;
|
||||
src = pos + strlen(search);
|
||||
src = pos + sizeof(search)-1;
|
||||
|
||||
memcpy(dst, replace, strlen(replace));
|
||||
dst += strlen(replace);
|
||||
memcpy(dst, replace, sizeof(replace)-1);
|
||||
dst += sizeof(replace)-1;
|
||||
}
|
||||
|
||||
const int final = fragment_size - (src - fragment_code);
|
||||
memcpy(dst, src, final);
|
||||
dst[final] = 0;
|
||||
dst[final] = '\0';
|
||||
|
||||
bool result = shaderCompile(
|
||||
this,
|
||||
vertex_code, vertex_size,
|
||||
newCode , fragment_size + diff);
|
||||
|
||||
free(newCode);
|
||||
return result;
|
||||
fragment_code = newCode;
|
||||
fragment_size = newLen;
|
||||
}
|
||||
|
||||
return shaderCompile(this,
|
||||
if (defines)
|
||||
{
|
||||
// find the end of any existing lines starting with #
|
||||
bool newLine = true;
|
||||
bool skip = false;
|
||||
int insertPos = 0;
|
||||
for(int i = 0; i < fragment_size; ++i)
|
||||
{
|
||||
if (skip)
|
||||
{
|
||||
if (fragment_code[i] == '\n')
|
||||
skip = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(fragment_code[i])
|
||||
{
|
||||
case '\n':
|
||||
newLine = true;
|
||||
continue;
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
continue;
|
||||
|
||||
case '#':
|
||||
if (newLine)
|
||||
{
|
||||
skip = true;
|
||||
continue;
|
||||
}
|
||||
//fallthrough
|
||||
|
||||
default:
|
||||
newLine = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!newLine)
|
||||
{
|
||||
insertPos = i;
|
||||
if (insertPos > 0)
|
||||
--insertPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int processedLen = fragment_size;
|
||||
const char * defineFormat = "#define %s %s\n";
|
||||
for(const EGL_ShaderDefine * define = defines; define->name; ++define)
|
||||
processedLen += snprintf(NULL, 0, defineFormat, define->name, define->value);
|
||||
|
||||
processed = malloc(processedLen);
|
||||
if (!processed)
|
||||
{
|
||||
DEBUG_ERROR("Out of memory");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
memcpy(processed, fragment_code, insertPos);
|
||||
|
||||
int offset = insertPos;
|
||||
for(const EGL_ShaderDefine * define = defines; define->name; ++define)
|
||||
offset += sprintf(processed + offset, defineFormat,
|
||||
define->name, define->value);
|
||||
|
||||
memcpy(
|
||||
processed + offset,
|
||||
fragment_code + insertPos,
|
||||
fragment_size - insertPos);
|
||||
|
||||
fragment_code = processed;
|
||||
fragment_size = processedLen;
|
||||
}
|
||||
|
||||
result = shaderCompile(this,
|
||||
vertex_code , vertex_size,
|
||||
fragment_code, fragment_size);
|
||||
|
||||
exit:
|
||||
free(processed);
|
||||
free(newCode);
|
||||
return result;
|
||||
}
|
||||
|
||||
void egl_shaderSetUniforms(EGL_Shader * this, EGL_Uniform * uniforms, int count)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2023 The Looking Glass Authors
|
||||
* Copyright © 2017-2025 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -93,15 +93,22 @@ typedef struct EGL_Uniform
|
||||
}
|
||||
EGL_Uniform;
|
||||
|
||||
typedef struct EGL_ShaderDefine
|
||||
{
|
||||
const char * name;
|
||||
const char * value;
|
||||
}
|
||||
EGL_ShaderDefine;
|
||||
|
||||
bool egl_shaderInit(EGL_Shader ** shader);
|
||||
void egl_shaderFree(EGL_Shader ** shader);
|
||||
|
||||
bool egl_shaderLoad(EGL_Shader * model, const char * vertex_file,
|
||||
const char * fragment_file, bool useDMA);
|
||||
const char * fragment_file, bool useDMA, const EGL_ShaderDefine * defines);
|
||||
|
||||
bool egl_shaderCompile(EGL_Shader * model, const char * vertex_code,
|
||||
size_t vertex_size, const char * fragment_code, size_t fragment_size,
|
||||
bool useDMA);
|
||||
bool useDMA, const EGL_ShaderDefine * defines);
|
||||
|
||||
void egl_shaderSetUniforms(EGL_Shader * shader, EGL_Uniform * uniforms,
|
||||
int count);
|
||||
|
||||
33
client/renderers/EGL/shader/convert_24bit.frag
Normal file
33
client/renderers/EGL/shader/convert_24bit.frag
Normal file
@@ -0,0 +1,33 @@
|
||||
#version 300 es
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D sampler1;
|
||||
uniform vec2 outputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
uvec2 inputSize = uvec2(textureSize(sampler1, 0));
|
||||
uvec2 outputPos = uvec2(fragCoord * outputSize);
|
||||
|
||||
uint fst = outputPos.x * 3u / 4u;
|
||||
vec4 color_0 = texelFetch(sampler1, ivec2(fst, outputPos.y), 0);
|
||||
|
||||
uint snd = (outputPos.x * 3u + 1u) / 4u;
|
||||
vec4 color_1 = texelFetch(sampler1, ivec2(snd, outputPos.y), 0);
|
||||
|
||||
uint trd = (outputPos.x * 3u + 2u) / 4u;
|
||||
vec4 color_2 = texelFetch(sampler1, ivec2(trd, outputPos.y), 0);
|
||||
|
||||
OUTPUT = vec4(
|
||||
color_0.barg[outputPos.x % 4u],
|
||||
color_1.gbar[outputPos.x % 4u],
|
||||
color_2.rgba[outputPos.x % 4u],
|
||||
1.0
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
#include "color_blind.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
#define EGL_SCALE_AUTO 0
|
||||
#define EGL_SCALE_NEAREST 1
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user