GDesktop.cpp 862 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <LibGUI/GDesktop.h>
  2. #include <LibGUI/GWindowServerConnection.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. GDesktop& GDesktop::the()
  6. {
  7. static GDesktop* the;
  8. if (!the)
  9. the = new GDesktop;
  10. return *the;
  11. }
  12. GDesktop::GDesktop()
  13. {
  14. }
  15. void GDesktop::did_receive_screen_rect(Badge<GWindowServerConnection>, const Rect& rect)
  16. {
  17. if (m_rect == rect)
  18. return;
  19. m_rect = rect;
  20. if (on_rect_change)
  21. on_rect_change(rect);
  22. }
  23. bool GDesktop::set_wallpaper(const StringView& path)
  24. {
  25. GWindowServerConnection::the().post_message(WindowServer::AsyncSetWallpaper(path));
  26. return GWindowServerConnection::the().wait_for_specific_message<WindowClient::AsyncSetWallpaperFinished>()->success();
  27. }
  28. String GDesktop::wallpaper() const
  29. {
  30. return GWindowServerConnection::the().send_sync<WindowServer::GetWallpaper>()->path();
  31. }