[fix] restore Linux cursor state build compatibility

This commit is contained in:
dijunkun
2026-08-25 22:59:45 +08:00
parent 0653a95250
commit d2b1329eca
+8 -9
View File
@@ -56,6 +56,12 @@ bool CursorStateProvider::Sample(CursorState* state) {
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h> #include <X11/extensions/Xfixes.h>
// X11/X.h defines CursorShape as a protocol request opcode, which conflicts
// with CrossDesk's CursorShape enum.
#ifdef CursorShape
#undef CursorShape
#endif
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <string> #include <string>
@@ -158,17 +164,10 @@ CursorStateProvider::~CursorStateProvider() = default;
bool CursorStateProvider::Sample(CursorState* state) { bool CursorStateProvider::Sample(CursorState* state) {
if (!state || !impl_ || !impl_->display) return false; if (!state || !impl_ || !impl_->display) return false;
XFixesCursorImage* image = XFixesGetCursorImageAndName(impl_->display); XFixesCursorImage* image = XFixesGetCursorImage(impl_->display);
if (!image) return false; if (!image) return false;
std::string name; const std::string name = image->name ? image->name : "";
if (image->atom != None) {
char* atom_name = XGetAtomName(impl_->display, image->atom);
if (atom_name) {
name = atom_name;
XFree(atom_name);
}
}
state->seq = 0; state->seq = 0;
state->visible = CursorHasVisiblePixel(*image); state->visible = CursorHasVisiblePixel(*image);