]>
Dogcows Code - chaz/openbox/blob - Util.hh
1536226ca86b532f6bf51cf0598bc2a2bfb5aafc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Util.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
24 #ifndef _BLACKBOX_UTIL_HH
25 #define _BLACKBOX_UTIL_HH
28 #include <X11/Xutil.h>
34 inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { }
35 inline Rect(int __x
, int __y
, unsigned int __w
, unsigned int __h
)
36 : _x1(__x
), _y1(__y
), _x2(__w
+ __x
- 1), _y2(__h
+ __y
- 1) { }
37 inline explicit Rect(const XRectangle
& xrect
)
38 : _x1(xrect
.x
), _y1(xrect
.y
), _x2(xrect
.width
+ xrect
.x
- 1),
39 _y2(xrect
.height
+ xrect
.y
- 1) { }
41 inline int left(void) const { return _x1
; }
42 inline int top(void) const { return _y1
; }
43 inline int right(void) const { return _x2
; }
44 inline int bottom(void) const { return _y2
; }
46 inline int x(void) const { return _x1
; }
47 inline int y(void) const { return _y1
; }
50 void setPos(int __x
, int __y
);
52 inline unsigned int width(void) const { return _x2
- _x1
+ 1; }
53 inline unsigned int height(void) const { return _y2
- _y1
+ 1; }
54 void setWidth(unsigned int __w
);
55 void setHeight(unsigned int __h
);
56 void setSize(unsigned int __w
, unsigned int __h
);
58 void setRect(int __x
, int __y
, unsigned int __w
, unsigned int __h
);
60 void setCoords(int __l
, int __t
, int __r
, int __b
);
62 inline bool operator==(const Rect
&a
)
63 { return _x1
== a
._x1
&& _y1
== a
._y1
&& _x2
== a
._x2
&& _y2
== a
._y2
; }
64 inline bool operator!=(const Rect
&a
) { return ! operator==(a
); }
66 Rect
operator|(const Rect
&a
) const;
67 Rect
operator&(const Rect
&a
) const;
68 inline Rect
&operator|=(const Rect
&a
) { *this = *this | a
; return *this; }
69 inline Rect
&operator&=(const Rect
&a
) { *this = *this & a
; return *this; }
71 inline bool valid(void) const { return _x2
> _x1
&& _y2
> _y1
; }
73 bool intersects(const Rect
&a
) const;
76 int _x1
, _y1
, _x2
, _y2
;
79 /* XXX: this needs autoconf help */
80 const unsigned int BSENTINEL
= 65535;
82 std::string
expandTilde(const std::string
& s
);
84 void bexec(const std::string
& command
, const std::string
& displaystring
);
87 std::string
basename(const std::string
& path
);
90 std::string
textPropertyToString(Display
*display
, XTextProperty
& text_prop
);
92 struct timeval
; // forward declare to avoid the header
93 timeval
normalizeTimeval(const timeval
&tm
);
95 struct PointerAssassin
{
97 inline void operator()(const T ptr
) const {
This page took 0.0406 seconds and 3 git commands to generate.