From a4f83c55a688b391cd7408ddc13e660f0632f57d Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Tue, 29 Sep 2020 11:00:06 +0900 Subject: [PATCH] Add Wayland build option --- profiler/build/unix/build.mk | 9 +++++++++ profiler/src/NativeWindow.cpp | 12 +++++++++++- profiler/src/main.cpp | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/profiler/build/unix/build.mk b/profiler/build/unix/build.mk index 1e945445..f58c8193 100644 --- a/profiler/build/unix/build.mk +++ b/profiler/build/unix/build.mk @@ -3,6 +3,15 @@ CXXFLAGS := $(CFLAGS) -std=c++17 DEFINES += -DIMGUI_IMPL_OPENGL_LOADER_GL3W INCLUDES := $(shell pkg-config --cflags glfw3 freetype2 capstone) -I../../../imgui -I../../libs/gl3w LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl + +DISPLAY_SERVER := X11 +libwayland_client := $(shell pkg-config --libs --silence-errors wayland-client) +ifeq ($(.SHELLSTATUS),0) + DISPLAY_SERVER := WAYLAND + LIBS += $(libwayland_client) +endif +CXXFLAGS += -D"DISPLAY_SERVER_$(DISPLAY_SERVER)" + PROJECT := Tracy IMAGE := $(PROJECT)-$(BUILD) diff --git a/profiler/src/NativeWindow.cpp b/profiler/src/NativeWindow.cpp index 79ac0f60..94031cdc 100644 --- a/profiler/src/NativeWindow.cpp +++ b/profiler/src/NativeWindow.cpp @@ -6,7 +6,13 @@ # define GLFW_EXPOSE_NATIVE_WIN32 # include #elif defined __linux__ -# define GLFW_EXPOSE_NATIVE_X11 +# ifdef DISPLAY_SERVER_X11 +# define GLFW_EXPOSE_NATIVE_X11 +# elif defined DISPLAY_SERVER_WAYLAND +# define GLFW_EXPOSE_NATIVE_WAYLAND +# else +# error "unsupported linux display server" +# endif # include #endif @@ -17,7 +23,11 @@ void* GetMainWindowNative() #ifdef _WIN32 return (void*)glfwGetWin32Window( s_glfwWindow ); #elif defined __linux__ +# ifdef DISPLAY_SERVER_X11 return (void*)glfwGetX11Window( s_glfwWindow ); +# elif defined DISPLAY_SERVER_WAYLAND + return (void*)glfwGetWaylandWindow( s_glfwWindow ); +# endif #else return nullptr; #endif diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index f453defc..1d88caa2 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -244,7 +244,9 @@ int main( int argc, char** argv ) // Setup window glfwSetErrorCallback(glfw_error_callback); if( !glfwInit() ) return 1; +#ifndef DISPLAY_SERVER_WAYLAND glfwWindowHint(GLFW_VISIBLE, 0); +#endif glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);