1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:27:45 +00:00

Applications: Create a display properties manager

An interactive application to modify the current display settings, such as
the current wallpaper as well as the screen resolution. Currently we're
adding the resolutions ourselves, because there's currently no way to
detect was resolutions the current display adapter supports (or at least
I can't see one... Maybe VBE does and I'm stupid). It even comes with
a very nice template'd `ItemList` that can support a vector of any type,
which makes life much simpler.
This commit is contained in:
Jesse Buhagiar 2019-09-03 21:45:02 +10:00 committed by Andreas Kling
parent af14b8dc59
commit ecbc0322c1
15 changed files with 329 additions and 1 deletions

View file

@ -109,6 +109,7 @@ struct WSAPI_ServerMessage {
DidSetWindowBackingStore,
DidSetWallpaper,
DidGetWallpaper,
DidSetResolution,
DidSetWindowHasAlphaChannel,
ScreenRectChanged,
@ -224,6 +225,7 @@ struct WSAPI_ClientMessage {
Greeting,
SetWallpaper,
GetWallpaper,
SetResolution,
SetWindowOverrideCursor,
WM_SetActiveWindow,
WM_SetWindowMinimized,
@ -260,6 +262,9 @@ struct WSAPI_ClientMessage {
bool minimized;
WSAPI_Point position;
} wm;
struct {
WSAPI_Size resolution;
} wm_conf;
struct {
int menubar_id;
int menu_id;

View file

@ -289,6 +289,9 @@ bool WSClientConnection::handle_message(const WSAPI_ClientMessage& message, cons
case WSAPI_ClientMessage::Type::GetWallpaper:
CEventLoop::current().post_event(*this, make<WSAPIGetWallpaperRequest>(client_id()));
break;
case WSAPI_ClientMessage::Type::SetResolution:
CEventLoop::current().post_event(*this, make<WSAPISetResolutionRequest>(client_id(), message.wm_conf.resolution.width, message.wm_conf.resolution.height));
break;
case WSAPI_ClientMessage::Type::SetWindowOverrideCursor:
CEventLoop::current().post_event(*this, make<WSAPISetWindowOverrideCursorRequest>(client_id(), message.window_id, (WSStandardCursor)message.cursor.cursor));
break;
@ -557,6 +560,15 @@ void WSClientConnection::handle_request(const WSAPIGetWallpaperRequest&)
post_message(response);
}
void WSClientConnection::handle_request(const WSAPISetResolutionRequest& request)
{
WSWindowManager::the().set_resolution(request.resolution().width(), request.resolution().height());
WSAPI_ServerMessage response;
response.type = WSAPI_ServerMessage::Type::DidSetResolution;
response.value = true;
post_message(response);
}
void WSClientConnection::handle_request(const WSAPISetWindowTitleRequest& request)
{
int window_id = request.window_id();
@ -984,6 +996,8 @@ void WSClientConnection::on_request(const WSAPIClientRequest& request)
return handle_request(static_cast<const WSAPISetWallpaperRequest&>(request));
case WSEvent::APIGetWallpaperRequest:
return handle_request(static_cast<const WSAPIGetWallpaperRequest&>(request));
case WSEvent::APISetResolutionRequest:
return handle_request(static_cast<const WSAPISetResolutionRequest&>(request));
case WSEvent::APISetWindowOverrideCursorRequest:
return handle_request(static_cast<const WSAPISetWindowOverrideCursorRequest&>(request));
case WSEvent::WMAPISetActiveWindowRequest:

View file

@ -73,6 +73,7 @@ private:
void handle_request(const WSAPISetWindowOpacityRequest&);
void handle_request(const WSAPISetWallpaperRequest&);
void handle_request(const WSAPIGetWallpaperRequest&);
void handle_request(const WSAPISetResolutionRequest&);
void handle_request(const WSAPISetWindowOverrideCursorRequest&);
void handle_request(const WSWMAPISetActiveWindowRequest&);
void handle_request(const WSWMAPISetWindowMinimizedRequest&);

View file

@ -300,6 +300,8 @@ void WSCompositor::set_resolution(int desired_width, int desired_height)
return;
m_wallpaper_path = {};
m_wallpaper = nullptr;
// Make sure it's impossible to set an invalid resolution
ASSERT(desired_width >= 640 && desired_height >= 480);
WSScreen::the().set_resolution(desired_width, desired_height);
init_bitmaps();
compose();

View file

@ -7,6 +7,7 @@
#include <LibDraw/Point.h>
#include <LibDraw/Rect.h>
#include <WindowServer/WSCursor.h>
#include <WindowServer/WSAPITypes.h>
#include <WindowServer/WSWindowType.h>
class WSEvent : public CEvent {
@ -60,6 +61,7 @@ public:
APIGetClipboardContentsRequest,
APISetWallpaperRequest,
APIGetWallpaperRequest,
APISetResolutionRequest,
APISetWindowOverrideCursorRequest,
APISetWindowHasAlphaChannelRequest,
APIMoveWindowToFrontRequest,
@ -441,6 +443,20 @@ public:
}
};
class WSAPISetResolutionRequest final : public WSAPIClientRequest {
public:
explicit WSAPISetResolutionRequest(int client_id, int width, int height)
: WSAPIClientRequest(WSEvent::APISetResolutionRequest, client_id),
m_resolution(width, height)
{
}
Size resolution() const { return m_resolution; }
private:
Size m_resolution;
};
class WSAPISetWindowTitleRequest final : public WSAPIClientRequest {
public:
explicit WSAPISetWindowTitleRequest(int client_id, int window_id, const String& title)