2021-08-15 18:38:30 +00:00
|
|
|
#ifndef SUNSHINE_X11_GRAB
|
|
|
|
#define SUNSHINE_X11_GRAB
|
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
|
|
|
|
#include "sunshine/platform/common.h"
|
|
|
|
#include "sunshine/utility.h"
|
|
|
|
|
2021-09-14 09:58:21 +00:00
|
|
|
// X11 Display
|
|
|
|
extern "C" struct _XDisplay;
|
|
|
|
|
2021-08-15 18:38:30 +00:00
|
|
|
namespace egl {
|
|
|
|
class cursor_t;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace platf::x11 {
|
|
|
|
|
|
|
|
#ifdef SUNSHINE_BUILD_X11
|
|
|
|
struct cursor_ctx_raw_t;
|
|
|
|
void freeCursorCtx(cursor_ctx_raw_t *ctx);
|
2021-09-14 09:58:21 +00:00
|
|
|
void freeDisplay(_XDisplay *xdisplay);
|
2021-08-15 18:38:30 +00:00
|
|
|
|
|
|
|
using cursor_ctx_t = util::safe_ptr<cursor_ctx_raw_t, freeCursorCtx>;
|
2021-09-14 09:58:21 +00:00
|
|
|
using xdisplay_t = util::safe_ptr<_XDisplay, freeDisplay>;
|
2021-08-15 18:38:30 +00:00
|
|
|
|
|
|
|
class cursor_t {
|
|
|
|
public:
|
|
|
|
static std::optional<cursor_t> make();
|
|
|
|
|
|
|
|
void capture(egl::cursor_t &img);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Capture and blend the cursor into the image
|
|
|
|
*
|
|
|
|
* img <-- destination image
|
|
|
|
* offsetX, offsetY <--- Top left corner of the virtual screen
|
|
|
|
*/
|
|
|
|
void blend(img_t &img, int offsetX, int offsetY);
|
|
|
|
|
|
|
|
cursor_ctx_t ctx;
|
|
|
|
};
|
2021-09-14 09:58:21 +00:00
|
|
|
|
|
|
|
xdisplay_t make_display();
|
2021-08-15 18:38:30 +00:00
|
|
|
#else
|
2021-09-14 09:58:21 +00:00
|
|
|
// It's never something different from nullptr
|
|
|
|
util::safe_ptr<_XDisplay, std::default_delete<_XDisplay>>;
|
|
|
|
|
2021-08-15 18:38:30 +00:00
|
|
|
class cursor_t {
|
|
|
|
public:
|
|
|
|
static std::optional<cursor_t> make() { return std::nullopt; }
|
|
|
|
|
|
|
|
void capture(egl::cursor_t &) {}
|
|
|
|
void blend(img_t &, int, int) {}
|
|
|
|
};
|
2021-09-14 09:58:21 +00:00
|
|
|
|
|
|
|
xdisplay_t make_display() { return nullptr; }
|
2021-08-15 18:38:30 +00:00
|
|
|
#endif
|
|
|
|
} // namespace platf::x11
|
|
|
|
|
|
|
|
#endif
|