-/* Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved.
+/* Copyright (C) 2006-2008 Constantin Kaplinsky. 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
// Geometry.cxx
//
-#include <rfb/Rect.h>
#include <rfb/LogWriter.h>
#include <x0vncserver/Geometry.h>
"");
Geometry::Geometry(int fullWidth, int fullHeight)
- : m_width(fullWidth), m_height(fullHeight),
- m_offsetLeft(0), m_offsetTop(0)
+ : m_rect(0, 0, fullWidth, fullHeight)
{
const char *param = m_geometryParam.getData();
if (strlen(param) != 0) {
y = fullHeight - h - y;
Rect fullRect(0, 0, fullWidth, fullHeight);
Rect partRect(x, y, x + w, y + h);
- Rect r = partRect.intersect(fullRect);
- if (r.area() > 0) {
- m_width = r.width();
- m_height = r.height();
- m_offsetLeft = r.tl.x;
- m_offsetTop = r.tl.y;
- } else {
+ m_rect = partRect.intersect(fullRect);
+ if (m_rect.area() <= 0) {
vlog.error("Requested area is out of the desktop boundaries");
+ m_rect.clear();
+ return;
}
} else {
vlog.error("Wrong argument format");
+ m_rect.clear();
+ return;
}
}
vlog.info("Desktop geometry is %dx%d+%d+%d",
- m_width, m_height, m_offsetLeft, m_offsetTop);
+ width(), height(), offsetLeft(), offsetTop());
}
-/* Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved.
+/* Copyright (C) 2006-2008 Constantin Kaplinsky. 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
#ifndef __GEOMETRY_H__
#define __GEOMETRY_H__
+#include <rfb/Rect.h>
#include <rfb/Configuration.h>
using namespace rfb;
public:
Geometry(int fullWidth, int fullHeight);
- int width() const { return m_width; }
- int height() const { return m_height; }
- int offsetLeft() const { return m_offsetLeft; }
- int offsetTop() const { return m_offsetTop; }
+ int width() const { return m_rect.width(); }
+ 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; }
protected:
static StringParameter m_geometryParam;
- int m_width;
- int m_height;
- int m_offsetLeft;
- int m_offsetTop;
+ Rect m_rect;
};
#endif // __GEOMETRY_H__
TXWindow::init(dpy,"x0vncserver");
Geometry geo(DisplayWidth(dpy, DefaultScreen(dpy)),
DisplayHeight(dpy, DefaultScreen(dpy)));
+ if (geo.getRect().is_empty()) {
+ vlog.error("Exiting with error");
+ return 1;
+ }
XDesktop desktop(dpy, &geo);
VNCServerST server("x0vncserver", &desktop);