Browse Source

Reorder some code and add stubs for HaikuOS support

Signed-off-by: falkTX <falktx@falktx.com>
pull/178/head
falkTX 3 years ago
parent
commit
14b4536aad
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
10 changed files with 271 additions and 98 deletions
  1. +14
    -5
      Makefile.base.mk
  2. +111
    -82
      dgl/src/Window.cpp
  3. +123
    -0
      dgl/src/pugl/pugl_haiku.cpp
  4. +1
    -1
      examples/CairoUI/Makefile
  5. +2
    -0
      examples/ExternalUI/Makefile
  6. +1
    -1
      examples/Latency/Makefile
  7. +1
    -1
      examples/Meters/Makefile
  8. +1
    -1
      examples/Parameters/Makefile
  9. +1
    -1
      examples/States/Makefile
  10. +16
    -6
      utils/lv2-ttl-generator/GNUmakefile

+ 14
- 5
Makefile.base.mk View File

@@ -208,18 +208,22 @@ HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
# ---------------------------------------------------------------------------------------------------------------------
# Set Generic DGL stuff

ifeq ($(HAIKU),true)
DGL_SYSTEM_LIBS += -lbe
endif

ifeq ($(MACOS),true)
DGL_SYSTEM_LIBS += -framework Cocoa
DGL_SYSTEM_LIBS += -framework Cocoa
endif

ifeq ($(WINDOWS),true)
DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
endif

ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_X11),true)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11)
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11)
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
endif
endif

@@ -244,6 +248,11 @@ ifeq ($(HAVE_OPENGL),true)

DGL_FLAGS += -DHAVE_OPENGL

ifeq ($(HAIKU),true)
OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl)
OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl)
endif

ifeq ($(MACOS),true)
OPENGL_LIBS = -framework OpenGL
endif
@@ -252,7 +261,7 @@ ifeq ($(WINDOWS),true)
OPENGL_LIBS = -lopengl32
endif

ifneq ($(MACOS_OR_WINDOWS),true)
ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
endif


+ 111
- 82
dgl/src/Window.cpp View File

@@ -37,14 +37,16 @@
# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif

