All Classes Namespaces Functions Variables Enumerations Properties Pages
macosxnative.mm
1 #include "macosxnative.h"
2 
3 #include <AppKit/NSWindow.h>
4 #include <AppKit/Appkit.h>
5 #include <Availability.h>
6 
7 namespace MacOSXNative
8 {
9  #if !defined(MAC_OS_X_VERSION_10_14) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14
10  NSString* const NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
11  #endif
12 
13  void removeUnwantedMenuItems()
14  {
15  // Remove "Show Tab Bar" option from the "View" menu if possible
16 
17  if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)])
18  {
19  NSWindow.allowsAutomaticWindowTabbing = NO;
20  }
21  }
22 
23  bool isMouseCoalescingEnabled()
24  {
25  return NSEvent.isMouseCoalescingEnabled;
26  }
27 
28  void setMouseCoalescingEnabled(bool enabled)
29  {
30  NSEvent.mouseCoalescingEnabled = enabled;
31  }
32 
33  bool isDarkMode()
34  {
35  if (@available(macOS 10.14, *))
36  {
37  NSAppearanceName appearance =
38  [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[
39  NSAppearanceNameAqua, NSAppearanceNameDarkAqua
40  ]];
41  return [appearance isEqual:NSAppearanceNameDarkAqua];
42  }
43  return false;
44  }
45 }