GDesktop.cpp 1.0 KB

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