Skip to content

Commit ddbe6bd

Browse files
awesomeklinggmta
authored andcommitted
Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
1 parent bdf696e commit ddbe6bd

File tree

128 files changed

+399
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+399
-401
lines changed

Documentation/EventLoop.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The **event loop stack** is mainly used for nesting GUI windows. Each window add
2929
An event loop handles several kinds of events:
3030

3131
- POSIX signals can be registered with `EventLoop::register_signal()`. This means that the event loop of the calling thread registers the specified POSIX signal and callback with the kernel, and you can be sure that the signal handler will run as a normal event without the weirdness that comes with POSIX signal handlers (such as unspecified thread).
32-
- EventLoop::post_event() allows calling code to fire an event targeting a specific Core::Object the next time the event loop is pumped.
32+
- EventLoop::post_event() allows calling code to fire an event targeting a specific Core::EventReceiver the next time the event loop is pumped.
3333
- Similarly, an arbitrary callback can be called on the next event loop iteration with `EventLoop::deferred_invoke()`.
3434
- Timer events, i.e. events that fire after a certain timeout, possibly repeatedly, can be created with `EventLoop::register_timer` and `Object::start_timer()`. A more user-friendly version is the `Core::Timer` utility class which does the same thing and allows you to attach any callback to the timer.
3535
- For when a "file" becomes readable or writeable, the utility class `Core::Notifier` interfaces with the event loop system to handle exactly that.

Ladybird/EventLoopImplementationQt.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "EventLoopImplementationQtEventTarget.h"
99
#include <AK/IDAllocator.h>
1010
#include <LibCore/Event.h>
11+
#include <LibCore/EventReceiver.h>
1112
#include <LibCore/Notifier.h>
12-
#include <LibCore/Object.h>
1313
#include <LibCore/ThreadEventQueue.h>
1414
#include <QCoreApplication>
1515
#include <QTimer>
@@ -73,14 +73,14 @@ void EventLoopImplementationQt::wake()
7373
m_event_loop.wakeUp();
7474
}
7575

76-
void EventLoopImplementationQt::post_event(Core::Object& receiver, NonnullOwnPtr<Core::Event>&& event)
76+
void EventLoopImplementationQt::post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&& event)
7777
{
7878
m_thread_event_queue.post_event(receiver, move(event));
7979
if (&m_thread_event_queue != &Core::ThreadEventQueue::current())
8080
wake();
8181
}
8282

