summaryrefslogtreecommitdiff
path: root/src/rect.cpp
blob: 892e369bfe7aadf01b47071bd04c7f324882db98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <compiz-core.h>
#include <comprect.h>

CompRect::CompRect ()
{
    mRegion.rects = &mRegion.extents;
    mRegion.numRects = 1;
    mRegion.extents.x1 = 0;
    mRegion.extents.x2 = 0;
    mRegion.extents.y1 = 0;
    mRegion.extents.y2 = 0;
}

CompRect::CompRect (int x1, int x2, int y1, int y2)
{
    CompRect ();
    setGeometry (x1, x2, y1, y2);
}

int
CompRect::x ()
{
    return mRegion.extents.x1;
}

int
CompRect::y ()
{
    return mRegion.extents.y1;
}

int
CompRect::x1 ()
{
    return mRegion.extents.x1;
}

int
CompRect::y1 ()
{
    return mRegion.extents.y1;
}

int
CompRect::x2 ()
{
    return mRegion.extents.x2;
}

int
CompRect::y2 ()
{
    return mRegion.extents.y2;
}

unsigned int
CompRect::width ()
{
    return mRegion.extents.x2 - mRegion.extents.x1;
}

unsigned int
CompRect::height ()
{
    return mRegion.extents.y2 - mRegion.extents.y1;
}

Region
CompRect::region ()
{
    return &mRegion;
}

void
CompRect::setGeometry (int x1, int x2, int y1, int y2)
{
    mRegion.extents.x1 = x1;
    mRegion.extents.y1 = y1;

    if (x2 < x1)
	mRegion.extents.x2 = x1;
    else
	mRegion.extents.x2 = x2;

    if (y2 < y1)
	mRegion.extents.y2 = y1;
    else
	mRegion.extents.y2 = y2;
}