@@ -18,19 +18,24 @@ slop::Rectangle::~Rectangle() {
1818 usleep ( 10000 );
1919}
2020
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 ) {
2222 m_x = std::min ( sx, ex );
2323 m_y = std::min ( sy, ey );
2424 m_width = std::max ( sx, ex ) - m_x;
2525 m_height = std::max ( sy, ey ) - m_y;
2626 m_border = border;
2727 m_window = None;
28+ m_highlight = highlight;
2829
2930 // If we don't have a border, we don't exist, so just die.
3031 if ( m_border == 0 ) {
3132 return ;
3233 }
3334
35+ if ( m_highlight ) {
36+ m_border = 0 ;
37+ }
38+
3439 // This sets up m_color
3540 int err = convertColor ( r, g, b );
3641 if ( err ) {
@@ -60,19 +65,25 @@ slop::Rectangle::Rectangle( int sx, int sy, int ex, int ey, int border, float r,
6065 XA_CARDINAL, 32 , PropModeReplace, (unsigned char *)&cardinal_alpha, 1 );
6166 }
6267
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-
6968 XClassHint classhints;
7069 char name[] = " slop" ;
7170 classhints.res_name = name;
7271 classhints.res_class = name;
7372 XSetClassHint ( xengine->m_display , m_window, &classhints );
7473
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 );
7687 XMapWindow ( xengine->m_display , m_window );
7788}
7889
@@ -89,24 +100,25 @@ void slop::Rectangle::setGeo( int sx, int sy, int ex, int ey ) {
89100 m_y = y;
90101 m_width = w;
91102 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- }
96103
97104 // Change the window size
98105 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+ }
110122 XMoveWindow ( xengine->m_display , m_window, m_x-m_border, m_y-m_border );
111123}
112124
0 commit comments