rx icon indicating copy to clipboard operation
rx copied to clipboard

Wayland support?

Open ghost opened this issue 3 years ago • 12 comments

Hi there!

First of all, thank you for developing RX. I've been using it for a while now and like it very much.

I am using Sway which uses Wayland instead of X11. I know there is xorg-server-xwayland package available but would like to ask whether Wayland will be natively supported or not? When I try to run RX, it gives me this error:

thread 'main' panicked at 'GLFW Error: X11: Failed to open display :0', /home/makkusu/.cargo/registry/src/github.com-1ecc6299db9ec823/glfw-0.34.0/src/lib.rs:422:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I suppose the program complains about X11 missing from the system. Unfortunately, I am not an experienced developer at all, therefore I cannot implement support for Wayland by myself and create a pull request right now.

Kind regards, Makkusu

ghost avatar Dec 27 '20 15:12 ghost

Hey, glad you are enjoying Rx! The underlying library I use to create the graphics context has experimental Wayland support, so it should be possible. I'm looking into it now.

cloudhead avatar Dec 27 '20 18:12 cloudhead

Hey, it looks like a few people are using Rx on Wayland already. How are you running Rx? From source or from the AppImage? I think if you have glfw-wayland installed, then it should work with wayland, unless the AppImage bundled the X11 version in (need to check).

cloudhead avatar Dec 27 '20 18:12 cloudhead

Hi there!

I run Rx from command line with "rx &". For installation I've used package from AUR. Tried both ordinary rx package and rx-bin, none of them seems to work without X11. I have installed glfw-wayland package as well but it doesn't solve the problem. The previously mentioned error pops up. I suppose my Wayland setup might be misconfigured in some ways, therefore I will continue investigating the issue.

Just in case some technical information regarding software I use:

  • Manjaro Linux
  • Sway WM

ghost avatar Dec 27 '20 20:12 ghost

I think it may be that people are running x11 within wayland :thinking:, ie. non-natively.

To run it natively, from my understanding, would require building glfw-rs (https://github.com/PistonDevelopers/glfw-rs) with wayland support.

One thing you could try though is to build rx from source, using rust (perhaps via the rustup package). You simply need to run cargo install --path . then.

cloudhead avatar Jan 01 '21 10:01 cloudhead

Thanks! I will give it a try this evening. To my assumption, package from AUR might be somewhat built for X11 only(I suppose), therefore it does not recognize Wayland at all. 🤔

ghost avatar Jan 01 '21 13:01 ghost

Hi there!

It's been a while since I tried rx. I've switched the system but the base remains the same: Wayland. I encountered yet another problem with compilation process:

error: failed to run custom build command for `glfw-sys v3.3.2`

Caused by:
  process didn't exit successfully: `/home/makkusu/Temporary/rx/target/release/build/glfw-sys-174ae65fb7f8337d/build-script-build` (exit code: 101)
  --- stdout
  running: "cmake" "/home/makkusu/.cargo/registry/src/github.com-1ecc6299db9ec823/glfw-sys-3.3.2/." "-DGLFW_BUILD_EXAMPLES=OFF" "-DGLFW_BUILD_TESTS=OFF" "-DGLFW_BUILD_DOCS=OFF" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_PREFIX=/home/makkusu/Temporary/rx/target/release/build/glfw-sys-19cb04e37a8af78d/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- Using X11 for window creation
  -- Configuring incomplete, errors occurred!
  See also "/home/makkusu/Temporary/rx/target/release/build/glfw-sys-19cb04e37a8af78d/out/build/CMakeFiles/CMakeOutput.log".

  --- stderr
  CMake Error at /usr/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
    Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
  Call Stack (most recent call first):
    /usr/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
    /usr/share/cmake-3.19/Modules/FindX11.cmake:437 (find_package_handle_standard_args)
    CMakeLists.txt:196 (find_package)


  thread 'main' panicked at '
  command did not execute successfully, got: exit code: 1

  build script failed, must exit now', /home/makkusu/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `rx v0.4.0 (/home/makkusu/Temporary/rx)`, intermediate artifacts can be found at `/home/makkusu/Temporary/rx/target`

I can clearly see the core of the problem:

-- Using X11 for window creation

It looks like glfw-sys package uses X11 by default or there is a custom setting which enabled X11 by default. Is there any way to specify whether the dependency should use Wayland or X11? :thinking:

ghost avatar Mar 24 '21 16:03 ghost

I found that Wayland can be enabled through this command when building glfw (Taken from this issue)

cmake -DGLFW_USE_WAYLAND=ON ..

Is there any way to specify that variable in Cargo.toml or Cargo.lock?

ghost avatar Mar 24 '21 16:03 ghost

Could you try installing GLFW via your distribution's package manager and then trying to build again? I'm wondering if it might be able to pickup the installed glfw that way instead of building it.

cloudhead avatar Apr 06 '21 20:04 cloudhead

One alternative that could be considered is using winit instead of glfw.

Winit has out of the box Wayland support and will work with OpenGL.

i509VCB avatar Apr 03 '22 00:04 i509VCB

One alternative that could be considered is using winit instead of glfw.

Winit has out of the box Wayland support and will work with OpenGL.

Yeah, I'd be down to explore this again. Rx used to run on winit, but I switched to glfw due to bugs and limitations in winit. This was a few years ago though, so maybe the situation has changed.

cloudhead avatar Apr 04 '22 09:04 cloudhead

I'm using the Sway window manager without XWayland support perfectly fine. I'm on Debian Stable, too, so it works even with "outdated" packages, too.

hendursaga avatar Oct 20 '22 17:10 hendursaga

This landed a while ago, so we'll be able to support it officially: https://github.com/PistonDevelopers/glfw-rs/commit/66c263b87c873a064420d2fd8fb452d15f2838bc

cloudhead avatar Oct 22 '22 19:10 cloudhead