Skip to content

Commit 384ecf1

Browse files
committed
wip
1 parent 0969d7b commit 384ecf1

File tree

34 files changed

+473
-506
lines changed

34 files changed

+473
-506
lines changed

src/apps/hideo-colorpicker/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct HsvPicker : public Ui::View<HsvPicker> {
6767
g.restore();
6868
}
6969

70-
void event(Events::Event &e) override {
70+
void event(Async::Event &e) override {
7171
_mouseListener.listen(*this, e);
7272

7373
if (_mouseListener.isPress() and e.is<Events::MouseEvent>()) {

src/apps/hideo-spreadsheet/table.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct Table : public Ui::View<Table> {
5252

5353
/* --- Events --- */
5454

55-
void event(Events::Event &e) override {
55+
void event(Async::Event &e) override {
5656
e.handle<Events::MouseEvent>([&](Events::MouseEvent const &m) {
5757
auto pos = m.pos - bound().topStart();
5858
if (bound().contains(m.pos)) {

src/impls/impl-efi/ui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ struct EfiHost :
3838
Efi::Key key = {};
3939
_stip->readKeyStroke(_stip, &key).unwrap();
4040
auto e = key.toKeyEvent();
41-
event(e);
41+
event<Events::KeyboardEvent>(*this, e);
4242
}
4343

4444
void wait(TimeSpan) override {
4545
}
4646

47-
void bubble(Events::Event &e) override {
47+
void bubble(Async::Event &e) override {
4848
Ui::Host::bubble(e);
4949
}
5050
};

src/impls/impl-sdl/ui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ struct SdlHost :
201201
SDL_WaitEventTimeout(nullptr, span.toMSecs());
202202
}
203203

204-
void bubble(Events::Event &e) override {
204+
void bubble(Async::Event &e) override {
205205
if (e.is<Ui::DragEvent>()) {
206206
auto &dragEvent = e.unwrap<Ui::DragEvent>();
207207
if (dragEvent.type == Ui::DragEvent::START) {

src/impls/impl-skift/ui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct Host :
3131
void wait(TimeSpan) override {
3232
}
3333

34-
void bubble(Events::Event &e) override {
34+
void bubble(Async::Event &e) override {
3535
Ui::Host::bubble(e);
3636
}
3737
};

src/kernel/loader/menu.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,16 @@ Ui::Child alert(String title, String subtitle) {
112112
Ui::spacing(64);
113113
}
114114

115-
void intent(Ui::Node &n, Events::Event &e) {
115+
void intent(Ui::Node &n, Async::Event &e) {
116116
if (auto *k = e.is<Events::KeyboardEvent>()) {
117117
if (k->key == Events::Key::LEFT) {
118-
Ui::dispatchAction<Action>(n, MoveSelectionAction{-1});
118+
Ui::bubble<Action>(n, MoveSelectionAction{-1});
119119
e.accept();
120120
} else if (k->key == Events::Key::RIGHT) {
121-
Ui::dispatchAction<Action>(n, MoveSelectionAction{1});
121+
Ui::bubble<Action>(n, MoveSelectionAction{1});
122122
e.accept();
123123
} else if (k->key == Events::Key::ENTER) {
124-
Ui::dispatchAction<Action>(n, SelectAction{});
124+
Ui::bubble<Action>(n, SelectAction{});
125125
e.accept();
126126
}
127127
}

src/libs/karm-async/async.cpp

+10-27
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,35 @@ namespace Karm::Async {
77
/* --- Sink --- */
88

99
void Loop::_post(Sink &sink, Box<Event> event) {
10-
_queued.emplaceBack(sink, std::move(event));
10+
_queued.emplaceBack(&sink, std::move(event));
1111
}
1212

13-
void Loop::_move(Sink &from, Sink &to) {
13+
void Loop::_move(Sink &from, Sink *to) {
1414
for (auto &q : _queued) {
1515
if (q.sink == &from) {
16-
q.sink = &to;
16+
q.sink = to;
1717
}
1818
}
1919

2020
for (auto &s : _sources) {
2121
if (s.sink == &from) {
22-
s.sink = &to;
22+
s.sink = to;
2323
}
2424
}
2525
}
2626

27-
void Loop::_dtor(Sink &sink) {
28-
for (auto &q : _queued) {
29-
if (q.sink == &sink)
30-
q.sink = nullptr;
31-
}
32-
33-
for (auto &s : _sources) {
34-
if (s.sink == &sink)
35-
s.sink = nullptr;
36-
}
37-
}
38-
3927
/* --- Source --- */
4028

4129
void Loop::_bind(Source &source, Sink &sink) {
42-
_sources.emplaceBack(source, sink);
43-
}
44-
45-
void Loop::_move(Source &from, Source &to) {
46-
for (auto &s : _sources) {
47-
if (s.source == &from)
48-
s.source = &to;
49-
}
30+
sink._attachedOnce = true;
31+
_sources.emplaceBack(&source, &sink);
5032
}
5133

52-
void Loop::_dtor(Source *source) {
34+
void Loop::_move(Source &from, Source *to) {
5335
for (auto &s : _sources) {
54-
if (s.source == source)
55-
s.source = nullptr;
36+
if (s.source == &from) {
37+
s.source = to;
38+
}
5639
}
5740
}
5841

0 commit comments

Comments
 (0)