Pass cursors
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
include_directories(${X11_INCLUDE_DIR})
|
include_directories(${X11_INCLUDE_DIR})
|
||||||
|
|
||||||
add_executable(kasmxproxy
|
add_executable(kasmxproxy
|
||||||
|
xxhash.c
|
||||||
kasmxproxy.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})
|
install(TARGETS kasmxproxy DESTINATION ${BIN_DIR})
|
||||||
|
|||||||
@@ -26,10 +26,14 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/Xcursor/Xcursor.h>
|
||||||
|
#include <X11/extensions/Xfixes.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
#include <X11/extensions/XShm.h>
|
#include <X11/extensions/XShm.h>
|
||||||
#include <X11/extensions/XTest.h>
|
#include <X11/extensions/XTest.h>
|
||||||
|
|
||||||
|
#include "xxhash.h"
|
||||||
|
|
||||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
static void help(const char name[]) {
|
static void help(const char name[]) {
|
||||||
@@ -141,6 +145,10 @@ int main(int argc, char **argv) {
|
|||||||
CurrentTime) != Success)
|
CurrentTime) != Success)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
XFixesCursorImage *cursor = NULL;
|
||||||
|
uint64_t cursorhash = 0;
|
||||||
|
Cursor xcursor = None;
|
||||||
|
|
||||||
const unsigned sleeptime = 1000 * 1000 / fps;
|
const unsigned sleeptime = 1000 * 1000 / fps;
|
||||||
|
|
||||||
while (1) {
|
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);
|
usleep(sleeptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
unix/kasmxproxy/xxhash.c
Symbolic link
1
unix/kasmxproxy/xxhash.c
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../common/rfb/xxhash.c
|
||||||
1
unix/kasmxproxy/xxhash.h
Symbolic link
1
unix/kasmxproxy/xxhash.h
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../common/rfb/xxhash.h
|
||||||
Reference in New Issue
Block a user