[Bf-blender-cvs] [3a8fa77c1fd] master: GHOST/Wayland: Add a build time option for DBUS, disable by default

Campbell Barton noreply at git.blender.org
Mon Jun 27 08:49:52 CEST 2022


Commit: 3a8fa77c1fd21b9266afe549f9bd308d74439dd0
Author: Campbell Barton
Date:   Mon Jun 27 16:33:58 2022 +1000
Branches: master
https://developer.blender.org/rB3a8fa77c1fd21b9266afe549f9bd308d74439dd0

GHOST/Wayland: Add a build time option for DBUS, disable by default

Add WITH_GHOST_WAYLAND_DBUS option, so Blender can be built without
DBUS support. Currently it's only used to access the cursor theme.
Without this the "default" cursors are used instead.

Disabling this since it adds an additional dependency for a minor gain
in functionality, with the benefit of removing a library requirement.

There is also a problem where Blender hangs on startup for ~5 seconds
when DBUS isn't running. Eventually it would be good to be able to avoid
this problem without a build option.

===================================================================

M	CMakeLists.txt
M	build_files/cmake/platform/platform_unix.cmake
M	intern/ghost/CMakeLists.txt
M	intern/ghost/intern/GHOST_WaylandCursorSettings.h

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 60d980930c1..3c3127e0f64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,6 +226,9 @@ if(UNIX AND NOT (APPLE OR HAIKU))
   if (WITH_GHOST_WAYLAND)
     option(WITH_GHOST_WAYLAND_LIBDECOR "Optionally build with LibDecor window decorations" OFF)
     mark_as_advanced(WITH_GHOST_WAYLAND_LIBDECOR)
+
+    option(WITH_GHOST_WAYLAND_DBUS "Optionally build with DBUS support (used for Cursor themes). May hang on startup systems where DBUS is not used." OFF)
+    mark_as_advanced(WITH_GHOST_WAYLAND_DBUS)
   endif()
 endif()
 
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 781e2798fea..875305b0564 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -613,7 +613,10 @@ if(WITH_GHOST_WAYLAND)
   pkg_check_modules(wayland-scanner REQUIRED wayland-scanner)
   pkg_check_modules(xkbcommon REQUIRED xkbcommon)
   pkg_check_modules(wayland-cursor REQUIRED wayland-cursor)
-  pkg_check_modules(dbus REQUIRED dbus-1)
+
+  if(WITH_GHOST_WAYLAND_DBUS)
+    pkg_check_modules(dbus REQUIRED dbus-1)
+  endif()
 
   if(WITH_GHOST_WAYLAND_LIBDECOR)
     pkg_check_modules(libdecor REQUIRED libdecor-0>=0.1)
@@ -626,9 +629,15 @@ if(WITH_GHOST_WAYLAND)
     ${wayland-egl_LINK_LIBRARIES}
     ${xkbcommon_LINK_LIBRARIES}
     ${wayland-cursor_LINK_LIBRARIES}
-    ${dbus_LINK_LIBRARIES}
   )
 
+  if(WITH_GHOST_WAYLAND_DBUS)
+    list(APPEND PLATFORM_LINKLIBS
+      ${dbus_LINK_LIBRARIES}
+    )
+    add_definitions(-DWITH_GHOST_WAYLAND_DBUS)
+  endif()
+
   if(WITH_GHOST_WAYLAND_LIBDECOR)
     list(APPEND PLATFORM_LINKLIBS
       ${libdecor_LIBRARIES}
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 150bcb9273e..6a11d00cbc4 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -268,9 +268,14 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND)
       ${wayland-egl_INCLUDE_DIRS}
       ${xkbcommon_INCLUDE_DIRS}
       ${wayland-cursor_INCLUDE_DIRS}
-      ${dbus_INCLUDE_DIRS}
     )
 
+    if(WITH_GHOST_WAYLAND_DBUS)
+      list(APPEND INC_SYS
+        ${dbus_INCLUDE_DIRS}
+      )
+    endif()
+
     if(WITH_GHOST_WAYLAND_LIBDECOR)
       list(APPEND INC_SYS
         ${libdecor_INCLUDE_DIRS}
diff --git a/intern/ghost/intern/GHOST_WaylandCursorSettings.h b/intern/ghost/intern/GHOST_WaylandCursorSettings.h
index 2491f6ca31f..f5649d20850 100644
--- a/intern/ghost/intern/GHOST_WaylandCursorSettings.h
+++ b/intern/ghost/intern/GHOST_WaylandCursorSettings.h
@@ -5,9 +5,13 @@
  */
 
 #pragma once
-#include <dbus/dbus.h>
 #include <string>
 
+#ifdef WITH_GHOST_WAYLAND_DBUS
+#  include <dbus/dbus.h>
+#endif
+
+#ifdef WITH_GHOST_WAYLAND_DBUS
 static DBusMessage *get_setting_sync(DBusConnection *const connection,
                                      const char *key,
                                      const char *value)
@@ -66,9 +70,11 @@ static bool parse_type(DBusMessage *const reply, const int type, void *value)
 
   return true;
 }
+#endif /* WITH_GHOST_WAYLAND_DBUS */
 
 static bool get_cursor_settings(std::string &theme, int &size)
 {
+#ifdef WITH_GHOST_WAYLAND_DBUS
   static const char name[] = "org.gnome.desktop.interface";
   static const char key_theme[] = "cursor-theme";
   static const char key_size[] = "cursor-size";
@@ -113,4 +119,11 @@ static bool get_cursor_settings(std::string &theme, int &size)
   dbus_message_unref(reply);
 
   return true;
+#else
+  /* NOTE: eventually we could have alternative ways to access the theme,
+   * this uses the "default" theme which is functional (instead of a user-defined theme). */
+  (void)theme;
+  (void)size;
+  return false;
+#endif /* !WITH_GHOST_WAYLAND_DBUS */
 }



More information about the Bf-blender-cvs mailing list