friedow / centerpiece

Your trusty omnibox search.
MIT License
192 stars 6 forks source link

Integrate with wlr layershell to properly support floating in wayland #188

Closed friedow closed 1 month ago

friedow commented 2 months ago

Instead of using the default implementation of floating within iced, we should switch to layershell: https://crates.io/crates/iced-layershell. layershell is wayland protocol which should be used for things like floating.

friedow commented 1 month ago

I've added the iced_layershell dependency on the feat/wlr-layershell branch. However, iced_layershell dependends on smithay-client-toolkit 0.18.1 which does not compile because of a missing libxkbcommon dependency.

FYI: We already depend on libxkbcommon, which does not seem to be found by smithay-client-toolkit 0.18.1. Furthermore, we're currently depending on smithay-client-toolkit 0.19.2, which compiles just fine.

Decodetalkers commented 1 month ago

I've added the iced_layershell dependency on the feat/wlr-layershell branch. However, iced_layershell dependends on smithay-client-toolkit 0.18.1 which does not compile because of a missing libxkbcommon dependency.

FYI: We already depend on libxkbcommon, which does not seem to be found by smithay-client-toolkit 0.18.1. Furthermore, we're currently depending on smithay-client-toolkit 0.19.2, which compiles just fine.

I have found this great project, and find you are trying to use our crate.

Emm, xkbcommon is used to handle the keyboard event, and origin iced should also rely on xkbcommon.. because winit use xkbcommon to handle the keyboard event.. we also made a crate namedwaycrate_xkbkeycode to handle it. Yes, not simithay-client-toolkit, but our crate.

And I have taken a look at that branch, seems it won't compile, because iced-layershell needs the message to be implemented the tryInto trait. So that macro to_layer_message is still needed

friedow commented 1 month ago

Uhhhhh thanks for the insights @Decodetalkers! I'll try the to_layer_message macro right away :).

friedow commented 1 month ago

@Decodetalkers sadly, this is not the problem for me currenlty. I'm running into the log below while compiling. I'm using NixOS with the nix development shell which is included in the repository.

   Compiling smithay-client-toolkit v0.19.2
   Compiling xkbcommon-dl v0.4.2
   Compiling wayland-protocols-wlr v0.2.0
   Compiling smithay-client-toolkit v0.18.1
   Compiling xkbcommon v0.7.0
   Compiling calloop-wayland-source v0.2.0
   Compiling darling_macro v0.20.10
   Compiling manyhow v0.11.4
error: failed to run custom build command for `smithay-client-toolkit v0.18.1`

Caused by:
  process didn't exit successfully: `/home/christian/Code/friedow/centerpiece/target/debug/build/smithay-client-toolkit-0aee21101633790d/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=XKBCOMMON_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=XKBCOMMON_STATIC
  cargo:rerun-if-env-changed=XKBCOMMON_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at /home/christian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-client-toolkit-0.18.1/build.rs:3:49:
  called `Result::unwrap()` on an `Err` value: "\npkg-config exited with status code 1\n> PKG_CONFIG_PATH=/nix/store/qj94g4g6i5z2m99pfjvjgwgqx0vy216q-dbus-1.14.10-dev/lib/pkgconfig:/nix/store/cyccwyjsfqkg5p2k096wvd274nv80q0l-expat-2.6.2-dev/lib/pkgconfig PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALL
