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

WindowServer: Add support for cursor themes

Now you can specify a CursorTheme key in /etc/WindowServer.ini. The
cursors are loaded from /res/cursor-themes/<name> directory. This
directory contains a Config.ini file with format similar to previous
Cursor section, except it uses relative paths.

This commit adds also Default theme, which uses cursors being
previously in /res/cursors.

The WidgetGallery is updated to match the new cursor path format.
This commit is contained in:
Maciej Zygmanowski 2021-08-01 17:22:44 +02:00 committed by Andreas Kling
parent 7d579b04c5
commit 040a723f1f
30 changed files with 71 additions and 53 deletions

View file

@ -10,6 +10,7 @@
#include <AK/Vector.h>
#include <LibCore/DirIterator.h>
#include <LibGUI/Model.h>
#include <LibGUI/WindowServerConnection.h>
class MouseCursorModel final : public GUI::Model {
public:
@ -57,17 +58,19 @@ public:
{
m_cursors.clear();
Core::DirIterator iterator("/res/cursors", Core::DirIterator::Flags::SkipDots);
Core::DirIterator iterator(String::formatted("/res/cursor-themes/{}", GUI::WindowServerConnection::the().get_cursor_theme()), Core::DirIterator::Flags::SkipDots);
while (iterator.has_next()) {
auto path = iterator.next_full_path();
if (path.ends_with(".ini"))
continue;
if (path.contains("2x"))
continue;
Cursor cursor;
cursor.path = move(path);
cursor.bitmap = Gfx::Bitmap::try_load_from_file(cursor.path);
auto filename_split = cursor.path.split('/');
cursor.name = filename_split[2];
cursor.name = filename_split[3];
m_cursors.append(move(cursor));
}