Patch against openbox3
Ruhi Bloodworth
ruhi at colophon.cjb.net
Tue Sep 17 23:41:45 EDT 2002
This patch, documents the Rect class and adds support for the -display
command line option
-------------- next part --------------
? autom4te.cache
? changes.patch
Index: util/rect.hh
===================================================================
RCS file: /cvs/cvsroot/openbox3/util/rect.hh,v
retrieving revision 1.2
diff -p -u -r1.2 rect.hh
--- util/rect.hh 2002/09/08 19:00:02 1.2
+++ util/rect.hh 2002/09/18 03:29:06
@@ -7,49 +7,139 @@ extern "C" {
namespace util {
+/*!
+ The Rect class defines a rectangle in the plane.
+*/
class Rect {
public:
+ //! Constructs an invalid rectangle
inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { }
+ //! Constructs a rectangle
+ /*!
+ \param x The x component of the point defining the top left corner of the
+ rectangle
+ \param y The y component of the point defining the top left corner of the
+ rectangle
+ \param w The width of the rectangle
+ \param h The height of the rectangle
+ */
inline Rect(int x, int y, unsigned int w, unsigned int h)
: _x1(x), _y1(y), _x2(w + x - 1), _y2(h + y - 1) { }
+ //! A Copy Constructor for Rect
+ /*!
+ \param xrect The Rect which will be copied
+ */
inline explicit Rect(const XRectangle& xrect)
: _x1(xrect.x), _y1(xrect.y), _x2(xrect.width + xrect.x - 1),
_y2(xrect.height + xrect.y - 1) { }
-
+ //! Returns the left coordinate of the rectangle. Identical to x().
inline int left(void) const { return _x1; }
+ //! Returns the top coordinate of the rectangle. Identical to y().
inline int top(void) const { return _y1; }
+ //! Returns the right coordinate of the rectangle.
inline int right(void) const { return _x2; }
+ //! Returns the bottom coordinate of the rectangle.
inline int bottom(void) const { return _y2; }
+ //! Returns the left coordinate of the rectangle. Identical to left().
inline int x(void) const { return _x1; }
+ //! Returns the top coordinate of the rectangle. Identical to top().
inline int y(void) const { return _y1; }
+ //! Sets the left edge of the rectangle.
+ /*!
+ May change the right edge to the rectangle, but never changes the width.
+ \param x The new left coordinate of the rectangle
+ */
void setX(int x);
+ //! Sets the top edge of the rectangle.
+ /*!
+ May change the bottom edge of the rectangle, but never changes the height.
+ \param y The new top coordinate of the rectangle
+ */
void setY(int y);
+ //! Sets the upper left corner of the rectangle.
+ /*!
+ May change the bottom right corner of the rectangle, but never changes the
+ width or height
+ \param x The new left coordinate of the rectangle
+ \param y The new top coordinate of the rectangle
+ */
void setPos(int x, int y);
+ //! Returns the width of the rectangle.
+ /*!
+ The width includes both the left and right edges. i.e. width = right -
+ left + 1
+ */
inline int width(void) const { return _x2 - _x1 + 1; }
+ //! Returns the height of the rectangle.
+ /*!
+ The height includes both the top and bottom edges. i.e. height = bottom -
+ top + 1
+ */
inline int height(void) const { return _y2 - _y1 + 1; }
+ //! Sets the width of the rectangle
+ /*!
+ The right edge is changed, but not the left edge.
+ \param w The new width of the rectangle
+ */
void setWidth(int w);
+ //! Sets the height of the rectangle
+ /*!
+ The bottom edge is changed, but not the top edge.
+ \param h The new height of the rectangle
+ */
void setHeight(int h);
+ //! Sets the width and height of the rectangle
+ /*!
+ The bottom right corner of the rectangle may be moved. The top and right
+ edges are not affected
+ \param w The new width of the rectangle
+ \param h The new height of the rectangle
+ */
void setSize(int w, int h);
-
+ //! Sets the upper-left corner and the width and height of the rectangle
+ /*!
+ \param x The left edge of the rectangle
+ \param y The top edge of the rectangle
+ \param w The width of the rectangle
+ \param h The height of the rectangle
+ */
void setRect(int x, int y, int w, int h);
-
+ //! Sets the edges of the rectangle
+ /*!
+ \param l The left edge of the rectangle
+ \param t The top edge of the rectangle
+ \param r The right edge of the rectangle
+ \param b The bottom edge of the rectangle
+ */
void setCoords(int l, int t, int r, int b);
-
+ //! Returns TRUE if the two Rects are equal otherwise return FALSE
inline bool operator==(const Rect &a)
{ return _x1 == a._x1 && _y1 == a._y1 && _x2 == a._x2 && _y2 == a._y2; }
+ //! Returns TRUE if the two Rects are different otherwise return FALSE
inline bool operator!=(const Rect &a) { return ! operator==(a); }
+ //! Returns the bounding rectangle of this rectangle and rectangle a
Rect operator|(const Rect &a) const;
+ //! Returns the intersection of this rectangle and rectangle a
Rect operator&(const Rect &a) const;
+ //! Unites this rectangle with rectangle a
inline Rect &operator|=(const Rect &a) { *this = *this | a; return *this; }
+ //! Intersects this rectangle with rectangle a
inline Rect &operator&=(const Rect &a) { *this = *this & a; return *this; }
+ //! Returns TRUE if the rectangle's width and height are not negative
inline bool valid(void) const { return _x2 > _x1 && _y2 > _y1; }
+ //! Returns TRUE if this rectangle intersects with rectangle a.
+ /*!
+ The rectangles intersect if they have at least one pixel in common
+ */
bool intersects(const Rect &a) const;
+ //! Returns TRUE if the point (x,y) is within this rectangle
bool contains(int x, int y) const;
+ //! Returns TRUE if the rectangle a lies completly within this rectangle
bool contains(const Rect &a) const;
private:
Index: wm/main.cc
===================================================================
RCS file: /cvs/cvsroot/openbox3/wm/main.cc,v
retrieving revision 1.3
diff -p -u -r1.3 main.cc
--- wm/main.cc 2002/09/08 19:00:02 1.3
+++ wm/main.cc 2002/09/18 03:29:07
@@ -2,16 +2,31 @@
#include "xlib/screen.hh"
#include <iostream>
+#include <string.h>
using std::cerr;
using std::endl;
using xlib::XDisplay;
using xlib::XScreen;
-int main(int, char **) {
+int main(int argc, char **argv) {
+ char *session_display = (char *) 0;
+ for(int i = 1; i < argc; ++i){
+ if (! strcmp(argv[i], "-display")){
+ // check for -display option... to run on a display other than the one
+ // set by the environmnet variable DISPLAY
+ if ((++i) >= argc) {
+ cerr << "error: '-display' requires an argument" << endl;
+ exit(1);
+ }
+ cerr << argv[i] << endl;
+ session_display = argv[i];
+ }
+ }
+
XDisplay display;
- if (!display.open()) {
+ if (!display.open(session_display)) {
cerr << "Failed to open X display" << endl;
exit(1);
More information about the openbox
mailing list