aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/ClientParams.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/ClientParams.cxx')
-rw-r--r--common/rfb/ClientParams.cxx36
1 files changed, 28 insertions, 8 deletions
diff --git a/common/rfb/ClientParams.cxx b/common/rfb/ClientParams.cxx
index e5fd105e..514b0b4e 100644
--- a/common/rfb/ClientParams.cxx
+++ b/common/rfb/ClientParams.cxx
@@ -24,14 +24,20 @@
#include <stdexcept>
+#include <core/LogWriter.h>
+#include <core/string.h>
+
#include <rfb/encodings.h>
#include <rfb/ledStates.h>
#include <rfb/clipboardTypes.h>
#include <rfb/ClientParams.h>
-#include <rfb/util.h>
+#include <rfb/Cursor.h>
+#include <rfb/ScreenSet.h>
using namespace rfb;
+static core::LogWriter vlog("ClientParams");
+
ClientParams::ClientParams()
: majorVersion(0), minorVersion(0),
compressLevel(2), qualityLevel(-1), fineQualityLevel(-1),
@@ -41,7 +47,11 @@ ClientParams::ClientParams()
{
setName("");
- cursor_ = new Cursor(0, 0, Point(), nullptr);
+ screenLayout_ = new ScreenSet();
+
+ pf_ = new PixelFormat();
+
+ cursor_ = new Cursor(0, 0, {}, nullptr);
clipFlags = clipboardUTF8 | clipboardRTF | clipboardHTML |
clipboardRequest | clipboardNotify | clipboardProvide;
@@ -51,7 +61,9 @@ ClientParams::ClientParams()
ClientParams::~ClientParams()
{
+ delete screenLayout_;
delete cursor_;
+ delete pf_;
}
void ClientParams::setDimensions(int width, int height)
@@ -63,17 +75,25 @@ void ClientParams::setDimensions(int width, int height)
void ClientParams::setDimensions(int width, int height, const ScreenSet& layout)
{
- if (!layout.validate(width, height))
+ if (!layout.validate(width, height)) {
+ char buffer[2048];
+ vlog.debug("Invalid screen layout for %dx%d:", width, height);
+ layout.print(buffer, sizeof(buffer));
+ vlog.debug("%s", buffer);
+
throw std::invalid_argument("Attempted to configure an invalid screen layout");
+ }
width_ = width;
height_ = height;
- screenLayout_ = layout;
+ delete screenLayout_;
+ screenLayout_ = new ScreenSet(layout);
}
void ClientParams::setPF(const PixelFormat& pf)
{
- pf_ = pf;
+ delete pf_;
+ pf_ = new PixelFormat(pf);
if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
throw std::invalid_argument("setPF: Not 8, 16 or 32 bpp?");
@@ -90,7 +110,7 @@ void ClientParams::setCursor(const Cursor& other)
cursor_ = new Cursor(other);
}
-void ClientParams::setCursorPos(const Point& pos)
+void ClientParams::setCursorPos(const core::Point& pos)
{
cursorPos_ = pos;
}
@@ -162,7 +182,7 @@ uint32_t ClientParams::clipboardSize(unsigned int format) const
return clipSizes[i];
}
- throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
+ throw std::invalid_argument(core::format("Invalid clipboard format 0x%x", format));
}
void ClientParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
@@ -236,4 +256,4 @@ bool ClientParams::supportsExtendedMouseButtons() const
if (supportsEncoding(pseudoEncodingExtendedMouseButtons))
return true;
return false;
-} \ No newline at end of file
+}