1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

LibCore: Put all classes in the Core namespace and remove the leading C

I've been wanting to do this for a long time. It's time we start being
consistent about how this stuff works.

The new convention is:

- "LibFoo" is a userspace library that provides the "Foo" namespace.

That's it :^) This was pretty tedious to convert and I didn't even
start on LibGUI yet. But it's coming up next.
This commit is contained in:
Andreas Kling 2020-02-02 12:34:39 +01:00
parent b7e3810b5c
commit 2d39da5405
265 changed files with 1380 additions and 1167 deletions

View file

@ -30,7 +30,7 @@
#include <LibGUI/GLabel.h>
#include <LibGUI/GWidget.h>
GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, CObject* parent)
GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, Core::Object* parent)
: GDialog(parent)
, m_name(name)
, m_icon(icon)

View file

@ -33,14 +33,14 @@ class GAboutDialog final : public GDialog {
public:
virtual ~GAboutDialog() override;
static void show(const StringView& name, const GraphicsBitmap* icon = nullptr, CObject* parent = nullptr)
static void show(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr)
{
auto dialog = GAboutDialog::construct(name, icon, parent);
dialog->exec();
}
private:
GAboutDialog(const StringView& name, const GraphicsBitmap* icon = nullptr, CObject* parent = nullptr);
GAboutDialog(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr);
String m_name;
RefPtr<GraphicsBitmap> m_icon;

View file

@ -37,7 +37,7 @@ GAbstractButton::GAbstractButton(const StringView& text, GWidget* parent)
: GWidget(parent)
, m_text(text)
{
m_auto_repeat_timer = CTimer::construct(this);
m_auto_repeat_timer = Core::Timer::construct(this);
m_auto_repeat_timer->on_timeout = [this] {
click();
};
@ -147,13 +147,13 @@ void GAbstractButton::mouseup_event(GMouseEvent& event)
GWidget::mouseup_event(event);
}
void GAbstractButton::enter_event(CEvent&)
void GAbstractButton::enter_event(Core::Event&)
{
m_hovered = true;
update();
}
void GAbstractButton::leave_event(CEvent&)
void GAbstractButton::leave_event(Core::Event&)
{
m_hovered = false;
update();

View file

@ -33,7 +33,7 @@
class GPainter;
class GAbstractButton : public GWidget {
C_OBJECT(GAbstractButton)
C_OBJECT_ABSTRACT(GAbstractButton)
public:
virtual ~GAbstractButton() override;
@ -69,8 +69,8 @@ protected:
virtual void mousemove_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual void enter_event(CEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void enter_event(Core::Event&) override;
virtual void leave_event(Core::Event&) override;
virtual void change_event(GEvent&) override;
void paint_text(GPainter&, const Rect&, const Font&, TextAlignment);
@ -86,11 +86,11 @@ private:
bool m_exclusive { false };
int m_auto_repeat_interval { 0 };
RefPtr<CTimer> m_auto_repeat_timer;
RefPtr<Core::Timer> m_auto_repeat_timer;
};
template<>
inline bool is<GAbstractButton>(const CObject& object)
inline bool Core::is<GAbstractButton>(const Core::Object& object)
{
if (!is<GWidget>(object))
return false;

View file

@ -517,7 +517,7 @@ void GAbstractTableView::context_menu_event(GContextMenuEvent& event)
on_context_menu_request(index, event);
}
void GAbstractTableView::leave_event(CEvent&)
void GAbstractTableView::leave_event(Core::Event&)
{
window()->set_override_cursor(GStandardCursor::None);
set_hovered_header_index(-1);

View file

@ -81,7 +81,7 @@ protected:
virtual void mousemove_event(GMouseEvent&) override;
virtual void doubleclick_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void leave_event(Core::Event&) override;
virtual void context_menu_event(GContextMenuEvent&) override;
virtual void toggle_index(const GModelIndex&) {}

View file

@ -32,52 +32,52 @@
namespace GCommonActions {
NonnullRefPtr<GAction> make_open_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_open_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Open...", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Delete", { Mod_None, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_fullscreen_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_fullscreen_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
}
@ -87,58 +87,58 @@ NonnullRefPtr<GAction> make_quit_action(Function<void(GAction&)> callback)
return GAction::create("Quit", { Mod_Alt, Key_F4 }, move(callback));
}
NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Go back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Go forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_go_home_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_go_home_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Go home", { Mod_Alt, Key_Home }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
}
NonnullRefPtr<GAction> make_reload_action(Function<void(GAction&)> callback, CObject* parent)
NonnullRefPtr<GAction> make_reload_action(Function<void(GAction&)> callback, Core::Object* parent)
{
return GAction::create("Reload", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent);
}
}
GAction::GAction(const StringView& text, Function<void(GAction&)> on_activation_callback, CObject* parent)
: CObject(parent)
GAction::GAction(const StringView& text, Function<void(GAction&)> on_activation_callback, Core::Object* parent)
: Core::Object(parent)
, on_activation(move(on_activation_callback))
, m_text(text)
{
}
GAction::GAction(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> on_activation_callback, CObject* parent)
: CObject(parent)
GAction::GAction(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> on_activation_callback, Core::Object* parent)
: Core::Object(parent)
, on_activation(move(on_activation_callback))
, m_text(text)
, m_icon(move(icon))
{
}
GAction::GAction(const StringView& text, const GShortcut& shortcut, Function<void(GAction&)> on_activation_callback, CObject* parent)
GAction::GAction(const StringView& text, const GShortcut& shortcut, Function<void(GAction&)> on_activation_callback, Core::Object* parent)
: GAction(text, shortcut, nullptr, move(on_activation_callback), parent)
{
}
GAction::GAction(const StringView& text, const GShortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> on_activation_callback, CObject* parent)
: CObject(parent)
GAction::GAction(const StringView& text, const GShortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> on_activation_callback, Core::Object* parent)
: Core::Object(parent)
, on_activation(move(on_activation_callback))
, m_text(text)
, m_icon(move(icon))
, m_shortcut(shortcut)
{
if (parent && is<GWidget>(*parent)) {
if (parent && Core::is<GWidget>(*parent)) {
m_scope = ShortcutScope::WidgetLocal;
} else if (parent && is<GWindow>(*parent)) {
} else if (parent && Core::is<GWindow>(*parent)) {
m_scope = ShortcutScope::WindowLocal;
} else {
m_scope = ShortcutScope::ApplicationGlobal;
@ -152,7 +152,7 @@ GAction::~GAction()
GApplication::the().unregister_global_shortcut_action({}, *this);
}
void GAction::activate(CObject* activator)
void GAction::activate(Core::Object* activator)
{
if (activator)
m_activator = activator->make_weak_ptr();

View file

@ -44,24 +44,24 @@ class GButton;
class GMenuItem;
namespace GCommonActions {
NonnullRefPtr<GAction> make_open_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_fullscreen_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_open_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_fullscreen_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_quit_action(Function<void(GAction&)>);
NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_go_home_action(Function<void(GAction&)> callback, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_reload_action(Function<void(GAction&)>, CObject* parent = nullptr);
NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_go_home_action(Function<void(GAction&)> callback, Core::Object* parent = nullptr);
NonnullRefPtr<GAction> make_reload_action(Function<void(GAction&)>, Core::Object* parent = nullptr);
};
class GAction final : public CObject {
class GAction final : public Core::Object {
C_OBJECT(GAction)
public:
enum class ShortcutScope {
@ -70,19 +70,19 @@ public:
WindowLocal,
ApplicationGlobal,
};
static NonnullRefPtr<GAction> create(const StringView& text, Function<void(GAction&)> callback, CObject* parent = nullptr)
static NonnullRefPtr<GAction> create(const StringView& text, Function<void(GAction&)> callback, Core::Object* parent = nullptr)
{
return adopt(*new GAction(text, move(callback), parent));
}
static NonnullRefPtr<GAction> create(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> callback, CObject* parent = nullptr)
static NonnullRefPtr<GAction> create(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> callback, Core::Object* parent = nullptr)
{
return adopt(*new GAction(text, move(icon), move(callback), parent));
}
static NonnullRefPtr<GAction> create(const StringView& text, const GShortcut& shortcut, Function<void(GAction&)> callback, CObject* parent = nullptr)
static NonnullRefPtr<GAction> create(const StringView& text, const GShortcut& shortcut, Function<void(GAction&)> callback, Core::Object* parent = nullptr)
{
return adopt(*new GAction(text, shortcut, move(callback), parent));
}
static NonnullRefPtr<GAction> create(const StringView& text, const GShortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> callback, CObject* parent = nullptr)
static NonnullRefPtr<GAction> create(const StringView& text, const GShortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> callback, Core::Object* parent = nullptr)
{
return adopt(*new GAction(text, shortcut, move(icon), move(callback), parent));
}
@ -93,12 +93,12 @@ public:
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
void set_icon(const GraphicsBitmap* icon) { m_icon = icon; }
const CObject* activator() const { return m_activator.ptr(); }
CObject* activator() { return m_activator.ptr(); }
const Core::Object* activator() const { return m_activator.ptr(); }
Core::Object* activator() { return m_activator.ptr(); }
Function<void(GAction&)> on_activation;
void activate(CObject* activator = nullptr);
void activate(Core::Object* activator = nullptr);
bool is_enabled() const { return m_enabled; }
void set_enabled(bool);
@ -124,10 +124,10 @@ public:
private:
virtual bool is_action() const override { return true; }
GAction(const StringView& text, Function<void(GAction&)> = nullptr, CObject* = nullptr);
GAction(const StringView& text, const GShortcut&, Function<void(GAction&)> = nullptr, CObject* = nullptr);
GAction(const StringView& text, const GShortcut&, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, CObject* = nullptr);
GAction(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, CObject* = nullptr);
GAction(const StringView& text, Function<void(GAction&)> = nullptr, Core::Object* = nullptr);
GAction(const StringView& text, const GShortcut&, Function<void(GAction&)> = nullptr, Core::Object* = nullptr);
GAction(const StringView& text, const GShortcut&, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, Core::Object* = nullptr);
GAction(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> = nullptr, Core::Object* = nullptr);
template<typename Callback>
void for_each_toolbar_button(Callback);
@ -145,11 +145,11 @@ private:
HashTable<GButton*> m_buttons;
HashTable<GMenuItem*> m_menu_items;
WeakPtr<GActionGroup> m_action_group;
WeakPtr<CObject> m_activator;
WeakPtr<Core::Object> m_activator;
};
template<>
inline bool is<GAction>(const CObject& object)
inline bool Core::is<GAction>(const Core::Object& object)
{
return object.is_action();
}

View file

@ -48,7 +48,7 @@ GApplication::GApplication(int argc, char** argv)
(void)argv;
ASSERT(!s_the);
s_the = this;
m_event_loop = make<CEventLoop>();
m_event_loop = make<Core::EventLoop>();
GWindowServerConnection::the();
if (argc > 0)
m_invoked_as = argv[0];

View file

@ -35,8 +35,10 @@
namespace AK {
class SharedBuffer;
}
namespace Core {
class EventLoop;
}
class CEventLoop;
class GAction;
class GKeyEvent;
class GMenuBar;
@ -78,7 +80,7 @@ public:
void set_system_palette(SharedBuffer&);
private:
OwnPtr<CEventLoop> m_event_loop;
OwnPtr<Core::EventLoop> m_event_loop;
OwnPtr<GMenuBar> m_menubar;
RefPtr<PaletteImpl> m_palette;
RefPtr<PaletteImpl> m_system_palette;

View file

@ -31,7 +31,7 @@
#include <LibGUI/GSpinBox.h>
#include <LibGUI/GWidget.h>
GColorPicker::GColorPicker(Color color, CObject* parent)
GColorPicker::GColorPicker(Color color, Core::Object* parent)
: GDialog(parent)
, m_color(color)
{

View file

@ -38,7 +38,7 @@ public:
Color color() const { return m_color; }
private:
explicit GColorPicker(Color, CObject* parent = nullptr);
explicit GColorPicker(Color, Core::Object* parent = nullptr);
void build();

View file

@ -28,7 +28,7 @@
#include <LibGUI/GDialog.h>
#include <LibGUI/GEvent.h>
GDialog::GDialog(CObject* parent)
GDialog::GDialog(Core::Object* parent)
: GWindow(parent)
{
set_modal(true);
@ -41,7 +41,7 @@ GDialog::~GDialog()
int GDialog::exec()
{
ASSERT(!m_event_loop);
m_event_loop = make<CEventLoop>();
m_event_loop = make<Core::EventLoop>();
auto new_rect = rect();
if (parent() && parent()->is_window()) {
auto& parent_window = *static_cast<GWindow*>(parent());
@ -67,7 +67,7 @@ void GDialog::done(int result)
m_event_loop->quit(result);
}
void GDialog::event(CEvent& event)
void GDialog::event(Core::Event& event)
{
if (event.type() == GEvent::KeyUp) {
auto& key_event = static_cast<GKeyEvent&>(event);

View file

@ -45,14 +45,14 @@ public:
int result() const { return m_result; }
void done(int result);
virtual void event(CEvent&) override;
virtual void event(Core::Event&) override;
virtual void close() override;
protected:
explicit GDialog(CObject* parent);
explicit GDialog(Core::Object* parent);
private:
OwnPtr<CEventLoop> m_event_loop;
OwnPtr<Core::EventLoop> m_event_loop;
int m_result { ExecAborted };
};

View file

@ -30,8 +30,8 @@
static GDragOperation* s_current_drag_operation;
GDragOperation::GDragOperation(CObject* parent)
: CObject(parent)
GDragOperation::GDragOperation(Core::Object* parent)
: Core::Object(parent)
{
}
@ -61,7 +61,7 @@ GDragOperation::Outcome GDragOperation::exec()
}
s_current_drag_operation = this;
m_event_loop = make<CEventLoop>();
m_event_loop = make<Core::EventLoop>();
auto result = m_event_loop->exec();
m_event_loop = nullptr;
dbgprintf("%s: event loop returned with result %d\n", class_name(), result);

View file

@ -32,7 +32,7 @@
class GraphicsBitmap;
class GWindowServerConnection;
class GDragOperation : public CObject {
class GDragOperation : public Core::Object {
C_OBJECT(GDragOperation)
public:
enum class Outcome {
@ -58,12 +58,12 @@ public:
static void notify_cancelled(Badge<GWindowServerConnection>);
protected:
explicit GDragOperation(CObject* parent = nullptr);
explicit GDragOperation(Core::Object* parent = nullptr);
private:
void done(Outcome);
OwnPtr<CEventLoop> m_event_loop;
OwnPtr<Core::EventLoop> m_event_loop;
Outcome m_outcome { Outcome::None };
String m_text;
String m_data_type;

View file

@ -32,9 +32,7 @@
#include <LibDraw/Rect.h>
#include <LibGUI/GWindowType.h>
class CObject;
class GEvent : public CEvent {
class GEvent : public Core::Event {
public:
enum Type {
Show = 1000,
@ -72,7 +70,7 @@ public:
GEvent() {}
explicit GEvent(Type type)
: CEvent(type)
: Core::Event(type)
{
}
virtual ~GEvent() {}

View file

@ -72,7 +72,7 @@ Optional<String> GFilePicker::get_save_filepath(const String& title, const Strin
return {};
}
GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringView& path, CObject* parent)
GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringView& path, Core::Object* parent)
: GDialog(parent)
, m_model(GFileSystemModel::create())
, m_mode(mode)

View file

@ -55,7 +55,7 @@ private:
void clear_preview();
void on_file_return();
GFilePicker(Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = String(get_current_user_home_path()), CObject* parent = nullptr);
GFilePicker(Mode type = Mode::Open, const StringView& file_name = "Untitled", const StringView& path = String(get_current_user_home_path()), Core::Object* parent = nullptr);
static String ok_button_name(Mode mode)
{

View file

@ -91,7 +91,7 @@ void GFileSystemModel::Node::traverse_if_needed(const GFileSystemModel& model)
total_size = 0;
auto full_path = this->full_path(model);
CDirIterator di(full_path, CDirIterator::SkipDots);
Core::DirIterator di(full_path, Core::DirIterator::SkipDots);
if (di.has_error()) {
fprintf(stderr, "CDirIterator: %s\n", di.error_string());
return;
@ -122,7 +122,7 @@ void GFileSystemModel::Node::traverse_if_needed(const GFileSystemModel& model)
}
fcntl(m_watch_fd, F_SETFD, FD_CLOEXEC);
dbg() << "Watching " << full_path << " for changes, m_watch_fd = " << m_watch_fd;
m_notifier = CNotifier::construct(m_watch_fd, CNotifier::Event::Read);
m_notifier = Core::Notifier::construct(m_watch_fd, Core::Notifier::Event::Read);
m_notifier->on_ready_to_read = [this, &model] {
char buffer[32];
int rc = read(m_notifier->fd(), buffer, sizeof(buffer));

View file

@ -85,7 +85,7 @@ public:
bool has_traversed { false };
int m_watch_fd { -1 };
RefPtr<CNotifier> m_notifier;
RefPtr<Core::Notifier> m_notifier;
GModelIndex index(const GFileSystemModel&, int column) const;
void traverse_if_needed(const GFileSystemModel&);

View file

@ -43,7 +43,7 @@ GFontDatabase& GFontDatabase::the()
GFontDatabase::GFontDatabase()
{
CDirIterator di("/res/fonts", CDirIterator::SkipDots);
Core::DirIterator di("/res/fonts", Core::DirIterator::SkipDots);
if (di.has_error()) {
fprintf(stderr, "CDirIterator: %s\n", di.error_string());
exit(1);

View file

@ -31,7 +31,7 @@
#include <LibGUI/GTextEditor.h>
#include <stdio.h>
GInputBox::GInputBox(const StringView& prompt, const StringView& title, CObject* parent)
GInputBox::GInputBox(const StringView& prompt, const StringView& title, Core::Object* parent)
: GDialog(parent)
, m_prompt(prompt)
{

View file

@ -34,7 +34,7 @@ class GTextEditor;
class GInputBox : public GDialog {
C_OBJECT(GInputBox)
public:
explicit GInputBox(const StringView& prompt, const StringView& title, CObject* parent = nullptr);
explicit GInputBox(const StringView& prompt, const StringView& title, Core::Object* parent = nullptr);
virtual ~GInputBox() override;
String text_value() const { return m_text_value; }

View file

@ -30,8 +30,8 @@
void GJsonArrayModel::update()
{
auto file = CFile::construct(m_json_path);
if (!file->open(CIODevice::ReadOnly)) {
auto file = Core::File::construct(m_json_path);
if (!file->open(Core::IODevice::ReadOnly)) {
dbg() << "Unable to open " << file->filename();
m_array.clear();
did_update();

View file

@ -35,7 +35,7 @@
class GAction;
class Point;
class GMenu final : public CObject {
class GMenu final : public Core::Object {
C_OBJECT(GMenu)
public:
explicit GMenu(const StringView& name = "");

View file

@ -30,13 +30,13 @@
#include <LibGUI/GMessageBox.h>
#include <stdio.h>
int GMessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, CObject* parent)
int GMessageBox::show(const StringView& text, const StringView& title, Type type, InputType input_type, Core::Object* parent)
{
auto box = GMessageBox::construct(text, title, type, input_type, parent);
return box->exec();
}
GMessageBox::GMessageBox(const StringView& text, const StringView& title, Type type, InputType input_type, CObject* parent)
GMessageBox::GMessageBox(const StringView& text, const StringView& title, Type type, InputType input_type, Core::Object* parent)
: GDialog(parent)
, m_text(text)
, m_type(type)

View file

@ -45,10 +45,10 @@ public:
virtual ~GMessageBox() override;
static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
static int show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Core::Object* parent = nullptr);
private:
explicit GMessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
explicit GMessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, Core::Object* parent = nullptr);
bool should_include_ok_button() const;
bool should_include_cancel_button() const;

View file

@ -53,7 +53,7 @@ private:
};
template<>
inline bool is<GRadioButton>(const CObject& object)
inline bool Core::is<GRadioButton>(const Core::Object& object)
{
if (!is<GWidget>(object))
return false;

View file

@ -60,13 +60,13 @@ void GResizeCorner::mousedown_event(GMouseEvent& event)
GWidget::mousedown_event(event);
}
void GResizeCorner::enter_event(CEvent& event)
void GResizeCorner::enter_event(Core::Event& event)
{
window()->set_override_cursor(GStandardCursor::ResizeDiagonalTLBR);
GWidget::enter_event(event);
}
void GResizeCorner::leave_event(CEvent& event)
void GResizeCorner::leave_event(Core::Event& event)
{
window()->set_override_cursor(GStandardCursor::None);
GWidget::leave_event(event);

View file

@ -36,8 +36,8 @@ protected:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void enter_event(CEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void enter_event(Core::Event&) override;
virtual void leave_event(Core::Event&) override;
private:
RefPtr<GraphicsBitmap> m_bitmap;

View file

@ -93,7 +93,7 @@ GScrollBar::GScrollBar(Orientation orientation, GWidget* parent)
: GWidget(parent)
, m_orientation(orientation)
{
m_automatic_scrolling_timer = CTimer::construct(this);
m_automatic_scrolling_timer = Core::Timer::construct(this);
if (!s_up_arrow_bitmap)
s_up_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 9, 9).leak_ref();
if (!s_down_arrow_bitmap)
@ -355,7 +355,7 @@ void GScrollBar::mousemove_event(GMouseEvent& event)
set_value(new_value);
}
void GScrollBar::leave_event(CEvent&)
void GScrollBar::leave_event(Core::Event&)
{
if (m_hovered_component != Component::Invalid) {
m_hovered_component = Component::Invalid;

View file

@ -72,7 +72,7 @@ private:
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mousewheel_event(GMouseEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void leave_event(Core::Event&) override;
virtual void change_event(GEvent&) override;
int default_button_size() const { return 16; }
@ -110,5 +110,5 @@ private:
};
AutomaticScrollingDirection m_automatic_scrolling_direction { AutomaticScrollingDirection::None };
RefPtr<CTimer> m_automatic_scrolling_timer;
RefPtr<Core::Timer> m_automatic_scrolling_timer;
};

View file

@ -162,7 +162,7 @@ void GSlider::mouseup_event(GMouseEvent& event)
return GWidget::mouseup_event(event);
}
void GSlider::leave_event(CEvent& event)
void GSlider::leave_event(Core::Event& event)
{
if (!is_enabled())
return;

View file

@ -77,7 +77,7 @@ protected:
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void leave_event(Core::Event&) override;
virtual void change_event(GEvent&) override;
private:

View file

@ -43,14 +43,14 @@ GSplitter::~GSplitter()
{
}
void GSplitter::enter_event(CEvent&)
void GSplitter::enter_event(Core::Event&)
{
set_background_role(ColorRole::HoverHighlight);
window()->set_override_cursor(m_orientation == Orientation::Horizontal ? GStandardCursor::ResizeHorizontal : GStandardCursor::ResizeVertical);
update();
}
void GSplitter::leave_event(CEvent&)
void GSplitter::leave_event(Core::Event&)
{
set_background_role(ColorRole::Button);
if (!m_resizing)

View file

@ -39,8 +39,8 @@ protected:
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void enter_event(CEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void enter_event(Core::Event&) override;
virtual void leave_event(Core::Event&) override;
private:
Orientation m_orientation;

View file

@ -59,11 +59,11 @@ void GStackWidget::resize_event(GResizeEvent& event)
m_active_widget->set_relative_rect({ {}, event.size() });
}
void GStackWidget::child_event(CChildEvent& event)
void GStackWidget::child_event(Core::ChildEvent& event)
{
if (!event.child() || !is<GWidget>(*event.child()))
if (!event.child() || !Core::is<GWidget>(*event.child()))
return GWidget::child_event(event);
auto& child = to<GWidget>(*event.child());
auto& child = Core::to<GWidget>(*event.child());
if (event.type() == GEvent::ChildAdded) {
if (!m_active_widget)
set_active_widget(&child);

View file

@ -41,7 +41,7 @@ public:
protected:
explicit GStackWidget(GWidget* parent);
virtual void child_event(CChildEvent&) override;
virtual void child_event(Core::ChildEvent&) override;
virtual void resize_event(GResizeEvent&) override;
private:

View file

@ -84,11 +84,11 @@ Rect GTabWidget::child_rect_for_size(const Size& size) const
return rect;
}
void GTabWidget::child_event(CChildEvent& event)
void GTabWidget::child_event(Core::ChildEvent& event)
{
if (!event.child() || !is<GWidget>(*event.child()))
if (!event.child() || !Core::is<GWidget>(*event.child()))
return GWidget::child_event(event);
auto& child = to<GWidget>(*event.child());
auto& child = Core::to<GWidget>(*event.child());
if (event.type() == GEvent::ChildAdded) {
if (!m_active_widget)
set_active_widget(&child);
@ -214,7 +214,7 @@ void GTabWidget::mousemove_event(GMouseEvent& event)
update_bar();
}
void GTabWidget::leave_event(CEvent&)
void GTabWidget::leave_event(Core::Event&)
{
if (m_hovered_tab_index != -1) {
m_hovered_tab_index = -1;

View file

@ -55,11 +55,11 @@ public:
protected:
virtual void paint_event(GPaintEvent&) override;
virtual void child_event(CChildEvent&) override;
virtual void child_event(Core::ChildEvent&) override;
virtual void resize_event(GResizeEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void leave_event(Core::Event&) override;
private:
Rect child_rect_for_size(const Size&) const;

View file

@ -37,7 +37,7 @@ GTextDocument::GTextDocument(Client* client)
append_line(make<GTextDocumentLine>(*this));
// TODO: Instead of a repating timer, this we should call a delayed 2 sec timer when the user types.
m_undo_timer = CTimer::construct(
m_undo_timer = Core::Timer::construct(
2000, [this] {
update_undo_timer();
});

View file

@ -146,7 +146,7 @@ private:
bool m_client_notifications_enabled { true };
GUndoStack m_undo_stack;
RefPtr<CTimer> m_undo_timer;
RefPtr<Core::Timer> m_undo_timer;
};
class GTextDocumentLine {

View file

@ -235,7 +235,7 @@ void GTextEditor::mousedown_event(GMouseEvent& event)
}
if (m_triple_click_timer.is_valid() && m_triple_click_timer.elapsed() < 250) {
m_triple_click_timer = CElapsedTimer();
m_triple_click_timer = Core::ElapsedTimer();
GTextPosition start;
GTextPosition end;
@ -1030,18 +1030,18 @@ void GTextEditor::set_cursor(const GTextPosition& a_position)
on_cursor_change();
}
void GTextEditor::focusin_event(CEvent&)
void GTextEditor::focusin_event(Core::Event&)
{
update_cursor();
start_timer(500);
}
void GTextEditor::focusout_event(CEvent&)
void GTextEditor::focusout_event(Core::Event&)
{
stop_timer();
}
void GTextEditor::timer_event(CTimerEvent&)
void GTextEditor::timer_event(Core::TimerEvent&)
{
m_cursor_state = !m_cursor_state;
if (is_focused())
@ -1171,13 +1171,13 @@ void GTextEditor::paste()
insert_at_cursor_or_replace_selection(paste_text);
}
void GTextEditor::enter_event(CEvent&)
void GTextEditor::enter_event(Core::Event&)
{
ASSERT(window());
window()->set_override_cursor(GStandardCursor::IBeam);
}
void GTextEditor::leave_event(CEvent&)
void GTextEditor::leave_event(Core::Event&)
{
ASSERT(window());
window()->set_override_cursor(GStandardCursor::None);

View file

@ -142,12 +142,12 @@ protected:
virtual void mousemove_event(GMouseEvent&) override;
virtual void doubleclick_event(GMouseEvent&) override;
virtual void keydown_event(GKeyEvent&) override;
virtual void focusin_event(CEvent&) override;
virtual void focusout_event(CEvent&) override;
virtual void timer_event(CTimerEvent&) override;
virtual void focusin_event(Core::Event&) override;
virtual void focusout_event(Core::Event&) override;
virtual void timer_event(Core::TimerEvent&) override;
virtual bool accepts_focus() const override { return true; }
virtual void enter_event(CEvent&) override;
virtual void leave_event(CEvent&) override;
virtual void enter_event(Core::Event&) override;
virtual void leave_event(Core::Event&) override;
virtual void context_menu_event(GContextMenuEvent&) override;
virtual void resize_event(GResizeEvent&) override;
virtual void cursor_did_change() {}
@ -232,7 +232,7 @@ private:
RefPtr<GAction> m_paste_action;
RefPtr<GAction> m_delete_action;
RefPtr<GAction> m_go_to_line_action;
CElapsedTimer m_triple_click_timer;
Core::ElapsedTimer m_triple_click_timer;
NonnullRefPtrVector<GAction> m_custom_context_menu_actions;
RefPtr<GTextDocument> m_document;

View file

@ -91,7 +91,7 @@ const GWidgetClassRegistration* GWidgetClassRegistration::find(const String& cla
}
GWidget::GWidget(GWidget* parent)
: CObject(parent, true)
: Core::Object(parent, true)
, m_font(Font::default_font())
, m_palette(GApplication::the().palette().impl())
{
@ -101,26 +101,26 @@ GWidget::~GWidget()
{
}
void GWidget::child_event(CChildEvent& event)
void GWidget::child_event(Core::ChildEvent& event)
{
if (event.type() == GEvent::ChildAdded) {
if (event.child() && is<GWidget>(*event.child()) && layout()) {
if (event.child() && Core::is<GWidget>(*event.child()) && layout()) {
if (event.insertion_before_child() && event.insertion_before_child()->is_widget())
layout()->insert_widget_before(to<GWidget>(*event.child()), to<GWidget>(*event.insertion_before_child()));
layout()->insert_widget_before(Core::to<GWidget>(*event.child()), Core::to<GWidget>(*event.insertion_before_child()));
else
layout()->add_widget(to<GWidget>(*event.child()));
layout()->add_widget(Core::to<GWidget>(*event.child()));
}
}
if (event.type() == GEvent::ChildRemoved) {
if (layout()) {
if (event.child() && is<GWidget>(*event.child()))
layout()->remove_widget(to<GWidget>(*event.child()));
if (event.child() && Core::is<GWidget>(*event.child()))
layout()->remove_widget(Core::to<GWidget>(*event.child()));
else
invalidate_layout();
}
update();
}
return CObject::child_event(event);
return Core::Object::child_event(event);
}
void GWidget::set_relative_rect(const Rect& a_rect)
@ -151,7 +151,7 @@ void GWidget::set_relative_rect(const Rect& a_rect)
update();
}
void GWidget::event(CEvent& event)
void GWidget::event(Core::Event& event)
{
switch (event.type()) {
case GEvent::Paint:
@ -189,7 +189,7 @@ void GWidget::event(CEvent& event)
case GEvent::EnabledChange:
return change_event(static_cast<GEvent&>(event));
default:
return CObject::event(event);
return Core::Object::event(event);
}
}
@ -278,14 +278,14 @@ void GWidget::handle_mousedoubleclick_event(GMouseEvent& event)
doubleclick_event(event);
}
void GWidget::handle_enter_event(CEvent& event)
void GWidget::handle_enter_event(Core::Event& event)
{
if (has_tooltip())
GApplication::the().show_tooltip(m_tooltip, screen_relative_rect().center().translated(0, height() / 2));
enter_event(event);
}
void GWidget::handle_leave_event(CEvent& event)
void GWidget::handle_leave_event(Core::Event& event)
{
GApplication::the().hide_tooltip();
leave_event(event);
@ -356,19 +356,19 @@ void GWidget::context_menu_event(GContextMenuEvent&)
{
}
void GWidget::focusin_event(CEvent&)
void GWidget::focusin_event(Core::Event&)
{
}
void GWidget::focusout_event(CEvent&)
void GWidget::focusout_event(Core::Event&)
{
}
void GWidget::enter_event(CEvent&)
void GWidget::enter_event(Core::Event&)
{
}
void GWidget::leave_event(CEvent&)
void GWidget::leave_event(Core::Event&)
{
}
@ -426,9 +426,9 @@ Rect GWidget::screen_relative_rect() const
GWidget* GWidget::child_at(const Point& point) const
{
for (int i = children().size() - 1; i >= 0; --i) {
if (!is<GWidget>(children()[i]))
if (!Core::is<GWidget>(children()[i]))
continue;
auto& child = to<GWidget>(children()[i]);
auto& child = Core::to<GWidget>(children()[i]);
if (!child.is_visible())
continue;
if (child.relative_rect().contains(point))
@ -701,7 +701,7 @@ void GWidget::save_to(AK::JsonObject& json)
json.set("foreground_color", foreground_color().to_string());
json.set("preferred_size", preferred_size().to_string());
json.set("size_policy", String::format("[%s,%s]", to_string(horizontal_size_policy()), to_string(vertical_size_policy())));
CObject::save_to(json);
Core::Object::save_to(json);
}
Vector<GWidget*> GWidget::child_widgets() const

View file

@ -94,7 +94,7 @@ private:
Function<NonnullRefPtr<GWidget>(GWidget*)> m_factory;
};
class GWidget : public CObject {
class GWidget : public Core::Object {
C_OBJECT(GWidget)
public:
virtual ~GWidget() override;
@ -123,7 +123,7 @@ public:
bool updates_enabled() const { return m_updates_enabled; }
void set_updates_enabled(bool);
virtual void event(CEvent&) override;
virtual void event(Core::Event&) override;
// This is called after children have been painted.
virtual void second_paint_event(GPaintEvent&);
@ -245,8 +245,8 @@ public:
void for_each_child_widget(Callback callback)
{
for_each_child([&](auto& child) {
if (is<GWidget>(child))
return callback(to<GWidget>(child));
if (Core::is<GWidget>(child))
return callback(Core::to<GWidget>(child));
return IterationDecision::Continue;
});
}
@ -281,11 +281,11 @@ protected:
virtual void click_event(GMouseEvent&);
virtual void doubleclick_event(GMouseEvent&);
virtual void context_menu_event(GContextMenuEvent&);
virtual void focusin_event(CEvent&);
virtual void focusout_event(CEvent&);
virtual void enter_event(CEvent&);
virtual void leave_event(CEvent&);
virtual void child_event(CChildEvent&) override;
virtual void focusin_event(Core::Event&);
virtual void focusout_event(Core::Event&);
virtual void enter_event(Core::Event&);
virtual void leave_event(Core::Event&);
virtual void child_event(Core::ChildEvent&) override;
virtual void change_event(GEvent&);
virtual void drop_event(GDropEvent&);
@ -295,8 +295,8 @@ private:
void handle_mousedown_event(GMouseEvent&);
void handle_mousedoubleclick_event(GMouseEvent&);
void handle_mouseup_event(GMouseEvent&);
void handle_enter_event(CEvent&);
void handle_leave_event(CEvent&);
void handle_enter_event(Core::Event&);
void handle_leave_event(Core::Event&);
void focus_previous_widget();
void focus_next_widget();
@ -326,20 +326,20 @@ private:
};
template<>
inline bool is<GWidget>(const CObject& object)
inline bool Core::is<GWidget>(const Core::Object& object)
{
return object.is_widget();
}
inline GWidget* GWidget::parent_widget()
{
if (parent() && is<GWidget>(*parent()))
return &to<GWidget>(*parent());
if (parent() && Core::is<GWidget>(*parent()))
return &Core::to<GWidget>(*parent());
return nullptr;
}
inline const GWidget* GWidget::parent_widget() const
{
if (parent() && is<GWidget>(*parent()))
return &to<const GWidget>(*parent());
if (parent() && Core::is<GWidget>(*parent()))
return &Core::to<const GWidget>(*parent());
return nullptr;
}

View file

@ -53,8 +53,8 @@ GWindow* GWindow::from_window_id(int window_id)
return nullptr;
}
GWindow::GWindow(CObject* parent)
: CObject(parent)
GWindow::GWindow(Core::Object* parent)
: Core::Object(parent)
{
all_windows->set(this);
m_rect_when_windowless = { 100, 400, 140, 140 };
@ -179,7 +179,7 @@ void GWindow::set_override_cursor(GStandardCursor cursor)
GWindowServerConnection::the().send_sync<WindowServer::SetWindowOverrideCursor>(m_window_id, (u32)cursor);
}
void GWindow::event(CEvent& event)
void GWindow::event(Core::Event& event)
{
if (event.type() == GEvent::Drop) {
auto& drop_event = static_cast<GDropEvent&>(event);
@ -317,7 +317,7 @@ void GWindow::event(CEvent& event)
if (event.type() > GEvent::__Begin_WM_Events && event.type() < GEvent::__End_WM_Events)
return wm_event(static_cast<GWMEvent&>(event));
CObject::event(event);
Core::Object::event(event);
}
bool GWindow::is_visible() const
@ -386,12 +386,12 @@ void GWindow::set_focused_widget(GWidget* widget)
if (m_focused_widget == widget)
return;
if (m_focused_widget) {
CEventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusOut));
Core::EventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusOut));
m_focused_widget->update();
}
m_focused_widget = widget ? widget->make_weak_ptr() : nullptr;
if (m_focused_widget) {
CEventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusIn));
Core::EventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusIn));
m_focused_widget->update();
}
}
@ -446,12 +446,12 @@ void GWindow::set_hovered_widget(GWidget* widget)
return;
if (m_hovered_widget)
CEventLoop::current().post_event(*m_hovered_widget, make<GEvent>(GEvent::Leave));
Core::EventLoop::current().post_event(*m_hovered_widget, make<GEvent>(GEvent::Leave));
m_hovered_widget = widget ? widget->make_weak_ptr() : nullptr;
if (m_hovered_widget)
CEventLoop::current().post_event(*m_hovered_widget, make<GEvent>(GEvent::Enter));
Core::EventLoop::current().post_event(*m_hovered_widget, make<GEvent>(GEvent::Enter));
}
void GWindow::set_current_backing_bitmap(GraphicsBitmap& bitmap, bool flush_immediately)
@ -583,7 +583,7 @@ void GWindow::save_to(AK::JsonObject& json)
json.set("rect", rect().to_string());
json.set("base_size", base_size().to_string());
json.set("size_increment", size_increment().to_string());
CObject::save_to(json);
Core::Object::save_to(json);
}
void GWindow::set_fullscreen(bool fullscreen)

View file

@ -52,7 +52,7 @@ enum class GStandardCursor {
Hand,
};
class GWindow : public CObject {
class GWindow : public Core::Object {
C_OBJECT(GWindow)
public:
virtual ~GWindow() override;
@ -112,7 +112,7 @@ public:
void resize(int width, int height) { resize({ width, height }); }
void resize(const Size& size) { set_rect({ position(), size }); }
virtual void event(CEvent&) override;
virtual void event(Core::Event&) override;
bool is_visible() const;
bool is_active() const { return m_is_active; }
@ -175,7 +175,7 @@ public:
GAction* action_for_key_event(const GKeyEvent&);
protected:
GWindow(CObject* parent = nullptr);
GWindow(Core::Object* parent = nullptr);
virtual void wm_event(GWMEvent&);
private:
@ -216,7 +216,7 @@ private:
};
template<>
inline bool is<GWindow>(const CObject& object)
inline bool Core::is<GWindow>(const Core::Object& object)
{
return object.is_window();
}

View file

@ -75,13 +75,13 @@ void GWindowServerConnection::handle(const WindowClient::Paint& message)
dbgprintf("WID=%d Paint\n", message.window_id());
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GMultiPaintEvent>(message.rects(), message.window_size()));
Core::EventLoop::current().post_event(*window, make<GMultiPaintEvent>(message.rects(), message.window_size()));
}
void GWindowServerConnection::handle(const WindowClient::WindowResized& message)
{
if (auto* window = GWindow::from_window_id(message.window_id())) {
CEventLoop::current().post_event(*window, make<GResizeEvent>(message.old_rect().size(), message.new_rect().size()));
Core::EventLoop::current().post_event(*window, make<GResizeEvent>(message.old_rect().size(), message.new_rect().size()));
}
}
@ -91,7 +91,7 @@ void GWindowServerConnection::handle(const WindowClient::WindowActivated& messag
dbgprintf("(%d) WID=%d WindowActivated\n", getpid(), message.window_id());
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowBecameActive));
Core::EventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowBecameActive));
}
void GWindowServerConnection::handle(const WindowClient::WindowDeactivated& message)
@ -100,25 +100,25 @@ void GWindowServerConnection::handle(const WindowClient::WindowDeactivated& mess
dbgprintf("(%d) WID=%d WindowDeactivated\n", getpid(), message.window_id());
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowBecameInactive));
Core::EventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowBecameInactive));
}
void GWindowServerConnection::handle(const WindowClient::WindowCloseRequest& message)
{
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowCloseRequest));
Core::EventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowCloseRequest));
}
void GWindowServerConnection::handle(const WindowClient::WindowEntered& message)
{
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowEntered));
Core::EventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowEntered));
}
void GWindowServerConnection::handle(const WindowClient::WindowLeft& message)
{
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowLeft));
Core::EventLoop::current().post_event(*window, make<GEvent>(GEvent::WindowLeft));
}
void GWindowServerConnection::handle(const WindowClient::KeyDown& message)
@ -151,7 +151,7 @@ void GWindowServerConnection::handle(const WindowClient::KeyDown& message)
action->activate();
return;
}
CEventLoop::current().post_event(*window, move(key_event));
Core::EventLoop::current().post_event(*window, move(key_event));
}
void GWindowServerConnection::handle(const WindowClient::KeyUp& message)
@ -169,7 +169,7 @@ void GWindowServerConnection::handle(const WindowClient::KeyUp& message)
key_event->m_text = String(&ch, 1);
}
CEventLoop::current().post_event(*window, move(key_event));
Core::EventLoop::current().post_event(*window, move(key_event));
}
GMouseButton to_gmousebutton(u32 button)
@ -196,7 +196,7 @@ void GWindowServerConnection::handle(const WindowClient::MouseDown& message)
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseDown, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
Core::EventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseDown, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
}
void GWindowServerConnection::handle(const WindowClient::MouseUp& message)
@ -206,7 +206,7 @@ void GWindowServerConnection::handle(const WindowClient::MouseUp& message)
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseUp, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
Core::EventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseUp, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
}
void GWindowServerConnection::handle(const WindowClient::MouseMove& message)
@ -216,7 +216,7 @@ void GWindowServerConnection::handle(const WindowClient::MouseMove& message)
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseMove, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
Core::EventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseMove, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
}
void GWindowServerConnection::handle(const WindowClient::MouseDoubleClick& message)
@ -226,7 +226,7 @@ void GWindowServerConnection::handle(const WindowClient::MouseDoubleClick& messa
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseDoubleClick, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
Core::EventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseDoubleClick, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
}
void GWindowServerConnection::handle(const WindowClient::MouseWheel& message)
@ -236,7 +236,7 @@ void GWindowServerConnection::handle(const WindowClient::MouseWheel& message)
#endif
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseWheel, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
Core::EventLoop::current().post_event(*window, make<GMouseEvent>(GEvent::MouseWheel, message.mouse_position(), message.buttons(), to_gmousebutton(message.button()), message.modifiers(), message.wheel_delta()));
}
void GWindowServerConnection::handle(const WindowClient::MenuItemActivated& message)
@ -256,7 +256,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowStateChanged&
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowStateChangedEvent>(message.client_id(), message.window_id(), message.title(), message.rect(), message.is_active(), (GWindowType)message.window_type(), message.is_minimized()));
Core::EventLoop::current().post_event(*window, make<GWMWindowStateChangedEvent>(message.client_id(), message.window_id(), message.title(), message.rect(), message.is_active(), (GWindowType)message.window_type(), message.is_minimized()));
}
void GWindowServerConnection::handle(const WindowClient::WM_WindowRectChanged& message)
@ -265,7 +265,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowRectChanged& m
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowRectChangedEvent>(message.client_id(), message.window_id(), message.rect()));
Core::EventLoop::current().post_event(*window, make<GWMWindowRectChangedEvent>(message.client_id(), message.window_id(), message.rect()));
}
void GWindowServerConnection::handle(const WindowClient::WM_WindowIconBitmapChanged& message)
@ -274,7 +274,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowIconBitmapChan
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.icon_buffer_id(), message.icon_size()));
Core::EventLoop::current().post_event(*window, make<GWMWindowIconBitmapChangedEvent>(message.client_id(), message.window_id(), message.icon_buffer_id(), message.icon_size()));
}
void GWindowServerConnection::handle(const WindowClient::WM_WindowRemoved& message)
@ -283,7 +283,7 @@ void GWindowServerConnection::handle(const WindowClient::WM_WindowRemoved& messa
dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type);
#endif
if (auto* window = GWindow::from_window_id(message.wm_id()))
CEventLoop::current().post_event(*window, make<GWMWindowRemovedEvent>(message.client_id(), message.window_id()));
Core::EventLoop::current().post_event(*window, make<GWMWindowRemovedEvent>(message.client_id(), message.window_id()));
}
void GWindowServerConnection::handle(const WindowClient::ScreenRectChanged& message)
@ -304,7 +304,7 @@ void GWindowServerConnection::handle(const WindowClient::AsyncSetWallpaperFinish
void GWindowServerConnection::handle(const WindowClient::DragDropped& message)
{
if (auto* window = GWindow::from_window_id(message.window_id()))
CEventLoop::current().post_event(*window, make<GDropEvent>(message.mouse_position(), message.text(), message.data_type(), message.data()));
Core::EventLoop::current().post_event(*window, make<GDropEvent>(message.mouse_position(), message.text(), message.data_type(), message.data()));
}
void GWindowServerConnection::handle(const WindowClient::DragAccepted&)