DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 066319187a8d9cd0fe48324a851cc46e4c1ad0da
parent b755b07abf79e4541cafda14fd6d9e4677669062
Author: falkTX <falktx@falktx.com>
Date:   Thu, 26 Aug 2021 15:58:31 +0100

Give focus to standalone uis on init; Fix macOS embed external ui

Diffstat:
Mdistrho/src/DistrhoUIInternal.hpp | 1+
Mexamples/EmbedExternalUI/EmbedExternalExampleUI.cpp | 42+++++++++++++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp @@ -197,6 +197,7 @@ public: DISTRHO_SAFE_ASSERT_RETURN(cb != nullptr,); uiData->window->show(); + uiData->window->focus(); uiData->app.addIdleCallback(cb); uiData->app.exec(); } diff --git a/examples/EmbedExternalUI/EmbedExternalExampleUI.cpp b/examples/EmbedExternalUI/EmbedExternalExampleUI.cpp @@ -31,19 +31,29 @@ #endif #if defined(DISTRHO_OS_MAC) +# ifndef __MAC_10_12 +# define NSEventMaskAny NSAnyEventMask +# define NSWindowStyleMaskClosable NSClosableWindowMask +# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask +# define NSWindowStyleMaskResizable NSResizableWindowMask +# define NSWindowStyleMaskTitled NSTitledWindowMask +# endif @interface NSExternalWindow : NSWindow @end -@implementation NSExternalWindow +@implementation NSExternalWindow { +@public + bool closed; +} - (id)initWithContentRect:(NSRect)contentRect - styleMask:(unsigned long)aStyle + styleMask:(ulong)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { + closed = false; NSWindow* result = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag]; - [result setAcceptsMouseMovedEvents:YES]; return (NSExternalWindow*)result; } - (BOOL)canBecomeKeyWindow @@ -54,6 +64,14 @@ { return NO; } +- (BOOL)windowShouldClose:(id)sender +{ + closed = true; + return YES; + + // unused + (void)sender; +} @end #endif @@ -112,14 +130,19 @@ public: } else { + const ulong styleMask = NSWindowStyleMaskClosable + | NSWindowStyleMaskMiniaturizable + | NSWindowStyleMaskResizable + | NSWindowStyleMaskTitled; + fWindow = [[[NSExternalWindow alloc] initWithContentRect:[fView frame] - styleMask:(NSWindowStyleMaskClosable | NSWindowStyleMaskTitled | NSWindowStyleMaskResizable) + styleMask:styleMask backing:NSBackingStoreBuffered defer:NO]retain]; DISTRHO_SAFE_ASSERT_RETURN(fWindow != nullptr,); - // [fWindow setIsVisible:NO]; + [fWindow setIsVisible:NO]; if (NSString* const nsTitle = [[NSString alloc] initWithBytes:getTitle() @@ -315,18 +338,23 @@ protected: for (NSEvent* event;;) { event = [NSApp - nextEventMatchingMask:NSAnyEventMask + nextEventMatchingMask:NSEventMaskAny untilDate:date inMode:NSDefaultRunLoopMode dequeue:YES]; if (event == nil) break; - d_stdout("uiIdle with event %p", event); [NSApp sendEvent:event]; } + if (fWindow->closed) + { + fWindow->closed = false; + close(); + } + [pool release]; #elif defined(DISTRHO_OS_WINDOWS) MSG msg;