Add --cursor argument
This commit is contained in:
parent
86b593b754
commit
ffa970ef7e
2 changed files with 40 additions and 0 deletions
|
@ -48,6 +48,7 @@ const struct option *gamescope_options = (struct option[]){
|
||||||
{ "prefer-output", no_argument, nullptr, 'O' },
|
{ "prefer-output", no_argument, nullptr, 'O' },
|
||||||
|
|
||||||
// steamcompmgr options
|
// steamcompmgr options
|
||||||
|
{ "cursor", required_argument, nullptr, 'a' },
|
||||||
{ "ready-fd", required_argument, nullptr, 'R' },
|
{ "ready-fd", required_argument, nullptr, 'R' },
|
||||||
{ "stats-path", required_argument, nullptr, 'T' },
|
{ "stats-path", required_argument, nullptr, 'T' },
|
||||||
{ "hide-cursor-delay", required_argument, nullptr, 'C' },
|
{ "hide-cursor-delay", required_argument, nullptr, 'C' },
|
||||||
|
|
|
@ -79,6 +79,9 @@
|
||||||
#include "pipewire.hpp"
|
#include "pipewire.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include "../subprojects/stb/stb_image.h"
|
||||||
|
|
||||||
#define GPUVIS_TRACE_IMPLEMENTATION
|
#define GPUVIS_TRACE_IMPLEMENTATION
|
||||||
#include "gpuvis_trace_utils.h"
|
#include "gpuvis_trace_utils.h"
|
||||||
|
|
||||||
|
@ -3407,6 +3410,32 @@ dispatch_nudge( int fd )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct rgba_t
|
||||||
|
{
|
||||||
|
uint8_t r,g,b,a;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool
|
||||||
|
load_mouse_cursor( MouseCursor *cursor, const char *path )
|
||||||
|
{
|
||||||
|
int w, h, channels;
|
||||||
|
rgba_t* data = (rgba_t*)stbi_load(path, &w, &h, &channels, STBI_rgb_alpha);
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Failed to open/load cursor file\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::transform(data, data + w * h, data, [](rgba_t x) {
|
||||||
|
if (x.a == 0)
|
||||||
|
return rgba_t{};
|
||||||
|
return rgba_t{ x.b, x.g, x.r, x.a };
|
||||||
|
});
|
||||||
|
|
||||||
|
// Data is freed by XDestroyImage in setCursorImage.
|
||||||
|
return cursor->setCursorImage((char*)data, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
enum event_type {
|
enum event_type {
|
||||||
EVENT_X11,
|
EVENT_X11,
|
||||||
EVENT_VBLANK,
|
EVENT_VBLANK,
|
||||||
|
@ -3414,6 +3443,8 @@ enum event_type {
|
||||||
EVENT_COUNT // keep last
|
EVENT_COUNT // keep last
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* g_customCursorPath = nullptr;
|
||||||
|
|
||||||
void
|
void
|
||||||
steamcompmgr_main (int argc, char **argv)
|
steamcompmgr_main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -3471,6 +3502,9 @@ steamcompmgr_main (int argc, char **argv)
|
||||||
case 'x':
|
case 'x':
|
||||||
useXRes = False;
|
useXRes = False;
|
||||||
break;
|
break;
|
||||||
|
case 'a':
|
||||||
|
g_customCursorPath = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3635,6 +3669,11 @@ steamcompmgr_main (int argc, char **argv)
|
||||||
XF86VidModeLockModeSwitch(dpy, scr, True);
|
XF86VidModeLockModeSwitch(dpy, scr, True);
|
||||||
|
|
||||||
std::unique_ptr<MouseCursor> cursor(new MouseCursor(dpy));
|
std::unique_ptr<MouseCursor> cursor(new MouseCursor(dpy));
|
||||||
|
if (g_customCursorPath)
|
||||||
|
{
|
||||||
|
if (!load_mouse_cursor(cursor.get(), g_customCursorPath))
|
||||||
|
fprintf(stderr, "Failed to load mouse cursor: %s.\n", g_customCursorPath);
|
||||||
|
}
|
||||||
|
|
||||||
gamesRunningCount = get_prop(dpy, root, gamesRunningAtom, 0);
|
gamesRunningCount = get_prop(dpy, root, gamesRunningAtom, 0);
|
||||||
overscanScaleRatio = get_prop(dpy, root, screenScaleAtom, 0xFFFFFFFF) / (double)0xFFFFFFFF;
|
overscanScaleRatio = get_prop(dpy, root, screenScaleAtom, 0xFFFFFFFF) / (double)0xFFFFFFFF;
|
||||||
|
|
Loading…
Reference in a new issue