diff --git a/unix/kasmxproxy/CMakeLists.txt b/unix/kasmxproxy/CMakeLists.txt index ee846ef..7deecc4 100644 --- a/unix/kasmxproxy/CMakeLists.txt +++ b/unix/kasmxproxy/CMakeLists.txt @@ -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}) diff --git a/unix/kasmxproxy/kasmxproxy.c b/unix/kasmxproxy/kasmxproxy.c index 3fca6a6..050a613 100644 --- a/unix/kasmxproxy/kasmxproxy.c +++ b/unix/kasmxproxy/kasmxproxy.c @@ -26,10 +26,14 @@ #include #include #include +#include +#include #include #include #include +#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); } diff --git a/unix/kasmxproxy/xxhash.c b/unix/kasmxproxy/xxhash.c new file mode 120000 index 0000000..d70891c --- /dev/null +++ b/unix/kasmxproxy/xxhash.c @@ -0,0 +1 @@ +../../common/rfb/xxhash.c \ No newline at end of file diff --git a/unix/kasmxproxy/xxhash.h b/unix/kasmxproxy/xxhash.h new file mode 120000 index 0000000..52b76ef --- /dev/null +++ b/unix/kasmxproxy/xxhash.h @@ -0,0 +1 @@ +../../common/rfb/xxhash.h \ No newline at end of file