summaryrefslogtreecommitdiff
path: root/src/output.cpp
blob: 8d526f629ecafb6a9850cd0481e3aa7c2963d3f3 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

#include <compiz-core.h>
#include <compoutput.h>

CompOutput::CompOutput ()
{
    mName = "";
    mId = ~0;
    mRegion.rects = &mRegion.extents;
    mRegion.numRects = 1;
    mRegion.extents.x1 = 0;
    mRegion.extents.x2 = 0;
    mRegion.extents.y1 = 0;
    mRegion.extents.y2 = 0;

    mWorkArea.x      = 0;
    mWorkArea.y      = 0;
    mWorkArea.width  = 0;
    mWorkArea.height = 0;
}

CompString
CompOutput::name ()
{
    return mName;
}

unsigned int
CompOutput::id ()
{
    return mId;
}

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

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

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

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

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

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

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

XRectangle
CompOutput::workArea ()
{
    return mWorkArea;
}

void
CompOutput::setWorkArea (XRectangle workarea)
{
    if (workarea.x < (int) x1 ())
	mWorkArea.x = x1 ();
    else
	mWorkArea.x = workarea.x;

    if (workarea.y < (int) y1 ())
	mWorkArea.y = y1 ();
    else
	mWorkArea.y = workarea.y;

    if (workarea.x + workarea.width > (int) x2 ())
	mWorkArea.width = x2 () - mWorkArea.x;
    else
	mWorkArea.width = workarea.width;

    if (workarea.y + workarea.height > (int) y2 ())
	mWorkArea.height = y2 () - mWorkArea.y;
    else
	mWorkArea.height = workarea.height;

}
void
CompOutput::setGeometry (unsigned int x1, unsigned int x2,
			 unsigned int y1, unsigned int y2)
{
    if (x1 < 0)
	mRegion.extents.x1 = 0;
    else
	mRegion.extents.x1 = x1;

    if (y1 < 0)
	mRegion.extents.y1 = 0;
    else
	mRegion.extents.y1 = y1;

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

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

    mWorkArea.x      = mRegion.extents.x1;
    mWorkArea.y      = mRegion.extents.y1;
    mWorkArea.width  = width ();
    mWorkArea.height = height ();
}

void
CompOutput::setId (CompString name, unsigned int id)
{
    mName = name;
    mId = id;
}