#if defined(DISTRHO_OS_WINDOWS)
# include "pugl/pugl_win.cpp"
# undef max
# undef min
#if defined(DISTRHO_OS_HAIKU)
# include "pugl/pugl_haiku.cpp"
#elif defined(DISTRHO_OS_MAC)
# define PuglWindow DISTRHO_JOIN_MACRO(PuglWindow, DGL_NAMESPACE)
# define PuglOpenGLView DISTRHO_JOIN_MACRO(PuglOpenGLView, DGL_NAMESPACE)
# include "pugl/pugl_osx.m"
#elif defined(DISTRHO_OS_WINDOWS)
# include "pugl/pugl_win.cpp"
# undef max
# undef min
#else
# include <sys/types.h>
# include <unistd.h>
@@ -99,14 +101,16 @@ struct Window::PrivateData {
fTitle(nullptr),
fWidgets(),
fModal(),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#if defined(DISTRHO_OS_HAIKU)
bWindow(nullptr)
#elif defined(DISTRHO_OS_MAC)
fNeedsIdle(true),
mView(nullptr),
mWindow(nullptr),
mParentWindow(nullptr)
#elif defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
# ifndef DGL_FILE_BROWSER_DISABLED
, fOpenFilePanel(nullptr),
fFilePanelDelegate(nullptr)
@@ -135,14 +139,16 @@ struct Window::PrivateData {
fTitle(nullptr),
fWidgets(),
fModal(parent.pData),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#if defined(DISTRHO_OS_HAIKU)
bWindow(nullptr)
#elif defined(DISTRHO_OS_MAC)
fNeedsIdle(false),
mView(nullptr),
mWindow(nullptr),
mParentWindow(nullptr)
#elif defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
# ifndef DGL_FILE_BROWSER_DISABLED
, fOpenFilePanel(nullptr),
fFilePanelDelegate(nullptr)
@@ -158,11 +164,13 @@ struct Window::PrivateData {
const PuglInternals* const parentImpl(parent.pData->fView->impl);

// NOTE: almost a 1:1 copy of setTransientWinId()
#if defined(DISTRHO_OS_WINDOWS)
hwndParent = parentImpl->hwnd;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)hwndParent);
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC)
mParentWindow = parentImpl->window;
#elif defined(DISTRHO_OS_WINDOWS)
hwndParent = parentImpl->hwnd;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)hwndParent);
#else
XSetTransientForHint(xDisplay, xWindow, parentImpl->win);
#endif
@@ -183,14 +191,16 @@ struct Window::PrivateData {
fTitle(nullptr),
fWidgets(),
fModal(),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#if defined(DISTRHO_OS_HAIKU)
bWindow(nullptr)
#elif defined(DISTRHO_OS_MAC)
fNeedsIdle(parentId == 0),
mView(nullptr),
mWindow(nullptr),
mParentWindow(nullptr)
#elif defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
# ifndef DGL_FILE_BROWSER_DISABLED
, fOpenFilePanel(nullptr),
fFilePanelDelegate(nullptr)
@@ -249,9 +259,8 @@ struct Window::PrivateData {

PuglInternals* impl = fView->impl;

#if defined(DISTRHO_OS_WINDOWS)
hwnd = impl->hwnd;
DISTRHO_SAFE_ASSERT(hwnd != 0);
#if defined(DISTRHO_OS_HAIKU)
bWindow = impl->window;
#elif defined(DISTRHO_OS_MAC)
mView = impl->view;
mWindow = impl->window;
@@ -261,6 +270,9 @@ struct Window::PrivateData {
} else {
DISTRHO_SAFE_ASSERT(mWindow != nullptr);
}
#elif defined(DISTRHO_OS_WINDOWS)
hwnd = impl->hwnd;
DISTRHO_SAFE_ASSERT(hwnd != 0);
#else
xDisplay = impl->display;
xWindow = impl->win;
@@ -327,11 +339,12 @@ struct Window::PrivateData {
fTitle = nullptr;
}

#if defined(DISTRHO_OS_WINDOWS)
hwnd = 0;
#if defined(DISTRHO_OS_HAIKU)
#elif defined(DISTRHO_OS_MAC)
mView = nullptr;
mWindow = nullptr;
#elif defined(DISTRHO_OS_WINDOWS)
hwnd = 0;
#else
xDisplay = nullptr;
xWindow = 0;
@@ -419,10 +432,12 @@ struct Window::PrivateData {

// the mouse position probably changed since the modal appeared,
// so send a mouse motion event to the modal's parent window
#if defined(DISTRHO_OS_WINDOWS)
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC)
// TODO
#elif defined(DISTRHO_OS_WINDOWS)
// TODO
#else
int i, wx, wy;
uint u;
@@ -440,13 +455,14 @@ struct Window::PrivateData {
void focus()
{
DBG("Window focus\n");
#if defined(DISTRHO_OS_WINDOWS)
SetForegroundWindow(hwnd);
SetActiveWindow(hwnd);
SetFocus(hwnd);
#if defined(DISTRHO_OS_HAIKU)
#elif defined(DISTRHO_OS_MAC)
if (mWindow != nullptr)
[mWindow makeKeyWindow];
#elif defined(DISTRHO_OS_WINDOWS)
SetForegroundWindow(hwnd);
SetActiveWindow(hwnd);
SetFocus(hwnd);
#else
XRaiseWindow(xDisplay, xWindow);
XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime);
@@ -476,7 +492,39 @@ struct Window::PrivateData {
if (yesNo && fFirstInit)
setSize(fWidth, fHeight, true);

#if defined(DISTRHO_OS_WINDOWS)
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC)
if (yesNo)
{
if (mWindow != nullptr)
{
if (mParentWindow != nullptr)
[mParentWindow addChildWindow:mWindow
ordered:NSWindowAbove];

[mWindow setIsVisible:YES];
}
else
{
[mView setHidden:NO];
}
}
else
{
if (mWindow != nullptr)
{
if (mParentWindow != nullptr)
[mParentWindow removeChildWindow:mWindow];

[mWindow setIsVisible:NO];
}
else
{
[mView setHidden:YES];
}
}
#elif defined(DISTRHO_OS_WINDOWS)
if (yesNo)
{
if (fFirstInit)
@@ -508,36 +556,6 @@ struct Window::PrivateData {
}

UpdateWindow(hwnd);
#elif defined(DISTRHO_OS_MAC)
if (yesNo)
{
if (mWindow != nullptr)
{
if (mParentWindow != nullptr)
[mParentWindow addChildWindow:mWindow
ordered:NSWindowAbove];

[mWindow setIsVisible:YES];
}
else
{
[mView setHidden:NO];
}
}
else
{
if (mWindow != nullptr)
{
if (mParentWindow != nullptr)
[mParentWindow removeChildWindow:mWindow];

[mWindow setIsVisible:NO];
}
else
{
[mView setHidden:YES];
}
}
#else
if (yesNo)
XMapRaised(xDisplay, xWindow);
@@ -579,13 +597,15 @@ struct Window::PrivateData {
fResizable = yesNo;
fView->user_resizable = yesNo;

#if defined(DISTRHO_OS_WINDOWS)
const int winFlags = fResizable ? GetWindowLong(hwnd, GWL_STYLE) | WS_SIZEBOX
: GetWindowLong(hwnd, GWL_STYLE) & ~WS_SIZEBOX;
SetWindowLong(hwnd, GWL_STYLE, winFlags);
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC)
const uint flags(yesNo ? (NSViewWidthSizable|NSViewHeightSizable) : 0x0);
[mView setAutoresizingMask:flags];
#elif defined(DISTRHO_OS_WINDOWS)
const int winFlags = fResizable ? GetWindowLong(hwnd, GWL_STYLE) | WS_SIZEBOX
: GetWindowLong(hwnd, GWL_STYLE) & ~WS_SIZEBOX;
SetWindowLong(hwnd, GWL_STYLE, winFlags);
#endif

setSize(fWidth, fHeight, true);
@@ -624,16 +644,8 @@ struct Window::PrivateData {

DBGp("Window setSize called %s, size %i %i, resizable %s\n", forced ? "(forced)" : "(not forced)", width, height, fResizable?"true":"false");

#if defined(DISTRHO_OS_WINDOWS)
const int winFlags = WS_POPUPWINDOW | WS_CAPTION | (fResizable ? WS_SIZEBOX : 0x0);
RECT wr = { 0, 0, static_cast<LONG>(width), static_cast<LONG>(height) };
AdjustWindowRectEx(&wr, fUsingEmbed ? WS_CHILD : winFlags, FALSE, WS_EX_TOPMOST);

SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top,
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);

if (! forced)
UpdateWindow(hwnd);
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC)
[mView setFrame:NSMakeRect(0, 0, width, height)];

@@ -655,6 +667,16 @@ struct Window::PrivateData {
[[mWindow standardWindowButton:NSWindowZoomButton] setHidden:YES];
}
}
#elif defined(DISTRHO_OS_WINDOWS)
const int winFlags = WS_POPUPWINDOW | WS_CAPTION | (fResizable ? WS_SIZEBOX : 0x0);
RECT wr = { 0, 0, static_cast<LONG>(width), static_cast<LONG>(height) };
AdjustWindowRectEx(&wr, fUsingEmbed ? WS_CHILD : winFlags, FALSE, WS_EX_TOPMOST);

SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top,
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);

if (! forced)
UpdateWindow(hwnd);
#else

if (! fResizable)
@@ -700,8 +722,9 @@ struct Window::PrivateData {

fTitle = strdup(title);

#if defined(DISTRHO_OS_WINDOWS)
SetWindowTextA(hwnd, title);
#if defined(DISTRHO_OS_HAIKU)
if (bWindow != nullptr)
bWindow->SetTitle(title);
#elif defined(DISTRHO_OS_MAC)
if (mWindow != nullptr)
{
@@ -712,6 +735,8 @@ struct Window::PrivateData {

[mWindow setTitle:titleString];
}
#elif defined(DISTRHO_OS_WINDOWS)
SetWindowTextA(hwnd, title);
#else
XStoreName(xDisplay, xWindow, title);
Atom netWmName = XInternAtom(xDisplay, "_NET_WM_NAME", False);
@@ -724,15 +749,17 @@ struct Window::PrivateData {
{
DISTRHO_SAFE_ASSERT_RETURN(winId != 0,);

#if defined(DISTRHO_OS_WINDOWS)
hwndParent = (HWND)winId;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)winId);
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC)
NSWindow* const parentWindow = [NSApp windowWithWindowNumber:winId];
DISTRHO_SAFE_ASSERT_RETURN(parentWindow != nullptr,);

[parentWindow addChildWindow:mWindow
ordered:NSWindowAbove];
#elif defined(DISTRHO_OS_WINDOWS)
hwndParent = (HWND)winId;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)winId);
#else
XSetTransientForHint(xDisplay, xWindow, static_cast< ::Window>(winId));
#endif
@@ -1164,12 +1191,8 @@ struct Window::PrivateData {
DISTRHO_DECLARE_NON_COPY_STRUCT(Modal)
} fModal;

