From ba528d05346aa837e6e91950a3369727eb95b51c Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 7 Oct 2020 00:51:22 +1100 Subject: [PATCH] Debugging --- v2/internal/ffenestri/ffenestri_darwin.c | 46 ++++++++++++----------- v2/internal/ffenestri/ffenestri_darwin.go | 5 --- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/v2/internal/ffenestri/ffenestri_darwin.c b/v2/internal/ffenestri/ffenestri_darwin.c index 95c24d21..4b1c1b50 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.c +++ b/v2/internal/ffenestri/ffenestri_darwin.c @@ -263,6 +263,10 @@ void messageHandler(id self, SEL cmd, id contentController, id message) { } else if( strcmp(name, "windowDrag") == 0 ) { // Guard against null events if( app->mouseEvent != NULL ) { + id defaultCenter = msg(c("NSNotificationCenter"), s("defaultCenter")); + msg(defaultCenter, s("postNotificationName:object:"), + str("NSWindowWillMoveNotification"), + app->mainWindow); msg(app->mainWindow, s("performWindowDragWithEvent:"), app->mouseEvent); } } else { @@ -368,10 +372,10 @@ void DestroyApplication(void *appPointer) { } // For frameless apps, remove the event monitor and drag message handler - if( app->frame == 0 ) { + // if( app->frame == 0 ) { msg( c("NSEvent"), s("removeMonitor:"), app->eventMonitor); msg(app->manager, s("removeScriptMessageHandlerForName:"), str("windowDrag")); - } + // } msg(app->manager, s("removeScriptMessageHandlerForName:"), str("external")); msg(app->mainWindow, s("close")); @@ -903,36 +907,36 @@ void Run(struct Application *app, int argc, char **argv) { CGRect contentViewBounds = GET_BOUNDS(contentView); msg(wkwebview, s("setFrame:"), contentViewBounds ); + // Setup drag message handler + msg(manager, s("addScriptMessageHandler:name:"), app->delegate, str("windowDrag")); + // Add mouse event hooks + app->eventMonitor = msg(c("NSEvent"), u("addLocalMonitorForEventsMatchingMask:handler:"), NSEventMaskLeftMouseDown, ^(id incomingEvent) { + app->mouseEvent = incomingEvent; + return incomingEvent; + }); + if( app->frame == 0) { msg(app->mainWindow, s("setTitlebarAppearsTransparent:"), YES); msg(app->mainWindow, s("setTitleVisibility:"), NSWindowTitleHidden); - // Setup drag message handler - msg(manager, s("addScriptMessageHandler:name:"), app->delegate, str("windowDrag")); - // Add mouse event hooks - app->eventMonitor = msg(c("NSEvent"), u("addLocalMonitorForEventsMatchingMask:handler:"), NSEventMaskLeftMouseDown, ^(id incomingEvent) { - app->mouseEvent = incomingEvent; - return incomingEvent; - }); } else { - Debug("setTitlebarAppearsTransparent %d", app->titlebarAppearsTransparent ? YES :NO); msg(app->mainWindow, s("setTitlebarAppearsTransparent:"), app->titlebarAppearsTransparent ? YES : NO); msg(app->mainWindow, s("setTitleVisibility:"), app->hideTitle); // Toolbar - if( app->useToolBar ) { - Debug("Setting Toolbar"); - id toolbar = msg(c("NSToolbar"),s("alloc")); - msg(toolbar, s("initWithIdentifier:"), str("wails.toolbar")); - msg(toolbar, s("autorelease")); + } + if( app->useToolBar ) { + Debug("Setting Toolbar"); + id toolbar = msg(c("NSToolbar"),s("alloc")); + msg(toolbar, s("initWithIdentifier:"), str("wails.toolbar")); + msg(toolbar, s("autorelease")); - // Separator - if( app->hideToolbarSeparator ) { - msg(toolbar, s("setShowsBaselineSeparator:"), NO); - } - - msg(app->mainWindow, s("setToolbar:"), toolbar); + // Separator + if( app->hideToolbarSeparator ) { + msg(toolbar, s("setShowsBaselineSeparator:"), NO); } + + msg(app->mainWindow, s("setToolbar:"), toolbar); } // Fix up resizing diff --git a/v2/internal/ffenestri/ffenestri_darwin.go b/v2/internal/ffenestri/ffenestri_darwin.go index 8c80595e..87239944 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.go +++ b/v2/internal/ffenestri/ffenestri_darwin.go @@ -50,11 +50,6 @@ func (a *Application) processPlatformSettings() { C.TitlebarAppearsTransparent(a.app) } - // For macs we consider "frameless" to mean a combination of options - if titlebar.TitlebarAppearsTransparent && titlebar.HideTitle { - C.DisableFrame(a.app) - } - // Process window Appearance if mac.Appearance != "" { C.SetAppearance(a.app, a.string2CString(string(mac.Appearance)))