Flutter Engine
The Flutter Engine
third_party
skia
tools
sk_app
mac
main_mac.mm
Go to the documentation of this file.
1
/*
2
* Copyright 2019 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#import <Cocoa/Cocoa.h>
9
10
#include "
tools/sk_app/Application.h
"
11
#include "
tools/sk_app/mac/Window_mac.h
"
12
13
@interface
AppDelegate
: NSObject<NSApplicationDelegate, NSWindowDelegate>
14
15
@property
(nonatomic, assign)
BOOL
done
;
16
17
@end
18
19
@implementation
AppDelegate
: NSObject
20
21
@synthesize
done
= _done;
22
23
- (
id
)
init
{
24
self
= [
super
init];
25
_done =
FALSE
;
26
return
self
;
27
}
28
29
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
30
_done =
TRUE
;
31
return
NSTerminateCancel;
32
}
33
34
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
35
[NSApp stop:nil];
36
}
37
38
@end
39
40
///////////////////////////////////////////////////////////////////////////////////////////
41
42
using
sk_app::Application
;
43
using
sk_app::Window_mac
;
44
45
int
main
(
int
argc,
char
*
argv
[]) {
46
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
47
// we only run on systems that support at least Core Profile 3.2
48
return
EXIT_FAILURE;
49
#endif
50
51
NSAutoreleasePool *
pool
= [[NSAutoreleasePool alloc] init];
52
[NSApplication sharedApplication];
53
54
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
55
56
//Create the application menu.
57
NSMenu* menuBar=[[NSMenu alloc] initWithTitle:@"AMainMenu"];
58
[NSApp setMainMenu:menuBar];
59
60
NSMenuItem* item;
61
NSMenu* subMenu;
62
63
item=[[NSMenuItem alloc] initWithTitle:@"Apple" action:nil keyEquivalent:@""];
64
[menuBar addItem:item];
65
subMenu=[[NSMenu alloc] initWithTitle:@"Apple"];
66
[menuBar setSubmenu:subMenu forItem:item];
67
[item release];
68
item=[[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
69
[subMenu addItem:item];
70
[item release];
71
[subMenu release];
72
73
// Set AppDelegate to catch certain global events
74
AppDelegate
* appDelegate = [[
AppDelegate
alloc] init];
75
[NSApp setDelegate:appDelegate];
76
77
Application
*
app
=
Application::Create
(argc,
argv
,
nullptr
);
78
79
// This will run until the application finishes launching, then lets us take over
80
[NSApp run];
81
82
// Now we process the events
83
while
(![appDelegate
done
]) {
84
NSEvent*
event
;
85
do
{
86
event
= [NSApp nextEventMatchingMask:NSAnyEventMask
87
untilDate:[NSDate distantPast]
88
inMode:NSDefaultRunLoopMode
89
dequeue:YES];
90
[NSApp sendEvent:event];
91
}
while
(
event
!= nil);
92
93
[pool drain];
94
pool
= [[NSAutoreleasePool alloc] init];
95
96
// Rather than depending on a Mac event to drive this, we treat our window
97
// invalidation flag as a separate event stream. Window::onPaint() will clear
98
// the invalidation flag, effectively removing it from the stream.
99
Window_mac::PaintWindows();
100
101
app
->onIdle();
102
}
103
104
delete
app
;
105
106
[NSApp setDelegate:nil];
107
[appDelegate release];
108
109
[menuBar release];
110
[pool release];
111
112
return
EXIT_SUCCESS;
113
}
Application.h
pool
AutoreleasePool pool
Definition:
BazelBenchmarkTestRunner.cpp:313
self
return self
Definition:
FlutterTextureRegistryRelay.mm:19
Create
static sk_sp< Effect > Create()
Definition:
RefCntTest.cpp:117
Window_mac.h
sk_app::Application
Definition:
Application.h:13
sk_app::Window_mac
Definition:
Window_mac.h:18
event
FlKeyEvent * event
Definition:
fl_key_channel_responder.cc:118
TRUE
return TRUE
Definition:
fl_pixel_buffer_texture_test.cc:53
AppDelegate
Definition:
AppDelegate.h:10
AppDelegate::done
BOOL done
Definition:
main_mac.mm:15
-[AppDelegate init]
id init()
Definition:
main_mac.mm:23
argv
char ** argv
Definition:
library.h:9
main
int main(int argc, char *argv[])
Definition:
main_mac.mm:45
FALSE
return FALSE
Definition:
mock_text_input_plugin.cc:23
gn.codesign_ios.app
app
Definition:
codesign_ios.py:62
id
const uintptr_t id
Definition:
texture_unittests.cc:27
BOOL
int BOOL
Definition:
windows_types.h:37
Generated on Sun Jun 23 2024 21:56:50 for Flutter Engine by
1.9.4