mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:07:44 +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:
parent
7d579b04c5
commit
040a723f1f
30 changed files with 71 additions and 53 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue