Pass cursors

feature/KASM-1883_x_proxy
Lauri Kasanen 4 years ago
parent 377d3e5629
commit 40d263368d

@ -1,8 +1,10 @@
include_directories(${X11_INCLUDE_DIR})
add_executable(kasmxproxy
xxhash.c
kasmxproxy.c)
target_link_libraries(kasmxproxy ${X11_LIBRARIES} ${X11_XTest_LIB} ${X11_Xrandr_LIB})
target_link_libraries(kasmxproxy ${X11_LIBRARIES} ${X11_XTest_LIB} ${X11_Xrandr_LIB}
${X11_Xcursor_LIB} ${X11_Xfixes_LIB})
install(TARGETS kasmxproxy DESTINATION ${BIN_DIR})

@ -26,10 +26,14 @@
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/XTest.h>
#include "xxhash.h"
#define min(a, b) ((a) < (b) ? (a) : (b))
static void help(const char name[]) {
@ -141,6 +145,10 @@ int main(int argc, char **argv) {
CurrentTime) != Success)
return 1;
XFixesCursorImage *cursor = NULL;
uint64_t cursorhash = 0;
Cursor xcursor = None;
const unsigned sleeptime = 1000 * 1000 / fps;
while (1) {
@ -255,6 +263,32 @@ int main(int argc, char **argv) {
}
}
// Cursors
cursor = XFixesGetCursorImage(appdisp);
uint64_t newhash = XXH64(cursor->pixels,
cursor->width * cursor->height * sizeof(unsigned long),
0);
if (cursorhash != newhash) {
if (cursorhash)
XFreeCursor(vncdisp, xcursor);
XcursorImage *converted = XcursorImageCreate(cursor->width, cursor->height);
converted->xhot = cursor->xhot;
converted->yhot = cursor->yhot;
unsigned i;
for (i = 0; i < cursor->width * cursor->height; i++) {
converted->pixels[i] = cursor->pixels[i];
}
xcursor = XcursorImageLoadCursor(vncdisp, converted);
XDefineCursor(vncdisp, vncroot, xcursor);
XcursorImageDestroy(converted);
cursorhash = newhash;
}
usleep(sleeptime);
}

@ -0,0 +1 @@
../../common/rfb/xxhash.c

@ -0,0 +1 @@
../../common/rfb/xxhash.h
Loading…
Cancel
Save