blob: 69ab687d09b5381b69b0de82e2fcc0d6a6630df6 [file] [log] [blame]
Constantin Kaplinsky23c60222008-06-04 03:58:07 +00001/* Copyright (C) 2006-2008 Constantin Kaplinsky. All Rights Reserved.
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +00002 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19//
20// Geometry.h
21//
22
23#ifndef __GEOMETRY_H__
24#define __GEOMETRY_H__
25
Constantin Kaplinsky23c60222008-06-04 03:58:07 +000026#include <rfb/Rect.h>
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000027#include <rfb/Configuration.h>
28
29using namespace rfb;
30
31class Geometry
32{
33public:
34 Geometry(int fullWidth, int fullHeight);
35
Constantin Kaplinsky6b5b8782008-09-02 10:33:23 +000036 // Return coordinates and dimensions that specify a rectangular part
37 // of the desktop that would be shown to RFB clients. This
38 // information is extracted in the constructor from the "Geometry"
39 // parameter.
Constantin Kaplinsky23c60222008-06-04 03:58:07 +000040 int width() const { return m_rect.width(); }
41 int height() const { return m_rect.height(); }
42 int offsetLeft() const { return m_rect.tl.x; }
43 int offsetTop() const { return m_rect.tl.y; }
Constantin Kaplinsky6b5b8782008-09-02 10:33:23 +000044
45 // Return the same information as a Rect structure.
Constantin Kaplinsky23c60222008-06-04 03:58:07 +000046 const Rect& getRect() const { return m_rect; }
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000047
Constantin Kaplinsky6b5b8782008-09-02 10:33:23 +000048 // Return coordinates of the video rectangle if one was set with the
49 // "VideoArea" parameter. The coordinates are relative to the whole
50 // rectangle as returned by getRect(). In other words, the
51 // coordinate (0, 0) corresponds to the top left corner of the
52 // rectangle shown to RFB clients.
Constantin Kaplinsky6d085f12008-08-20 09:54:32 +000053 const Rect& getVideoRect() const { return m_videoRect; }
54
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000055protected:
Constantin Kaplinsky63a8f372008-08-20 08:45:29 +000056 // Parse a string, extract size and coordinates,
57 // and return that rectangle clipped to m_rect.
Constantin Kaplinsky5120e5e2008-08-20 06:04:57 +000058 Rect parseString(const char *arg) const;
59
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000060 static StringParameter m_geometryParam;
Constantin Kaplinsky6d085f12008-08-20 09:54:32 +000061 static StringParameter m_videoAreaParam;
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000062
Constantin Kaplinsky6d085f12008-08-20 09:54:32 +000063 int m_fullWidth;
64 int m_fullHeight;
Constantin Kaplinsky23c60222008-06-04 03:58:07 +000065 Rect m_rect;
Constantin Kaplinsky6d085f12008-08-20 09:54:32 +000066 Rect m_videoRect;
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000067};
68
69#endif // __GEOMETRY_H__
70