Use bundled cursor if cursor fails to load

This commit is contained in:
dec05eba
2025-01-27 17:35:35 +01:00
parent 81cb8f539f
commit 309cc3425b
3 changed files with 14 additions and 3 deletions

View File

@@ -39,7 +39,7 @@ This program has to grab all keyboards and create a virtual keyboard (`gsr-ui vi
This might cause issues for you if you use input remapping software. To workaround this you can go into settings and select "Only grab virtual devices" This might cause issues for you if you use input remapping software. To workaround this you can go into settings and select "Only grab virtual devices"
# License # License
This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`. This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`. `images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `Creative Commons Attribution-Share Alike 3.0`.
# Demo # Demo
[![Click here to watch a demo video on youtube](https://img.youtube.com/vi/SOqXusCTXXA/0.jpg)](https://www.youtube.com/watch?v=SOqXusCTXXA) [![Click here to watch a demo video on youtube](https://img.youtube.com/vi/SOqXusCTXXA/0.jpg)](https://www.youtube.com/watch?v=SOqXusCTXXA)

BIN
images/default.cur Normal file

Binary file not shown.

View File

@@ -774,15 +774,26 @@ namespace gsr {
XcursorImage *cursor_image = nullptr; XcursorImage *cursor_image = nullptr;
for(int cursor_size_test : {cursor_size, 24}) { for(int cursor_size_test : {cursor_size, 24}) {
for(const char *cursor_theme_test : {cursor_theme, "default"}) { for(const char *cursor_theme_test : {cursor_theme, "default", "Adwaita"}) {
for(unsigned int shape : {XC_left_ptr, XC_arrow}) { for(unsigned int shape : {XC_left_ptr, XC_arrow}) {
cursor_image = XcursorShapeLoadImage(shape, cursor_theme_test, cursor_size_test); cursor_image = XcursorShapeLoadImage(shape, cursor_theme_test, cursor_size_test);
if(cursor_image) if(cursor_image)
break; goto done;
} }
} }
} }
done:
if(!cursor_image) {
fprintf(stderr, "Error: failed to get cursor, loading bundled default cursor instead\n");
const std::string default_cursor_path = resources_path + "images/default.cur";
for(int cursor_size_test : {cursor_size, 24}) {
cursor_image = XcursorFilenameLoadImage(default_cursor_path.c_str(), cursor_size_test);
if(cursor_image)
break;
}
}
if(!cursor_image) { if(!cursor_image) {
fprintf(stderr, "Error: failed to get cursor\n"); fprintf(stderr, "Error: failed to get cursor\n");
XFixesShowCursor(xi_display, DefaultRootWindow(xi_display)); XFixesShowCursor(xi_display, DefaultRootWindow(xi_display));