OW_SYSTEM_CFLAGS=1 pkgconf --libs --cflags xkbcommon\n\nThe system library `xkbcommon` required by crate `smithay-client-toolkit` was not found.\nThe file `xkbcommon.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.\nPKG_CONFIG_PATH contains th
e following:\n    - /nix/store/qj94g4g6i5z2m99pfjvjgwgqx0vy216q-dbus-1.14.10-dev/lib/pkgconfig\n    - /nix/store/cyccwyjsfqkg5p2k096wvd274nv80q0l-expat-2.6.2-dev/lib/pkgconfig\n\nHINT: you may need to install a package such as xkbcommon, xkbcommon-dev or xkbcommon-devel.\n"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Decodetalkers commented 1 month ago

@Decodetalkers sadly, this is not the problem for me currenlty. I'm running into the log below while compiling. I'm using NixOS with the nix development shell which is included in the repository.

   Compiling smithay-client-toolkit v0.19.2
   Compiling xkbcommon-dl v0.4.2
   Compiling wayland-protocols-wlr v0.2.0
   Compiling smithay-client-toolkit v0.18.1
   Compiling xkbcommon v0.7.0
   Compiling calloop-wayland-source v0.2.0
   Compiling darling_macro v0.20.10
   Compiling manyhow v0.11.4
error: failed to run custom build command for `smithay-client-toolkit v0.18.1`

Caused by:
  process didn't exit successfully: `/home/christian/Code/friedow/centerpiece/target/debug/build/smithay-client-toolkit-0aee21101633790d/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=XKBCOMMON_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=XKBCOMMON_STATIC
  cargo:rerun-if-env-changed=XKBCOMMON_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at /home/christian/.cargo/registry/src/index.crates.io-6f17d22bba15001f/smithay-client-toolkit-0.18.1/build.rs:3:49:
  called `Result::unwrap()` on an `Err` value: "\npkg-config exited with status code 1\n> PKG_CONFIG_PATH=/nix/store/qj94g4g6i5z2m99pfjvjgwgqx0vy216q-dbus-1.14.10-dev/lib/pkgconfig:/nix/store/cyccwyjsfqkg5p2k096wvd274nv80q0l-expat-2.6.2-dev/lib/pkgconfig PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALL
OW_SYSTEM_CFLAGS=1 pkgconf --libs --cflags xkbcommon\n\nThe system library `xkbcommon` required by crate `smithay-client-toolkit` was not found.\nThe file `xkbcommon.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.\nPKG_CONFIG_PATH contains th
e following:\n    - /nix/store/qj94g4g6i5z2m99pfjvjgwgqx0vy216q-dbus-1.14.10-dev/lib/pkgconfig\n    - /nix/store/cyccwyjsfqkg5p2k096wvd274nv80q0l-expat-2.6.2-dev/lib/pkgconfig\n\nHINT: you may need to install a package such as xkbcommon, xkbcommon-dev or xkbcommon-devel.\n"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Maybe update the deps? New release of iced-layershell does not use the simithay-client-toolkit

Decodetalkers commented 1 month ago

I have made a pr for you . Can you take a try?

friedow commented 1 month ago

This is so great! I was tinkering with this just a few minutes ago myself and was not nearly at a point to get i working. Thank you so much!

If I understand this correctly then iced_layershell does not support the new builder pattern which was introduced in iced 0.13 right?

friedow commented 1 month ago

Hey @Decodetalkers, this works very well now :). I've adjusted centerpiece to launch in the top layer and adjusted its size. The last thing that does not work yet is closing the application. Usually you hit Esc to close it. I've checked and the close call to iced gets called but it does nothing. The window stays open.

The code that should close the window is over here: https://github.com/friedow/centerpiece/blob/feat/wlr-layershell/client/src/main.rs#L89

Specifically this code snippet should close the window: iced::window::get_latest().and_then(iced::window::close);

Is this a bug in iced_layershell or am I missing something here?

Decodetalkers commented 1 month ago

Hey @Decodetalkers, this works very well now :). I've adjusted centerpiece to launch in the top layer and adjusted its size. The last thing that does not work yet is closing the application. Usually you hit Esc to close it. I've checked and the close call to iced gets called but it does nothing. The window stays open.

The code that should close the window is over here: https://github.com/friedow/centerpiece/blob/feat/wlr-layershell/client/src/main.rs#L89

Specifically this code snippet should close the window: iced::window::get_latest().and_then(iced::window::close);

Is this a bug in iced_layershell or am I missing something here?

ohh.. I have not handled the get_last event in our plugin.. but in your case, just use the Exit Action in iced_runtime, I think it will be enough

In my opinion, for the layershell plugin, it should not have the concept of last window, because you will not know if the last window is popup , or the window monitor following layershell. in our plugin you can get every id and know their role, and so something with the id. And your program is just a single window program, so you do not need to get the last window, I think

Yes, build pattern haven't been support. It maybe be a little hard for me..