Browse Source

Misc fixing to DGL Window class, other experiments

gh-pages
falkTX 11 years ago
parent
commit
3292468711
4 changed files with 64 additions and 37 deletions
  1. +56
    -33
      dgl/src/Window.cpp
  2. +1
    -1
      dgl/src/pugl/pugl_osx_extended.h
  3. +6
    -2
      dgl/src/pugl/pugl_osx_extended.m
  4. +1
    -1
      distrho/src/DistrhoPluginVST.cpp

+ 56
- 33
dgl/src/Window.cpp View File

@@ -74,6 +74,7 @@ public:
fFirstInit(true), fFirstInit(true),
fVisible(false), fVisible(false),
fResizable(true), fResizable(true),
fUsingEmbed(false),
#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
hwnd(0) hwnd(0)
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
@@ -83,7 +84,7 @@ public:
_dummy('\0') _dummy('\0')
#endif #endif
{ {
DBG("Creating simple window without parent..."); DBGF;
DBG("Creating window without parent..."); DBGF;
init(); init();
} }


@@ -94,6 +95,7 @@ public:
fFirstInit(true), fFirstInit(true),
fVisible(false), fVisible(false),
fResizable(true), fResizable(true),
fUsingEmbed(false),
fModal(parent.pData), fModal(parent.pData),
#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
hwnd(0) hwnd(0)
@@ -108,10 +110,9 @@ public:
init(); init();


#if DGL_OS_LINUX #if DGL_OS_LINUX
PuglInternals* const parentImpl = parent.pData->fView->impl;
const PuglInternals* const parentImpl(parent.pData->fView->impl);


XSetTransientForHint(xDisplay, xWindow, parentImpl->win); XSetTransientForHint(xDisplay, xWindow, parentImpl->win);
XFlush(xDisplay);
#endif #endif
} }


@@ -122,6 +123,7 @@ public:
fFirstInit(true), fFirstInit(true),
fVisible(true), fVisible(true),
fResizable(false), fResizable(false),
fUsingEmbed(true),
#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
hwnd(0) hwnd(0)
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
@@ -131,10 +133,10 @@ public:
_dummy('\0') _dummy('\0')
#endif #endif
{ {
DBG("Creating window embedded with parent Id..."); DBGF;
DBG("Creating embedded window..."); DBGF;
init(); init();


DBG("Embed window always visible\n");
DBG("NOTE: Embed window is always visible and non-resizable\n");
fApp._oneShown(); fApp._oneShown();
fFirstInit = false; fFirstInit = false;
} }
@@ -186,12 +188,25 @@ public:
//fOnModal = false; //fOnModal = false;
fWidgets.clear(); fWidgets.clear();


if (fSelf != nullptr && fView != nullptr)
if (fSelf != nullptr)
{ {
fApp._removeWindow(fSelf); fApp._removeWindow(fSelf);
fSelf = nullptr;
}

if (fView != nullptr)
{
puglDestroy(fView); puglDestroy(fView);
fView = nullptr;
} }


#if DGL_OS_WINDOWS
hwnd = 0;
#elif DGL_OS_LINUX
xDisplay = nullptr;
xWindow = 0;
#endif

DBG("Success!\n"); DBG("Success!\n");
} }


@@ -216,7 +231,7 @@ public:


