cloudhead / rx

👾 Modern and minimalist pixel editor
https://discord.gg/xHggPjfsS9
GNU General Public License v3.0
3.07k stars 109 forks source link

Wayland support? #98

Open ghost opened 3 years ago

ghost commented 3 years ago

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

cloudhead commented 3 years ago

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 commented 3 years ago

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).

ghost commented 3 years ago

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:

cloudhead commented 3 years ago

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.

ghost commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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?

cloudhead commented 3 years ago

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.

i509VCB commented 2 years ago

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.

cloudhead commented 2 years ago

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.

hendursaga commented 1 year ago

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.

cloudhead commented 1 year ago

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