mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 23:10:10 +01:00
Compare commits
175 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 70f54a1e1b | |||
|
|
f6c5c659a7 | ||
|
|
c23a0c20a4 | ||
|
|
3bbbb5aaca | ||
|
|
315806f598 | ||
|
|
6175ecd4c4 | ||
| f88deb928a | |||
|
|
18901b8e59 | ||
| 7098558420 | |||
|
|
59438908de | ||
| cbfdbe9fa1 | |||
| c94a981711 | |||
| beb1b578e8 | |||
| c5beecb2c3 | |||
|
|
6e09eb2e6c | ||
|
|
6b491e4d6b | ||
| 4036c37e55 | |||
|
|
7ccc57eb7c | ||
|
|
e4a8f2b14f | ||
|
|
6535ff07c9 | ||
|
|
05ccbb2f2d | ||
| 09e195d1f2 | |||
| fd5e790d08 | |||
|
|
69db0bcae6 | ||
|
|
8dfdcfb353 | ||
|
|
5700736505 | ||
|
|
75f6435f70 | ||
|
|
5dd224805d | ||
| 2ca7ad7efc | |||
| 9aa313402b | |||
|
|
1ff801f5f3 | ||
|
|
3cf6dfd7e6 | ||
|
|
f58c80fd39 | ||
|
|
6712fb954f | ||
| efe665b455 | |||
|
|
920353370b | ||
|
|
834f019bab | ||
| a5b7c91329 | |||
|
|
916e5d1aea | ||
|
|
9584b2d40e | ||
|
|
532ca053d6 | ||
|
|
ca99e8228c | ||
|
|
8ca40479a7 | ||
| c26e91f074 | |||
|
|
76ac655c9e | ||
| f8d5aad1a1 | |||
| b8bb5e9bde | |||
|
|
7797deb935 | ||
| d3c9c54b79 | |||
|
|
cedadf4fdc | ||
|
|
222dbe99d0 | ||
|
|
ebe74be75a | ||
| afeda6cee6 | |||
| 6a1daff5f3 | |||
|
|
016eb7a23d | ||
|
|
ec6756f961 | ||
|
|
9264436f35 | ||
|
|
d5c52ef58e | ||
|
|
52b3c8cbc6 | ||
|
|
279a07c2ce | ||
|
|
17ae3fb704 | ||
|
|
43ed0db3b3 | ||
|
|
38f912c401 | ||
|
|
9cd070fd31 | ||
|
|
d9657a95cb | ||
| 9b1891e476 | |||
|
|
93e5e92b0a | ||
|
|
3cf0280b11 | ||
|
|
2cadc8abab | ||
|
|
f82a8630d7 | ||
|
|
bb963fb002 | ||
|
|
f11cf6f1de | ||
| 574ee71d56 | |||
|
|
7e1e24fea6 | ||
|
|
68eecf61cd | ||
| f9742ab501 | |||
|
|
e42185b83d | ||
|
|
a51918fd27 | ||
|
|
379ee99c68 | ||
|
|
4036e35e73 | ||
|
|
d21f2e5729 | ||
|
|
4e5a284bc4 | ||
|
|
210930bef9 | ||
|
|
40d8fa8491 | ||
|
|
1c1746de61 | ||
|
|
619e9d285b | ||
|
|
ec3b3403e7 | ||
| 703394affb | |||
|
|
fe6a855bbb | ||
|
|
475e87b351 | ||
|
|
3d7ea9c02f | ||
|
|
2b0fd417d3 | ||
|
|
56904edbd2 | ||
|
|
e584a8bade | ||
| 2ac9ded2ac | |||
| abb2f7ee6f | |||
| 79a2781923 | |||
| d66c9222b0 | |||
|
|
b5a2ef77b7 | ||
|
|
c5d45b7653 | ||
|
|
c249a9f4b8 | ||
|
|
00cce1c8ff | ||
| 6b8e3358d6 | |||
|
|
80b96a3166 | ||
|
|
f9d1da6667 | ||
| 7532115318 | |||
|
|
1c29d6b1ba | ||
|
|
d0503bea43 | ||
| fbb31503f1 | |||
|
|
9f02dca8de | ||
|
|
6a8d306992 | ||
| e4b40abce6 | |||
|
|
9495f989b4 | ||
|
|
2c9c4d0905 | ||
| e15409bbeb | |||
|
|
312073ce79 | ||
| edc311544a | |||
| 37fe7b2efd | |||
|
|
c2670e9ab9 | ||
| 95ee08b340 | |||
|
|
ff6d771be0 | ||
| 64e4e913e1 | |||
|
|
ad52ba9c13 | ||
| 526aa1d020 | |||
| 5f0575737f | |||
|
|
4695f85829 | ||
|
|
1796dbcdc3 | ||
|
|
e354066945 | ||
|
|
2b14f27ca8 | ||
| 68c23fbdaf | |||
| 484d87d469 | |||
| cefa63c2af | |||
|
|
9d67511871 | ||
|
|
5265fa3be8 | ||
|
|
dfb4dcd55c | ||
|
|
9d02fe9c23 | ||
|
|
76edcfc66c | ||
|
|
11451d68b7 | ||
| 3534dbdb89 | |||
|
|
6e2fe103bc | ||
|
|
7910bc42af | ||
|
|
0770494ddf | ||
| 49c0c97c5a | |||
| e948445f6e | |||
|
|
7a6177532b | ||
| f0de61ca21 | |||
| c02a6184d3 | |||
| 15b4b1dd91 | |||
| a6b877fec2 | |||
| d2d1613e4f | |||
|
|
c7e14ecd30 | ||
|
|
9321f52e07 | ||
|
|
b04e8e00b0 | ||
|
|
5b373ea9f5 | ||
|
|
d52639fdfa | ||
|
|
e616e595ae | ||
|
|
cb47eb1d11 | ||
|
|
9b006b2c85 | ||
|
|
b35f78431f | ||
|
|
b62ab4b578 | ||
|
|
43527d3634 | ||
|
|
55a93b8a52 | ||
|
|
64ee8f8a72 | ||
| b77cbad502 | |||
|
|
308226a4fc | ||
|
|
ee2168c665 | ||
|
|
c330d4334f | ||
|
|
cadf922417 | ||
|
|
ac8edc6a80 | ||
|
|
b2ea6b010c | ||
| 0b1d690676 | |||
| 2931184921 | |||
|
|
0bd11d5eb9 | ||
|
|
06b37c3907 | ||
| 522edc8712 |
350 changed files with 13873 additions and 8832 deletions
11
.github/actions/setup_base/action.yml
vendored
11
.github/actions/setup_base/action.yml
vendored
|
|
@ -24,6 +24,7 @@ runs:
|
||||||
glm \
|
glm \
|
||||||
glslang \
|
glslang \
|
||||||
go \
|
go \
|
||||||
|
gtest \
|
||||||
hyprlang \
|
hyprlang \
|
||||||
hyprcursor \
|
hyprcursor \
|
||||||
jq \
|
jq \
|
||||||
|
|
@ -45,6 +46,7 @@ runs:
|
||||||
libxkbfile \
|
libxkbfile \
|
||||||
lld \
|
lld \
|
||||||
meson \
|
meson \
|
||||||
|
muparser \
|
||||||
ninja \
|
ninja \
|
||||||
pango \
|
pango \
|
||||||
pixman \
|
pixman \
|
||||||
|
|
@ -74,6 +76,15 @@ runs:
|
||||||
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
|
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
|
||||||
cmake --install build
|
cmake --install build
|
||||||
|
|
||||||
|
- name: Get hyprwire-git
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/hyprwm/hyprwire --recursive
|
||||||
|
cd hyprwire
|
||||||
|
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
|
||||||
|
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
|
||||||
|
cmake --install build
|
||||||
|
|
||||||
- name: Get hyprutils-git
|
- name: Get hyprutils-git
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
4
.github/labeler.yml
vendored
4
.github/labeler.yml
vendored
|
|
@ -22,6 +22,10 @@ protocols:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: ["protocols/**", "src/protocols/**"]
|
- any-glob-to-any-file: ["protocols/**", "src/protocols/**"]
|
||||||
|
|
||||||
|
start:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: "start/**"
|
||||||
|
|
||||||
core:
|
core:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: "src/**"
|
- any-glob-to-any-file: "src/**"
|
||||||
|
|
|
||||||
82
.github/workflows/ci.yaml
vendored
82
.github/workflows/ci.yaml
vendored
|
|
@ -21,7 +21,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build Hyprland
|
- name: Build Hyprland
|
||||||
run: |
|
run: |
|
||||||
CFLAGS=-Werror CXXFLAGS=-Werror make all
|
CFLAGS=-Werror CXXFLAGS=-Werror make nopch
|
||||||
|
|
||||||
- name: Compress and package artifacts
|
- name: Compress and package artifacts
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -41,86 +41,16 @@ jobs:
|
||||||
name: Build archive
|
name: Build archive
|
||||||
path: Hyprland.tar.xz
|
path: Hyprland.tar.xz
|
||||||
|
|
||||||
meson:
|
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
|
||||||
name: "Build Hyprland with Meson (Arch)"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: archlinux
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository actions
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
sparse-checkout: .github/actions
|
|
||||||
|
|
||||||
- name: Setup base
|
|
||||||
uses: ./.github/actions/setup_base
|
|
||||||
|
|
||||||
- name: Configure
|
|
||||||
run: meson setup build -Ddefault_library=static
|
|
||||||
|
|
||||||
- name: Compile
|
|
||||||
run: ninja -C build
|
|
||||||
|
|
||||||
no-pch:
|
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
|
||||||
name: "Build Hyprland without precompiled headers (Arch)"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: archlinux
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository actions
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
sparse-checkout: .github/actions
|
|
||||||
|
|
||||||
- name: Setup base
|
|
||||||
uses: ./.github/actions/setup_base
|
|
||||||
with:
|
|
||||||
INSTALL_XORG_PKGS: true
|
|
||||||
|
|
||||||
- name: Compile
|
|
||||||
run: make nopch
|
|
||||||
|
|
||||||
noxwayland:
|
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
|
||||||
name: "Build Hyprland in pure Wayland (Arch)"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: archlinux
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository actions
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
sparse-checkout: .github/actions
|
|
||||||
|
|
||||||
- name: Setup base
|
|
||||||
uses: ./.github/actions/setup_base
|
|
||||||
|
|
||||||
- name: Configure
|
|
||||||
run: mkdir -p build && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DNO_XWAYLAND:STRING=true -H./ -B./build -G Ninja
|
|
||||||
|
|
||||||
- name: Compile
|
|
||||||
run: make release
|
|
||||||
|
|
||||||
clang-format:
|
clang-format:
|
||||||
permissions: read-all
|
permissions: read-all
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
||||||
name: "Code Style (Arch)"
|
name: "Code Style"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: archlinux
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository actions
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
sparse-checkout: .github/actions
|
|
||||||
|
|
||||||
- name: Setup base
|
|
||||||
uses: ./.github/actions/setup_base
|
|
||||||
|
|
||||||
- name: Configure
|
|
||||||
run: meson setup build -Ddefault_library=static
|
|
||||||
|
|
||||||
- name: clang-format check
|
- name: clang-format check
|
||||||
run: ninja -C build clang-format-check
|
uses: jidicula/clang-format-action@v4.16.0
|
||||||
|
with:
|
||||||
|
exclude-regex: ^subprojects$
|
||||||
|
|
|
||||||
36
.github/workflows/clang-format.yml
vendored
36
.github/workflows/clang-format.yml
vendored
|
|
@ -4,43 +4,23 @@ jobs:
|
||||||
clang-format:
|
clang-format:
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork
|
||||||
name: "Code Style (Arch)"
|
name: "Code Style"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: archlinux
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository actions
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
sparse-checkout: .github/actions
|
|
||||||
|
|
||||||
- name: Setup base
|
|
||||||
uses: ./.github/actions/setup_base
|
|
||||||
|
|
||||||
- name: Configure
|
|
||||||
run: meson setup build -Ddefault_library=static
|
|
||||||
|
|
||||||
- name: clang-format check
|
- name: clang-format check
|
||||||
run: ninja -C build clang-format-check
|
uses: jidicula/clang-format-action@v4.16.0
|
||||||
|
with:
|
||||||
|
exclude-regex: ^subprojects$
|
||||||
|
|
||||||
- name: clang-format apply
|
- name: Create comment
|
||||||
if: ${{ failure() && github.event_name == 'pull_request' }}
|
|
||||||
run: ninja -C build clang-format
|
|
||||||
|
|
||||||
- name: Create patch
|
|
||||||
if: ${{ failure() && github.event_name == 'pull_request' }}
|
if: ${{ failure() && github.event_name == 'pull_request' }}
|
||||||
run: |
|
run: |
|
||||||
echo 'Please fix the formatting issues by running [`clang-format`](https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/#code-style), or directly apply this patch:' > clang-format.patch
|
echo 'Please fix the formatting issues by running [`clang-format`](https://wiki.hyprland.org/Contributing-and-Debugging/PR-Guidelines/#code-style).' > clang-format.patch
|
||||||
echo '<details>' >> clang-format.patch
|
|
||||||
echo '<summary>clang-format.patch</summary>' >> clang-format.patch
|
|
||||||
echo >> clang-format.patch
|
|
||||||
echo '```diff' >> clang-format.patch
|
|
||||||
git diff >> clang-format.patch
|
|
||||||
echo '```' >> clang-format.patch
|
|
||||||
echo >> clang-format.patch
|
|
||||||
echo '</details>' >> clang-format.patch
|
|
||||||
|
|
||||||
- name: Comment patch
|
- name: Post comment
|
||||||
if: ${{ failure() && github.event_name == 'pull_request' }}
|
if: ${{ failure() && github.event_name == 'pull_request' }}
|
||||||
uses: mshick/add-pr-comment@v2
|
uses: mshick/add-pr-comment@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
45
.github/workflows/new-pr-comment.yml
vendored
Normal file
45
.github/workflows/new-pr-comment.yml
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
name: "New MR welcome comment"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
comment:
|
||||||
|
if: >
|
||||||
|
github.event.pull_request.user.login != 'vaxerski' &&
|
||||||
|
github.event.pull_request.user.login != 'fufexan' &&
|
||||||
|
github.event.pull_request.user.login != 'gulafaran' &&
|
||||||
|
github.event.pull_request.user.login != 'ujint34' &&
|
||||||
|
github.event.pull_request.user.login != 'paideiadilemma' &&
|
||||||
|
github.event.pull_request.user.login != 'notashelf'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
PR_COMMENT: |
|
||||||
|
Hello and thank you for making a PR to Hyprland!
|
||||||
|
|
||||||
|
Please check the [PR Guidelines](https://wiki.hypr.land/Contributing-and-Debugging/PR-Guidelines/) and make sure your PR follows them.
|
||||||
|
It will make the entire review process faster. :)
|
||||||
|
|
||||||
|
If your code can be tested, please always add tests. See more [here](https://wiki.hypr.land/Contributing-and-Debugging/Tests/).
|
||||||
|
|
||||||
|
_beep boop, I'm just a bot. A real human will review your PR soon._
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Add comment to PR
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
const pr = context.payload.pull_request;
|
||||||
|
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: pr.number,
|
||||||
|
body: process.env.PR_COMMENT,
|
||||||
|
});
|
||||||
1
.github/workflows/nix-ci.yml
vendored
1
.github/workflows/nix-ci.yml
vendored
|
|
@ -25,6 +25,5 @@ jobs:
|
||||||
|
|
||||||
test:
|
test:
|
||||||
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
|
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
|
||||||
needs: hyprland
|
|
||||||
uses: ./.github/workflows/nix-test.yml
|
uses: ./.github/workflows/nix-test.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
|
||||||
16
.github/workflows/nix-test.yml
vendored
16
.github/workflows/nix-test.yml
vendored
|
|
@ -20,25 +20,13 @@ jobs:
|
||||||
- name: Restore and save Nix store
|
- name: Restore and save Nix store
|
||||||
uses: nix-community/cache-nix-action@v6
|
uses: nix-community/cache-nix-action@v6
|
||||||
with:
|
with:
|
||||||
# restore and save a cache using this key
|
# restore and save a cache using this key (per job)
|
||||||
primary-key: nix-${{ runner.os }}
|
primary-key: nix-${{ runner.os }}-${{ github.job }}
|
||||||
# if there's no cache hit, restore a cache by this prefix
|
# if there's no cache hit, restore a cache by this prefix
|
||||||
restore-prefixes-first-match: nix-${{ runner.os }}
|
restore-prefixes-first-match: nix-${{ runner.os }}
|
||||||
# collect garbage until the Nix store size (in bytes) is at most this number
|
# collect garbage until the Nix store size (in bytes) is at most this number
|
||||||
# before trying to save a new cache
|
# before trying to save a new cache
|
||||||
# 1G = 1073741824
|
|
||||||
gc-max-store-size-linux: 5G
|
gc-max-store-size-linux: 5G
|
||||||
# do purge caches
|
|
||||||
purge: true
|
|
||||||
# purge all versions of the cache
|
|
||||||
purge-prefixes: nix-${{ runner.os }}
|
|
||||||
# created more than this number of seconds ago
|
|
||||||
purge-created: 0
|
|
||||||
# or, last accessed more than this number of seconds ago
|
|
||||||
# relative to the start of the `Post Restore and save Nix store` phase
|
|
||||||
purge-last-accessed: 0
|
|
||||||
# except any version with the key that is the same as the `primary-key`
|
|
||||||
purge-primary-key: never
|
|
||||||
|
|
||||||
- uses: cachix/cachix-action@v15
|
- uses: cachix/cachix-action@v15
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
20
.github/workflows/nix-update-inputs.yml
vendored
20
.github/workflows/nix-update-inputs.yml
vendored
|
|
@ -27,25 +27,13 @@ jobs:
|
||||||
- name: Restore and save Nix store
|
- name: Restore and save Nix store
|
||||||
uses: nix-community/cache-nix-action@v6
|
uses: nix-community/cache-nix-action@v6
|
||||||
with:
|
with:
|
||||||
# restore and save a cache using this key
|
# restore and save a cache using this key (per job)
|
||||||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
|
primary-key: nix-${{ runner.os }}-${{ github.job }}
|
||||||
# if there's no cache hit, restore a cache by this prefix
|
# if there's no cache hit, restore a cache by this prefix
|
||||||
restore-prefixes-first-match: nix-${{ runner.os }}-
|
restore-prefixes-first-match: nix-${{ runner.os }}
|
||||||
# collect garbage until the Nix store size (in bytes) is at most this number
|
# collect garbage until the Nix store size (in bytes) is at most this number
|
||||||
# before trying to save a new cache
|
# before trying to save a new cache
|
||||||
# 1G = 1073741824
|
gc-max-store-size-linux: 5G
|
||||||
gc-max-store-size-linux: 1G
|
|
||||||
# do purge caches
|
|
||||||
purge: true
|
|
||||||
# purge all versions of the cache
|
|
||||||
purge-prefixes: nix-${{ runner.os }}-
|
|
||||||
# created more than this number of seconds ago
|
|
||||||
purge-created: 0
|
|
||||||
# or, last accessed more than this number of seconds ago
|
|
||||||
# relative to the start of the `Post Restore and save Nix store` phase
|
|
||||||
purge-last-accessed: 0
|
|
||||||
# except any version with the key that is the same as the `primary-key`
|
|
||||||
purge-primary-key: never
|
|
||||||
|
|
||||||
- name: Update inputs
|
- name: Update inputs
|
||||||
run: nix/update-inputs.sh
|
run: nix/update-inputs.sh
|
||||||
|
|
|
||||||
16
.github/workflows/nix.yml
vendored
16
.github/workflows/nix.yml
vendored
|
|
@ -25,25 +25,13 @@ jobs:
|
||||||
- name: Restore and save Nix store
|
- name: Restore and save Nix store
|
||||||
uses: nix-community/cache-nix-action@v6
|
uses: nix-community/cache-nix-action@v6
|
||||||
with:
|
with:
|
||||||
# restore and save a cache using this key
|
# restore and save a cache using this key (per job)
|
||||||
primary-key: nix-${{ runner.os }}
|
primary-key: nix-${{ runner.os }}-${{ github.job }}
|
||||||
# if there's no cache hit, restore a cache by this prefix
|
# if there's no cache hit, restore a cache by this prefix
|
||||||
restore-prefixes-first-match: nix-${{ runner.os }}
|
restore-prefixes-first-match: nix-${{ runner.os }}
|
||||||
# collect garbage until the Nix store size (in bytes) is at most this number
|
# collect garbage until the Nix store size (in bytes) is at most this number
|
||||||
# before trying to save a new cache
|
# before trying to save a new cache
|
||||||
# 1G = 1073741824
|
|
||||||
gc-max-store-size-linux: 5G
|
gc-max-store-size-linux: 5G
|
||||||
# do purge caches
|
|
||||||
purge: true
|
|
||||||
# purge all versions of the cache
|
|
||||||
purge-prefixes: nix-${{ runner.os }}
|
|
||||||
# created more than this number of seconds ago
|
|
||||||
purge-created: 0
|
|
||||||
# or, last accessed more than this number of seconds ago
|
|
||||||
# relative to the start of the `Post Restore and save Nix store` phase
|
|
||||||
purge-last-accessed: 0
|
|
||||||
# except any version with the key that is the same as the `primary-key`
|
|
||||||
purge-primary-key: never
|
|
||||||
|
|
||||||
- uses: cachix/cachix-action@v15
|
- uses: cachix/cachix-action@v15
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
139
.github/workflows/translation-ai-check.yml
vendored
Normal file
139
.github/workflows/translation-ai-check.yml
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
name: AI Translation Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
# pull_request_target:
|
||||||
|
# types:
|
||||||
|
# - opened
|
||||||
|
issue_comment:
|
||||||
|
types:
|
||||||
|
- created
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
review:
|
||||||
|
name: Review Translation
|
||||||
|
if: ${{ github.event_name == 'pull_request_target' || (github.event_name == 'issue_comment' && github.event.action == 'created' && github.event.issue.pull_request != null && github.event.comment.user.login == 'vaxerski' && github.event.comment.body == 'ai, please recheck' ) }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
OPENAI_MODEL: gpt-5-mini
|
||||||
|
SYSTEM_PROMPT: |
|
||||||
|
You are a programmer and a translator. Your job is to review the attached patch for adding translation to a piece of software and make sure the submitted translation is not malicious, and that it makes sense. If the translation is not malicious, and doesn't contain obvious grammatical mistakes, say "Translation check OK". Otherwise, say "Translation check not ok" and list bad entries.
|
||||||
|
Examples of bad translations include obvious trolling (slurs, etc) or nonsense sentences. Meaningful improvements may be suggested, but if there are only minor improvements, just reply with "Translation check OK". Do not provide anything but the result and (if applicable) the bad entries or improvements.
|
||||||
|
|
||||||
|
AI_PROMPT: Translation patch below.
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout source code
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- uses: dorny/paths-filter@v3
|
||||||
|
id: changes
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
i18n:
|
||||||
|
- 'src/i18n/**'
|
||||||
|
|
||||||
|
- name: Stop if i18n not changed
|
||||||
|
if: steps.changes.outputs.i18n != 'true'
|
||||||
|
run: echo "No i18n changes in this PR; skipping." && exit 0
|
||||||
|
|
||||||
|
- name: Determine PR number
|
||||||
|
id: pr
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "pull_request_target" ]; then
|
||||||
|
echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Download combined PR diff
|
||||||
|
id: get_diff
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||||
|
run: |
|
||||||
|
# Get the combined diff for the entire PR
|
||||||
|
curl -sSL \
|
||||||
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
|
-H "Accept: application/vnd.github.v3.diff" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
|
||||||
|
-o pr.diff
|
||||||
|
|
||||||
|
# Compute character length
|
||||||
|
LEN=$(wc -c < pr.diff | tr -d ' ')
|
||||||
|
echo "len=$LEN" >> "$GITHUB_OUTPUT"
|
||||||
|
if [ "$LEN" -gt 25000 ]; then
|
||||||
|
echo "too_long=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "too_long=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "got diff:"
|
||||||
|
cat pr.diff
|
||||||
|
|
||||||
|
- name: Comment when diff length exceeded
|
||||||
|
if: steps.get_diff.outputs.too_long == 'true'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||||
|
run: |
|
||||||
|
jq -n --arg body "Diff length exceeded, can't query API" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
|
||||||
|
curl -sS -X POST \
|
||||||
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
|
||||||
|
--data @body.json
|
||||||
|
|
||||||
|
- name: Query OpenAI and post review
|
||||||
|
if: steps.get_diff.outputs.too_long == 'false'
|
||||||
|
env:
|
||||||
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
OPENAI_MODEL: ${{ env.OPENAI_MODEL }}
|
||||||
|
SYSTEM_PROMPT: ${{ env.SYSTEM_PROMPT }}
|
||||||
|
AI_PROMPT: ${{ env.AI_PROMPT }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||||
|
run: |
|
||||||
|
# Prepare OpenAI chat request payload (embed diff safely)
|
||||||
|
jq -n \
|
||||||
|
--arg model "$OPENAI_MODEL" \
|
||||||
|
--arg sys "$SYSTEM_PROMPT" \
|
||||||
|
--arg prompt "$AI_PROMPT" \
|
||||||
|
--rawfile diff pr.diff \
|
||||||
|
'{model:$model,
|
||||||
|
messages:[
|
||||||
|
{role:"system", content:$sys},
|
||||||
|
{role:"user", content: ($prompt + "\n\n```diff\n" + $diff + "\n```")}
|
||||||
|
]
|
||||||
|
}' > payload.json
|
||||||
|
|
||||||
|
# Call OpenAI
|
||||||
|
curl -sS https://api.openai.com/v1/chat/completions \
|
||||||
|
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d @payload.json > response.json
|
||||||
|
|
||||||
|
# Extract response text
|
||||||
|
COMMENT=$(jq -r '.choices[0].message.content // empty' response.json)
|
||||||
|
if [ -z "$COMMENT" ]; then
|
||||||
|
COMMENT="AI did not return a response."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If failed, add a note
|
||||||
|
ADDITIONAL_NOTE=""
|
||||||
|
if [[ "$COMMENT" == *"not ok"* ]]; then
|
||||||
|
ADDITIONAL_NOTE=$(echo -ne "\n\nPlease note this check is a guideline, not a hard requirement. It is here to help you translate. If you disagree with some points, just state that. Any typos should be fixed.")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Post the review as a PR comment
|
||||||
|
jq -n --arg body "$COMMENT" --arg note "$ADDITIONAL_NOTE" '{body: ("AI translation check result:\n\n" + $body + $note)}' > body.json
|
||||||
|
echo "CURLing https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments"
|
||||||
|
curl -sS -X POST \
|
||||||
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
|
||||||
|
--data @body.json
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -32,6 +32,8 @@ src/render/shaders/*.inc
|
||||||
src/render/shaders/Shaders.hpp
|
src/render/shaders/Shaders.hpp
|
||||||
|
|
||||||
hyprctl/hyprctl
|
hyprctl/hyprctl
|
||||||
|
hyprctl/hw-protocols/*.c*
|
||||||
|
hyprctl/hw-protocols/*.h*
|
||||||
|
|
||||||
gmon.out
|
gmon.out
|
||||||
*.out
|
*.out
|
||||||
|
|
|
||||||
232
CMakeLists.txt
232
CMakeLists.txt
|
|
@ -17,7 +17,6 @@ set(HYPRLAND_VERSION ${VER})
|
||||||
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||||
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
|
set(INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
set(BINDIR ${CMAKE_INSTALL_BINDIR})
|
set(BINDIR ${CMAKE_INSTALL_BINDIR})
|
||||||
configure_file(hyprland.pc.in hyprland.pc @ONLY)
|
|
||||||
|
|
||||||
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS")
|
||||||
|
|
||||||
|
|
@ -25,7 +24,14 @@ message(STATUS "Gathering git info")
|
||||||
|
|
||||||
# Make shader files includable
|
# Make shader files includable
|
||||||
execute_process(COMMAND ./scripts/generateShaderIncludes.sh
|
execute_process(COMMAND ./scripts/generateShaderIncludes.sh
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE HYPR_SHADER_GEN_RESULT)
|
||||||
|
if(NOT HYPR_SHADER_GEN_RESULT EQUAL 0)
|
||||||
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"Failed to generate shader includes (scripts/generateShaderIncludes.sh), exit code: ${HYPR_SHADER_GEN_RESULT}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
|
|
@ -33,11 +39,23 @@ find_package(PkgConfig REQUIRED)
|
||||||
# provide a .pc file and won't be detected this way
|
# provide a .pc file and won't be detected this way
|
||||||
pkg_check_modules(udis_dep IMPORTED_TARGET udis86>=1.7.2)
|
pkg_check_modules(udis_dep IMPORTED_TARGET udis86>=1.7.2)
|
||||||
|
|
||||||
# Fallback to subproject
|
# Find non-pkgconfig udis86, otherwise fallback to subproject
|
||||||
if(NOT udis_dep_FOUND)
|
if(NOT udis_dep_FOUND)
|
||||||
add_subdirectory("subprojects/udis86")
|
find_library(udis_nopc udis86)
|
||||||
include_directories("subprojects/udis86")
|
if(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND"))
|
||||||
message(STATUS "udis86 dependency not found, falling back to subproject")
|
message(STATUS "Found udis86 at ${udis_nopc}")
|
||||||
|
else()
|
||||||
|
add_subdirectory("subprojects/udis86")
|
||||||
|
include_directories("subprojects/udis86")
|
||||||
|
message(STATUS "udis86 dependency not found, falling back to subproject")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(librt rt)
|
||||||
|
if("${librt}" MATCHES "librt-NOTFOUND")
|
||||||
|
unset(LIBRT)
|
||||||
|
else()
|
||||||
|
set(LIBRT rt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE)
|
if(CMAKE_BUILD_TYPE)
|
||||||
|
|
@ -68,9 +86,11 @@ message(
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
message(STATUS "Configuring Hyprland in Debug with CMake")
|
message(STATUS "Configuring Hyprland in Debug with CMake")
|
||||||
add_compile_definitions(HYPRLAND_DEBUG)
|
add_compile_definitions(HYPRLAND_DEBUG)
|
||||||
|
set(BUILD_TESTING ON)
|
||||||
else()
|
else()
|
||||||
add_compile_options(-O3)
|
add_compile_options(-O3)
|
||||||
message(STATUS "Configuring Hyprland in Release with CMake")
|
message(STATUS "Configuring Hyprland in Release with CMake")
|
||||||
|
set(BUILD_TESTING OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}")
|
add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}")
|
||||||
|
|
@ -105,11 +125,17 @@ find_package(Threads REQUIRED)
|
||||||
set(GLES_VERSION "GLES3")
|
set(GLES_VERSION "GLES3")
|
||||||
find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
|
find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
|
||||||
|
|
||||||
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=0.9.3)
|
set(AQUAMARINE_MINIMUM_VERSION 0.9.3)
|
||||||
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=0.3.2)
|
set(HYPRLANG_MINIMUM_VERSION 0.6.7)
|
||||||
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=0.1.7)
|
set(HYPRCURSOR_MINIMUM_VERSION 0.1.7)
|
||||||
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.8.2)
|
set(HYPRUTILS_MINIMUM_VERSION 0.11.0)
|
||||||
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=0.1.6)
|
set(HYPRGRAPHICS_MINIMUM_VERSION 0.1.6)
|
||||||
|
|
||||||
|
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=${AQUAMARINE_MINIMUM_VERSION})
|
||||||
|
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=${HYPRLANG_MINIMUM_VERSION})
|
||||||
|
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=${HYPRCURSOR_MINIMUM_VERSION})
|
||||||
|
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=${HYPRUTILS_MINIMUM_VERSION})
|
||||||
|
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=${HYPRGRAPHICS_MINIMUM_VERSION})
|
||||||
|
|
||||||
string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION})
|
string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION})
|
||||||
list(GET AQ_VERSION_LIST 0 AQ_VERSION_MAJOR)
|
list(GET AQ_VERSION_LIST 0 AQ_VERSION_MAJOR)
|
||||||
|
|
@ -128,13 +154,41 @@ set(HYPRGRAPHICS_VERSION "${hyprgraphics_dep_VERSION}")
|
||||||
|
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
|
|
||||||
set(GIT_COMMIT_HASH "unknown")
|
# Populate variables with env vars if present
|
||||||
set(GIT_BRANCH "unknown")
|
set(GIT_COMMIT_HASH "$ENV{GIT_COMMIT_HASH}")
|
||||||
set(GIT_COMMIT_MESSAGE "unknown")
|
if(NOT GIT_COMMIT_HASH)
|
||||||
set(GIT_COMMIT_DATE "unknown")
|
set(GIT_COMMIT_HASH "unknown")
|
||||||
set(GIT_DIRTY "unknown")
|
endif()
|
||||||
set(GIT_TAG "unknown")
|
|
||||||
set(GIT_COMMITS "0")
|
set(GIT_BRANCH "$ENV{GIT_BRANCH}")
|
||||||
|
if(NOT GIT_BRANCH)
|
||||||
|
set(GIT_BRANCH "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GIT_COMMIT_MESSAGE "$ENV{GIT_COMMIT_MESSAGE}")
|
||||||
|
if(NOT GIT_COMMIT_MESSAGE)
|
||||||
|
set(GIT_COMMIT_MESSAGE "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GIT_COMMIT_DATE "$ENV{GIT_COMMIT_DATE}")
|
||||||
|
if(NOT GIT_COMMIT_DATE)
|
||||||
|
set(GIT_COMMIT_DATE "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GIT_DIRTY "$ENV{GIT_DIRTY}")
|
||||||
|
if(NOT GIT_DIRTY)
|
||||||
|
set(GIT_DIRTY "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GIT_TAG "$ENV{GIT_TAG}")
|
||||||
|
if(NOT GIT_TAG)
|
||||||
|
set(GIT_TAG "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(GIT_COMMITS "$ENV{GIT_COMMITS}")
|
||||||
|
if(NOT GIT_COMMITS)
|
||||||
|
set(GIT_COMMITS "0")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(Git_FOUND)
|
if(Git_FOUND)
|
||||||
execute_process(
|
execute_process(
|
||||||
|
|
@ -155,10 +209,10 @@ if(Git_FOUND)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} branch --show-current
|
execute_process(COMMAND ${GIT_EXECUTABLE} branch --show-current
|
||||||
WORKING_DIRECTORY ${GIT_TOPLEVEL}
|
WORKING_DIRECTORY ${GIT_TOPLEVEL}
|
||||||
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%s
|
execute_process(COMMAND sh "-c" "${GIT_EXECUTABLE} show -s --format=%s --no-show-signature | sed \"s/\\\"/\'/g\""
|
||||||
WORKING_DIRECTORY ${GIT_TOPLEVEL}
|
WORKING_DIRECTORY ${GIT_TOPLEVEL}
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_MESSAGE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_VARIABLE GIT_COMMIT_MESSAGE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%cd --date=local
|
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%cd --date=local --no-show-signature
|
||||||
WORKING_DIRECTORY ${GIT_TOPLEVEL}
|
WORKING_DIRECTORY ${GIT_TOPLEVEL}
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_VARIABLE GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD --
|
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD --
|
||||||
|
|
@ -188,28 +242,36 @@ configure_file(
|
||||||
|
|
||||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERATED TRUE)
|
||||||
|
|
||||||
|
set(XKBCOMMON_MINIMUM_VERSION 1.11.0)
|
||||||
|
set(WAYLAND_SERVER_MINIMUM_VERSION 1.22.90)
|
||||||
|
set(WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION 1.45)
|
||||||
|
set(LIBINPUT_MINIMUM_VERSION 1.28)
|
||||||
|
|
||||||
pkg_check_modules(
|
pkg_check_modules(
|
||||||
deps
|
deps
|
||||||
REQUIRED
|
REQUIRED
|
||||||
IMPORTED_TARGET
|
IMPORTED_TARGET GLOBAL
|
||||||
xkbcommon
|
xkbcommon>=${XKBCOMMON_MINIMUM_VERSION}
|
||||||
uuid
|
uuid
|
||||||
wayland-server>=1.22.90
|
wayland-server>=${WAYLAND_SERVER_MINIMUM_VERSION}
|
||||||
wayland-protocols>=1.45
|
wayland-protocols>=${WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION}
|
||||||
cairo
|
cairo
|
||||||
pango
|
pango
|
||||||
pangocairo
|
pangocairo
|
||||||
pixman-1
|
pixman-1
|
||||||
xcursor
|
xcursor
|
||||||
libdrm
|
libdrm
|
||||||
libinput>=1.28
|
libinput>=${LIBINPUT_MINIMUM_VERSION}
|
||||||
gbm
|
gbm
|
||||||
gio-2.0
|
gio-2.0
|
||||||
re2)
|
re2
|
||||||
|
muparser)
|
||||||
|
|
||||||
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
|
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRCFILES "src/*.cpp")
|
file(GLOB_RECURSE SRCFILES "src/*.cpp")
|
||||||
|
get_filename_component(FULL_MAIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ABSOLUTE)
|
||||||
|
list(REMOVE_ITEM SRCFILES "${FULL_MAIN_PATH}")
|
||||||
|
|
||||||
set(TRACY_CPP_FILES "")
|
set(TRACY_CPP_FILES "")
|
||||||
if(USE_TRACY)
|
if(USE_TRACY)
|
||||||
|
|
@ -217,7 +279,12 @@ if(USE_TRACY)
|
||||||
message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES})
|
message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(Hyprland ${SRCFILES} ${TRACY_CPP_FILES})
|
add_library(hyprland_lib STATIC ${SRCFILES})
|
||||||
|
add_executable(Hyprland src/main.cpp ${TRACY_CPP_FILES})
|
||||||
|
target_link_libraries(Hyprland hyprland_lib)
|
||||||
|
|
||||||
|
target_include_directories(hyprland_lib PUBLIC ${deps_INCLUDE_DIRS})
|
||||||
|
target_include_directories(Hyprland PUBLIC ${deps_INCLUDE_DIRS})
|
||||||
|
|
||||||
set(USE_GPROF OFF)
|
set(USE_GPROF OFF)
|
||||||
|
|
||||||
|
|
@ -227,8 +294,8 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
if(WITH_ASAN)
|
if(WITH_ASAN)
|
||||||
message(STATUS "Enabling ASan")
|
message(STATUS "Enabling ASan")
|
||||||
|
|
||||||
target_link_libraries(Hyprland asan)
|
target_link_libraries(hyprland_lib PUBLIC asan)
|
||||||
target_compile_options(Hyprland PUBLIC -fsanitize=address)
|
target_compile_options(hyprland_lib PUBLIC -fsanitize=address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_TRACY)
|
if(USE_TRACY)
|
||||||
|
|
@ -238,7 +305,7 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
option(TRACY_ON_DEMAND "" ON)
|
option(TRACY_ON_DEMAND "" ON)
|
||||||
add_subdirectory(subprojects/tracy)
|
add_subdirectory(subprojects/tracy)
|
||||||
|
|
||||||
target_link_libraries(Hyprland Tracy::TracyClient)
|
target_link_libraries(hyprland_lib PUBLIC Tracy::TracyClient)
|
||||||
|
|
||||||
if(USE_TRACY_GPU)
|
if(USE_TRACY_GPU)
|
||||||
message(STATUS "Tracy GPU Profiling is turned on")
|
message(STATUS "Tracy GPU Profiling is turned on")
|
||||||
|
|
@ -254,6 +321,10 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILT_WITH_NIX)
|
||||||
|
add_compile_definitions(BUILT_WITH_NIX)
|
||||||
|
endif()
|
||||||
|
|
||||||
check_include_file("execinfo.h" EXECINFOH)
|
check_include_file("execinfo.h" EXECINFOH)
|
||||||
if(EXECINFOH)
|
if(EXECINFOH)
|
||||||
message(STATUS "Configuration supports execinfo")
|
message(STATUS "Configuration supports execinfo")
|
||||||
|
|
@ -263,19 +334,19 @@ endif()
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
|
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
|
||||||
if(HAVE_LIBEXECINFO)
|
if(HAVE_LIBEXECINFO)
|
||||||
target_link_libraries(Hyprland execinfo)
|
target_link_libraries(hyprland_lib PUBLIC execinfo)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_include_file("sys/timerfd.h" HAS_TIMERFD)
|
check_include_file("sys/timerfd.h" HAS_TIMERFD)
|
||||||
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
|
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
|
||||||
if(NOT HAS_TIMERFD AND epoll_FOUND)
|
if(NOT HAS_TIMERFD AND epoll_FOUND)
|
||||||
target_link_libraries(Hyprland PkgConfig::epoll)
|
target_link_libraries(hyprland_lib PUBLIC PkgConfig::epoll)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_include_file("sys/inotify.h" HAS_INOTIFY)
|
check_include_file("sys/inotify.h" HAS_INOTIFY)
|
||||||
pkg_check_modules(inotify IMPORTED_TARGET libinotify)
|
pkg_check_modules(inotify IMPORTED_TARGET libinotify)
|
||||||
if(NOT HAS_INOTIFY AND inotify_FOUND)
|
if(NOT HAS_INOTIFY AND inotify_FOUND)
|
||||||
target_link_libraries(Hyprland PkgConfig::inotify)
|
target_link_libraries(hyprland_lib PUBLIC PkgConfig::inotify)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NO_XWAYLAND)
|
if(NO_XWAYLAND)
|
||||||
|
|
@ -283,10 +354,7 @@ if(NO_XWAYLAND)
|
||||||
add_compile_definitions(NO_XWAYLAND)
|
add_compile_definitions(NO_XWAYLAND)
|
||||||
else()
|
else()
|
||||||
message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
|
message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...")
|
||||||
pkg_check_modules(
|
set(XWAYLAND_DEPENDENCIES
|
||||||
xdeps
|
|
||||||
REQUIRED
|
|
||||||
IMPORTED_TARGET
|
|
||||||
xcb
|
xcb
|
||||||
xcb-render
|
xcb-render
|
||||||
xcb-xfixes
|
xcb-xfixes
|
||||||
|
|
@ -294,9 +362,21 @@ else()
|
||||||
xcb-composite
|
xcb-composite
|
||||||
xcb-res
|
xcb-res
|
||||||
xcb-errors)
|
xcb-errors)
|
||||||
target_link_libraries(Hyprland PkgConfig::xdeps)
|
|
||||||
|
pkg_check_modules(
|
||||||
|
xdeps
|
||||||
|
REQUIRED
|
||||||
|
IMPORTED_TARGET
|
||||||
|
${XWAYLAND_DEPENDENCIES})
|
||||||
|
|
||||||
|
string(JOIN ", " PKGCONFIG_XWAYLAND_DEPENDENCIES ${XWAYLAND_DEPENDENCIES})
|
||||||
|
string(PREPEND PKGCONFIG_XWAYLAND_DEPENDENCIES ", ")
|
||||||
|
|
||||||
|
target_link_libraries(hyprland_lib PUBLIC PkgConfig::xdeps)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
configure_file(hyprland.pc.in hyprland.pc @ONLY)
|
||||||
|
|
||||||
if(NO_SYSTEMD)
|
if(NO_SYSTEMD)
|
||||||
message(STATUS "SYSTEMD support is disabled...")
|
message(STATUS "SYSTEMD support is disabled...")
|
||||||
else()
|
else()
|
||||||
|
|
@ -321,29 +401,38 @@ if(CMAKE_DISABLE_PRECOMPILE_HEADERS)
|
||||||
message(STATUS "Not using precompiled headers")
|
message(STATUS "Not using precompiled headers")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Setting precompiled headers")
|
message(STATUS "Setting precompiled headers")
|
||||||
target_precompile_headers(Hyprland PRIVATE
|
target_precompile_headers(hyprland_lib PRIVATE
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
|
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Setting link libraries")
|
message(STATUS "Setting link libraries")
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
Hyprland
|
hyprland_lib
|
||||||
rt
|
PUBLIC
|
||||||
PkgConfig::aquamarine_dep
|
PkgConfig::aquamarine_dep
|
||||||
PkgConfig::hyprlang_dep
|
PkgConfig::hyprlang_dep
|
||||||
PkgConfig::hyprutils_dep
|
PkgConfig::hyprutils_dep
|
||||||
PkgConfig::hyprcursor_dep
|
PkgConfig::hyprcursor_dep
|
||||||
PkgConfig::hyprgraphics_dep
|
PkgConfig::hyprgraphics_dep
|
||||||
PkgConfig::deps)
|
PkgConfig::deps
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
Hyprland
|
||||||
|
${LIBRT}
|
||||||
|
hyprland_lib)
|
||||||
if(udis_dep_FOUND)
|
if(udis_dep_FOUND)
|
||||||
target_link_libraries(Hyprland PkgConfig::udis_dep)
|
target_link_libraries(hyprland_lib PUBLIC PkgConfig::udis_dep)
|
||||||
|
elseif(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND"))
|
||||||
|
target_link_libraries(hyprland_lib PUBLIC ${udis_nopc})
|
||||||
else()
|
else()
|
||||||
target_link_libraries(Hyprland libudis86)
|
target_link_libraries(hyprland_lib PUBLIC libudis86)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# used by `make installheaders`, to ensure the headers are generated
|
# used by `make installheaders`, to ensure the headers are generated
|
||||||
add_custom_target(generate-protocol-headers)
|
add_custom_target(generate-protocol-headers)
|
||||||
|
set(PROTOCOL_SOURCES "")
|
||||||
|
|
||||||
function(protocolnew protoPath protoName external)
|
function(protocolnew protoPath protoName external)
|
||||||
if(external)
|
if(external)
|
||||||
|
|
@ -357,10 +446,15 @@ function(protocolnew protoPath protoName external)
|
||||||
COMMAND hyprwayland-scanner ${path}/${protoName}.xml
|
COMMAND hyprwayland-scanner ${path}/${protoName}.xml
|
||||||
${CMAKE_SOURCE_DIR}/protocols/
|
${CMAKE_SOURCE_DIR}/protocols/
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp
|
target_sources(hyprland_lib PRIVATE protocols/${protoName}.cpp
|
||||||
protocols/${protoName}.hpp)
|
protocols/${protoName}.hpp)
|
||||||
target_sources(generate-protocol-headers
|
target_sources(generate-protocol-headers
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)
|
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)
|
||||||
|
|
||||||
|
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp")
|
||||||
|
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
|
||||||
|
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp")
|
||||||
|
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
function(protocolWayland)
|
function(protocolWayland)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
|
@ -370,12 +464,17 @@ function(protocolWayland)
|
||||||
hyprwayland-scanner --wayland-enums
|
hyprwayland-scanner --wayland-enums
|
||||||
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
|
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
target_sources(Hyprland PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
|
target_sources(hyprland_lib PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
|
||||||
target_sources(generate-protocol-headers
|
target_sources(generate-protocol-headers
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)
|
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)
|
||||||
|
|
||||||
|
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.hpp")
|
||||||
|
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
|
||||||
|
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.cpp")
|
||||||
|
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
target_link_libraries(Hyprland OpenGL::EGL OpenGL::GL Threads::Threads)
|
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GL Threads::Threads)
|
||||||
|
|
||||||
pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.4)
|
pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.4)
|
||||||
if(hyprland_protocols_dep_FOUND)
|
if(hyprland_protocols_dep_FOUND)
|
||||||
|
|
@ -457,6 +556,7 @@ protocolwayland()
|
||||||
|
|
||||||
# tools
|
# tools
|
||||||
add_subdirectory(hyprctl)
|
add_subdirectory(hyprctl)
|
||||||
|
add_subdirectory(start)
|
||||||
|
|
||||||
if(NO_HYPRPM)
|
if(NO_HYPRPM)
|
||||||
message(STATUS "hyprpm is disabled")
|
message(STATUS "hyprpm is disabled")
|
||||||
|
|
@ -483,7 +583,6 @@ add_compile_definitions(DATAROOTDIR="${CMAKE_INSTALL_FULL_DATAROOTDIR}")
|
||||||
|
|
||||||
# installable assets
|
# installable assets
|
||||||
file(GLOB_RECURSE INSTALLABLE_ASSETS "assets/install/*")
|
file(GLOB_RECURSE INSTALLABLE_ASSETS "assets/install/*")
|
||||||
list(FILTER INSTALLABLE_ASSETS EXCLUDE REGEX "meson.build")
|
|
||||||
install(FILES ${INSTALLABLE_ASSETS}
|
install(FILES ${INSTALLABLE_ASSETS}
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr)
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr)
|
||||||
|
|
||||||
|
|
@ -521,10 +620,37 @@ install(
|
||||||
PATTERN "*.hpp"
|
PATTERN "*.hpp"
|
||||||
PATTERN "*.inc")
|
PATTERN "*.inc")
|
||||||
|
|
||||||
if(BUILD_TESTING OR BUILD_HYPRTESTER)
|
if(BUILD_TESTING OR WITH_TESTS)
|
||||||
message(STATUS "Building hyprtester")
|
message(STATUS "Building tests")
|
||||||
|
|
||||||
|
# hyprtester
|
||||||
add_subdirectory(hyprtester)
|
add_subdirectory(hyprtester)
|
||||||
|
|
||||||
|
# GTest
|
||||||
|
find_package(GTest CONFIG REQUIRED)
|
||||||
|
include(GoogleTest)
|
||||||
|
file(GLOB_RECURSE TESTFILES "tests/*.cpp")
|
||||||
|
add_executable(hyprland_gtests ${TESTFILES})
|
||||||
|
target_compile_options(hyprland_gtests PRIVATE --coverage)
|
||||||
|
target_link_options(hyprland_gtests PRIVATE --coverage)
|
||||||
|
target_include_directories(
|
||||||
|
hyprland_gtests
|
||||||
|
PUBLIC "./include"
|
||||||
|
PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
|
target_link_libraries(hyprland_gtests hyprland_lib GTest::gtest_main)
|
||||||
|
|
||||||
|
gtest_discover_tests(hyprland_gtests)
|
||||||
|
|
||||||
|
# Enable coverage in main hyprland lib
|
||||||
|
target_compile_options(hyprland_lib PRIVATE --coverage)
|
||||||
|
target_link_options(hyprland_lib PRIVATE --coverage)
|
||||||
|
target_link_libraries(hyprland_lib PUBLIC gcov)
|
||||||
|
|
||||||
|
# Enable coverage in hyprland exe
|
||||||
|
target_compile_options(Hyprland PRIVATE --coverage)
|
||||||
|
target_link_options(Hyprland PRIVATE --coverage)
|
||||||
|
target_link_libraries(Hyprland gcov)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
|
|
@ -533,12 +659,8 @@ if(BUILD_TESTING)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_custom_target(tests)
|
add_custom_target(tests)
|
||||||
|
|
||||||
add_test(
|
add_dependencies(tests hyprland_gtests)
|
||||||
NAME "Main Test"
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/hyprtester
|
|
||||||
COMMAND hyprtester)
|
|
||||||
|
|
||||||
add_dependencies(tests hyprtester)
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Testing is disabled")
|
message(STATUS "Testing is disabled")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
0.52.1
|
0.52.0
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
globber = run_command('sh', '-c', 'find . -type f -not -name "*.build"', check: true)
|
|
||||||
files = globber.stdout().strip().split('\n')
|
|
||||||
|
|
||||||
foreach file : files
|
|
||||||
install_data(
|
|
||||||
file,
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'hypr'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
)
|
|
||||||
endforeach
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
install_data(
|
|
||||||
'hyprland-portals.conf',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'xdg-desktop-portal'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
)
|
|
||||||
|
|
||||||
subdir('install')
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
install_man('Hyprland.1')
|
|
||||||
install_man('hyprctl.1')
|
|
||||||
|
|
@ -27,7 +27,7 @@ monitor=,preferred,auto,auto
|
||||||
# Set programs that you use
|
# Set programs that you use
|
||||||
$terminal = kitty
|
$terminal = kitty
|
||||||
$fileManager = dolphin
|
$fileManager = dolphin
|
||||||
$menu = wofi --show drun
|
$menu = hyprlauncher
|
||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
|
@ -159,10 +159,23 @@ animations {
|
||||||
# uncomment all if you wish to use that.
|
# uncomment all if you wish to use that.
|
||||||
# workspace = w[tv1], gapsout:0, gapsin:0
|
# workspace = w[tv1], gapsout:0, gapsin:0
|
||||||
# workspace = f[1], gapsout:0, gapsin:0
|
# workspace = f[1], gapsout:0, gapsin:0
|
||||||
# windowrule = bordersize 0, floating:0, onworkspace:w[tv1]
|
# windowrule {
|
||||||
# windowrule = rounding 0, floating:0, onworkspace:w[tv1]
|
# name = no-gaps-wtv1
|
||||||
# windowrule = bordersize 0, floating:0, onworkspace:f[1]
|
# match:float = false
|
||||||
# windowrule = rounding 0, floating:0, onworkspace:f[1]
|
# match:workspace = w[tv1]
|
||||||
|
#
|
||||||
|
# border_size = 0
|
||||||
|
# rounding = 0
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# windowrule {
|
||||||
|
# name = no-gaps-f1
|
||||||
|
# match:float = false
|
||||||
|
# match:workspace = f[1]
|
||||||
|
#
|
||||||
|
# border_size = 0
|
||||||
|
# rounding = 0
|
||||||
|
# }
|
||||||
|
|
||||||
# See https://wiki.hypr.land/Configuring/Dwindle-Layout/ for more
|
# See https://wiki.hypr.land/Configuring/Dwindle-Layout/ for more
|
||||||
dwindle {
|
dwindle {
|
||||||
|
|
@ -224,7 +237,7 @@ $mainMod = SUPER # Sets "Windows" key as main modifier
|
||||||
# Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more
|
# Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more
|
||||||
bind = $mainMod, Q, exec, $terminal
|
bind = $mainMod, Q, exec, $terminal
|
||||||
bind = $mainMod, C, killactive,
|
bind = $mainMod, C, killactive,
|
||||||
bind = $mainMod, M, exit,
|
bind = $mainMod, M, exec, command -v hyprshutdown >/dev/null 2>&1 && hyprshutdown || hyprctl dispatch exit
|
||||||
bind = $mainMod, E, exec, $fileManager
|
bind = $mainMod, E, exec, $fileManager
|
||||||
bind = $mainMod, V, togglefloating,
|
bind = $mainMod, V, togglefloating,
|
||||||
bind = $mainMod, R, exec, $menu
|
bind = $mainMod, R, exec, $menu
|
||||||
|
|
@ -294,11 +307,35 @@ bindl = , XF86AudioPrev, exec, playerctl previous
|
||||||
# See https://wiki.hypr.land/Configuring/Window-Rules/ for more
|
# See https://wiki.hypr.land/Configuring/Window-Rules/ for more
|
||||||
# See https://wiki.hypr.land/Configuring/Workspace-Rules/ for workspace rules
|
# See https://wiki.hypr.land/Configuring/Workspace-Rules/ for workspace rules
|
||||||
|
|
||||||
# Example windowrule
|
# Example windowrules that are useful
|
||||||
# windowrule = float,class:^(kitty)$,title:^(kitty)$
|
|
||||||
|
|
||||||
# Ignore maximize requests from apps. You'll probably like this.
|
windowrule {
|
||||||
windowrule = suppressevent maximize, class:.*
|
# Ignore maximize requests from all apps. You'll probably like this.
|
||||||
|
name = suppress-maximize-events
|
||||||
|
match:class = .*
|
||||||
|
|
||||||
# Fix some dragging issues with XWayland
|
suppress_event = maximize
|
||||||
windowrule = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0
|
}
|
||||||
|
|
||||||
|
windowrule {
|
||||||
|
# Fix some dragging issues with XWayland
|
||||||
|
name = fix-xwayland-drags
|
||||||
|
match:class = ^$
|
||||||
|
match:title = ^$
|
||||||
|
match:xwayland = true
|
||||||
|
match:float = true
|
||||||
|
match:fullscreen = false
|
||||||
|
match:pin = false
|
||||||
|
|
||||||
|
no_focus = true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hyprland-run windowrule
|
||||||
|
windowrule {
|
||||||
|
name = move-hyprland-run
|
||||||
|
|
||||||
|
match:class = hyprland-run
|
||||||
|
|
||||||
|
move = 20 monitor_h-120
|
||||||
|
float = yes
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Hyprland
|
Name=Hyprland
|
||||||
Comment=An intelligent dynamic tiling Wayland compositor
|
Comment=An intelligent dynamic tiling Wayland compositor
|
||||||
Exec=Hyprland
|
Exec=start-hyprland
|
||||||
Type=Application
|
Type=Application
|
||||||
DesktopNames=Hyprland
|
DesktopNames=Hyprland
|
||||||
Keywords=tiling;wayland;compositor;
|
Keywords=tiling;wayland;compositor;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
install_data(
|
|
||||||
'hyprland.conf',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'hypr'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
)
|
|
||||||
install_data(
|
|
||||||
'hyprland.desktop',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'wayland-sessions'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
)
|
|
||||||
96
flake.lock
generated
96
flake.lock
generated
|
|
@ -16,11 +16,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762356719,
|
"lastModified": 1765900596,
|
||||||
"narHash": "sha256-qwd/xdoOya1m8FENle+4hWnydCtlXUWLAW/Auk6WL7s=",
|
"narHash": "sha256-+hn8v9jkkLP9m+o0Nm5SiEq10W0iWDSotH2XfjU45fA=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "aquamarine",
|
"repo": "aquamarine",
|
||||||
"rev": "6d0b3567584691bf9d8fedb5d0093309e2f979c7",
|
"rev": "d83c97f8f5c0aae553c1489c7d9eff3eadcadace",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -32,11 +32,11 @@
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1747046372,
|
"lastModified": 1761588595,
|
||||||
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
|
"narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=",
|
||||||
"owner": "edolstra",
|
"owner": "edolstra",
|
||||||
"repo": "flake-compat",
|
"repo": "flake-compat",
|
||||||
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
|
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -105,11 +105,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762462052,
|
"lastModified": 1763733840,
|
||||||
"narHash": "sha256-6roLYzcDf4V38RUMSqycsOwAnqfodL6BmhRkUtwIgdA=",
|
"narHash": "sha256-JnET78yl5RvpGuDQy3rCycOCkiKoLr5DN1fPhRNNMco=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprgraphics",
|
"repo": "hyprgraphics",
|
||||||
"rev": "ffc999d980c7b3bca85d3ebd0a9fbadf984a8162",
|
"rev": "8f1bec691b2d198c60cccabca7a94add2df4ed1a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -133,6 +133,9 @@
|
||||||
"hyprutils": [
|
"hyprutils": [
|
||||||
"hyprutils"
|
"hyprutils"
|
||||||
],
|
],
|
||||||
|
"hyprwayland-scanner": [
|
||||||
|
"hyprwayland-scanner"
|
||||||
|
],
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
|
|
@ -141,11 +144,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762465111,
|
"lastModified": 1765643131,
|
||||||
"narHash": "sha256-dS13YZdWjgGGLBjpT4FHB6xf8I/WiAU+mgNWXsZgDUs=",
|
"narHash": "sha256-CCGohW5EBIRy4B7vTyBMqPgsNcaNenVad/wszfddET0=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprland-guiutils",
|
"repo": "hyprland-guiutils",
|
||||||
"rev": "a415eba866a953f3096d661318f771aa0082eb98",
|
"rev": "e50ae912813bdfa8372d62daf454f48d6df02297",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -164,11 +167,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759610243,
|
"lastModified": 1765214753,
|
||||||
"narHash": "sha256-+KEVnKBe8wz+a6dTLq8YDcF3UrhQElwsYJaVaHXJtoI=",
|
"narHash": "sha256-P9zdGXOzToJJgu5sVjv7oeOGPIIwrd9hAUAP3PsmBBs=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprland-protocols",
|
"repo": "hyprland-protocols",
|
||||||
"rev": "bd153e76f751f150a09328dbdeb5e4fab9d23622",
|
"rev": "3f3860b869014c00e8b9e0528c7b4ddc335c21ab",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -190,11 +193,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1758927902,
|
"lastModified": 1764612430,
|
||||||
"narHash": "sha256-LZgMds7M94+vuMql2bERQ6LiFFdhgsEFezE4Vn+Ys3A=",
|
"narHash": "sha256-54ltTSbI6W+qYGMchAgCR6QnC1kOdKXN6X6pJhOWxFg=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprlang",
|
"repo": "hyprlang",
|
||||||
"rev": "4dafa28d4f79877d67a7d1a654cddccf8ebf15da",
|
"rev": "0d00dc118981531aa731150b6ea551ef037acddd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -221,7 +224,10 @@
|
||||||
"hyprland-guiutils",
|
"hyprland-guiutils",
|
||||||
"hyprutils"
|
"hyprutils"
|
||||||
],
|
],
|
||||||
"hyprwayland-scanner": "hyprwayland-scanner",
|
"hyprwayland-scanner": [
|
||||||
|
"hyprland-guiutils",
|
||||||
|
"hyprwayland-scanner"
|
||||||
|
],
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"hyprland-guiutils",
|
"hyprland-guiutils",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
|
|
@ -232,11 +238,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762463729,
|
"lastModified": 1764592794,
|
||||||
"narHash": "sha256-2fYkU/mdz8WKY3dkDPlE/j6hTxIwqultsx4gMMsMns0=",
|
"narHash": "sha256-7CcO+wbTJ1L1NBQHierHzheQGPWwkIQug/w+fhTAVuU=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprtoolkit",
|
"repo": "hyprtoolkit",
|
||||||
"rev": "88483bdee5329ec985f0c8f834c519cd18cfe532",
|
"rev": "5cfe0743f0e608e1462972303778d8a0859ee63e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -255,11 +261,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762387740,
|
"lastModified": 1766160771,
|
||||||
"narHash": "sha256-gQ9zJ+pUI4o+Gh4Z6jhJll7jjCSwi8ZqJIhCE2oqwhQ=",
|
"narHash": "sha256-roINUGikWRqqgKrD4iotKbGj3ZKJl3hjMz5l/SyKrHw=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprutils",
|
"repo": "hyprutils",
|
||||||
"rev": "926689ddb9c0a8787e58c02c765a62e32d63d1f7",
|
"rev": "5ac060bfcf2f12b3a6381156ebbc13826a05b09f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -271,22 +277,18 @@
|
||||||
"hyprwayland-scanner": {
|
"hyprwayland-scanner": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"hyprland-guiutils",
|
|
||||||
"hyprtoolkit",
|
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"systems": [
|
"systems": [
|
||||||
"hyprland-guiutils",
|
|
||||||
"hyprtoolkit",
|
|
||||||
"systems"
|
"systems"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1755184602,
|
"lastModified": 1763640274,
|
||||||
"narHash": "sha256-RCBQN8xuADB0LEgaKbfRqwm6CdyopE1xIEhNc67FAbw=",
|
"narHash": "sha256-Uan1Nl9i4TF/kyFoHnTq1bd/rsWh4GAK/9/jDqLbY5A=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprwayland-scanner",
|
"repo": "hyprwayland-scanner",
|
||||||
"rev": "b3b0f1f40ae09d4447c20608e5a4faf8bf3c492d",
|
"rev": "f6cf414ca0e16a4d30198fd670ec86df3c89f671",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -295,8 +297,11 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hyprwayland-scanner_2": {
|
"hyprwire": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"hyprutils": [
|
||||||
|
"hyprutils"
|
||||||
|
],
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
|
|
@ -305,26 +310,26 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1755184602,
|
"lastModified": 1766253200,
|
||||||
"narHash": "sha256-RCBQN8xuADB0LEgaKbfRqwm6CdyopE1xIEhNc67FAbw=",
|
"narHash": "sha256-26qPwrd3od+xoYVywSB7hC2cz9ivN46VPLlrsXyGxvE=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprwayland-scanner",
|
"repo": "hyprwire",
|
||||||
"rev": "b3b0f1f40ae09d4447c20608e5a4faf8bf3c492d",
|
"rev": "1079777525b30a947c8d657fac158e00ae85de9d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "hyprwayland-scanner",
|
"repo": "hyprwire",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762363567,
|
"lastModified": 1766070988,
|
||||||
"narHash": "sha256-YRqMDEtSMbitIMj+JLpheSz0pwEr0Rmy5mC7myl17xs=",
|
"narHash": "sha256-G/WVghka6c4bAzMhTwT2vjLccg/awmHkdKSd2JrycLc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ae814fd3904b621d8ab97418f1d0f2eb0d3716f4",
|
"rev": "c6245e83d836d0433170a16eb185cefe0572f8b8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -343,11 +348,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1762441963,
|
"lastModified": 1765911976,
|
||||||
"narHash": "sha256-j+rNQ119ffYUkYt2YYS6rnd6Jh/crMZmbqpkGLXaEt0=",
|
"narHash": "sha256-t3T/xm8zstHRLx+pIHxVpQTiySbKqcQbK+r+01XVKc0=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "git-hooks.nix",
|
"repo": "git-hooks.nix",
|
||||||
"rev": "8e7576e79b88c16d7ee3bbd112c8d90070832885",
|
"rev": "b68b780b69702a090c8bb1b973bab13756cc7a27",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -365,7 +370,8 @@
|
||||||
"hyprland-protocols": "hyprland-protocols",
|
"hyprland-protocols": "hyprland-protocols",
|
||||||
"hyprlang": "hyprlang",
|
"hyprlang": "hyprlang",
|
||||||
"hyprutils": "hyprutils",
|
"hyprutils": "hyprutils",
|
||||||
"hyprwayland-scanner": "hyprwayland-scanner_2",
|
"hyprwayland-scanner": "hyprwayland-scanner",
|
||||||
|
"hyprwire": "hyprwire",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"pre-commit-hooks": "pre-commit-hooks",
|
"pre-commit-hooks": "pre-commit-hooks",
|
||||||
"systems": "systems",
|
"systems": "systems",
|
||||||
|
|
|
||||||
10
flake.nix
10
flake.nix
|
|
@ -43,6 +43,7 @@
|
||||||
inputs.hyprgraphics.follows = "hyprgraphics";
|
inputs.hyprgraphics.follows = "hyprgraphics";
|
||||||
inputs.hyprutils.follows = "hyprutils";
|
inputs.hyprutils.follows = "hyprutils";
|
||||||
inputs.hyprlang.follows = "hyprlang";
|
inputs.hyprlang.follows = "hyprlang";
|
||||||
|
inputs.hyprwayland-scanner.follows = "hyprwayland-scanner";
|
||||||
};
|
};
|
||||||
|
|
||||||
hyprlang = {
|
hyprlang = {
|
||||||
|
|
@ -64,6 +65,13 @@
|
||||||
inputs.systems.follows = "systems";
|
inputs.systems.follows = "systems";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hyprwire = {
|
||||||
|
url = "github:hyprwm/hyprwire";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.systems.follows = "systems";
|
||||||
|
inputs.hyprutils.follows = "hyprutils";
|
||||||
|
};
|
||||||
|
|
||||||
xdph = {
|
xdph = {
|
||||||
url = "github:hyprwm/xdg-desktop-portal-hyprland";
|
url = "github:hyprwm/xdg-desktop-portal-hyprland";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
@ -150,8 +158,8 @@
|
||||||
(pkgsFor.${system})
|
(pkgsFor.${system})
|
||||||
# hyprland-packages
|
# hyprland-packages
|
||||||
hyprland
|
hyprland
|
||||||
hyprland-with-hyprtester
|
|
||||||
hyprland-unwrapped
|
hyprland-unwrapped
|
||||||
|
hyprland-with-tests
|
||||||
# hyprland-extras
|
# hyprland-extras
|
||||||
xdg-desktop-portal-hyprland
|
xdg-desktop-portal-hyprland
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,32 @@ project(
|
||||||
DESCRIPTION "Control utility for Hyprland"
|
DESCRIPTION "Control utility for Hyprland"
|
||||||
)
|
)
|
||||||
|
|
||||||
pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 re2)
|
pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 hyprwire re2)
|
||||||
|
|
||||||
add_executable(hyprctl "main.cpp")
|
file(GLOB_RECURSE HYPRCTL_SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "hw-protocols/*.cpp" "include/*.hpp")
|
||||||
|
|
||||||
|
add_executable(hyprctl ${HYPRCTL_SRCFILES})
|
||||||
|
|
||||||
target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps)
|
target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps)
|
||||||
|
target_include_directories(hyprctl PRIVATE "hw-protocols")
|
||||||
|
|
||||||
|
# Hyprwire
|
||||||
|
|
||||||
|
function(hyprprotocol protoPath protoName)
|
||||||
|
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath})
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.hpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-spec.hpp
|
||||||
|
COMMAND hyprwire-scanner --client ${path}/${protoName}.xml
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
target_sources(hyprctl PRIVATE hw-protocols/${protoName}-client.cpp
|
||||||
|
hw-protocols/${protoName}-client.hpp
|
||||||
|
hw-protocols/${protoName}-spec.hpp)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
hyprprotocol(hw-protocols hyprpaper_core)
|
||||||
|
|
||||||
# binary
|
# binary
|
||||||
install(TARGETS hyprctl)
|
install(TARGETS hyprctl)
|
||||||
|
|
|
||||||
144
hyprctl/hw-protocols/hyprpaper_core.xml
Normal file
144
hyprctl/hw-protocols/hyprpaper_core.xml
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<protocol name="hyprpaper_core" version="1">
|
||||||
|
<copyright>
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2025, Hypr Development
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<object name="hyprpaper_core_manager" version="1">
|
||||||
|
<description summary="manager object">
|
||||||
|
This is the core manager object for hyprpaper operations
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<c2s name="get_wallpaper_object">
|
||||||
|
<description summary="Get a wallpaper object">
|
||||||
|
Creates a wallpaper object
|
||||||
|
</description>
|
||||||
|
<returns iface="hyprpaper_wallpaper"/>
|
||||||
|
</c2s>
|
||||||
|
|
||||||
|
<s2c name="add_monitor">
|
||||||
|
<description summary="New monitor added">
|
||||||
|
Emitted when a new monitor is added.
|
||||||
|
</description>
|
||||||
|
<arg name="monitor_name" type="varchar" summary="the monitor's name"/>
|
||||||
|
</s2c>
|
||||||
|
|
||||||
|
<s2c name="remove_monitor">
|
||||||
|
<description summary="A monitor was removed">
|
||||||
|
Emitted when a monitor is removed.
|
||||||
|
</description>
|
||||||
|
<arg name="monitor_name" type="varchar" summary="the monitor's name"/>
|
||||||
|
</s2c>
|
||||||
|
|
||||||
|
<c2s name="destroy" destructor="true">
|
||||||
|
<description summary="Destroy this object">
|
||||||
|
Destroys this object. Children remain alive until destroyed.
|
||||||
|
</description>
|
||||||
|
</c2s>
|
||||||
|
</object>
|
||||||
|
|
||||||
|
<enum name="wallpaper_fit_mode">
|
||||||
|
<value idx="0" name="stretch"/>
|
||||||
|
<value idx="1" name="cover"/>
|
||||||
|
<value idx="2" name="contain"/>
|
||||||
|
<value idx="3" name="tile"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum name="wallpaper_errors">
|
||||||
|
<value idx="0" name="inert_wallpaper_object" description="attempted to use an inert wallpaper object"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum name="applying_error">
|
||||||
|
<value idx="0" name="invalid_path" description="path provided was invalid"/>
|
||||||
|
<value idx="1" name="invalid_monitor" description="monitor provided was invalid"/>
|
||||||
|
<value idx="2" name="unknown_error" description="unknown error"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<object name="hyprpaper_wallpaper" version="1">
|
||||||
|
<description summary="wallpaper object">
|
||||||
|
This is an object describing a wallpaper
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<c2s name="path">
|
||||||
|
<description summary="Set a path">
|
||||||
|
Set a file path for the wallpaper. This has to be an absolute path from the fs root.
|
||||||
|
This is required.
|
||||||
|
</description>
|
||||||
|
<arg name="wallpaper" type="varchar" summary="path"/>
|
||||||
|
</c2s>
|
||||||
|
|
||||||
|
<c2s name="fit_mode">
|
||||||
|
<description summary="Set a fit mode">
|
||||||
|
Set a fit mode for the wallpaper. This is set to cover by default.
|
||||||
|
</description>
|
||||||
|
<arg name="fit_mode" type="enum" interface="wallpaper_fit_mode" summary="path"/>
|
||||||
|
</c2s>
|
||||||
|
|
||||||
|
<c2s name="monitor_name">
|
||||||
|
<description summary="Set the monitor name">
|
||||||
|
Set a monitor for the wallpaper. Setting this to empty (or not setting at all) will
|
||||||
|
treat this as a wildcard fallback.
|
||||||
|
|
||||||
|
See hyprpaper_core_manager.add_monitor and hyprpaper_core_manager.remove_monitor
|
||||||
|
for tracking monitor names.
|
||||||
|
</description>
|
||||||
|
<arg name="monitor_name" type="varchar" summary="monitor name"/>
|
||||||
|
</c2s>
|
||||||
|
|
||||||
|
<c2s name="apply">
|
||||||
|
<description summary="Apply this wallpaper">
|
||||||
|
Applies this object's state to the wallpaper state. Will emit .success on success,
|
||||||
|
and .failed on failure.
|
||||||
|
|
||||||
|
This object becomes inert after .succeess or .failed, the only valid operation
|
||||||
|
is to destroy it afterwards.
|
||||||
|
</description>
|
||||||
|
</c2s>
|
||||||
|
|
||||||
|
<s2c name="success">
|
||||||
|
<description summary="Operation succeeded">
|
||||||
|
Wallpaper was applied successfully.
|
||||||
|
</description>
|
||||||
|
</s2c>
|
||||||
|
|
||||||
|
<s2c name="failed">
|
||||||
|
<description summary="Operation failed">
|
||||||
|
Wallpaper was not applied. See the error field for more information.
|
||||||
|
</description>
|
||||||
|
<arg name="error" type="enum" interface="hyprpaper_wallpaper_application_error" summary="path"/>
|
||||||
|
</s2c>
|
||||||
|
|
||||||
|
<c2s name="destroy" destructor="true">
|
||||||
|
<description summary="Destroy this object">
|
||||||
|
Destroys this object.
|
||||||
|
</description>
|
||||||
|
</c2s>
|
||||||
|
</object>
|
||||||
|
</protocol>
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
executable(
|
|
||||||
'hyprctl',
|
|
||||||
'main.cpp',
|
|
||||||
dependencies: [
|
|
||||||
dependency('hyprutils', version: '>= 0.1.1'),
|
|
||||||
dependency('re2', required: true)
|
|
||||||
],
|
|
||||||
install: true,
|
|
||||||
)
|
|
||||||
|
|
||||||
install_data(
|
|
||||||
'hyprctl.bash',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
rename: 'hyprctl',
|
|
||||||
)
|
|
||||||
install_data(
|
|
||||||
'hyprctl.fish',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'fish/vendor_completions.d'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
)
|
|
||||||
install_data(
|
|
||||||
'hyprctl.zsh',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'zsh/site-functions'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
rename: '_hyprctl',
|
|
||||||
)
|
|
||||||
|
|
@ -74,11 +74,8 @@ flags:
|
||||||
const std::string_view HYPRPAPER_HELP = R"#(usage: hyprctl [flags] hyprpaper <request>
|
const std::string_view HYPRPAPER_HELP = R"#(usage: hyprctl [flags] hyprpaper <request>
|
||||||
|
|
||||||
requests:
|
requests:
|
||||||
listactive → Lists all active images
|
wallpaper → Issue a wallpaper to call a config wallpaper dynamically.
|
||||||
listloaded → Lists all loaded images
|
Arguments are [mon],[path],[fit_mode]. Fit mode is optional.
|
||||||
preload <path> → Preloads image
|
|
||||||
unload <path> → Unloads image. Pass 'all' as path to unload all images
|
|
||||||
wallpaper → Issue a wallpaper to call a config wallpaper dynamically
|
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
See 'hyprctl --help')#";
|
See 'hyprctl --help')#";
|
||||||
11
hyprctl/src/helpers/Memory.hpp
Normal file
11
hyprctl/src/helpers/Memory.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hyprutils/memory/SharedPtr.hpp>
|
||||||
|
#include <hyprutils/memory/UniquePtr.hpp>
|
||||||
|
#include <hyprutils/memory/Atomic.hpp>
|
||||||
|
|
||||||
|
using namespace Hyprutils::Memory;
|
||||||
|
|
||||||
|
#define SP CSharedPointer
|
||||||
|
#define WP CWeakPointer
|
||||||
|
#define UP CUniquePointer
|
||||||
148
hyprctl/src/hyprpaper/Hyprpaper.cpp
Normal file
148
hyprctl/src/hyprpaper/Hyprpaper.cpp
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
#include "Hyprpaper.hpp"
|
||||||
|
#include "../helpers/Memory.hpp"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <format>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include <hyprpaper_core-client.hpp>
|
||||||
|
|
||||||
|
#include <hyprutils/string/VarList2.hpp>
|
||||||
|
using namespace Hyprutils::String;
|
||||||
|
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
|
constexpr const char* SOCKET_NAME = ".hyprpaper.sock";
|
||||||
|
static SP<CCHyprpaperCoreImpl> g_coreImpl;
|
||||||
|
|
||||||
|
constexpr const uint32_t PROTOCOL_VERSION_SUPPORTED = 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
static hyprpaperCoreWallpaperFitMode fitFromString(const std::string_view& sv) {
|
||||||
|
if (sv == "contain")
|
||||||
|
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_CONTAIN;
|
||||||
|
if (sv == "fit" || sv == "stretch")
|
||||||
|
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_STRETCH;
|
||||||
|
if (sv == "tile")
|
||||||
|
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_TILE;
|
||||||
|
return HYPRPAPER_CORE_WALLPAPER_FIT_MODE_COVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::expected<std::string, std::string> resolvePath(const std::string_view& sv) {
|
||||||
|
std::error_code ec;
|
||||||
|
auto can = std::filesystem::canonical(sv, ec);
|
||||||
|
|
||||||
|
if (ec)
|
||||||
|
return std::unexpected(std::format("invalid path: {}", ec.message()));
|
||||||
|
|
||||||
|
return can;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::expected<std::string, std::string> getFullPath(const std::string_view& sv) {
|
||||||
|
if (sv.empty())
|
||||||
|
return std::unexpected("empty path");
|
||||||
|
|
||||||
|
if (sv[0] == '~') {
|
||||||
|
static auto HOME = getenv("HOME");
|
||||||
|
if (!HOME || HOME[0] == '\0')
|
||||||
|
return std::unexpected("home path but no $HOME");
|
||||||
|
|
||||||
|
return resolvePath(std::string{HOME} + "/"s + std::string{sv.substr(1)});
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolvePath(sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::expected<void, std::string> Hyprpaper::makeHyprpaperRequest(const std::string_view& rq) {
|
||||||
|
if (!rq.contains(' '))
|
||||||
|
return std::unexpected("Invalid request");
|
||||||
|
|
||||||
|
if (!rq.starts_with("/hyprpaper "))
|
||||||
|
return std::unexpected("Invalid request");
|
||||||
|
|
||||||
|
std::string_view LHS, RHS;
|
||||||
|
auto spacePos = rq.find(' ', 12);
|
||||||
|
LHS = rq.substr(11, spacePos - 11);
|
||||||
|
RHS = rq.substr(spacePos + 1);
|
||||||
|
|
||||||
|
if (LHS != "wallpaper")
|
||||||
|
return std::unexpected("Unknown hyprpaper request");
|
||||||
|
|
||||||
|
CVarList2 args(std::string{RHS}, 0, ',');
|
||||||
|
|
||||||
|
const std::string MONITOR = std::string{args[0]};
|
||||||
|
const auto& PATH_RAW = args[1];
|
||||||
|
const auto& FIT = args[2];
|
||||||
|
|
||||||
|
if (PATH_RAW.empty())
|
||||||
|
return std::unexpected("not enough args");
|
||||||
|
|
||||||
|
const auto RTDIR = getenv("XDG_RUNTIME_DIR");
|
||||||
|
|
||||||
|
if (!RTDIR || RTDIR[0] == '\0')
|
||||||
|
return std::unexpected("can't send: no XDG_RUNTIME_DIR");
|
||||||
|
|
||||||
|
const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||||
|
|
||||||
|
if (!HIS || HIS[0] == '\0')
|
||||||
|
return std::unexpected("can't send: no HYPRLAND_INSTANCE_SIGNATURE (not running under hyprland)");
|
||||||
|
|
||||||
|
const auto PATH = getFullPath(PATH_RAW);
|
||||||
|
|
||||||
|
if (!PATH)
|
||||||
|
return std::unexpected(std::format("bad path: {}", PATH_RAW));
|
||||||
|
|
||||||
|
auto socketPath = RTDIR + "/hypr/"s + HIS + "/"s + SOCKET_NAME;
|
||||||
|
|
||||||
|
auto socket = Hyprwire::IClientSocket::open(socketPath);
|
||||||
|
|
||||||
|
if (!socket)
|
||||||
|
return std::unexpected("can't send: failed to connect to hyprpaper (is it running?)");
|
||||||
|
|
||||||
|
g_coreImpl = makeShared<CCHyprpaperCoreImpl>(1);
|
||||||
|
|
||||||
|
socket->addImplementation(g_coreImpl);
|
||||||
|
|
||||||
|
if (!socket->waitForHandshake())
|
||||||
|
return std::unexpected("can't send: wire handshake failed");
|
||||||
|
|
||||||
|
auto spec = socket->getSpec(g_coreImpl->protocol()->specName());
|
||||||
|
|
||||||
|
if (!spec)
|
||||||
|
return std::unexpected("can't send: hyprpaper doesn't have the spec?!");
|
||||||
|
|
||||||
|
auto manager = makeShared<CCHyprpaperCoreManagerObject>(socket->bindProtocol(g_coreImpl->protocol(), PROTOCOL_VERSION_SUPPORTED));
|
||||||
|
|
||||||
|
if (!manager)
|
||||||
|
return std::unexpected("wire error: couldn't create manager");
|
||||||
|
|
||||||
|
auto wallpaper = makeShared<CCHyprpaperWallpaperObject>(manager->sendGetWallpaperObject());
|
||||||
|
|
||||||
|
if (!wallpaper)
|
||||||
|
return std::unexpected("wire error: couldn't create wallpaper object");
|
||||||
|
|
||||||
|
bool canExit = false;
|
||||||
|
std::optional<std::string> err;
|
||||||
|
|
||||||
|
wallpaper->setFailed([&canExit, &err](uint32_t code) {
|
||||||
|
canExit = true;
|
||||||
|
err = std::format("failed to set wallpaper, code {}", code);
|
||||||
|
});
|
||||||
|
wallpaper->setSuccess([&canExit]() { canExit = true; });
|
||||||
|
|
||||||
|
wallpaper->sendPath(PATH->c_str());
|
||||||
|
wallpaper->sendMonitorName(MONITOR.c_str());
|
||||||
|
if (!FIT.empty())
|
||||||
|
wallpaper->sendFitMode(fitFromString(FIT));
|
||||||
|
|
||||||
|
wallpaper->sendApply();
|
||||||
|
|
||||||
|
while (!canExit) {
|
||||||
|
socket->dispatchEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return std::unexpected(*err);
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
8
hyprctl/src/hyprpaper/Hyprpaper.hpp
Normal file
8
hyprctl/src/hyprpaper/Hyprpaper.hpp
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <expected>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Hyprpaper {
|
||||||
|
std::expected<void, std::string> makeHyprpaperRequest(const std::string_view& rq);
|
||||||
|
};
|
||||||
|
|
@ -31,6 +31,7 @@ using namespace Hyprutils::String;
|
||||||
using namespace Hyprutils::Memory;
|
using namespace Hyprutils::Memory;
|
||||||
|
|
||||||
#include "Strings.hpp"
|
#include "Strings.hpp"
|
||||||
|
#include "hyprpaper/Hyprpaper.hpp"
|
||||||
|
|
||||||
std::string instanceSignature;
|
std::string instanceSignature;
|
||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
|
|
@ -305,10 +306,6 @@ int requestIPC(std::string_view filename, std::string_view arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int requestHyprpaper(std::string_view arg) {
|
|
||||||
return requestIPC(".hyprpaper.sock", arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int requestHyprsunset(std::string_view arg) {
|
int requestHyprsunset(std::string_view arg) {
|
||||||
return requestIPC(".hyprsunset.sock", arg);
|
return requestIPC(".hyprsunset.sock", arg);
|
||||||
}
|
}
|
||||||
|
|
@ -500,9 +497,12 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
if (fullRequest.contains("/--batch"))
|
if (fullRequest.contains("/--batch"))
|
||||||
batchRequest(fullRequest, json);
|
batchRequest(fullRequest, json);
|
||||||
else if (fullRequest.contains("/hyprpaper"))
|
else if (fullRequest.contains("/hyprpaper")) {
|
||||||
exitStatus = requestHyprpaper(fullRequest);
|
auto result = Hyprpaper::makeHyprpaperRequest(fullRequest);
|
||||||
else if (fullRequest.contains("/hyprsunset"))
|
if (!result)
|
||||||
|
log(std::format("error: {}", result.error()));
|
||||||
|
exitStatus = !result;
|
||||||
|
} else if (fullRequest.contains("/hyprsunset"))
|
||||||
exitStatus = requestHyprsunset(fullRequest);
|
exitStatus = requestHyprsunset(fullRequest);
|
||||||
else if (fullRequest.contains("/switchxkblayout"))
|
else if (fullRequest.contains("/switchxkblayout"))
|
||||||
exitStatus = request(fullRequest, 2);
|
exitStatus = request(fullRequest, 2);
|
||||||
|
|
@ -4,4 +4,5 @@ Name: Hyprland
|
||||||
URL: https://github.com/hyprwm/Hyprland
|
URL: https://github.com/hyprwm/Hyprland
|
||||||
Description: Hyprland header files
|
Description: Hyprland header files
|
||||||
Version: @HYPRLAND_VERSION@
|
Version: @HYPRLAND_VERSION@
|
||||||
|
Requires: aquamarine >= @AQUAMARINE_MINIMUM_VERSION@, hyprcursor >= @HYPRCURSOR_MINIMUM_VERSION@, hyprgraphics >= @HYPRGRAPHICS_MINIMUM_VERSION@, hyprlang >= @HYPRLANG_MINIMUM_VERSION@, hyprutils >= @HYPRUTILS_MINIMUM_VERSION@, libdrm, egl, cairo, xkbcommon >= @XKBCOMMON_MINIMUM_VERSION@, libinput >= @LIBINPUT_MINIMUM_VERSION@, wayland-server >= @WAYLAND_SERVER_MINIMUM_VERSION@@PKGCONFIG_XWAYLAND_DEPENDENCIES@
|
||||||
Cflags: -I${prefix} -I${prefix}/hyprland/protocols -I${prefix}/hyprland
|
Cflags: -I${prefix} -I${prefix}/hyprland/protocols -I${prefix}/hyprland
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.7.0)
|
pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.7.0)
|
||||||
|
|
||||||
find_package(glaze QUIET)
|
find_package(glaze 6.0.0 QUIET)
|
||||||
if (NOT glaze_FOUND)
|
if (NOT glaze_FOUND)
|
||||||
set(GLAZE_VERSION v5.1.1)
|
set(GLAZE_VERSION v6.1.0)
|
||||||
message(STATUS "glaze dependency not found, retrieving ${GLAZE_VERSION} with FetchContent")
|
message(STATUS "glaze dependency not found, retrieving ${GLAZE_VERSION} with FetchContent")
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
|
||||||
auto DATA = toml::table{
|
auto DATA = toml::table{
|
||||||
{"repository", toml::table{
|
{"repository", toml::table{
|
||||||
{"name", repo.name},
|
{"name", repo.name},
|
||||||
|
{"author", repo.author},
|
||||||
{"hash", repo.hash},
|
{"hash", repo.hash},
|
||||||
{"url", repo.url},
|
{"url", repo.url},
|
||||||
{"rev", repo.rev}
|
{"rev", repo.rev}
|
||||||
|
|
@ -122,31 +123,32 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
|
||||||
Debug::die("{}", failureString("Failed to write plugin state"));
|
Debug::die("{}", failureString("Failed to write plugin state"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataState::pluginRepoExists(const std::string& urlOrName) {
|
bool DataState::pluginRepoExists(const SPluginRepoIdentifier identifier) {
|
||||||
ensureStateStoreExists();
|
ensureStateStoreExists();
|
||||||
|
|
||||||
for (const auto& stateFile : getPluginStates()) {
|
for (const auto& stateFile : getPluginStates()) {
|
||||||
const auto STATE = toml::parse_file(stateFile.c_str());
|
const auto STATE = toml::parse_file(stateFile.c_str());
|
||||||
const auto NAME = STATE["repository"]["name"].value_or("");
|
const auto NAME = STATE["repository"]["name"].value_or("");
|
||||||
const auto URL = STATE["repository"]["url"].value_or("");
|
const auto AUTHOR = STATE["repository"]["author"].value_or("");
|
||||||
|
const auto URL = STATE["repository"]["url"].value_or("");
|
||||||
|
|
||||||
if (URL == urlOrName || NAME == urlOrName)
|
if (identifier.matches(URL, NAME, AUTHOR))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataState::removePluginRepo(const std::string& urlOrName) {
|
void DataState::removePluginRepo(const SPluginRepoIdentifier identifier) {
|
||||||
ensureStateStoreExists();
|
ensureStateStoreExists();
|
||||||
|
|
||||||
for (const auto& stateFile : getPluginStates()) {
|
for (const auto& stateFile : getPluginStates()) {
|
||||||
const auto STATE = toml::parse_file(stateFile.c_str());
|
const auto STATE = toml::parse_file(stateFile.c_str());
|
||||||
const auto NAME = STATE["repository"]["name"].value_or("");
|
const auto NAME = STATE["repository"]["name"].value_or("");
|
||||||
const auto URL = STATE["repository"]["url"].value_or("");
|
const auto AUTHOR = STATE["repository"]["author"].value_or("");
|
||||||
|
const auto URL = STATE["repository"]["url"].value_or("");
|
||||||
if (URL == urlOrName || NAME == urlOrName) {
|
|
||||||
|
|
||||||
|
if (identifier.matches(URL, NAME, AUTHOR)) {
|
||||||
// unload the plugins!!
|
// unload the plugins!!
|
||||||
for (const auto& file : std::filesystem::directory_iterator(stateFile.parent_path())) {
|
for (const auto& file : std::filesystem::directory_iterator(stateFile.parent_path())) {
|
||||||
if (!file.path().string().ends_with(".so"))
|
if (!file.path().string().ends_with(".so"))
|
||||||
|
|
@ -181,7 +183,7 @@ void DataState::updateGlobalState(const SGlobalState& state) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto DATA = toml::table{
|
auto DATA = toml::table{
|
||||||
{"state", toml::table{
|
{"state", toml::table{
|
||||||
{"hash", state.headersHashCompiled},
|
{"hash", state.headersAbiCompiled},
|
||||||
{"dont_warn_install", state.dontWarnInstall}
|
{"dont_warn_install", state.dontWarnInstall}
|
||||||
}}
|
}}
|
||||||
};
|
};
|
||||||
|
|
@ -206,8 +208,8 @@ SGlobalState DataState::getGlobalState() {
|
||||||
auto DATA = toml::parse_file(stateFile.c_str());
|
auto DATA = toml::parse_file(stateFile.c_str());
|
||||||
|
|
||||||
SGlobalState state;
|
SGlobalState state;
|
||||||
state.headersHashCompiled = DATA["state"]["hash"].value_or("");
|
state.headersAbiCompiled = DATA["state"]["hash"].value_or("");
|
||||||
state.dontWarnInstall = DATA["state"]["dont_warn_install"].value_or(false);
|
state.dontWarnInstall = DATA["state"]["dont_warn_install"].value_or(false);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
@ -219,16 +221,18 @@ std::vector<SPluginRepository> DataState::getAllRepositories() {
|
||||||
for (const auto& stateFile : getPluginStates()) {
|
for (const auto& stateFile : getPluginStates()) {
|
||||||
const auto STATE = toml::parse_file(stateFile.c_str());
|
const auto STATE = toml::parse_file(stateFile.c_str());
|
||||||
|
|
||||||
const auto NAME = STATE["repository"]["name"].value_or("");
|
const auto NAME = STATE["repository"]["name"].value_or("");
|
||||||
const auto URL = STATE["repository"]["url"].value_or("");
|
const auto AUTHOR = STATE["repository"]["author"].value_or("");
|
||||||
const auto REV = STATE["repository"]["rev"].value_or("");
|
const auto URL = STATE["repository"]["url"].value_or("");
|
||||||
const auto HASH = STATE["repository"]["hash"].value_or("");
|
const auto REV = STATE["repository"]["rev"].value_or("");
|
||||||
|
const auto HASH = STATE["repository"]["hash"].value_or("");
|
||||||
|
|
||||||
SPluginRepository repo;
|
SPluginRepository repo;
|
||||||
repo.hash = HASH;
|
repo.hash = HASH;
|
||||||
repo.name = NAME;
|
repo.name = NAME;
|
||||||
repo.url = URL;
|
repo.author = AUTHOR;
|
||||||
repo.rev = REV;
|
repo.url = URL;
|
||||||
|
repo.rev = REV;
|
||||||
|
|
||||||
for (const auto& [key, val] : STATE) {
|
for (const auto& [key, val] : STATE) {
|
||||||
if (key == "repository")
|
if (key == "repository")
|
||||||
|
|
@ -247,7 +251,7 @@ std::vector<SPluginRepository> DataState::getAllRepositories() {
|
||||||
return repos;
|
return repos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
|
bool DataState::setPluginEnabled(const SPluginRepoIdentifier identifier, bool enabled) {
|
||||||
ensureStateStoreExists();
|
ensureStateStoreExists();
|
||||||
|
|
||||||
for (const auto& stateFile : getPluginStates()) {
|
for (const auto& stateFile : getPluginStates()) {
|
||||||
|
|
@ -256,8 +260,17 @@ bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
|
||||||
if (key == "repository")
|
if (key == "repository")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (key.str() != name)
|
switch (identifier.type) {
|
||||||
continue;
|
case IDENTIFIER_NAME:
|
||||||
|
if (key.str() != identifier.name)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
case IDENTIFIER_AUTHOR_NAME:
|
||||||
|
if (STATE["repository"]["author"] != identifier.author || key.str() != identifier.name)
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
|
||||||
const auto FAILED = STATE[key]["failed"].value_or(false);
|
const auto FAILED = STATE[key]["failed"].value_or(false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
#include "Plugin.hpp"
|
#include "Plugin.hpp"
|
||||||
|
|
||||||
struct SGlobalState {
|
struct SGlobalState {
|
||||||
std::string headersHashCompiled = "";
|
std::string headersAbiCompiled = "";
|
||||||
bool dontWarnInstall = false;
|
bool dontWarnInstall = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace DataState {
|
namespace DataState {
|
||||||
|
|
@ -15,11 +15,11 @@ namespace DataState {
|
||||||
std::vector<std::filesystem::path> getPluginStates();
|
std::vector<std::filesystem::path> getPluginStates();
|
||||||
void ensureStateStoreExists();
|
void ensureStateStoreExists();
|
||||||
void addNewPluginRepo(const SPluginRepository& repo);
|
void addNewPluginRepo(const SPluginRepository& repo);
|
||||||
void removePluginRepo(const std::string& urlOrName);
|
void removePluginRepo(const SPluginRepoIdentifier identifier);
|
||||||
bool pluginRepoExists(const std::string& urlOrName);
|
bool pluginRepoExists(const SPluginRepoIdentifier identifier);
|
||||||
void updateGlobalState(const SGlobalState& state);
|
void updateGlobalState(const SGlobalState& state);
|
||||||
void purgeAllCache();
|
void purgeAllCache();
|
||||||
SGlobalState getGlobalState();
|
SGlobalState getGlobalState();
|
||||||
bool setPluginEnabled(const std::string& name, bool enabled);
|
bool setPluginEnabled(const SPluginRepoIdentifier identifier, bool enabled);
|
||||||
std::vector<SPluginRepository> getAllRepositories();
|
std::vector<SPluginRepository> getAllRepositories();
|
||||||
};
|
};
|
||||||
48
hyprpm/src/core/Plugin.cpp
Normal file
48
hyprpm/src/core/Plugin.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include "Plugin.hpp"
|
||||||
|
|
||||||
|
SPluginRepoIdentifier SPluginRepoIdentifier::fromUrl(const std::string& url) {
|
||||||
|
return SPluginRepoIdentifier{.type = IDENTIFIER_URL, .url = url};
|
||||||
|
}
|
||||||
|
|
||||||
|
SPluginRepoIdentifier SPluginRepoIdentifier::fromName(const std::string& name) {
|
||||||
|
return SPluginRepoIdentifier{.type = IDENTIFIER_NAME, .name = name};
|
||||||
|
}
|
||||||
|
|
||||||
|
SPluginRepoIdentifier SPluginRepoIdentifier::fromAuthorName(const std::string& author, const std::string& name) {
|
||||||
|
return SPluginRepoIdentifier{.type = IDENTIFIER_AUTHOR_NAME, .name = name, .author = author};
|
||||||
|
}
|
||||||
|
|
||||||
|
SPluginRepoIdentifier SPluginRepoIdentifier::fromString(const std::string& string) {
|
||||||
|
if (string.find(':') != std::string::npos) {
|
||||||
|
return SPluginRepoIdentifier{.type = IDENTIFIER_URL, .url = string};
|
||||||
|
} else {
|
||||||
|
auto slashPos = string.find('/');
|
||||||
|
if (slashPos != std::string::npos) {
|
||||||
|
std::string author = string.substr(0, slashPos);
|
||||||
|
std::string name = string.substr(slashPos + 1, string.size() - slashPos - 1);
|
||||||
|
return SPluginRepoIdentifier{.type = IDENTIFIER_AUTHOR_NAME, .name = name, .author = author};
|
||||||
|
} else {
|
||||||
|
return SPluginRepoIdentifier{.type = IDENTIFIER_NAME, .name = string};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string SPluginRepoIdentifier::toString() const {
|
||||||
|
switch (type) {
|
||||||
|
case IDENTIFIER_NAME: return name;
|
||||||
|
case IDENTIFIER_AUTHOR_NAME: return author + '/' + name;
|
||||||
|
case IDENTIFIER_URL: return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPluginRepoIdentifier::matches(const std::string& url, const std::string& name, const std::string& author) const {
|
||||||
|
switch (type) {
|
||||||
|
case IDENTIFIER_URL: return this->url == url;
|
||||||
|
case IDENTIFIER_NAME: return this->name == name;
|
||||||
|
case IDENTIFIER_AUTHOR_NAME: return this->author == author && this->name == name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,27 @@ struct SPluginRepository {
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string rev;
|
std::string rev;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string author;
|
||||||
std::vector<SPlugin> plugins;
|
std::vector<SPlugin> plugins;
|
||||||
std::string hash;
|
std::string hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ePluginRepoIdentifierType {
|
||||||
|
IDENTIFIER_URL,
|
||||||
|
IDENTIFIER_NAME,
|
||||||
|
IDENTIFIER_AUTHOR_NAME
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SPluginRepoIdentifier {
|
||||||
|
ePluginRepoIdentifierType type;
|
||||||
|
std::string url = "";
|
||||||
|
std::string name = "";
|
||||||
|
std::string author = "";
|
||||||
|
|
||||||
|
static SPluginRepoIdentifier fromString(const std::string& string);
|
||||||
|
static SPluginRepoIdentifier fromUrl(const std::string& Url);
|
||||||
|
static SPluginRepoIdentifier fromName(const std::string& name);
|
||||||
|
static SPluginRepoIdentifier fromAuthorName(const std::string& author, const std::string& name);
|
||||||
|
std::string toString() const;
|
||||||
|
bool matches(const std::string& url, const std::string& name, const std::string& author) const;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <string>
|
||||||
#include <print>
|
#include <print>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
@ -78,40 +79,30 @@ SHyprlandVersion CPluginManager::getHyprlandVersion(bool running) {
|
||||||
else
|
else
|
||||||
onceInstalled = true;
|
onceInstalled = true;
|
||||||
|
|
||||||
const auto HLVERCALL = running ? NHyprlandSocket::send("/version") : execAndGet("Hyprland --version");
|
const auto HLVERCALL = running ? NHyprlandSocket::send("j/version") : execAndGet("Hyprland --version-json");
|
||||||
if (m_bVerbose)
|
|
||||||
std::println("{}", verboseString("{} version returned: {}", running ? "running" : "installed", HLVERCALL));
|
|
||||||
|
|
||||||
if (!HLVERCALL.contains("Tag:")) {
|
auto jsonQuery = glz::read_json<glz::generic>(HLVERCALL);
|
||||||
std::println(stderr, "\n{}", failureString("You don't seem to be running Hyprland."));
|
|
||||||
|
if (!jsonQuery) {
|
||||||
|
std::println("{}", failureString("failed to get the current hyprland version. Are you running hyprland?"));
|
||||||
return SHyprlandVersion{};
|
return SHyprlandVersion{};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string hlcommit = HLVERCALL.substr(HLVERCALL.find("at commit") + 10);
|
auto hlbranch = (*jsonQuery)["branch"].get_string();
|
||||||
hlcommit = hlcommit.substr(0, hlcommit.find_first_of(' '));
|
auto hlcommit = (*jsonQuery)["commit"].get_string();
|
||||||
|
auto abiHash = (*jsonQuery)["abiHash"].get_string();
|
||||||
|
auto hldate = (*jsonQuery)["commit_date"].get_string();
|
||||||
|
auto hlcommits = (*jsonQuery)["commits"].get_string();
|
||||||
|
|
||||||
std::string hlbranch = HLVERCALL.substr(HLVERCALL.find("from branch") + 12);
|
size_t commits = 0;
|
||||||
hlbranch = hlbranch.substr(0, hlbranch.find(" at commit "));
|
|
||||||
|
|
||||||
std::string hldate = HLVERCALL.substr(HLVERCALL.find("Date: ") + 6);
|
|
||||||
hldate = hldate.substr(0, hldate.find('\n'));
|
|
||||||
|
|
||||||
std::string hlcommits;
|
|
||||||
|
|
||||||
if (HLVERCALL.contains("commits:")) {
|
|
||||||
hlcommits = HLVERCALL.substr(HLVERCALL.find("commits:") + 9);
|
|
||||||
hlcommits = hlcommits.substr(0, hlcommits.find(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
int commits = 0;
|
|
||||||
try {
|
try {
|
||||||
commits = std::stoi(hlcommits);
|
commits = std::stoull(hlcommits);
|
||||||
} catch (...) { ; }
|
} catch (...) { ; }
|
||||||
|
|
||||||
if (m_bVerbose)
|
if (m_bVerbose)
|
||||||
std::println("{}", verboseString("parsed commit {} at branch {} on {}, commits {}", hlcommit, hlbranch, hldate, commits));
|
std::println("{}", verboseString("parsed commit {} at branch {} on {}, commits {}", hlcommit, hlbranch, hldate, commits));
|
||||||
|
|
||||||
auto ver = SHyprlandVersion{hlbranch, hlcommit, hldate, commits};
|
auto ver = SHyprlandVersion{hlbranch, hlcommit, hldate, abiHash, commits};
|
||||||
|
|
||||||
if (running)
|
if (running)
|
||||||
verRunning = ver;
|
verRunning = ver;
|
||||||
|
|
@ -146,7 +137,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DataState::pluginRepoExists(url)) {
|
if (DataState::pluginRepoExists(SPluginRepoIdentifier::fromUrl(url))) {
|
||||||
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Repository already installed."));
|
std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Repository already installed."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +152,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
|
||||||
DataState::updateGlobalState(GLOBALSTATE);
|
DataState::updateGlobalState(GLOBALSTATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GLOBALSTATE.headersHashCompiled.empty()) {
|
if (GLOBALSTATE.headersAbiCompiled.empty()) {
|
||||||
std::println("\n{}", failureString("Cannot find headers in the global state. Try running hyprpm update first."));
|
std::println("\n{}", failureString("Cannot find headers in the global state. Try running hyprpm update first."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -343,10 +334,13 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
|
||||||
std::string repohash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD");
|
std::string repohash = execAndGet("cd " + m_szWorkingPluginDirectory + " && git rev-parse HEAD");
|
||||||
if (repohash.length() > 0)
|
if (repohash.length() > 0)
|
||||||
repohash.pop_back();
|
repohash.pop_back();
|
||||||
repo.name = pManifest->m_repository.name.empty() ? url.substr(url.find_last_of('/') + 1) : pManifest->m_repository.name;
|
auto lastSlash = url.find_last_of('/');
|
||||||
repo.url = url;
|
auto secondLastSlash = url.find_last_of('/', lastSlash - 1);
|
||||||
repo.rev = rev;
|
repo.name = pManifest->m_repository.name.empty() ? url.substr(lastSlash + 1) : pManifest->m_repository.name;
|
||||||
repo.hash = repohash;
|
repo.author = url.substr(secondLastSlash + 1, lastSlash - secondLastSlash - 1);
|
||||||
|
repo.url = url;
|
||||||
|
repo.rev = rev;
|
||||||
|
repo.hash = repohash;
|
||||||
for (auto const& p : pManifest->m_plugins) {
|
for (auto const& p : pManifest->m_plugins) {
|
||||||
repo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, false, p.failed});
|
repo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, false, p.failed});
|
||||||
}
|
}
|
||||||
|
|
@ -366,13 +360,13 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string&
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPluginManager::removePluginRepo(const std::string& urlOrName) {
|
bool CPluginManager::removePluginRepo(const SPluginRepoIdentifier identifier) {
|
||||||
if (!DataState::pluginRepoExists(urlOrName)) {
|
if (!DataState::pluginRepoExists(identifier)) {
|
||||||
std::println(stderr, "\n{}", failureString("Could not remove the repository. Repository is not installed."));
|
std::println(stderr, "\n{}", failureString("Could not remove the repository. Repository is not installed."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << Colors::YELLOW << "!" << Colors::RESET << Colors::RED << " removing a plugin repository: " << Colors::RESET << urlOrName << "\n "
|
std::cout << Colors::YELLOW << "!" << Colors::RESET << Colors::RED << " removing a plugin repository: " << Colors::RESET << identifier.toString() << "\n "
|
||||||
<< "Are you sure? [Y/n] ";
|
<< "Are you sure? [Y/n] ";
|
||||||
std::fflush(stdout);
|
std::fflush(stdout);
|
||||||
std::string input;
|
std::string input;
|
||||||
|
|
@ -383,7 +377,7 @@ bool CPluginManager::removePluginRepo(const std::string& urlOrName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataState::removePluginRepo(urlOrName);
|
DataState::removePluginRepo(identifier);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -444,11 +438,16 @@ eHeadersErrors CPluginManager::headersValid() {
|
||||||
if (hash != HLVER.hash)
|
if (hash != HLVER.hash)
|
||||||
return HEADERS_MISMATCHED;
|
return HEADERS_MISMATCHED;
|
||||||
|
|
||||||
|
// check ABI hash too
|
||||||
|
const auto GLOBALSTATE = DataState::getGlobalState();
|
||||||
|
|
||||||
|
if (GLOBALSTATE.headersAbiCompiled != HLVER.abiHash)
|
||||||
|
return HEADERS_ABI_MISMATCH;
|
||||||
|
|
||||||
return HEADERS_OK;
|
return HEADERS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPluginManager::updateHeaders(bool force) {
|
bool CPluginManager::updateHeaders(bool force) {
|
||||||
|
|
||||||
DataState::ensureStateStoreExists();
|
DataState::ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HLVER = getHyprlandVersion(false);
|
const auto HLVER = getHyprlandVersion(false);
|
||||||
|
|
@ -589,14 +588,15 @@ bool CPluginManager::updateHeaders(bool force) {
|
||||||
std::filesystem::remove_all(WORKINGDIR);
|
std::filesystem::remove_all(WORKINGDIR);
|
||||||
|
|
||||||
auto HEADERSVALID = headersValid();
|
auto HEADERSVALID = headersValid();
|
||||||
if (HEADERSVALID == HEADERS_OK) {
|
|
||||||
|
if (HEADERSVALID == HEADERS_OK || HEADERSVALID == HEADERS_MISMATCHED || HEADERSVALID == HEADERS_ABI_MISMATCH) {
|
||||||
progress.printMessageAbove(successString("installed headers"));
|
progress.printMessageAbove(successString("installed headers"));
|
||||||
progress.m_iSteps = 5;
|
progress.m_iSteps = 5;
|
||||||
progress.m_szCurrentMessage = "Done!";
|
progress.m_szCurrentMessage = "Done!";
|
||||||
progress.print();
|
progress.print();
|
||||||
|
|
||||||
auto GLOBALSTATE = DataState::getGlobalState();
|
auto GLOBALSTATE = DataState::getGlobalState();
|
||||||
GLOBALSTATE.headersHashCompiled = HLVER.hash;
|
GLOBALSTATE.headersAbiCompiled = HLVER.abiHash;
|
||||||
DataState::updateGlobalState(GLOBALSTATE);
|
DataState::updateGlobalState(GLOBALSTATE);
|
||||||
|
|
||||||
std::print("\n");
|
std::print("\n");
|
||||||
|
|
@ -775,7 +775,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
|
||||||
const auto OLDPLUGINIT = std::find_if(repo.plugins.begin(), repo.plugins.end(), [&](const auto& other) { return other.name == p.name; });
|
const auto OLDPLUGINIT = std::find_if(repo.plugins.begin(), repo.plugins.end(), [&](const auto& other) { return other.name == p.name; });
|
||||||
newrepo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false});
|
newrepo.plugins.push_back(SPlugin{p.name, m_szWorkingPluginDirectory + "/" + p.output, OLDPLUGINIT != repo.plugins.end() ? OLDPLUGINIT->enabled : false});
|
||||||
}
|
}
|
||||||
DataState::removePluginRepo(newrepo.name);
|
DataState::removePluginRepo(SPluginRepoIdentifier::fromName(newrepo.name));
|
||||||
DataState::addNewPluginRepo(newrepo);
|
DataState::addNewPluginRepo(newrepo);
|
||||||
|
|
||||||
std::filesystem::remove_all(m_szWorkingPluginDirectory);
|
std::filesystem::remove_all(m_szWorkingPluginDirectory);
|
||||||
|
|
@ -787,8 +787,8 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
|
||||||
progress.m_szCurrentMessage = "Updating global state...";
|
progress.m_szCurrentMessage = "Updating global state...";
|
||||||
progress.print();
|
progress.print();
|
||||||
|
|
||||||
auto GLOBALSTATE = DataState::getGlobalState();
|
auto GLOBALSTATE = DataState::getGlobalState();
|
||||||
GLOBALSTATE.headersHashCompiled = HLVER.hash;
|
GLOBALSTATE.headersAbiCompiled = HLVER.abiHash;
|
||||||
DataState::updateGlobalState(GLOBALSTATE);
|
DataState::updateGlobalState(GLOBALSTATE);
|
||||||
|
|
||||||
progress.m_iSteps++;
|
progress.m_iSteps++;
|
||||||
|
|
@ -800,17 +800,23 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPluginManager::enablePlugin(const std::string& name) {
|
bool CPluginManager::enablePlugin(const SPluginRepoIdentifier identifier) {
|
||||||
bool ret = DataState::setPluginEnabled(name, true);
|
bool ret = false;
|
||||||
|
|
||||||
|
switch (identifier.type) {
|
||||||
|
case IDENTIFIER_NAME:
|
||||||
|
case IDENTIFIER_AUTHOR_NAME: ret = DataState::setPluginEnabled(identifier, true); break;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
std::println("{}", successString("Enabled {}", name));
|
std::println("{}", successString("Enabled {}", identifier.name));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPluginManager::disablePlugin(const std::string& name) {
|
bool CPluginManager::disablePlugin(const SPluginRepoIdentifier identifier) {
|
||||||
bool ret = DataState::setPluginEnabled(name, false);
|
bool ret = DataState::setPluginEnabled(identifier, false);
|
||||||
if (ret)
|
if (ret)
|
||||||
std::println("{}", successString("Disabled {}", name));
|
std::println("{}", successString("Disabled {}", identifier.name));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -828,7 +834,7 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState(bool forceReload)
|
||||||
}
|
}
|
||||||
const auto HYPRPMPATH = DataState::getDataStatePath();
|
const auto HYPRPMPATH = DataState::getDataStatePath();
|
||||||
|
|
||||||
const auto json = glz::read_json<glz::json_t::array_t>(NHyprlandSocket::send("j/plugins list"));
|
const auto json = glz::read_json<glz::generic::array_t>(NHyprlandSocket::send("j/plugins list"));
|
||||||
if (!json) {
|
if (!json) {
|
||||||
std::println(stderr, "PluginManager: couldn't parse plugin list output");
|
std::println(stderr, "PluginManager: couldn't parse plugin list output");
|
||||||
return LOADSTATE_FAIL;
|
return LOADSTATE_FAIL;
|
||||||
|
|
@ -913,9 +919,9 @@ bool CPluginManager::loadUnloadPlugin(const std::string& path, bool load) {
|
||||||
auto state = DataState::getGlobalState();
|
auto state = DataState::getGlobalState();
|
||||||
auto HLVER = getHyprlandVersion(true);
|
auto HLVER = getHyprlandVersion(true);
|
||||||
|
|
||||||
if (state.headersHashCompiled != HLVER.hash) {
|
if (state.headersAbiCompiled != HLVER.abiHash) {
|
||||||
if (load)
|
if (load)
|
||||||
std::println("{}", infoString("Running Hyprland version ({}) differs from plugin state ({}), please restart Hyprland.", HLVER.hash, state.headersHashCompiled));
|
std::println("{}", infoString("Running Hyprland version ({}) differs from plugin state ({}), please restart Hyprland.", HLVER.hash, state.headersAbiCompiled));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -931,7 +937,7 @@ void CPluginManager::listAllPlugins() {
|
||||||
const auto REPOS = DataState::getAllRepositories();
|
const auto REPOS = DataState::getAllRepositories();
|
||||||
|
|
||||||
for (auto const& r : REPOS) {
|
for (auto const& r : REPOS) {
|
||||||
std::println("{}", infoString("Repository {}:", r.name));
|
std::println("{}", infoString("Repository {} (by {}):", r.name, r.author));
|
||||||
|
|
||||||
for (auto const& p : r.plugins) {
|
for (auto const& p : r.plugins) {
|
||||||
std::println(" │ Plugin {}", p.name);
|
std::println(" │ Plugin {}", p.name);
|
||||||
|
|
@ -956,6 +962,7 @@ std::string CPluginManager::headerError(const eHeadersErrors err) {
|
||||||
case HEADERS_MISMATCHED: return failureString("Headers version mismatch. Please run hyprpm update to fix those.\n");
|
case HEADERS_MISMATCHED: return failureString("Headers version mismatch. Please run hyprpm update to fix those.\n");
|
||||||
case HEADERS_NOT_HYPRLAND: return failureString("It doesn't seem you are running on hyprland.\n");
|
case HEADERS_NOT_HYPRLAND: return failureString("It doesn't seem you are running on hyprland.\n");
|
||||||
case HEADERS_MISSING: return failureString("Headers missing. Please run hyprpm update to fix those.\n");
|
case HEADERS_MISSING: return failureString("Headers missing. Please run hyprpm update to fix those.\n");
|
||||||
|
case HEADERS_ABI_MISMATCH: return failureString("ABI is mismatched. Please run hyprpm update to fix that.\n");
|
||||||
case HEADERS_DUPLICATED: {
|
case HEADERS_DUPLICATED: {
|
||||||
return failureString("Headers duplicated!!! This is a very bad sign.\n"
|
return failureString("Headers duplicated!!! This is a very bad sign.\n"
|
||||||
"This could be due to e.g. installing hyprland manually while a system package of hyprland is also installed.\n"
|
"This could be due to e.g. installing hyprland manually while a system package of hyprland is also installed.\n"
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include "Plugin.hpp"
|
||||||
|
|
||||||
enum eHeadersErrors {
|
enum eHeadersErrors {
|
||||||
HEADERS_OK = 0,
|
HEADERS_OK = 0,
|
||||||
|
|
@ -11,6 +13,7 @@ enum eHeadersErrors {
|
||||||
HEADERS_MISSING,
|
HEADERS_MISSING,
|
||||||
HEADERS_CORRUPTED,
|
HEADERS_CORRUPTED,
|
||||||
HEADERS_MISMATCHED,
|
HEADERS_MISMATCHED,
|
||||||
|
HEADERS_ABI_MISMATCH,
|
||||||
HEADERS_DUPLICATED
|
HEADERS_DUPLICATED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -36,6 +39,7 @@ struct SHyprlandVersion {
|
||||||
std::string branch;
|
std::string branch;
|
||||||
std::string hash;
|
std::string hash;
|
||||||
std::string date;
|
std::string date;
|
||||||
|
std::string abiHash;
|
||||||
int commits = 0;
|
int commits = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -44,7 +48,7 @@ class CPluginManager {
|
||||||
CPluginManager();
|
CPluginManager();
|
||||||
|
|
||||||
bool addNewPluginRepo(const std::string& url, const std::string& rev);
|
bool addNewPluginRepo(const std::string& url, const std::string& rev);
|
||||||
bool removePluginRepo(const std::string& urlOrName);
|
bool removePluginRepo(const SPluginRepoIdentifier identifier);
|
||||||
|
|
||||||
eHeadersErrors headersValid();
|
eHeadersErrors headersValid();
|
||||||
bool updateHeaders(bool force = false);
|
bool updateHeaders(bool force = false);
|
||||||
|
|
@ -52,8 +56,8 @@ class CPluginManager {
|
||||||
|
|
||||||
void listAllPlugins();
|
void listAllPlugins();
|
||||||
|
|
||||||
bool enablePlugin(const std::string& name);
|
bool enablePlugin(const SPluginRepoIdentifier identifier);
|
||||||
bool disablePlugin(const std::string& name);
|
bool disablePlugin(const SPluginRepoIdentifier identifier);
|
||||||
ePluginLoadStateReturn ensurePluginsLoadState(bool forceReload = false);
|
ePluginLoadStateReturn ensurePluginsLoadState(bool forceReload = false);
|
||||||
|
|
||||||
bool loadUnloadPlugin(const std::string& path, bool load);
|
bool loadUnloadPlugin(const std::string& path, bool load);
|
||||||
|
|
|
||||||
|
|
@ -13,25 +13,25 @@ using namespace Hyprutils::Utils;
|
||||||
|
|
||||||
constexpr std::string_view HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
|
constexpr std::string_view HELP = R"#(┏ hyprpm, a Hyprland Plugin Manager
|
||||||
┃
|
┃
|
||||||
┣ add [url] [git rev] → Install a new plugin repository from git. Git revision
|
┣ add <url> [git rev] → Install a new plugin repository from git. Git revision
|
||||||
┃ is optional, when set, commit locks are ignored.
|
┃ is optional, when set, commit locks are ignored.
|
||||||
┣ remove [url/name] → Remove an installed plugin repository.
|
┣ remove <url|name|author/name> → Remove an installed plugin repository.
|
||||||
┣ enable [name] → Enable a plugin.
|
┣ enable <name|author/name> → Enable a plugin.
|
||||||
┣ disable [name] → Disable a plugin.
|
┣ disable <name|author/name> → Disable a plugin.
|
||||||
┣ update → Check and update all plugins if needed.
|
┣ update → Check and update all plugins if needed.
|
||||||
┣ reload → Reload hyprpm state. Ensure all enabled plugins are loaded.
|
┣ reload → Reload hyprpm state. Ensure all enabled plugins are loaded.
|
||||||
┣ list → List all installed plugins.
|
┣ list → List all installed plugins.
|
||||||
┣ purge-cache → Remove the entire hyprpm cache, built plugins, hyprpm settings and headers.
|
┣ purge-cache → Remove the entire hyprpm cache, built plugins, hyprpm settings and headers.
|
||||||
┃
|
┃
|
||||||
┣ Flags:
|
┣ Flags:
|
||||||
┃
|
┃
|
||||||
┣ --notify | -n → Send a hyprland notification for important events (including both successes and fail events).
|
┣ --notify | -n → Send a hyprland notification confirming successful plugin load.
|
||||||
┣ --notify-fail | -nn → Send a hyprland notification for fail events only.
|
┃ Warnings/Errors trigger notifications regardless of this flag.
|
||||||
┣ --help | -h → Show this menu.
|
┣ --help | -h → Show this menu.
|
||||||
┣ --verbose | -v → Enable too much logging.
|
┣ --verbose | -v → Enable too much logging.
|
||||||
┣ --force | -f → Force an operation ignoring checks (e.g. update -f).
|
┣ --force | -f → Force an operation ignoring checks (e.g. update -f).
|
||||||
┣ --no-shallow | -s → Disable shallow cloning of Hyprland sources.
|
┣ --no-shallow | -s → Disable shallow cloning of Hyprland sources.
|
||||||
┣ --hl-url | → Pass a custom hyprland source url.
|
┣ --hl-url | → Pass a custom hyprland source url.
|
||||||
┗
|
┗
|
||||||
)#";
|
)#";
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ int main(int argc, char** argv, char** envp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> command;
|
std::vector<std::string> command;
|
||||||
bool notify = false, notifyFail = false, verbose = false, force = false, noShallow = false;
|
bool notify = false, verbose = false, force = false, noShallow = false;
|
||||||
std::string customHlUrl;
|
std::string customHlUrl;
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
|
@ -58,7 +58,9 @@ int main(int argc, char** argv, char** envp) {
|
||||||
} else if (ARGS[i] == "--notify" || ARGS[i] == "-n") {
|
} else if (ARGS[i] == "--notify" || ARGS[i] == "-n") {
|
||||||
notify = true;
|
notify = true;
|
||||||
} else if (ARGS[i] == "--notify-fail" || ARGS[i] == "-nn") {
|
} else if (ARGS[i] == "--notify-fail" || ARGS[i] == "-nn") {
|
||||||
notifyFail = notify = true;
|
// TODO: Deprecated since v.053.0. Remove in version>0.56.0
|
||||||
|
std::println(stderr, "{}", failureString("Deprececated flag."));
|
||||||
|
g_pPluginManager->notify(ICON_INFO, 0, 10000, "[hyprpm] -n flag is deprecated, see hyprpm --help.");
|
||||||
} else if (ARGS[i] == "--verbose" || ARGS[i] == "-v") {
|
} else if (ARGS[i] == "--verbose" || ARGS[i] == "-v") {
|
||||||
verbose = true;
|
verbose = true;
|
||||||
} else if (ARGS[i] == "--no-shallow" || ARGS[i] == "-s") {
|
} else if (ARGS[i] == "--no-shallow" || ARGS[i] == "-s") {
|
||||||
|
|
@ -104,7 +106,7 @@ int main(int argc, char** argv, char** envp) {
|
||||||
const auto HLVER = g_pPluginManager->getHyprlandVersion();
|
const auto HLVER = g_pPluginManager->getHyprlandVersion();
|
||||||
auto GLOBALSTATE = DataState::getGlobalState();
|
auto GLOBALSTATE = DataState::getGlobalState();
|
||||||
|
|
||||||
if (GLOBALSTATE.headersHashCompiled != HLVER.hash) {
|
if (GLOBALSTATE.headersAbiCompiled != HLVER.abiHash) {
|
||||||
std::println(stderr, "{}", failureString("Headers outdated, please run hyprpm update."));
|
std::println(stderr, "{}", failureString("Headers outdated, please run hyprpm update."));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +126,7 @@ int main(int argc, char** argv, char** envp) {
|
||||||
NSys::root::cacheSudo();
|
NSys::root::cacheSudo();
|
||||||
CScopeGuard x([] { NSys::root::dropSudo(); });
|
CScopeGuard x([] { NSys::root::dropSudo(); });
|
||||||
|
|
||||||
return g_pPluginManager->removePluginRepo(command[1]) ? 0 : 1;
|
return g_pPluginManager->removePluginRepo(SPluginRepoIdentifier::fromString(command[1])) ? 0 : 1;
|
||||||
} else if (command[0] == "update") {
|
} else if (command[0] == "update") {
|
||||||
NSys::root::cacheSudo();
|
NSys::root::cacheSudo();
|
||||||
CScopeGuard x([] { NSys::root::dropSudo(); });
|
CScopeGuard x([] { NSys::root::dropSudo(); });
|
||||||
|
|
@ -135,7 +137,7 @@ int main(int argc, char** argv, char** envp) {
|
||||||
if (headers) {
|
if (headers) {
|
||||||
const auto HLVER = g_pPluginManager->getHyprlandVersion(false);
|
const auto HLVER = g_pPluginManager->getHyprlandVersion(false);
|
||||||
auto GLOBALSTATE = DataState::getGlobalState();
|
auto GLOBALSTATE = DataState::getGlobalState();
|
||||||
const auto COMPILEDOUTDATED = HLVER.hash != GLOBALSTATE.headersHashCompiled;
|
const auto COMPILEDOUTDATED = HLVER.abiHash != GLOBALSTATE.headersAbiCompiled;
|
||||||
|
|
||||||
bool ret1 = g_pPluginManager->updatePlugins(!headersValid || force || COMPILEDOUTDATED);
|
bool ret1 = g_pPluginManager->updatePlugins(!headersValid || force || COMPILEDOUTDATED);
|
||||||
|
|
||||||
|
|
@ -149,15 +151,16 @@ int main(int argc, char** argv, char** envp) {
|
||||||
|
|
||||||
if (ret2 != LOADSTATE_OK)
|
if (ret2 != LOADSTATE_OK)
|
||||||
return 1;
|
return 1;
|
||||||
} else if (notify)
|
} else {
|
||||||
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Couldn't update headers");
|
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Couldn't update headers");
|
||||||
|
}
|
||||||
} else if (command[0] == "enable") {
|
} else if (command[0] == "enable") {
|
||||||
if (command.size() < 2) {
|
if (command.size() < 2) {
|
||||||
std::println(stderr, "{}", failureString("Not enough args for enable."));
|
std::println(stderr, "{}", failureString("Not enough args for enable."));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_pPluginManager->enablePlugin(command[1])) {
|
if (!g_pPluginManager->enablePlugin(SPluginRepoIdentifier::fromString(command[1]))) {
|
||||||
std::println(stderr, "{}", failureString("Couldn't enable plugin (missing?)"));
|
std::println(stderr, "{}", failureString("Couldn't enable plugin (missing?)"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -178,7 +181,7 @@ int main(int argc, char** argv, char** envp) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_pPluginManager->disablePlugin(command[1])) {
|
if (!g_pPluginManager->disablePlugin(SPluginRepoIdentifier::fromString(command[1]))) {
|
||||||
std::println(stderr, "{}", failureString("Couldn't disable plugin (missing?)"));
|
std::println(stderr, "{}", failureString("Couldn't disable plugin (missing?)"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -194,19 +197,17 @@ int main(int argc, char** argv, char** envp) {
|
||||||
auto ret = g_pPluginManager->ensurePluginsLoadState(force);
|
auto ret = g_pPluginManager->ensurePluginsLoadState(force);
|
||||||
|
|
||||||
if (ret != LOADSTATE_OK) {
|
if (ret != LOADSTATE_OK) {
|
||||||
if (notify) {
|
switch (ret) {
|
||||||
switch (ret) {
|
case LOADSTATE_FAIL:
|
||||||
case LOADSTATE_FAIL:
|
case LOADSTATE_PARTIAL_FAIL: g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins"); break;
|
||||||
case LOADSTATE_PARTIAL_FAIL: g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins"); break;
|
case LOADSTATE_HEADERS_OUTDATED:
|
||||||
case LOADSTATE_HEADERS_OUTDATED:
|
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins: Outdated headers. Please run hyprpm update manually.");
|
||||||
g_pPluginManager->notify(ICON_ERROR, 0, 10000, "[hyprpm] Failed to load plugins: Outdated headers. Please run hyprpm update manually.");
|
break;
|
||||||
break;
|
default: break;
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else if (notify && !notifyFail) {
|
} else if (notify) {
|
||||||
g_pPluginManager->notify(ICON_OK, 0, 4000, "[hyprpm] Loaded plugins");
|
g_pPluginManager->notify(ICON_OK, 0, 4000, "[hyprpm] Loaded plugins");
|
||||||
}
|
}
|
||||||
} else if (command[0] == "purge-cache") {
|
} else if (command[0] == "purge-cache") {
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
globber = run_command('sh', '-c', 'find . -name "*.cpp" | sort', check: true)
|
|
||||||
src = globber.stdout().strip().split('\n')
|
|
||||||
|
|
||||||
executable(
|
|
||||||
'hyprpm',
|
|
||||||
src,
|
|
||||||
dependencies: [
|
|
||||||
dependency('hyprutils', version: '>= 0.1.1'),
|
|
||||||
dependency('threads'),
|
|
||||||
dependency('tomlplusplus'),
|
|
||||||
dependency('glaze', method: 'cmake'),
|
|
||||||
],
|
|
||||||
install: true,
|
|
||||||
)
|
|
||||||
|
|
||||||
install_data(
|
|
||||||
'../hyprpm.bash',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'bash-completion/completions'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
rename: 'hyprpm',
|
|
||||||
)
|
|
||||||
install_data(
|
|
||||||
'../hyprpm.fish',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'fish/vendor_completions.d'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
)
|
|
||||||
install_data(
|
|
||||||
'../hyprpm.zsh',
|
|
||||||
install_dir: join_paths(get_option('datadir'), 'zsh/site-functions'),
|
|
||||||
install_tag: 'runtime',
|
|
||||||
rename: '_hyprpm',
|
|
||||||
)
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
#include <src/managers/input/InputManager.hpp>
|
#include <src/managers/input/InputManager.hpp>
|
||||||
#include <src/managers/PointerManager.hpp>
|
#include <src/managers/PointerManager.hpp>
|
||||||
#include <src/managers/input/trackpad/TrackpadGestures.hpp>
|
#include <src/managers/input/trackpad/TrackpadGestures.hpp>
|
||||||
|
#include <src/desktop/rule/windowRule/WindowRuleEffectContainer.hpp>
|
||||||
|
#include <src/desktop/rule/windowRule/WindowRuleApplicator.hpp>
|
||||||
#include <src/Compositor.hpp>
|
#include <src/Compositor.hpp>
|
||||||
|
#include <src/desktop/state/FocusState.hpp>
|
||||||
#undef private
|
#undef private
|
||||||
|
|
||||||
#include <hyprutils/utils/ScopeGuard.hpp>
|
#include <hyprutils/utils/ScopeGuard.hpp>
|
||||||
|
|
@ -43,7 +46,7 @@ static SDispatchResult test(std::string in) {
|
||||||
|
|
||||||
// Trigger a snap move event for the active window
|
// Trigger a snap move event for the active window
|
||||||
static SDispatchResult snapMove(std::string in) {
|
static SDispatchResult snapMove(std::string in) {
|
||||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||||
if (!PLASTWINDOW->m_isFloating)
|
if (!PLASTWINDOW->m_isFloating)
|
||||||
return {.success = false, .error = "Window must be floating"};
|
return {.success = false, .error = "Window must be floating"};
|
||||||
|
|
||||||
|
|
@ -210,7 +213,7 @@ static SDispatchResult scroll(std::string in) {
|
||||||
by = std::stod(in);
|
by = std::stod(in);
|
||||||
} catch (...) { return SDispatchResult{.success = false, .error = "invalid input"}; }
|
} catch (...) { return SDispatchResult{.success = false, .error = "invalid input"}; }
|
||||||
|
|
||||||
Debug::log(LOG, "tester: scrolling by {}", by);
|
Log::logger->log(Log::DEBUG, "tester: scrolling by {}", by);
|
||||||
|
|
||||||
g_mouse->m_pointerEvents.axis.emit(IPointer::SAxisEvent{
|
g_mouse->m_pointerEvents.axis.emit(IPointer::SAxisEvent{
|
||||||
.delta = by,
|
.delta = by,
|
||||||
|
|
@ -222,7 +225,7 @@ static SDispatchResult scroll(std::string in) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDispatchResult keybind(std::string in) {
|
static SDispatchResult keybind(std::string in) {
|
||||||
CVarList data(in);
|
CVarList2 data(std::move(in));
|
||||||
// 0 = release, 1 = press
|
// 0 = release, 1 = press
|
||||||
bool press;
|
bool press;
|
||||||
// See src/devices/IKeyboard.hpp : eKeyboardModifiers for modifier bitmasks
|
// See src/devices/IKeyboard.hpp : eKeyboardModifiers for modifier bitmasks
|
||||||
|
|
@ -231,9 +234,9 @@ static SDispatchResult keybind(std::string in) {
|
||||||
// keycode
|
// keycode
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
try {
|
try {
|
||||||
press = std::stoul(data[0]) == 1;
|
press = std::stoul(std::string{data[0]}) == 1;
|
||||||
modifier = std::stoul(data[1]);
|
modifier = std::stoul(std::string{data[1]});
|
||||||
key = std::stoul(data[2]) - 8; // xkb offset
|
key = std::stoul(std::string{data[2]}) - 8; // xkb offset
|
||||||
} catch (...) { return {.success = false, .error = "invalid input"}; }
|
} catch (...) { return {.success = false, .error = "invalid input"}; }
|
||||||
|
|
||||||
uint32_t modifierMask = 0;
|
uint32_t modifierMask = 0;
|
||||||
|
|
@ -245,6 +248,32 @@ static SDispatchResult keybind(std::string in) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Desktop::Rule::CWindowRuleEffectContainer::storageType ruleIDX = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
static SDispatchResult addRule(std::string in) {
|
||||||
|
ruleIDX = Desktop::Rule::windowEffects()->registerEffect("plugin_rule");
|
||||||
|
|
||||||
|
if (Desktop::Rule::windowEffects()->registerEffect("plugin_rule") != ruleIDX)
|
||||||
|
return {.success = false, .error = "re-registering returned a different id?"};
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
static SDispatchResult checkRule(std::string in) {
|
||||||
|
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||||
|
|
||||||
|
if (!PLASTWINDOW)
|
||||||
|
return {.success = false, .error = "No window"};
|
||||||
|
|
||||||
|
if (!PLASTWINDOW->m_ruleApplicator->m_otherProps.props.contains(ruleIDX))
|
||||||
|
return {.success = false, .error = "No rule"};
|
||||||
|
|
||||||
|
if (PLASTWINDOW->m_ruleApplicator->m_otherProps.props[ruleIDX]->effect != "effect")
|
||||||
|
return {.success = false, .error = "Effect isn't \"effect\""};
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
PHANDLE = handle;
|
PHANDLE = handle;
|
||||||
|
|
||||||
|
|
@ -255,6 +284,8 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:gesture", ::simulateGesture);
|
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:gesture", ::simulateGesture);
|
||||||
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:scroll", ::scroll);
|
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:scroll", ::scroll);
|
||||||
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:keybind", ::keybind);
|
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:keybind", ::keybind);
|
||||||
|
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:add_rule", ::addRule);
|
||||||
|
HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:check_rule", ::checkRule);
|
||||||
|
|
||||||
// init mouse
|
// init mouse
|
||||||
g_mouse = CTestMouse::create(false);
|
g_mouse = CTestMouse::create(false);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,17 @@ namespace Colors {
|
||||||
constexpr const char* RESET = "\x1b[0m";
|
constexpr const char* RESET = "\x1b[0m";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define EXPECT_MAX_DELTA(expr, desired, delta) \
|
||||||
|
if (const auto RESULT = expr; std::abs(RESULT - (desired)) > delta) { \
|
||||||
|
NLog::log("{}Failed: {}{}, expected max delta of {}, got delta {} ({} - {}). Source: {}@{}.", Colors::RED, Colors::RESET, #expr, delta, (RESULT - (desired)), RESULT, \
|
||||||
|
desired, __FILE__, __LINE__); \
|
||||||
|
ret = 1; \
|
||||||
|
TESTS_FAILED++; \
|
||||||
|
} else { \
|
||||||
|
NLog::log("{}Passed: {}{}. Got {}", Colors::GREEN, Colors::RESET, #expr, (RESULT - (desired))); \
|
||||||
|
TESTS_PASSED++; \
|
||||||
|
}
|
||||||
|
|
||||||
#define EXPECT(expr, val) \
|
#define EXPECT(expr, val) \
|
||||||
if (const auto RESULT = expr; RESULT != (val)) { \
|
if (const auto RESULT = expr; RESULT != (val)) { \
|
||||||
NLog::log("{}Failed: {}{}, expected {}, got {}. Source: {}@{}.", Colors::RED, Colors::RESET, #expr, val, RESULT, __FILE__, __LINE__); \
|
NLog::log("{}Failed: {}{}, expected {}, got {}. Source: {}@{}.", Colors::RED, Colors::RESET, #expr, val, RESULT, __FILE__, __LINE__); \
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ static bool startClient(SClient& client) {
|
||||||
// wait for window to appear
|
// wait for window to appear
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||||
|
|
||||||
if (getFromSocket(std::format("/dispatch setprop pid:{} noanim 1", client.proc->pid())) != "ok") {
|
if (getFromSocket(std::format("/dispatch setprop pid:{} no_anim 1", client.proc->pid())) != "ok") {
|
||||||
NLog::log("{}Failed to disable animations for client window", Colors::RED, ret);
|
NLog::log("{}Failed to disable animations for client window", Colors::RED, ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +130,7 @@ static bool test() {
|
||||||
EXPECT(sendScroll(10), true);
|
EXPECT(sendScroll(10), true);
|
||||||
EXPECT(getLastDelta(client), 30);
|
EXPECT(getLastDelta(client), 30);
|
||||||
|
|
||||||
EXPECT(getFromSocket("r/dispatch setprop active scrollmouse 4"), "ok");
|
EXPECT(getFromSocket("r/dispatch setprop active scroll_mouse 4"), "ok");
|
||||||
EXPECT(sendScroll(10), true);
|
EXPECT(sendScroll(10), true);
|
||||||
EXPECT(getLastDelta(client), 40);
|
EXPECT(getLastDelta(client), 40);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ static bool startClient(SClient& client) {
|
||||||
// wait for window to appear
|
// wait for window to appear
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||||
|
|
||||||
if (getFromSocket(std::format("/dispatch setprop pid:{} noanim 1", client.proc->pid())) != "ok") {
|
if (getFromSocket(std::format("/dispatch setprop pid:{} no_anim 1", client.proc->pid())) != "ok") {
|
||||||
NLog::log("{}Failed to disable animations for client window", Colors::RED, ret);
|
NLog::log("{}Failed to disable animations for client window", Colors::RED, ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ static void testFloatClamp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
OK(getFromSocket("/keyword dwindle:force_split 2"));
|
OK(getFromSocket("/keyword dwindle:force_split 2"));
|
||||||
|
OK(getFromSocket("/keyword monitor HEADLESS-2, addreserved, 0, 20, 0, 20"));
|
||||||
OK(getFromSocket("/dispatch focuswindow class:c"));
|
OK(getFromSocket("/dispatch focuswindow class:c"));
|
||||||
OK(getFromSocket("/dispatch setfloating class:c"));
|
OK(getFromSocket("/dispatch setfloating class:c"));
|
||||||
OK(getFromSocket("/dispatch resizewindowpixel exact 1200 900,class:c"));
|
OK(getFromSocket("/dispatch resizewindowpixel exact 1200 900,class:c"));
|
||||||
|
|
@ -24,7 +25,7 @@ static void testFloatClamp() {
|
||||||
|
|
||||||
{
|
{
|
||||||
auto str = getFromSocket("/clients");
|
auto str = getFromSocket("/clients");
|
||||||
EXPECT_CONTAINS(str, "at: 718,178");
|
EXPECT_CONTAINS(str, "at: 698,158");
|
||||||
EXPECT_CONTAINS(str, "size: 1200,900");
|
EXPECT_CONTAINS(str, "size: 1200,900");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,33 @@ static bool test() {
|
||||||
// The cursor should have moved because of the gesture
|
// The cursor should have moved because of the gesture
|
||||||
EXPECT(cursorPos1 != cursorPos2, true);
|
EXPECT(cursorPos1 != cursorPos2, true);
|
||||||
|
|
||||||
|
// Test that `workspace previous` works correctly after a workspace gesture.
|
||||||
|
{
|
||||||
|
OK(getFromSocket("/keyword gestures:workspace_swipe_invert 0"));
|
||||||
|
OK(getFromSocket("/keyword gestures:workspace_swipe_create_new 1"));
|
||||||
|
OK(getFromSocket("/dispatch workspace 3"));
|
||||||
|
|
||||||
|
// Come to workspace 5 from workspace 3: 5 will remember that.
|
||||||
|
OK(getFromSocket("/dispatch workspace 5"));
|
||||||
|
Tests::spawnKitty(); // Keep workspace 5 open
|
||||||
|
|
||||||
|
// Swipe from 1 to 5: 5 shall remember that.
|
||||||
|
OK(getFromSocket("/dispatch workspace 1"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:alt 1"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:gesture right,3"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:alt 0"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 5 (5)");
|
||||||
|
|
||||||
|
// Must return to 1 rather than 3
|
||||||
|
OK(getFromSocket("/dispatch workspace previous"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 1 (1)");
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch workspace previous"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activeworkspace"), "ID 5 (5)");
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch workspace 1"));
|
||||||
|
}
|
||||||
|
|
||||||
// kill all
|
// kill all
|
||||||
NLog::log("{}Killing all windows", Colors::YELLOW);
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
|
|
|
||||||
|
|
@ -56,82 +56,82 @@ static bool testGetprop() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// animationstyle
|
// animation
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animationstyle"), "(unset)");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation"), "(unset)");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animationstyle -j"), R"({"animationstyle": ""})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation -j"), R"({"animation": ""})");
|
||||||
getFromSocket("/dispatch setprop class:kitty animationstyle teststyle");
|
getFromSocket("/dispatch setprop class:kitty animation teststyle");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animationstyle"), "teststyle");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation"), "teststyle");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animationstyle -j"), R"({"animationstyle": "teststyle"})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty animation -j"), R"({"animation": "teststyle"})");
|
||||||
|
|
||||||
// maxsize
|
// max_size
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty maxsize"), "inf inf");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size"), "inf inf");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty maxsize -j"), R"({"maxsize": [null,null]})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size -j"), R"({"max_size": [null,null]})");
|
||||||
getFromSocket("/dispatch setprop class:kitty maxsize 200 150");
|
getFromSocket("/dispatch setprop class:kitty max_size 200 150");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty maxsize"), "200 150");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size"), "200 150");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty maxsize -j"), R"({"maxsize": [200,150]})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty max_size -j"), R"({"max_size": [200,150]})");
|
||||||
|
|
||||||
// minsize
|
// min_size
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty minsize"), "20 20");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size"), "20 20");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty minsize -j"), R"({"minsize": [20,20]})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size -j"), R"({"min_size": [20,20]})");
|
||||||
getFromSocket("/dispatch setprop class:kitty minsize 100 50");
|
getFromSocket("/dispatch setprop class:kitty min_size 100 50");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty minsize"), "100 50");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size"), "100 50");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty minsize -j"), R"({"minsize": [100,50]})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty min_size -j"), R"({"min_size": [100,50]})");
|
||||||
|
|
||||||
// alpha
|
// opacity
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alpha"), "1");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity"), "1");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alpha -j"), R"({"alpha": 1})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity -j"), R"({"opacity": 1})");
|
||||||
getFromSocket("/dispatch setprop class:kitty alpha 0.3");
|
getFromSocket("/dispatch setprop class:kitty opacity 0.3");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alpha"), "0.3");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity"), "0.3");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alpha -j"), R"({"alpha": 0.3})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity -j"), R"({"opacity": 0.3})");
|
||||||
|
|
||||||
// alphainactive
|
// opacity_inactive
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactive"), "1");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive"), "1");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactive -j"), R"({"alphainactive": 1})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive -j"), R"({"opacity_inactive": 1})");
|
||||||
getFromSocket("/dispatch setprop class:kitty alphainactive 0.5");
|
getFromSocket("/dispatch setprop class:kitty opacity_inactive 0.5");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactive"), "0.5");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive"), "0.5");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactive -j"), R"({"alphainactive": 0.5})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive -j"), R"({"opacity_inactive": 0.5})");
|
||||||
|
|
||||||
// alphafullscreen
|
// opacity_fullscreen
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreen"), "1");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen"), "1");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreen -j"), R"({"alphafullscreen": 1})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen -j"), R"({"opacity_fullscreen": 1})");
|
||||||
getFromSocket("/dispatch setprop class:kitty alphafullscreen 0.75");
|
getFromSocket("/dispatch setprop class:kitty opacity_fullscreen 0.75");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreen"), "0.75");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen"), "0.75");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreen -j"), R"({"alphafullscreen": 0.75})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen -j"), R"({"opacity_fullscreen": 0.75})");
|
||||||
|
|
||||||
// alphaoverride
|
// opacity_override
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphaoverride"), "false");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override"), "false");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphaoverride -j"), R"({"alphaoverride": false})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override -j"), R"({"opacity_override": false})");
|
||||||
getFromSocket("/dispatch setprop class:kitty alphaoverride true");
|
getFromSocket("/dispatch setprop class:kitty opacity_override true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphaoverride"), "true");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override"), "true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphaoverride -j"), R"({"alphaoverride": true})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_override -j"), R"({"opacity_override": true})");
|
||||||
|
|
||||||
// alphainactiveoverride
|
// opacity_inactive_override
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactiveoverride"), "false");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override"), "false");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactiveoverride -j"), R"({"alphainactiveoverride": false})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override -j"), R"({"opacity_inactive_override": false})");
|
||||||
getFromSocket("/dispatch setprop class:kitty alphainactiveoverride true");
|
getFromSocket("/dispatch setprop class:kitty opacity_inactive_override true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactiveoverride"), "true");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override"), "true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphainactiveoverride -j"), R"({"alphainactiveoverride": true})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_inactive_override -j"), R"({"opacity_inactive_override": true})");
|
||||||
|
|
||||||
// alphafullscreenoverride
|
// opacity_fullscreen_override
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreenoverride"), "false");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override"), "false");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreenoverride -j"), R"({"alphafullscreenoverride": false})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override -j"), R"({"opacity_fullscreen_override": false})");
|
||||||
getFromSocket("/dispatch setprop class:kitty alphafullscreenoverride true");
|
getFromSocket("/dispatch setprop class:kitty opacity_fullscreen_override true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreenoverride"), "true");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override"), "true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty alphafullscreenoverride -j"), R"({"alphafullscreenoverride": true})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty opacity_fullscreen_override -j"), R"({"opacity_fullscreen_override": true})");
|
||||||
|
|
||||||
// activebordercolor
|
// active_border_color
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty activebordercolor"), "ee33ccff ee00ff99 45deg");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color"), "ee33ccff ee00ff99 45deg");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty activebordercolor -j"), R"({"activebordercolor": "ee33ccff ee00ff99 45deg"})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color -j"), R"({"active_border_color": "ee33ccff ee00ff99 45deg"})");
|
||||||
getFromSocket("/dispatch setprop class:kitty activebordercolor rgb(abcdef)");
|
getFromSocket("/dispatch setprop class:kitty active_border_color rgb(abcdef)");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty activebordercolor"), "ffabcdef 0deg");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color"), "ffabcdef 0deg");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty activebordercolor -j"), R"({"activebordercolor": "ffabcdef 0deg"})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty active_border_color -j"), R"({"active_border_color": "ffabcdef 0deg"})");
|
||||||
|
|
||||||
// bool window properties
|
// bool window properties
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allowsinput"), "false");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input"), "false");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allowsinput -j"), R"({"allowsinput": false})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input -j"), R"({"allows_input": false})");
|
||||||
getFromSocket("/dispatch setprop class:kitty allowsinput true");
|
getFromSocket("/dispatch setprop class:kitty allows_input true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allowsinput"), "true");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input"), "true");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allowsinput -j"), R"({"allowsinput": true})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty allows_input -j"), R"({"allows_input": true})");
|
||||||
|
|
||||||
// int window properties
|
// int window properties
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding"), "10");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding"), "10");
|
||||||
|
|
@ -141,16 +141,16 @@ static bool testGetprop() {
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding -j"), R"({"rounding": 4})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding -j"), R"({"rounding": 4})");
|
||||||
|
|
||||||
// float window properties
|
// float window properties
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty roundingpower"), "2");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power"), "2");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty roundingpower -j"), R"({"roundingpower": 2})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power -j"), R"({"rounding_power": 2})");
|
||||||
getFromSocket("/dispatch setprop class:kitty roundingpower 1.25");
|
getFromSocket("/dispatch setprop class:kitty rounding_power 1.25");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty roundingpower"), "1.25");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power"), "1.25");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty roundingpower -j"), R"({"roundingpower": 1.25})");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty rounding_power -j"), R"({"rounding_power": 1.25})");
|
||||||
|
|
||||||
// errors
|
// errors
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop"), "not enough args");
|
EXPECT(getCommandStdOut("hyprctl getprop"), "not enough args");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty"), "not enough args");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty"), "not enough args");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:nonexistantclass animationstyle"), "window not found");
|
EXPECT(getCommandStdOut("hyprctl getprop class:nonexistantclass animation"), "window not found");
|
||||||
EXPECT(getCommandStdOut("hyprctl getprop class:kitty nonexistantprop"), "prop not found");
|
EXPECT(getCommandStdOut("hyprctl getprop class:kitty nonexistantprop"), "prop not found");
|
||||||
|
|
||||||
// kill all
|
// kill all
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,17 @@ static bool checkFlag() {
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool attemptCheckFlag(int attempts, int intervalMs) {
|
||||||
|
for (int i = 0; i < attempts; i++) {
|
||||||
|
if (checkFlag())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(intervalMs));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string readKittyOutput() {
|
static std::string readKittyOutput() {
|
||||||
std::string output = Tests::execAndGet("kitten @ --to unix:/tmp/hyprtester-kitty.sock get-text --extent all");
|
std::string output = Tests::execAndGet("kitten @ --to unix:/tmp/hyprtester-kitty.sock get-text --extent all");
|
||||||
// chop off shell prompt
|
// chop off shell prompt
|
||||||
|
|
@ -75,8 +86,7 @@ static void testBind() {
|
||||||
// press keybind
|
// press keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
// await flag
|
// await flag
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
EXPECT(attemptCheckFlag(20, 50), true);
|
||||||
EXPECT(checkFlag(), true);
|
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
|
|
@ -88,8 +98,7 @@ static void testBindKey() {
|
||||||
// press keybind
|
// press keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 1,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,0,29"));
|
||||||
// await flag
|
// await flag
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
EXPECT(attemptCheckFlag(20, 50), true);
|
||||||
EXPECT(checkFlag(), true);
|
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
EXPECT(getFromSocket("/keyword unbind ,Y"), "ok");
|
EXPECT(getFromSocket("/keyword unbind ,Y"), "ok");
|
||||||
|
|
@ -105,7 +114,7 @@ static void testLongPress() {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
|
|
@ -122,7 +131,7 @@ static void testKeyLongPress() {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
|
|
@ -141,7 +150,7 @@ static void testLongPressRelease() {
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +167,7 @@ static void testLongPressOnlyKeyRelease() {
|
||||||
// release key, keep modifier
|
// release key, keep modifier
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
|
|
@ -171,13 +180,13 @@ static void testRepeat() {
|
||||||
// press keybind
|
// press keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
// await flag
|
// await flag
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// check that it continues repeating
|
// check that it continues repeating
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
|
|
@ -194,10 +203,10 @@ static void testKeyRepeat() {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// check that it continues repeating
|
// check that it continues repeating
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
|
|
@ -216,10 +225,12 @@ static void testRepeatRelease() {
|
||||||
// release keybind
|
// release keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
|
clearFlag();
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
// check that it is not repeating
|
// check that it is not repeating
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
}
|
}
|
||||||
|
|
@ -231,15 +242,17 @@ static void testRepeatOnlyKeyRelease() {
|
||||||
// press keybind
|
// press keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
// await flag
|
// await flag
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), true);
|
EXPECT(checkFlag(), true);
|
||||||
// release key, keep modifier
|
// release key, keep modifier
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
|
clearFlag();
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
// check that it is not repeating
|
// check that it is not repeating
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
EXPECT(checkFlag(), false);
|
EXPECT(checkFlag(), false);
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
|
|
@ -304,9 +317,9 @@ static void testShortcutLongPress() {
|
||||||
// press keybind
|
// press keybind
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,0,29"));
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
const std::string output = readKittyOutput();
|
const std::string output = readKittyOutput();
|
||||||
int yCount = Tests::countOccurrences(output, "y");
|
int yCount = Tests::countOccurrences(output, "y");
|
||||||
// sometimes 1, sometimes 2, not sure why
|
// sometimes 1, sometimes 2, not sure why
|
||||||
|
|
@ -336,7 +349,7 @@ static void testShortcutLongPressKeyRelease() {
|
||||||
// release key, keep modifier
|
// release key, keep modifier
|
||||||
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
// await repeat delay
|
// await repeat delay
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(150));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
const std::string output = readKittyOutput();
|
const std::string output = readKittyOutput();
|
||||||
// disabled: doesn't work on CI
|
// disabled: doesn't work on CI
|
||||||
// EXPECT_COUNT_STRING(output, "y", 1);
|
// EXPECT_COUNT_STRING(output, "y", 1);
|
||||||
|
|
@ -443,9 +456,39 @@ static void testSubmap() {
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void testSubmapUniversal() {
|
||||||
|
NLog::log("{}Testing submap universal", Colors::GREEN);
|
||||||
|
|
||||||
|
EXPECT(checkFlag(), false);
|
||||||
|
EXPECT(getFromSocket("/keyword bindu SUPER,Y,exec,touch " + flagFile), "ok");
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/submap"), "default");
|
||||||
|
|
||||||
|
// keybind works on default submap
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
|
EXPECT(attemptCheckFlag(30, 5), true);
|
||||||
|
|
||||||
|
// keybind works on submap1
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 1,7,30");
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 0,7,30");
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/submap"), "submap1");
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 1,7,29"));
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:keybind 0,7,29"));
|
||||||
|
EXPECT(attemptCheckFlag(30, 5), true);
|
||||||
|
|
||||||
|
// reset to default submap
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 1,0,33");
|
||||||
|
getFromSocket("/dispatch plugin:test:keybind 0,0,33");
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/submap"), "default");
|
||||||
|
|
||||||
|
EXPECT(getFromSocket("/keyword unbind SUPER,Y"), "ok");
|
||||||
|
}
|
||||||
|
|
||||||
static bool test() {
|
static bool test() {
|
||||||
NLog::log("{}Testing keybinds", Colors::GREEN);
|
NLog::log("{}Testing keybinds", Colors::GREEN);
|
||||||
|
|
||||||
|
clearFlag();
|
||||||
|
|
||||||
testBind();
|
testBind();
|
||||||
testBindKey();
|
testBindKey();
|
||||||
testLongPress();
|
testLongPress();
|
||||||
|
|
@ -462,8 +505,8 @@ static bool test() {
|
||||||
testShortcutLongPressKeyRelease();
|
testShortcutLongPressKeyRelease();
|
||||||
testShortcutRepeat();
|
testShortcutRepeat();
|
||||||
testShortcutRepeatKeyRelease();
|
testShortcutRepeatKeyRelease();
|
||||||
|
|
||||||
testSubmap();
|
testSubmap();
|
||||||
|
testSubmapUniversal();
|
||||||
|
|
||||||
clearFlag();
|
clearFlag();
|
||||||
return !ret;
|
return !ret;
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ static bool test() {
|
||||||
|
|
||||||
NLog::log("{}Testing new_window_takes_over_fullscreen", Colors::YELLOW);
|
NLog::log("{}Testing new_window_takes_over_fullscreen", Colors::YELLOW);
|
||||||
|
|
||||||
OK(getFromSocket("/keyword misc:new_window_takes_over_fullscreen 0"));
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 0"));
|
||||||
|
|
||||||
Tests::spawnKitty("kitty_A");
|
Tests::spawnKitty("kitty_A");
|
||||||
|
|
||||||
|
|
@ -73,7 +73,16 @@ static bool test() {
|
||||||
EXPECT_CONTAINS(str, "kitty_A");
|
EXPECT_CONTAINS(str, "kitty_A");
|
||||||
}
|
}
|
||||||
|
|
||||||
OK(getFromSocket("/keyword misc:new_window_takes_over_fullscreen 1"));
|
OK(getFromSocket("/dispatch focuswindow class:kitty_B"));
|
||||||
|
|
||||||
|
{
|
||||||
|
// should be ignored as per focus_under_fullscreen 0
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "fullscreen: 2");
|
||||||
|
EXPECT_CONTAINS(str, "kitty_A");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 1"));
|
||||||
|
|
||||||
Tests::spawnKitty("kitty_C");
|
Tests::spawnKitty("kitty_C");
|
||||||
|
|
||||||
|
|
@ -83,7 +92,7 @@ static bool test() {
|
||||||
EXPECT_CONTAINS(str, "kitty_C");
|
EXPECT_CONTAINS(str, "kitty_C");
|
||||||
}
|
}
|
||||||
|
|
||||||
OK(getFromSocket("/keyword misc:new_window_takes_over_fullscreen 2"));
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 2"));
|
||||||
|
|
||||||
Tests::spawnKitty("kitty_D");
|
Tests::spawnKitty("kitty_D");
|
||||||
|
|
||||||
|
|
@ -93,7 +102,7 @@ static bool test() {
|
||||||
EXPECT_CONTAINS(str, "kitty_D");
|
EXPECT_CONTAINS(str, "kitty_D");
|
||||||
}
|
}
|
||||||
|
|
||||||
OK(getFromSocket("/keyword misc:new_window_takes_over_fullscreen 0"));
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 0"));
|
||||||
|
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
|
@ -138,6 +147,7 @@ static bool test() {
|
||||||
Tests::spawnKitty("kitty_A");
|
Tests::spawnKitty("kitty_A");
|
||||||
Tests::spawnKitty("kitty_B");
|
Tests::spawnKitty("kitty_B");
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,21 +21,24 @@ static bool testTags() {
|
||||||
|
|
||||||
NLog::log("{}Testing testTag tags", Colors::YELLOW);
|
NLog::log("{}Testing testTag tags", Colors::YELLOW);
|
||||||
|
|
||||||
OK(getFromSocket("/keyword windowrule tag +testTag, class:tagged"));
|
OK(getFromSocket("/keyword windowrule[tag-test-1]:tag +testTag"));
|
||||||
OK(getFromSocket("/keyword windowrule noshadow, tag:negative:testTag"));
|
OK(getFromSocket("/keyword windowrule[tag-test-1]:match:class tagged"));
|
||||||
OK(getFromSocket("/keyword windowrule noborder, tag:testTag"));
|
OK(getFromSocket("/keyword windowrule[tag-test-2]:match:tag negative:testTag"));
|
||||||
|
OK(getFromSocket("/keyword windowrule[tag-test-2]:no_shadow true"));
|
||||||
|
OK(getFromSocket("/keyword windowrule[tag-test-3]:match:tag testTag"));
|
||||||
|
OK(getFromSocket("/keyword windowrule[tag-test-3]:no_dim true"));
|
||||||
|
|
||||||
EXPECT(Tests::windowCount(), 2);
|
EXPECT(Tests::windowCount(), 2);
|
||||||
OK(getFromSocket("/dispatch focuswindow class:tagged"));
|
OK(getFromSocket("/dispatch focuswindow class:tagged"));
|
||||||
NLog::log("{}Testing tagged window for noborder & noshadow", Colors::YELLOW);
|
NLog::log("{}Testing tagged window for no_dim 0 & no_shadow", Colors::YELLOW);
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "testTag");
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "testTag");
|
||||||
EXPECT_CONTAINS(getFromSocket("/getprop activewindow noborder"), "true");
|
EXPECT_CONTAINS(getFromSocket("/getprop activewindow no_dim"), "true");
|
||||||
EXPECT_CONTAINS(getFromSocket("/getprop activewindow noshadow"), "false");
|
EXPECT_CONTAINS(getFromSocket("/getprop activewindow no_shadow"), "false");
|
||||||
NLog::log("{}Testing untagged window for noborder & noshadow", Colors::YELLOW);
|
NLog::log("{}Testing untagged window for no_dim & no_shadow", Colors::YELLOW);
|
||||||
OK(getFromSocket("/dispatch focuswindow class:untagged"));
|
OK(getFromSocket("/dispatch focuswindow class:untagged"));
|
||||||
EXPECT_NOT_CONTAINS(getFromSocket("/activewindow"), "testTag");
|
EXPECT_NOT_CONTAINS(getFromSocket("/activewindow"), "testTag");
|
||||||
EXPECT_CONTAINS(getFromSocket("/getprop activewindow noborder"), "false");
|
EXPECT_CONTAINS(getFromSocket("/getprop activewindow no_shadow"), "true");
|
||||||
EXPECT_CONTAINS(getFromSocket("/getprop activewindow noshadow"), "true");
|
EXPECT_CONTAINS(getFromSocket("/getprop activewindow no_dim"), "false");
|
||||||
|
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
EXPECT(Tests::windowCount(), 0);
|
EXPECT(Tests::windowCount(), 0);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <thread>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <thread>
|
||||||
#include <hyprutils/os/Process.hpp>
|
#include <hyprutils/os/Process.hpp>
|
||||||
#include <hyprutils/memory/WeakPtr.hpp>
|
#include <hyprutils/memory/WeakPtr.hpp>
|
||||||
|
#include <hyprutils/string/VarList2.hpp>
|
||||||
|
|
||||||
#include "../../shared.hpp"
|
#include "../../shared.hpp"
|
||||||
#include "../../hyprctlCompat.hpp"
|
#include "../../hyprctlCompat.hpp"
|
||||||
|
|
@ -11,9 +15,9 @@
|
||||||
|
|
||||||
static int ret = 0;
|
static int ret = 0;
|
||||||
|
|
||||||
static bool spawnKitty(const std::string& class_) {
|
static bool spawnKitty(const std::string& class_, const std::vector<std::string>& args = {}) {
|
||||||
NLog::log("{}Spawning {}", Colors::YELLOW, class_);
|
NLog::log("{}Spawning {}", Colors::YELLOW, class_);
|
||||||
if (!Tests::spawnKitty(class_)) {
|
if (!Tests::spawnKitty(class_, args)) {
|
||||||
NLog::log("{}Error: {} did not spawn", Colors::RED, class_);
|
NLog::log("{}Error: {} did not spawn", Colors::RED, class_);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -131,6 +135,244 @@ static void testSwapWindow() {
|
||||||
EXPECT(Tests::windowCount(), 0);
|
EXPECT(Tests::windowCount(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void testGroupRules() {
|
||||||
|
NLog::log("{}Testing group window rules", Colors::YELLOW);
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword general:border_size 8"));
|
||||||
|
OK(getFromSocket("/keyword workspace w[tv1], bordersize:0"));
|
||||||
|
OK(getFromSocket("/keyword workspace f[1], bordersize:0"));
|
||||||
|
OK(getFromSocket("/keyword windowrule match:workspace w[tv1], border_size 0"));
|
||||||
|
OK(getFromSocket("/keyword windowrule match:workspace f[1], border_size 0"));
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("kitty_A")) {
|
||||||
|
ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("kitty_B")) {
|
||||||
|
ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "8");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch togglegroup"));
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_B"));
|
||||||
|
OK(getFromSocket("/dispatch moveintogroup l"));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch changegroupactive f"));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("kitty_C")) {
|
||||||
|
ret = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch moveoutofgroup r"));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "8");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isActiveWindow(const std::string& class_, char fullscreen, bool log = true) {
|
||||||
|
std::string activeWin = getFromSocket("/activewindow");
|
||||||
|
auto winClass = getWindowAttribute(activeWin, "class:");
|
||||||
|
auto winFullscreen = getWindowAttribute(activeWin, "fullscreen:").back();
|
||||||
|
if (winClass.substr(strlen("class: ")) == class_ && winFullscreen == fullscreen)
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
if (log)
|
||||||
|
NLog::log("{}Wrong active window: expected class {} fullscreen '{}', found class {}, fullscreen '{}'", Colors::RED, class_, fullscreen, winClass, winFullscreen);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool waitForActiveWindow(const std::string& class_, char fullscreen, int maxTries = 50) {
|
||||||
|
int cnt = 0;
|
||||||
|
while (!isActiveWindow(class_, fullscreen, false)) {
|
||||||
|
++cnt;
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
if (cnt > maxTries) {
|
||||||
|
return isActiveWindow(class_, fullscreen, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tests behavior of a window being focused when on that window's workspace
|
||||||
|
/// another fullscreen window exists.
|
||||||
|
static bool testWindowFocusOnFullscreenConflict() {
|
||||||
|
if (!spawnKitty("kitty_A"))
|
||||||
|
return false;
|
||||||
|
if (!spawnKitty("kitty_B"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword misc:focus_on_activate true"));
|
||||||
|
|
||||||
|
auto spawnKittyActivating = [] -> std::string {
|
||||||
|
// `XXXXXX` is what `mkstemp` expects to find in the string
|
||||||
|
std::string tmpFilename = (std::filesystem::temp_directory_path() / "XXXXXX").string();
|
||||||
|
int fd = mkstemp(tmpFilename.data());
|
||||||
|
if (fd < 0) {
|
||||||
|
NLog::log("{}Error: could not create tmp file: errno {}", Colors::RED, errno);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
(void)close(fd);
|
||||||
|
bool ok = spawnKitty("kitty_activating",
|
||||||
|
{"-o", "allow_remote_control=yes", "--", "/bin/sh", "-c", "while [ -f \"" + tmpFilename + "\" ]; do :; done; kitten @ focus-window; sleep infinity"});
|
||||||
|
if (!ok) {
|
||||||
|
NLog::log("{}Error: failed to spawn kitty", Colors::RED);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return tmpFilename;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Unfullscreen on conflict
|
||||||
|
{
|
||||||
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 2"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
|
||||||
|
// Dispatch-focus the same window
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
|
||||||
|
// Dispatch-focus a different window
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_B"));
|
||||||
|
EXPECT(isActiveWindow("kitty_B", '0'), true);
|
||||||
|
|
||||||
|
// Make a window that will request focus
|
||||||
|
const std::string removeToActivate = spawnKittyActivating();
|
||||||
|
if (removeToActivate.empty())
|
||||||
|
return false;
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
std::filesystem::remove(removeToActivate);
|
||||||
|
EXPECT(waitForActiveWindow("kitty_activating", '0'), true);
|
||||||
|
OK(getFromSocket("/dispatch forcekillactive"));
|
||||||
|
Tests::waitUntilWindowsN(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Take over on conflict
|
||||||
|
{
|
||||||
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 1"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
|
||||||
|
// Dispatch-focus the same window
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
|
||||||
|
// Dispatch-focus a different window
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_B"));
|
||||||
|
EXPECT(isActiveWindow("kitty_B", '2'), true);
|
||||||
|
OK(getFromSocket("/dispatch fullscreenstate 0 0"));
|
||||||
|
|
||||||
|
// Make a window that will request focus
|
||||||
|
const std::string removeToActivate = spawnKittyActivating();
|
||||||
|
if (removeToActivate.empty())
|
||||||
|
return false;
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
std::filesystem::remove(removeToActivate);
|
||||||
|
EXPECT(waitForActiveWindow("kitty_activating", '2'), true);
|
||||||
|
OK(getFromSocket("/dispatch forcekillactive"));
|
||||||
|
Tests::waitUntilWindowsN(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep the old focus on conflict
|
||||||
|
{
|
||||||
|
OK(getFromSocket("/keyword misc:on_focus_under_fullscreen 0"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
|
||||||
|
// Dispatch-focus the same window
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
|
||||||
|
// Make a window that will request focus - the setting is treated normally
|
||||||
|
const std::string removeToActivate = spawnKittyActivating();
|
||||||
|
if (removeToActivate.empty())
|
||||||
|
return false;
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(isActiveWindow("kitty_A", '2'), true);
|
||||||
|
std::filesystem::remove(removeToActivate);
|
||||||
|
EXPECT(waitForActiveWindow("kitty_A", '2'), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
NLog::log("{}Reloading config", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
|
||||||
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
|
||||||
|
EXPECT(Tests::windowCount(), 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testMaximizeSize() {
|
||||||
|
NLog::log("{}Testing maximize size", Colors::GREEN);
|
||||||
|
|
||||||
|
EXPECT(spawnKitty("kitty_A"), true);
|
||||||
|
|
||||||
|
// check kitty properties. Maximizing shouldnt change its size
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/clients");
|
||||||
|
EXPECT(str.contains("at: 22,22"), true);
|
||||||
|
EXPECT(str.contains("size: 1876,1036"), true);
|
||||||
|
EXPECT(str.contains("fullscreen: 0"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 1"));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/clients");
|
||||||
|
EXPECT(str.contains("at: 22,22"), true);
|
||||||
|
EXPECT(str.contains("size: 1876,1036"), true);
|
||||||
|
EXPECT(str.contains("fullscreen: 1"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
|
||||||
|
EXPECT(Tests::windowCount(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
static bool test() {
|
static bool test() {
|
||||||
NLog::log("{}Testing windows", Colors::GREEN);
|
NLog::log("{}Testing windows", Colors::GREEN);
|
||||||
|
|
||||||
|
|
@ -161,13 +403,13 @@ static bool test() {
|
||||||
const int MONITOR_H = 1080;
|
const int MONITOR_H = 1080;
|
||||||
|
|
||||||
const float totalAvailableHeight = MONITOR_H - (GAPSOUT * 2);
|
const float totalAvailableHeight = MONITOR_H - (GAPSOUT * 2);
|
||||||
const int HEIGHT = std::round(totalAvailableHeight) - BORDERS;
|
const int HEIGHT = std::floor(totalAvailableHeight) - BORDERS;
|
||||||
const float availableWidthForSplit = MONITOR_W - (GAPSOUT * 2) - GAPSIN;
|
const float availableWidthForSplit = MONITOR_W - (GAPSOUT * 2) - GAPSIN;
|
||||||
|
|
||||||
auto calculateFinalWidth = [&](double boxWidth, bool isLeftWindow) {
|
auto calculateFinalWidth = [&](double boxWidth, bool isLeftWindow) {
|
||||||
double gapLeft = isLeftWindow ? GAPSOUT : GAPSIN;
|
double gapLeft = isLeftWindow ? GAPSOUT : GAPSIN;
|
||||||
double gapRight = isLeftWindow ? GAPSIN : GAPSOUT;
|
double gapRight = isLeftWindow ? GAPSIN : GAPSOUT;
|
||||||
return std::round(boxWidth - gapLeft - gapRight - BORDERS);
|
return std::floor(boxWidth - gapLeft - gapRight - BORDERS);
|
||||||
};
|
};
|
||||||
|
|
||||||
double geomBoxWidthA_R1 = (availableWidthForSplit * INITIAL_RATIO / 2.0) + GAPSOUT + (GAPSIN / 2.0);
|
double geomBoxWidthA_R1 = (availableWidthForSplit * INITIAL_RATIO / 2.0) + GAPSOUT + (GAPSIN / 2.0);
|
||||||
|
|
@ -197,12 +439,38 @@ static bool test() {
|
||||||
if (!spawnKitty("kitty_B"))
|
if (!spawnKitty("kitty_B"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NLog::log("{}Expecting kitty_B size: {},{}", Colors::YELLOW, WIDTH2, HEIGHT);
|
try {
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), std::format("size: {},{}", WIDTH2, HEIGHT));
|
NLog::log("{}Expecting kitty_B size: {},{}", Colors::YELLOW, WIDTH2, HEIGHT);
|
||||||
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
{
|
||||||
NLog::log("{}Expecting kitty_A size: {},{}", Colors::YELLOW, WIDTH_A_FINAL, HEIGHT);
|
auto data = getFromSocket("/activewindow");
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), std::format("size: {},{}", WIDTH_A_FINAL, HEIGHT));
|
data = data.substr(data.find("size:") + 5);
|
||||||
|
data = data.substr(0, data.find('\n'));
|
||||||
|
|
||||||
|
Hyprutils::String::CVarList2 sizes(std::move(data), 0, ',');
|
||||||
|
|
||||||
|
EXPECT_MAX_DELTA(std::stoi(std::string{sizes[0]}), WIDTH2, 2);
|
||||||
|
EXPECT_MAX_DELTA(std::stoi(std::string{sizes[1]}), HEIGHT, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:kitty_A"));
|
||||||
|
NLog::log("{}Expecting kitty_A size: {},{}", Colors::YELLOW, WIDTH_A_FINAL, HEIGHT);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto data = getFromSocket("/activewindow");
|
||||||
|
data = data.substr(data.find("size:") + 5);
|
||||||
|
data = data.substr(0, data.find('\n'));
|
||||||
|
|
||||||
|
Hyprutils::String::CVarList2 sizes(std::move(data), 0, ',');
|
||||||
|
|
||||||
|
EXPECT_MAX_DELTA(std::stoi(std::string{sizes[0]}), WIDTH_A_FINAL, 2);
|
||||||
|
EXPECT_MAX_DELTA(std::stoi(std::string{sizes[1]}), HEIGHT, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
NLog::log("{}Exception thrown", Colors::RED);
|
||||||
|
EXPECT(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
OK(getFromSocket("/keyword dwindle:default_split_ratio 1"));
|
OK(getFromSocket("/keyword dwindle:default_split_ratio 1"));
|
||||||
}
|
}
|
||||||
|
|
@ -212,16 +480,7 @@ static bool test() {
|
||||||
getFromSocket("/dispatch exec xeyes");
|
getFromSocket("/dispatch exec xeyes");
|
||||||
|
|
||||||
NLog::log("{}Keep checking if xeyes spawned", Colors::YELLOW);
|
NLog::log("{}Keep checking if xeyes spawned", Colors::YELLOW);
|
||||||
int counter = 0;
|
Tests::waitUntilWindowsN(3);
|
||||||
while (Tests::windowCount() != 3) {
|
|
||||||
counter++;
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
||||||
|
|
||||||
if (counter > 50) {
|
|
||||||
EXPECT(Tests::windowCount(), 3);
|
|
||||||
return !ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NLog::log("{}Expecting 3 windows", Colors::YELLOW);
|
NLog::log("{}Expecting 3 windows", Colors::YELLOW);
|
||||||
EXPECT(Tests::windowCount(), 3);
|
EXPECT(Tests::windowCount(), 3);
|
||||||
|
|
@ -246,12 +505,45 @@ static bool test() {
|
||||||
|
|
||||||
testSwapWindow();
|
testSwapWindow();
|
||||||
|
|
||||||
|
getFromSocket("/dispatch workspace 1");
|
||||||
|
|
||||||
|
if (!testWindowFocusOnFullscreenConflict()) {
|
||||||
|
ret = 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLog::log("{}Testing spawning a floating window over a fullscreen window", Colors::YELLOW);
|
||||||
|
{
|
||||||
|
if (!spawnKitty("kitty_A"))
|
||||||
|
return false;
|
||||||
|
OK(getFromSocket("/dispatch fullscreen 0 set"));
|
||||||
|
EXPECT(Tests::windowCount(), 1);
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch exec [float] kitty"));
|
||||||
|
Tests::waitUntilWindowsN(2);
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:^kitty$"));
|
||||||
|
const auto focused1 = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(focused1, "class: kitty\n");
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch killwindow activewindow"));
|
||||||
|
Tests::waitUntilWindowsN(1);
|
||||||
|
|
||||||
|
// The old window should be focused again
|
||||||
|
const auto focused2 = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(focused2, "class: kitty_A\n");
|
||||||
|
|
||||||
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
|
Tests::killAllWindows();
|
||||||
|
}
|
||||||
|
|
||||||
NLog::log("{}Testing minsize/maxsize rules for tiled windows", Colors::YELLOW);
|
NLog::log("{}Testing minsize/maxsize rules for tiled windows", Colors::YELLOW);
|
||||||
{
|
{
|
||||||
// Enable the config for testing, test max/minsize for tiled windows and centering
|
// Enable the config for testing, test max/minsize for tiled windows and centering
|
||||||
OK(getFromSocket("/keyword misc:size_limits_tiled 1"));
|
OK(getFromSocket("/keyword misc:size_limits_tiled 1"));
|
||||||
OK(getFromSocket("/keyword windowrule maxsize 1500 500, class:kitty_maxsize"));
|
OK(getFromSocket("/keyword windowrule[kitty-max-rule]:match:class kitty_maxsize"));
|
||||||
OK(getFromSocket("/keyword windowrule minsize 1200 500, class:kitty_maxsize"));
|
OK(getFromSocket("/keyword windowrule[kitty-max-rule]:max_size 1500 500"));
|
||||||
|
OK(getFromSocket("r/keyword windowrule[kitty-max-rule]:min_size 1200 500"));
|
||||||
if (!spawnKitty("kitty_maxsize"))
|
if (!spawnKitty("kitty_maxsize"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -297,29 +589,162 @@ static bool test() {
|
||||||
EXPECT_CONTAINS(str, "floating: 1");
|
EXPECT_CONTAINS(str, "floating: 1");
|
||||||
EXPECT_CONTAINS(str, std::format("size: {},{}", SIZE, SIZE));
|
EXPECT_CONTAINS(str, std::format("size: {},{}", SIZE, SIZE));
|
||||||
EXPECT_NOT_CONTAINS(str, "pinned: 1");
|
EXPECT_NOT_CONTAINS(str, "pinned: 1");
|
||||||
OK(getFromSocket("/keyword windowrule plugin:someplugin:variable, class:wr_kitty"));
|
}
|
||||||
OK(getFromSocket("/keyword windowrule plugin:someplugin:variable 10, class:wr_kitty"));
|
|
||||||
OK(getFromSocket("/keyword windowrule workspace 1, class:wr_kitty"));
|
|
||||||
OK(getFromSocket("/keyword windowrule workspace special:magic, class:magic_kitty"));
|
|
||||||
|
|
||||||
if (!spawnKitty("magic_kitty"))
|
OK(getFromSocket("/keyword windowrule[wr-kitty-stuff]:opacity 0.5 0.5 override"));
|
||||||
return false;
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "special:magic");
|
{
|
||||||
|
auto str = getFromSocket("/getprop active opacity");
|
||||||
|
EXPECT_CONTAINS(str, "0.5");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword windowrule[special-magic-kitty]:match:class magic_kitty"));
|
||||||
|
OK(getFromSocket("/keyword windowrule[special-magic-kitty]:workspace special:magic"));
|
||||||
|
|
||||||
|
if (!spawnKitty("magic_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "special:magic");
|
||||||
EXPECT_NOT_CONTAINS(str, "workspace: 9");
|
EXPECT_NOT_CONTAINS(str, "workspace: 9");
|
||||||
}
|
}
|
||||||
|
|
||||||
NLog::log("{}Testing faulty rules", Colors::YELLOW);
|
if (auto str = getFromSocket("/monitors"); str.contains("magic)")) {
|
||||||
{
|
OK(getFromSocket("/dispatch togglespecialworkspace magic"));
|
||||||
const auto PARAM = "Invalid parameter";
|
|
||||||
const auto RULE = "Invalid value";
|
|
||||||
const auto NORULE = "no rules provided";
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule notarule, class:wr_kitty"), RULE)
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule class:wr_kitty"), NORULE)
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule float, class:wr_kitty, size"), PARAM)
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule float, classI:wr_kitty"), PARAM)
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/keyword windowrule workspace:, class:wr_kitty"), NORULE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
if (!spawnKitty("tag_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "floating: 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
// test rules that overlap effects but don't overlap props
|
||||||
|
OK(getFromSocket("/keyword windowrule match:class overlap_kitty, border_size 0"));
|
||||||
|
OK(getFromSocket("/keyword windowrule match:fullscreen false, border_size 10"));
|
||||||
|
|
||||||
|
if (!spawnKitty("overlap_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "10");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
// test persistent_size between floating window launches
|
||||||
|
OK(getFromSocket("/keyword windowrule match:class persistent_size_kitty, persistent_size true, float true"));
|
||||||
|
|
||||||
|
if (!spawnKitty("persistent_size_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch resizeactive exact 600 400"))
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "size: 600,400");
|
||||||
|
EXPECT_CONTAINS(str, "floating: 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
if (!spawnKitty("persistent_size_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "size: 600,400");
|
||||||
|
EXPECT_CONTAINS(str, "floating: 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword general:border_size 0"));
|
||||||
|
OK(getFromSocket("/keyword windowrule match:float true, border_size 10"));
|
||||||
|
|
||||||
|
if (!spawnKitty("border_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch togglefloating"));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "10");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch togglefloating"));
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/getprop active border_size");
|
||||||
|
EXPECT_CONTAINS(str, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
// test expression rules
|
||||||
|
OK(getFromSocket("/keyword windowrule match:class expr_kitty, float yes, size monitor_w*0.5 monitor_h*0.5, move 20+(monitor_w*0.1) monitor_h*0.5"));
|
||||||
|
|
||||||
|
if (!spawnKitty("expr_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto str = getFromSocket("/activewindow");
|
||||||
|
EXPECT_CONTAINS(str, "floating: 1");
|
||||||
|
EXPECT_CONTAINS(str, "at: 212,540");
|
||||||
|
EXPECT_CONTAINS(str, "size: 960,540");
|
||||||
|
}
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:add_rule"));
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword windowrule match:class plugin_kitty, plugin_rule effect"));
|
||||||
|
|
||||||
|
if (!spawnKitty("plugin_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:check_rule"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:add_rule"));
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/keyword windowrule[test-plugin-rule]:match:class plugin_kitty"));
|
||||||
|
OK(getFromSocket("/keyword windowrule[test-plugin-rule]:plugin_rule effect"));
|
||||||
|
|
||||||
|
if (!spawnKitty("plugin_kitty"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch plugin:test:check_rule"));
|
||||||
|
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
testGroupRules();
|
||||||
|
|
||||||
|
testMaximizeSize();
|
||||||
|
|
||||||
NLog::log("{}Reloading config", Colors::YELLOW);
|
NLog::log("{}Reloading config", Colors::YELLOW);
|
||||||
OK(getFromSocket("/reload"));
|
OK(getFromSocket("/reload"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,94 @@ using namespace Hyprutils::Utils;
|
||||||
#define UP CUniquePointer
|
#define UP CUniquePointer
|
||||||
#define SP CSharedPointer
|
#define SP CSharedPointer
|
||||||
|
|
||||||
|
static bool testAsymmetricGaps() {
|
||||||
|
NLog::log("{}Testing asymmetric gap splits", Colors::YELLOW);
|
||||||
|
{
|
||||||
|
|
||||||
|
CScopeGuard guard = {[&]() {
|
||||||
|
NLog::log("{}Cleaning up asymmetric gap test", Colors::YELLOW);
|
||||||
|
Tests::killAllWindows();
|
||||||
|
OK(getFromSocket("/reload"));
|
||||||
|
}};
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch workspace name:gap_split_test"));
|
||||||
|
OK(getFromSocket("r/keyword general:gaps_in 0"));
|
||||||
|
OK(getFromSocket("r/keyword general:border_size 0"));
|
||||||
|
OK(getFromSocket("r/keyword dwindle:split_width_multiplier 1.0"));
|
||||||
|
OK(getFromSocket("r/keyword workspace name:gap_split_test,gapsout:0 1000 0 0"));
|
||||||
|
|
||||||
|
NLog::log("{}Testing default split (force_split = 0)", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("r/keyword dwindle:force_split 0"));
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NLog::log("{}Expecting vertical split (B below A)", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
|
||||||
|
|
||||||
|
Tests::killAllWindows();
|
||||||
|
EXPECT(Tests::windowCount(), 0);
|
||||||
|
|
||||||
|
NLog::log("{}Testing force_split = 1", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("r/keyword dwindle:force_split 1"));
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NLog::log("{}Expecting vertical split (B above A)", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
|
||||||
|
|
||||||
|
NLog::log("{}Expecting horizontal split (C left of B)", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("gaps_kitty_C"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_C"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 460,0");
|
||||||
|
|
||||||
|
Tests::killAllWindows();
|
||||||
|
EXPECT(Tests::windowCount(), 0);
|
||||||
|
|
||||||
|
NLog::log("{}Testing force_split = 2", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("r/keyword dwindle:force_split 2"));
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
NLog::log("{}Expecting vertical split (B below A)", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
|
||||||
|
|
||||||
|
NLog::log("{}Expecting horizontal split (C right of A)", Colors::YELLOW);
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
||||||
|
|
||||||
|
if (!Tests::spawnKitty("gaps_kitty_C"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
||||||
|
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_C"));
|
||||||
|
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 460,0");
|
||||||
|
}
|
||||||
|
|
||||||
|
// kill all
|
||||||
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
|
Tests::killAllWindows();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool test() {
|
static bool test() {
|
||||||
NLog::log("{}Testing workspaces", Colors::GREEN);
|
NLog::log("{}Testing workspaces", Colors::GREEN);
|
||||||
|
|
||||||
|
|
@ -27,7 +115,7 @@ static bool test() {
|
||||||
|
|
||||||
// test on workspace "window"
|
// test on workspace "window"
|
||||||
NLog::log("{}Switching to workspace 1", Colors::YELLOW);
|
NLog::log("{}Switching to workspace 1", Colors::YELLOW);
|
||||||
OK(getFromSocket("/dispatch workspace 1"));
|
getFromSocket("/dispatch workspace 1");
|
||||||
|
|
||||||
NLog::log("{}Checking persistent no-mon", Colors::YELLOW);
|
NLog::log("{}Checking persistent no-mon", Colors::YELLOW);
|
||||||
OK(getFromSocket("r/keyword workspace 966,persistent:1"));
|
OK(getFromSocket("r/keyword workspace 966,persistent:1"));
|
||||||
|
|
@ -361,94 +449,7 @@ static bool test() {
|
||||||
NLog::log("{}Killing all windows", Colors::YELLOW);
|
NLog::log("{}Killing all windows", Colors::YELLOW);
|
||||||
Tests::killAllWindows();
|
Tests::killAllWindows();
|
||||||
|
|
||||||
NLog::log("{}Testing asymmetric gap splits", Colors::YELLOW);
|
testAsymmetricGaps();
|
||||||
{
|
|
||||||
|
|
||||||
CScopeGuard guard = {[&]() {
|
|
||||||
NLog::log("{}Cleaning up asymmetric gap test", Colors::YELLOW);
|
|
||||||
Tests::killAllWindows();
|
|
||||||
OK(getFromSocket("/reload"));
|
|
||||||
}};
|
|
||||||
|
|
||||||
OK(getFromSocket("/dispatch workspace name:gap_split_test"));
|
|
||||||
OK(getFromSocket("r/keyword general:gaps_in 0"));
|
|
||||||
OK(getFromSocket("r/keyword general:border_size 0"));
|
|
||||||
OK(getFromSocket("r/keyword dwindle:split_width_multiplier 1.0"));
|
|
||||||
OK(getFromSocket("r/keyword workspace name:gap_split_test,gapsout:0 1000 0 0"));
|
|
||||||
|
|
||||||
NLog::log("{}Testing default split (force_split = 0)", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("r/keyword dwindle:force_split 0"));
|
|
||||||
|
|
||||||
if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NLog::log("{}Expecting vertical split (B below A)", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
|
|
||||||
|
|
||||||
Tests::killAllWindows();
|
|
||||||
EXPECT(Tests::windowCount(), 0);
|
|
||||||
|
|
||||||
NLog::log("{}Testing force_split = 1", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("r/keyword dwindle:force_split 1"));
|
|
||||||
|
|
||||||
if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NLog::log("{}Expecting vertical split (B above A)", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
|
|
||||||
|
|
||||||
NLog::log("{}Expecting horizontal split (C left of B)", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
|
||||||
|
|
||||||
if (!Tests::spawnKitty("gaps_kitty_C")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_C"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 460,0");
|
|
||||||
|
|
||||||
Tests::killAllWindows();
|
|
||||||
EXPECT(Tests::windowCount(), 0);
|
|
||||||
|
|
||||||
NLog::log("{}Testing force_split = 2", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("r/keyword dwindle:force_split 2"));
|
|
||||||
|
|
||||||
if (!Tests::spawnKitty("gaps_kitty_A") || !Tests::spawnKitty("gaps_kitty_B")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NLog::log("{}Expecting vertical split (B below A)", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_B"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,540");
|
|
||||||
|
|
||||||
NLog::log("{}Expecting horizontal split (C right of A)", Colors::YELLOW);
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
|
||||||
|
|
||||||
if (!Tests::spawnKitty("gaps_kitty_C")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_A"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 0,0");
|
|
||||||
OK(getFromSocket("/dispatch focuswindow class:gaps_kitty_C"));
|
|
||||||
EXPECT_CONTAINS(getFromSocket("/activewindow"), "at: 460,0");
|
|
||||||
}
|
|
||||||
|
|
||||||
// kill all
|
|
||||||
NLog::log("{}Killing all windows", Colors::YELLOW);
|
|
||||||
Tests::killAllWindows();
|
|
||||||
|
|
||||||
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
|
NLog::log("{}Expecting 0 windows", Colors::YELLOW);
|
||||||
EXPECT(Tests::windowCount(), 0);
|
EXPECT(Tests::windowCount(), 0);
|
||||||
|
|
|
||||||
|
|
@ -318,28 +318,70 @@ submap = reset
|
||||||
### WINDOWS AND WORKSPACES ###
|
### WINDOWS AND WORKSPACES ###
|
||||||
##############################
|
##############################
|
||||||
|
|
||||||
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
|
windowrule {
|
||||||
# See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules
|
# Ignore maximize requests from apps. You'll probably like this.
|
||||||
|
name = suppress-maximize-events
|
||||||
|
match:class = .*
|
||||||
|
|
||||||
# Example windowrule v1
|
suppress_event = maximize
|
||||||
# windowrule = float, ^(kitty)$
|
}
|
||||||
|
|
||||||
# Example windowrule v2
|
windowrule {
|
||||||
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
|
# Fix some dragging issues with XWayland
|
||||||
|
name = fix-xwayland-drags
|
||||||
|
match:class = ^$
|
||||||
|
match:title = ^$
|
||||||
|
match:xwayland = true
|
||||||
|
match:float = true
|
||||||
|
match:fullscreen = false
|
||||||
|
match:pin = false
|
||||||
|
|
||||||
# Ignore maximize requests from apps. You'll probably like this.
|
no_focus = true
|
||||||
windowrulev2 = suppressevent maximize, class:.*
|
}
|
||||||
|
|
||||||
# Fix some dragging issues with XWayland
|
|
||||||
windowrulev2 = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0
|
|
||||||
|
|
||||||
# Workspace "windows" is a smart gaps one
|
|
||||||
workspace = n[s:window] w[tv1], gapsout:0, gapsin:0
|
workspace = n[s:window] w[tv1], gapsout:0, gapsin:0
|
||||||
workspace = n[s:window] f[1], gapsout:0, gapsin:0
|
workspace = n[s:window] f[1], gapsout:0, gapsin:0
|
||||||
windowrulev2 = bordersize 0, floating:0, onworkspace:n[s:window] w[tv1]
|
|
||||||
windowrulev2 = rounding 0, floating:0, onworkspace:n[s:window] w[tv1]
|
windowrule {
|
||||||
windowrulev2 = bordersize 0, floating:0, onworkspace:n[s:window] f[1]
|
name = smart-gaps-1
|
||||||
windowrulev2 = rounding 0, floating:0, onworkspace:n[s:window] f[1]
|
match:float = false
|
||||||
|
match:workspace = n[s:window] w[tv1]
|
||||||
|
|
||||||
|
border_size = 0
|
||||||
|
rounding = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
windowrule {
|
||||||
|
name = smart-gaps-2
|
||||||
|
match:float = false
|
||||||
|
match:workspace = n[s:window] f[1]
|
||||||
|
|
||||||
|
border_size = 0
|
||||||
|
rounding = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
windowrule {
|
||||||
|
name = wr-kitty-stuff
|
||||||
|
match:class = wr_kitty
|
||||||
|
|
||||||
|
float = true
|
||||||
|
size = 200 200
|
||||||
|
pin = false
|
||||||
|
}
|
||||||
|
|
||||||
|
windowrule {
|
||||||
|
name = tagged-kitty-floats
|
||||||
|
match:tag = tag_kitty
|
||||||
|
|
||||||
|
float = true
|
||||||
|
}
|
||||||
|
|
||||||
|
windowrule {
|
||||||
|
name = static-kitty-tag
|
||||||
|
match:class = tag_kitty
|
||||||
|
|
||||||
|
tag = +tag_kitty
|
||||||
|
}
|
||||||
|
|
||||||
gesture = 3, left, dispatcher, exec, kitty
|
gesture = 3, left, dispatcher, exec, kitty
|
||||||
gesture = 3, right, float
|
gesture = 3, right, float
|
||||||
|
|
@ -356,7 +398,3 @@ gesture = 5, left, dispatcher, sendshortcut, , i, activewindow
|
||||||
gesture = 5, right, dispatcher, sendshortcut, , t, activewindow
|
gesture = 5, right, dispatcher, sendshortcut, , t, activewindow
|
||||||
gesture = 4, right, dispatcher, sendshortcut, , return, activewindow
|
gesture = 4, right, dispatcher, sendshortcut, , return, activewindow
|
||||||
gesture = 4, left, dispatcher, movecursortocorner, 1
|
gesture = 4, left, dispatcher, movecursortocorner, 1
|
||||||
|
|
||||||
windowrule = float, pin, class:wr_kitty
|
|
||||||
windowrule = size 200 200, class:wr_kitty
|
|
||||||
windowrule = unset pin, class:wr_kitty
|
|
||||||
|
|
|
||||||
151
meson.build
151
meson.build
|
|
@ -1,151 +0,0 @@
|
||||||
project(
|
|
||||||
'Hyprland',
|
|
||||||
'cpp',
|
|
||||||
'c',
|
|
||||||
version: run_command('cat', join_paths(meson.project_source_root(), 'VERSION'), check: true).stdout().strip(),
|
|
||||||
default_options: [
|
|
||||||
'warning_level=2',
|
|
||||||
'default_library=static',
|
|
||||||
'optimization=3',
|
|
||||||
'buildtype=release',
|
|
||||||
'debug=false',
|
|
||||||
'b_lto=false',
|
|
||||||
'cpp_std=c++26',
|
|
||||||
],
|
|
||||||
meson_version: '>= 1.1.0',
|
|
||||||
)
|
|
||||||
|
|
||||||
datarootdir = '-DDATAROOTDIR="' + get_option('prefix') / get_option('datadir') + '"'
|
|
||||||
add_project_arguments(
|
|
||||||
[
|
|
||||||
'-Wno-unused-parameter',
|
|
||||||
'-Wno-unused-value',
|
|
||||||
'-Wno-missing-field-initializers',
|
|
||||||
'-Wno-narrowing',
|
|
||||||
'-Wno-pointer-arith',
|
|
||||||
datarootdir,
|
|
||||||
'-DHYPRLAND_VERSION="' + meson.project_version() + '"',
|
|
||||||
],
|
|
||||||
language: 'cpp',
|
|
||||||
)
|
|
||||||
|
|
||||||
cpp_compiler = meson.get_compiler('cpp')
|
|
||||||
if cpp_compiler.check_header('execinfo.h')
|
|
||||||
add_project_arguments('-DHAS_EXECINFO', language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
aquamarine = dependency('aquamarine', version: '>=0.9.3')
|
|
||||||
hyprcursor = dependency('hyprcursor', version: '>=0.1.7')
|
|
||||||
hyprgraphics = dependency('hyprgraphics', version: '>=0.1.6')
|
|
||||||
hyprlang = dependency('hyprlang', version: '>=0.3.2')
|
|
||||||
hyprutils = dependency('hyprutils', version: '>=0.8.2')
|
|
||||||
|
|
||||||
aq_ver_list = aquamarine.version().split('.')
|
|
||||||
git = find_program('git', required: false)
|
|
||||||
|
|
||||||
if git.found()
|
|
||||||
git_hash = run_command(git, 'rev-parse', 'HEAD').stdout().strip()
|
|
||||||
git_branch = run_command(git, 'branch', '--show-current').stdout().strip()
|
|
||||||
git_message = run_command(git, 'show', '-s', '--format=%s').stdout().strip()
|
|
||||||
git_date = run_command(git, 'show', '-s', '--format=%cd', '--date=local').stdout().strip()
|
|
||||||
git_dirty = run_command(git, 'diff-index', '--quiet', 'HEAD', '--', check: false).returncode() != 0 ? 'dirty' : 'clean'
|
|
||||||
git_tag = run_command(git, 'describe', '--tags').stdout().strip()
|
|
||||||
git_commits = run_command(git, 'rev-list', '--count', 'HEAD').stdout().strip()
|
|
||||||
else
|
|
||||||
git_hash = 'unknown'
|
|
||||||
git_branch = 'unknown'
|
|
||||||
git_message = 'unknown'
|
|
||||||
git_date = 'unknown'
|
|
||||||
git_dirty = 'unknown'
|
|
||||||
git_tag = 'unknown'
|
|
||||||
git_commits = '0'
|
|
||||||
endif
|
|
||||||
|
|
||||||
cfg = configuration_data()
|
|
||||||
cfg.set('GIT_COMMIT_HASH', git_hash)
|
|
||||||
cfg.set('GIT_BRANCH', git_branch)
|
|
||||||
cfg.set('GIT_COMMIT_MESSAGE', git_message)
|
|
||||||
cfg.set('GIT_COMMIT_DATE', git_date)
|
|
||||||
cfg.set('GIT_DIRTY', git_dirty)
|
|
||||||
cfg.set('GIT_TAG', git_tag)
|
|
||||||
cfg.set('GIT_COMMITS', git_commits)
|
|
||||||
cfg.set('AQUAMARINE_VERSION', aquamarine.version())
|
|
||||||
cfg.set('AQUAMARINE_VERSION_MAJOR', aq_ver_list[0])
|
|
||||||
cfg.set('AQUAMARINE_VERSION_MINOR', aq_ver_list[1])
|
|
||||||
cfg.set('AQUAMARINE_VERSION_PATCH', aq_ver_list[2])
|
|
||||||
cfg.set('HYPRLANG_VERSION', hyprlang.version())
|
|
||||||
cfg.set('HYPRUTILS_VERSION', hyprutils.version())
|
|
||||||
cfg.set('HYPRCURSOR_VERSION', hyprcursor.version())
|
|
||||||
cfg.set('HYPRGRAPHICS_VERSION', hyprgraphics.version())
|
|
||||||
|
|
||||||
version_h = configure_file(
|
|
||||||
input: 'src/version.h.in',
|
|
||||||
output: 'version.h',
|
|
||||||
configuration: cfg
|
|
||||||
)
|
|
||||||
|
|
||||||
install_headers(version_h, subdir: 'hyprland/src')
|
|
||||||
|
|
||||||
xcb_dep = dependency('xcb', required: get_option('xwayland'))
|
|
||||||
xcb_composite_dep = dependency('xcb-composite', required: get_option('xwayland'))
|
|
||||||
xcb_errors_dep = dependency('xcb-errors', required: get_option('xwayland'))
|
|
||||||
xcb_icccm_dep = dependency('xcb-icccm', required: get_option('xwayland'))
|
|
||||||
xcb_render_dep = dependency('xcb-render', required: get_option('xwayland'))
|
|
||||||
xcb_res_dep = dependency('xcb-res', required: get_option('xwayland'))
|
|
||||||
xcb_xfixes_dep = dependency('xcb-xfixes', required: get_option('xwayland'))
|
|
||||||
gio_dep = dependency('gio-2.0', required: true)
|
|
||||||
|
|
||||||
if not xcb_dep.found()
|
|
||||||
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
backtrace_dep = cpp_compiler.find_library('execinfo', required: false)
|
|
||||||
epoll_dep = dependency('epoll-shim', required: false)
|
|
||||||
inotify_dep = dependency('libinotify', required: false)
|
|
||||||
re2 = dependency('re2', required: true)
|
|
||||||
|
|
||||||
systemd_option = get_option('systemd')
|
|
||||||
systemd = dependency('systemd', required: systemd_option)
|
|
||||||
systemd_option.enable_auto_if(systemd.found())
|
|
||||||
if (systemd_option.enabled())
|
|
||||||
add_project_arguments('-DUSES_SYSTEMD', language: 'cpp')
|
|
||||||
subdir('systemd')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get_option('buildtype') == 'debug'
|
|
||||||
add_project_arguments('-DHYPRLAND_DEBUG', language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
run_command('sh', '-c', 'scripts/generateShaderIncludes.sh', check: true)
|
|
||||||
|
|
||||||
globber = run_command('find', 'src', '-name', '*.h*', '-o', '-name', '*.inc', check: true)
|
|
||||||
headers = globber.stdout().strip().split('\n')
|
|
||||||
foreach file : headers
|
|
||||||
install_headers(file, subdir: 'hyprland', preserve_path: true)
|
|
||||||
endforeach
|
|
||||||
install_headers(version_h, subdir: 'src')
|
|
||||||
|
|
||||||
tracy = dependency('tracy', static: true, required: get_option('tracy_enable'))
|
|
||||||
if get_option('tracy_enable') and get_option('buildtype') != 'debugoptimized'
|
|
||||||
warning('Profiling builds should set -- buildtype = debugoptimized')
|
|
||||||
endif
|
|
||||||
|
|
||||||
subdir('protocols')
|
|
||||||
subdir('src')
|
|
||||||
subdir('hyprctl')
|
|
||||||
subdir('assets')
|
|
||||||
subdir('example')
|
|
||||||
subdir('docs')
|
|
||||||
if get_option('hyprpm').enabled()
|
|
||||||
subdir('hyprpm/src')
|
|
||||||
endif
|
|
||||||
|
|
||||||
pkg_install_dir = join_paths(get_option('datadir'), 'pkgconfig')
|
|
||||||
import('pkgconfig').generate(
|
|
||||||
name: 'Hyprland',
|
|
||||||
filebase: 'hyprland',
|
|
||||||
url: 'https://github.com/hyprwm/Hyprland',
|
|
||||||
description: 'Hyprland header files',
|
|
||||||
install_dir: pkg_install_dir,
|
|
||||||
subdirs: ['', 'hyprland/protocols', 'hyprland'],
|
|
||||||
)
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')
|
|
||||||
option('systemd', type: 'feature', value: 'auto', description: 'Enable systemd integration')
|
|
||||||
option('uwsm', type: 'feature', value: 'enabled', description: 'Enable uwsm integration (only if systemd is enabled)')
|
|
||||||
option('hyprpm', type: 'feature', value: 'enabled', description: 'Enable hyprpm')
|
|
||||||
option('tracy_enable', type: 'boolean', value: false , description: 'Enable profiling')
|
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
cairo,
|
cairo,
|
||||||
epoll-shim,
|
epoll-shim,
|
||||||
git,
|
git,
|
||||||
glaze,
|
glaze-hyprland,
|
||||||
|
gtest,
|
||||||
hyprcursor,
|
hyprcursor,
|
||||||
hyprgraphics,
|
hyprgraphics,
|
||||||
hyprland-protocols,
|
hyprland-protocols,
|
||||||
|
|
@ -19,6 +20,7 @@
|
||||||
hyprlang,
|
hyprlang,
|
||||||
hyprutils,
|
hyprutils,
|
||||||
hyprwayland-scanner,
|
hyprwayland-scanner,
|
||||||
|
hyprwire,
|
||||||
libGL,
|
libGL,
|
||||||
libdrm,
|
libdrm,
|
||||||
libexecinfo,
|
libexecinfo,
|
||||||
|
|
@ -26,6 +28,7 @@
|
||||||
libxkbcommon,
|
libxkbcommon,
|
||||||
libuuid,
|
libuuid,
|
||||||
libgbm,
|
libgbm,
|
||||||
|
muparser,
|
||||||
pango,
|
pango,
|
||||||
pciutils,
|
pciutils,
|
||||||
re2,
|
re2,
|
||||||
|
|
@ -38,6 +41,7 @@
|
||||||
xorg,
|
xorg,
|
||||||
xwayland,
|
xwayland,
|
||||||
debug ? false,
|
debug ? false,
|
||||||
|
withTests ? false,
|
||||||
enableXWayland ? true,
|
enableXWayland ? true,
|
||||||
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
|
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
|
||||||
wrapRuntimeDeps ? true,
|
wrapRuntimeDeps ? true,
|
||||||
|
|
@ -45,12 +49,12 @@
|
||||||
commit,
|
commit,
|
||||||
revCount,
|
revCount,
|
||||||
date,
|
date,
|
||||||
withHyprtester ? false,
|
|
||||||
# deprecated flags
|
# deprecated flags
|
||||||
enableNvidiaPatches ? false,
|
enableNvidiaPatches ? false,
|
||||||
nvidiaPatches ? false,
|
nvidiaPatches ? false,
|
||||||
hidpiXWayland ? false,
|
hidpiXWayland ? false,
|
||||||
legacyRenderer ? false,
|
legacyRenderer ? false,
|
||||||
|
withHyprtester ? false,
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) foldl' readFile;
|
inherit (builtins) foldl' readFile;
|
||||||
inherit (lib.asserts) assertMsg;
|
inherit (lib.asserts) assertMsg;
|
||||||
|
|
@ -70,9 +74,10 @@ in
|
||||||
assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
|
assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
|
||||||
assert assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hypr.land/Configuring/XWayland";
|
assert assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hypr.land/Configuring/XWayland";
|
||||||
assert assertMsg (!legacyRenderer) "The option `legacyRenderer` has been removed. Legacy renderer is no longer supported.";
|
assert assertMsg (!legacyRenderer) "The option `legacyRenderer` has been removed. Legacy renderer is no longer supported.";
|
||||||
|
assert assertMsg (!withHyprtester) "The option `withHyprtester` has been removed. Hyprtester is always built now.";
|
||||||
customStdenv.mkDerivation (finalAttrs: {
|
customStdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "hyprland${optionalString debug "-debug"}";
|
pname = "hyprland${optionalString debug "-debug"}";
|
||||||
inherit version;
|
inherit version withTests;
|
||||||
|
|
||||||
src = fs.toSource {
|
src = fs.toSource {
|
||||||
root = ../.;
|
root = ../.;
|
||||||
|
|
@ -88,13 +93,14 @@ in
|
||||||
../LICENSE
|
../LICENSE
|
||||||
../protocols
|
../protocols
|
||||||
../src
|
../src
|
||||||
|
../start
|
||||||
../systemd
|
../systemd
|
||||||
../VERSION
|
../VERSION
|
||||||
(fs.fileFilter (file: file.hasExt "1") ../docs)
|
(fs.fileFilter (file: file.hasExt "1") ../docs)
|
||||||
(fs.fileFilter (file: file.hasExt "conf" || file.hasExt "desktop") ../example)
|
(fs.fileFilter (file: file.hasExt "conf" || file.hasExt "desktop") ../example)
|
||||||
(fs.fileFilter (file: file.hasExt "sh") ../scripts)
|
(fs.fileFilter (file: file.hasExt "sh") ../scripts)
|
||||||
(fs.fileFilter (file: file.name == "CMakeLists.txt") ../.)
|
(fs.fileFilter (file: file.name == "CMakeLists.txt") ../.)
|
||||||
(optional withHyprtester ../hyprtester)
|
(optional withTests [../tests ../hyprtester])
|
||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -106,11 +112,13 @@ in
|
||||||
sed -i "s#@PREFIX@/##g" hyprland.pc.in
|
sed -i "s#@PREFIX@/##g" hyprland.pc.in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
COMMITS = revCount;
|
env = {
|
||||||
DATE = date;
|
GIT_COMMITS = revCount;
|
||||||
DIRTY = optionalString (commit == "") "dirty";
|
GIT_COMMIT_DATE = date;
|
||||||
HASH = commit;
|
GIT_COMMIT_HASH = commit;
|
||||||
TAG = "v${trim (readFile "${finalAttrs.src}/VERSION")}";
|
GIT_DIRTY = if (commit == "") then "clean" else "dirty";
|
||||||
|
GIT_TAG = "v${trim (readFile "${finalAttrs.src}/VERSION")}";
|
||||||
|
};
|
||||||
|
|
||||||
depsBuildBuild = [
|
depsBuildBuild = [
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|
@ -118,6 +126,7 @@ in
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
hyprwayland-scanner
|
hyprwayland-scanner
|
||||||
|
hyprwire
|
||||||
makeWrapper
|
makeWrapper
|
||||||
cmake
|
cmake
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|
@ -134,18 +143,21 @@ in
|
||||||
aquamarine
|
aquamarine
|
||||||
cairo
|
cairo
|
||||||
git
|
git
|
||||||
glaze
|
glaze-hyprland
|
||||||
|
gtest
|
||||||
hyprcursor
|
hyprcursor
|
||||||
hyprgraphics
|
hyprgraphics
|
||||||
hyprland-protocols
|
hyprland-protocols
|
||||||
hyprlang
|
hyprlang
|
||||||
hyprutils
|
hyprutils
|
||||||
|
hyprwire
|
||||||
libdrm
|
libdrm
|
||||||
libGL
|
libGL
|
||||||
libinput
|
libinput
|
||||||
libuuid
|
libuuid
|
||||||
libxkbcommon
|
libxkbcommon
|
||||||
libgbm
|
libgbm
|
||||||
|
muparser
|
||||||
pango
|
pango
|
||||||
pciutils
|
pciutils
|
||||||
re2
|
re2
|
||||||
|
|
@ -180,6 +192,7 @@ in
|
||||||
dontStrip = debug;
|
dontStrip = debug;
|
||||||
|
|
||||||
cmakeFlags = mapAttrsToList cmakeBool {
|
cmakeFlags = mapAttrsToList cmakeBool {
|
||||||
|
"BUILT_WITH_NIX" = true;
|
||||||
"NO_XWAYLAND" = !enableXWayland;
|
"NO_XWAYLAND" = !enableXWayland;
|
||||||
"LEGACY_RENDERER" = legacyRenderer;
|
"LEGACY_RENDERER" = legacyRenderer;
|
||||||
"NO_SYSTEMD" = !withSystemd;
|
"NO_SYSTEMD" = !withSystemd;
|
||||||
|
|
@ -187,7 +200,7 @@ in
|
||||||
"NO_UWSM" = true;
|
"NO_UWSM" = true;
|
||||||
"NO_HYPRPM" = true;
|
"NO_HYPRPM" = true;
|
||||||
"TRACY_ENABLE" = false;
|
"TRACY_ENABLE" = false;
|
||||||
"BUILD_HYPRTESTER" = withHyprtester;
|
"WITH_TESTS" = withTests;
|
||||||
};
|
};
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
|
|
@ -206,9 +219,12 @@ in
|
||||||
pkgconf
|
pkgconf
|
||||||
]}
|
]}
|
||||||
''}
|
''}
|
||||||
'' + optionalString withHyprtester ''
|
|
||||||
install hyprtester/pointer-warp -t $out/bin
|
${optionalString withTests ''
|
||||||
install hyprtester/pointer-scroll -t $out/bin
|
install hyprtester/pointer-warp -t $out/bin
|
||||||
|
install hyprtester/pointer-scroll -t $out/bin
|
||||||
|
install hyprland_gtests -t $out/bin
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.providedSessions = ["hyprland"];
|
passthru.providedSessions = ["hyprland"];
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,9 @@ in {
|
||||||
inputs.hyprlang.overlays.default
|
inputs.hyprlang.overlays.default
|
||||||
inputs.hyprutils.overlays.default
|
inputs.hyprutils.overlays.default
|
||||||
inputs.hyprwayland-scanner.overlays.default
|
inputs.hyprwayland-scanner.overlays.default
|
||||||
|
inputs.hyprwire.overlays.default
|
||||||
self.overlays.udis86
|
self.overlays.udis86
|
||||||
|
self.overlays.glaze
|
||||||
|
|
||||||
# Hyprland packages themselves
|
# Hyprland packages themselves
|
||||||
(final: _prev: let
|
(final: _prev: let
|
||||||
|
|
@ -43,7 +45,14 @@ in {
|
||||||
};
|
};
|
||||||
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
|
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
|
||||||
|
|
||||||
hyprland-with-hyprtester = final.hyprland.override {withHyprtester = true;};
|
hyprland-with-tests = final.hyprland.override {withTests = true;};
|
||||||
|
|
||||||
|
hyprland-with-hyprtester =
|
||||||
|
builtins.trace ''
|
||||||
|
hyprland-with-hyprtester was removed. Please use the hyprland package.
|
||||||
|
Hyprtester is always built now.
|
||||||
|
''
|
||||||
|
final.hyprland;
|
||||||
|
|
||||||
# deprecated packages
|
# deprecated packages
|
||||||
hyprland-legacy-renderer =
|
hyprland-legacy-renderer =
|
||||||
|
|
@ -102,4 +111,13 @@ in {
|
||||||
patches = [];
|
patches = [];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Even though glaze itself disables it by default, nixpkgs sets ENABLE_SSL set to true.
|
||||||
|
# Since we don't include openssl, the build failes without the `enableSSL = false;` override
|
||||||
|
glaze = final: prev: {
|
||||||
|
glaze-hyprland = prev.glaze.override {
|
||||||
|
enableSSL = false;
|
||||||
|
enableInterop = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
inputs: pkgs: let
|
inputs: pkgs: let
|
||||||
flake = inputs.self.packages.${pkgs.stdenv.hostPlatform.system};
|
flake = inputs.self.packages.${pkgs.stdenv.hostPlatform.system};
|
||||||
hyprland = flake.hyprland-with-hyprtester;
|
hyprland = flake.hyprland-with-tests;
|
||||||
in {
|
in {
|
||||||
tests = pkgs.testers.runNixOSTest {
|
tests = pkgs.testers.runNixOSTest {
|
||||||
name = "hyprland-tests";
|
name = "hyprland-tests";
|
||||||
|
|
@ -68,6 +68,12 @@ in {
|
||||||
# Wait for tty to be up
|
# Wait for tty to be up
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
|
|
||||||
|
# Run gtests
|
||||||
|
print("Running gtests")
|
||||||
|
exit_status, _out = machine.execute("su - alice -c 'hyprland_gtests 2>&1 | tee /tmp/gtestslog; exit ''${PIPESTATUS[0]}'")
|
||||||
|
machine.execute(f'echo {exit_status} > /tmp/exit_status_gtests')
|
||||||
|
|
||||||
# Run hyprtester testing framework/suite
|
# Run hyprtester testing framework/suite
|
||||||
print("Running hyprtester")
|
print("Running hyprtester")
|
||||||
exit_status, _out = machine.execute("su - alice -c 'hyprtester -b ${hyprland}/bin/Hyprland -c /etc/test.conf -p ${hyprland}/lib/hyprtestplugin.so 2>&1 | tee /tmp/testerlog; exit ''${PIPESTATUS[0]}'")
|
exit_status, _out = machine.execute("su - alice -c 'hyprtester -b ${hyprland}/bin/Hyprland -c /etc/test.conf -p ${hyprland}/lib/hyprtestplugin.so 2>&1 | tee /tmp/testerlog; exit ''${PIPESTATUS[0]}'")
|
||||||
|
|
@ -76,6 +82,7 @@ in {
|
||||||
# Copy logs to host
|
# Copy logs to host
|
||||||
machine.execute('cp "$(find /tmp/hypr -name *.log | head -1)" /tmp/hyprlog')
|
machine.execute('cp "$(find /tmp/hypr -name *.log | head -1)" /tmp/hyprlog')
|
||||||
machine.execute(f'echo {exit_status} > /tmp/exit_status')
|
machine.execute(f'echo {exit_status} > /tmp/exit_status')
|
||||||
|
machine.copy_from_vm("/tmp/gtestslog")
|
||||||
machine.copy_from_vm("/tmp/testerlog")
|
machine.copy_from_vm("/tmp/testerlog")
|
||||||
machine.copy_from_vm("/tmp/hyprlog")
|
machine.copy_from_vm("/tmp/hyprlog")
|
||||||
machine.copy_from_vm("/tmp/exit_status")
|
machine.copy_from_vm("/tmp/exit_status")
|
||||||
|
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
wayland_protos = dependency(
|
|
||||||
'wayland-protocols',
|
|
||||||
version: '>=1.45',
|
|
||||||
fallback: 'wayland-protocols',
|
|
||||||
default_options: ['tests=false'],
|
|
||||||
)
|
|
||||||
|
|
||||||
hyprland_protos = dependency(
|
|
||||||
'hyprland-protocols',
|
|
||||||
version: '>=0.6.4',
|
|
||||||
fallback: 'hyprland-protocols',
|
|
||||||
)
|
|
||||||
|
|
||||||
wayland_protocol_dir = wayland_protos.get_variable('pkgdatadir')
|
|
||||||
hyprland_protocol_dir = hyprland_protos.get_variable('pkgdatadir')
|
|
||||||
|
|
||||||
hyprwayland_scanner_dep = dependency('hyprwayland-scanner', version: '>=0.3.10', native: true)
|
|
||||||
hyprwayland_scanner = find_program(
|
|
||||||
hyprwayland_scanner_dep.get_variable('hyprwayland_scanner'),
|
|
||||||
native: true,
|
|
||||||
)
|
|
||||||
|
|
||||||
protocols = [
|
|
||||||
'wlr-gamma-control-unstable-v1.xml',
|
|
||||||
'wlr-foreign-toplevel-management-unstable-v1.xml',
|
|
||||||
'wlr-output-power-management-unstable-v1.xml',
|
|
||||||
'input-method-unstable-v2.xml',
|
|
||||||
'virtual-keyboard-unstable-v1.xml',
|
|
||||||
'wlr-virtual-pointer-unstable-v1.xml',
|
|
||||||
'wlr-output-management-unstable-v1.xml',
|
|
||||||
'kde-server-decoration.xml',
|
|
||||||
'wlr-layer-shell-unstable-v1.xml',
|
|
||||||
'wayland-drm.xml',
|
|
||||||
'wlr-data-control-unstable-v1.xml',
|
|
||||||
'wlr-screencopy-unstable-v1.xml',
|
|
||||||
'xx-color-management-v4.xml',
|
|
||||||
'frog-color-management-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-global-shortcuts-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-toplevel-export-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-toplevel-mapping-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-focus-grab-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-ctm-control-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-surface-v1.xml',
|
|
||||||
hyprland_protocol_dir / 'protocols/hyprland-lock-notify-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/tearing-control/tearing-control-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/fractional-scale/fractional-scale-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/cursor-shape/cursor-shape-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/relative-pointer/relative-pointer-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/alpha-modifier/alpha-modifier-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/text-input/text-input-unstable-v3.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/text-input/text-input-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/xdg-activation/xdg-activation-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/ext-idle-notify/ext-idle-notify-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/ext-session-lock/ext-session-lock-v1.xml',
|
|
||||||
wayland_protocol_dir / 'stable/tablet/tablet-v2.xml',
|
|
||||||
wayland_protocol_dir / 'stable/presentation-time/presentation-time.xml',
|
|
||||||
wayland_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
|
|
||||||
wayland_protocol_dir / 'unstable/primary-selection/primary-selection-unstable-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/xwayland-shell/xwayland-shell-v1.xml',
|
|
||||||
wayland_protocol_dir / 'stable/viewporter/viewporter.xml',
|
|
||||||
wayland_protocol_dir / 'stable/linux-dmabuf/linux-dmabuf-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/drm-lease/drm-lease-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/linux-drm-syncobj/linux-drm-syncobj-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/xdg-dialog/xdg-dialog-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/single-pixel-buffer/single-pixel-buffer-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/security-context/security-context-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/content-type/content-type-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/color-management/color-management-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/xdg-toplevel-tag/xdg-toplevel-tag-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/xdg-system-bell/xdg-system-bell-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/ext-workspace/ext-workspace-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/ext-data-control/ext-data-control-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/pointer-warp/pointer-warp-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/fifo/fifo-v1.xml',
|
|
||||||
wayland_protocol_dir / 'staging/commit-timing/commit-timing-v1.xml',
|
|
||||||
]
|
|
||||||
|
|
||||||
wl_protocols = []
|
|
||||||
foreach protocol : protocols
|
|
||||||
wl_protocols += custom_target(
|
|
||||||
protocol.underscorify(),
|
|
||||||
input: protocol,
|
|
||||||
install: true,
|
|
||||||
install_dir: [false, join_paths(get_option('includedir'), 'hyprland/protocols')],
|
|
||||||
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
|
|
||||||
command: [hyprwayland_scanner, '@INPUT@', '@OUTDIR@'],
|
|
||||||
)
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
# wayland.xml generation
|
|
||||||
wayland_scanner = dependency('wayland-scanner', native: true)
|
|
||||||
wayland_scanner_datadir = wayland_scanner.get_variable('pkgdatadir')
|
|
||||||
|
|
||||||
wayland_xml = wayland_scanner_datadir / 'wayland.xml'
|
|
||||||
wayland_protocol = custom_target(
|
|
||||||
wayland_xml.underscorify(),
|
|
||||||
input: wayland_xml,
|
|
||||||
install: true,
|
|
||||||
install_dir: [false, join_paths(get_option('includedir'), 'hyprland/protocols')],
|
|
||||||
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
|
|
||||||
command: [hyprwayland_scanner, '--wayland-enums', '@INPUT@', '@OUTDIR@'],
|
|
||||||
)
|
|
||||||
|
|
||||||
lib_server_protos = static_library(
|
|
||||||
'server_protos',
|
|
||||||
wl_protocols + wayland_protocol,
|
|
||||||
)
|
|
||||||
|
|
||||||
server_protos = declare_dependency(
|
|
||||||
link_with: lib_server_protos,
|
|
||||||
sources: wl_protocols + wayland_protocol,
|
|
||||||
)
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,7 +7,7 @@
|
||||||
#include "managers/XWaylandManager.hpp"
|
#include "managers/XWaylandManager.hpp"
|
||||||
#include "managers/KeybindManager.hpp"
|
#include "managers/KeybindManager.hpp"
|
||||||
#include "managers/SessionLockManager.hpp"
|
#include "managers/SessionLockManager.hpp"
|
||||||
#include "desktop/Window.hpp"
|
#include "desktop/view/Window.hpp"
|
||||||
#include "protocols/types/ColorManagement.hpp"
|
#include "protocols/types/ColorManagement.hpp"
|
||||||
|
|
||||||
#include <aquamarine/backend/Backend.hpp>
|
#include <aquamarine/backend/Backend.hpp>
|
||||||
|
|
@ -40,6 +40,7 @@ class CCompositor {
|
||||||
} m_drmRenderNode;
|
} m_drmRenderNode;
|
||||||
|
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
|
bool m_safeMode = false;
|
||||||
SP<Aquamarine::CBackend> m_aqBackend;
|
SP<Aquamarine::CBackend> m_aqBackend;
|
||||||
|
|
||||||
std::string m_hyprTempDataRoot = "";
|
std::string m_hyprTempDataRoot = "";
|
||||||
|
|
@ -55,6 +56,7 @@ class CCompositor {
|
||||||
std::vector<PHLLS> m_layers;
|
std::vector<PHLLS> m_layers;
|
||||||
std::vector<PHLWINDOWREF> m_windowsFadingOut;
|
std::vector<PHLWINDOWREF> m_windowsFadingOut;
|
||||||
std::vector<PHLLSREF> m_surfacesFadingOut;
|
std::vector<PHLLSREF> m_surfacesFadingOut;
|
||||||
|
std::vector<SP<Desktop::View::IView>> m_otherViews;
|
||||||
|
|
||||||
std::unordered_map<std::string, MONITORID> m_monitorIDMap;
|
std::unordered_map<std::string, MONITORID> m_monitorIDMap;
|
||||||
std::unordered_map<std::string, WORKSPACEID> m_seenMonitorWorkspaceMap; // map of seen monitor names to workspace IDs
|
std::unordered_map<std::string, WORKSPACEID> m_seenMonitorWorkspaceMap; // map of seen monitor names to workspace IDs
|
||||||
|
|
@ -65,12 +67,7 @@ class CCompositor {
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void bumpNofile();
|
void bumpNofile();
|
||||||
void restoreNofile();
|
void restoreNofile();
|
||||||
|
bool setWatchdogFd(int fd);
|
||||||
WP<CWLSurfaceResource> m_lastFocus;
|
|
||||||
PHLWINDOWREF m_lastWindow;
|
|
||||||
PHLMONITORREF m_lastMonitor;
|
|
||||||
|
|
||||||
std::vector<PHLWINDOWREF> m_windowFocusHistory; // first element is the most recently focused
|
|
||||||
|
|
||||||
bool m_readyToProcess = false;
|
bool m_readyToProcess = false;
|
||||||
bool m_sessionActive = true;
|
bool m_sessionActive = true;
|
||||||
|
|
@ -99,8 +96,6 @@ class CCompositor {
|
||||||
PHLMONITOR getMonitorFromCursor();
|
PHLMONITOR getMonitorFromCursor();
|
||||||
PHLMONITOR getMonitorFromVector(const Vector2D&);
|
PHLMONITOR getMonitorFromVector(const Vector2D&);
|
||||||
void removeWindowFromVectorSafe(PHLWINDOW);
|
void removeWindowFromVectorSafe(PHLWINDOW);
|
||||||
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr, bool preserveFocusHistory = false);
|
|
||||||
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
|
|
||||||
bool monitorExists(PHLMONITOR);
|
bool monitorExists(PHLMONITOR);
|
||||||
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
|
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
|
||||||
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*, bool aboveLockscreen = false);
|
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*, bool aboveLockscreen = false);
|
||||||
|
|
@ -129,7 +124,6 @@ class CCompositor {
|
||||||
PHLMONITOR getMonitorInDirection(const char&);
|
PHLMONITOR getMonitorInDirection(const char&);
|
||||||
PHLMONITOR getMonitorInDirection(PHLMONITOR, const char&);
|
PHLMONITOR getMonitorInDirection(PHLMONITOR, const char&);
|
||||||
void updateAllWindowsAnimatedDecorationValues();
|
void updateAllWindowsAnimatedDecorationValues();
|
||||||
void updateWindowAnimatedDecorationValues(PHLWINDOW);
|
|
||||||
MONITORID getNextAvailableMonitorID(std::string const& name);
|
MONITORID getNextAvailableMonitorID(std::string const& name);
|
||||||
void moveWorkspaceToMonitor(PHLWORKSPACE, PHLMONITOR, bool noWarpCursor = false);
|
void moveWorkspaceToMonitor(PHLWORKSPACE, PHLMONITOR, bool noWarpCursor = false);
|
||||||
void swapActiveWorkspaces(PHLMONITOR, PHLMONITOR);
|
void swapActiveWorkspaces(PHLMONITOR, PHLMONITOR);
|
||||||
|
|
@ -137,7 +131,7 @@ class CCompositor {
|
||||||
bool workspaceIDOutOfBounds(const WORKSPACEID&);
|
bool workspaceIDOutOfBounds(const WORKSPACEID&);
|
||||||
void setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
|
void setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
|
||||||
void setWindowFullscreenClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
|
void setWindowFullscreenClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
|
||||||
void setWindowFullscreenState(const PHLWINDOW PWINDOW, const SFullscreenState state);
|
void setWindowFullscreenState(const PHLWINDOW PWINDOW, const Desktop::View::SFullscreenState state);
|
||||||
void changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
|
void changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
|
||||||
PHLWINDOW getX11Parent(PHLWINDOW);
|
PHLWINDOW getX11Parent(PHLWINDOW);
|
||||||
void scheduleFrameForMonitor(PHLMONITOR, Aquamarine::IOutput::scheduleFrameReason reason = Aquamarine::IOutput::AQ_SCHEDULE_CLIENT_UNKNOWN);
|
void scheduleFrameForMonitor(PHLMONITOR, Aquamarine::IOutput::scheduleFrameReason reason = Aquamarine::IOutput::AQ_SCHEDULE_CLIENT_UNKNOWN);
|
||||||
|
|
@ -151,7 +145,6 @@ class CCompositor {
|
||||||
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
||||||
[[nodiscard]] PHLWORKSPACE createNewWorkspace(const WORKSPACEID&, const MONITORID&, const std::string& name = "",
|
[[nodiscard]] PHLWORKSPACE createNewWorkspace(const WORKSPACEID&, const MONITORID&, const std::string& name = "",
|
||||||
bool isEmpty = true); // will be deleted next frame if left empty and unfocused!
|
bool isEmpty = true); // will be deleted next frame if left empty and unfocused!
|
||||||
void setActiveMonitor(PHLMONITOR);
|
|
||||||
bool isWorkspaceSpecial(const WORKSPACEID&);
|
bool isWorkspaceSpecial(const WORKSPACEID&);
|
||||||
WORKSPACEID getNewSpecialID();
|
WORKSPACEID getNewSpecialID();
|
||||||
void performUserChecks();
|
void performUserChecks();
|
||||||
|
|
@ -170,27 +163,30 @@ class CCompositor {
|
||||||
std::optional<unsigned int> getVTNr();
|
std::optional<unsigned int> getVTNr();
|
||||||
|
|
||||||
NColorManagement::SImageDescription getPreferredImageDescription();
|
NColorManagement::SImageDescription getPreferredImageDescription();
|
||||||
|
NColorManagement::SImageDescription getHDRImageDescription();
|
||||||
bool shouldChangePreferredImageDescription();
|
bool shouldChangePreferredImageDescription();
|
||||||
|
|
||||||
bool supportsDrmSyncobjTimeline() const;
|
bool supportsDrmSyncobjTimeline() const;
|
||||||
std::string m_explicitConfigPath;
|
std::string m_explicitConfigPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
void removeAllSignals();
|
void removeAllSignals();
|
||||||
void cleanEnvironment();
|
void cleanEnvironment();
|
||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
void initManagers(eManagersInitStage stage);
|
void initManagers(eManagersInitStage stage);
|
||||||
void prepareFallbackOutput();
|
void prepareFallbackOutput();
|
||||||
void createLockFile();
|
void createLockFile();
|
||||||
void removeLockFile();
|
void removeLockFile();
|
||||||
void setMallocThreshold();
|
void setMallocThreshold();
|
||||||
|
void openSafeModeBox();
|
||||||
|
|
||||||
uint64_t m_hyprlandPID = 0;
|
uint64_t m_hyprlandPID = 0;
|
||||||
wl_event_source* m_critSigSource = nullptr;
|
wl_event_source* m_critSigSource = nullptr;
|
||||||
rlimit m_originalNofile = {};
|
rlimit m_originalNofile = {};
|
||||||
|
Hyprutils::OS::CFileDescriptor m_watchdogWriteFd;
|
||||||
|
|
||||||
std::vector<PHLWORKSPACEREF> m_workspaces;
|
std::vector<PHLWORKSPACEREF> m_workspaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline UP<CCompositor> g_pCompositor;
|
inline UP<CCompositor> g_pCompositor;
|
||||||
|
|
|
||||||
|
|
@ -97,27 +97,29 @@ class CCssGapData : public ICustomConfigValueData {
|
||||||
int64_t m_bottom;
|
int64_t m_bottom;
|
||||||
int64_t m_left;
|
int64_t m_left;
|
||||||
|
|
||||||
void parseGapData(CVarList varlist) {
|
void parseGapData(CVarList2 varlist) {
|
||||||
|
const auto toInt = [](std::string_view string) -> int { return std::stoi(std::string(string)); };
|
||||||
|
|
||||||
switch (varlist.size()) {
|
switch (varlist.size()) {
|
||||||
case 1: {
|
case 1: {
|
||||||
*this = CCssGapData(std::stoi(varlist[0]));
|
*this = CCssGapData(toInt(varlist[0]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]));
|
*this = CCssGapData(toInt(varlist[0]), toInt(varlist[1]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]), std::stoi(varlist[2]));
|
*this = CCssGapData(toInt(varlist[0]), toInt(varlist[1]), toInt(varlist[2]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]), std::stoi(varlist[2]), std::stoi(varlist[3]));
|
*this = CCssGapData(toInt(varlist[0]), toInt(varlist[1]), toInt(varlist[2]), toInt(varlist[3]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
Debug::log(WARN, "Too many arguments provided for gaps.");
|
Log::logger->log(Log::WARN, "Too many arguments provided for gaps.");
|
||||||
*this = CCssGapData(std::stoi(varlist[0]), std::stoi(varlist[1]), std::stoi(varlist[2]), std::stoi(varlist[3]));
|
*this = CCssGapData(toInt(varlist[0]), toInt(varlist[1]), toInt(varlist[2]), toInt(varlist[3]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,6 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_INT,
|
.type = CONFIG_OPTION_INT,
|
||||||
.data = SConfigOptionDescription::SRangeData{1, 0, 20},
|
.data = SConfigOptionDescription::SRangeData{1, 0, 20},
|
||||||
},
|
},
|
||||||
SConfigOptionDescription{
|
|
||||||
.value = "general:no_border_on_floating",
|
|
||||||
.description = "disable borders for floating windows",
|
|
||||||
.type = CONFIG_OPTION_BOOL,
|
|
||||||
.data = SConfigOptionDescription::SBoolData{false},
|
|
||||||
},
|
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "general:gaps_in",
|
.value = "general:gaps_in",
|
||||||
.description = "gaps between windows\n\nsupports css style gaps (top, right, bottom, left -> 5 10 15 20)",
|
.description = "gaps between windows\n\nsupports css style gaps (top, right, bottom, left -> 5 10 15 20)",
|
||||||
|
|
@ -144,10 +138,16 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
},
|
},
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "general:modal_parent_blocking",
|
.value = "general:modal_parent_blocking",
|
||||||
.description = "If true, parent windows of modals will not be interactive.",
|
.description = "if true, parent windows of modals will not be interactive.",
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SBoolData{true},
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "general:locale",
|
||||||
|
.description = "overrides the system locale",
|
||||||
|
.type = CONFIG_OPTION_STRING_SHORT,
|
||||||
|
.data = SConfigOptionDescription::SStringData{""},
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* decoration:
|
* decoration:
|
||||||
|
|
@ -1115,6 +1115,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SRangeData{0, -20, 20},
|
.data = SConfigOptionDescription::SRangeData{0, -20, 20},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "group:groupbar:blur",
|
||||||
|
.description = "enable background blur for groupbars",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{false},
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* misc:
|
* misc:
|
||||||
|
|
@ -1273,11 +1279,11 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.data = SConfigOptionDescription::SBoolData{true},
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
},
|
},
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "misc:new_window_takes_over_fullscreen",
|
.value = "misc:on_focus_under_fullscreen",
|
||||||
.description = "if there is a fullscreen or maximized window, decide whether a new tiled window opened should replace it, stay behind or disable the fullscreen/maximized "
|
.description = "if there is a fullscreen or maximized window, decide whether a tiled window requested to focus should replace it, stay behind or disable the "
|
||||||
"state. 0 - behind, 1 - takes over, 2 - unfullscreen/unmaxize [0/1/2]",
|
"fullscreen/maximized state. 0 - ignore focus request (keep focus on fullscreen window), 1 - takes over, 2 - unfullscreen/unmaximize [0/1/2]",
|
||||||
.type = CONFIG_OPTION_INT,
|
.type = CONFIG_OPTION_INT,
|
||||||
.data = SConfigOptionDescription::SRangeData{0, 0, 2},
|
.data = SConfigOptionDescription::SRangeData{2, 0, 2},
|
||||||
},
|
},
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "misc:exit_window_retains_fullscreen",
|
.value = "misc:exit_window_retains_fullscreen",
|
||||||
|
|
@ -1315,6 +1321,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SBoolData{false},
|
.data = SConfigOptionDescription::SBoolData{false},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "misc:disable_watchdog_warning",
|
||||||
|
.description = "whether to disable the warning about not using start-hyprland.",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{false},
|
||||||
|
},
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "misc:lockdead_screen_delay",
|
.value = "misc:lockdead_screen_delay",
|
||||||
.description = "the delay in ms after the lockdead screen appears if the lock screen did not appear after a lock event occurred.",
|
.description = "the delay in ms after the lockdead screen appears if the lock screen did not appear after a lock event occurred.",
|
||||||
|
|
@ -1646,6 +1658,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SBoolData{false},
|
.data = SConfigOptionDescription::SBoolData{false},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "cursor:zoom_detached_camera",
|
||||||
|
.description = "Detaches the camera from the mouse when zoomed in, only ever moving to keep the mouse in view",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
|
},
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "cursor:enable_hyprcursor",
|
.value = "cursor:enable_hyprcursor",
|
||||||
.description = "whether to enable hyprcursor support",
|
.description = "whether to enable hyprcursor support",
|
||||||
|
|
@ -1664,6 +1682,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SBoolData{true},
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "cursor:hide_on_tablet",
|
||||||
|
.description = "Hides the cursor when the last input was a tablet input until a mouse input is done.",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
|
},
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "cursor:use_cpu_buffer",
|
.value = "cursor:use_cpu_buffer",
|
||||||
.description = "Makes HW cursors use a CPU buffer. Required on Nvidia to have HW cursors. Experimental",
|
.description = "Makes HW cursors use a CPU buffer. Required on Nvidia to have HW cursors. Experimental",
|
||||||
|
|
@ -1940,12 +1964,6 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_STRING_SHORT,
|
.type = CONFIG_OPTION_STRING_SHORT,
|
||||||
.data = SConfigOptionDescription::SStringData{"left"},
|
.data = SConfigOptionDescription::SStringData{"left"},
|
||||||
},
|
},
|
||||||
SConfigOptionDescription{
|
|
||||||
.value = "master:inherit_fullscreen",
|
|
||||||
.description = "inherit fullscreen status when cycling/swapping to another window (e.g. monocle layout)",
|
|
||||||
.type = CONFIG_OPTION_BOOL,
|
|
||||||
.data = SConfigOptionDescription::SBoolData{true},
|
|
||||||
},
|
|
||||||
SConfigOptionDescription{
|
SConfigOptionDescription{
|
||||||
.value = "master:slave_count_for_center_master",
|
.value = "master:slave_count_for_center_master",
|
||||||
.description = "when using orientation=center, make the master window centered only when at least this many slave windows are open. (Set 0 to always_center_master)",
|
.description = "when using orientation=center, make the master window centered only when at least this many slave windows are open. (Set 0 to always_center_master)",
|
||||||
|
|
@ -1993,4 +2011,16 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SBoolData{false},
|
.data = SConfigOptionDescription::SBoolData{false},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Quirks
|
||||||
|
*/
|
||||||
|
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "quirks:prefer_hdr",
|
||||||
|
.description = "Prefer HDR mode. 0 - off, 1 - always, 2 - gamescope only",
|
||||||
|
.type = CONFIG_OPTION_INT,
|
||||||
|
.data = SConfigOptionDescription::SRangeData{.value = 0, .min = 0, .max = 2},
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -12,15 +12,14 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
#include "../helpers/Monitor.hpp"
|
#include "../helpers/Monitor.hpp"
|
||||||
#include "../desktop/Window.hpp"
|
#include "../desktop/view/Window.hpp"
|
||||||
#include "../desktop/LayerRule.hpp"
|
|
||||||
|
|
||||||
#include "ConfigDataValues.hpp"
|
#include "ConfigDataValues.hpp"
|
||||||
#include "../SharedDefs.hpp"
|
#include "../SharedDefs.hpp"
|
||||||
#include "../helpers/Color.hpp"
|
#include "../helpers/Color.hpp"
|
||||||
#include "../desktop/DesktopTypes.hpp"
|
#include "../desktop/DesktopTypes.hpp"
|
||||||
|
#include "../desktop/reserved/ReservedArea.hpp"
|
||||||
#include "../helpers/memory/Memory.hpp"
|
#include "../helpers/memory/Memory.hpp"
|
||||||
#include "../desktop/WindowRule.hpp"
|
|
||||||
#include "../managers/XWaylandManager.hpp"
|
#include "../managers/XWaylandManager.hpp"
|
||||||
#include "../managers/KeybindManager.hpp"
|
#include "../managers/KeybindManager.hpp"
|
||||||
|
|
||||||
|
|
@ -50,13 +49,6 @@ struct SWorkspaceRule {
|
||||||
std::map<std::string, std::string> layoutopts;
|
std::map<std::string, std::string> layoutopts;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorAdditionalReservedArea {
|
|
||||||
int top = 0;
|
|
||||||
int bottom = 0;
|
|
||||||
int left = 0;
|
|
||||||
int right = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SPluginKeyword {
|
struct SPluginKeyword {
|
||||||
HANDLE handle = nullptr;
|
HANDLE handle = nullptr;
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
@ -68,11 +60,6 @@ struct SPluginVariable {
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SExecRequestedRule {
|
|
||||||
std::string szRule = "";
|
|
||||||
uint64_t iPid = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eConfigOptionType : uint8_t {
|
enum eConfigOptionType : uint8_t {
|
||||||
CONFIG_OPTION_BOOL = 0,
|
CONFIG_OPTION_BOOL = 0,
|
||||||
CONFIG_OPTION_INT = 1, /* e.g. 0/1/2*/
|
CONFIG_OPTION_INT = 1, /* e.g. 0/1/2*/
|
||||||
|
|
@ -192,7 +179,7 @@ class CMonitorRuleParser {
|
||||||
|
|
||||||
void setDisabled();
|
void setDisabled();
|
||||||
void setMirror(const std::string& value);
|
void setMirror(const std::string& value);
|
||||||
bool setReserved(const SMonitorAdditionalReservedArea& value);
|
bool setReserved(const Desktop::CReservedArea& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SMonitorRule m_rule;
|
SMonitorRule m_rule;
|
||||||
|
|
@ -203,39 +190,34 @@ class CConfigManager {
|
||||||
public:
|
public:
|
||||||
CConfigManager();
|
CConfigManager();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void reload();
|
void reload();
|
||||||
std::string verify();
|
std::string verify();
|
||||||
|
|
||||||
int getDeviceInt(const std::string&, const std::string&, const std::string& fallback = "");
|
int getDeviceInt(const std::string&, const std::string&, const std::string& fallback = "");
|
||||||
float getDeviceFloat(const std::string&, const std::string&, const std::string& fallback = "");
|
float getDeviceFloat(const std::string&, const std::string&, const std::string& fallback = "");
|
||||||
Vector2D getDeviceVec(const std::string&, const std::string&, const std::string& fallback = "");
|
Vector2D getDeviceVec(const std::string&, const std::string&, const std::string& fallback = "");
|
||||||
std::string getDeviceString(const std::string&, const std::string&, const std::string& fallback = "");
|
std::string getDeviceString(const std::string&, const std::string&, const std::string& fallback = "");
|
||||||
bool deviceConfigExplicitlySet(const std::string&, const std::string&);
|
bool deviceConfigExplicitlySet(const std::string&, const std::string&);
|
||||||
bool deviceConfigExists(const std::string&);
|
bool deviceConfigExists(const std::string&);
|
||||||
Hyprlang::CConfigValue* getConfigValueSafeDevice(const std::string& dev, const std::string& val, const std::string& fallback);
|
Hyprlang::CConfigValue* getConfigValueSafeDevice(const std::string& dev, const std::string& val, const std::string& fallback);
|
||||||
bool shouldBlurLS(const std::string&);
|
|
||||||
|
|
||||||
void* const* getConfigValuePtr(const std::string&);
|
void* const* getConfigValuePtr(const std::string&);
|
||||||
Hyprlang::CConfigValue* getHyprlangConfigValuePtr(const std::string& name, const std::string& specialCat = "");
|
Hyprlang::CConfigValue* getHyprlangConfigValuePtr(const std::string& name, const std::string& specialCat = "");
|
||||||
std::string getMainConfigPath();
|
std::string getMainConfigPath();
|
||||||
std::string getConfigString();
|
std::string getConfigString();
|
||||||
|
|
||||||
SMonitorRule getMonitorRuleFor(const PHLMONITOR);
|
SMonitorRule getMonitorRuleFor(const PHLMONITOR);
|
||||||
SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace);
|
SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace);
|
||||||
std::string getDefaultWorkspaceFor(const std::string&);
|
std::string getDefaultWorkspaceFor(const std::string&);
|
||||||
|
|
||||||
PHLMONITOR getBoundMonitorForWS(const std::string&);
|
PHLMONITOR getBoundMonitorForWS(const std::string&);
|
||||||
std::string getBoundMonitorStringForWS(const std::string&);
|
std::string getBoundMonitorStringForWS(const std::string&);
|
||||||
const std::vector<SWorkspaceRule>& getAllWorkspaceRules();
|
const std::vector<SWorkspaceRule>& getAllWorkspaceRules();
|
||||||
|
|
||||||
std::vector<SP<CWindowRule>> getMatchingRules(PHLWINDOW, bool dynamic = true, bool shadowExec = false);
|
void ensurePersistentWorkspacesPresent();
|
||||||
std::vector<SP<CLayerRule>> getMatchingRules(PHLLS);
|
|
||||||
void ensurePersistentWorkspacesPresent();
|
|
||||||
|
|
||||||
const std::vector<SConfigOptionDescription>& getAllDescriptions();
|
const std::vector<SConfigOptionDescription>& getAllDescriptions();
|
||||||
|
|
||||||
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, SP<Hyprutils::Animation::SAnimationPropertyConfig>>& getAnimationConfig();
|
const std::unordered_map<std::string, SP<Hyprutils::Animation::SAnimationPropertyConfig>>& getAnimationConfig();
|
||||||
|
|
||||||
|
|
@ -260,8 +242,6 @@ class CConfigManager {
|
||||||
|
|
||||||
SP<Hyprutils::Animation::SAnimationPropertyConfig> getAnimationPropertyConfig(const std::string&);
|
SP<Hyprutils::Animation::SAnimationPropertyConfig> getAnimationPropertyConfig(const std::string&);
|
||||||
|
|
||||||
void addExecRule(const SExecRequestedRule&);
|
|
||||||
|
|
||||||
void handlePluginLoads();
|
void handlePluginLoads();
|
||||||
std::string getErrors();
|
std::string getErrors();
|
||||||
|
|
||||||
|
|
@ -274,22 +254,24 @@ class CConfigManager {
|
||||||
std::optional<std::string> handleMonitor(const std::string&, const std::string&);
|
std::optional<std::string> handleMonitor(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleBind(const std::string&, const std::string&);
|
std::optional<std::string> handleBind(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleUnbind(const std::string&, const std::string&);
|
std::optional<std::string> handleUnbind(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleWindowRule(const std::string&, const std::string&);
|
|
||||||
std::optional<std::string> handleLayerRule(const std::string&, const std::string&);
|
|
||||||
std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&);
|
std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleBezier(const std::string&, const std::string&);
|
std::optional<std::string> handleBezier(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleAnimation(const std::string&, const std::string&);
|
std::optional<std::string> handleAnimation(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleSource(const std::string&, const std::string&);
|
std::optional<std::string> handleSource(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleSubmap(const std::string&, const std::string&);
|
std::optional<std::string> handleSubmap(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleBlurLS(const std::string&, const std::string&);
|
|
||||||
std::optional<std::string> handleBindWS(const std::string&, const std::string&);
|
std::optional<std::string> handleBindWS(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleEnv(const std::string&, const std::string&);
|
std::optional<std::string> handleEnv(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handlePlugin(const std::string&, const std::string&);
|
std::optional<std::string> handlePlugin(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handlePermission(const std::string&, const std::string&);
|
std::optional<std::string> handlePermission(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleGesture(const std::string&, const std::string&);
|
std::optional<std::string> handleGesture(const std::string&, const std::string&);
|
||||||
|
std::optional<std::string> handleWindowrule(const std::string&, const std::string&);
|
||||||
|
std::optional<std::string> handleLayerrule(const std::string&, const std::string&);
|
||||||
|
|
||||||
std::optional<std::string> handleMonitorv2(const std::string& output);
|
std::optional<std::string> handleMonitorv2(const std::string& output);
|
||||||
Hyprlang::CParseResult handleMonitorv2();
|
Hyprlang::CParseResult handleMonitorv2();
|
||||||
|
std::optional<std::string> addRuleFromConfigKey(const std::string& name);
|
||||||
|
std::optional<std::string> addLayerRuleFromConfigKey(const std::string& name);
|
||||||
|
Hyprlang::CParseResult reloadRules();
|
||||||
|
|
||||||
std::string m_configCurrentPath;
|
std::string m_configCurrentPath;
|
||||||
|
|
||||||
|
|
@ -310,19 +292,16 @@ class CConfigManager {
|
||||||
|
|
||||||
SSubmap m_currentSubmap;
|
SSubmap m_currentSubmap;
|
||||||
|
|
||||||
std::vector<SExecRequestedRule> m_execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
|
|
||||||
|
|
||||||
std::vector<std::string> m_declaredPlugins;
|
std::vector<std::string> m_declaredPlugins;
|
||||||
std::vector<SPluginKeyword> m_pluginKeywords;
|
std::vector<SPluginKeyword> m_pluginKeywords;
|
||||||
std::vector<SPluginVariable> m_pluginVariables;
|
std::vector<SPluginVariable> m_pluginVariables;
|
||||||
|
|
||||||
|
std::vector<SP<Desktop::Rule::IRule>> m_keywordRules;
|
||||||
|
|
||||||
bool m_isFirstLaunch = true; // For exec-once
|
bool m_isFirstLaunch = true; // For exec-once
|
||||||
|
|
||||||
std::vector<SMonitorRule> m_monitorRules;
|
std::vector<SMonitorRule> m_monitorRules;
|
||||||
std::vector<SWorkspaceRule> m_workspaceRules;
|
std::vector<SWorkspaceRule> m_workspaceRules;
|
||||||
std::vector<SP<CWindowRule>> m_windowRules;
|
|
||||||
std::vector<SP<CLayerRule>> m_layerRules;
|
|
||||||
std::vector<std::string> m_blurLSNamespaces;
|
|
||||||
|
|
||||||
bool m_firstExecDispatched = false;
|
bool m_firstExecDispatched = false;
|
||||||
bool m_manualCrashInitiated = false;
|
bool m_manualCrashInitiated = false;
|
||||||
|
|
@ -336,11 +315,11 @@ class CConfigManager {
|
||||||
uint32_t m_configValueNumber = 0;
|
uint32_t m_configValueNumber = 0;
|
||||||
|
|
||||||
// internal methods
|
// internal methods
|
||||||
void updateBlurredLS(const std::string&, const bool);
|
|
||||||
void setDefaultAnimationVars();
|
void setDefaultAnimationVars();
|
||||||
std::optional<std::string> resetHLConfig();
|
std::optional<std::string> resetHLConfig();
|
||||||
std::optional<std::string> generateConfig(std::string configPath);
|
std::optional<std::string> generateConfig(std::string configPath, bool safeMode = false);
|
||||||
std::optional<std::string> verifyConfigExists();
|
std::optional<std::string> verifyConfigExists();
|
||||||
|
void reloadRuleConfigs();
|
||||||
|
|
||||||
void postConfigReload(const Hyprlang::CParseResult& result);
|
void postConfigReload(const Hyprlang::CParseResult& result);
|
||||||
SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&);
|
SWorkspaceRule mergeWorkspaceRules(const SWorkspaceRule&, const SWorkspaceRule&);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#include "ConfigWatcher.hpp"
|
#include "ConfigWatcher.hpp"
|
||||||
|
#if defined(__linux__)
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
#endif
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#include "../debug/Log.hpp"
|
#include "../debug/log/Logger.hpp"
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -11,14 +13,14 @@ using namespace Hyprutils::OS;
|
||||||
|
|
||||||
CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) {
|
CConfigWatcher::CConfigWatcher() : m_inotifyFd(inotify_init()) {
|
||||||
if (!m_inotifyFd.isValid()) {
|
if (!m_inotifyFd.isValid()) {
|
||||||
Debug::log(ERR, "CConfigWatcher couldn't open an inotify node. Config will not be automatically reloaded");
|
Log::logger->log(Log::ERR, "CConfigWatcher couldn't open an inotify node. Config will not be automatically reloaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make CFileDescriptor take F_GETFL, F_SETFL
|
// TODO: make CFileDescriptor take F_GETFL, F_SETFL
|
||||||
const int FLAGS = fcntl(m_inotifyFd.get(), F_GETFL, 0);
|
const int FLAGS = fcntl(m_inotifyFd.get(), F_GETFL, 0);
|
||||||
if (fcntl(m_inotifyFd.get(), F_SETFL, FLAGS | O_NONBLOCK) < 0) {
|
if (fcntl(m_inotifyFd.get(), F_SETFL, FLAGS | O_NONBLOCK) < 0) {
|
||||||
Debug::log(ERR, "CConfigWatcher couldn't non-block inotify node. Config will not be automatically reloaded");
|
Log::logger->log(Log::ERR, "CConfigWatcher couldn't non-block inotify node. Config will not be automatically reloaded");
|
||||||
m_inotifyFd.reset();
|
m_inotifyFd.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -76,19 +78,19 @@ void CConfigWatcher::onInotifyEvent() {
|
||||||
const auto* ev = rc<const inotify_event*>(buffer.data() + offset);
|
const auto* ev = rc<const inotify_event*>(buffer.data() + offset);
|
||||||
|
|
||||||
if (offset + sizeof(inotify_event) > sc<size_t>(bytesRead)) {
|
if (offset + sizeof(inotify_event) > sc<size_t>(bytesRead)) {
|
||||||
Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated header");
|
Log::logger->log(Log::ERR, "CConfigWatcher: malformed inotify event, truncated header");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + sizeof(inotify_event) + ev->len > sc<size_t>(bytesRead)) {
|
if (offset + sizeof(inotify_event) + ev->len > sc<size_t>(bytesRead)) {
|
||||||
Debug::log(ERR, "CConfigWatcher: malformed inotify event, truncated name field");
|
Log::logger->log(Log::ERR, "CConfigWatcher: malformed inotify event, truncated name field");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto WD = std::ranges::find_if(m_watches, [wd = ev->wd](const auto& e) { return e.wd == wd; });
|
const auto WD = std::ranges::find_if(m_watches, [wd = ev->wd](const auto& e) { return e.wd == wd; });
|
||||||
|
|
||||||
if (WD == m_watches.end())
|
if (WD == m_watches.end())
|
||||||
Debug::log(ERR, "CConfigWatcher: got an event for wd {} which we don't have?!", ev->wd);
|
Log::logger->log(Log::ERR, "CConfigWatcher: got an event for wd {} which we don't have?!", ev->wd);
|
||||||
else
|
else
|
||||||
m_watchCallback(SConfigWatchEvent{
|
m_watchCallback(SConfigWatchEvent{
|
||||||
.file = WD->file,
|
.file = WD->file,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../defines.hpp"
|
|
||||||
|
|
||||||
namespace NCrashReporter {
|
|
||||||
void createAndSaveCrash(int sig);
|
|
||||||
};
|
|
||||||
|
|
@ -40,10 +40,12 @@ using namespace Hyprutils::OS;
|
||||||
#include "../devices/ITouch.hpp"
|
#include "../devices/ITouch.hpp"
|
||||||
#include "../devices/Tablet.hpp"
|
#include "../devices/Tablet.hpp"
|
||||||
#include "../protocols/GlobalShortcuts.hpp"
|
#include "../protocols/GlobalShortcuts.hpp"
|
||||||
#include "debug/RollingLogFollow.hpp"
|
#include "debug/log/RollingLogFollow.hpp"
|
||||||
#include "config/ConfigManager.hpp"
|
#include "config/ConfigManager.hpp"
|
||||||
#include "helpers/MiscFunctions.hpp"
|
#include "helpers/MiscFunctions.hpp"
|
||||||
#include "../desktop/LayerSurface.hpp"
|
#include "../desktop/view/LayerSurface.hpp"
|
||||||
|
#include "../desktop/rule/Engine.hpp"
|
||||||
|
#include "../desktop/state/FocusState.hpp"
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
|
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
|
|
@ -253,13 +255,13 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
|
||||||
escapeJSONStrings(m->m_output->serial), sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), sc<int>(m->m_output->physicalSize.x),
|
escapeJSONStrings(m->m_output->serial), sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), sc<int>(m->m_output->physicalSize.x),
|
||||||
sc<int>(m->m_output->physicalSize.y), m->m_refreshRate, sc<int>(m->m_position.x), sc<int>(m->m_position.y), m->activeWorkspaceID(),
|
sc<int>(m->m_output->physicalSize.y), m->m_refreshRate, sc<int>(m->m_position.x), sc<int>(m->m_position.y), m->activeWorkspaceID(),
|
||||||
(!m->m_activeWorkspace ? "" : escapeJSONStrings(m->m_activeWorkspace->m_name)), m->activeSpecialWorkspaceID(),
|
(!m->m_activeWorkspace ? "" : escapeJSONStrings(m->m_activeWorkspace->m_name)), m->activeSpecialWorkspaceID(),
|
||||||
escapeJSONStrings(m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""), sc<int>(m->m_reservedTopLeft.x), sc<int>(m->m_reservedTopLeft.y),
|
escapeJSONStrings(m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""), sc<int>(m->m_reservedArea.left()), sc<int>(m->m_reservedArea.top()),
|
||||||
sc<int>(m->m_reservedBottomRight.x), sc<int>(m->m_reservedBottomRight.y), m->m_scale, sc<int>(m->m_transform), (m == g_pCompositor->m_lastMonitor ? "true" : "false"),
|
sc<int>(m->m_reservedArea.right()), sc<int>(m->m_reservedArea.bottom()), m->m_scale, sc<int>(m->m_transform),
|
||||||
(m->m_dpmsStatus ? "true" : "false"), (m->m_output->state->state().adaptiveSync ? "true" : "false"), rc<uint64_t>(m->m_solitaryClient.get()),
|
(m == Desktop::focusState()->monitor() ? "true" : "false"), (m->m_dpmsStatus ? "true" : "false"), (m->m_output->state->state().adaptiveSync ? "true" : "false"),
|
||||||
getSolitaryBlockedReason(m, format), (m->m_tearingState.activelyTearing ? "true" : "false"), getTearingBlockedReason(m, format), rc<uint64_t>(m->m_lastScanout.get()),
|
rc<uint64_t>(m->m_solitaryClient.get()), getSolitaryBlockedReason(m, format), (m->m_tearingState.activelyTearing ? "true" : "false"),
|
||||||
getDSBlockedReason(m, format), (m->m_enabled ? "false" : "true"), formatToString(m->m_output->state->state().drmFormat),
|
getTearingBlockedReason(m, format), rc<uint64_t>(m->m_lastScanout.get()), getDSBlockedReason(m, format), (m->m_enabled ? "false" : "true"),
|
||||||
m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format), (NCMType::toString(m->m_cmType)), (m->m_sdrBrightness),
|
formatToString(m->m_output->state->state().drmFormat), m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format),
|
||||||
(m->m_sdrSaturation), (m->m_sdrMinLuminance), (m->m_sdrMaxLuminance));
|
(NCMType::toString(m->m_cmType)), (m->m_sdrBrightness), (m->m_sdrSaturation), (m->m_sdrMinLuminance), (m->m_sdrMaxLuminance));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result += std::format(
|
result += std::format(
|
||||||
|
|
@ -272,8 +274,8 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
|
||||||
m->m_name, m->m_id, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_refreshRate, sc<int>(m->m_position.x), sc<int>(m->m_position.y), m->m_shortDescription,
|
m->m_name, m->m_id, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_refreshRate, sc<int>(m->m_position.x), sc<int>(m->m_position.y), m->m_shortDescription,
|
||||||
m->m_output->make, m->m_output->model, sc<int>(m->m_output->physicalSize.x), sc<int>(m->m_output->physicalSize.y), m->m_output->serial, m->activeWorkspaceID(),
|
m->m_output->make, m->m_output->model, sc<int>(m->m_output->physicalSize.x), sc<int>(m->m_output->physicalSize.y), m->m_output->serial, m->activeWorkspaceID(),
|
||||||
(!m->m_activeWorkspace ? "" : m->m_activeWorkspace->m_name), m->activeSpecialWorkspaceID(), (m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""),
|
(!m->m_activeWorkspace ? "" : m->m_activeWorkspace->m_name), m->activeSpecialWorkspaceID(), (m->m_activeSpecialWorkspace ? m->m_activeSpecialWorkspace->m_name : ""),
|
||||||
sc<int>(m->m_reservedTopLeft.x), sc<int>(m->m_reservedTopLeft.y), sc<int>(m->m_reservedBottomRight.x), sc<int>(m->m_reservedBottomRight.y), m->m_scale,
|
sc<int>(m->m_reservedArea.left()), sc<int>(m->m_reservedArea.top()), sc<int>(m->m_reservedArea.right()), sc<int>(m->m_reservedArea.bottom()), m->m_scale,
|
||||||
sc<int>(m->m_transform), (m == g_pCompositor->m_lastMonitor ? "yes" : "no"), sc<int>(m->m_dpmsStatus), m->m_output->state->state().adaptiveSync,
|
sc<int>(m->m_transform), (m == Desktop::focusState()->monitor() ? "yes" : "no"), sc<int>(m->m_dpmsStatus), m->m_output->state->state().adaptiveSync,
|
||||||
rc<uint64_t>(m->m_solitaryClient.get()), getSolitaryBlockedReason(m, format), m->m_tearingState.activelyTearing, getTearingBlockedReason(m, format),
|
rc<uint64_t>(m->m_solitaryClient.get()), getSolitaryBlockedReason(m, format), m->m_tearingState.activelyTearing, getTearingBlockedReason(m, format),
|
||||||
rc<uint64_t>(m->m_lastScanout.get()), getDSBlockedReason(m, format), !m->m_enabled, formatToString(m->m_output->state->state().drmFormat),
|
rc<uint64_t>(m->m_lastScanout.get()), getDSBlockedReason(m, format), !m->m_enabled, formatToString(m->m_output->state->state().drmFormat),
|
||||||
m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format), (NCMType::toString(m->m_cmType)), (m->m_sdrBrightness),
|
m->m_mirrorOf ? std::format("{}", m->m_mirrorOf->m_id) : "none", availableModesForOutput(m, format), (NCMType::toString(m->m_cmType)), (m->m_sdrBrightness),
|
||||||
|
|
@ -317,7 +319,7 @@ static std::string monitorsRequest(eHyprCtlOutputFormat format, std::string requ
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string getTagsData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
static std::string getTagsData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
const auto tags = w->m_tags.getTags();
|
const auto tags = w->m_ruleApplicator->m_tagKeeper.getTags();
|
||||||
|
|
||||||
if (format == eHyprCtlOutputFormat::FORMAT_JSON)
|
if (format == eHyprCtlOutputFormat::FORMAT_JSON)
|
||||||
return std::ranges::fold_left(tags, std::string(),
|
return std::ranges::fold_left(tags, std::string(),
|
||||||
|
|
@ -352,8 +354,8 @@ static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
auto getFocusHistoryID = [](PHLWINDOW wnd) -> int {
|
auto getFocusHistoryID = [](PHLWINDOW wnd) -> int {
|
||||||
for (size_t i = 0; i < g_pCompositor->m_windowFocusHistory.size(); ++i) {
|
for (size_t i = 0; i < Desktop::focusState()->windowHistory().size(); ++i) {
|
||||||
if (g_pCompositor->m_windowFocusHistory[i].lock() == wnd)
|
if (Desktop::focusState()->windowHistory()[i].lock() == wnd)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -389,7 +391,8 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
"focusHistoryID": {},
|
"focusHistoryID": {},
|
||||||
"inhibitingIdle": {},
|
"inhibitingIdle": {},
|
||||||
"xdgTag": "{}",
|
"xdgTag": "{}",
|
||||||
"xdgDescription": "{}"
|
"xdgDescription": "{}",
|
||||||
|
"contentType": "{}"
|
||||||
}},)#",
|
}},)#",
|
||||||
rc<uintptr_t>(w.get()), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), sc<int>(w->m_realPosition->goal().x),
|
rc<uintptr_t>(w.get()), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), sc<int>(w->m_realPosition->goal().x),
|
||||||
sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
|
sc<int>(w->m_realPosition->goal().y), sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
|
||||||
|
|
@ -397,20 +400,21 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
|
||||||
w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle), w->getPID(),
|
w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle), w->getPID(),
|
||||||
(sc<int>(w->m_isX11) == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client),
|
(sc<int>(w->m_isX11) == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client),
|
||||||
getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w),
|
getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w),
|
||||||
(g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")));
|
(g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")),
|
||||||
|
escapeJSONStrings(NContentType::toString(w->getContentType())));
|
||||||
} else {
|
} else {
|
||||||
return std::format(
|
return std::format(
|
||||||
"Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tpseudo: {}\n\tmonitor: {}\n\tclass: {}\n\ttitle: "
|
"Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tpseudo: {}\n\tmonitor: {}\n\tclass: {}\n\ttitle: "
|
||||||
"{}\n\tinitialClass: {}\n\tinitialTitle: {}\n\tpid: "
|
"{}\n\tinitialClass: {}\n\tinitialTitle: {}\n\tpid: "
|
||||||
"{}\n\txwayland: {}\n\tpinned: "
|
"{}\n\txwayland: {}\n\tpinned: "
|
||||||
"{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: {}\n\txdgTag: "
|
"{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: {}\n\txdgTag: "
|
||||||
"{}\n\txdgDescription: {}\n\n",
|
"{}\n\txdgDescription: {}\n\tcontentType: {}\n\n",
|
||||||
rc<uintptr_t>(w.get()), w->m_title, sc<int>(w->m_isMapped), sc<int>(w->isHidden()), sc<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y),
|
rc<uintptr_t>(w.get()), w->m_title, sc<int>(w->m_isMapped), sc<int>(w->isHidden()), sc<int>(w->m_realPosition->goal().x), sc<int>(w->m_realPosition->goal().y),
|
||||||
sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
|
sc<int>(w->m_realSize->goal().x), sc<int>(w->m_realSize->goal().y), w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
|
||||||
(!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_isFloating), sc<int>(w->m_isPseudotiled), w->monitorID(), w->m_class, w->m_title, w->m_initialClass,
|
(!w->m_workspace ? "" : w->m_workspace->m_name), sc<int>(w->m_isFloating), sc<int>(w->m_isPseudotiled), w->monitorID(), w->m_class, w->m_title, w->m_initialClass,
|
||||||
w->m_initialTitle, w->getPID(), sc<int>(w->m_isX11), sc<int>(w->m_pinned), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client),
|
w->m_initialTitle, w->getPID(), sc<int>(w->m_isX11), sc<int>(w->m_pinned), sc<uint8_t>(w->m_fullscreenState.internal), sc<uint8_t>(w->m_fullscreenState.client),
|
||||||
getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), sc<int>(g_pInputManager->isWindowInhibiting(w, false)),
|
getGroupedData(w, format), getTagsData(w, format), rc<uintptr_t>(w->m_swallowed.get()), getFocusHistoryID(w), sc<int>(g_pInputManager->isWindowInhibiting(w, false)),
|
||||||
w->xdgTag().value_or(""), w->xdgDescription().value_or(""));
|
w->xdgTag().value_or(""), w->xdgDescription().value_or(""), NContentType::toString(w->getContentType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -521,11 +525,11 @@ static std::string getWorkspaceRuleData(const SWorkspaceRule& r, eHyprCtlOutputF
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string activeWorkspaceRequest(eHyprCtlOutputFormat format, std::string request) {
|
static std::string activeWorkspaceRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
if (!g_pCompositor->m_lastMonitor)
|
if (!Desktop::focusState()->monitor())
|
||||||
return "unsafe state";
|
return "unsafe state";
|
||||||
|
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
auto w = g_pCompositor->m_lastMonitor->m_activeWorkspace;
|
auto w = Desktop::focusState()->monitor()->m_activeWorkspace;
|
||||||
|
|
||||||
if (!valid(w))
|
if (!valid(w))
|
||||||
return "internal error";
|
return "internal error";
|
||||||
|
|
@ -575,7 +579,7 @@ static std::string workspaceRulesRequest(eHyprCtlOutputFormat format, std::strin
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string activeWindowRequest(eHyprCtlOutputFormat format, std::string request) {
|
static std::string activeWindowRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
const auto PWINDOW = Desktop::focusState()->window();
|
||||||
|
|
||||||
if (!validMapped(PWINDOW))
|
if (!validMapped(PWINDOW))
|
||||||
return format == eHyprCtlOutputFormat::FORMAT_JSON ? "{}" : "Invalid";
|
return format == eHyprCtlOutputFormat::FORMAT_JSON ? "{}" : "Invalid";
|
||||||
|
|
@ -953,11 +957,10 @@ static std::string rollinglogRequest(eHyprCtlOutputFormat format, std::string re
|
||||||
|
|
||||||
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
|
||||||
result += "[\n\"log\":\"";
|
result += "[\n\"log\":\"";
|
||||||
result += escapeJSONStrings(Debug::m_rollingLog);
|
result += escapeJSONStrings(Log::logger->rolling());
|
||||||
result += "\"]";
|
result += "\"]";
|
||||||
} else {
|
} else
|
||||||
result = Debug::m_rollingLog;
|
result = Log::logger->rolling();
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -1025,6 +1028,7 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
|
||||||
"has_description": {},
|
"has_description": {},
|
||||||
"modmask": {},
|
"modmask": {},
|
||||||
"submap": "{}",
|
"submap": "{}",
|
||||||
|
"submap_universal": "{}",
|
||||||
"key": "{}",
|
"key": "{}",
|
||||||
"keycode": {},
|
"keycode": {},
|
||||||
"catch_all": {},
|
"catch_all": {},
|
||||||
|
|
@ -1033,8 +1037,9 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
|
||||||
"arg": "{}"
|
"arg": "{}"
|
||||||
}},)#",
|
}},)#",
|
||||||
kb->locked ? "true" : "false", kb->mouse ? "true" : "false", kb->release ? "true" : "false", kb->repeat ? "true" : "false", kb->longPress ? "true" : "false",
|
kb->locked ? "true" : "false", kb->mouse ? "true" : "false", kb->release ? "true" : "false", kb->repeat ? "true" : "false", kb->longPress ? "true" : "false",
|
||||||
kb->nonConsuming ? "true" : "false", kb->hasDescription ? "true" : "false", kb->modmask, escapeJSONStrings(kb->submap.name), escapeJSONStrings(kb->key),
|
kb->nonConsuming ? "true" : "false", kb->hasDescription ? "true" : "false", kb->modmask, escapeJSONStrings(kb->submap.name), kb->submapUniversal,
|
||||||
kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler), escapeJSONStrings(kb->arg));
|
escapeJSONStrings(kb->key), kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler),
|
||||||
|
escapeJSONStrings(kb->arg));
|
||||||
}
|
}
|
||||||
trimTrailingComma(ret);
|
trimTrailingComma(ret);
|
||||||
ret += "]";
|
ret += "]";
|
||||||
|
|
@ -1057,8 +1062,11 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
result += "\n";
|
result += "\n";
|
||||||
result += getBuiltSystemLibraryNames();
|
result += getBuiltSystemLibraryNames();
|
||||||
result += "\n";
|
result += "\n";
|
||||||
|
result += "Version ABI string: ";
|
||||||
|
result += __hyprland_api_get_hash();
|
||||||
|
result += "\n";
|
||||||
|
|
||||||
#if (!ISDEBUG && !defined(NO_XWAYLAND))
|
#if (!ISDEBUG && !defined(NO_XWAYLAND) && !defined(BUILT_WITH_NIX))
|
||||||
result += "no flags were set\n";
|
result += "no flags were set\n";
|
||||||
#else
|
#else
|
||||||
result += "flags set:\n";
|
result += "flags set:\n";
|
||||||
|
|
@ -1068,6 +1076,9 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
#ifdef NO_XWAYLAND
|
#ifdef NO_XWAYLAND
|
||||||
result += "no xwayland\n";
|
result += "no xwayland\n";
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef BUILT_WITH_NIX
|
||||||
|
result += "nix\n";
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1091,10 +1102,12 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
"systemHyprutils": "{}",
|
"systemHyprutils": "{}",
|
||||||
"systemHyprcursor": "{}",
|
"systemHyprcursor": "{}",
|
||||||
"systemHyprgraphics": "{}",
|
"systemHyprgraphics": "{}",
|
||||||
|
"abiHash": "{}",
|
||||||
"flags": [)#",
|
"flags": [)#",
|
||||||
GIT_BRANCH, GIT_COMMIT_HASH, HYPRLAND_VERSION, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG,
|
GIT_BRANCH, GIT_COMMIT_HASH, HYPRLAND_VERSION, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG,
|
||||||
GIT_COMMITS, AQUAMARINE_VERSION, HYPRLANG_VERSION, HYPRUTILS_VERSION, HYPRCURSOR_VERSION, HYPRGRAPHICS_VERSION, getSystemLibraryVersion("aquamarine"),
|
GIT_COMMITS, AQUAMARINE_VERSION, HYPRLANG_VERSION, HYPRUTILS_VERSION, HYPRCURSOR_VERSION, HYPRGRAPHICS_VERSION, getSystemLibraryVersion("aquamarine"),
|
||||||
getSystemLibraryVersion("hyprlang"), getSystemLibraryVersion("hyprutils"), getSystemLibraryVersion("hyprcursor"), getSystemLibraryVersion("hyprgraphics"));
|
getSystemLibraryVersion("hyprlang"), getSystemLibraryVersion("hyprutils"), getSystemLibraryVersion("hyprcursor"), getSystemLibraryVersion("hyprgraphics"),
|
||||||
|
__hyprland_api_get_hash());
|
||||||
|
|
||||||
#if ISDEBUG
|
#if ISDEBUG
|
||||||
result += "\"debug\",";
|
result += "\"debug\",";
|
||||||
|
|
@ -1102,6 +1115,9 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
|
||||||
#ifdef NO_XWAYLAND
|
#ifdef NO_XWAYLAND
|
||||||
result += "\"no xwayland\",";
|
result += "\"no xwayland\",";
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef BUILT_WITH_NIX
|
||||||
|
result += "\"nix\",";
|
||||||
|
#endif
|
||||||
|
|
||||||
trimTrailingComma(result);
|
trimTrailingComma(result);
|
||||||
|
|
||||||
|
|
@ -1243,7 +1259,7 @@ static std::string dispatchRequest(eHyprCtlOutputFormat format, std::string in)
|
||||||
|
|
||||||
SDispatchResult res = DISPATCHER->second(DISPATCHARG);
|
SDispatchResult res = DISPATCHER->second(DISPATCHARG);
|
||||||
|
|
||||||
Debug::log(LOG, "Hyprctl: dispatcher {} : {}{}", DISPATCHSTR, DISPATCHARG, res.success ? "" : " -> " + res.error);
|
Log::logger->log(Log::DEBUG, "Hyprctl: dispatcher {} : {}{}", DISPATCHSTR, DISPATCHARG, res.success ? "" : " -> " + res.error);
|
||||||
|
|
||||||
return res.success ? "ok" : res.error;
|
return res.success ? "ok" : res.error;
|
||||||
}
|
}
|
||||||
|
|
@ -1270,8 +1286,12 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in)
|
||||||
if (COMMAND.empty())
|
if (COMMAND.empty())
|
||||||
return "Invalid input: command is empty";
|
return "Invalid input: command is empty";
|
||||||
|
|
||||||
|
g_pHyprCtl->m_currentRequestParams.isDynamicKeyword = true;
|
||||||
|
|
||||||
std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE);
|
std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE);
|
||||||
|
|
||||||
|
g_pHyprCtl->m_currentRequestParams.isDynamicKeyword = false;
|
||||||
|
|
||||||
// if we are executing a dynamic source we have to reload everything, so every if will have a check for source.
|
// if we are executing a dynamic source we have to reload everything, so every if will have a check for source.
|
||||||
if (COMMAND == "monitor" || COMMAND == "source")
|
if (COMMAND == "monitor" || COMMAND == "source")
|
||||||
g_pConfigManager->m_wantsMonitorReload = true; // for monitor keywords
|
g_pConfigManager->m_wantsMonitorReload = true; // for monitor keywords
|
||||||
|
|
@ -1304,8 +1324,7 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in)
|
||||||
g_pConfigManager->updateWatcher();
|
g_pConfigManager->updateWatcher();
|
||||||
|
|
||||||
// decorations will probably need a repaint
|
// decorations will probably need a repaint
|
||||||
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source" ||
|
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source") {
|
||||||
COMMAND.starts_with("windowrule")) {
|
|
||||||
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
|
||||||
for (auto const& m : g_pCompositor->m_monitors) {
|
for (auto const& m : g_pCompositor->m_monitors) {
|
||||||
*(m->m_cursorZoom) = *PZOOMFACTOR;
|
*(m->m_cursorZoom) = *PZOOMFACTOR;
|
||||||
|
|
@ -1314,10 +1333,13 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (COMMAND.contains("windowrule ") || COMMAND.contains("windowrule["))
|
||||||
|
g_pConfigManager->reloadRules();
|
||||||
|
|
||||||
if (COMMAND.contains("workspace"))
|
if (COMMAND.contains("workspace"))
|
||||||
g_pConfigManager->ensurePersistentWorkspacesPresent();
|
g_pConfigManager->ensurePersistentWorkspacesPresent();
|
||||||
|
|
||||||
Debug::log(LOG, "Hyprctl: keyword {} : {}", COMMAND, VALUE);
|
Log::logger->log(Log::DEBUG, "Hyprctl: keyword {} : {}", COMMAND, VALUE);
|
||||||
|
|
||||||
if (retval.empty())
|
if (retval.empty())
|
||||||
return "ok";
|
return "ok";
|
||||||
|
|
@ -1519,11 +1541,6 @@ static std::string dispatchSeterror(eHyprCtlOutputFormat format, std::string req
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string dispatchSetProp(eHyprCtlOutputFormat format, std::string request) {
|
|
||||||
auto result = g_pKeybindManager->m_dispatchers["setprop"](request.substr(request.find_first_of(' ') + 1));
|
|
||||||
return "DEPRECATED: use hyprctl dispatch setprop instead" + (result.success ? "" : "\n" + result.error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string request) {
|
static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string request) {
|
||||||
CVarList vars(request, 0, ' ');
|
CVarList vars(request, 0, ' ');
|
||||||
|
|
||||||
|
|
@ -1541,9 +1558,9 @@ static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string requ
|
||||||
const bool FORMNORM = format == FORMAT_NORMAL;
|
const bool FORMNORM = format == FORMAT_NORMAL;
|
||||||
|
|
||||||
auto sizeToString = [&](bool max) -> std::string {
|
auto sizeToString = [&](bool max) -> std::string {
|
||||||
auto sizeValue = PWINDOW->m_windowData.minSize.valueOr(Vector2D(MIN_WINDOW_SIZE, MIN_WINDOW_SIZE));
|
auto sizeValue = PWINDOW->m_ruleApplicator->minSize().valueOr(Vector2D(MIN_WINDOW_SIZE, MIN_WINDOW_SIZE));
|
||||||
if (max)
|
if (max)
|
||||||
sizeValue = PWINDOW->m_windowData.maxSize.valueOr(Vector2D(INFINITY, INFINITY));
|
sizeValue = PWINDOW->m_ruleApplicator->maxSize().valueOr(Vector2D(INFINITY, INFINITY));
|
||||||
|
|
||||||
if (FORMNORM)
|
if (FORMNORM)
|
||||||
return std::format("{} {}", sizeValue.x, sizeValue.y);
|
return std::format("{} {}", sizeValue.x, sizeValue.y);
|
||||||
|
|
@ -1554,7 +1571,7 @@ static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string requ
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto alphaToString = [&](CWindowOverridableVar<SAlphaValue>& alpha, bool getAlpha) -> std::string {
|
auto alphaToString = [&](Desktop::Types::COverridableVar<Desktop::Types::SAlphaValue>& alpha, bool getAlpha) -> std::string {
|
||||||
if (FORMNORM) {
|
if (FORMNORM) {
|
||||||
if (getAlpha)
|
if (getAlpha)
|
||||||
return std::format("{}", alpha.valueOrDefault().alpha);
|
return std::format("{}", alpha.valueOrDefault().alpha);
|
||||||
|
|
@ -1588,7 +1605,7 @@ static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string requ
|
||||||
const auto* const ACTIVECOLOR =
|
const auto* const ACTIVECOLOR =
|
||||||
!PWINDOW->m_groupData.pNextWindow.lock() ? (!PWINDOW->m_groupData.deny ? ACTIVECOL : NOGROUPACTIVECOL) : (GROUPLOCKED ? GROUPACTIVELOCKEDCOL : GROUPACTIVECOL);
|
!PWINDOW->m_groupData.pNextWindow.lock() ? (!PWINDOW->m_groupData.deny ? ACTIVECOL : NOGROUPACTIVECOL) : (GROUPLOCKED ? GROUPACTIVELOCKEDCOL : GROUPACTIVECOL);
|
||||||
|
|
||||||
std::string borderColorString = PWINDOW->m_windowData.activeBorderColor.valueOr(*ACTIVECOLOR).toString();
|
std::string borderColorString = PWINDOW->m_ruleApplicator->activeBorderColor().valueOr(*ACTIVECOLOR).toString();
|
||||||
if (FORMNORM)
|
if (FORMNORM)
|
||||||
return borderColorString;
|
return borderColorString;
|
||||||
else
|
else
|
||||||
|
|
@ -1601,7 +1618,7 @@ static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string requ
|
||||||
const auto* const INACTIVECOLOR = !PWINDOW->m_groupData.pNextWindow.lock() ? (!PWINDOW->m_groupData.deny ? INACTIVECOL : NOGROUPINACTIVECOL) :
|
const auto* const INACTIVECOLOR = !PWINDOW->m_groupData.pNextWindow.lock() ? (!PWINDOW->m_groupData.deny ? INACTIVECOL : NOGROUPINACTIVECOL) :
|
||||||
(GROUPLOCKED ? GROUPINACTIVELOCKEDCOL : GROUPINACTIVECOL);
|
(GROUPLOCKED ? GROUPINACTIVELOCKEDCOL : GROUPINACTIVECOL);
|
||||||
|
|
||||||
std::string borderColorString = PWINDOW->m_windowData.inactiveBorderColor.valueOr(*INACTIVECOLOR).toString();
|
std::string borderColorString = PWINDOW->m_ruleApplicator->inactiveBorderColor().valueOr(*INACTIVECOLOR).toString();
|
||||||
if (FORMNORM)
|
if (FORMNORM)
|
||||||
return borderColorString;
|
return borderColorString;
|
||||||
else
|
else
|
||||||
|
|
@ -1616,38 +1633,92 @@ static std::string dispatchGetProp(eHyprCtlOutputFormat format, std::string requ
|
||||||
return std::format(R"({{"{}": {}}})", PROP, prop.valueOrDefault());
|
return std::format(R"({{"{}": {}}})", PROP, prop.valueOrDefault());
|
||||||
};
|
};
|
||||||
|
|
||||||
if (PROP == "animationstyle") {
|
if (PROP == "animation") {
|
||||||
auto& animationStyle = PWINDOW->m_windowData.animationStyle;
|
auto& animationStyle = PWINDOW->m_ruleApplicator->animationStyle();
|
||||||
if (FORMNORM)
|
if (FORMNORM)
|
||||||
return animationStyle.valueOr("(unset)");
|
return animationStyle.valueOr("(unset)");
|
||||||
else
|
else
|
||||||
return std::format(R"({{"{}": "{}"}})", PROP, animationStyle.valueOr(""));
|
return std::format(R"({{"{}": "{}"}})", PROP, animationStyle.valueOr(""));
|
||||||
} else if (PROP == "maxsize")
|
} else if (PROP == "max_size")
|
||||||
return sizeToString(true);
|
return sizeToString(true);
|
||||||
else if (PROP == "minsize")
|
else if (PROP == "min_size")
|
||||||
return sizeToString(false);
|
return sizeToString(false);
|
||||||
else if (PROP == "alpha")
|
else if (PROP == "opacity")
|
||||||
return alphaToString(PWINDOW->m_windowData.alpha, true);
|
return alphaToString(PWINDOW->m_ruleApplicator->alpha(), true);
|
||||||
else if (PROP == "alphainactive")
|
else if (PROP == "opacity_inactive")
|
||||||
return alphaToString(PWINDOW->m_windowData.alphaInactive, true);
|
return alphaToString(PWINDOW->m_ruleApplicator->alphaInactive(), true);
|
||||||
else if (PROP == "alphafullscreen")
|
else if (PROP == "opacity_fullscreen")
|
||||||
return alphaToString(PWINDOW->m_windowData.alphaFullscreen, true);
|
return alphaToString(PWINDOW->m_ruleApplicator->alphaFullscreen(), true);
|
||||||
else if (PROP == "alphaoverride")
|
else if (PROP == "opacity_override")
|
||||||
return alphaToString(PWINDOW->m_windowData.alpha, false);
|
return alphaToString(PWINDOW->m_ruleApplicator->alpha(), false);
|
||||||
else if (PROP == "alphainactiveoverride")
|
else if (PROP == "opacity_inactive_override")
|
||||||
return alphaToString(PWINDOW->m_windowData.alphaInactive, false);
|
return alphaToString(PWINDOW->m_ruleApplicator->alphaInactive(), false);
|
||||||
else if (PROP == "alphafullscreenoverride")
|
else if (PROP == "opacity_fullscreen_override")
|
||||||
return alphaToString(PWINDOW->m_windowData.alphaFullscreen, false);
|
return alphaToString(PWINDOW->m_ruleApplicator->alphaFullscreen(), false);
|
||||||
else if (PROP == "activebordercolor")
|
else if (PROP == "active_border_color")
|
||||||
return borderColorToString(true);
|
return borderColorToString(true);
|
||||||
else if (PROP == "inactivebordercolor")
|
else if (PROP == "inactive_border_color")
|
||||||
return borderColorToString(false);
|
return borderColorToString(false);
|
||||||
else if (auto search = NWindowProperties::boolWindowProperties.find(PROP); search != NWindowProperties::boolWindowProperties.end())
|
else if (PROP == "allows_input")
|
||||||
return windowPropToString(*search->second(PWINDOW));
|
return windowPropToString(PWINDOW->m_ruleApplicator->allowsInput());
|
||||||
else if (auto search = NWindowProperties::intWindowProperties.find(PROP); search != NWindowProperties::intWindowProperties.end())
|
else if (PROP == "decorate")
|
||||||
return windowPropToString(*search->second(PWINDOW));
|
return windowPropToString(PWINDOW->m_ruleApplicator->decorate());
|
||||||
else if (auto search = NWindowProperties::floatWindowProperties.find(PROP); search != NWindowProperties::floatWindowProperties.end())
|
else if (PROP == "focus_on_activate")
|
||||||
return windowPropToString(*search->second(PWINDOW));
|
return windowPropToString(PWINDOW->m_ruleApplicator->focusOnActivate());
|
||||||
|
else if (PROP == "keep_aspect_ratio")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->keepAspectRatio());
|
||||||
|
else if (PROP == "nearest_neighbor")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->nearestNeighbor());
|
||||||
|
else if (PROP == "no_anim")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noAnim());
|
||||||
|
else if (PROP == "no_blur")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noBlur());
|
||||||
|
else if (PROP == "no_dim")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noDim());
|
||||||
|
else if (PROP == "no_focus")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noFocus());
|
||||||
|
else if (PROP == "no_max_size")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noMaxSize());
|
||||||
|
else if (PROP == "no_shadow")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noShadow());
|
||||||
|
else if (PROP == "no_shortcuts_inhibit")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noShortcutsInhibit());
|
||||||
|
else if (PROP == "opaque")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->opaque());
|
||||||
|
else if (PROP == "dim_around")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->dimAround());
|
||||||
|
else if (PROP == "force_rgbx")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->RGBX());
|
||||||
|
else if (PROP == "sync_fullscreen")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->syncFullscreen());
|
||||||
|
else if (PROP == "immediate")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->tearing());
|
||||||
|
else if (PROP == "xray")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->xray());
|
||||||
|
else if (PROP == "render_unfocused")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->renderUnfocused());
|
||||||
|
else if (PROP == "no_follow_mouse")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noFollowMouse());
|
||||||
|
else if (PROP == "no_screen_share")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noScreenShare());
|
||||||
|
else if (PROP == "no_vrr")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->noVRR());
|
||||||
|
else if (PROP == "persistent_size")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->persistentSize());
|
||||||
|
else if (PROP == "stay_focused")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->stayFocused());
|
||||||
|
else if (PROP == "idle_inhibit")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->idleInhibitMode());
|
||||||
|
else if (PROP == "border_size")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->borderSize());
|
||||||
|
else if (PROP == "rounding")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->rounding());
|
||||||
|
else if (PROP == "rounding_power")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->roundingPower());
|
||||||
|
else if (PROP == "scroll_mouse")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->scrollMouse());
|
||||||
|
else if (PROP == "scroll_touchpad")
|
||||||
|
return windowPropToString(PWINDOW->m_ruleApplicator->scrollTouchpad());
|
||||||
|
|
||||||
return "prop not found";
|
return "prop not found";
|
||||||
}
|
}
|
||||||
|
|
@ -2012,7 +2083,6 @@ CHyprCtl::CHyprCtl() {
|
||||||
registerCommand(SHyprCtlCommand{"plugin", false, dispatchPlugin});
|
registerCommand(SHyprCtlCommand{"plugin", false, dispatchPlugin});
|
||||||
registerCommand(SHyprCtlCommand{"notify", false, dispatchNotify});
|
registerCommand(SHyprCtlCommand{"notify", false, dispatchNotify});
|
||||||
registerCommand(SHyprCtlCommand{"dismissnotify", false, dispatchDismissNotify});
|
registerCommand(SHyprCtlCommand{"dismissnotify", false, dispatchDismissNotify});
|
||||||
registerCommand(SHyprCtlCommand{"setprop", false, dispatchSetProp});
|
|
||||||
registerCommand(SHyprCtlCommand{"getprop", false, dispatchGetProp});
|
registerCommand(SHyprCtlCommand{"getprop", false, dispatchGetProp});
|
||||||
registerCommand(SHyprCtlCommand{"seterror", false, dispatchSeterror});
|
registerCommand(SHyprCtlCommand{"seterror", false, dispatchSeterror});
|
||||||
registerCommand(SHyprCtlCommand{"switchxkblayout", false, switchXKBLayoutRequest});
|
registerCommand(SHyprCtlCommand{"switchxkblayout", false, switchXKBLayoutRequest});
|
||||||
|
|
@ -2128,8 +2198,7 @@ std::string CHyprCtl::getReply(std::string request) {
|
||||||
if (!w->m_isMapped || !w->m_workspace || !w->m_workspace->isVisible())
|
if (!w->m_isMapped || !w->m_workspace || !w->m_workspace->isVisible())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
w->updateDynamicRules();
|
Desktop::Rule::ruleEngine()->updateAllRules();
|
||||||
g_pCompositor->updateWindowAnimatedDecorationValues(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& m : g_pCompositor->m_monitors) {
|
for (auto const& m : g_pCompositor->m_monitors) {
|
||||||
|
|
@ -2153,23 +2222,23 @@ static bool successWrite(int fd, const std::string& data, bool needLog = true) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (needLog)
|
if (needLog)
|
||||||
Debug::log(ERR, "Couldn't write to socket. Error: " + std::string(strerror(errno)));
|
Log::logger->log(Log::ERR, "Couldn't write to socket. Error: " + std::string(strerror(errno)));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runWritingDebugLogThread(const int conn) {
|
static void runWritingDebugLogThread(const int conn) {
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
Debug::log(LOG, "In followlog thread, got connection, start writing: {}", conn);
|
Log::logger->log(Log::DEBUG, "In followlog thread, got connection, start writing: {}", conn);
|
||||||
//will be finished, when reading side close connection
|
//will be finished, when reading side close connection
|
||||||
std::thread([conn]() {
|
std::thread([conn]() {
|
||||||
while (Debug::SRollingLogFollow::get().isRunning()) {
|
while (Log::SRollingLogFollow::get().isRunning()) {
|
||||||
if (Debug::SRollingLogFollow::get().isEmpty(conn)) {
|
if (Log::SRollingLogFollow::get().isEmpty(conn)) {
|
||||||
std::this_thread::sleep_for(1000ms);
|
std::this_thread::sleep_for(1000ms);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto line = Debug::SRollingLogFollow::get().getLog(conn);
|
auto line = Log::SRollingLogFollow::get().getLog(conn);
|
||||||
if (!successWrite(conn, line))
|
if (!successWrite(conn, line))
|
||||||
// We cannot write, when connection is closed. So thread will successfully exit by itself
|
// We cannot write, when connection is closed. So thread will successfully exit by itself
|
||||||
break;
|
break;
|
||||||
|
|
@ -2177,7 +2246,7 @@ static void runWritingDebugLogThread(const int conn) {
|
||||||
std::this_thread::sleep_for(100ms);
|
std::this_thread::sleep_for(100ms);
|
||||||
}
|
}
|
||||||
close(conn);
|
close(conn);
|
||||||
Debug::SRollingLogFollow::get().stopFor(conn);
|
Log::SRollingLogFollow::get().stopFor(conn);
|
||||||
}).detach();
|
}).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2203,10 +2272,10 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
|
||||||
CRED_T creds;
|
CRED_T creds;
|
||||||
uint32_t len = sizeof(creds);
|
uint32_t len = sizeof(creds);
|
||||||
if (getsockopt(ACCEPTEDCONNECTION, CRED_LVL, CRED_OPT, &creds, &len) == -1)
|
if (getsockopt(ACCEPTEDCONNECTION, CRED_LVL, CRED_OPT, &creds, &len) == -1)
|
||||||
Debug::log(ERR, "Hyprctl: failed to get peer creds");
|
Log::logger->log(Log::ERR, "Hyprctl: failed to get peer creds");
|
||||||
else {
|
else {
|
||||||
g_pHyprCtl->m_currentRequestParams.pid = creds.CRED_PID;
|
g_pHyprCtl->m_currentRequestParams.pid = creds.CRED_PID;
|
||||||
Debug::log(LOG, "Hyprctl: new connection from pid {}", creds.CRED_PID);
|
Log::logger->log(Log::DEBUG, "Hyprctl: new connection from pid {}", creds.CRED_PID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -2241,7 +2310,7 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
|
||||||
try {
|
try {
|
||||||
reply = g_pHyprCtl->getReply(request);
|
reply = g_pHyprCtl->getReply(request);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Error in request: {}", e.what());
|
Log::logger->log(Log::ERR, "Error in request: {}", e.what());
|
||||||
reply = "Err: " + std::string(e.what());
|
reply = "Err: " + std::string(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2261,10 +2330,10 @@ static int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
|
||||||
successWrite(ACCEPTEDCONNECTION, reply);
|
successWrite(ACCEPTEDCONNECTION, reply);
|
||||||
|
|
||||||
if (isFollowUpRollingLogRequest(request)) {
|
if (isFollowUpRollingLogRequest(request)) {
|
||||||
Debug::log(LOG, "Followup rollinglog request received. Starting thread to write to socket.");
|
Log::logger->log(Log::DEBUG, "Followup rollinglog request received. Starting thread to write to socket.");
|
||||||
Debug::SRollingLogFollow::get().startFor(ACCEPTEDCONNECTION);
|
Log::SRollingLogFollow::get().startFor(ACCEPTEDCONNECTION);
|
||||||
runWritingDebugLogThread(ACCEPTEDCONNECTION);
|
runWritingDebugLogThread(ACCEPTEDCONNECTION);
|
||||||
Debug::log(LOG, Debug::SRollingLogFollow::get().debugInfo());
|
Log::logger->log(Log::DEBUG, Log::SRollingLogFollow::get().debugInfo());
|
||||||
} else
|
} else
|
||||||
close(ACCEPTEDCONNECTION);
|
close(ACCEPTEDCONNECTION);
|
||||||
|
|
||||||
|
|
@ -2281,7 +2350,7 @@ void CHyprCtl::startHyprCtlSocket() {
|
||||||
m_socketFD = CFileDescriptor{socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)};
|
m_socketFD = CFileDescriptor{socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)};
|
||||||
|
|
||||||
if (!m_socketFD.isValid()) {
|
if (!m_socketFD.isValid()) {
|
||||||
Debug::log(ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work.");
|
Log::logger->log(Log::ERR, "Couldn't start the Hyprland Socket. (1) IPC will not work.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2292,14 +2361,14 @@ void CHyprCtl::startHyprCtlSocket() {
|
||||||
snprintf(SERVERADDRESS.sun_path, sizeof(SERVERADDRESS.sun_path), "%s", m_socketPath.c_str());
|
snprintf(SERVERADDRESS.sun_path, sizeof(SERVERADDRESS.sun_path), "%s", m_socketPath.c_str());
|
||||||
|
|
||||||
if (bind(m_socketFD.get(), rc<sockaddr*>(&SERVERADDRESS), SUN_LEN(&SERVERADDRESS)) < 0) {
|
if (bind(m_socketFD.get(), rc<sockaddr*>(&SERVERADDRESS), SUN_LEN(&SERVERADDRESS)) < 0) {
|
||||||
Debug::log(ERR, "Couldn't start the Hyprland Socket. (2) IPC will not work.");
|
Log::logger->log(Log::ERR, "Couldn't start the Hyprland Socket. (2) IPC will not work.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10 max queued.
|
// 10 max queued.
|
||||||
listen(m_socketFD.get(), 10);
|
listen(m_socketFD.get(), 10);
|
||||||
|
|
||||||
Debug::log(LOG, "Hypr socket started at {}", m_socketPath);
|
Log::logger->log(Log::DEBUG, "Hypr socket started at {}", m_socketPath);
|
||||||
|
|
||||||
m_eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, m_socketFD.get(), WL_EVENT_READABLE, hyprCtlFDTick, nullptr);
|
m_eventSource = wl_event_loop_add_fd(g_pCompositor->m_wlEventLoop, m_socketFD.get(), WL_EVENT_READABLE, hyprCtlFDTick, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "../helpers/MiscFunctions.hpp"
|
#include "../helpers/MiscFunctions.hpp"
|
||||||
#include "../helpers/defer/Promise.hpp"
|
#include "../helpers/defer/Promise.hpp"
|
||||||
#include "../desktop/Window.hpp"
|
#include "../desktop/view/Window.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <hyprutils/os/FileDescriptor.hpp>
|
#include <hyprutils/os/FileDescriptor.hpp>
|
||||||
|
|
@ -25,9 +25,10 @@ class CHyprCtl {
|
||||||
Hyprutils::OS::CFileDescriptor m_socketFD;
|
Hyprutils::OS::CFileDescriptor m_socketFD;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool all = false;
|
bool all = false;
|
||||||
bool sysInfoConfig = false;
|
bool sysInfoConfig = false;
|
||||||
pid_t pid = 0;
|
bool isDynamicKeyword = false;
|
||||||
|
pid_t pid = 0;
|
||||||
SP<CPromise<std::string>> pendingPromise;
|
SP<CPromise<std::string>> pendingPromise;
|
||||||
} m_currentRequestParams;
|
} m_currentRequestParams;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../render/pass/TexPassElement.hpp"
|
#include "../render/pass/TexPassElement.hpp"
|
||||||
#include "../render/Renderer.hpp"
|
#include "../render/Renderer.hpp"
|
||||||
#include "../managers/animation/AnimationManager.hpp"
|
#include "../managers/animation/AnimationManager.hpp"
|
||||||
|
#include "../desktop/state/FocusState.hpp"
|
||||||
|
|
||||||
CHyprDebugOverlay::CHyprDebugOverlay() {
|
CHyprDebugOverlay::CHyprDebugOverlay() {
|
||||||
m_texture = makeShared<CTexture>();
|
m_texture = makeShared<CTexture>();
|
||||||
|
|
@ -57,7 +58,7 @@ void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) {
|
||||||
m_monitor = pMonitor;
|
m_monitor = pMonitor;
|
||||||
|
|
||||||
// anim data too
|
// anim data too
|
||||||
const auto PMONITORFORTICKS = g_pHyprRenderer->m_mostHzMonitor ? g_pHyprRenderer->m_mostHzMonitor.lock() : g_pCompositor->m_lastMonitor.lock();
|
const auto PMONITORFORTICKS = g_pHyprRenderer->m_mostHzMonitor ? g_pHyprRenderer->m_mostHzMonitor.lock() : Desktop::focusState()->monitor();
|
||||||
if (PMONITORFORTICKS == pMonitor) {
|
if (PMONITORFORTICKS == pMonitor) {
|
||||||
if (m_lastAnimationTicks.size() > sc<long unsigned int>(PMONITORFORTICKS->m_refreshRate))
|
if (m_lastAnimationTicks.size() > sc<long unsigned int>(PMONITORFORTICKS->m_refreshRate))
|
||||||
m_lastAnimationTicks.pop_front();
|
m_lastAnimationTicks.pop_front();
|
||||||
|
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
#include "Log.hpp"
|
|
||||||
#include "../defines.hpp"
|
|
||||||
#include "RollingLogFollow.hpp"
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <print>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
void Debug::init(const std::string& IS) {
|
|
||||||
m_logFile = IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
|
||||||
m_logOfs.open(m_logFile, std::ios::out | std::ios::app);
|
|
||||||
auto handle = m_logOfs.native_handle();
|
|
||||||
fcntl(handle, F_SETFD, FD_CLOEXEC);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Debug::close() {
|
|
||||||
m_logOfs.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Debug::log(eLogLevel level, std::string str) {
|
|
||||||
if (level == TRACE && !m_trace)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_shuttingDown)
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(m_logMutex);
|
|
||||||
|
|
||||||
std::string coloredStr = str;
|
|
||||||
//NOLINTBEGIN
|
|
||||||
switch (level) {
|
|
||||||
case LOG:
|
|
||||||
str = "[LOG] " + str;
|
|
||||||
coloredStr = str;
|
|
||||||
break;
|
|
||||||
case WARN:
|
|
||||||
str = "[WARN] " + str;
|
|
||||||
coloredStr = "\033[1;33m" + str + "\033[0m"; // yellow
|
|
||||||
break;
|
|
||||||
case ERR:
|
|
||||||
str = "[ERR] " + str;
|
|
||||||
coloredStr = "\033[1;31m" + str + "\033[0m"; // red
|
|
||||||
break;
|
|
||||||
case CRIT:
|
|
||||||
str = "[CRITICAL] " + str;
|
|
||||||
coloredStr = "\033[1;35m" + str + "\033[0m"; // magenta
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
str = "[INFO] " + str;
|
|
||||||
coloredStr = "\033[1;32m" + str + "\033[0m"; // green
|
|
||||||
break;
|
|
||||||
case TRACE:
|
|
||||||
str = "[TRACE] " + str;
|
|
||||||
coloredStr = "\033[1;34m" + str + "\033[0m"; // blue
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
//NOLINTEND
|
|
||||||
|
|
||||||
m_rollingLog += str + "\n";
|
|
||||||
if (m_rollingLog.size() > ROLLING_LOG_SIZE)
|
|
||||||
m_rollingLog = m_rollingLog.substr(m_rollingLog.size() - ROLLING_LOG_SIZE);
|
|
||||||
|
|
||||||
if (SRollingLogFollow::get().isRunning())
|
|
||||||
SRollingLogFollow::get().addLog(str);
|
|
||||||
|
|
||||||
if (!m_disableLogs || !**m_disableLogs) {
|
|
||||||
// log to a file
|
|
||||||
m_logOfs << str << "\n";
|
|
||||||
m_logOfs.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
// log it to the stdout too.
|
|
||||||
if (!m_disableStdout) {
|
|
||||||
std::println("{}", ((m_coloredLogs && !**m_coloredLogs) ? str : coloredStr));
|
|
||||||
std::fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include <format>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <chrono>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#define LOGMESSAGESIZE 1024
|
|
||||||
#define ROLLING_LOG_SIZE 4096
|
|
||||||
|
|
||||||
enum eLogLevel : int8_t {
|
|
||||||
NONE = -1,
|
|
||||||
LOG = 0,
|
|
||||||
WARN,
|
|
||||||
ERR,
|
|
||||||
CRIT,
|
|
||||||
INFO,
|
|
||||||
TRACE
|
|
||||||
};
|
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
|
||||||
namespace Debug {
|
|
||||||
inline std::string m_logFile;
|
|
||||||
inline std::ofstream m_logOfs;
|
|
||||||
inline int64_t* const* m_disableLogs = nullptr;
|
|
||||||
inline int64_t* const* m_disableTime = nullptr;
|
|
||||||
inline bool m_disableStdout = false;
|
|
||||||
inline bool m_trace = false;
|
|
||||||
inline bool m_shuttingDown = false;
|
|
||||||
inline int64_t* const* m_coloredLogs = nullptr;
|
|
||||||
|
|
||||||
inline std::string m_rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log
|
|
||||||
inline std::mutex m_logMutex;
|
|
||||||
|
|
||||||
void init(const std::string& IS);
|
|
||||||
void close();
|
|
||||||
|
|
||||||
//
|
|
||||||
void log(eLogLevel level, std::string str);
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
//NOLINTNEXTLINE
|
|
||||||
void log(eLogLevel level, std::format_string<Args...> fmt, Args&&... args) {
|
|
||||||
if (level == TRACE && !m_trace)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_shuttingDown)
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::string logMsg = "";
|
|
||||||
|
|
||||||
// print date and time to the ofs
|
|
||||||
if (m_disableTime && !**m_disableTime) {
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
static auto current_zone = std::chrono::current_zone();
|
|
||||||
const auto zt = std::chrono::zoned_time{current_zone, std::chrono::system_clock::now()};
|
|
||||||
const auto hms = std::chrono::hh_mm_ss{zt.get_local_time() - std::chrono::floor<std::chrono::days>(zt.get_local_time())};
|
|
||||||
#else
|
|
||||||
// TODO: current clang 17 does not support `zoned_time`, remove this once clang 19 is ready
|
|
||||||
const auto hms = std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())};
|
|
||||||
#endif
|
|
||||||
logMsg += std::format("[{}] ", hms);
|
|
||||||
}
|
|
||||||
|
|
||||||
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
|
|
||||||
// because
|
|
||||||
// 1. any faulty format specifier that sucks will cause a compilation error.
|
|
||||||
// 2. and `std::bad_alloc` is catastrophic, (Almost any operation in stdlib could throw this.)
|
|
||||||
// 3. this is actually what std::format in stdlib does
|
|
||||||
logMsg += std::vformat(fmt.get(), std::make_format_args(args...));
|
|
||||||
|
|
||||||
log(level, logMsg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#ifdef USE_TRACY_GPU
|
#ifdef USE_TRACY_GPU
|
||||||
|
|
||||||
#include "Log.hpp"
|
#include "log/Logger.hpp"
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GLES2/gl2ext.h>
|
#include <GLES2/gl2ext.h>
|
||||||
|
|
|
||||||
|
|
@ -6,36 +6,43 @@
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include "../helpers/MiscFunctions.hpp"
|
#include "../../helpers/MiscFunctions.hpp"
|
||||||
|
|
||||||
#include "../plugins/PluginSystem.hpp"
|
#include "../../plugins/PluginSystem.hpp"
|
||||||
#include "../signal-safe.hpp"
|
#include "SignalSafe.hpp"
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char const* const MESSAGES[] = {"Sorry, didn't mean to...",
|
static char const* const MESSAGES[] = {
|
||||||
"This was an accident, I swear!",
|
"Sorry, didn't mean to...",
|
||||||
"Calm down, it was a misinput! MISINPUT!",
|
"This was an accident, I swear!",
|
||||||
"Oops",
|
"Calm down, it was a misinput! MISINPUT!",
|
||||||
"Vaxry is going to be upset.",
|
"Oops",
|
||||||
"Who tried dividing by zero?!",
|
"Vaxry is going to be upset.",
|
||||||
"Maybe you should try dusting your PC in the meantime?",
|
"Who tried dividing by zero?!",
|
||||||
"I tried so hard, and got so far...",
|
"Maybe you should try dusting your PC in the meantime?",
|
||||||
"I don't feel so good...",
|
"I tried so hard, and got so far...",
|
||||||
"*thud*",
|
"I don't feel so good...",
|
||||||
"Well this is awkward.",
|
"*thud*",
|
||||||
"\"stable\"",
|
"Well this is awkward.",
|
||||||
"I hope you didn't have any unsaved progress.",
|
"\"stable\"",
|
||||||
"All these computers..."};
|
"I hope you didn't have any unsaved progress.",
|
||||||
|
"All these computers...",
|
||||||
|
"The math isn't mathing...",
|
||||||
|
"We've got an imposter in the code!",
|
||||||
|
"Well, at least the crash reporter didn't crash!",
|
||||||
|
"Everything's just fi-",
|
||||||
|
"Have you tried asking Hyprland politely not to crash?",
|
||||||
|
};
|
||||||
|
|
||||||
// <random> is not async-signal-safe, fake it with time(NULL) instead
|
// <random> is not async-signal-safe, fake it with time(NULL) instead
|
||||||
char const* getRandomMessage() {
|
static char const* getRandomMessage() {
|
||||||
return MESSAGES[time(nullptr) % (sizeof(MESSAGES) / sizeof(MESSAGES[0]))];
|
return MESSAGES[time(nullptr) % (sizeof(MESSAGES) / sizeof(MESSAGES[0]))];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]] inline void exitWithError(char const* err) {
|
[[noreturn]] static inline void exitWithError(char const* err) {
|
||||||
write(STDERR_FILENO, err, strlen(err));
|
write(STDERR_FILENO, err, strlen(err));
|
||||||
// perror() is not signal-safe, but we use it here
|
// perror() is not signal-safe, but we use it here
|
||||||
// because if the crash-handler already crashed, it can't get any worse.
|
// because if the crash-handler already crashed, it can't get any worse.
|
||||||
|
|
@ -43,17 +50,17 @@ char const* getRandomMessage() {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NCrashReporter::createAndSaveCrash(int sig) {
|
void CrashReporter::createAndSaveCrash(int sig) {
|
||||||
int reportFd = -1;
|
int reportFd = -1;
|
||||||
|
|
||||||
// We're in the signal handler, so we *only* have stack memory.
|
// We're in the signal handler, so we *only* have stack memory.
|
||||||
// To save as much stack memory as possible,
|
// To save as much stack memory as possible,
|
||||||
// destroy things as soon as possible.
|
// destroy things as soon as possible.
|
||||||
{
|
{
|
||||||
CMaxLengthCString<255> reportPath;
|
SignalSafe::CMaxLengthCString<255> reportPath;
|
||||||
|
|
||||||
const auto HOME = sigGetenv("HOME");
|
const auto HOME = SignalSafe::getenv("HOME");
|
||||||
const auto CACHE_HOME = sigGetenv("XDG_CACHE_HOME");
|
const auto CACHE_HOME = SignalSafe::getenv("XDG_CACHE_HOME");
|
||||||
|
|
||||||
if (CACHE_HOME && CACHE_HOME[0] != '\0') {
|
if (CACHE_HOME && CACHE_HOME[0] != '\0') {
|
||||||
reportPath += CACHE_HOME;
|
reportPath += CACHE_HOME;
|
||||||
|
|
@ -67,32 +74,30 @@ void NCrashReporter::createAndSaveCrash(int sig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = mkdir(reportPath.getStr(), S_IRWXU);
|
int ret = mkdir(reportPath.getStr(), S_IRWXU);
|
||||||
//__asm__("int $3");
|
if (ret < 0 && errno != EEXIST)
|
||||||
if (ret < 0 && errno != EEXIST) {
|
|
||||||
exitWithError("failed to mkdir() crash report directory\n");
|
exitWithError("failed to mkdir() crash report directory\n");
|
||||||
}
|
|
||||||
reportPath += "/hyprlandCrashReport";
|
reportPath += "/hyprlandCrashReport";
|
||||||
reportPath.writeNum(getpid());
|
reportPath.writeNum(getpid());
|
||||||
reportPath += ".txt";
|
reportPath += ".txt";
|
||||||
|
|
||||||
{
|
{
|
||||||
CBufFileWriter<64> stderr(2);
|
SignalSafe::CBufFileWriter<64> stderrOut(STDERR_FILENO);
|
||||||
stderr += "Hyprland has crashed :( Consult the crash report at ";
|
stderrOut += "Hyprland has crashed :( Consult the crash report at ";
|
||||||
if (!reportPath.boundsExceeded()) {
|
if (!reportPath.boundsExceeded())
|
||||||
stderr += reportPath.getStr();
|
stderrOut += reportPath.getStr();
|
||||||
} else {
|
else
|
||||||
stderr += "[ERROR: Crash report path does not fit into memory! Check if your $CACHE_HOME/$HOME is too deeply nested. Max 255 characters.]";
|
stderrOut += "[ERROR: Crash report path does not fit into memory! Check if your $CACHE_HOME/$HOME is too deeply nested. Max 255 characters.]";
|
||||||
}
|
|
||||||
stderr += " for more information.\n";
|
stderrOut += " for more information.\n";
|
||||||
stderr.flush();
|
stderrOut.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
reportFd = open(reportPath.getStr(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
|
reportFd = open(reportPath.getStr(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
|
||||||
if (reportFd < 0) {
|
if (reportFd < 0)
|
||||||
exitWithError("Failed to open crash report path for writing");
|
exitWithError("Failed to open crash report path for writing");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
CBufFileWriter<512> finalCrashReport(reportFd);
|
SignalSafe::CBufFileWriter<512> finalCrashReport(reportFd);
|
||||||
|
|
||||||
finalCrashReport += "--------------------------------------------\n Hyprland Crash Report\n--------------------------------------------\n";
|
finalCrashReport += "--------------------------------------------\n Hyprland Crash Report\n--------------------------------------------\n";
|
||||||
finalCrashReport += getRandomMessage();
|
finalCrashReport += getRandomMessage();
|
||||||
|
|
@ -101,7 +106,7 @@ void NCrashReporter::createAndSaveCrash(int sig) {
|
||||||
finalCrashReport += "Hyprland received signal ";
|
finalCrashReport += "Hyprland received signal ";
|
||||||
finalCrashReport.writeNum(sig);
|
finalCrashReport.writeNum(sig);
|
||||||
finalCrashReport += '(';
|
finalCrashReport += '(';
|
||||||
finalCrashReport += sigStrsignal(sig);
|
finalCrashReport += SignalSafe::strsignal(sig);
|
||||||
finalCrashReport += ")\nVersion: ";
|
finalCrashReport += ")\nVersion: ";
|
||||||
finalCrashReport += GIT_COMMIT_HASH;
|
finalCrashReport += GIT_COMMIT_HASH;
|
||||||
finalCrashReport += "\nTag: ";
|
finalCrashReport += "\nTag: ";
|
||||||
|
|
@ -243,5 +248,5 @@ void NCrashReporter::createAndSaveCrash(int sig) {
|
||||||
|
|
||||||
finalCrashReport += "\n\nLog tail:\n";
|
finalCrashReport += "\n\nLog tail:\n";
|
||||||
|
|
||||||
finalCrashReport += std::string_view(Debug::m_rollingLog).substr(Debug::m_rollingLog.find('\n') + 1);
|
finalCrashReport += Log::logger->rolling();
|
||||||
}
|
}
|
||||||
5
src/debug/crash/CrashReporter.hpp
Normal file
5
src/debug/crash/CrashReporter.hpp
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace CrashReporter {
|
||||||
|
void createAndSaveCrash(int sig);
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "signal-safe.hpp"
|
#include "SignalSafe.hpp"
|
||||||
|
|
||||||
#ifndef __GLIBC__
|
#ifndef __GLIBC__
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
@ -7,11 +7,13 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace SignalSafe;
|
||||||
|
|
||||||
// NOLINTNEXTLINE
|
// NOLINTNEXTLINE
|
||||||
extern "C" char** environ;
|
extern "C" char** environ;
|
||||||
|
|
||||||
//
|
//
|
||||||
char const* sigGetenv(char const* name) {
|
char const* SignalSafe::getenv(char const* name) {
|
||||||
const size_t len = strlen(name);
|
const size_t len = strlen(name);
|
||||||
for (char** var = environ; *var != nullptr; var++) {
|
for (char** var = environ; *var != nullptr; var++) {
|
||||||
if (strncmp(*var, name, len) == 0 && (*var)[len] == '=') {
|
if (strncmp(*var, name, len) == 0 && (*var)[len] == '=') {
|
||||||
|
|
@ -21,7 +23,7 @@ char const* sigGetenv(char const* name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* sigStrsignal(int sig) {
|
char const* SignalSafe::strsignal(int sig) {
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
return sigabbrev_np(sig);
|
return sigabbrev_np(sig);
|
||||||
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
203
src/debug/crash/SignalSafe.hpp
Normal file
203
src/debug/crash/SignalSafe.hpp
Normal file
|
|
@ -0,0 +1,203 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "defines.hpp"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
namespace SignalSafe {
|
||||||
|
template <uint16_t N>
|
||||||
|
class CMaxLengthCString {
|
||||||
|
public:
|
||||||
|
CMaxLengthCString() {
|
||||||
|
m_str[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator+=(char const* rhs) {
|
||||||
|
write(rhs, strlen(rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(char const* data, size_t len) {
|
||||||
|
if (m_boundsExceeded || m_strPos + len >= N) {
|
||||||
|
m_boundsExceeded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(m_str + m_strPos, data, len);
|
||||||
|
m_strPos += len;
|
||||||
|
m_str[m_strPos] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(char c) {
|
||||||
|
if (m_boundsExceeded || m_strPos + 1 >= N) {
|
||||||
|
m_boundsExceeded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_str[m_strPos] = c;
|
||||||
|
m_strPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeNum(size_t num) {
|
||||||
|
size_t d = 1;
|
||||||
|
|
||||||
|
while (num / 10 >= d) {
|
||||||
|
d *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (num > 0) {
|
||||||
|
char c = '0' + (num / d);
|
||||||
|
write(c);
|
||||||
|
num %= d;
|
||||||
|
d /= 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char const* getStr() {
|
||||||
|
return m_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool boundsExceeded() {
|
||||||
|
return m_boundsExceeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
char m_str[N];
|
||||||
|
size_t m_strPos = 0;
|
||||||
|
bool m_boundsExceeded = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <uint16_t BUFSIZE>
|
||||||
|
class CBufFileWriter {
|
||||||
|
public:
|
||||||
|
CBufFileWriter(int fd_) : m_fd(fd_) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
~CBufFileWriter() {
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(char const* data, size_t len) {
|
||||||
|
while (len > 0) {
|
||||||
|
size_t to_add = std::min(len, sc<size_t>(BUFSIZE) - m_writeBufPos);
|
||||||
|
memcpy(m_writeBuf + m_writeBufPos, data, to_add);
|
||||||
|
data += to_add;
|
||||||
|
len -= to_add;
|
||||||
|
m_writeBufPos += to_add;
|
||||||
|
if (m_writeBufPos == BUFSIZE)
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(char c) {
|
||||||
|
if (m_writeBufPos == BUFSIZE)
|
||||||
|
flush();
|
||||||
|
m_writeBuf[m_writeBufPos] = c;
|
||||||
|
m_writeBufPos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator+=(char const* str) {
|
||||||
|
write(str, strlen(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator+=(std::string_view str) {
|
||||||
|
write(str.data(), str.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator+=(char c) {
|
||||||
|
write(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeNum(size_t num) {
|
||||||
|
size_t d = 1;
|
||||||
|
|
||||||
|
while (num / 10 >= d) {
|
||||||
|
d *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (num > 0) {
|
||||||
|
char c = '0' + (num / d);
|
||||||
|
write(c);
|
||||||
|
num %= d;
|
||||||
|
d /= 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeCmdOutput(const char* cmd) {
|
||||||
|
int pipefd[2];
|
||||||
|
if (pipe(pipefd) < 0) {
|
||||||
|
*this += "<pipe(pipefd) failed with";
|
||||||
|
writeNum(errno);
|
||||||
|
*this += ">\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// terminate child instead of waiting
|
||||||
|
{
|
||||||
|
struct sigaction act;
|
||||||
|
act.sa_handler = SIG_DFL;
|
||||||
|
sigemptyset(&act.sa_mask);
|
||||||
|
act.sa_flags = SA_NOCLDWAIT;
|
||||||
|
#ifdef SA_RESTORER
|
||||||
|
act.sa_restorer = NULL;
|
||||||
|
#endif
|
||||||
|
sigaction(SIGCHLD, &act, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const pid_t pid = fork();
|
||||||
|
|
||||||
|
if (pid < 0) {
|
||||||
|
*this += "<fork() failed with ";
|
||||||
|
writeNum(errno);
|
||||||
|
*this += ">\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
close(pipefd[0]);
|
||||||
|
dup2(pipefd[1], STDOUT_FILENO);
|
||||||
|
char const* const argv[] = {"/bin/sh", "-c", cmd, nullptr};
|
||||||
|
execv("/bin/sh", cc<char* const*>(argv));
|
||||||
|
|
||||||
|
CBufFileWriter<64> failmsg(pipefd[1]);
|
||||||
|
failmsg += "<execv(";
|
||||||
|
failmsg += cmd;
|
||||||
|
failmsg += ") resulted in errno ";
|
||||||
|
failmsg.write(errno);
|
||||||
|
failmsg += ">\n";
|
||||||
|
close(pipefd[1]);
|
||||||
|
abort();
|
||||||
|
} else {
|
||||||
|
close(pipefd[1]);
|
||||||
|
int64_t len = 0;
|
||||||
|
char readbuf[256];
|
||||||
|
while ((len = read(pipefd[0], readbuf, 256)) > 0) {
|
||||||
|
write(readbuf, len);
|
||||||
|
}
|
||||||
|
if (len < 0) {
|
||||||
|
*this += "<interrupted, read() resulted in errno ";
|
||||||
|
writeNum(errno);
|
||||||
|
*this += ">\n";
|
||||||
|
}
|
||||||
|
close(pipefd[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void flush() {
|
||||||
|
size_t i = 0;
|
||||||
|
while (i < m_writeBufPos) {
|
||||||
|
auto written = ::write(m_fd, m_writeBuf + i, m_writeBufPos - i);
|
||||||
|
if (written <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i += written;
|
||||||
|
}
|
||||||
|
m_writeBufPos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
char m_writeBuf[BUFSIZE] = {0};
|
||||||
|
size_t m_writeBufPos = 0;
|
||||||
|
int m_fd = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
char const* getenv(const char* name);
|
||||||
|
char const* strsignal(int sig);
|
||||||
|
}
|
||||||
64
src/debug/log/Logger.cpp
Normal file
64
src/debug/log/Logger.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
#include "Logger.hpp"
|
||||||
|
#include "RollingLogFollow.hpp"
|
||||||
|
|
||||||
|
#include "../../defines.hpp"
|
||||||
|
|
||||||
|
#include "../../managers/HookSystemManager.hpp"
|
||||||
|
#include "../../config/ConfigValue.hpp"
|
||||||
|
|
||||||
|
using namespace Log;
|
||||||
|
|
||||||
|
CLogger::CLogger() {
|
||||||
|
const auto IS_TRACE = Env::isTrace();
|
||||||
|
m_logger.setLogLevel(IS_TRACE ? Hyprutils::CLI::LOG_TRACE : Hyprutils::CLI::LOG_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogger::log(Hyprutils::CLI::eLogLevel level, const std::string_view& str) {
|
||||||
|
|
||||||
|
static bool TRACE = Env::isTrace();
|
||||||
|
|
||||||
|
if (!m_logsEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (level == Hyprutils::CLI::LOG_TRACE && !TRACE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (SRollingLogFollow::get().isRunning())
|
||||||
|
SRollingLogFollow::get().addLog(str);
|
||||||
|
|
||||||
|
m_logger.log(level, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogger::initIS(const std::string_view& IS) {
|
||||||
|
// NOLINTNEXTLINE
|
||||||
|
m_logger.setOutputFile(std::string{IS} + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log"));
|
||||||
|
m_logger.setEnableRolling(true);
|
||||||
|
m_logger.setEnableColor(false);
|
||||||
|
m_logger.setEnableStdout(true);
|
||||||
|
m_logger.setTime(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogger::initCallbacks() {
|
||||||
|
static auto P = g_pHookSystem->hookDynamic("configReloaded", [this](void* hk, SCallbackInfo& info, std::any param) { recheckCfg(); });
|
||||||
|
recheckCfg();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLogger::recheckCfg() {
|
||||||
|
static auto PDISABLELOGS = CConfigValue<Hyprlang::INT>("debug:disable_logs");
|
||||||
|
static auto PDISABLETIME = CConfigValue<Hyprlang::INT>("debug:disable_time");
|
||||||
|
static auto PENABLESTDOUT = CConfigValue<Hyprlang::INT>("debug:enable_stdout_logs");
|
||||||
|
static auto PENABLECOLOR = CConfigValue<Hyprlang::INT>("debug:colored_stdout_logs");
|
||||||
|
|
||||||
|
m_logger.setEnableStdout(!*PDISABLELOGS && *PENABLESTDOUT);
|
||||||
|
m_logsEnabled = !*PDISABLELOGS;
|
||||||
|
m_logger.setTime(!*PDISABLETIME);
|
||||||
|
m_logger.setEnableColor(*PENABLECOLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& CLogger::rolling() {
|
||||||
|
return m_logger.rollingLog();
|
||||||
|
}
|
||||||
|
|
||||||
|
Hyprutils::CLI::CLogger& CLogger::hu() {
|
||||||
|
return m_logger;
|
||||||
|
}
|
||||||
61
src/debug/log/Logger.hpp
Normal file
61
src/debug/log/Logger.hpp
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <hyprutils/cli/Logger.hpp>
|
||||||
|
|
||||||
|
#include "../../helpers/memory/Memory.hpp"
|
||||||
|
#include "../../helpers/env/Env.hpp"
|
||||||
|
|
||||||
|
namespace Log {
|
||||||
|
class CLogger {
|
||||||
|
public:
|
||||||
|
CLogger();
|
||||||
|
~CLogger() = default;
|
||||||
|
|
||||||
|
void initIS(const std::string_view& IS);
|
||||||
|
void initCallbacks();
|
||||||
|
|
||||||
|
void log(Hyprutils::CLI::eLogLevel level, const std::string_view& str);
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
//NOLINTNEXTLINE
|
||||||
|
void log(Hyprutils::CLI::eLogLevel level, std::format_string<Args...> fmt, Args&&... args) {
|
||||||
|
static bool TRACE = Env::isTrace();
|
||||||
|
|
||||||
|
if (!m_logsEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (level == Hyprutils::CLI::LOG_TRACE && !TRACE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string logMsg = "";
|
||||||
|
|
||||||
|
// no need for try {} catch {} because std::format_string<Args...> ensures that vformat never throw std::format_error
|
||||||
|
// because
|
||||||
|
// 1. any faulty format specifier that sucks will cause a compilation error.
|
||||||
|
// 2. and `std::bad_alloc` is catastrophic, (Almost any operation in stdlib could throw this.)
|
||||||
|
// 3. this is actually what std::format in stdlib does
|
||||||
|
logMsg += std::vformat(fmt.get(), std::make_format_args(args...));
|
||||||
|
|
||||||
|
log(level, logMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& rolling();
|
||||||
|
Hyprutils::CLI::CLogger& hu();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void recheckCfg();
|
||||||
|
|
||||||
|
Hyprutils::CLI::CLogger m_logger;
|
||||||
|
bool m_logsEnabled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline UP<CLogger> logger = makeUnique<CLogger>();
|
||||||
|
|
||||||
|
//
|
||||||
|
inline constexpr const Hyprutils::CLI::eLogLevel DEBUG = Hyprutils::CLI::LOG_DEBUG;
|
||||||
|
inline constexpr const Hyprutils::CLI::eLogLevel WARN = Hyprutils::CLI::LOG_WARN;
|
||||||
|
inline constexpr const Hyprutils::CLI::eLogLevel ERR = Hyprutils::CLI::LOG_ERR;
|
||||||
|
inline constexpr const Hyprutils::CLI::eLogLevel CRIT = Hyprutils::CLI::LOG_CRIT;
|
||||||
|
inline constexpr const Hyprutils::CLI::eLogLevel INFO = Hyprutils::CLI::LOG_DEBUG;
|
||||||
|
inline constexpr const Hyprutils::CLI::eLogLevel TRACE = Hyprutils::CLI::LOG_TRACE;
|
||||||
|
};
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <format>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
namespace Log {
|
||||||
namespace Debug {
|
|
||||||
struct SRollingLogFollow {
|
struct SRollingLogFollow {
|
||||||
std::unordered_map<int, std::string> m_socketToRollingLogFollowQueue;
|
std::unordered_map<int, std::string> m_socketToRollingLogFollowQueue;
|
||||||
std::shared_mutex m_mutex;
|
std::shared_mutex m_mutex;
|
||||||
|
|
@ -30,12 +32,14 @@ namespace Debug {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
void addLog(const std::string& log) {
|
void addLog(const std::string_view& log) {
|
||||||
std::unique_lock<std::shared_mutex> w(m_mutex);
|
std::unique_lock<std::shared_mutex> w(m_mutex);
|
||||||
m_running = true;
|
m_running = true;
|
||||||
std::vector<int> to_erase;
|
std::vector<int> to_erase;
|
||||||
for (const auto& p : m_socketToRollingLogFollowQueue)
|
for (const auto& p : m_socketToRollingLogFollowQueue) {
|
||||||
m_socketToRollingLogFollowQueue[p.first] += log + "\n";
|
m_socketToRollingLogFollowQueue[p.first] += log;
|
||||||
|
m_socketToRollingLogFollowQueue[p.first] += "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRunning() {
|
bool isRunning() {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "includes.hpp"
|
#include "includes.hpp"
|
||||||
#include "debug/Log.hpp"
|
#include "debug/log/Logger.hpp"
|
||||||
#include "helpers/Color.hpp"
|
#include "helpers/Color.hpp"
|
||||||
#include "macros.hpp"
|
#include "macros.hpp"
|
||||||
#include "desktop/DesktopTypes.hpp"
|
#include "desktop/DesktopTypes.hpp"
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,28 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../helpers/memory/Memory.hpp"
|
#include "../helpers/memory/Memory.hpp"
|
||||||
|
|
||||||
class CWorkspace;
|
class CWorkspace;
|
||||||
class CWindow;
|
|
||||||
class CLayerSurface;
|
|
||||||
class CMonitor;
|
class CMonitor;
|
||||||
|
|
||||||
|
namespace Desktop::View {
|
||||||
|
class CWindow;
|
||||||
|
class CLayerSurface;
|
||||||
|
}
|
||||||
|
|
||||||
/* Shared pointer to a workspace */
|
/* Shared pointer to a workspace */
|
||||||
using PHLWORKSPACE = SP<CWorkspace>;
|
using PHLWORKSPACE = SP<CWorkspace>;
|
||||||
/* Weak pointer to a workspace */
|
/* Weak pointer to a workspace */
|
||||||
using PHLWORKSPACEREF = WP<CWorkspace>;
|
using PHLWORKSPACEREF = WP<CWorkspace>;
|
||||||
|
|
||||||
/* Shared pointer to a window */
|
/* Shared pointer to a window */
|
||||||
using PHLWINDOW = SP<CWindow>;
|
using PHLWINDOW = SP<Desktop::View::CWindow>;
|
||||||
/* Weak pointer to a window */
|
/* Weak pointer to a window */
|
||||||
using PHLWINDOWREF = WP<CWindow>;
|
using PHLWINDOWREF = WP<Desktop::View::CWindow>;
|
||||||
|
|
||||||
/* Shared pointer to a layer surface */
|
/* Shared pointer to a layer surface */
|
||||||
using PHLLS = SP<CLayerSurface>;
|
using PHLLS = SP<Desktop::View::CLayerSurface>;
|
||||||
/* Weak pointer to a layer surface */
|
/* Weak pointer to a layer surface */
|
||||||
using PHLLSREF = WP<CLayerSurface>;
|
using PHLLSREF = WP<Desktop::View::CLayerSurface>;
|
||||||
|
|
||||||
/* Shared pointer to a monitor */
|
/* Shared pointer to a monitor */
|
||||||
using PHLMONITOR = SP<CMonitor>;
|
using PHLMONITOR = SP<CMonitor>;
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#include <re2/re2.h>
|
|
||||||
#include "LayerRule.hpp"
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <algorithm>
|
|
||||||
#include "../debug/Log.hpp"
|
|
||||||
|
|
||||||
static const auto RULES = std::unordered_set<std::string>{"noanim", "blur", "blurpopups", "dimaround", "noscreenshare"};
|
|
||||||
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order", "abovelock"};
|
|
||||||
|
|
||||||
CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_targetNamespace(ns_), m_rule(rule_) {
|
|
||||||
const bool VALID = RULES.contains(m_rule) || std::ranges::any_of(RULES_PREFIX, [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });
|
|
||||||
|
|
||||||
if (!VALID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_rule == "noanim")
|
|
||||||
m_ruleType = RULE_NOANIM;
|
|
||||||
else if (m_rule == "blur")
|
|
||||||
m_ruleType = RULE_BLUR;
|
|
||||||
else if (m_rule == "blurpopups")
|
|
||||||
m_ruleType = RULE_BLURPOPUPS;
|
|
||||||
else if (m_rule == "dimaround")
|
|
||||||
m_ruleType = RULE_DIMAROUND;
|
|
||||||
else if (m_rule == "noscreenshare")
|
|
||||||
m_ruleType = RULE_NOSCREENSHARE;
|
|
||||||
else if (m_rule.starts_with("ignorealpha"))
|
|
||||||
m_ruleType = RULE_IGNOREALPHA;
|
|
||||||
else if (m_rule.starts_with("ignorezero"))
|
|
||||||
m_ruleType = RULE_IGNOREZERO;
|
|
||||||
else if (m_rule.starts_with("xray"))
|
|
||||||
m_ruleType = RULE_XRAY;
|
|
||||||
else if (m_rule.starts_with("animation"))
|
|
||||||
m_ruleType = RULE_ANIMATION;
|
|
||||||
else if (m_rule.starts_with("order"))
|
|
||||||
m_ruleType = RULE_ORDER;
|
|
||||||
else if (m_rule.starts_with("abovelock"))
|
|
||||||
m_ruleType = RULE_ABOVELOCK;
|
|
||||||
else {
|
|
||||||
Debug::log(ERR, "CLayerRule: didn't match a rule that was found valid?!");
|
|
||||||
m_ruleType = RULE_INVALID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
#include "Rule.hpp"
|
|
||||||
|
|
||||||
class CLayerRule {
|
|
||||||
public:
|
|
||||||
CLayerRule(const std::string& rule, const std::string& targetNS);
|
|
||||||
|
|
||||||
enum eRuleType : uint8_t {
|
|
||||||
RULE_INVALID = 0,
|
|
||||||
RULE_NOANIM,
|
|
||||||
RULE_BLUR,
|
|
||||||
RULE_BLURPOPUPS,
|
|
||||||
RULE_DIMAROUND,
|
|
||||||
RULE_ABOVELOCK,
|
|
||||||
RULE_IGNOREALPHA,
|
|
||||||
RULE_IGNOREZERO,
|
|
||||||
RULE_XRAY,
|
|
||||||
RULE_ANIMATION,
|
|
||||||
RULE_ORDER,
|
|
||||||
RULE_ZUMBA,
|
|
||||||
RULE_NOSCREENSHARE
|
|
||||||
};
|
|
||||||
|
|
||||||
eRuleType m_ruleType = RULE_INVALID;
|
|
||||||
|
|
||||||
const std::string m_targetNamespace;
|
|
||||||
const std::string m_rule;
|
|
||||||
|
|
||||||
CRuleRegexContainer m_targetNamespaceRegex;
|
|
||||||
};
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "../defines.hpp"
|
|
||||||
#include "WLSurface.hpp"
|
|
||||||
#include "../helpers/AnimatedVariable.hpp"
|
|
||||||
|
|
||||||
class CLayerShellResource;
|
|
||||||
|
|
||||||
class CLayerSurface {
|
|
||||||
public:
|
|
||||||
static PHLLS create(SP<CLayerShellResource>);
|
|
||||||
|
|
||||||
private:
|
|
||||||
CLayerSurface(SP<CLayerShellResource>);
|
|
||||||
|
|
||||||
public:
|
|
||||||
~CLayerSurface();
|
|
||||||
|
|
||||||
void applyRules();
|
|
||||||
bool isFadedOut();
|
|
||||||
int popupsCount();
|
|
||||||
|
|
||||||
PHLANIMVAR<Vector2D> m_realPosition;
|
|
||||||
PHLANIMVAR<Vector2D> m_realSize;
|
|
||||||
PHLANIMVAR<float> m_alpha;
|
|
||||||
|
|
||||||
WP<CLayerShellResource> m_layerSurface;
|
|
||||||
|
|
||||||
// the header providing the enum type cannot be imported here
|
|
||||||
int m_interactivity = 0;
|
|
||||||
|
|
||||||
SP<CWLSurface> m_surface;
|
|
||||||
|
|
||||||
bool m_mapped = false;
|
|
||||||
uint32_t m_layer = 0;
|
|
||||||
|
|
||||||
PHLMONITORREF m_monitor;
|
|
||||||
|
|
||||||
bool m_fadingOut = false;
|
|
||||||
bool m_readyToDelete = false;
|
|
||||||
bool m_noProcess = false;
|
|
||||||
bool m_noAnimations = false;
|
|
||||||
|
|
||||||
bool m_forceBlur = false;
|
|
||||||
bool m_forceBlurPopups = false;
|
|
||||||
int64_t m_xray = -1;
|
|
||||||
bool m_ignoreAlpha = false;
|
|
||||||
float m_ignoreAlphaValue = 0.f;
|
|
||||||
bool m_dimAround = false;
|
|
||||||
bool m_noScreenShare = false;
|
|
||||||
int64_t m_order = 0;
|
|
||||||
bool m_aboveLockscreen = false;
|
|
||||||
bool m_aboveLockscreenInteractable = false;
|
|
||||||
|
|
||||||
std::optional<std::string> m_animationStyle;
|
|
||||||
|
|
||||||
PHLLSREF m_self;
|
|
||||||
|
|
||||||
CBox m_geometry = {0, 0, 0, 0};
|
|
||||||
Vector2D m_position;
|
|
||||||
std::string m_namespace = "";
|
|
||||||
UP<CPopup> m_popupHead;
|
|
||||||
|
|
||||||
pid_t getPID();
|
|
||||||
|
|
||||||
void onDestroy();
|
|
||||||
void onMap();
|
|
||||||
void onUnmap();
|
|
||||||
void onCommit();
|
|
||||||
MONITORID monitorID();
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct {
|
|
||||||
CHyprSignalListener destroy;
|
|
||||||
CHyprSignalListener map;
|
|
||||||
CHyprSignalListener unmap;
|
|
||||||
CHyprSignalListener commit;
|
|
||||||
} m_listeners;
|
|
||||||
|
|
||||||
void registerCallbacks();
|
|
||||||
|
|
||||||
// For the list lookup
|
|
||||||
bool operator==(const CLayerSurface& rhs) const {
|
|
||||||
return m_layerSurface == rhs.m_layerSurface && m_monitor == rhs.m_monitor;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool valid(PHLLS l) {
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool valid(PHLLSREF l) {
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool validMapped(PHLLS l) {
|
|
||||||
if (!valid(l))
|
|
||||||
return false;
|
|
||||||
return l->m_mapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool validMapped(PHLLSREF l) {
|
|
||||||
if (!valid(l))
|
|
||||||
return false;
|
|
||||||
return l->m_mapped;
|
|
||||||
}
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "Subsurface.hpp"
|
|
||||||
#include "../helpers/signal/Signal.hpp"
|
|
||||||
#include "../helpers/memory/Memory.hpp"
|
|
||||||
#include "../helpers/AnimatedVariable.hpp"
|
|
||||||
|
|
||||||
class CXDGPopupResource;
|
|
||||||
|
|
||||||
class CPopup {
|
|
||||||
public:
|
|
||||||
// dummy head nodes
|
|
||||||
static UP<CPopup> create(PHLWINDOW pOwner);
|
|
||||||
static UP<CPopup> create(PHLLS pOwner);
|
|
||||||
|
|
||||||
// real nodes
|
|
||||||
static UP<CPopup> create(SP<CXDGPopupResource> popup, WP<CPopup> pOwner);
|
|
||||||
|
|
||||||
~CPopup();
|
|
||||||
|
|
||||||
SP<CWLSurface> getT1Owner();
|
|
||||||
Vector2D coordsRelativeToParent();
|
|
||||||
Vector2D coordsGlobal();
|
|
||||||
PHLMONITOR getMonitor();
|
|
||||||
|
|
||||||
Vector2D size();
|
|
||||||
|
|
||||||
void onNewPopup(SP<CXDGPopupResource> popup);
|
|
||||||
void onDestroy();
|
|
||||||
void onMap();
|
|
||||||
void onUnmap();
|
|
||||||
void onCommit(bool ignoreSiblings = false);
|
|
||||||
void onReposition();
|
|
||||||
|
|
||||||
void recheckTree();
|
|
||||||
|
|
||||||
bool visible();
|
|
||||||
bool inert() const;
|
|
||||||
|
|
||||||
// will also loop over this node
|
|
||||||
void breadthfirst(std::function<void(WP<CPopup>, void*)> fn, void* data);
|
|
||||||
WP<CPopup> at(const Vector2D& globalCoords, bool allowsInput = false);
|
|
||||||
|
|
||||||
//
|
|
||||||
SP<CWLSurface> m_wlSurface;
|
|
||||||
WP<CPopup> m_self;
|
|
||||||
bool m_mapped = false;
|
|
||||||
|
|
||||||
// fade in-out
|
|
||||||
PHLANIMVAR<float> m_alpha;
|
|
||||||
bool m_fadingOut = false;
|
|
||||||
|
|
||||||
private:
|
|
||||||
CPopup() = default;
|
|
||||||
|
|
||||||
// T1 owners, each popup has to have one of these
|
|
||||||
PHLWINDOWREF m_windowOwner;
|
|
||||||
PHLLSREF m_layerOwner;
|
|
||||||
|
|
||||||
// T2 owners
|
|
||||||
WP<CPopup> m_parent;
|
|
||||||
|
|
||||||
WP<CXDGPopupResource> m_resource;
|
|
||||||
|
|
||||||
Vector2D m_lastSize = {};
|
|
||||||
Vector2D m_lastPos = {};
|
|
||||||
|
|
||||||
bool m_requestedReposition = false;
|
|
||||||
|
|
||||||
bool m_inert = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
std::vector<UP<CPopup>> m_children;
|
|
||||||
UP<CSubsurface> m_subsurfaceHead;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
CHyprSignalListener newPopup;
|
|
||||||
CHyprSignalListener destroy;
|
|
||||||
CHyprSignalListener map;
|
|
||||||
CHyprSignalListener unmap;
|
|
||||||
CHyprSignalListener commit;
|
|
||||||
CHyprSignalListener dismissed;
|
|
||||||
CHyprSignalListener reposition;
|
|
||||||
} m_listeners;
|
|
||||||
|
|
||||||
void initAllSignals();
|
|
||||||
void reposition();
|
|
||||||
void recheckChildrenRecursive();
|
|
||||||
void sendScale();
|
|
||||||
void fullyDestroy();
|
|
||||||
|
|
||||||
Vector2D localToGlobal(const Vector2D& rel);
|
|
||||||
Vector2D t1ParentCoords();
|
|
||||||
static void bfHelper(std::vector<WP<CPopup>> const& nodes, std::function<void(WP<CPopup>, void*)> fn, void* data);
|
|
||||||
};
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
#include <re2/re2.h>
|
|
||||||
#include "../helpers/memory/Memory.hpp"
|
|
||||||
#include "Rule.hpp"
|
|
||||||
#include "../debug/Log.hpp"
|
|
||||||
|
|
||||||
CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) {
|
|
||||||
const bool NEGATIVE = regex_.starts_with("negative:");
|
|
||||||
|
|
||||||
m_negative = NEGATIVE;
|
|
||||||
m_regex = makeUnique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);
|
|
||||||
|
|
||||||
// TODO: maybe pop an error?
|
|
||||||
if (!m_regex->ok())
|
|
||||||
Debug::log(ERR, "RuleRegexContainer: regex {} failed to parse!", regex_);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CRuleRegexContainer::passes(const std::string& str) const {
|
|
||||||
if (!m_regex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return RE2::FullMatch(str, *m_regex) != m_negative;
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <hyprutils/memory/UniquePtr.hpp>
|
|
||||||
|
|
||||||
//NOLINTNEXTLINE
|
|
||||||
namespace re2 {
|
|
||||||
class RE2;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CRuleRegexContainer {
|
|
||||||
public:
|
|
||||||
CRuleRegexContainer() = default;
|
|
||||||
|
|
||||||
CRuleRegexContainer(const std::string& regex);
|
|
||||||
|
|
||||||
bool passes(const std::string& str) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Hyprutils::Memory::CUniquePointer<re2::RE2> m_regex;
|
|
||||||
bool m_negative = false;
|
|
||||||
};
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../defines.hpp"
|
|
||||||
#include <vector>
|
|
||||||
#include "WLSurface.hpp"
|
|
||||||
|
|
||||||
class CPopup;
|
|
||||||
class CWLSubsurfaceResource;
|
|
||||||
|
|
||||||
class CSubsurface {
|
|
||||||
public:
|
|
||||||
// root dummy nodes
|
|
||||||
static UP<CSubsurface> create(PHLWINDOW pOwner);
|
|
||||||
static UP<CSubsurface> create(WP<CPopup> pOwner);
|
|
||||||
|
|
||||||
// real nodes
|
|
||||||
static UP<CSubsurface> create(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner);
|
|
||||||
static UP<CSubsurface> create(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner);
|
|
||||||
|
|
||||||
~CSubsurface() = default;
|
|
||||||
|
|
||||||
Vector2D coordsRelativeToParent();
|
|
||||||
Vector2D coordsGlobal();
|
|
||||||
|
|
||||||
Vector2D size();
|
|
||||||
|
|
||||||
void onCommit();
|
|
||||||
void onDestroy();
|
|
||||||
void onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface);
|
|
||||||
void onMap();
|
|
||||||
void onUnmap();
|
|
||||||
|
|
||||||
bool visible();
|
|
||||||
|
|
||||||
void recheckDamageForSubsurfaces();
|
|
||||||
|
|
||||||
WP<CSubsurface> m_self;
|
|
||||||
|
|
||||||
private:
|
|
||||||
CSubsurface() = default;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
CHyprSignalListener destroySubsurface;
|
|
||||||
CHyprSignalListener commitSubsurface;
|
|
||||||
CHyprSignalListener mapSubsurface;
|
|
||||||
CHyprSignalListener unmapSubsurface;
|
|
||||||
CHyprSignalListener newSubsurface;
|
|
||||||
} m_listeners;
|
|
||||||
|
|
||||||
WP<CWLSubsurfaceResource> m_subsurface;
|
|
||||||
SP<CWLSurface> m_wlSurface;
|
|
||||||
Vector2D m_lastSize = {};
|
|
||||||
Vector2D m_lastPosition = {};
|
|
||||||
|
|
||||||
// if nullptr, means it's a dummy node
|
|
||||||
WP<CSubsurface> m_parent;
|
|
||||||
|
|
||||||
PHLWINDOWREF m_windowParent;
|
|
||||||
WP<CPopup> m_popupParent;
|
|
||||||
|
|
||||||
std::vector<UP<CSubsurface>> m_children;
|
|
||||||
|
|
||||||
bool m_inert = false;
|
|
||||||
|
|
||||||
void initSignals();
|
|
||||||
void initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
|
|
||||||
void checkSiblingDamage();
|
|
||||||
void damageLastArea();
|
|
||||||
};
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "../defines.hpp"
|
|
||||||
#include "../helpers/math/Math.hpp"
|
|
||||||
#include "../helpers/signal/Signal.hpp"
|
|
||||||
|
|
||||||
class CSubsurface;
|
|
||||||
class CPopup;
|
|
||||||
class CPointerConstraint;
|
|
||||||
class CWLSurfaceResource;
|
|
||||||
|
|
||||||
class CWLSurface {
|
|
||||||
public:
|
|
||||||
static SP<CWLSurface> create() {
|
|
||||||
auto p = SP<CWLSurface>(new CWLSurface);
|
|
||||||
p->m_self = p;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
~CWLSurface();
|
|
||||||
|
|
||||||
// anonymous surfaces are non-desktop components, e.g. a cursor surface or a DnD
|
|
||||||
void assign(SP<CWLSurfaceResource> pSurface);
|
|
||||||
void assign(SP<CWLSurfaceResource> pSurface, PHLWINDOW pOwner);
|
|
||||||
void assign(SP<CWLSurfaceResource> pSurface, PHLLS pOwner);
|
|
||||||
void assign(SP<CWLSurfaceResource> pSurface, CSubsurface* pOwner);
|
|
||||||
void assign(SP<CWLSurfaceResource> pSurface, CPopup* pOwner);
|
|
||||||
void unassign();
|
|
||||||
|
|
||||||
CWLSurface(const CWLSurface&) = delete;
|
|
||||||
CWLSurface(CWLSurface&&) = delete;
|
|
||||||
CWLSurface& operator=(const CWLSurface&) = delete;
|
|
||||||
CWLSurface& operator=(CWLSurface&&) = delete;
|
|
||||||
|
|
||||||
SP<CWLSurfaceResource> resource() const;
|
|
||||||
bool exists() const;
|
|
||||||
bool small() const; // means surface is smaller than the requested size
|
|
||||||
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
|
|
||||||
Vector2D correctSmallVecBuf() const; // returns a corrective vector for small() surfaces, in BL coords
|
|
||||||
Vector2D getViewporterCorrectedSize() const;
|
|
||||||
CRegion computeDamage() const; // logical coordinates. May be wrong if the surface is unassigned
|
|
||||||
bool visible();
|
|
||||||
bool keyboardFocusable() const;
|
|
||||||
|
|
||||||
// getters for owners.
|
|
||||||
PHLWINDOW getWindow() const;
|
|
||||||
PHLLS getLayer() const;
|
|
||||||
CPopup* getPopup() const;
|
|
||||||
CSubsurface* getSubsurface() const;
|
|
||||||
|
|
||||||
// desktop components misc utils
|
|
||||||
std::optional<CBox> getSurfaceBoxGlobal() const;
|
|
||||||
void appendConstraint(WP<CPointerConstraint> constraint);
|
|
||||||
SP<CPointerConstraint> constraint() const;
|
|
||||||
|
|
||||||
// allow stretching. Useful for plugins.
|
|
||||||
bool m_fillIgnoreSmall = false;
|
|
||||||
|
|
||||||
// track surface data and avoid dupes
|
|
||||||
float m_lastScaleFloat = 0;
|
|
||||||
int m_lastScaleInt = 0;
|
|
||||||
wl_output_transform m_lastTransform = sc<wl_output_transform>(-1);
|
|
||||||
|
|
||||||
//
|
|
||||||
CWLSurface& operator=(SP<CWLSurfaceResource> pSurface) {
|
|
||||||
destroy();
|
|
||||||
m_resource = pSurface;
|
|
||||||
init();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const CWLSurface& other) const {
|
|
||||||
return other.resource() == resource();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const SP<CWLSurfaceResource> other) const {
|
|
||||||
return other == resource();
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit operator bool() const {
|
|
||||||
return exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
static SP<CWLSurface> fromResource(SP<CWLSurfaceResource> pSurface);
|
|
||||||
|
|
||||||
// used by the alpha-modifier protocol
|
|
||||||
float m_alphaModifier = 1.F;
|
|
||||||
|
|
||||||
// used by the hyprland-surface protocol
|
|
||||||
float m_overallOpacity = 1.F;
|
|
||||||
CRegion m_visibleRegion;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
CSignalT<> destroy;
|
|
||||||
} m_events;
|
|
||||||
|
|
||||||
WP<CWLSurface> m_self;
|
|
||||||
|
|
||||||
private:
|
|
||||||
CWLSurface() = default;
|
|
||||||
|
|
||||||
bool m_inert = true;
|
|
||||||
|
|
||||||
WP<CWLSurfaceResource> m_resource;
|
|
||||||
|
|
||||||
PHLWINDOWREF m_windowOwner;
|
|
||||||
PHLLSREF m_layerOwner;
|
|
||||||
CPopup* m_popupOwner = nullptr;
|
|
||||||
CSubsurface* m_subsurfaceOwner = nullptr;
|
|
||||||
|
|
||||||
//
|
|
||||||
WP<CPointerConstraint> m_constraint;
|
|
||||||
|
|
||||||
void destroy();
|
|
||||||
void init();
|
|
||||||
bool desktopComponent() const;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
CHyprSignalListener destroy;
|
|
||||||
} m_listeners;
|
|
||||||
|
|
||||||
friend class CPointerConstraint;
|
|
||||||
friend class CXxColorManagerV4;
|
|
||||||
};
|
|
||||||
|
|
@ -1,555 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include "../config/ConfigDataValues.hpp"
|
|
||||||
#include "../helpers/AnimatedVariable.hpp"
|
|
||||||
#include "../helpers/TagKeeper.hpp"
|
|
||||||
#include "../macros.hpp"
|
|
||||||
#include "../managers/XWaylandManager.hpp"
|
|
||||||
#include "../render/decorations/IHyprWindowDecoration.hpp"
|
|
||||||
#include "../render/Transformer.hpp"
|
|
||||||
#include "DesktopTypes.hpp"
|
|
||||||
#include "Popup.hpp"
|
|
||||||
#include "Subsurface.hpp"
|
|
||||||
#include "WLSurface.hpp"
|
|
||||||
#include "Workspace.hpp"
|
|
||||||
#include "WindowRule.hpp"
|
|
||||||
#include "WindowOverridableVar.hpp"
|
|
||||||
#include "../protocols/types/ContentType.hpp"
|
|
||||||
|
|
||||||
class CXDGSurfaceResource;
|
|
||||||
class CXWaylandSurface;
|
|
||||||
|
|
||||||
enum eIdleInhibitMode : uint8_t {
|
|
||||||
IDLEINHIBIT_NONE = 0,
|
|
||||||
IDLEINHIBIT_ALWAYS,
|
|
||||||
IDLEINHIBIT_FULLSCREEN,
|
|
||||||
IDLEINHIBIT_FOCUS
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eGroupRules : uint8_t {
|
|
||||||
// effective only during first map, except for _ALWAYS variant
|
|
||||||
GROUP_NONE = 0,
|
|
||||||
GROUP_SET = 1 << 0, // Open as new group or add to focused group
|
|
||||||
GROUP_SET_ALWAYS = 1 << 1,
|
|
||||||
GROUP_BARRED = 1 << 2, // Don't insert to focused group.
|
|
||||||
GROUP_LOCK = 1 << 3, // Lock m_sGroupData.lock
|
|
||||||
GROUP_LOCK_ALWAYS = 1 << 4,
|
|
||||||
GROUP_INVADE = 1 << 5, // Force enter a group, event if lock is engaged
|
|
||||||
GROUP_OVERRIDE = 1 << 6, // Override other rules
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eGetWindowProperties : uint8_t {
|
|
||||||
WINDOW_ONLY = 0,
|
|
||||||
RESERVED_EXTENTS = 1 << 0,
|
|
||||||
INPUT_EXTENTS = 1 << 1,
|
|
||||||
FULL_EXTENTS = 1 << 2,
|
|
||||||
FLOATING_ONLY = 1 << 3,
|
|
||||||
ALLOW_FLOATING = 1 << 4,
|
|
||||||
USE_PROP_TILED = 1 << 5,
|
|
||||||
SKIP_FULLSCREEN_PRIORITY = 1 << 6,
|
|
||||||
FOCUS_PRIORITY = 1 << 7,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eSuppressEvents : uint8_t {
|
|
||||||
SUPPRESS_NONE = 0,
|
|
||||||
SUPPRESS_FULLSCREEN = 1 << 0,
|
|
||||||
SUPPRESS_MAXIMIZE = 1 << 1,
|
|
||||||
SUPPRESS_ACTIVATE = 1 << 2,
|
|
||||||
SUPPRESS_ACTIVATE_FOCUSONLY = 1 << 3,
|
|
||||||
SUPPRESS_FULLSCREEN_OUTPUT = 1 << 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
class IWindowTransformer;
|
|
||||||
|
|
||||||
struct SAlphaValue {
|
|
||||||
float alpha;
|
|
||||||
bool overridden;
|
|
||||||
|
|
||||||
float applyAlpha(float a) const {
|
|
||||||
if (overridden)
|
|
||||||
return alpha;
|
|
||||||
else
|
|
||||||
return alpha * a;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SWindowData {
|
|
||||||
CWindowOverridableVar<SAlphaValue> alpha = SAlphaValue{.alpha = 1.f, .overridden = false};
|
|
||||||
CWindowOverridableVar<SAlphaValue> alphaInactive = SAlphaValue{.alpha = 1.f, .overridden = false};
|
|
||||||
CWindowOverridableVar<SAlphaValue> alphaFullscreen = SAlphaValue{.alpha = 1.f, .overridden = false};
|
|
||||||
|
|
||||||
CWindowOverridableVar<bool> allowsInput = false;
|
|
||||||
CWindowOverridableVar<bool> dimAround = false;
|
|
||||||
CWindowOverridableVar<bool> decorate = true;
|
|
||||||
CWindowOverridableVar<bool> focusOnActivate = false;
|
|
||||||
CWindowOverridableVar<bool> keepAspectRatio = false;
|
|
||||||
CWindowOverridableVar<bool> nearestNeighbor = false;
|
|
||||||
CWindowOverridableVar<bool> noAnim = false;
|
|
||||||
CWindowOverridableVar<bool> noBorder = false;
|
|
||||||
CWindowOverridableVar<bool> noBlur = false;
|
|
||||||
CWindowOverridableVar<bool> noDim = false;
|
|
||||||
CWindowOverridableVar<bool> noFocus = false;
|
|
||||||
CWindowOverridableVar<bool> noMaxSize = false;
|
|
||||||
CWindowOverridableVar<bool> noRounding = false;
|
|
||||||
CWindowOverridableVar<bool> noShadow = false;
|
|
||||||
CWindowOverridableVar<bool> noShortcutsInhibit = false;
|
|
||||||
CWindowOverridableVar<bool> opaque = false;
|
|
||||||
CWindowOverridableVar<bool> RGBX = false;
|
|
||||||
CWindowOverridableVar<bool> syncFullscreen = true;
|
|
||||||
CWindowOverridableVar<bool> tearing = false;
|
|
||||||
CWindowOverridableVar<bool> xray = false;
|
|
||||||
CWindowOverridableVar<bool> renderUnfocused = false;
|
|
||||||
CWindowOverridableVar<bool> noFollowMouse = false;
|
|
||||||
CWindowOverridableVar<bool> noScreenShare = false;
|
|
||||||
CWindowOverridableVar<bool> noVRR = false;
|
|
||||||
|
|
||||||
CWindowOverridableVar<Hyprlang::INT> borderSize = {std::string("general:border_size"), sc<Hyprlang::INT>(0), std::nullopt};
|
|
||||||
CWindowOverridableVar<Hyprlang::INT> rounding = {std::string("decoration:rounding"), sc<Hyprlang::INT>(0), std::nullopt};
|
|
||||||
|
|
||||||
CWindowOverridableVar<Hyprlang::FLOAT> roundingPower = {std::string("decoration:rounding_power")};
|
|
||||||
CWindowOverridableVar<Hyprlang::FLOAT> scrollMouse = {std::string("input:scroll_factor")};
|
|
||||||
CWindowOverridableVar<Hyprlang::FLOAT> scrollTouchpad = {std::string("input:touchpad:scroll_factor")};
|
|
||||||
|
|
||||||
CWindowOverridableVar<std::string> animationStyle;
|
|
||||||
CWindowOverridableVar<Vector2D> maxSize;
|
|
||||||
CWindowOverridableVar<Vector2D> minSize;
|
|
||||||
|
|
||||||
CWindowOverridableVar<CGradientValueData> activeBorderColor;
|
|
||||||
CWindowOverridableVar<CGradientValueData> inactiveBorderColor;
|
|
||||||
|
|
||||||
CWindowOverridableVar<bool> persistentSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SInitialWorkspaceToken {
|
|
||||||
PHLWINDOWREF primaryOwner;
|
|
||||||
std::string workspace;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SFullscreenState {
|
|
||||||
eFullscreenMode internal = FSMODE_NONE;
|
|
||||||
eFullscreenMode client = FSMODE_NONE;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CWindow {
|
|
||||||
public:
|
|
||||||
static PHLWINDOW create(SP<CXDGSurfaceResource>);
|
|
||||||
static PHLWINDOW create(SP<CXWaylandSurface>);
|
|
||||||
|
|
||||||
private:
|
|
||||||
CWindow(SP<CXDGSurfaceResource> resource);
|
|
||||||
CWindow(SP<CXWaylandSurface> surface);
|
|
||||||
|
|
||||||
public:
|
|
||||||
~CWindow();
|
|
||||||
|
|
||||||
SP<CWLSurface> m_wlSurface;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
CSignalT<> destroy;
|
|
||||||
} m_events;
|
|
||||||
|
|
||||||
WP<CXDGSurfaceResource> m_xdgSurface;
|
|
||||||
WP<CXWaylandSurface> m_xwaylandSurface;
|
|
||||||
|
|
||||||
// this is the position and size of the "bounding box"
|
|
||||||
Vector2D m_position = Vector2D(0, 0);
|
|
||||||
Vector2D m_size = Vector2D(0, 0);
|
|
||||||
|
|
||||||
// this is the real position and size used to draw the thing
|
|
||||||
PHLANIMVAR<Vector2D> m_realPosition;
|
|
||||||
PHLANIMVAR<Vector2D> m_realSize;
|
|
||||||
|
|
||||||
// for not spamming the protocols
|
|
||||||
Vector2D m_reportedPosition;
|
|
||||||
Vector2D m_reportedSize;
|
|
||||||
Vector2D m_pendingReportedSize;
|
|
||||||
std::optional<std::pair<uint32_t, Vector2D>> m_pendingSizeAck;
|
|
||||||
std::vector<std::pair<uint32_t, Vector2D>> m_pendingSizeAcks;
|
|
||||||
|
|
||||||
// for restoring floating statuses
|
|
||||||
Vector2D m_lastFloatingSize;
|
|
||||||
Vector2D m_lastFloatingPosition;
|
|
||||||
|
|
||||||
// for floating window offset in workspace animations
|
|
||||||
Vector2D m_floatingOffset = Vector2D(0, 0);
|
|
||||||
|
|
||||||
// this is used for pseudotiling
|
|
||||||
bool m_isPseudotiled = false;
|
|
||||||
Vector2D m_pseudoSize = Vector2D(1280, 720);
|
|
||||||
|
|
||||||
// for recovering relative cursor position
|
|
||||||
Vector2D m_relativeCursorCoordsOnLastWarp = Vector2D(-1, -1);
|
|
||||||
|
|
||||||
bool m_firstMap = false; // for layouts
|
|
||||||
bool m_isFloating = false;
|
|
||||||
bool m_draggingTiled = false; // for dragging around tiled windows
|
|
||||||
SFullscreenState m_fullscreenState = {.internal = FSMODE_NONE, .client = FSMODE_NONE};
|
|
||||||
std::string m_title = "";
|
|
||||||
std::string m_class = "";
|
|
||||||
std::string m_initialTitle = "";
|
|
||||||
std::string m_initialClass = "";
|
|
||||||
PHLWORKSPACE m_workspace;
|
|
||||||
PHLMONITORREF m_monitor;
|
|
||||||
|
|
||||||
bool m_isMapped = false;
|
|
||||||
|
|
||||||
bool m_requestsFloat = false;
|
|
||||||
|
|
||||||
// This is for fullscreen apps
|
|
||||||
bool m_createdOverFullscreen = false;
|
|
||||||
|
|
||||||
// XWayland stuff
|
|
||||||
bool m_isX11 = false;
|
|
||||||
bool m_X11DoesntWantBorders = false;
|
|
||||||
bool m_X11ShouldntFocus = false;
|
|
||||||
float m_X11SurfaceScaledBy = 1.f;
|
|
||||||
//
|
|
||||||
|
|
||||||
// For nofocus
|
|
||||||
bool m_noInitialFocus = false;
|
|
||||||
|
|
||||||
// Fullscreen and Maximize
|
|
||||||
bool m_wantsInitialFullscreen = false;
|
|
||||||
MONITORID m_wantsInitialFullscreenMonitor = MONITOR_INVALID;
|
|
||||||
|
|
||||||
// bitfield suppressEvents
|
|
||||||
uint64_t m_suppressedEvents = SUPPRESS_NONE;
|
|
||||||
|
|
||||||
// desktop components
|
|
||||||
UP<CSubsurface> m_subsurfaceHead;
|
|
||||||
UP<CPopup> m_popupHead;
|
|
||||||
|
|
||||||
// Animated border
|
|
||||||
CGradientValueData m_realBorderColor = {0};
|
|
||||||
CGradientValueData m_realBorderColorPrevious = {0};
|
|
||||||
PHLANIMVAR<float> m_borderFadeAnimationProgress;
|
|
||||||
PHLANIMVAR<float> m_borderAngleAnimationProgress;
|
|
||||||
|
|
||||||
// Fade in-out
|
|
||||||
PHLANIMVAR<float> m_alpha;
|
|
||||||
bool m_fadingOut = false;
|
|
||||||
bool m_readyToDelete = false;
|
|
||||||
Vector2D m_originalClosedPos; // these will be used for calculations later on in
|
|
||||||
Vector2D m_originalClosedSize; // drawing the closing animations
|
|
||||||
SBoxExtents m_originalClosedExtents;
|
|
||||||
bool m_animatingIn = false;
|
|
||||||
|
|
||||||
// For pinned (sticky) windows
|
|
||||||
bool m_pinned = false;
|
|
||||||
|
|
||||||
// For preserving pinned state when fullscreening a pinned window
|
|
||||||
bool m_pinFullscreened = false;
|
|
||||||
|
|
||||||
// urgency hint
|
|
||||||
bool m_isUrgent = false;
|
|
||||||
|
|
||||||
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
|
|
||||||
PHLWINDOWREF m_lastCycledWindow;
|
|
||||||
|
|
||||||
// Window decorations
|
|
||||||
// TODO: make this a SP.
|
|
||||||
std::vector<UP<IHyprWindowDecoration>> m_windowDecorations;
|
|
||||||
std::vector<IHyprWindowDecoration*> m_decosToRemove;
|
|
||||||
|
|
||||||
// Special render data, rules, etc
|
|
||||||
SWindowData m_windowData;
|
|
||||||
|
|
||||||
// Transformers
|
|
||||||
std::vector<UP<IWindowTransformer>> m_transformers;
|
|
||||||
|
|
||||||
// for alpha
|
|
||||||
PHLANIMVAR<float> m_activeInactiveAlpha;
|
|
||||||
PHLANIMVAR<float> m_movingFromWorkspaceAlpha;
|
|
||||||
|
|
||||||
// animated shadow color
|
|
||||||
PHLANIMVAR<CHyprColor> m_realShadowColor;
|
|
||||||
|
|
||||||
// animated tint
|
|
||||||
PHLANIMVAR<float> m_dimPercent;
|
|
||||||
|
|
||||||
// animate moving to an invisible workspace
|
|
||||||
int m_monitorMovedFrom = -1; // -1 means not moving
|
|
||||||
PHLANIMVAR<float> m_movingToWorkspaceAlpha;
|
|
||||||
|
|
||||||
// swallowing
|
|
||||||
PHLWINDOWREF m_swallowed;
|
|
||||||
bool m_currentlySwallowed = false;
|
|
||||||
bool m_groupSwallowed = false;
|
|
||||||
|
|
||||||
// focus stuff
|
|
||||||
bool m_stayFocused = false;
|
|
||||||
|
|
||||||
// for toplevel monitor events
|
|
||||||
MONITORID m_lastSurfaceMonitorID = -1;
|
|
||||||
|
|
||||||
// for idle inhibiting windows
|
|
||||||
eIdleInhibitMode m_idleInhibitMode = IDLEINHIBIT_NONE;
|
|
||||||
|
|
||||||
// initial token. Will be unregistered on workspace change or timeout of 2 minutes
|
|
||||||
std::string m_initialWorkspaceToken = "";
|
|
||||||
|
|
||||||
// for groups
|
|
||||||
struct SGroupData {
|
|
||||||
PHLWINDOWREF pNextWindow; // nullptr means no grouping. Self means single group.
|
|
||||||
bool head = false;
|
|
||||||
bool locked = false; // per group lock
|
|
||||||
bool deny = false; // deny window from enter a group or made a group
|
|
||||||
} m_groupData;
|
|
||||||
uint16_t m_groupRules = GROUP_NONE;
|
|
||||||
|
|
||||||
bool m_tearingHint = false;
|
|
||||||
|
|
||||||
// stores the currently matched window rules
|
|
||||||
std::vector<SP<CWindowRule>> m_matchedRules;
|
|
||||||
|
|
||||||
// window tags
|
|
||||||
CTagKeeper m_tags;
|
|
||||||
|
|
||||||
// ANR
|
|
||||||
PHLANIMVAR<float> m_notRespondingTint;
|
|
||||||
|
|
||||||
// For the noclosefor windowrule
|
|
||||||
Time::steady_tp m_closeableSince = Time::steadyNow();
|
|
||||||
|
|
||||||
// For the list lookup
|
|
||||||
bool operator==(const CWindow& rhs) const {
|
|
||||||
return m_xdgSurface == rhs.m_xdgSurface && m_xwaylandSurface == rhs.m_xwaylandSurface && m_position == rhs.m_position && m_size == rhs.m_size &&
|
|
||||||
m_fadingOut == rhs.m_fadingOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
// methods
|
|
||||||
CBox getFullWindowBoundingBox();
|
|
||||||
SBoxExtents getFullWindowExtents();
|
|
||||||
CBox getWindowBoxUnified(uint64_t props);
|
|
||||||
SBoxExtents getWindowExtentsUnified(uint64_t props);
|
|
||||||
CBox getWindowIdealBoundingBoxIgnoreReserved();
|
|
||||||
void addWindowDeco(UP<IHyprWindowDecoration> deco);
|
|
||||||
void updateWindowDecos();
|
|
||||||
void removeWindowDeco(IHyprWindowDecoration* deco);
|
|
||||||
void uncacheWindowDecos();
|
|
||||||
bool checkInputOnDecos(const eInputType, const Vector2D&, std::any = {});
|
|
||||||
pid_t getPID();
|
|
||||||
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
|
||||||
void updateToplevel();
|
|
||||||
void updateSurfaceScaleTransformDetails(bool force = false);
|
|
||||||
void moveToWorkspace(PHLWORKSPACE);
|
|
||||||
PHLWINDOW x11TransientFor();
|
|
||||||
void onUnmap();
|
|
||||||
void onMap();
|
|
||||||
void setHidden(bool hidden);
|
|
||||||
bool isHidden();
|
|
||||||
void applyDynamicRule(const SP<CWindowRule>& r);
|
|
||||||
void updateDynamicRules();
|
|
||||||
SBoxExtents getFullWindowReservedArea();
|
|
||||||
Vector2D middle();
|
|
||||||
bool opaque();
|
|
||||||
float rounding();
|
|
||||||
float roundingPower();
|
|
||||||
bool canBeTorn();
|
|
||||||
void setSuspended(bool suspend);
|
|
||||||
bool visibleOnMonitor(PHLMONITOR pMonitor);
|
|
||||||
WORKSPACEID workspaceID();
|
|
||||||
MONITORID monitorID();
|
|
||||||
bool onSpecialWorkspace();
|
|
||||||
void activate(bool force = false);
|
|
||||||
int surfacesCount();
|
|
||||||
void clampWindowSize(const std::optional<Vector2D> minSize, const std::optional<Vector2D> maxSize);
|
|
||||||
bool isFullscreen();
|
|
||||||
bool isEffectiveInternalFSMode(const eFullscreenMode);
|
|
||||||
int getRealBorderSize();
|
|
||||||
float getScrollMouse();
|
|
||||||
float getScrollTouchpad();
|
|
||||||
bool isScrollMouseOverridden();
|
|
||||||
bool isScrollTouchpadOverridden();
|
|
||||||
void updateWindowData();
|
|
||||||
void updateWindowData(const struct SWorkspaceRule&);
|
|
||||||
void onBorderAngleAnimEnd(WP<Hyprutils::Animation::CBaseAnimatedVariable> pav);
|
|
||||||
bool isInCurvedCorner(double x, double y);
|
|
||||||
bool hasPopupAt(const Vector2D& pos);
|
|
||||||
int popupsCount();
|
|
||||||
void applyGroupRules();
|
|
||||||
void createGroup();
|
|
||||||
void destroyGroup();
|
|
||||||
PHLWINDOW getGroupHead();
|
|
||||||
PHLWINDOW getGroupTail();
|
|
||||||
PHLWINDOW getGroupCurrent();
|
|
||||||
PHLWINDOW getGroupPrevious();
|
|
||||||
PHLWINDOW getGroupWindowByIndex(int);
|
|
||||||
bool hasInGroup(PHLWINDOW);
|
|
||||||
int getGroupSize();
|
|
||||||
bool canBeGroupedInto(PHLWINDOW pWindow);
|
|
||||||
void setGroupCurrent(PHLWINDOW pWindow);
|
|
||||||
void insertWindowToGroup(PHLWINDOW pWindow);
|
|
||||||
void updateGroupOutputs();
|
|
||||||
void switchWithWindowInGroup(PHLWINDOW pWindow);
|
|
||||||
void setAnimationsToMove();
|
|
||||||
void onWorkspaceAnimUpdate();
|
|
||||||
void onFocusAnimUpdate();
|
|
||||||
void onUpdateState();
|
|
||||||
void onUpdateMeta();
|
|
||||||
void onX11ConfigureRequest(CBox box);
|
|
||||||
void onResourceChangeX11();
|
|
||||||
std::string fetchTitle();
|
|
||||||
std::string fetchClass();
|
|
||||||
void warpCursor(bool force = false);
|
|
||||||
PHLWINDOW getSwallower();
|
|
||||||
void unsetWindowData(eOverridePriority priority);
|
|
||||||
bool isX11OverrideRedirect();
|
|
||||||
bool isModal();
|
|
||||||
Vector2D requestedMinSize();
|
|
||||||
Vector2D requestedMaxSize();
|
|
||||||
Vector2D realToReportSize();
|
|
||||||
Vector2D realToReportPosition();
|
|
||||||
Vector2D xwaylandSizeToReal(Vector2D size);
|
|
||||||
Vector2D xwaylandPositionToReal(Vector2D size);
|
|
||||||
void updateX11SurfaceScale();
|
|
||||||
void sendWindowSize(bool force = false);
|
|
||||||
NContentType::eContentType getContentType();
|
|
||||||
void setContentType(NContentType::eContentType contentType);
|
|
||||||
void deactivateGroupMembers();
|
|
||||||
bool isNotResponding();
|
|
||||||
std::optional<std::string> xdgTag();
|
|
||||||
std::optional<std::string> xdgDescription();
|
|
||||||
PHLWINDOW parent();
|
|
||||||
bool priorityFocus();
|
|
||||||
SP<CWLSurfaceResource> getSolitaryResource();
|
|
||||||
Vector2D getReportedSize();
|
|
||||||
|
|
||||||
CBox getWindowMainSurfaceBox() const {
|
|
||||||
return {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y};
|
|
||||||
}
|
|
||||||
|
|
||||||
// listeners
|
|
||||||
void onAck(uint32_t serial);
|
|
||||||
|
|
||||||
//
|
|
||||||
std::unordered_map<std::string, std::string> getEnv();
|
|
||||||
|
|
||||||
//
|
|
||||||
PHLWINDOWREF m_self;
|
|
||||||
|
|
||||||
// make private once we move listeners to inside CWindow
|
|
||||||
struct {
|
|
||||||
CHyprSignalListener map;
|
|
||||||
CHyprSignalListener ack;
|
|
||||||
CHyprSignalListener unmap;
|
|
||||||
CHyprSignalListener commit;
|
|
||||||
CHyprSignalListener destroy;
|
|
||||||
CHyprSignalListener activate;
|
|
||||||
CHyprSignalListener configureRequest;
|
|
||||||
CHyprSignalListener setGeometry;
|
|
||||||
CHyprSignalListener updateState;
|
|
||||||
CHyprSignalListener updateMetadata;
|
|
||||||
CHyprSignalListener resourceChange;
|
|
||||||
} m_listeners;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// For hidden windows and stuff
|
|
||||||
bool m_hidden = false;
|
|
||||||
bool m_suspended = false;
|
|
||||||
WORKSPACEID m_lastWorkspace = WORKSPACE_INVALID;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool valid(PHLWINDOW w) {
|
|
||||||
return w.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool valid(PHLWINDOWREF w) {
|
|
||||||
return !w.expired();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool validMapped(PHLWINDOW w) {
|
|
||||||
if (!valid(w))
|
|
||||||
return false;
|
|
||||||
return w->m_isMapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool validMapped(PHLWINDOWREF w) {
|
|
||||||
if (!valid(w))
|
|
||||||
return false;
|
|
||||||
return w->m_isMapped;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace NWindowProperties {
|
|
||||||
static const std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(const PHLWINDOW&)>> boolWindowProperties = {
|
|
||||||
{"allowsinput", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.allowsInput; }},
|
|
||||||
{"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.dimAround; }},
|
|
||||||
{"decorate", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.decorate; }},
|
|
||||||
{"focusonactivate", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.focusOnActivate; }},
|
|
||||||
{"keepaspectratio", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.keepAspectRatio; }},
|
|
||||||
{"nearestneighbor", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.nearestNeighbor; }},
|
|
||||||
{"noanim", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noAnim; }},
|
|
||||||
{"noblur", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noBlur; }},
|
|
||||||
{"noborder", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noBorder; }},
|
|
||||||
{"nodim", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noDim; }},
|
|
||||||
{"nofocus", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noFocus; }},
|
|
||||||
{"nomaxsize", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noMaxSize; }},
|
|
||||||
{"norounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noRounding; }},
|
|
||||||
{"noshadow", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noShadow; }},
|
|
||||||
{"noshortcutsinhibit", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noShortcutsInhibit; }},
|
|
||||||
{"opaque", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.opaque; }},
|
|
||||||
{"forcergbx", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.RGBX; }},
|
|
||||||
{"syncfullscreen", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.syncFullscreen; }},
|
|
||||||
{"novrr", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noVRR; }},
|
|
||||||
{"immediate", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.tearing; }},
|
|
||||||
{"xray", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.xray; }},
|
|
||||||
{"nofollowmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noFollowMouse; }},
|
|
||||||
{"noscreenshare", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noScreenShare; }},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, std::function<CWindowOverridableVar<Hyprlang::INT>*(const PHLWINDOW&)>> intWindowProperties = {
|
|
||||||
{"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.rounding; }},
|
|
||||||
{"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.borderSize; }},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::unordered_map<std::string, std::function<CWindowOverridableVar<Hyprlang::FLOAT>*(PHLWINDOW)>> floatWindowProperties = {
|
|
||||||
{"roundingpower", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.roundingPower; }},
|
|
||||||
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.scrollMouse; }},
|
|
||||||
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.scrollTouchpad; }},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
format specification
|
|
||||||
- 'x', only address, equivalent of (uintpr_t)CWindow*
|
|
||||||
- 'm', with monitor id
|
|
||||||
- 'w', with workspace id
|
|
||||||
- 'c', with application class
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <typename CharT>
|
|
||||||
struct std::formatter<PHLWINDOW, CharT> : std::formatter<CharT> {
|
|
||||||
bool formatAddressOnly = false;
|
|
||||||
bool formatWorkspace = false;
|
|
||||||
bool formatMonitor = false;
|
|
||||||
bool formatClass = false;
|
|
||||||
FORMAT_PARSE( //
|
|
||||||
FORMAT_FLAG('x', formatAddressOnly) //
|
|
||||||
FORMAT_FLAG('m', formatMonitor) //
|
|
||||||
FORMAT_FLAG('w', formatWorkspace) //
|
|
||||||
FORMAT_FLAG('c', formatClass),
|
|
||||||
PHLWINDOW)
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
auto format(PHLWINDOW const& w, FormatContext& ctx) const {
|
|
||||||
auto&& out = ctx.out();
|
|
||||||
if (formatAddressOnly)
|
|
||||||
return std::format_to(out, "{:x}", rc<uintptr_t>(w.get()));
|
|
||||||
if (!w)
|
|
||||||
return std::format_to(out, "[Window nullptr]");
|
|
||||||
|
|
||||||
std::format_to(out, "[");
|
|
||||||
std::format_to(out, "Window {:x}: title: \"{}\"", rc<uintptr_t>(w.get()), w->m_title);
|
|
||||||
if (formatWorkspace)
|
|
||||||
std::format_to(out, ", workspace: {}", w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID);
|
|
||||||
if (formatMonitor)
|
|
||||||
std::format_to(out, ", monitor: {}", w->monitorID());
|
|
||||||
if (formatClass)
|
|
||||||
std::format_to(out, ", class: {}", w->m_class);
|
|
||||||
return std::format_to(out, "]");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <any>
|
|
||||||
#include "../config/ConfigValue.hpp"
|
|
||||||
|
|
||||||
enum eOverridePriority : uint8_t {
|
|
||||||
PRIORITY_LAYOUT = 0,
|
|
||||||
PRIORITY_WORKSPACE_RULE,
|
|
||||||
PRIORITY_WINDOW_RULE,
|
|
||||||
PRIORITY_SET_PROP,
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T clampOptional(T const& value, std::optional<T> const& min, std::optional<T> const& max) {
|
|
||||||
return std::clamp(value, min.value_or(std::numeric_limits<T>::min()), max.value_or(std::numeric_limits<T>::max()));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, bool Extended = std::is_same_v<T, bool> || std::is_same_v<T, Hyprlang::INT> || std::is_same_v<T, Hyprlang::FLOAT>>
|
|
||||||
class CWindowOverridableVar {
|
|
||||||
public:
|
|
||||||
CWindowOverridableVar(T const& value, eOverridePriority priority) {
|
|
||||||
m_values[priority] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
CWindowOverridableVar(T const& value) : m_defaultValue{value} {}
|
|
||||||
CWindowOverridableVar(T const& value, std::optional<T> const& min, std::optional<T> const& max = std::nullopt) : m_defaultValue{value}, m_minValue{min}, m_maxValue{max} {}
|
|
||||||
CWindowOverridableVar(std::string const& value)
|
|
||||||
requires(Extended && !std::is_same_v<T, bool>)
|
|
||||||
: m_configValue(SP<CConfigValue<T>>(new CConfigValue<T>(value))) {}
|
|
||||||
CWindowOverridableVar(std::string const& value, std::optional<T> const& min, std::optional<T> const& max = std::nullopt)
|
|
||||||
requires(Extended && !std::is_same_v<T, bool>)
|
|
||||||
: m_minValue(min), m_maxValue(max), m_configValue(SP<CConfigValue<T>>(new CConfigValue<T>(value))) {}
|
|
||||||
|
|
||||||
CWindowOverridableVar() = default;
|
|
||||||
~CWindowOverridableVar() = default;
|
|
||||||
|
|
||||||
CWindowOverridableVar& operator=(CWindowOverridableVar<T> const& other) {
|
|
||||||
// Self-assignment check
|
|
||||||
if (this == &other)
|
|
||||||
return *this;
|
|
||||||
|
|
||||||
for (auto const& value : other.m_values) {
|
|
||||||
if constexpr (Extended && !std::is_same_v<T, bool>)
|
|
||||||
m_values[value.first] = clampOptional(value.second, m_minValue, m_maxValue);
|
|
||||||
else
|
|
||||||
m_values[value.first] = value.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unset(eOverridePriority priority) {
|
|
||||||
m_values.erase(priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasValue() {
|
|
||||||
return !m_values.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
T value() {
|
|
||||||
if (!m_values.empty())
|
|
||||||
return std::prev(m_values.end())->second;
|
|
||||||
else
|
|
||||||
throw std::bad_optional_access();
|
|
||||||
}
|
|
||||||
|
|
||||||
T valueOr(T const& other) {
|
|
||||||
if (hasValue())
|
|
||||||
return value();
|
|
||||||
else
|
|
||||||
return other;
|
|
||||||
}
|
|
||||||
|
|
||||||
T valueOrDefault()
|
|
||||||
requires(Extended && !std::is_same_v<T, bool>)
|
|
||||||
{
|
|
||||||
if (hasValue())
|
|
||||||
return value();
|
|
||||||
else if (m_defaultValue.has_value())
|
|
||||||
return m_defaultValue.value();
|
|
||||||
else
|
|
||||||
return **std::any_cast<SP<CConfigValue<T>>>(m_configValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
T valueOrDefault()
|
|
||||||
requires(!Extended || std::is_same_v<T, bool>)
|
|
||||||
{
|
|
||||||
if (hasValue())
|
|
||||||
return value();
|
|
||||||
else if (!m_defaultValue.has_value())
|
|
||||||
throw std::bad_optional_access();
|
|
||||||
else
|
|
||||||
return m_defaultValue.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
eOverridePriority getPriority() {
|
|
||||||
if (!m_values.empty())
|
|
||||||
return std::prev(m_values.end())->first;
|
|
||||||
else
|
|
||||||
throw std::bad_optional_access();
|
|
||||||
}
|
|
||||||
|
|
||||||
void increment(T const& other, eOverridePriority priority) {
|
|
||||||
if constexpr (std::is_same_v<T, bool>)
|
|
||||||
m_values[priority] = valueOr(false) ^ other;
|
|
||||||
else
|
|
||||||
m_values[priority] = clampOptional(valueOrDefault() + other, m_minValue, m_maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void matchOptional(std::optional<T> const& optValue, eOverridePriority priority) {
|
|
||||||
if (optValue.has_value())
|
|
||||||
m_values[priority] = optValue.value();
|
|
||||||
else
|
|
||||||
unset(priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
operator std::optional<T>() {
|
|
||||||
if (hasValue())
|
|
||||||
return value();
|
|
||||||
else
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<eOverridePriority, T> m_values;
|
|
||||||
std::optional<T> m_defaultValue; // used for toggling, so required for bool
|
|
||||||
std::optional<T> m_minValue;
|
|
||||||
std::optional<T> m_maxValue;
|
|
||||||
std::any m_configValue; // only there for select variables
|
|
||||||
};
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
||||||
#include "WindowRule.hpp"
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <re2/re2.h>
|
|
||||||
#include "../config/ConfigManager.hpp"
|
|
||||||
|
|
||||||
static const auto RULES = std::unordered_set<std::string>{
|
|
||||||
"float", "fullscreen", "maximize", "noinitialfocus", "pin", "stayfocused", "tile", "renderunfocused", "persistentsize",
|
|
||||||
};
|
|
||||||
static const auto RULES_PREFIX = std::unordered_set<std::string>{
|
|
||||||
"animation", "bordercolor", "bordersize", "center", "content", "fullscreenstate", "group", "idleinhibit", "maxsize", "minsize", "monitor",
|
|
||||||
"move", "noclosefor", "opacity", "plugin:", "prop", "pseudo", "rounding", "roundingpower", "scrollmouse", "scrolltouchpad", "size",
|
|
||||||
"suppressevent", "tag", "workspace", "xray", "novrr",
|
|
||||||
};
|
|
||||||
|
|
||||||
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : m_value(value), m_rule(rule), m_v2(isV2), m_execRule(isExecRule) {
|
|
||||||
const auto VALS = CVarList(rule, 2, ' ');
|
|
||||||
const bool VALID = RULES.contains(rule) || std::ranges::any_of(RULES_PREFIX, [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
|
|
||||||
(NWindowProperties::boolWindowProperties.contains(VALS[0])) || (NWindowProperties::intWindowProperties.contains(VALS[0])) ||
|
|
||||||
(NWindowProperties::floatWindowProperties.contains(VALS[0]));
|
|
||||||
|
|
||||||
if (!VALID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (rule == "float")
|
|
||||||
m_ruleType = RULE_FLOAT;
|
|
||||||
else if (rule == "fullscreen")
|
|
||||||
m_ruleType = RULE_FULLSCREEN;
|
|
||||||
else if (rule == "maximize")
|
|
||||||
m_ruleType = RULE_MAXIMIZE;
|
|
||||||
else if (rule == "noinitialfocus")
|
|
||||||
m_ruleType = RULE_NOINITIALFOCUS;
|
|
||||||
else if (rule == "pin")
|
|
||||||
m_ruleType = RULE_PIN;
|
|
||||||
else if (rule == "stayfocused")
|
|
||||||
m_ruleType = RULE_STAYFOCUSED;
|
|
||||||
else if (rule == "tile")
|
|
||||||
m_ruleType = RULE_TILE;
|
|
||||||
else if (rule == "renderunfocused")
|
|
||||||
m_ruleType = RULE_RENDERUNFOCUSED;
|
|
||||||
else if (rule == "persistentsize")
|
|
||||||
m_ruleType = RULE_PERSISTENTSIZE;
|
|
||||||
else if (rule.starts_with("animation"))
|
|
||||||
m_ruleType = RULE_ANIMATION;
|
|
||||||
else if (rule.starts_with("bordercolor"))
|
|
||||||
m_ruleType = RULE_BORDERCOLOR;
|
|
||||||
else if (rule.starts_with("center"))
|
|
||||||
m_ruleType = RULE_CENTER;
|
|
||||||
else if (rule.starts_with("fullscreenstate"))
|
|
||||||
m_ruleType = RULE_FULLSCREENSTATE;
|
|
||||||
else if (rule.starts_with("group"))
|
|
||||||
m_ruleType = RULE_GROUP;
|
|
||||||
else if (rule.starts_with("idleinhibit"))
|
|
||||||
m_ruleType = RULE_IDLEINHIBIT;
|
|
||||||
else if (rule.starts_with("maxsize"))
|
|
||||||
m_ruleType = RULE_MAXSIZE;
|
|
||||||
else if (rule.starts_with("minsize"))
|
|
||||||
m_ruleType = RULE_MINSIZE;
|
|
||||||
else if (rule.starts_with("monitor"))
|
|
||||||
m_ruleType = RULE_MONITOR;
|
|
||||||
else if (rule.starts_with("move"))
|
|
||||||
m_ruleType = RULE_MOVE;
|
|
||||||
else if (rule.starts_with("opacity"))
|
|
||||||
m_ruleType = RULE_OPACITY;
|
|
||||||
else if (rule.starts_with("plugin:"))
|
|
||||||
m_ruleType = RULE_PLUGIN;
|
|
||||||
else if (rule.starts_with("pseudo"))
|
|
||||||
m_ruleType = RULE_PSEUDO;
|
|
||||||
else if (rule.starts_with("size"))
|
|
||||||
m_ruleType = RULE_SIZE;
|
|
||||||
else if (rule.starts_with("suppressevent"))
|
|
||||||
m_ruleType = RULE_SUPPRESSEVENT;
|
|
||||||
else if (rule.starts_with("novrr"))
|
|
||||||
m_ruleType = RULE_NOVRR;
|
|
||||||
else if (rule.starts_with("tag"))
|
|
||||||
m_ruleType = RULE_TAG;
|
|
||||||
else if (rule.starts_with("workspace"))
|
|
||||||
m_ruleType = RULE_WORKSPACE;
|
|
||||||
else if (rule.starts_with("prop"))
|
|
||||||
m_ruleType = RULE_PROP;
|
|
||||||
else if (rule.starts_with("content"))
|
|
||||||
m_ruleType = RULE_CONTENT;
|
|
||||||
else if (rule.starts_with("noclosefor"))
|
|
||||||
m_ruleType = RULE_NOCLOSEFOR;
|
|
||||||
else {
|
|
||||||
// check if this is a prop.
|
|
||||||
const CVarList VARS(rule, 0, 's', true);
|
|
||||||
const bool ISPROP = NWindowProperties::intWindowProperties.contains(VARS[0]) || NWindowProperties::boolWindowProperties.contains(VARS[0]) ||
|
|
||||||
NWindowProperties::floatWindowProperties.contains(VARS[0]);
|
|
||||||
if (ISPROP) {
|
|
||||||
*const_cast<std::string*>(&m_rule) = "prop " + rule;
|
|
||||||
m_ruleType = RULE_PROP;
|
|
||||||
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule);
|
|
||||||
} else {
|
|
||||||
Debug::log(ERR, "CWindowRule: didn't match a rule that was found valid?!");
|
|
||||||
m_ruleType = RULE_INVALID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
|
||||||
#include "Rule.hpp"
|
|
||||||
|
|
||||||
class CWindowRule {
|
|
||||||
public:
|
|
||||||
CWindowRule(const std::string& rule, const std::string& value, bool isV2 = false, bool isExecRule = false);
|
|
||||||
|
|
||||||
enum eRuleType : uint8_t {
|
|
||||||
RULE_INVALID = 0,
|
|
||||||
RULE_FLOAT,
|
|
||||||
RULE_FULLSCREEN,
|
|
||||||
RULE_MAXIMIZE,
|
|
||||||
RULE_NOINITIALFOCUS,
|
|
||||||
RULE_PIN,
|
|
||||||
RULE_STAYFOCUSED,
|
|
||||||
RULE_TILE,
|
|
||||||
RULE_RENDERUNFOCUSED,
|
|
||||||
RULE_ANIMATION,
|
|
||||||
RULE_BORDERCOLOR,
|
|
||||||
RULE_CENTER,
|
|
||||||
RULE_FULLSCREENSTATE,
|
|
||||||
RULE_GROUP,
|
|
||||||
RULE_IDLEINHIBIT,
|
|
||||||
RULE_MAXSIZE,
|
|
||||||
RULE_MINSIZE,
|
|
||||||
RULE_MONITOR,
|
|
||||||
RULE_MOVE,
|
|
||||||
RULE_OPACITY,
|
|
||||||
RULE_PLUGIN,
|
|
||||||
RULE_PSEUDO,
|
|
||||||
RULE_SIZE,
|
|
||||||
RULE_SUPPRESSEVENT,
|
|
||||||
RULE_TAG,
|
|
||||||
RULE_WORKSPACE,
|
|
||||||
RULE_PROP,
|
|
||||||
RULE_CONTENT,
|
|
||||||
RULE_PERSISTENTSIZE,
|
|
||||||
RULE_NOCLOSEFOR,
|
|
||||||
RULE_NOVRR,
|
|
||||||
};
|
|
||||||
|
|
||||||
eRuleType m_ruleType = RULE_INVALID;
|
|
||||||
|
|
||||||
const std::string m_value;
|
|
||||||
const std::string m_rule;
|
|
||||||
const bool m_v2 = false;
|
|
||||||
const bool m_execRule = false;
|
|
||||||
|
|
||||||
std::string m_title;
|
|
||||||
std::string m_class;
|
|
||||||
std::string m_initialTitle;
|
|
||||||
std::string m_initialClass;
|
|
||||||
std::string m_tag;
|
|
||||||
int m_X11 = -1; // -1 means "ANY"
|
|
||||||
int m_floating = -1;
|
|
||||||
int m_fullscreen = -1;
|
|
||||||
int m_pinned = -1;
|
|
||||||
int m_focus = -1;
|
|
||||||
int m_group = -1;
|
|
||||||
int m_modal = -1;
|
|
||||||
std::string m_fullscreenState = ""; // empty means any
|
|
||||||
std::string m_onWorkspace = ""; // empty means any
|
|
||||||
std::string m_workspace = ""; // empty means any
|
|
||||||
std::string m_contentType = ""; // empty means any
|
|
||||||
std::string m_xdgTag = ""; // empty means any
|
|
||||||
|
|
||||||
// precompiled regexes
|
|
||||||
CRuleRegexContainer m_titleRegex;
|
|
||||||
CRuleRegexContainer m_classRegex;
|
|
||||||
CRuleRegexContainer m_initialTitleRegex;
|
|
||||||
CRuleRegexContainer m_initialClassRegex;
|
|
||||||
CRuleRegexContainer m_v1Regex;
|
|
||||||
};
|
|
||||||
|
|
@ -60,7 +60,7 @@ SWorkspaceIDName CWorkspace::getPrevWorkspaceIDName() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
CWorkspace::~CWorkspace() {
|
CWorkspace::~CWorkspace() {
|
||||||
Debug::log(LOG, "Destroying workspace ID {}", m_id);
|
Log::logger->log(Log::DEBUG, "Destroying workspace ID {}", m_id);
|
||||||
|
|
||||||
// check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing.
|
// check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing.
|
||||||
if (g_pHookSystem)
|
if (g_pHookSystem)
|
||||||
|
|
@ -90,7 +90,7 @@ void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev->m_id == m_id) {
|
if (prev->m_id == m_id) {
|
||||||
Debug::log(LOG, "Tried to set prev workspace to the same as current one");
|
Log::logger->log(Log::DEBUG, "Tried to set prev workspace to the same as current one");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,14 +156,14 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
if (cur == 'r') {
|
if (cur == 'r') {
|
||||||
WORKSPACEID from = 0, to = 0;
|
WORKSPACEID from = 0, to = 0;
|
||||||
if (!prop.starts_with("r[") || !prop.ends_with("]")) {
|
if (!prop.starts_with("r[") || !prop.ends_with("]")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = prop.substr(2, prop.length() - 3);
|
prop = prop.substr(2, prop.length() - 3);
|
||||||
|
|
||||||
if (!prop.contains("-")) {
|
if (!prop.contains("-")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,7 +171,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
|
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
|
||||||
|
|
||||||
if (!isNumber(LHS) || !isNumber(RHS)) {
|
if (!isNumber(LHS) || !isNumber(RHS)) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,12 +179,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
from = std::stoll(LHS);
|
from = std::stoll(LHS);
|
||||||
to = std::stoll(RHS);
|
to = std::stoll(RHS);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to < from || to < 1 || from < 1) {
|
if (to < from || to < 1 || from < 1) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,7 +195,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
|
|
||||||
if (cur == 's') {
|
if (cur == 's') {
|
||||||
if (!prop.starts_with("s[") || !prop.ends_with("]")) {
|
if (!prop.starts_with("s[") || !prop.ends_with("]")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,7 +210,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
|
|
||||||
if (cur == 'm') {
|
if (cur == 'm') {
|
||||||
if (!prop.starts_with("m[") || !prop.ends_with("]")) {
|
if (!prop.starts_with("m[") || !prop.ends_with("]")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
|
|
||||||
if (cur == 'n') {
|
if (cur == 'n') {
|
||||||
if (!prop.starts_with("n[") || !prop.ends_with("]")) {
|
if (!prop.starts_with("n[") || !prop.ends_with("]")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +246,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
if (cur == 'w') {
|
if (cur == 'w') {
|
||||||
WORKSPACEID from = 0, to = 0;
|
WORKSPACEID from = 0, to = 0;
|
||||||
if (!prop.starts_with("w[") || !prop.ends_with("]")) {
|
if (!prop.starts_with("w[") || !prop.ends_with("]")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,14 +284,14 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
// try single
|
// try single
|
||||||
|
|
||||||
if (!isNumber(prop)) {
|
if (!isNumber(prop)) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
from = std::stoll(prop);
|
from = std::stoll(prop);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -314,7 +314,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
|
const auto LHS = prop.substr(0, DASHPOS), RHS = prop.substr(DASHPOS + 1);
|
||||||
|
|
||||||
if (!isNumber(LHS) || !isNumber(RHS)) {
|
if (!isNumber(LHS) || !isNumber(RHS)) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,12 +322,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
from = std::stoll(LHS);
|
from = std::stoll(LHS);
|
||||||
to = std::stoll(RHS);
|
to = std::stoll(RHS);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to < from || to < 1 || from < 1) {
|
if (to < from || to < 1 || from < 1) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,7 +348,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
|
|
||||||
if (cur == 'f') {
|
if (cur == 'f') {
|
||||||
if (!prop.starts_with("f[") || !prop.ends_with("]")) {
|
if (!prop.starts_with("f[") || !prop.ends_with("]")) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,7 +357,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
try {
|
try {
|
||||||
FSSTATE = std::stoi(prop);
|
FSSTATE = std::stoi(prop);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,7 +379,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Invalid selector {}", selector);
|
Log::logger->log(Log::DEBUG, "Invalid selector {}", selector);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -522,7 +522,7 @@ void CWorkspace::rename(const std::string& name) {
|
||||||
if (g_pCompositor->isWorkspaceSpecial(m_id))
|
if (g_pCompositor->isWorkspaceSpecial(m_id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug::log(LOG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_id, name);
|
Log::logger->log(Log::DEBUG, "CWorkspace::rename: Renaming workspace {} to '{}'", m_id, name);
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|
||||||
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock());
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock());
|
||||||
|
|
@ -542,7 +542,7 @@ void CWorkspace::updateWindows() {
|
||||||
if (!w->m_isMapped || w->m_workspace != m_self)
|
if (!w->m_isMapped || w->m_workspace != m_self)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
w->updateDynamicRules();
|
w->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_ON_WORKSPACE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ enum eFullscreenMode : int8_t {
|
||||||
FSMODE_MAX = (1 << 2) - 1
|
FSMODE_MAX = (1 << 2) - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
class CWindow;
|
|
||||||
|
|
||||||
class CWorkspace {
|
class CWorkspace {
|
||||||
public:
|
public:
|
||||||
static PHLWORKSPACE create(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special = false, bool isEmpty = true);
|
static PHLWORKSPACE create(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special = false, bool isEmpty = true);
|
||||||
|
|
|
||||||
89
src/desktop/reserved/ReservedArea.cpp
Normal file
89
src/desktop/reserved/ReservedArea.cpp
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
#include "ReservedArea.hpp"
|
||||||
|
#include "../../macros.hpp"
|
||||||
|
|
||||||
|
using namespace Desktop;
|
||||||
|
|
||||||
|
// fuck me. Writing this at 11pm, and I have an in-class test tomorrow.
|
||||||
|
// I am failing that bitch
|
||||||
|
|
||||||
|
CReservedArea::CReservedArea(const Vector2D& tl, const Vector2D& br) : m_initialTopLeft(tl), m_initialBottomRight(br) {
|
||||||
|
calculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
CReservedArea::CReservedArea(double top, double right, double bottom, double left) : m_initialTopLeft(left, top), m_initialBottomRight(right, bottom) {
|
||||||
|
calculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
CReservedArea::CReservedArea(const CBox& parent, const CBox& child) {
|
||||||
|
ASSERT(!parent.empty() && !child.empty());
|
||||||
|
|
||||||
|
ASSERT(parent.containsPoint(child.pos() + Vector2D{0.0001, 0.0001}));
|
||||||
|
ASSERT(parent.containsPoint(child.pos() + child.size() - Vector2D{0.0001, 0.0001}));
|
||||||
|
|
||||||
|
m_initialTopLeft = child.pos() - parent.pos();
|
||||||
|
m_initialBottomRight = (parent.pos() + parent.size()) - (child.pos() + child.size());
|
||||||
|
|
||||||
|
calculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CReservedArea::calculate() {
|
||||||
|
m_bottomRight = m_initialBottomRight;
|
||||||
|
m_topLeft = m_initialTopLeft;
|
||||||
|
|
||||||
|
for (const auto& e : m_dynamicReserved) {
|
||||||
|
m_bottomRight += e.bottomRight;
|
||||||
|
m_topLeft += e.topLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CBox CReservedArea::apply(const CBox& other) const {
|
||||||
|
auto c = other.copy();
|
||||||
|
c.x += m_topLeft.x;
|
||||||
|
c.y += m_topLeft.y;
|
||||||
|
c.w -= m_topLeft.x + m_bottomRight.x;
|
||||||
|
c.h -= m_topLeft.y + m_bottomRight.y;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CReservedArea::applyip(CBox& other) const {
|
||||||
|
other.x += m_topLeft.x;
|
||||||
|
other.y += m_topLeft.y;
|
||||||
|
other.w -= m_topLeft.x + m_bottomRight.x;
|
||||||
|
other.h -= m_topLeft.y + m_bottomRight.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CReservedArea::operator==(const CReservedArea& other) const {
|
||||||
|
return other.m_bottomRight == m_bottomRight && other.m_topLeft == m_topLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CReservedArea::left() const {
|
||||||
|
return m_topLeft.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CReservedArea::right() const {
|
||||||
|
return m_bottomRight.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CReservedArea::top() const {
|
||||||
|
return m_topLeft.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CReservedArea::bottom() const {
|
||||||
|
return m_bottomRight.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CReservedArea::resetType(eReservedDynamicType t) {
|
||||||
|
m_dynamicReserved[t] = {};
|
||||||
|
calculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CReservedArea::addType(eReservedDynamicType t, const Vector2D& topLeft, const Vector2D& bottomRight) {
|
||||||
|
auto& ref = m_dynamicReserved[t];
|
||||||
|
ref.topLeft += topLeft;
|
||||||
|
ref.bottomRight += bottomRight;
|
||||||
|
calculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CReservedArea::addType(eReservedDynamicType t, const CReservedArea& area) {
|
||||||
|
addType(t, {area.left(), area.top()}, {area.right(), area.bottom()});
|
||||||
|
}
|
||||||
48
src/desktop/reserved/ReservedArea.hpp
Normal file
48
src/desktop/reserved/ReservedArea.hpp
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../../helpers/math/Math.hpp"
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace Desktop {
|
||||||
|
enum eReservedDynamicType : uint8_t {
|
||||||
|
RESERVED_DYNAMIC_TYPE_LS = 0,
|
||||||
|
RESERVED_DYNAMIC_TYPE_ERROR_BAR,
|
||||||
|
|
||||||
|
RESERVED_DYNAMIC_TYPE_END,
|
||||||
|
};
|
||||||
|
|
||||||
|
class CReservedArea {
|
||||||
|
public:
|
||||||
|
CReservedArea() = default;
|
||||||
|
CReservedArea(const Vector2D& tl, const Vector2D& br);
|
||||||
|
CReservedArea(double top, double right, double bottom, double left);
|
||||||
|
CReservedArea(const CBox& parent, const CBox& child);
|
||||||
|
~CReservedArea() = default;
|
||||||
|
|
||||||
|
CBox apply(const CBox& other) const;
|
||||||
|
void applyip(CBox& other) const;
|
||||||
|
|
||||||
|
void resetType(eReservedDynamicType);
|
||||||
|
void addType(eReservedDynamicType, const Vector2D& topLeft, const Vector2D& bottomRight);
|
||||||
|
void addType(eReservedDynamicType, const CReservedArea& area);
|
||||||
|
|
||||||
|
double left() const;
|
||||||
|
double right() const;
|
||||||
|
double top() const;
|
||||||
|
double bottom() const;
|
||||||
|
|
||||||
|
bool operator==(const CReservedArea& other) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void calculate();
|
||||||
|
|
||||||
|
Vector2D m_topLeft, m_bottomRight;
|
||||||
|
Vector2D m_initialTopLeft, m_initialBottomRight;
|
||||||
|
|
||||||
|
struct SDynamicData {
|
||||||
|
Vector2D topLeft, bottomRight;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::array<SDynamicData, RESERVED_DYNAMIC_TYPE_END> m_dynamicReserved;
|
||||||
|
};
|
||||||
|
};
|
||||||
56
src/desktop/rule/Engine.cpp
Normal file
56
src/desktop/rule/Engine.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include "Engine.hpp"
|
||||||
|
#include "Rule.hpp"
|
||||||
|
#include "../view/LayerSurface.hpp"
|
||||||
|
#include "../../Compositor.hpp"
|
||||||
|
|
||||||
|
using namespace Desktop;
|
||||||
|
using namespace Desktop::Rule;
|
||||||
|
|
||||||
|
SP<CRuleEngine> Rule::ruleEngine() {
|
||||||
|
static SP<CRuleEngine> engine = makeShared<CRuleEngine>();
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuleEngine::registerRule(SP<IRule>&& rule) {
|
||||||
|
m_rules.emplace_back(std::move(rule));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuleEngine::unregisterRule(const std::string& name) {
|
||||||
|
if (name.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::erase_if(m_rules, [&name](const auto& el) { return el->name() == name; });
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuleEngine::unregisterRule(const SP<IRule>& rule) {
|
||||||
|
std::erase(m_rules, rule);
|
||||||
|
cleanExecRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuleEngine::cleanExecRules() {
|
||||||
|
std::erase_if(m_rules, [](const auto& e) { return e->isExecRule() && e->execExpired(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuleEngine::updateAllRules() {
|
||||||
|
cleanExecRules();
|
||||||
|
for (const auto& w : g_pCompositor->m_windows) {
|
||||||
|
if (!validMapped(w) || w->isHidden())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
w->m_ruleApplicator->propertiesChanged(RULE_PROP_ALL);
|
||||||
|
}
|
||||||
|
for (const auto& ls : g_pCompositor->m_layers) {
|
||||||
|
if (!validMapped(ls))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ls->m_ruleApplicator->propertiesChanged(RULE_PROP_ALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuleEngine::clearAllRules() {
|
||||||
|
std::erase_if(m_rules, [](const auto& e) { return !e->isExecRule() || e->execExpired(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<SP<IRule>>& CRuleEngine::rules() {
|
||||||
|
return m_rules;
|
||||||
|
}
|
||||||
24
src/desktop/rule/Engine.hpp
Normal file
24
src/desktop/rule/Engine.hpp
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Rule.hpp"
|
||||||
|
|
||||||
|
namespace Desktop::Rule {
|
||||||
|
class CRuleEngine {
|
||||||
|
public:
|
||||||
|
CRuleEngine() = default;
|
||||||
|
~CRuleEngine() = default;
|
||||||
|
|
||||||
|
void registerRule(SP<IRule>&& rule);
|
||||||
|
void unregisterRule(const std::string& name);
|
||||||
|
void unregisterRule(const SP<IRule>& rule);
|
||||||
|
void updateAllRules();
|
||||||
|
void cleanExecRules();
|
||||||
|
void clearAllRules();
|
||||||
|
const std::vector<SP<IRule>>& rules();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<SP<IRule>> m_rules;
|
||||||
|
};
|
||||||
|
|
||||||
|
SP<CRuleEngine> ruleEngine();
|
||||||
|
}
|
||||||
149
src/desktop/rule/Rule.cpp
Normal file
149
src/desktop/rule/Rule.cpp
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
#include "Rule.hpp"
|
||||||
|
#include "../../debug/log/Logger.hpp"
|
||||||
|
#include <re2/re2.h>
|
||||||
|
|
||||||
|
#include "matchEngine/RegexMatchEngine.hpp"
|
||||||
|
#include "matchEngine/BoolMatchEngine.hpp"
|
||||||
|
#include "matchEngine/IntMatchEngine.hpp"
|
||||||
|
#include "matchEngine/WorkspaceMatchEngine.hpp"
|
||||||
|
#include "matchEngine/TagMatchEngine.hpp"
|
||||||
|
|
||||||
|
using namespace Desktop;
|
||||||
|
using namespace Desktop::Rule;
|
||||||
|
|
||||||
|
static const std::unordered_map<eRuleProperty, std::string> MATCH_PROP_STRINGS = {
|
||||||
|
{RULE_PROP_CLASS, "class"}, //
|
||||||
|
{RULE_PROP_TITLE, "title"}, //
|
||||||
|
{RULE_PROP_INITIAL_CLASS, "initial_class"}, //
|
||||||
|
{RULE_PROP_INITIAL_TITLE, "initial_title"}, //
|
||||||
|
{RULE_PROP_FLOATING, "float"}, //
|
||||||
|
{RULE_PROP_TAG, "tag"}, //
|
||||||
|
{RULE_PROP_XWAYLAND, "xwayland"}, //
|
||||||
|
{RULE_PROP_FULLSCREEN, "fullscreen"}, //
|
||||||
|
{RULE_PROP_PINNED, "pin"}, //
|
||||||
|
{RULE_PROP_FOCUS, "focus"}, //
|
||||||
|
{RULE_PROP_GROUP, "group"}, //
|
||||||
|
{RULE_PROP_MODAL, "modal"}, //
|
||||||
|
{RULE_PROP_FULLSCREENSTATE_INTERNAL, "fullscreen_state_internal"}, //
|
||||||
|
{RULE_PROP_FULLSCREENSTATE_CLIENT, "fullscreen_state_client"}, //
|
||||||
|
{RULE_PROP_ON_WORKSPACE, "workspace"}, //
|
||||||
|
{RULE_PROP_CONTENT, "content"}, //
|
||||||
|
{RULE_PROP_XDG_TAG, "xdg_tag"}, //
|
||||||
|
{RULE_PROP_NAMESPACE, "namespace"}, //
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::unordered_map<eRuleProperty, eRuleMatchEngine> RULE_ENGINES = {
|
||||||
|
{RULE_PROP_CLASS, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
{RULE_PROP_TITLE, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
{RULE_PROP_INITIAL_CLASS, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
{RULE_PROP_INITIAL_TITLE, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
{RULE_PROP_FLOATING, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_TAG, RULE_MATCH_ENGINE_TAG}, //
|
||||||
|
{RULE_PROP_XWAYLAND, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_FULLSCREEN, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_PINNED, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_FOCUS, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_GROUP, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_MODAL, RULE_MATCH_ENGINE_BOOL}, //
|
||||||
|
{RULE_PROP_FULLSCREENSTATE_INTERNAL, RULE_MATCH_ENGINE_INT}, //
|
||||||
|
{RULE_PROP_FULLSCREENSTATE_CLIENT, RULE_MATCH_ENGINE_INT}, //
|
||||||
|
{RULE_PROP_ON_WORKSPACE, RULE_MATCH_ENGINE_WORKSPACE}, //
|
||||||
|
{RULE_PROP_CONTENT, RULE_MATCH_ENGINE_INT}, //
|
||||||
|
{RULE_PROP_XDG_TAG, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
{RULE_PROP_NAMESPACE, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
{RULE_PROP_EXEC_TOKEN, RULE_MATCH_ENGINE_REGEX}, //
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::vector<std::string>& Rule::allMatchPropStrings() {
|
||||||
|
static std::vector<std::string> strings;
|
||||||
|
static bool once = true;
|
||||||
|
if (once) {
|
||||||
|
for (const auto& [k, v] : MATCH_PROP_STRINGS) {
|
||||||
|
strings.emplace_back(v);
|
||||||
|
}
|
||||||
|
once = false;
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<eRuleProperty> Rule::matchPropFromString(const std::string_view& s) {
|
||||||
|
const auto IT = std::ranges::find_if(MATCH_PROP_STRINGS, [&s](const auto& el) { return el.second == s; });
|
||||||
|
if (IT == MATCH_PROP_STRINGS.end())
|
||||||
|
return std::nullopt;
|
||||||
|
|
||||||
|
return IT->first;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<eRuleProperty> Rule::matchPropFromString(const std::string& s) {
|
||||||
|
return matchPropFromString(std::string_view{s});
|
||||||
|
}
|
||||||
|
|
||||||
|
IRule::IRule(const std::string& name) : m_name(name) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRule::registerMatch(eRuleProperty p, const std::string& s) {
|
||||||
|
if (!RULE_ENGINES.contains(p)) {
|
||||||
|
Log::logger->log(Log::ERR, "BUG THIS: IRule: RULE_ENGINES does not contain rule idx {}", sc<std::underlying_type_t<eRuleProperty>>(p));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (RULE_ENGINES.at(p)) {
|
||||||
|
case RULE_MATCH_ENGINE_REGEX: m_matchEngines[p] = makeUnique<CRegexMatchEngine>(s); break;
|
||||||
|
case RULE_MATCH_ENGINE_BOOL: m_matchEngines[p] = makeUnique<CBoolMatchEngine>(s); break;
|
||||||
|
case RULE_MATCH_ENGINE_INT: m_matchEngines[p] = makeUnique<CIntMatchEngine>(s); break;
|
||||||
|
case RULE_MATCH_ENGINE_WORKSPACE: m_matchEngines[p] = makeUnique<CWorkspaceMatchEngine>(s); break;
|
||||||
|
case RULE_MATCH_ENGINE_TAG: m_matchEngines[p] = makeUnique<CTagMatchEngine>(s); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mask |= p;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::underlying_type_t<eRuleProperty> IRule::getPropertiesMask() {
|
||||||
|
return m_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRule::has(eRuleProperty p) {
|
||||||
|
return m_matchEngines.contains(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRule::matches(eRuleProperty p, const std::string& s) {
|
||||||
|
if (!has(p))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return m_matchEngines[p]->match(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRule::matches(eRuleProperty p, bool b) {
|
||||||
|
if (!has(p))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return m_matchEngines[p]->match(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& IRule::name() {
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRule::markAsExecRule(const std::string& token, bool persistent) {
|
||||||
|
m_execData.isExecRule = true;
|
||||||
|
m_execData.isExecPersistent = persistent;
|
||||||
|
m_execData.token = token;
|
||||||
|
m_execData.expiresAt = Time::steadyNow() + std::chrono::minutes(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRule::isExecRule() {
|
||||||
|
return m_execData.isExecRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRule::isExecPersistent() {
|
||||||
|
return m_execData.isExecPersistent;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IRule::execExpired() {
|
||||||
|
return Time::steadyNow() > m_execData.expiresAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& IRule::execToken() {
|
||||||
|
return m_execData.token;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue