2019-03-08 15:27:19 +03:00
|
|
|
#include <WindowServer/WSClipboard.h>
|
2019-04-03 17:50:08 +03:00
|
|
|
#include <AK/Eternal.h>
|
2019-03-08 15:27:19 +03:00
|
|
|
|
|
|
|
WSClipboard& WSClipboard::the()
|
|
|
|
{
|
2019-04-03 17:50:08 +03:00
|
|
|
static Eternal<WSClipboard> the;
|
|
|
|
return the;
|
2019-03-08 15:27:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
WSClipboard::WSClipboard()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WSClipboard::~WSClipboard()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-01 20:14:57 +03:00
|
|
|
void WSClipboard::on_message(const WSMessage&)
|
2019-03-08 15:27:19 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|