summaryrefslogtreecommitdiff
path: root/src/macos.m
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-20 11:37:23 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-20 11:37:23 +0300
commit2d81addf78d6a8b0fb2f2959b04a385c4adffdf2 (patch)
tree5e0f45b9c945499bc6a6669563de13c5203981a6 /src/macos.m
parent201021092d204680b353c82ce9e9beb76f3044e8 (diff)
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.
Diffstat (limited to 'src/macos.m')
-rw-r--r--src/macos.m17
1 files changed, 16 insertions, 1 deletions
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. */
30#include "ui/window.h" 30#include "ui/window.h"
31 31
32#include <SDL_timer.h> 32#include <SDL_timer.h>
33#include <SDL_syswm.h>
33 34
34#import <AppKit/AppKit.h> 35#import <AppKit/AppKit.h>
35 36
@@ -51,6 +52,16 @@ static iInt2 macVer_(void) {
51 return init_I2(10, 10); 52 return init_I2(10, 10);
52} 53}
53 54
55static NSWindow *nsWindow_(SDL_Window *window) {
56 SDL_SysWMinfo wm;
57 SDL_VERSION(&wm.version);
58 if (SDL_GetWindowWMInfo(window, &wm)) {
59 return wm.info.cocoa.window;
60 }
61 iAssert(false);
62 return nil;
63}
64
54static NSString *currentSystemAppearance_(void) { 65static NSString *currentSystemAppearance_(void) {
55 /* This API does not exist on 10.13. */ 66 /* This API does not exist on 10.13. */
56 if ([NSApp respondsToSelector:@selector(effectiveAppearance)]) { 67 if ([NSApp respondsToSelector:@selector(effectiveAppearance)]) {
@@ -370,6 +381,11 @@ void setupApplication_MacOS(void) {
370 windowCloseItem.action = @selector(closeTab); 381 windowCloseItem.action = @selector(closeTab);
371} 382}
372 383
384void hideTitleBar_MacOS(iWindow *window) {
385 NSWindow *w = nsWindow_(window->win);
386 w.styleMask = 0; /* borderless */
387}
388
373void enableMenu_MacOS(const char *menuLabel, iBool enable) { 389void enableMenu_MacOS(const char *menuLabel, iBool enable) {
374 menuLabel = translateCStr_Lang(menuLabel); 390 menuLabel = translateCStr_Lang(menuLabel);
375 NSApplication *app = [NSApplication sharedApplication]; 391 NSApplication *app = [NSApplication sharedApplication];
@@ -377,7 +393,6 @@ void enableMenu_MacOS(const char *menuLabel, iBool enable) {
377 NSString *label = [NSString stringWithUTF8String:menuLabel]; 393 NSString *label = [NSString stringWithUTF8String:menuLabel];
378 NSMenuItem *menuItem = [appMenu itemAtIndex:[appMenu indexOfItemWithTitle:label]]; 394 NSMenuItem *menuItem = [appMenu itemAtIndex:[appMenu indexOfItemWithTitle:label]];
379 [menuItem setEnabled:enable]; 395 [menuItem setEnabled:enable];
380 [label release];
381} 396}
382 397
383void enableMenuItem_MacOS(const char *menuItemCommand, iBool enable) { 398void enableMenuItem_MacOS(const char *menuItemCommand, iBool enable) {