GDesktop.cpp 968 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <LibGUI/GDesktop.h>
  2. #include <LibGUI/GEventLoop.h>
  3. #include <string.h>
  4. GDesktop& GDesktop::the()
  5. {
  6. static GDesktop* s_the;
  7. if (!s_the)
  8. s_the = new GDesktop;
  9. return *s_the;
  10. }
  11. GDesktop::GDesktop()
  12. {
  13. }
  14. bool GDesktop::set_wallpaper(const String& path)
  15. {
  16. WSAPI_ClientMessage message;
  17. message.type = WSAPI_ClientMessage::Type::SetWallpaper;
  18. ASSERT(path.length() < (int)sizeof(message.text));
  19. strncpy(message.text, path.characters(), path.length());
  20. message.text_length = path.length();
  21. auto response = GEventLoop::current().sync_request(message, WSAPI_ServerMessage::Type::DidSetWallpaper);
  22. return response.value;
  23. }
  24. String GDesktop::wallpaper() const
  25. {
  26. WSAPI_ClientMessage message;
  27. message.type = WSAPI_ClientMessage::Type::GetWallpaper;
  28. auto response = GEventLoop::current().sync_request(message, WSAPI_ServerMessage::Type::DidGetWallpaper);
  29. return String(response.text, response.text_length);
  30. }