ladybird/Libraries/LibCore/Event.h
ayeteadoe 4fb1ba0193 LibCore: Remove unused NotifierActivationEvent fd() and type() methods
In 11b8bbe one thing that was claimed was that we now properly set the
Notifier's actual fd on the NotifierActivationEvent. It turns out that
claim was false because a crucial step was forgotten: actually set the
m_notifier_fd when registering. Despite that mistake, it ultimately was
irrelevant as the methods on NotifierActivationEvent are currently
unused code. We were posting the event to the correct Notifier receiver
so the on_activation was still getting invoked.

Given they are unused, NotifierActivationEvent can be defined the same
way as TimerEvent is, where we just pass the event type enum to the
Event base class. Additionally, NotificationType can be moved to
the Notifier header as this enum is now always used in the context of
creating or using a Notifier instance.
2025-11-22 09:47:25 +01:00

84 lines
1.7 KiB
C++

/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/EnumBits.h>
#include <AK/Function.h>
#include <AK/Types.h>
#include <AK/WeakPtr.h>
#include <LibCore/DeferredInvocationContext.h>
#include <LibCore/Forward.h>
namespace Core {
class Event {
public:
enum Type : u8 {
Invalid = 0,
Quit,
Timer,
NotifierActivation,
DeferredInvoke,
};
Event() = default;
explicit Event(unsigned type)
: m_type(type)
{
}
virtual ~Event() = default;
unsigned type() const { return m_type; }
bool is_accepted() const { return m_accepted; }
void accept() { m_accepted = true; }
void ignore() { m_accepted = false; }
private:
unsigned m_type { Type::Invalid };
bool m_accepted { true };
};
class DeferredInvocationEvent : public Event {
friend class EventLoop;
friend class ThreadEventQueue;
public:
DeferredInvocationEvent(NonnullRefPtr<DeferredInvocationContext> context, Function<void()> invokee)
: Event(Event::Type::DeferredInvoke)
, m_context(move(context))
, m_invokee(move(invokee))
{
}
private:
NonnullRefPtr<DeferredInvocationContext> m_context;
Function<void()> m_invokee;
};
class TimerEvent final : public Event {
public:
explicit TimerEvent()
: Event(Event::Timer)
{
}
~TimerEvent() = default;
};
class NotifierActivationEvent final : public Event {
public:
explicit NotifierActivationEvent()
: Event(Event::NotifierActivation)
{
}
~NotifierActivationEvent() = default;
};
}