From: Constantin Kaplinsky Date: Wed, 20 Aug 2008 09:54:32 +0000 (+0000) Subject: Added parsing for new VideoArea parameter. It does not have any effect yet. X-Git-Tag: v0.0.90~405 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6d085f11e79f3872a7eed9c3c6829c07a84d8cd2;p=tigervnc.git Added parsing for new VideoArea parameter. It does not have any effect yet. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2686 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/unix/x0vncserver/Geometry.cxx b/unix/x0vncserver/Geometry.cxx index 9594112b..728c1136 100644 --- a/unix/x0vncserver/Geometry.cxx +++ b/unix/x0vncserver/Geometry.cxx @@ -32,18 +32,47 @@ StringParameter Geometry::m_geometryParam("Geometry", "If the argument is empty, full screen is shown to VNC clients.", ""); +StringParameter Geometry::m_videoAreaParam("VideoArea", + "Screen area to be handled as video. " + "Format is x++.", + ""); + Geometry::Geometry(int fullWidth, int fullHeight) - : m_rect(0, 0, fullWidth, fullHeight) + : m_fullWidth(fullWidth), + m_fullHeight(fullHeight), + m_rect(0, 0, fullWidth, fullHeight) { + // Parse geometry specification and save the result in m_rect. const char *param = m_geometryParam.getData(); - if (strlen(param) > 0) { + bool geometrySpecified = (strlen(param) > 0); + if (geometrySpecified) { m_rect = parseString(param); } delete[] param; // don't forget to deallocate memory // allocated by StringParameter::getData() + if (m_rect.is_empty()) { + vlog.info("Desktop geometry is invalid"); + return; // further processing does not make sense + } - vlog.info("Desktop geometry is %dx%d+%d+%d", + // Everything went good so far. + vlog.info("Desktop geometry is set to %dx%d+%d+%d", width(), height(), offsetLeft(), offsetTop()); + + // Handle the VideoArea parameter, save the result in m_videoRect. + param = m_videoAreaParam.getData(); + bool videoAreaSpecified = (strlen(param) > 0); + if (videoAreaSpecified) { + m_videoRect = parseString(param); + if (isVideoAreaSet()) { + vlog.info("Video area set to %dx%d+%d+%d", + m_videoRect.width(), m_videoRect.height(), + m_videoRect.tl.x, m_videoRect.tl.y); + } else { + vlog.info("Video area was not set"); + } + } + delete[] param; } Rect Geometry::parseString(const char *arg) const @@ -59,9 +88,9 @@ Rect Geometry::parseString(const char *arg) const &w, &h, sign_x, &x, sign_y, &y); if ((n == 2 || n == 6) && w > 0 && h > 0 && x >= 0 && y >= 0) { if (sign_x[0] == '-') - x = m_rect.width() - w - x; + x = m_fullWidth - w - x; if (sign_y[0] == '-') - y = m_rect.height() - h - y; + y = m_fullHeight - h - y; Rect partRect(x, y, x + w, y + h); result = partRect.intersect(m_rect); if (result.area() <= 0) { diff --git a/unix/x0vncserver/Geometry.h b/unix/x0vncserver/Geometry.h index 3e5f23bc..82da9c6e 100644 --- a/unix/x0vncserver/Geometry.h +++ b/unix/x0vncserver/Geometry.h @@ -37,17 +37,23 @@ public: int height() const { return m_rect.height(); } int offsetLeft() const { return m_rect.tl.x; } int offsetTop() const { return m_rect.tl.y; } - const Rect& getRect() const { return m_rect; } + bool isVideoAreaSet() const { return !m_videoRect.is_empty(); } + const Rect& getVideoRect() const { return m_videoRect; } + protected: // Parse a string, extract size and coordinates, // and return that rectangle clipped to m_rect. Rect parseString(const char *arg) const; static StringParameter m_geometryParam; + static StringParameter m_videoAreaParam; + int m_fullWidth; + int m_fullHeight; Rect m_rect; + Rect m_videoRect; }; #endif // __GEOMETRY_H__