Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
@@ -14,7 +14,7 @@ BUILD_CXX_FLAGS += -Isrc/pugl-upstream/include | |||
LINK_FLAGS += $(DGL_LIBS) | |||
# TODO fix these after pugl-upstream is done | |||
BUILD_CXX_FLAGS += -Wno-missing-field-initializers -Wno-extra -Wno-narrowing | |||
BUILD_CXX_FLAGS += -Wno-attributes -Wno-extra -Wno-missing-field-initializers -Wno-narrowing | |||
# ifneq ($(MACOS_OLD),true) | |||
# needed by sofd right now, fix later | |||
@@ -39,36 +39,42 @@ OBJS_common = \ | |||
../build/dgl/WidgetPrivateData.cpp.o \ | |||
../build/dgl/Window.cpp.o \ | |||
../build/dgl/WindowPrivateData.cpp.o | |||
# ../build/dgl/WindowFileBrowser.cpp.o | |||
# TODO: ImageWidgets.cpp | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
OBJS_cairo = $(OBJS_common) \ | |||
../build/dgl/Cairo.cpp.cairo.o \ | |||
../build/dgl/pugl.cpp.cairo.o | |||
../build/dgl/Cairo.cpp.cairo.o | |||
# ifeq ($(MACOS),true) | |||
# OBJS_cairo += ../build/dgl/Window.mm.cairo.o | |||
# else | |||
# OBJS_cairo += ../build/dgl/Window.cpp.cairo.o | |||
# endif | |||
ifeq ($(MACOS),true) | |||
OBJS_cairo += ../build/dgl/pugl.mm.cairo.o | |||
else | |||
OBJS_cairo += ../build/dgl/pugl.cpp.cairo.o | |||
endif | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
OBJS_opengl = $(OBJS_common) \ | |||
../build/dgl/ImageWidgets.cpp.o \ | |||
../build/dgl/OpenGL.cpp.opengl.o \ | |||
../build/dgl/NanoVG.cpp.opengl.o \ | |||
../build/dgl/pugl.cpp.opengl.o | |||
../build/dgl/NanoVG.cpp.opengl.o | |||
# ifeq ($(MACOS),true) | |||
# OBJS_opengl += ../build/dgl/Window.mm.opengl.o | |||
# else | |||
# OBJS_opengl += ../build/dgl/Window.cpp.opengl.o | |||
# endif | |||
ifeq ($(MACOS),true) | |||
OBJS_opengl += ../build/dgl/pugl.mm.opengl.o | |||
else | |||
OBJS_opengl += ../build/dgl/pugl.cpp.opengl.o | |||
endif | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
OBJS_vulkan = $(OBJS_common) \ | |||
../build/dgl/Cairo.cpp.vulkan.o | |||
ifeq ($(MACOS),true) | |||
OBJS_vulkan += ../build/dgl/pugl.mm.vulkan.o | |||
else | |||
OBJS_vulkan += ../build/dgl/pugl.cpp.vulkan.o | |||
endif | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
@@ -82,6 +88,10 @@ TARGETS += ../build/libdgl-opengl.a | |||
TARGETS += ../build/libdgl.a | |||
endif | |||
ifeq ($(HAVE_VULKAN),true) | |||
TARGETS += ../build/libdgl-vulkan.a | |||
endif | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
all: $(TARGETS) | |||
@@ -100,6 +110,12 @@ all: $(TARGETS) | |||
$(SILENT)rm -f $@ | |||
$(SILENT)$(AR) crs $@ $^ | |||
../build/libdgl-vulkan.a: $(OBJS_vulkan) | |||
-@mkdir -p ../build | |||
@echo "Creating libdgl-vulkan.a" | |||
$(SILENT)rm -f $@ | |||
$(SILENT)$(AR) crs $@ $^ | |||
# Compat name, to be removed soon | |||
../build/libdgl.a: ../build/libdgl-opengl.a | |||
@echo "Symlinking libdgl.a" | |||
@@ -117,6 +133,11 @@ all: $(TARGETS) | |||
@echo "Compiling $<" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
../build/dgl/%.mm.o: src/%.mm | |||
-@mkdir -p ../build/dgl | |||
@echo "Compiling $<" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -ObjC++ -o $@ | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
../build/dgl/%.cpp.cairo.o: src/%.cpp | |||
@@ -124,15 +145,10 @@ all: $(TARGETS) | |||
@echo "Compiling $< (Cairo variant)" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@ | |||
# ../build/dgl/Window.cpp.cairo.o: src/Window.cpp src/sofd/* src/pugl-upstream/* | |||
# -@mkdir -p ../build/dgl | |||
# @echo "Compiling $< (Cairo variant)" | |||
# $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@ | |||
# | |||
# ../build/dgl/Window.mm.cairo.o: src/Window.cpp src/sofd/* src/pugl-upstream/* | |||
# -@mkdir -p ../build/dgl | |||
# @echo "Compiling $< (Cairo variant)" | |||
# $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -ObjC++ -c -o $@ | |||
../build/dgl/%.mm.cairo.o: src/%.mm | |||
-@mkdir -p ../build/dgl | |||
@echo "Compiling $< (Cairo variant)" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -ObjC++ -o $@ | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
@@ -141,15 +157,22 @@ all: $(TARGETS) | |||
@echo "Compiling $< (OpenGL variant)" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@ | |||
# ../build/dgl/Window.cpp.opengl.o: src/Window.cpp src/sofd/* src/pugl-upstream/* | |||
# -@mkdir -p ../build/dgl | |||
# @echo "Compiling $< (OpenGL variant)" | |||
# $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@ | |||
# | |||
# ../build/dgl/Window.mm.opengl.o: src/Window.cpp src/sofd/* src/pugl-upstream/* | |||
# -@mkdir -p ../build/dgl | |||
# @echo "Compiling $< (OpenGL variant)" | |||
# $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -ObjC++ -c -o $@ | |||
../build/dgl/%.mm.opengl.o: src/%.mm | |||
-@mkdir -p ../build/dgl | |||
@echo "Compiling $< (OpenGL variant)" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -ObjC++ -o $@ | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
../build/dgl/%.cpp.vulkan.o: src/%.cpp | |||
-@mkdir -p ../build/dgl | |||
@echo "Compiling $< (Vulkan variant)" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(VULKAN_FLAGS) -DDGL_VULKAN -c -o $@ | |||
../build/dgl/%.mm.vulkan.o: src/%.mm | |||
-@mkdir -p ../build/dgl | |||
@echo "Compiling $< (Vulkan variant)" | |||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(VULKAN_FLAGS) -DDGL_VULKAN -c -ObjC++ -o $@ | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
@@ -164,5 +187,6 @@ debug: | |||
-include $(OBJS_common:%.o=%.d) | |||
-include $(OBJS_cairo:%.o=%.d) | |||
-include $(OBJS_opengl:%.o=%.d) | |||
-include $(OBJS_vulkan:%.o=%.d) | |||
# --------------------------------------------------------------------------------------------------------------------- |
@@ -19,11 +19,13 @@ | |||
#include "pugl.hpp" | |||
#include <cinttypes> | |||
#define DGL_DEBUG_EVENTS | |||
START_NAMESPACE_DGL | |||
#if defined(DEBUG) && defined(DGL_DEBUG_EVENTS) | |||
# include <cinttypes> | |||
#endif | |||
#define DGL_DEBUG_EVENTS | |||
START_NAMESPACE_DGL | |||
#if defined(DEBUG) && defined(DGL_DEBUG_EVENTS) | |||
# define DGL_DBG(msg) std::fprintf(stderr, "%s", msg); | |||
@@ -1 +1 @@ | |||
Subproject commit b0a018a006c5d7d7796074b86c1b69f8671d2d83 | |||
Subproject commit 9cab7cdcba159aec5f3df4d5841b83c12ef64185 |
@@ -25,7 +25,36 @@ | |||
#if defined(DISTRHO_OS_HAIKU) | |||
#elif defined(DISTRHO_OS_MAC) | |||
# import <Cocoa/Cocoa.h> | |||
# include <dlfcn.h> | |||
# include <mach/mach_time.h> | |||
# ifdef DGL_CAIRO | |||
# include <cairo.h> | |||
# include <cairo-quartz.h> | |||
# endif | |||
# ifdef DGL_OPENGL | |||
# include <OpenGL/gl.h> | |||
# endif | |||
# ifdef DGL_VULKAN | |||
# import <QuartzCore/CAMetalLayer.h> | |||
# include <vulkan/vulkan_core.h> | |||
# include <vulkan/vulkan_macos.h> | |||
# endif | |||
#elif defined(DISTRHO_OS_WINDOWS) | |||
# include <wctype.h> | |||
# include <windows.h> | |||
# include <windowsx.h> | |||
# ifdef DGL_CAIRO | |||
# include <cairo.h> | |||
# include <cairo-win32.h> | |||
# endif | |||
# ifdef DGL_OPENGL | |||
# include <GL/gl.h> | |||
# endif | |||
# ifdef DGL_VULKAN | |||
# include <vulkan/vulkan.h> | |||
# include <vulkan/vulkan_win32.h> | |||
# endif | |||
#else | |||
# include <dlfcn.h> | |||
# include <sys/select.h> | |||
@@ -51,6 +80,7 @@ | |||
# include <cairo-xlib.h> | |||
# endif | |||
# ifdef DGL_OPENGL | |||
# include <GL/gl.h> | |||
# include <GL/glx.h> | |||
# endif | |||
# ifdef DGL_VULKAN | |||
@@ -67,9 +97,33 @@ START_NAMESPACE_DGL | |||
#if defined(DISTRHO_OS_HAIKU) | |||
#elif defined(DISTRHO_OS_MAC) | |||
/* | |||
# define PuglWindow DISTRHO_JOIN_MACRO(PuglWindow, DGL_NAMESPACE) | |||
# define PuglOpenGLView DISTRHO_JOIN_MACRO(PuglOpenGLView, DGL_NAMESPACE) | |||
*/ | |||
# import "pugl-upstream/src/mac.m" | |||
# import "pugl-upstream/src/mac_stub.m" | |||
# ifdef DGL_CAIRO | |||
# import "pugl-upstream/src/mac_cairo.m" | |||
# endif | |||
# ifdef DGL_OPENGL | |||
# import "pugl-upstream/src/mac_gl.m" | |||
# endif | |||
# ifdef DGL_VULKAN | |||
# import "pugl-upstream/src/mac_vulkan.m" | |||
# endif | |||
#elif defined(DISTRHO_OS_WINDOWS) | |||
# include "pugl-upstream/src/win.c" | |||
# include "pugl-upstream/src/win_stub.c" | |||
# ifdef DGL_CAIRO | |||
# include "pugl-upstream/src/win_cairo.c" | |||
# endif | |||
# ifdef DGL_OPENGL | |||
# include "pugl-upstream/src/win_gl.c" | |||
# endif | |||
# ifdef DGL_VULKAN | |||
# include "pugl-upstream/src/win_vulkan.c" | |||
# endif | |||
#else | |||
# include "pugl-upstream/src/x11.c" | |||
# include "pugl-upstream/src/x11_stub.c" | |||
@@ -120,7 +174,7 @@ void puglRaiseWindow(PuglView* view) | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// set backend that matches current build | |||
void puglSetMatchingBackendForCurrentBuild(PuglView* view) | |||
void puglSetMatchingBackendForCurrentBuild(PuglView* const view) | |||
{ | |||
#ifdef DGL_CAIRO | |||
puglSetBackend(view, puglCairoBackend()); | |||
@@ -136,7 +190,7 @@ void puglSetMatchingBackendForCurrentBuild(PuglView* view) | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// Combine puglSetMinSize and puglSetAspectRatio | |||
PuglStatus puglSetGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect) | |||
PuglStatus puglSetGeometryConstraints(PuglView* const view, const uint width, const uint height, const bool aspect) | |||
{ | |||
view->minWidth = width; | |||
view->minHeight = height; | |||
@@ -170,16 +224,18 @@ PuglStatus puglSetGeometryConstraints(PuglView* view, unsigned int width, unsign | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// set window size without changing frame x/y position | |||
PuglStatus puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height) | |||
PuglStatus puglSetWindowSize(PuglView* const view, const uint width, const uint height) | |||
{ | |||
#if defined(DISTRHO_OS_HAIKU) || defined(DISTRHO_OS_MAC) | |||
// TODO | |||
const PuglRect frame = { 0.0, 0.0, (double)width, (double)height }; | |||
// keep upstream behaviour | |||
const PuglRect frame = { view->frame.x, view->frame.y, (double)width, (double)height }; | |||
return puglSetFrame(view, frame); | |||
#elif defined(DISTRHO_OS_WINDOWS) | |||
// matches upstream pugl, except we add SWP_NOMOVE flag | |||
if (view->impl->hwnd) | |||
{ | |||
const PuglRect frame = view->frame; | |||
RECT rect = { (long)frame.x, | |||
(long)frame.y, | |||
(long)frame.x + (long)frame.width, | |||
@@ -202,23 +258,6 @@ PuglStatus puglSetWindowSize(PuglView* view, unsigned int width, unsigned int he | |||
{ | |||
if (! XResizeWindow(view->world->impl->display, view->impl->win, width, height)) | |||
return PUGL_UNKNOWN_ERROR; | |||
#if 0 | |||
if (! fResizable) | |||
{ | |||
XSizeHints sizeHints; | |||
memset(&sizeHints, 0, sizeof(sizeHints)); | |||
sizeHints.flags = PSize|PMinSize|PMaxSize; | |||
sizeHints.width = static_cast<int>(width); | |||
sizeHints.height = static_cast<int>(height); | |||
sizeHints.min_width = static_cast<int>(width); | |||
sizeHints.min_height = static_cast<int>(height); | |||
sizeHints.max_width = static_cast<int>(width); | |||
sizeHints.max_height = static_cast<int>(height); | |||
XSetWMNormalHints(xDisplay, xWindow, &sizeHints); | |||
} | |||
#endif | |||
} | |||
#endif | |||
@@ -241,7 +280,7 @@ void puglOnDisplayPrepare(PuglView*) | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// DGL specific, build-specific fallback resize | |||
void puglFallbackOnResize(PuglView* view) | |||
void puglFallbackOnResize(PuglView* const view) | |||
{ | |||
#ifdef DGL_OPENGL | |||
glEnable(GL_BLEND); | |||
@@ -255,6 +294,60 @@ void puglFallbackOnResize(PuglView* view) | |||
#endif | |||
} | |||
#ifdef DISTRHO_OS_WINDOWS | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// win32 specific, call ShowWindow with SW_RESTORE | |||
void puglWin32RestoreWindow(PuglView* const view) | |||
{ | |||
PuglInternals* impl = view->impl; | |||
DISTRHO_SAFE_ASSERT_RETURN(impl->hwnd != nullptr,); | |||
ShowWindow(impl->hwnd, SW_RESTORE); | |||
SetFocus(impl->hwnd); | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// win32 specific, center view based on parent coordinates (if there is one) | |||
void puglWin32ShowWindowCentered(PuglView* const view) | |||
{ | |||
PuglInternals* impl = view->impl; | |||
DISTRHO_SAFE_ASSERT_RETURN(impl->hwnd != nullptr,); | |||
RECT rectChild, rectParent; | |||
if (view->transientParent != 0 && | |||
GetWindowRect(impl->hwnd, &rectChild) && | |||
GetWindowRect((HWND)view->transientParent, &rectParent)) | |||
{ | |||
SetWindowPos(impl->hwnd, (HWND)view->transientParent, | |||
rectParent.left + (rectChild.right-rectChild.left)/2, | |||
rectParent.top + (rectChild.bottom-rectChild.top)/2, | |||
0, 0, SWP_SHOWWINDOW|SWP_NOSIZE); | |||
} | |||
else | |||
{ | |||
ShowWindow(impl->hwnd, SW_SHOWNORMAL); | |||
} | |||
SetFocus(impl->hwnd); | |||
} | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
// win32 specific, set or unset WS_SIZEBOX style flag | |||
void puglWin32SetWindowResizable(PuglView* const view, const bool resizable) | |||
{ | |||
PuglInternals* impl = view->impl; | |||
DISTRHO_SAFE_ASSERT_RETURN(impl->hwnd != nullptr,); | |||
const int winFlags = resizable ? GetWindowLong(impl->hwnd, GWL_STYLE) | WS_SIZEBOX | |||
: GetWindowLong(impl->hwnd, GWL_STYLE) & ~WS_SIZEBOX; | |||
SetWindowLong(impl->hwnd, GWL_STYLE, winFlags); | |||
} | |||
#endif | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
END_NAMESPACE_DGL |
@@ -28,6 +28,7 @@ START_NAMESPACE_DGL | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
#define PUGL_API | |||
#define PUGL_DISABLE_DEPRECATED | |||
#include "pugl-upstream/include/pugl/pugl.h" | |||
@@ -65,6 +66,20 @@ puglOnDisplayPrepare(PuglView* view); | |||
PUGL_API void | |||
puglFallbackOnResize(PuglView* view); | |||
#ifdef DISTRHO_OS_WINDOWS | |||
// win32 specific, call ShowWindow with SW_RESTORE | |||
PUGL_API void | |||
puglWin32RestoreWindow(PuglView* view); | |||
// win32 specific, center view based on parent coordinates (if there is one) | |||
PUGL_API void | |||
puglWin32ShowWindowCentered(PuglView* view); | |||
// win32 specific, set or unset WS_SIZEBOX style flag | |||
PUGL_API void | |||
puglWin32SetWindowResizable(PuglView* view, bool resizable); | |||
#endif | |||
PUGL_END_DECLS | |||
// -------------------------------------------------------------------------------------------------------------------- | |||
@@ -16,7 +16,7 @@ BUILD_CXX_FLAGS += $(DGL_FLAGS) -I.. -I../dgl/src/pugl-upstream/include -DDONT_S | |||
LINK_FLAGS += -lpthread | |||
# TODO fix within pugl | |||
BUILD_CXX_FLAGS += -Wno-missing-field-initializers -Wno-extra | |||
BUILD_CXX_FLAGS += -Wno-extra -Wno-missing-field-initializers | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
@@ -33,8 +33,8 @@ ifeq ($(HAVE_VULKAN),true) | |||
WTESTS = Window.vulkan | |||
endif | |||
TARGETS = $(TESTS:%=../build/tests/%) | |||
TARGETS += $(WTESTS:Window.%=../build/tests/Window.%) | |||
TARGETS = $(TESTS:%=../build/tests/%$(APP_EXT)) | |||
TARGETS += $(WTESTS:Window.%=../build/tests/Window.%$(APP_EXT)) | |||
OBJS = $(TESTS:%=../build/tests/%.cpp.o) | |||
OBJS += $(WTESTS:Window.%=../build/tests/Window.cpp.%.o) | |||
@@ -102,31 +102,31 @@ clean: | |||
# --------------------------------------------------------------------------------------------------------------------- | |||
# linking steps | |||
../build/tests/%: ../build/tests/%.cpp.o | |||
../build/tests/%$(APP_EXT): ../build/tests/%.cpp.o | |||
@echo "Linking $*" | |||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) -o $@ | |||
../build/tests/%.cairo: ../build/tests/%.cpp.cairo.o | |||
../build/tests/%.cairo$(APP_EXT): ../build/tests/%.cpp.cairo.o | |||
@echo "Linking $*" | |||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | |||
../build/tests/%.opengl: ../build/tests/%.cpp.opengl.o | |||
../build/tests/%.opengl$(APP_EXT): ../build/tests/%.cpp.opengl.o | |||
@echo "Linking $*" | |||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | |||
../build/tests/%.vulkan: ../build/tests/%.cpp.vulkan.o | |||
../build/tests/%.vulkan$(APP_EXT): ../build/tests/%.cpp.vulkan.o | |||
@echo "Linking $*" | |||
$(SILENT)$(CXX) $< $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | |||
../build/tests/Demo.cairo: ../build/tests/Demo.cpp.cairo.o ../build/libdgl-cairo.a | |||
../build/tests/Demo.cairo$(APP_EXT): ../build/tests/Demo.cpp.cairo.o ../build/libdgl-cairo.a | |||
@echo "Linking Demo (Cairo)" | |||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(CAIRO_LIBS) -o $@ | |||
../build/tests/Demo.opengl: ../build/tests/Demo.cpp.opengl.o ../build/libdgl-opengl.a | |||
../build/tests/Demo.opengl$(APP_EXT): ../build/tests/Demo.cpp.opengl.o ../build/libdgl-opengl.a | |||
@echo "Linking Demo (OpenGL)" | |||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(OPENGL_LIBS) -o $@ | |||
../build/tests/Demo.vulkan: ../build/tests/Demo.cpp.vulkan.o ../build/libdgl-vulkan.a | |||
../build/tests/Demo.vulkan$(APP_EXT): ../build/tests/Demo.cpp.vulkan.o ../build/libdgl-vulkan.a | |||
@echo "Linking Demo (OpenGL)" | |||
$(SILENT)$(CXX) $^ $(LINK_FLAGS) $(DGL_SYSTEM_LIBS) $(VULKAN_LIBS) -o $@ | |||