mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
c02c9880b6
This is useful for static locals that never need to be destroyed: Thing& Thing::the() { static Eternal<Thing> the; return the; } The object will be allocated in data segment memory and will never have its destructor invoked.
47 lines
846 B
C++
47 lines
846 B
C++
#include <WindowServer/WSClipboard.h>
|
|
#include <AK/Eternal.h>
|
|
|
|
WSClipboard& WSClipboard::the()
|
|
{
|
|
static Eternal<WSClipboard> the;
|
|
return the;
|
|
}
|
|
|
|
WSClipboard::WSClipboard()
|
|
{
|
|
}
|
|
|
|
WSClipboard::~WSClipboard()
|
|
{
|
|
}
|
|
|
|
void WSClipboard::on_message(const WSMessage&)
|
|
{
|
|
}
|
|
|
|
const byte* WSClipboard::data() const
|
|
{
|
|
if (!m_shared_buffer)
|
|
return nullptr;
|
|
return (const byte*)m_shared_buffer->data();
|
|
}
|
|
|
|
int WSClipboard::size() const
|
|
{
|
|
if (!m_shared_buffer)
|
|
return 0;
|
|
return m_contents_size;
|
|
}
|
|
|
|
void WSClipboard::clear()
|
|
{
|
|
m_shared_buffer = nullptr;
|
|
m_contents_size = 0;
|
|
}
|
|
|
|
void WSClipboard::set_data(Retained<SharedBuffer>&& data, int contents_size)
|
|
{
|
|
dbgprintf("WSClipboard::set_data <- %p (%u bytes)\n", data->data(), contents_size);
|
|
m_shared_buffer = move(data);
|
|
m_contents_size = contents_size;
|
|
}
|