Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[experimental] Wayland build on Linux #13307

Closed
wants to merge 1 commit into from
Closed

Conversation

tibordp
Copy link

@tibordp tibordp commented Aug 27, 2024

This is the minimum changes I needed to get PrusaSlicer working on native Wayland. It's probably broken in subtle and not-so-subtle ways, but the basic functionality works on my machine and it's finally not blurry anymore with fractional scaling.

Included changes:

image

@lukasmatena
Copy link
Collaborator

Thanks. We will definitely have a look and test it. It would be nice if you could update your PR so the commit does not do the needless whitespace changes. For now, this is the diff without them:

diff --git a/deps/+GLEW/GLEW.cmake b/deps/+GLEW/GLEW.cmake
index c2db9117b6..280caec26b 100644
--- a/deps/+GLEW/GLEW.cmake
+++ b/deps/+GLEW/GLEW.cmake
@@ -5,4 +5,5 @@ add_cmake_project(
   SOURCE_SUBDIR build/cmake
   CMAKE_ARGS
     -DBUILD_UTILS=OFF
+    -DGLEW_EGL=ON
 )
diff --git a/deps/+wxWidgets/wxWidgets.cmake b/deps/+wxWidgets/wxWidgets.cmake
index 77c12ee72f..9aa11938d9 100644
--- a/deps/+wxWidgets/wxWidgets.cmake
+++ b/deps/+wxWidgets/wxWidgets.cmake
@@ -28,8 +28,8 @@ else ()
 endif ()
 
 add_cmake_project(wxWidgets
-    URL https://github.com/prusa3d/wxWidgets/archive/323a465e577e03f330e2e6a4c78e564d125340cb.zip
-    URL_HASH SHA256=B538E4AD3CC93117932F4DED70C476D6650F9C70A9D4055A08F3693864C47465
+    URL https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.5/wxWidgets-3.2.5.tar.bz2
+    URL_HASH SHA256=0AD86A3AD3E2E519B6A705248FC9226E3A09BBF069C6C692A02ACF7C2D1C6B51
     CMAKE_ARGS
         "-DCMAKE_DEBUG_POSTFIX:STRING="
         -DwxBUILD_PRECOMP=ON
@@ -50,7 +50,7 @@ add_cmake_project(wxWidgets
         -DwxUSE_EXPAT=sys
         -DwxUSE_LIBSDL=OFF
         -DwxUSE_XTEST=OFF
-        -DwxUSE_GLCANVAS_EGL=OFF
+        -DwxUSE_GLCANVAS_EGL=ON
         -DwxUSE_WEBREQUEST=OFF
         ${_wx_webview}
         ${_wx_secretstore}
diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp
index ccabc07485..a0676c15fb 100644
--- a/src/PrusaSlicer.cpp
+++ b/src/PrusaSlicer.cpp
@@ -85,13 +85,6 @@ int CLI::run(int argc, char **argv)
     // Save the thread ID of the main thread.
     save_main_thread_id();
 
-#ifdef __WXGTK__
-    // On Linux, wxGTK has no support for Wayland, and the app crashes on
-    // startup if gtk3 is used. This env var has to be set explicitly to
-    // instruct the window manager to fall back to X server mode.
-    ::setenv("GDK_BACKEND", "x11", /* replace */ true);
-#endif
-
 	// Switch boost::filesystem to utf8.
     try {
         boost::nowide::nowide_filesystem();
diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp
index 11ca1249c9..b4577f7492 100644
--- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp
+++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp
@@ -606,7 +606,8 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
     // Always fill in the "printhost_port" combo box from the config and select it.
     {
         Choice* choice = dynamic_cast<Choice*>(m_optgroup->get_field("printhost_port"));
-        choice->set_values({ m_config->opt_string("printhost_port") });
+        std::vector<std::string> vals { m_config->opt_string("printhost_port") };
+        choice->set_values(vals);
         choice->set_selection();
     }
 
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index bbaf4c5d73..d66331efc7 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -4048,7 +4048,8 @@ void Plater::load_project(const wxString& filename)
 
     p->reset();
 
-    if (! load_files({ into_path(filename) }).empty()) {
+    std::vector<boost::filesystem::path> input_files { into_path(filename) };
+    if (! load_files(input_files).empty()) {
         // At least one file was loaded.
         p->set_project_filename(filename);
         // Save the names of active presets and project specific config into ProjectDirtyStateManager.

@dcompoze
Copy link

dcompoze commented Sep 29, 2024

I managed to build the ArchLinux package with the following patch:

diff --git deps/+GLEW/GLEW.cmake deps/+GLEW/GLEW.cmake
index c2db9117b..280caec26 100644
--- deps/+GLEW/GLEW.cmake
+++ deps/+GLEW/GLEW.cmake
@@ -5,4 +5,5 @@ add_cmake_project(
   SOURCE_SUBDIR build/cmake
   CMAKE_ARGS
     -DBUILD_UTILS=OFF
-)
\ No newline at end of file
+    -DGLEW_EGL=ON
+)
diff --git deps/+wxWidgets/wxWidgets.cmake deps/+wxWidgets/wxWidgets.cmake
index e09f3d987..b5b797014 100644
--- deps/+wxWidgets/wxWidgets.cmake
+++ deps/+wxWidgets/wxWidgets.cmake
@@ -28,9 +28,8 @@ else ()
 endif ()
 
 add_cmake_project(wxWidgets
-    URL https://github.com/prusa3d/wxWidgets/archive/323a465e577e03f330e2e6a4c78e564d125340cb.zip
-    URL_HASH SHA256=B538E4AD3CC93117932F4DED70C476D6650F9C70A9D4055A08F3693864C47465
-    PATCH_COMMAND COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/webview.patch
+    URL https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.6/wxWidgets-3.2.6.tar.bz2
+    URL_HASH SHA256=939E5B77DDC5B6092D1D7D29491FE67010A2433CF9B9C0D841EE4D04ACB9DCE7
     CMAKE_ARGS
         "-DCMAKE_DEBUG_POSTFIX:STRING="
         -DwxBUILD_PRECOMP=ON
@@ -51,7 +50,7 @@ add_cmake_project(wxWidgets
         -DwxUSE_EXPAT=sys
         -DwxUSE_LIBSDL=OFF
         -DwxUSE_XTEST=OFF
-        -DwxUSE_GLCANVAS_EGL=OFF
+        -DwxUSE_GLCANVAS_EGL=ON
         -DwxUSE_WEBREQUEST=OFF
         ${_wx_webview}
         ${_wx_secretstore}
diff --git src/PrusaSlicer.cpp src/PrusaSlicer.cpp
index 07fefd058..10ef368ab 100644
--- src/PrusaSlicer.cpp
+++ src/PrusaSlicer.cpp
@@ -86,13 +86,6 @@ int CLI::run(int argc, char **argv)
     // Save the thread ID of the main thread.
     save_main_thread_id();
 
-#ifdef __WXGTK__
-    // On Linux, wxGTK has no support for Wayland, and the app crashes on
-    // startup if gtk3 is used. This env var has to be set explicitly to
-    // instruct the window manager to fall back to X server mode.
-    ::setenv("GDK_BACKEND", "x11", /* replace */ true);
-#endif
-
 	// Switch boost::filesystem to utf8.
     try {
         boost::nowide::nowide_filesystem();
diff --git src/slic3r/GUI/PhysicalPrinterDialog.cpp src/slic3r/GUI/PhysicalPrinterDialog.cpp
index 373d0b6bf..021957231 100644
--- src/slic3r/GUI/PhysicalPrinterDialog.cpp
+++ src/slic3r/GUI/PhysicalPrinterDialog.cpp
@@ -607,7 +607,8 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
     // Always fill in the "printhost_port" combo box from the config and select it.
     {
         Choice* choice = dynamic_cast<Choice*>(m_optgroup->get_field("printhost_port"));
-        choice->set_values({ m_config->opt_string("printhost_port") });
+        std::vector<std::string> vals { m_config->opt_string("printhost_port") };
+        choice->set_values(vals);
         choice->set_selection();
     }
 
diff --git src/slic3r/GUI/Plater.cpp src/slic3r/GUI/Plater.cpp
index a80064f99..21d2ae77a 100644
--- src/slic3r/GUI/Plater.cpp
+++ src/slic3r/GUI/Plater.cpp
@@ -4106,7 +4106,8 @@ void Plater::load_project(const wxString& filename)
 
     p->reset();
 
-    if (! load_files({ into_path(filename) }).empty()) {
+    std::vector<boost::filesystem::path> input_files { into_path(filename) };
+    if (! load_files(input_files).empty()) {
         // At least one file was loaded.
         p->set_project_filename(filename);
         // Save the names of active presets and project specific config into ProjectDirtyStateManager.

And so far it seems to work fine as a native wayland client (although with some visual artifacts).

It would be great to have official native wayland support.

@sl1pkn07
Copy link

Hi. seems this needs to be rebased

greetings

@tibordp
Copy link
Author

tibordp commented Nov 25, 2024

Sorry, I don't have interest in getting this into a mergeable state, this was more of a proof-of-concept. Feel free to use this in any way, if it is useful, but I am going to close the PR now.

@tibordp tibordp closed this Nov 25, 2024
@sl1pkn07
Copy link

????

:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants