Frameless is calculated for Mac

This commit is contained in:
Lea Anthony 2020-09-29 20:34:54 +10:00
commit b8bb891275
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
4 changed files with 24 additions and 11 deletions

View file

@ -134,10 +134,10 @@ func (a *Application) Run(incomingDispatcher Dispatcher, bindings string) error
// Set debug if needed
C.SetDebug(app, a.bool2Cint(DEBUG))
// Set Frameless
if a.config.Frameless {
C.DisableFrame(a.app)
}
// TODO: Move frameless to Linux options
// if a.config.Frameless {
// C.DisableFrame(a.app)
// }
if a.config.Colour != 0 {
r, g, b, alpha := intToColour(a.config.Colour)

View file

@ -122,6 +122,7 @@ struct Application {
// Features
int frame;
int startHidden;
int maximised;
int minimised;
int titlebarAppearsTransparent;
@ -236,7 +237,12 @@ void closeWindow(id self, SEL cmd, id sender) {
app->sendMessageToBackend("WC");
}
void* NewApplication(const char *title, int width, int height, int resizable, int devtools, int fullscreen) {
// void willFinishLaunching(id self) {
// struct Application *app = (struct Application *) objc_getAssociatedObject(self, "application");
// Debug("willFinishLaunching called!");
// }
void* NewApplication(const char *title, int width, int height, int resizable, int devtools, int fullscreen, int startHidden) {
// Setup main application struct
struct Application *result = malloc(sizeof(struct Application));
result->title = title;
@ -252,6 +258,7 @@ void* NewApplication(const char *title, int width, int height, int resizable, in
result->lock = 0;
result->maximised = 0;
result->minimised = 0;
result->startHidden = startHidden;
result->mainWindow = NULL;
result->mouseEvent = NULL;
@ -693,8 +700,7 @@ void Run(void *applicationPointer, int argc, char **argv) {
class_addMethod(delegateClass, s("applicationShouldTerminateAfterLastWindowClosed:"), (IMP) yes, "c@:@");
// Script handler
class_addMethod(delegateClass, s("userContentController:didReceiveScriptMessage:"), (IMP) messageHandler,
"v@:@@");
class_addMethod(delegateClass, s("userContentController:didReceiveScriptMessage:"), (IMP) messageHandler, "v@:@@");
objc_registerClassPair(delegateClass);
// Create delegate
@ -740,7 +746,7 @@ void Run(void *applicationPointer, int argc, char **argv) {
}
msg(wkwebview, s("initWithFrame:configuration:"), CGRectMake(0, 0, 0, 0), config);
// Andd message handlers
msg(manager, s("addScriptMessageHandler:name:"), delegate, str("external"));
msg(manager, s("addScriptMessageHandler:name:"), delegate, str("completed"));
msg(mainWindow, s("setContentView:"), wkwebview);
@ -812,7 +818,7 @@ void Run(void *applicationPointer, int argc, char **argv) {
};
class_addMethod(delegateClass, s("closeWindow"), (IMP) closeWindow, "v@:@");
// class_addMethod(delegateClass, s("applicationWillFinishLaunching:"), (IMP) willFinishLaunching, "@@:@");
// Include callback after evaluation
temp = concat(internalCode, "webkit.messageHandlers.completed.postMessage(true);");
free((void*)internalCode);
@ -833,7 +839,6 @@ void Run(void *applicationPointer, int argc, char **argv) {
// Finally call run
Debug("Run called");
msg(application, s("activateIgnoringOtherApps:"), true);
msg(application, s("run"));
free((void*)internalCode);

View file

@ -10,6 +10,7 @@ extern void HideTitleBar(void *);
extern void FullSizeContent(void *);
extern void UseToolbar(void *);
extern void HideToolbarSeparator(void *);
extern void DisableFrame(void *);
*/
import "C"
@ -46,4 +47,8 @@ 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)
}
}

View file

@ -3,6 +3,7 @@ package main
import (
wails "github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
func main() {
@ -16,7 +17,9 @@ func main() {
MinHeight: 600,
MaxWidth: 1280,
MaxHeight: 1024,
Frameless: true,
Mac: &mac.Options{
TitleBar: mac.TitleBarHidden(),
},
})
app.Bind(newBasic())