aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2016-05-04 17:51:19 +0200
committerPierre Ossman <ossman@cendio.se>2016-05-04 17:51:19 +0200
commit919ae4572ceef9c0368fec88734ea075ffa1c962 (patch)
tree5e0abc4781044613c407e0474bec2c4a73537871
parent2b949c2a8b02be4920388ce58a473e8cdc182b43 (diff)
downloadtigervnc-919ae4572ceef9c0368fec88734ea075ffa1c962.tar.gz
tigervnc-919ae4572ceef9c0368fec88734ea075ffa1c962.zip
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.
-rw-r--r--vncviewer/X11PixelBuffer.cxx12
-rw-r--r--vncviewer/X11PixelBuffer.h1
2 files changed, 12 insertions, 1 deletions
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<X11PixelBuffer*> shmList;
};