aboutsummaryrefslogtreecommitdiff
path: root/nxcompshad/X11.cpp
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-11-13 09:53:12 +0100
committerReinhard Tartler <siretart@tauware.de>2011-11-13 09:53:12 +0100
commitc70adf725d3fea94eabdde467b8b8b106a796c0a (patch)
tree5209ab3f372afaab6e0e17fdca97d8c38877ea7b /nxcompshad/X11.cpp
parent2208f4f9ecf967579a364021f0847b3ad1d7777c (diff)
downloadnx-libs-c70adf725d3fea94eabdde467b8b8b106a796c0a.tar.gz
nx-libs-c70adf725d3fea94eabdde467b8b8b106a796c0a.tar.bz2
nx-libs-c70adf725d3fea94eabdde467b8b8b106a796c0a.zip
Imported nxcompshad-3.4.0-3.tar.gznxcompshad/3.4.0-3
Summary: Imported nxcompshad-3.4.0-3.tar.gz Keywords: Imported nxcompshad-3.4.0-3.tar.gz into Git repository
Diffstat (limited to 'nxcompshad/X11.cpp')
-rw-r--r--nxcompshad/X11.cpp93
1 files changed, 66 insertions, 27 deletions
diff --git a/nxcompshad/X11.cpp b/nxcompshad/X11.cpp
index 837efad71..cb8f55fc5 100644
--- a/nxcompshad/X11.cpp
+++ b/nxcompshad/X11.cpp
@@ -1,6 +1,6 @@
/**************************************************************************/
/* */
-/* Copyright (c) 2001, 2009 NoMachine, http://www.nomachine.com/. */
+/* Copyright (c) 2001, 2010 NoMachine, http://www.nomachine.com/. */
/* */
/* NXCOMPSHAD, NX protocol compression and NX extensions to this software */
/* are copyright of NoMachine. Redistribution and use of the present */
@@ -127,7 +127,7 @@ Poller::~Poller()
XCloseDisplay(display_);
}
- if (tmpBuffer_ != NULL && shmExtension_ == 1 && damageExtension_ == 1)
+ if (tmpBuffer_ != NULL && shmExtension_ != -1 && damageExtension_ == 1)
{
XFree(tmpBuffer_);
@@ -181,13 +181,21 @@ int Poller::updateShadowFrameBuffer(void)
return -1;
}
-
- return 1;
}
else
{
- return 0;
+ image_ = XGetImage(display_, DefaultRootWindow(display_), 0, 0, width_,
+ height_, AllPlanes, ZPixmap);
+
+ if (image_ == NULL)
+ {
+ logDebug("Poller::updateShadowFrameBuffer", "XGetImage failed!");
+
+ return -1;
+ }
}
+
+ return 1;
}
char *Poller::getRect(XRectangle r)
@@ -255,6 +263,8 @@ char *Poller::getRect(XRectangle r)
}
XFree(image_);
+
+ image_ = NULL;
}
return tmpBuffer_;
@@ -1469,42 +1479,71 @@ void Poller::handleDamageNotify(XEvent *X)
void Poller::updateDamagedAreas(void)
{
- if (shmExtension_ == 1)
- {
- BOX *boxPtr;
+ BOX *boxPtr;
- XRectangle rectangle;
+ XRectangle rectangle;
- int i;
- int y;
+ int i;
+ int y;
+
+ for (i = 0; i < lastUpdatedRegion_ -> numRects; i++)
+ {
+ boxPtr = lastUpdatedRegion_ -> rects + i;
- for (i = 0; i < lastUpdatedRegion_ -> numRects; i++)
+ if (shmExtension_ == 1)
{
- boxPtr = lastUpdatedRegion_ -> rects + i;
-
image_ -> width = boxPtr -> x2 - boxPtr -> x1;
- image_ -> height = boxPtr -> y2 - boxPtr -> y1;
+ image_ -> height = boxPtr -> y2 - boxPtr -> y1;
+ image_ -> bytes_per_line =
+ ROUNDUP((image_ -> bits_per_pixel * image_ -> width),
+ image_ -> bitmap_pad);
+
+ if (XShmGetImage(display_, DefaultRootWindow(display_), image_,
+ boxPtr -> x1, boxPtr -> y1, AllPlanes) == 0)
+ {
+ logDebug("Poller::updateDamagedAreas", "XShmGetImage failed!");
- image_ -> bytes_per_line = ROUNDUP((image_ -> bits_per_pixel * image_ -> width), image_ -> bitmap_pad);
+ return;
+ }
+ }
+ else if (shmExtension_ == 0)
+ {
+ image_ = XGetImage(display_, DefaultRootWindow(display_), boxPtr -> x1,
+ boxPtr -> y1, boxPtr -> x2 - boxPtr -> x1,
+ boxPtr -> y2 - boxPtr -> y1, AllPlanes,
+ ZPixmap);
- if (XShmGetImage(display_, DefaultRootWindow(display_), image_, boxPtr -> x1, boxPtr -> y1, AllPlanes) == 0)
+ if (image_ == NULL)
{
- logDebug("Poller::getRect", "XShmGetImage failed!");
+ logDebug("Poller::updateDamagedAreas", "XGetImage failed!");
return;
}
- rectangle.height = 1;
- rectangle.width = image_ -> width;
- rectangle.x = boxPtr -> x1;
- rectangle.y = boxPtr -> y1;
+ image_ -> width = boxPtr -> x2 - boxPtr -> x1;
+ image_ -> height = boxPtr -> y2 - boxPtr -> y1;
+ image_ -> bytes_per_line =
+ ROUNDUP((image_ -> bits_per_pixel * image_ -> width),
+ image_ -> bitmap_pad);
+ }
+
+ rectangle.height = 1;
+ rectangle.width = image_ -> width;
+ rectangle.x = boxPtr -> x1;
+ rectangle.y = boxPtr -> y1;
- for (y = 0; y < image_ -> height; y++)
- {
- update(image_ -> data + y * image_ -> bytes_per_line, rectangle);
+ for (y = 0; y < image_ -> height; y++)
+ {
+ update(image_ -> data + y * image_ -> bytes_per_line, rectangle);
- rectangle.y++;
- }
+ rectangle.y++;
+ }
+
+ if (shmExtension_ != 1)
+ {
+ XDestroyImage(image_);
+
+ image_ = NULL;
}
}