1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 20:35:06 +00:00
serenity/LibGUI/GDesktop.cpp
Andreas Kling c02c9880b6 AK: Add Eternal<T> and use it in various places.
This is useful for static locals that never need to be destroyed:

Thing& Thing::the()
{
    static Eternal<Thing> the;
    return the;
}

The object will be allocated in data segment memory and will never have
its destructor invoked.
2019-04-03 16:52:25 +02:00

33 lines
949 B
C++

#include <LibGUI/GDesktop.h>
#include <LibGUI/GEventLoop.h>
#include <AK/Eternal.h>
#include <string.h>
GDesktop& GDesktop::the()
{
static Eternal<GDesktop> the;
return the;
}
GDesktop::GDesktop()
{
}
bool GDesktop::set_wallpaper(const String& path)
{
WSAPI_ClientMessage message;
message.type = WSAPI_ClientMessage::Type::SetWallpaper;
ASSERT(path.length() < (int)sizeof(message.text));
strncpy(message.text, path.characters(), path.length());
message.text_length = path.length();
auto response = GEventLoop::current().sync_request(message, WSAPI_ServerMessage::Type::DidSetWallpaper);
return response.value;
}
String GDesktop::wallpaper() const
{
WSAPI_ClientMessage message;
message.type = WSAPI_ClientMessage::Type::GetWallpaper;
auto response = GEventLoop::current().sync_request(message, WSAPI_ServerMessage::Type::DidGetWallpaper);
return String(response.text, response.text_length);
}