#if defined(DISTRHO_OS_WINDOWS)
HWND hwnd;
HWND hwndParent;
# ifndef DGL_FILE_BROWSER_DISABLED
String fSelectedFile;
# endif
#if defined(DISTRHO_OS_HAIKU)
BWindow* bWindow;
#elif defined(DISTRHO_OS_MAC)
bool fNeedsIdle;
NSView<PuglGenericView>* mView;
@@ -1179,6 +1202,12 @@ struct Window::PrivateData {
NSOpenPanel* fOpenFilePanel;
id fFilePanelDelegate;
# endif
#elif defined(DISTRHO_OS_WINDOWS)
HWND hwnd;
HWND hwndParent;
# ifndef DGL_FILE_BROWSER_DISABLED
String fSelectedFile;
# endif
#else
Display* xDisplay;
::Window xWindow;


+ 123
- 0
dgl/src/pugl/pugl_haiku.cpp View File

@@ -0,0 +1,123 @@
/*
Copyright 2019 Filipe Coelho <falktx@falktx.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
@file pugl_haiku.cpp BeOS/HaikuOS Pugl Implementation.
*/
#include <interface/Window.h>
#ifdef PUGL_CAIRO
#include <cairo/cairo.h>
#endif
#ifdef PUGL_OPENGL
#include <GL/gl.h>
#endif
#include "pugl_internal.h"
struct PuglInternalsImpl {
BWindow* window;
};
PuglInternals*
puglInitInternals()
{
return (PuglInternals*)calloc(1, sizeof(PuglInternals));
}
void
puglEnterContext(PuglView* view)
{
}
void
puglLeaveContext(PuglView* view, bool flush)
{
}
class DWindow : public BWindow
{
public:
DWindow(PuglInternals* const i)
: BWindow(BRect(), "", B_TITLED_WINDOW, 0x0),
impl(i)
{
}
private:
PuglInternals* const impl;
};
int
puglCreateWindow(PuglView* view, const char* title)
{
PuglInternals* impl = view->impl;
impl->window = new DWindow(impl);
return 0;
}
void
puglShowWindow(PuglView* view)
{
}
void
puglHideWindow(PuglView* view)
{
}
void
puglDestroy(PuglView* view)
{
}
PuglStatus
puglProcessEvents(PuglView* view)
{
return PUGL_SUCCESS;
}
void
puglPostRedisplay(PuglView* view)
{
view->redisplay = true;
}
PuglNativeWindow
puglGetNativeWindow(PuglView* view)
{
return NULL;
}
void*
puglGetContext(PuglView* view)
{
return NULL;
}
int
puglUpdateGeometryConstraints(PuglView* view, int min_width, int min_height, bool aspect)
{
// TODO
return 1;
(void)view;
(void)min_width;
(void)min_height;
(void)aspect;
}

+ 1
- 1
examples/CairoUI/Makefile View File

@@ -35,7 +35,7 @@ TARGETS += jack
endif
endif

ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_CAIRO),true)
ifeq ($(HAVE_LIBLO),true)
TARGETS += dssi


