diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index 0f84679b847..4917a3cbad7 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -37,8 +37,8 @@ int main(int argc, char** argv) u8 buffer[4096]; piano_widget->fill_audio_buffer(buffer, sizeof(buffer)); audio->write(buffer, sizeof(buffer)); - GEventLoop::current().post_event(*piano_widget, make(0)); - GEventLoop::wake(); + CEventLoop::current().post_event(*piano_widget, make(0)); + CEventLoop::wake(); } }); sound_thread.start(); diff --git a/Libraries/LibCore/CEventLoop.cpp b/Libraries/LibCore/CEventLoop.cpp index 68ef3bd753d..17be63d0203 100644 --- a/Libraries/LibCore/CEventLoop.cpp +++ b/Libraries/LibCore/CEventLoop.cpp @@ -181,6 +181,7 @@ CEventLoop& CEventLoop::current() void CEventLoop::quit(int code) { + dbg() << "CEventLoop::quit(" << code << ")"; m_exit_requested = true; m_exit_code = code; } diff --git a/Libraries/LibCore/CEventLoop.h b/Libraries/LibCore/CEventLoop.h index 16538e2c48d..d4de3fc211c 100644 --- a/Libraries/LibCore/CEventLoop.h +++ b/Libraries/LibCore/CEventLoop.h @@ -18,7 +18,7 @@ class CNotifier; class CEventLoop { public: CEventLoop(); - virtual ~CEventLoop(); + ~CEventLoop(); int exec(); diff --git a/Libraries/LibGUI/GApplication.cpp b/Libraries/LibGUI/GApplication.cpp index ca2c0b061d2..770204e1a9b 100644 --- a/Libraries/LibGUI/GApplication.cpp +++ b/Libraries/LibGUI/GApplication.cpp @@ -21,7 +21,8 @@ GApplication::GApplication(int argc, char** argv) (void)argv; ASSERT(!s_the); s_the = this; - m_event_loop = make(); + m_event_loop = make(); + GWindowServerConnection::the(); } GApplication::~GApplication() diff --git a/Libraries/LibGUI/GApplication.h b/Libraries/LibGUI/GApplication.h index 4b571cc6da7..d217de75d47 100644 --- a/Libraries/LibGUI/GApplication.h +++ b/Libraries/LibGUI/GApplication.h @@ -5,8 +5,8 @@ #include #include +class CEventLoop; class GAction; -class GEventLoop; class GKeyEvent; class GMenuBar; class GWindow; @@ -36,7 +36,7 @@ public: void did_delete_last_window(Badge); private: - OwnPtr m_event_loop; + OwnPtr m_event_loop; OwnPtr m_menubar; HashMap m_global_shortcut_actions; class TooltipWindow; diff --git a/Libraries/LibGUI/GDialog.cpp b/Libraries/LibGUI/GDialog.cpp index a3cd4a5e0f8..1db0fbadf47 100644 --- a/Libraries/LibGUI/GDialog.cpp +++ b/Libraries/LibGUI/GDialog.cpp @@ -1,12 +1,10 @@ #include #include -#include GDialog::GDialog(CObject* parent) : GWindow(parent) { set_modal(true); - } GDialog::~GDialog() @@ -16,7 +14,7 @@ GDialog::~GDialog() int GDialog::exec() { ASSERT(!m_event_loop); - m_event_loop = make(); + m_event_loop = make(); auto new_rect = rect(); if (parent() && parent()->is_window()) { auto& parent_window = *static_cast(parent()); @@ -47,4 +45,3 @@ void GDialog::close() GWindow::close(); m_event_loop->quit(ExecCancel); } - diff --git a/Libraries/LibGUI/GDialog.h b/Libraries/LibGUI/GDialog.h index 6b3bbb7f04e..581d2b406ee 100644 --- a/Libraries/LibGUI/GDialog.h +++ b/Libraries/LibGUI/GDialog.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include class GDialog : public GWindow { @@ -25,6 +25,6 @@ protected: explicit GDialog(CObject* parent); private: - OwnPtr m_event_loop; + OwnPtr m_event_loop; int m_result { ExecAborted }; }; diff --git a/Libraries/LibGUI/GEventLoop.cpp b/Libraries/LibGUI/GEventLoop.cpp index 2d3c5e3d5d3..2736a2a3ad0 100644 --- a/Libraries/LibGUI/GEventLoop.cpp +++ b/Libraries/LibGUI/GEventLoop.cpp @@ -43,17 +43,6 @@ void GWindowServerConnection::handshake() handle_greeting(response); } -GEventLoop::GEventLoop() -{ - // ensure the WS connection is up, as our users might be expecting it to be - // valid very early (via e.g. GDesktop) :) - GWindowServerConnection::the(); -} - -GEventLoop::~GEventLoop() -{ -} - void GWindowServerConnection::handle_paint_event(const WSAPI_ServerMessage& event, GWindow& window, const ByteBuffer& extra_data) { #ifdef GEVENTLOOP_DEBUG diff --git a/Libraries/LibGUI/GEventLoop.h b/Libraries/LibGUI/GEventLoop.h index 8171300216e..522dcb9bcd7 100644 --- a/Libraries/LibGUI/GEventLoop.h +++ b/Libraries/LibGUI/GEventLoop.h @@ -33,14 +33,3 @@ private: void handle_wm_event(const WSAPI_ServerMessage&, GWindow&); void handle_greeting(WSAPI_ServerMessage&); }; - -class GEventLoop final : public CEventLoop { -public: - GEventLoop(); - virtual ~GEventLoop() override; - - static GEventLoop& current() { return static_cast(CEventLoop::current()); } - -private: - void process_unprocessed_bundles(); -}; diff --git a/Libraries/LibGUI/GWindow.cpp b/Libraries/LibGUI/GWindow.cpp index 59fe675d070..c05f7fe4b4d 100644 --- a/Libraries/LibGUI/GWindow.cpp +++ b/Libraries/LibGUI/GWindow.cpp @@ -497,12 +497,12 @@ void GWindow::set_focused_widget(GWidget* widget) if (m_focused_widget == widget) return; if (m_focused_widget) { - GEventLoop::current().post_event(*m_focused_widget, make(GEvent::FocusOut)); + CEventLoop::current().post_event(*m_focused_widget, make(GEvent::FocusOut)); m_focused_widget->update(); } m_focused_widget = widget ? widget->make_weak_ptr() : nullptr; if (m_focused_widget) { - GEventLoop::current().post_event(*m_focused_widget, make(GEvent::FocusIn)); + CEventLoop::current().post_event(*m_focused_widget, make(GEvent::FocusIn)); m_focused_widget->update(); } } @@ -567,12 +567,12 @@ void GWindow::set_hovered_widget(GWidget* widget) return; if (m_hovered_widget) - GEventLoop::current().post_event(*m_hovered_widget, make(GEvent::Leave)); + CEventLoop::current().post_event(*m_hovered_widget, make(GEvent::Leave)); m_hovered_widget = widget ? widget->make_weak_ptr() : nullptr; if (m_hovered_widget) - GEventLoop::current().post_event(*m_hovered_widget, make(GEvent::Enter)); + CEventLoop::current().post_event(*m_hovered_widget, make(GEvent::Enter)); } void GWindow::set_current_backing_bitmap(GraphicsBitmap& bitmap, bool flush_immediately) diff --git a/Userland/copy.cpp b/Userland/copy.cpp index ddad0a5ffae..2887bec3fcb 100644 --- a/Userland/copy.cpp +++ b/Userland/copy.cpp @@ -1,10 +1,12 @@ #include #include #include +#include #include #include -#include #include +#include +#include struct Options { String data; @@ -86,7 +88,7 @@ int main(int argc, char* argv[]) { Options options = parse_options(argc, argv); - new GEventLoop; + CEventLoop loop; GClipboard& clipboard = GClipboard::the(); clipboard.set_data(options.data, options.type); diff --git a/Userland/paste.cpp b/Userland/paste.cpp index 2b5acce5d36..947463dd37b 100644 --- a/Userland/paste.cpp +++ b/Userland/paste.cpp @@ -1,7 +1,9 @@ #include +#include #include -#include #include +#include +#include struct Options { bool print_type { false }; @@ -62,7 +64,7 @@ int main(int argc, char* argv[]) { Options options = parse_options(argc, argv); - new GEventLoop; + CEventLoop loop; GClipboard& clipboard = GClipboard::the(); auto data_and_type = clipboard.data_and_type();