Browse Source

pugl related changes

gh-pages
falkTX 11 years ago
parent
commit
0469b08e20
3 changed files with 32 additions and 48 deletions
  1. +23
    -25
      dgl/src/Window.cpp
  2. +6
    -4
      dgl/src/pugl/pugl_internal.h
  3. +3
    -19
      dgl/src/pugl/pugl_win.cpp

+ 23
- 25
dgl/src/Window.cpp View File

@@ -15,13 +15,12 @@
*/ */


// we need this for now // we need this for now
#define XKEYFOCUSGRAB 1
#define PUGL_GRAB_FOCUS 1


#include "AppPrivateData.hpp" #include "AppPrivateData.hpp"
#include "../Widget.hpp" #include "../Widget.hpp"
#include "../Window.hpp" #include "../Window.hpp"


#include <cassert>
#include <cstdio> #include <cstdio>
#include <list> #include <list>


@@ -30,12 +29,9 @@
#if defined(DISTRHO_OS_WINDOWS) #if defined(DISTRHO_OS_WINDOWS)
# include "pugl/pugl_win.cpp" # include "pugl/pugl_win.cpp"
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
# include "pugl/pugl_osx_extended.h"
extern "C" { extern "C" {
struct PuglViewImpl {
int width;
int height;
};}
# include "pugl/pugl_osx.m"
}
#elif defined(DISTRHO_OS_LINUX) #elif defined(DISTRHO_OS_LINUX)
# include <sys/types.h> # include <sys/types.h>
# include <unistd.h> # include <unistd.h>
@@ -69,12 +65,11 @@ Window* dgl_lastUiParent = nullptr;
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Window Private // Window Private


