From 2d81addf78d6a8b0fb2f2959b04a385c4adffdf2 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 20 Sep 2021 11:37:23 +0300 Subject: Experimenting with independent popup windows Toe dipping into multiple window support by allowing popup menu widgets to be displayed in independent windows. This is not a 100% replacement for native menus, but it gets pretty close. --- src/macos.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/macos.m') diff --git a/src/macos.m b/src/macos.m index d588fa4a..298db0f8 100644 --- a/src/macos.m +++ b/src/macos.m @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ui/window.h" #include +#include #import @@ -51,6 +52,16 @@ static iInt2 macVer_(void) { return init_I2(10, 10); } +static NSWindow *nsWindow_(SDL_Window *window) { + SDL_SysWMinfo wm; + SDL_VERSION(&wm.version); + if (SDL_GetWindowWMInfo(window, &wm)) { + return wm.info.cocoa.window; + } + iAssert(false); + return nil; +} + static NSString *currentSystemAppearance_(void) { /* This API does not exist on 10.13. */ if ([NSApp respondsToSelector:@selector(effectiveAppearance)]) { @@ -370,6 +381,11 @@ void setupApplication_MacOS(void) { windowCloseItem.action = @selector(closeTab); } +void hideTitleBar_MacOS(iWindow *window) { + NSWindow *w = nsWindow_(window->win); + w.styleMask = 0; /* borderless */ +} + void enableMenu_MacOS(const char *menuLabel, iBool enable) { menuLabel = translateCStr_Lang(menuLabel); NSApplication *app = [NSApplication sharedApplication]; @@ -377,7 +393,6 @@ void enableMenu_MacOS(const char *menuLabel, iBool enable) { NSString *label = [NSString stringWithUTF8String:menuLabel]; NSMenuItem *menuItem = [appMenu itemAtIndex:[appMenu indexOfItemWithTitle:label]]; [menuItem setEnabled:enable]; - [label release]; } void enableMenuItem_MacOS(const char *menuItemCommand, iBool enable) { -- cgit v1.2.3