mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 16:30:50 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
69
Libraries/LibCore/Notifier.cpp
Normal file
69
Libraries/LibCore/Notifier.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
Notifier::Notifier(int fd, Type type, EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
, m_fd(fd)
|
||||
, m_type(type)
|
||||
{
|
||||
set_enabled(true);
|
||||
}
|
||||
|
||||
Notifier::~Notifier()
|
||||
{
|
||||
set_enabled(false);
|
||||
}
|
||||
|
||||
void Notifier::set_enabled(bool enabled)
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return;
|
||||
if (enabled == m_is_enabled)
|
||||
return;
|
||||
m_is_enabled = enabled;
|
||||
if (enabled)
|
||||
Core::EventLoop::register_notifier({}, *this);
|
||||
else
|
||||
Core::EventLoop::unregister_notifier({}, *this);
|
||||
}
|
||||
|
||||
void Notifier::close()
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return;
|
||||
set_enabled(false);
|
||||
m_fd = -1;
|
||||
}
|
||||
|
||||
void Notifier::set_type(Type type)
|
||||
{
|
||||
if (m_is_enabled) {
|
||||
// FIXME: Directly communicate intent to the EventLoop.
|
||||
set_enabled(false);
|
||||
m_type = type;
|
||||
set_enabled(true);
|
||||
} else {
|
||||
m_type = type;
|
||||
}
|
||||
}
|
||||
|
||||
void Notifier::event(Core::Event& event)
|
||||
{
|
||||
if (event.type() == Core::Event::NotifierActivation) {
|
||||
if (on_activation)
|
||||
on_activation();
|
||||
return;
|
||||
}
|
||||
EventReceiver::event(event);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue