WSClipboard.cpp 862 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <WindowServer/WSClipboard.h>
  2. WSClipboard& WSClipboard::the()
  3. {
  4. static WSClipboard* s_the;
  5. if (!s_the)
  6. s_the = new WSClipboard;
  7. return *s_the;
  8. }
  9. WSClipboard::WSClipboard()
  10. {
  11. }
  12. WSClipboard::~WSClipboard()
  13. {
  14. }
  15. void WSClipboard::on_message(WSMessage&)
  16. {
  17. }
  18. const byte* WSClipboard::data() const
  19. {
  20. if (!m_shared_buffer)
  21. return nullptr;
  22. return (const byte*)m_shared_buffer->data();
  23. }
  24. int WSClipboard::size() const
  25. {
  26. if (!m_shared_buffer)
  27. return 0;
  28. return m_contents_size;
  29. }
  30. void WSClipboard::clear()
  31. {
  32. m_shared_buffer = nullptr;
  33. m_contents_size = 0;
  34. }
  35. void WSClipboard::set_data(Retained<SharedBuffer>&& data, int contents_size)
  36. {
  37. dbgprintf("WSClipboard::set_data <- %p (%u bytes)\n", data->data(), contents_size);
  38. m_shared_buffer = move(data);
  39. m_contents_size = contents_size;
  40. }