struct Window::PrivateData
{
struct Window::PrivateData {
PrivateData(App& app, Window* const self) PrivateData(App& app, Window* const self)
: fApp(app), : fApp(app),
fSelf(self), fSelf(self),
fView(puglCreate(0, "Window", 100, 100, true, false)),
fView(puglInit(nullptr, nullptr)),
fFirstInit(true), fFirstInit(true),
fVisible(false), fVisible(false),
fResizable(true), fResizable(true),
@@ -97,7 +92,7 @@ struct Window::PrivateData
PrivateData(App& app, Window* const self, Window& parent) PrivateData(App& app, Window* const self, Window& parent)
: fApp(app), : fApp(app),
fSelf(self), fSelf(self),
fView(puglCreate(0, "Window", 100, 100, true, false)),
fView(puglInit(nullptr, nullptr)),
fFirstInit(true), fFirstInit(true),
fVisible(false), fVisible(false),
fResizable(true), fResizable(true),
@@ -127,7 +122,7 @@ struct Window::PrivateData
PrivateData(App& app, Window* const self, const intptr_t parentId) PrivateData(App& app, Window* const self, const intptr_t parentId)
: fApp(app), : fApp(app),
fSelf(self), fSelf(self),
fView(puglCreate(parentId, "Window", 100, 100, (parentId == 0), (parentId != 0))),
fView(puglInit(nullptr, nullptr)),
fFirstInit(true), fFirstInit(true),
fVisible(parentId != 0), fVisible(parentId != 0),
fResizable(parentId == 0), fResizable(parentId == 0),
@@ -143,9 +138,13 @@ struct Window::PrivateData
_dummy('\0') _dummy('\0')
#endif #endif
{ {
if (parentId != 0) {
if (parentId != 0)
{
DBG("Creating embedded window..."); DBGF; DBG("Creating embedded window..."); DBGF;
} else {
puglInitWindowParent(fView, parentId);
}
else
{
DBG("Creating window without parent..."); DBGF; DBG("Creating window without parent..."); DBGF;
} }


@@ -154,6 +153,7 @@ struct Window::PrivateData
if (parentId != 0) if (parentId != 0)
{ {
DBG("NOTE: Embed window is always visible and non-resizable\n"); DBG("NOTE: Embed window is always visible and non-resizable\n");
puglShowWindow(fView);
fApp.pData->oneShown(); fApp.pData->oneShown();
fFirstInit = false; fFirstInit = false;
} }
@@ -170,6 +170,8 @@ struct Window::PrivateData


dgl_lastUiParent = fSelf; dgl_lastUiParent = fSelf;


puglInitResizable(fView, fResizable);

puglSetHandle(fView, this); puglSetHandle(fView, this);
puglSetDisplayFunc(fView, onDisplayCallback); puglSetDisplayFunc(fView, onDisplayCallback);
puglSetKeyboardFunc(fView, onKeyboardCallback); puglSetKeyboardFunc(fView, onKeyboardCallback);
@@ -180,15 +182,17 @@ struct Window::PrivateData
puglSetReshapeFunc(fView, onReshapeCallback); puglSetReshapeFunc(fView, onReshapeCallback);
puglSetCloseFunc(fView, onCloseCallback); puglSetCloseFunc(fView, onCloseCallback);


puglCreateWindow(fView, nullptr);

#if defined(DISTRHO_OS_WINDOWS) #if defined(DISTRHO_OS_WINDOWS)
PuglInternals* impl = fView->impl; PuglInternals* impl = fView->impl;
hwnd = impl->hwnd; hwnd = impl->hwnd;
assert(hwnd != 0);
DISTRHO_SAFE_ASSERT(hwnd != 0);
#elif defined(DISTRHO_OS_LINUX) #elif defined(DISTRHO_OS_LINUX)
PuglInternals* impl = fView->impl; PuglInternals* impl = fView->impl;
xDisplay = impl->display; xDisplay = impl->display;
xWindow = impl->win; xWindow = impl->win;
assert(xWindow != 0);
DISTRHO_SAFE_ASSERT(xWindow != 0);


if (! fUsingEmbed) if (! fUsingEmbed)
{ {
@@ -530,13 +534,7 @@ struct Window::PrivateData
void exec_init() void exec_init()
{ {
DBG("Window modal loop starting..."); DBGF; DBG("Window modal loop starting..."); DBGF;
assert(fModal.parent != nullptr);

if (fModal.parent == nullptr)
{
DBG("Failed, there's no modal parent!\n");
return setVisible(true);
}
DISTRHO_SAFE_ASSERT_RETURN(fModal.parent != nullptr, setVisible(true));


fModal.enabled = true; fModal.enabled = true;
fModal.parent->fModal.childFocus = this; fModal.parent->fModal.childFocus = this;
@@ -731,8 +729,8 @@ struct Window::PrivateData


~Modal() ~Modal()
{ {
assert(! enabled);
assert(childFocus == nullptr);
DISTRHO_SAFE_ASSERT(! enabled);
DISTRHO_SAFE_ASSERT(childFocus == nullptr);
} }
} fModal; } fModal;




+ 6
- 4
dgl/src/pugl/pugl_internal.h View File

@@ -42,9 +42,6 @@
typedef struct PuglInternalsImpl PuglInternals; typedef struct PuglInternalsImpl PuglInternals;


struct PuglViewImpl { struct PuglViewImpl {
int width;
int height;

PuglHandle handle; PuglHandle handle;
PuglCloseFunc closeFunc; PuglCloseFunc closeFunc;
PuglDisplayFunc displayFunc; PuglDisplayFunc displayFunc;
@@ -59,6 +56,8 @@ struct PuglViewImpl {


PuglNativeWindow parent; PuglNativeWindow parent;


int width;
int height;
int mods; int mods;
bool mouse_in_view; bool mouse_in_view;
bool ignoreKeyRepeat; bool ignoreKeyRepeat;
@@ -89,6 +88,9 @@ puglInit(int* pargc, char** argv)
view->height = 480; view->height = 480;


return view; return view;

// unused
(void)pargc; (void)argv;
} }


void void
@@ -107,7 +109,7 @@ puglInitWindowParent(PuglView* view, PuglNativeWindow parent)
void void
puglInitResizable(PuglView* view, bool resizable) puglInitResizable(PuglView* view, bool resizable)
{ {
view->resizable = true;
view->resizable = resizable;
} }


void void


+ 3
- 19
dgl/src/pugl/pugl_win.cpp View File

@@ -37,7 +37,7 @@
# define WHEEL_DELTA 120 # define WHEEL_DELTA 120
#endif #endif


const int LOCAL_CLOSE_MSG = WM_USER + 50;
#define PUGL_LOCAL_CLOSE_MSG (WM_USER + 50)


HINSTANCE hInstance = NULL; HINSTANCE hInstance = NULL;


@@ -60,22 +60,6 @@ DllMain(HINSTANCE hInst, DWORD, LPVOID)
} }
} // extern "C" } // extern "C"


PuglView*
puglInit()
{
PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
if (!view || !impl) {
return NULL;
}

view->impl = impl;
view->width = 640;
view->height = 480;

return view;
}

PuglView* PuglView*
puglCreateInternals(PuglNativeWindow parent, puglCreateInternals(PuglNativeWindow parent,
const char* title, const char* title,
@@ -343,7 +327,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
case WM_QUIT: case WM_QUIT:
case LOCAL_CLOSE_MSG:
case PUGL_LOCAL_CLOSE_MSG:
if (view->closeFunc) { if (view->closeFunc) {
view->closeFunc(view); view->closeFunc(view);
} }
@@ -386,7 +370,7 @@ wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
PostMessage(hwnd, WM_SHOWWINDOW, TRUE, 0); PostMessage(hwnd, WM_SHOWWINDOW, TRUE, 0);
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
PostMessage(hwnd, LOCAL_CLOSE_MSG, wParam, lParam);
PostMessage(hwnd, PUGL_LOCAL_CLOSE_MSG, wParam, lParam);
return 0; return 0;
case WM_DESTROY: case WM_DESTROY:
return 0; return 0;


Loading…
Cancel
Save