|
@@ -18,19 +18,24 @@ slop::Rectangle::~Rectangle() {
|
18
|
18
|
usleep( 10000 );
|
19
|
19
|
}
|
20
|
20
|
|
21
|
|
-slop::Rectangle::Rectangle( int sx, int sy, int ex, int ey, int border, float r, float g, float b, float a ) {
|
|
21
|
+slop::Rectangle::Rectangle( int sx, int sy, int ex, int ey, int border, bool highlight, float r, float g, float b, float a ) {
|
22
|
22
|
m_x = std::min( sx, ex );
|
23
|
23
|
m_y = std::min( sy, ey );
|
24
|
24
|
m_width = std::max( sx, ex ) - m_x;
|
25
|
25
|
m_height = std::max( sy, ey ) - m_y;
|
26
|
26
|
m_border = border;
|
27
|
27
|
m_window = None;
|
|
28
|
+ m_highlight = highlight;
|
28
|
29
|
|
29
|
30
|
// If we don't have a border, we don't exist, so just die.
|
30
|
31
|
if ( m_border == 0 ) {
|
31
|
32
|
return;
|
32
|
33
|
}
|
33
|
34
|
|
|
35
|
+ if ( m_highlight ) {
|
|
36
|
+ m_border = 0;
|
|
37
|
+ }
|
|
38
|
+
|
34
|
39
|
// This sets up m_color
|
35
|
40
|
int err = convertColor( r, g, b );
|
36
|
41
|
if ( err ) {
|
|
@@ -60,19 +65,25 @@ slop::Rectangle::Rectangle( int sx, int sy, int ex, int ey, int border, float r,
|
60
|
65
|
XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&cardinal_alpha, 1 );
|
61
|
66
|
}
|
62
|
67
|
|
63
|
|
- // Now punch a hole into it so it looks like a selection rectangle!
|
64
|
|
- XRectangle rect;
|
65
|
|
- rect.x = rect.y = m_border;
|
66
|
|
- rect.width = m_width;
|
67
|
|
- rect.height = m_height;
|
68
|
|
-
|
69
|
68
|
XClassHint classhints;
|
70
|
69
|
char name[] = "slop";
|
71
|
70
|
classhints.res_name = name;
|
72
|
71
|
classhints.res_class = name;
|
73
|
72
|
XSetClassHint( xengine->m_display, m_window, &classhints );
|
74
|
73
|
|
75
|
|
- XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0);
|
|
74
|
+ // Now punch a hole into it so it looks like a selection rectangle, but only if we're not highlighting.
|
|
75
|
+ if ( !m_highlight ) {
|
|
76
|
+ XRectangle rect;
|
|
77
|
+ rect.x = rect.y = m_border;
|
|
78
|
+ rect.width = m_width;
|
|
79
|
+ rect.height = m_height;
|
|
80
|
+
|
|
81
|
+ XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0);
|
|
82
|
+ }
|
|
83
|
+ // Make it so all input falls through
|
|
84
|
+ XRectangle rect;
|
|
85
|
+ rect.x = rect.y = rect.width = rect.height = 0;
|
|
86
|
+ XShapeCombineRectangles( xengine->m_display, m_window, ShapeInput, 0, 0, &rect, 1, ShapeSet, 0);
|
76
|
87
|
XMapWindow( xengine->m_display, m_window );
|
77
|
88
|
}
|
78
|
89
|
|
|
@@ -89,24 +100,25 @@ void slop::Rectangle::setGeo( int sx, int sy, int ex, int ey ) {
|
89
|
100
|
m_y = y;
|
90
|
101
|
m_width = w;
|
91
|
102
|
m_height = h;
|
92
|
|
- // If we don't have a border, we don't exist, so just die.
|
93
|
|
- if ( m_border == 0 ) {
|
94
|
|
- return;
|
95
|
|
- }
|
96
|
103
|
|
97
|
104
|
// Change the window size
|
98
|
105
|
XResizeWindow( xengine->m_display, m_window, m_width+m_border*2, m_height+m_border*2 );
|
99
|
|
- // Fill up our old hole
|
100
|
|
- XRectangle rect;
|
101
|
|
- rect.x = rect.y = 0;
|
102
|
|
- rect.width = m_width+m_border*2;
|
103
|
|
- rect.height = m_height+m_border*2;
|
104
|
|
- XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0);
|
105
|
|
- // Then punch out another.
|
106
|
|
- rect.x = rect.y = m_border;
|
107
|
|
- rect.width = m_width;
|
108
|
|
- rect.height = m_height;
|
109
|
|
- XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0);
|
|
106
|
+ if ( m_border > 0 ) {
|
|
107
|
+ // Fill up our old hole
|
|
108
|
+ XRectangle rect;
|
|
109
|
+ rect.x = rect.y = 0;
|
|
110
|
+ rect.width = m_width+m_border*2;
|
|
111
|
+ rect.height = m_height+m_border*2;
|
|
112
|
+ XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0);
|
|
113
|
+ // Then punch out another.
|
|
114
|
+ rect.x = rect.y = m_border;
|
|
115
|
+ rect.width = m_width;
|
|
116
|
+ rect.height = m_height;
|
|
117
|
+ XShapeCombineRectangles( xengine->m_display, m_window, ShapeBounding, 0, 0, &rect, 1, ShapeSubtract, 0);
|
|
118
|
+ // Then make it so all input falls through.
|
|
119
|
+ rect.x = rect.y = rect.width = rect.height = 0;
|
|
120
|
+ XShapeCombineRectangles( xengine->m_display, m_window, ShapeInput, 0, 0, &rect, 1, ShapeSet, 0);
|
|
121
|
+ }
|
110
|
122
|
XMoveWindow( xengine->m_display, m_window, m_x-m_border, m_y-m_border );
|
111
|
123
|
}
|
112
|
124
|
|