83-
static void qt_timer_fired(int timer_id, Core::TimerShouldFireWhenNotVisible should_fire_when_not_visible, Core::Object& object)
83+
static void qt_timer_fired(int timer_id, Core::TimerShouldFireWhenNotVisible should_fire_when_not_visible, Core::EventReceiver& object)
8484
{
8585
if (should_fire_when_not_visible == Core::TimerShouldFireWhenNotVisible::No) {
8686
if (!object.is_visible_for_timer_purposes())
@@ -90,7 +90,7 @@ static void qt_timer_fired(int timer_id, Core::TimerShouldFireWhenNotVisible sho
9090
object.dispatch_event(event);
9191
}
9292

93-
int EventLoopManagerQt::register_timer(Core::Object& object, int milliseconds, bool should_reload, Core::TimerShouldFireWhenNotVisible should_fire_when_not_visible)
93+
int EventLoopManagerQt::register_timer(Core::EventReceiver& object, int milliseconds, bool should_reload, Core::TimerShouldFireWhenNotVisible should_fire_when_not_visible)
9494
{
9595
auto& thread_data = ThreadData::the();
9696
auto timer = make<QTimer>();

Ladybird/EventLoopImplementationQt.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class EventLoopManagerQt final : public Core::EventLoopManager {
2626
virtual ~EventLoopManagerQt() override;
2727
virtual NonnullOwnPtr<Core::EventLoopImplementation> make_implementation() override;
2828

29-
virtual int register_timer(Core::Object&, int milliseconds, bool should_reload, Core::TimerShouldFireWhenNotVisible) override;
29+
virtual int register_timer(Core::EventReceiver&, int milliseconds, bool should_reload, Core::TimerShouldFireWhenNotVisible) override;
3030
virtual bool unregister_timer(int timer_id) override;
3131

3232
virtual void register_notifier(Core::Notifier&) override;
@@ -67,7 +67,7 @@ class EventLoopImplementationQt final : public Core::EventLoopImplementation {
6767
virtual size_t pump(PumpMode) override;
6868
virtual void quit(int) override;
6969
virtual void wake() override;
70-
virtual void post_event(Core::Object& receiver, NonnullOwnPtr<Core::Event>&&) override;
70+
virtual void post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&&) override;
7171

7272
// FIXME: These APIs only exist for obscure use-cases inside SerenityOS. Try to get rid of them.
7373
virtual void unquit() override { }

Tests/Kernel/crash.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# include <Kernel/Arch/x86_64/IO.h>
1313
#endif
1414
#include <LibCore/ArgsParser.h>
15-
#include <LibCore/Object.h>
15+
#include <LibCore/EventReceiver.h>
1616
#include <LibTest/CrashTest.h>
1717
#include <stdio.h>
1818
#include <stdlib.h>
@@ -327,7 +327,7 @@ int main(int argc, char** argv)
327327

328328
if (do_deref_null_refptr || do_all_crash_types) {
329329
any_failures |= !Crash("Dereference a null RefPtr", [] {
330-
RefPtr<Core::Object> p;
330+
RefPtr<Core::EventReceiver> p;
331331
*p;
332332
return Crash::Failure::DidNotCrash;
333333
}).run(run_type);

Userland/Applications/Escalator/EscalatorWindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <AK/StringView.h>
1212
#include <AK/Vector.h>
1313
#include <LibCore/Account.h>
14-
#include <LibCore/Object.h>
14+
#include <LibCore/EventReceiver.h>
1515
#include <LibGUI/Button.h>
1616
#include <LibGUI/ImageWidget.h>
1717
#include <LibGUI/TextBox.h>

Userland/Applications/Piano/AudioPlayerLoop.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <LibAudio/Sample.h>
1414
#include <LibAudio/WavWriter.h>
1515
#include <LibCore/Event.h>
16-
#include <LibCore/Object.h>
16+
#include <LibCore/EventReceiver.h>
1717
#include <LibDSP/Music.h>
1818
#include <LibThreading/MutexProtected.h>
1919
#include <LibThreading/Thread.h>
@@ -22,7 +22,7 @@ class TrackManager;
2222

2323
// Wrapper class accepting custom events to advance the track playing and forward audio data to the system.
2424
// This does not run on a separate thread, preventing IPC multithreading madness.
25-
class AudioPlayerLoop final : public Core::Object {
25+
class AudioPlayerLoop final : public Core::EventReceiver {
2626
C_OBJECT(AudioPlayerLoop)
2727
public:
2828
virtual ~AudioPlayerLoop() override;

Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include <AK/NonnullRefPtr.h>
10-
#include <LibCore/Object.h>
10+
#include <LibCore/EventReceiver.h>
1111
#include <LibDSP/ProcessorParameter.h>
1212
#include <LibGUI/Label.h>
1313
#include <LibGUI/Widget.h>

Userland/Applications/Piano/ProcessorParameterWidget/Toggle.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#pragma once
88

9-
#include <LibCore/Object.h>
9+
#include <LibCore/EventReceiver.h>
1010
#include <LibDSP/ProcessorParameter.h>
1111
#include <LibGUI/CheckBox.h>
1212
#include <LibGUI/Widget.h>

Userland/Applications/PixelPaint/ScopeWidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#pragma once
88

99
#include "Image.h"
10-
#include <LibCore/Object.h>
10+
#include <LibCore/EventReceiver.h>
1111
#include <LibGUI/Frame.h>
1212

1313
namespace PixelPaint {

Userland/Applications/SoundPlayer/SoundPlayerWidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SoundPlayerWidget final : public GUI::Widget
3333
m_visualization->remove_from_parent();
3434
update();
3535
auto new_visualization = T::construct(move(args)...);
36-
m_player_view->insert_child_before(new_visualization, *static_cast<Core::Object*>(m_playback_progress_slider.ptr()));
36+
m_player_view->insert_child_before(new_visualization, *static_cast<Core::EventReceiver*>(m_playback_progress_slider.ptr()));
3737
m_visualization = new_visualization;
3838
if (!loaded_filename().is_empty())
3939
m_visualization->start_new_file(loaded_filename());

Userland/Applications/Spreadsheet/Spreadsheet.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <AK/Types.h>
1818
#include <AK/WeakPtr.h>
1919
#include <AK/Weakable.h>
20-
#include <LibCore/Object.h>
20+
#include <LibCore/EventReceiver.h>
2121
#include <LibJS/Interpreter.h>
2222

2323
namespace Spreadsheet {
@@ -41,7 +41,7 @@ class CellChange {
4141
CellTypeMetadata m_new_type_metadata;
4242
};
4343

44-
class Sheet : public Core::Object {
44+
class Sheet : public Core::EventReceiver {
4545
C_OBJECT(Sheet);
4646

4747
public:

Userland/Applications/SystemMonitor/GraphWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
#include "GraphWidget.h"
9-
#include <LibCore/Object.h>
9+
#include <LibCore/EventReceiver.h>
1010
#include <LibGUI/Application.h>
1111
#include <LibGUI/Painter.h>
1212
#include <LibGfx/Font/Font.h>

Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "GraphWidget.h"
1010
#include <AK/JsonObject.h>
1111
#include <AK/NumberFormat.h>
12-
#include <LibCore/Object.h>
12+
#include <LibCore/EventReceiver.h>
1313
#include <LibGUI/BoxLayout.h>
1414
#include <LibGUI/Label.h>
1515
#include <LibGUI/Painter.h>

Userland/Applications/SystemMonitor/ThreadStackWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void ThreadStackWidget::refresh()
126126
[weak_this = make_weak_ptr()](auto result) -> ErrorOr<void> {
127127
if (!weak_this)
128128
return {};
129-
Core::EventLoop::current().post_event(const_cast<Core::Object&>(*weak_this), make<CompletionEvent>(move(result)));
129+
Core::EventLoop::current().post_event(const_cast<Core::EventReceiver&>(*weak_this), make<CompletionEvent>(move(result)));
130130
return {};
131131
});
132132
}

Userland/Applications/SystemMonitor/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <LibConfig/Client.h>
2222
#include <LibCore/ArgsParser.h>
2323
#include <LibCore/EventLoop.h>
24-
#include <LibCore/Object.h>
24+
#include <LibCore/EventReceiver.h>
2525
#include <LibCore/System.h>
2626
#include <LibCore/Timer.h>
2727
#include <LibGUI/Action.h>

Userland/DevTools/GMLPlayground/MainWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ErrorOr<NonnullRefPtr<MainWidget>> MainWidget::try_create(GUI::Icon const& icon)
9090
main_widget->m_editor->on_change = [main_widget = main_widget.ptr()] {
9191
main_widget->m_preview->remove_all_children();
9292
// FIXME: Parsing errors happen while the user is typing. What should we do about them?
93-
(void)main_widget->m_preview->load_from_gml(main_widget->m_editor->text(), [](DeprecatedString const& class_name) -> ErrorOr<NonnullRefPtr<Core::Object>> {
93+
(void)main_widget->m_preview->load_from_gml(main_widget->m_editor->text(), [](DeprecatedString const& class_name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
9494
return UnregisteredWidget::try_create(class_name);
9595
});
9696
};

Userland/DevTools/HackStudio/GMLPreviewWidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void GMLPreviewWidget::load_gml(DeprecatedString const& gml)
2828
}
2929

3030
// FIXME: Parsing errors happen while the user is typing. What should we do about them?
31-
(void)load_from_gml(gml, [](DeprecatedString const& name) -> ErrorOr<NonnullRefPtr<Core::Object>> {
31+
(void)load_from_gml(gml, [](DeprecatedString const& name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
3232
return GUI::Label::try_create(TRY(String::formatted("{} is not registered as a GML element!", name)));
3333
});
3434

Userland/DevTools/HackStudio/Locator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_sy
9595
return s;
9696
}
9797

98-
Locator::Locator(Core::Object* parent)
98+
Locator::Locator(Core::EventReceiver* parent)
9999
{
100100
set_layout<GUI::VerticalBoxLayout>();
101101
set_fixed_height(22);

Userland/DevTools/HackStudio/Locator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Locator final : public GUI::Widget {
2424
void update_suggestions();
2525
void open_suggestion(const GUI::ModelIndex&);
2626

27-
Locator(Core::Object* parent = nullptr);
27+
Locator(Core::EventReceiver* parent = nullptr);
2828

2929
RefPtr<GUI::TextBox> m_textbox;
3030
RefPtr<GUI::Window> m_popup_window;

Userland/DevTools/HackStudio/ProjectConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <AK/JsonObject.h>
1111
#include <AK/Optional.h>
1212
#include <AK/OwnPtr.h>
13-
#include <LibCore/Object.h>
13+
#include <LibCore/EventReceiver.h>
1414

1515
namespace HackStudio {
1616

Userland/Libraries/LibAudio/ConnectionToServer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <LibAudio/Queue.h>
1515
#include <LibAudio/UserSampleQueue.h>
1616
#include <LibCore/EventLoop.h>
17-
#include <LibCore/Object.h>
17+
#include <LibCore/EventReceiver.h>
1818
#include <LibIPC/ConnectionToServer.h>
1919
#include <LibThreading/Mutex.h>
2020
#include <LibThreading/Thread.h>

Userland/Libraries/LibCards/Card.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#pragma once
1010

1111
#include <AK/Format.h>
12-
#include <LibCore/Object.h>
12+
#include <LibCore/EventReceiver.h>
1313
#include <LibGUI/Painter.h>
1414
#include <LibGfx/Bitmap.h>
1515
#include <LibGfx/CharacterBitmap.h>
@@ -77,7 +77,7 @@ enum class Suit : u8 {
7777
__Count
7878
};
7979

80-
class Card final : public Core::Object {
80+
class Card final : public Core::EventReceiver {
8181
C_OBJECT(Card)
8282
public:
8383
static constexpr int width = 80;

Userland/Libraries/LibChess/UCIEndpoint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void Endpoint::event(Core::Event& event)
5151
case Command::Type::UCINewGame:
5252
return handle_ucinewgame();
5353
default:
54-
Object::event(event);
54+
EventReceiver::event(event);
5555
break;
5656
}
5757
}

Userland/Libraries/LibChess/UCIEndpoint.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
#pragma once
99

1010
#include <LibChess/UCICommand.h>
11+
#include <LibCore/EventReceiver.h>
1112
#include <LibCore/File.h>
1213
#include <LibCore/Notifier.h>
13-
#include <LibCore/Object.h>
1414

1515
namespace Chess::UCI {
1616

17-
class Endpoint : public Core::Object {
17+
class Endpoint : public Core::EventReceiver {
1818
C_OBJECT(Endpoint)
1919
public:
2020
virtual ~Endpoint() override = default;

Userland/Libraries/LibCore/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ set(SOURCES
1212
EventLoop.cpp
1313
EventLoopImplementation.cpp
1414
EventLoopImplementationUnix.cpp
15+
EventReceiver.cpp
1516
File.cpp
1617
LockFile.cpp
1718
MappedFile.cpp
1819
MimeData.cpp
1920
NetworkJob.cpp
2021
Notifier.cpp
21-
Object.cpp
2222
Process.cpp
2323
ProcessStatisticsReader.cpp
2424
SecretString.cpp

Userland/Libraries/LibCore/DeferredInvocationContext.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
#pragma once
99

10-
#include <LibCore/Object.h>
10+
#include <LibCore/EventReceiver.h>
1111

1212
namespace Core {
1313

14-
class DeferredInvocationContext final : public Core::Object {
14+
class DeferredInvocationContext final : public Core::EventReceiver {
1515
C_OBJECT(DeferredInvocationContext)
1616
private:
1717
DeferredInvocationContext() = default;

Userland/Libraries/LibCore/Event.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@
77

88
#include <AK/WeakPtr.h>
99
#include <LibCore/Event.h>
10-
#include <LibCore/Object.h>
10+
#include <LibCore/EventReceiver.h>
1111

1212
namespace Core {
1313

14-
ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child)
14+
ChildEvent::ChildEvent(Type type, EventReceiver& child, EventReceiver* insertion_before_child)
1515
: Core::Event(type)
1616
, m_child(child.make_weak_ptr())
1717
, m_insertion_before_child(AK::make_weak_ptr_if_nonnull(insertion_before_child))
1818
{
1919
}
2020

21-
Object* ChildEvent::child()
21+
EventReceiver* ChildEvent::child()
2222
{
2323
if (auto ref = m_child.strong_ref())
2424
return ref.ptr();
2525
return nullptr;
2626
}
2727

28-
Object const* ChildEvent::child() const
28+
EventReceiver const* ChildEvent::child() const
2929
{
3030
if (auto ref = m_child.strong_ref())
3131
return ref.ptr();
3232
return nullptr;
3333
}
3434

35-
Object* ChildEvent::insertion_before_child()
35+
EventReceiver* ChildEvent::insertion_before_child()
3636
{
3737
if (auto ref = m_insertion_before_child.strong_ref())
3838
return ref.ptr();
3939
return nullptr;
4040
}
4141

42-
Object const* ChildEvent::insertion_before_child() const
42+
EventReceiver const* ChildEvent::insertion_before_child() const
4343
{
4444
if (auto ref = m_insertion_before_child.strong_ref())
4545
return ref.ptr();

Userland/Libraries/LibCore/Event.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ class NotifierActivationEvent final : public Event {
9595

9696
class ChildEvent final : public Event {
9797
public:
98-
ChildEvent(Type, Object& child, Object* insertion_before_child = nullptr);
98+
ChildEvent(Type, EventReceiver& child, EventReceiver* insertion_before_child = nullptr);
9999
~ChildEvent() = default;
100100

101-
Object* child();
102-
Object const* child() const;
101+
EventReceiver* child();
102+
EventReceiver const* child() const;
103103

104-
Object* insertion_before_child();
105-
Object const* insertion_before_child() const;
104+
EventReceiver* insertion_before_child();
105+
EventReceiver const* insertion_before_child() const;
106106

107107
private:
108-
WeakPtr<Object> m_child;
109-
WeakPtr<Object> m_insertion_before_child;
108+
WeakPtr<EventReceiver> m_child;
109+
WeakPtr<EventReceiver> m_insertion_before_child;
110110
};
111111

112112
class CustomEvent : public Event {

0 commit comments

Comments
 (0)