if (lockWait) if (lockWait)
{ {
while (fVisible && fModal.enabled)
for (; fVisible && fModal.enabled;)
{ {
// idle() // idle()
puglProcessEvents(fView); puglProcessEvents(fView);
@@ -270,7 +285,12 @@ public:
{ {
if (fVisible == yesNo) if (fVisible == yesNo)
{ {
DBG("Window setVisible ignored!\n");
DBG("Window setVisible matches current state, ignoring request\n");
return;
}
if (fUsingEmbed)
{
DBG("Window setVisible cannot be called when embedded\n");
return; return;
} }


@@ -283,16 +303,9 @@ public:


#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
if (yesNo) if (yesNo)
{
if (fFirstInit)
ShowWindow(hwnd, SW_SHOWNORMAL);
else
ShowWindow(hwnd, SW_RESTORE);
}
ShowWindow(hwnd, fFirstInit ? SW_SHOWNORMAL : SW_RESTORE);
else else
{
ShowWindow(hwnd, SW_HIDE); ShowWindow(hwnd, SW_HIDE);
}


UpdateWindow(hwnd); UpdateWindow(hwnd);
#elif DGL_OS_MAC #elif DGL_OS_MAC
@@ -329,7 +342,12 @@ public:
{ {
if (fResizable == yesNo) if (fResizable == yesNo)
{ {
DBG("Window setResizable ignored!\n");
DBG("Window setResizable matches current state, ignoring request\n");
return;
}
if (fUsingEmbed)
{
DBG("Window setResizable cannot be called when embedded\n");
return; return;
} }


@@ -359,21 +377,22 @@ public:


void setSize(unsigned int width, unsigned int height, const bool forced = false) void setSize(unsigned int width, unsigned int height, const bool forced = false)
{ {
if (width == 0)
width = 1;
if (height == 0)
height = 1;
if (width == 0 || height == 0)
{
DBGp("Window setSize called with invalid value(s) %i %i, ignoring request\n", width, height);
return;
}


if (fView->width == (int)width && fView->height == (int)height && ! forced)
if (fView->width == static_cast<int>(width) && fView->height == static_cast<int>(height) && ! forced)
{ {
DBG("Window setSize ignored!\n");
DBG("Window setSize matches current size, ignoring request\n");
return; return;
} }


fView->width = width; fView->width = width;
fView->height = height; fView->height = height;


DBG("Window setSize called\n");
DBGp("Window setSize called %s\n", forced ? "(forced)" : "(not forced)");


#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
int winFlags = WS_POPUPWINDOW | WS_CAPTION; int winFlags = WS_POPUPWINDOW | WS_CAPTION;
@@ -381,13 +400,15 @@ public:
if (fResizable) if (fResizable)
winFlags |= WS_SIZEBOX; winFlags |= WS_SIZEBOX;


RECT wr = { 0, 0, (long)width, (long)height };
RECT wr = { 0, 0, static_cast<long>(width), static_cast<long>(height) };
AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST); AdjustWindowRectEx(&wr, 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); SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
UpdateWindow(hwnd);

if (! forced)
UpdateWindow(hwnd);
#elif DGL_OS_MAC #elif DGL_OS_MAC
puglImplSetSize(fView, width, height);
puglImplSetSize(fView, width, height, forced);
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
XResizeWindow(xDisplay, xWindow, width, height); XResizeWindow(xDisplay, xWindow, width, height);


@@ -405,7 +426,8 @@ public:
XSetNormalHints(xDisplay, xWindow, &sizeHints); XSetNormalHints(xDisplay, xWindow, &sizeHints);
} }


XFlush(xDisplay);
if (! forced)
XFlush(xDisplay);
#endif #endif


repaint(); repaint();
@@ -415,14 +437,14 @@ public:


void setTitle(const char* const title) void setTitle(const char* const title)
{ {
DBG("Window setTitle\n");
DBGp("Window setTitle \"%s\"\n", title);

#if DGL_OS_WINDOWS #if DGL_OS_WINDOWS
SetWindowTextA(hwnd, title); SetWindowTextA(hwnd, title);
#elif DGL_OS_MAC #elif DGL_OS_MAC
puglImplSetTitle(fView, title); puglImplSetTitle(fView, title);
#elif DGL_OS_LINUX #elif DGL_OS_LINUX
XStoreName(xDisplay, xWindow, title); XStoreName(xDisplay, xWindow, title);
XFlush(xDisplay);
#endif #endif
} }


@@ -645,13 +667,14 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------


private: private:
App& fApp;
Window* const fSelf;
PuglView* const fView;
App& fApp;
Window* fSelf;
PuglView* fView;


bool fFirstInit; bool fFirstInit;
bool fVisible; bool fVisible;
bool fResizable; bool fResizable;
bool fUsingEmbed;
std::list<Widget*> fWidgets; std::list<Widget*> fWidgets;


struct Modal { struct Modal {


+ 1
- 1
dgl/src/pugl/pugl_osx_extended.h View File

@@ -28,7 +28,7 @@ extern "C" {
#endif #endif


void puglImplFocus(PuglView* view); void puglImplFocus(PuglView* view);
void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height);
void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height, bool forced);
void puglImplSetTitle(PuglView* view, const char* title); void puglImplSetTitle(PuglView* view, const char* title);
void puglImplSetVisible(PuglView* view, bool yesNo); void puglImplSetVisible(PuglView* view, bool yesNo);




+ 6
- 2
dgl/src/pugl/pugl_osx_extended.m View File

@@ -32,7 +32,7 @@ void puglImplFocus(PuglView* view)
[window makeKeyAndOrderFront:window]; [window makeKeyAndOrderFront:window];
} }


void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height)
void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height, bool forced)
{ {
id window = view->impl->window; id window = view->impl->window;


@@ -41,7 +41,11 @@ void puglImplSetSize(PuglView* view, unsigned int width, unsigned int height)
frame.size.width = width; frame.size.width = width;
frame.size.height = height+20; frame.size.height = height+20;


[window setFrame:frame];
if (forced) {
[window setFrame:frame];
} else {
[window setFrame:frame display:YES animate:NO];
}
} }


void puglImplSetTitle(PuglView* view, const char* title) void puglImplSetTitle(PuglView* view, const char* title)


+ 1
- 1
distrho/src/DistrhoPluginVST.cpp View File

@@ -438,7 +438,7 @@ public:
case effEditOpen: case effEditOpen:
if (fVstUi == nullptr) if (fVstUi == nullptr)
{ {
# if defined(DISTRHO_OS_MAC) && ! defined(__LP64__)
# if DISTRHO_OS_MAC && ! defined(__LP64__)
if ((fEffect->dispatcher(fEffect, effCanDo, 0, 0, (void*)"hasCockosViewAsConfig", 0.0f) & 0xffff0000) != 0xbeef0000) if ((fEffect->dispatcher(fEffect, effCanDo, 0, 0, (void*)"hasCockosViewAsConfig", 0.0f) & 0xffff0000) != 0xbeef0000)
return 0; return 0;
# endif # endif


Loading…
Cancel
Save