summaryrefslogtreecommitdiffstats
path: root/unix/xserver/hw/vnc/RegionHelper.h
diff options
context:
space:
mode:
authorAdam Tkac <atkac@redhat.com>2008-03-21 18:56:48 +0000
committerAdam Tkac <atkac@redhat.com>2008-03-21 18:56:48 +0000
commit4c0427ffb370b5020a6f82456106774b6711ddd4 (patch)
tree20e0eb1d073746e04d953b488618573de14abbf6 /unix/xserver/hw/vnc/RegionHelper.h
parentbee114ae5e69b10e132c5d6d680045d9165e5a90 (diff)
downloadtigervnc-4c0427ffb370b5020a6f82456106774b6711ddd4.tar.gz
tigervnc-4c0427ffb370b5020a6f82456106774b6711ddd4.zip
- moved Xvnc sources to unix/xserver/hw/vnc directory to affect current X tree
- replaced unix/xc.patch by unix/xserver.patch - completely deleted unneded unix/xc subtree (sources are in unix/xserver/hw/vnc) git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/1.5-xserver@2439 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'unix/xserver/hw/vnc/RegionHelper.h')
-rw-r--r--unix/xserver/hw/vnc/RegionHelper.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/unix/xserver/hw/vnc/RegionHelper.h b/unix/xserver/hw/vnc/RegionHelper.h
new file mode 100644
index 00000000..61dc89ff
--- /dev/null
+++ b/unix/xserver/hw/vnc/RegionHelper.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+#ifndef __REGIONHELPER_H__
+#define __REGIONHELPER_H__
+
+// RegionHelper is a class which helps in using X server regions by
+// automatically freeing them in the destructor. It also fixes a problem with
+// REGION_INIT when given an empty rectangle.
+
+// REGION_NULL was introduced in the Xorg tree as the way to initialise an
+// empty region. If it's not already defined do it the old way. Note that the
+// old way causes a segfault in the new tree...
+#ifndef REGION_NULL
+#define REGION_NULL(pScreen,pReg) REGION_INIT(pScreen,pReg,NullBox,0)
+#endif
+
+class RegionHelper {
+public:
+
+ // constructor from a single rect
+ RegionHelper(ScreenPtr pScreen_, BoxPtr rect, int size)
+ : pScreen(pScreen_), reg(0)
+ {
+ init(rect, size);
+ }
+
+ // constructor from an existing X server region
+ RegionHelper(ScreenPtr pScreen_, RegionPtr pRegion)
+ : pScreen(pScreen_), reg(&regRec)
+ {
+ REGION_NULL(pScreen, reg);
+ REGION_COPY(pScreen, reg, pRegion);
+ }
+
+ // constructor from an array of rectangles
+ RegionHelper(ScreenPtr pScreen_, int nrects, xRectanglePtr rects,
+ int ctype=CT_NONE)
+ : pScreen(pScreen_)
+ {
+ reg = RECTS_TO_REGION(pScreen, nrects, rects, ctype);
+ }
+
+ // constructor for calling init() later
+ RegionHelper(ScreenPtr pScreen_) : pScreen(pScreen_), reg(0) {
+ }
+
+ void init(BoxPtr rect, int size) {
+ reg = &regRec;
+ if (!rect || (rect && (rect->x2 == rect->x1 || rect->y2 == rect->y1))) {
+ REGION_NULL(pScreen, reg);
+ } else {
+ REGION_INIT(pScreen, reg, rect, size);
+ }
+ }
+
+ // destructor frees as appropriate
+ ~RegionHelper() {
+ if (reg == &regRec) {
+ REGION_UNINIT(pScreen, reg);
+ } else if (reg) {
+ REGION_DESTROY(pScreen, reg);
+ }
+ }
+ ScreenPtr pScreen;
+ RegionRec regRec;
+ RegionPtr reg;
+};
+
+#endif