summaryrefslogtreecommitdiffstats
path: root/x11vnc/xwrappers.c
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/xwrappers.c')
-rw-r--r--x11vnc/xwrappers.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/x11vnc/xwrappers.c b/x11vnc/xwrappers.c
index 667957e..bb73565 100644
--- a/x11vnc/xwrappers.c
+++ b/x11vnc/xwrappers.c
@@ -347,7 +347,15 @@ XImage *XCreateImage_wr(Display *disp, Visual *visual, unsigned int depth,
xi = (XImage *) malloc(sizeof(XImage));
memset(xi, 0, sizeof(XImage));
xi->depth = depth;
- xi->bits_per_pixel = (depth == 24) ? 32 : depth;
+ if (depth >= 24) {
+ xi->bits_per_pixel = 32;
+ } else if (depth > 16) {
+ xi->bits_per_pixel = 24;
+ } else if (depth > 8) {
+ xi->bits_per_pixel = 16;
+ } else {
+ xi->bits_per_pixel = 8;
+ }
xi->format = format;
xi->xoffset = offset;
xi->data = data;
@@ -706,7 +714,7 @@ void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) {
src = snap->data + snap->bytes_per_line*y + pixelsize*x;
dst = dest->data;
-if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d\n", snap->bytes_per_line, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x);
+if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d bpp: %d pixelsize: %d\n", snap->bytes_per_line, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x, bpp, pixelsize);
for (line = 0; line < h; line++) {
memcpy(dst, src, w * pixelsize);
@@ -725,7 +733,7 @@ if (db) fprintf(stderr, "snap->bytes_per_line: %d, dest->bytes_per_line: %d, w:
src = raw_fb_addr + raw_fb_offset + bpl*y + pixelsize*x;
dst = dest->data;
-if (db) fprintf(stderr, "bpl: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d\n", bpl, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x);
+if (db) fprintf(stderr, "bpl: %d, dest->bytes_per_line: %d, w: %d h: %d dpy_x: %d wdpy_x: %d cdpy_x: %d bpp: %d pixelsize: %d\n", bpl, dest->bytes_per_line, w, h, dpy_x, wdpy_x, cdpy_x, bpp, pixelsize);
for (line = 0; line < h; line++) {
memcpy(dst, src, w * pixelsize);
@@ -878,6 +886,7 @@ void XTRAP_FakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
unsigned long delay) {
static int first = 1;
+ int regrab = 0;
RAWFB_RET_VOID
@@ -903,11 +912,16 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
if (grab_kbd) {
XUngrabKeyboard(dpy, CurrentTime);
+ regrab = 1;
+ }
+ if (grab_ptr && ungrab_both) {
+ XUngrabPointer(dpy, CurrentTime);
+ regrab = 1;
}
if (xtrap_input) {
XTRAP_FakeKeyEvent_wr(dpy, key, down, delay);
- if (grab_kbd) {
+ if (regrab) {
adjust_grabs(1, 1);
}
return;
@@ -923,7 +937,7 @@ void XTestFakeKeyEvent_wr(Display* dpy, KeyCode key, Bool down,
}
#if LIBVNCSERVER_HAVE_XTEST
XTestFakeKeyEvent(dpy, key, down, delay);
- if (grab_kbd) {
+ if (regrab) {
adjust_grabs(1, 1);
}
if (debug_keyboard) {
@@ -964,6 +978,7 @@ void XTRAP_FakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
unsigned long delay) {
+ int regrab = 0;
RAWFB_RET_VOID
#if NO_X11
@@ -974,11 +989,16 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
if (grab_ptr) {
XUngrabPointer(dpy, CurrentTime);
+ regrab = 1;
+ }
+ if (grab_kbd && ungrab_both) {
+ XUngrabKeyboard(dpy, CurrentTime);
+ regrab = 1;
}
if (xtrap_input) {
XTRAP_FakeButtonEvent_wr(dpy, button, is_press, delay);
- if (grab_ptr) {
+ if (regrab) {
adjust_grabs(1, 1);
}
return;
@@ -995,7 +1015,7 @@ void XTestFakeButtonEvent_wr(Display* dpy, unsigned int button, Bool is_press,
#if LIBVNCSERVER_HAVE_XTEST
XTestFakeButtonEvent(dpy, button, is_press, delay);
#endif
- if (grab_ptr) {
+ if (regrab) {
adjust_grabs(1, 1);
}
#endif /* NO_X11 */
@@ -1029,6 +1049,7 @@ void XTRAP_FakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
unsigned long delay) {
+ int regrab = 0;
RAWFB_RET_VOID
#if NO_X11
@@ -1039,11 +1060,16 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
if (grab_ptr) {
XUngrabPointer(dpy, CurrentTime);
+ regrab = 1;
+ }
+ if (grab_kbd && ungrab_both) {
+ XUngrabKeyboard(dpy, CurrentTime);
+ regrab = 1;
}
if (xtrap_input) {
XTRAP_FakeMotionEvent_wr(dpy, screen, x, y, delay);
- if (grab_ptr) {
+ if (regrab) {
adjust_grabs(1, 1);
}
return;
@@ -1056,7 +1082,7 @@ void XTestFakeMotionEvent_wr(Display* dpy, int screen, int x, int y,
#if LIBVNCSERVER_HAVE_XTEST
XTestFakeMotionEvent(dpy, screen, x, y, delay);
#endif
- if (grab_ptr) {
+ if (regrab) {
adjust_grabs(1, 1);
}
#endif /* NO_X11 */