From 919ae4572ceef9c0368fec88734ea075ffa1c962 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 4 May 2016 17:51:19 +0200 Subject: [PATCH] Be more paranoid about ShmCompletion events Unfortunately HP ships a buggy X server on their thin clients that send out extra, bogus ShmCompletion events. This screws up our logic so we need to filter them out. Fortunately they are sent with an invalid drawable id, so simply verify that. --- vncviewer/X11PixelBuffer.cxx | 12 +++++++++++- vncviewer/X11PixelBuffer.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vncviewer/X11PixelBuffer.cxx b/vncviewer/X11PixelBuffer.cxx index 046676eb..3c41490a 100644 --- a/vncviewer/X11PixelBuffer.cxx +++ b/vncviewer/X11PixelBuffer.cxx @@ -101,7 +101,7 @@ static PixelFormat display_pf() X11PixelBuffer::X11PixelBuffer(int width, int height) : PlatformPixelBuffer(display_pf(), width, height, NULL, 0), - shminfo(NULL), xim(NULL), pendingPutImage(0) + shminfo(NULL), xim(NULL), pendingPutImage(0), pendingDrawable(0) { // Might not be open at this point fl_open_display(); @@ -146,6 +146,8 @@ void X11PixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h) if (shminfo) { XShmPutImage(fl_display, fl_window, fl_gc, xim, src_x, src_y, x, y, w, h, True); pendingPutImage++; + assert((pendingPutImage == 1) || (pendingDrawable == fl_window)); + pendingDrawable = fl_window; } else { XPutImage(fl_display, fl_window, fl_gc, xim, src_x, src_y, x, y, w, h); } @@ -255,10 +257,18 @@ int X11PixelBuffer::handleSystemEvent(void* event, void* data) shmevent = (XShmCompletionEvent*)event; + if (shmevent->send_event) + return 0; + for (iter = shmList.begin();iter != shmList.end();++iter) { if (shmevent->shmseg != (*iter)->shminfo->shmseg) continue; + /* HP has a buggy X server on their thin clients that sends bogus + * extra events with an incorrect drawable id */ + if (shmevent->drawable != (*iter)->pendingDrawable) + continue; + (*iter)->pendingPutImage--; assert((*iter)->pendingPutImage >= 0); diff --git a/vncviewer/X11PixelBuffer.h b/vncviewer/X11PixelBuffer.h index 115984da..a616672d 100644 --- a/vncviewer/X11PixelBuffer.h +++ b/vncviewer/X11PixelBuffer.h @@ -46,6 +46,7 @@ protected: XShmSegmentInfo *shminfo; XImage *xim; int pendingPutImage; + Drawable pendingDrawable; static std::list shmList; }; -- 2.39.5