+ 2
- 0
examples/ExternalUI/Makefile View File

@@ -23,7 +23,9 @@ FILES_UI = \

include ../../Makefile.plugins.mk

ifneq ($(HAIKU),true)
LINK_FLAGS += -ldl
endif

# --------------------------------------------------------------
# Enable all possible plugin types


+ 1
- 1
examples/Latency/Makefile View File

@@ -23,7 +23,7 @@ include ../../Makefile.plugins.mk
# --------------------------------------------------------------
# Enable all possible plugin types

ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
TARGETS += ladspa
TARGETS += dssi
endif


+ 1
- 1
examples/Meters/Makefile View File

@@ -32,7 +32,7 @@ TARGETS += jack
endif
endif

ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += dssi


+ 1
- 1
examples/Parameters/Makefile View File

@@ -32,7 +32,7 @@ TARGETS += jack
endif
endif

ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += ladspa


+ 1
- 1
examples/States/Makefile View File

@@ -32,7 +32,7 @@ TARGETS += jack
endif
endif

ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += dssi


+ 16
- 6
utils/lv2-ttl-generator/GNUmakefile View File

@@ -1,19 +1,29 @@
#!/usr/bin/makefile -f

include ../../Makefile.base.mk

all: build

ifeq ($(WINDOWS),true)
build: ../lv2_ttl_generator.exe
else
build: ../lv2_ttl_generator
endif

../lv2_ttl_generator: lv2_ttl_generator.c
$(CC) $< $(CFLAGS) -o $@ $(LDFLAGS) -ldl
build: ../lv2_ttl_generator.exe

../lv2_ttl_generator.exe: lv2_ttl_generator.c
$(CC) $< $(CFLAGS) -o $@ $(LDFLAGS) -static
touch ../lv2_ttl_generator

else # WINDOWS

ifneq ($(HAIKU),true)
LDFLAGS += -ldl
endif

build: ../lv2_ttl_generator

../lv2_ttl_generator: lv2_ttl_generator.c
$(CC) $< $(CFLAGS) -o $@ $(LDFLAGS)

endif # WINDOWS

clean:
rm -f ../lv2_ttl_generator ../lv2_ttl_generator.exe

Loading…
Cancel
Save