Flutter Engine
The Flutter Engine
third_party
skia
tools
sk_app
unix
main_unix.cpp
Go to the documentation of this file.
1
/*
2
3
* Copyright 2016 Google Inc.
4
*
5
* Use of this source code is governed by a BSD-style license that can be
6
* found in the LICENSE file.
7
*/
8
9
#include "
include/core/SkTypes.h
"
10
#include "
src/core/SkTHash.h
"
11
#include "
tools/sk_app/Application.h
"
12
#include "
tools/sk_app/unix/Window_unix.h
"
13
#include "
tools/timer/Timer.h
"
14
15
using namespace
skia_private
;
16
17
int
main
(
int
argc,
char
**
argv
) {
18
XInitThreads();
19
Display* display = XOpenDisplay(
nullptr
);
20
21
sk_app::Application
*
app
=
sk_app::Application::Create
(argc,
argv
, (
void
*)display);
22
23
// Get the file descriptor for the X display
24
const
int
x11_fd = ConnectionNumber(display);
25
26
bool
done
=
false
;
27
while
(!
done
) {
28
if
(0 == XPending(display)) {
29
// Only call select() when we have no events.
30
31
// Create a file description set containing x11_fd
32
fd_set in_fds;
33
FD_ZERO(&in_fds);
34
FD_SET(x11_fd, &in_fds);
35
36
// Set a sleep timer
37
struct
timeval tv;
38
tv.tv_usec = 10;
39
tv.tv_sec = 0;
40
41
// Wait for an event on the file descriptor or for timer expiration
42
(void)select(1, &in_fds,
nullptr
,
nullptr
, &tv);
43
}
44
45
// Handle all pending XEvents (if any) and flush the input
46
// Only handle a finite number of events before finishing resize and paint..
47
if
(
int
count
= XPending(display)) {
48
// collapse any Expose and Resize events.
49
THashSet<sk_app::Window_unix*>
pendingWindows;
50
while
(
count
-- && !
done
) {
51
XEvent
event
;
52
XNextEvent(display, &
event
);
53
54
sk_app::Window_unix
* win =
sk_app::Window_unix::gWindowMap
.find(
event
.xany.window);
55
if
(!win) {
56
continue
;
57
}
58
59
// paint and resize events get collapsed
60
switch
(
event
.type) {
61
case
Expose:
62
win->
markPendingPaint
();
63
pendingWindows.
add
(win);
64
break
;
65
case
ConfigureNotify:
66
win->
markPendingResize
(
event
.xconfigurerequest.width,
67
event
.xconfigurerequest.height);
68
pendingWindows.
add
(win);
69
break
;
70
default
:
71
if
(win->
handleEvent
(
event
)) {
72
done
=
true
;
73
}
74
break
;
75
}
76
}
77
pendingWindows.
foreach
([](
sk_app::Window_unix
* win) {
78
win->
finishResize
();
79
win->
finishPaint
();
80
});
81
}
else
{
82
// We are only really "idle" when the timer went off with zero events.
83
app
->onIdle();
84
}
85
86
XFlush(display);
87
}
88
89
delete
app
;
90
91
XCloseDisplay(display);
92
93
return
0;
94
}
Application.h
done
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition:
DM.cpp:263
count
int count
Definition:
FontMgrTest.cpp:50
SkTHash.h
SkTypes.h
Timer.h
Window_unix.h
sk_app::Application
Definition:
Application.h:13
sk_app::Application::Create
static Application * Create(int argc, char **argv, void *platformData)
Definition:
editor_application.cpp:447
sk_app::Window_unix
Definition:
Window_unix.h:24
sk_app::Window_unix::handleEvent
bool handleEvent(const XEvent &event)
Definition:
Window_unix.cpp:249
sk_app::Window_unix::finishPaint
void finishPaint()
Definition:
Window_unix.h:61
sk_app::Window_unix::finishResize
void finishResize()
Definition:
Window_unix.h:75
sk_app::Window_unix::markPendingPaint
void markPendingPaint()
Definition:
Window_unix.h:60
sk_app::Window_unix::gWindowMap
static SkTDynamicHash< Window_unix, XWindow > gWindowMap
Definition:
Window_unix.h:58
sk_app::Window_unix::markPendingResize
void markPendingResize(int width, int height)
Definition:
Window_unix.h:68
skia_private::THashSet
Definition:
SkTHash.h:556
skia_private::THashSet::add
void add(T item)
Definition:
SkTHash.h:592
skia_private::THashSet::foreach
void foreach(Fn &&fn) const
Definition:
SkTHash.h:609
event
FlKeyEvent * event
Definition:
fl_key_channel_responder.cc:118
argv
char ** argv
Definition:
library.h:9
main
int main(int argc, char **argv)
Definition:
main_unix.cpp:17
gn.codesign_ios.app
app
Definition:
codesign_ios.py:62
skia_private
Definition:
SkTArray.h:32
Generated on Sun Jun 23 2024 21:56:50 for Flutter Engine by
1.9.4