|
@@ -4,7 +4,7 @@
|
4
|
4
|
#include "rectangle.hpp"
|
5
|
5
|
#include "options.hpp"
|
6
|
6
|
|
7
|
|
-void printSelection( bool cancelled, int x, int y, int w, int h ) {
|
|
7
|
+void printSelection( bool cancelled, int x, int y, int w, int h, int window ) {
|
8
|
8
|
printf( "X=%i\n", x );
|
9
|
9
|
printf( "Y=%i\n", y );
|
10
|
10
|
printf( "W=%i\n", w );
|
|
@@ -23,6 +23,7 @@ void printSelection( bool cancelled, int x, int y, int w, int h ) {
|
23
|
23
|
printf( "%i", y );
|
24
|
24
|
}
|
25
|
25
|
printf( "\n" );
|
|
26
|
+ printf( "ID=%i\n", window );
|
26
|
27
|
if ( cancelled ) {
|
27
|
28
|
printf( "Cancel=true\n" );
|
28
|
29
|
} else {
|
|
@@ -91,6 +92,7 @@ int main( int argc, char** argv ) {
|
91
|
92
|
bool running = true;
|
92
|
93
|
slop::Rectangle* selection = NULL;
|
93
|
94
|
Window window = None;
|
|
95
|
+ Window windowmemory = None;
|
94
|
96
|
std::string xdisplay = options->m_xdisplay;
|
95
|
97
|
int padding = options->m_padding;
|
96
|
98
|
int borderSize = options->m_borderSize;
|
|
@@ -116,12 +118,12 @@ int main( int argc, char** argv ) {
|
116
|
118
|
// if we fail for either we exit immediately.
|
117
|
119
|
err = xengine->init( xdisplay.c_str() );
|
118
|
120
|
if ( err ) {
|
119
|
|
- printSelection( true, 0, 0, 0, 0 );
|
|
121
|
+ printSelection( true, 0, 0, 0, 0, None );
|
120
|
122
|
return err;
|
121
|
123
|
}
|
122
|
124
|
err = xengine->grabCursor( slop::Cross );
|
123
|
125
|
if ( err ) {
|
124
|
|
- printSelection( true, 0, 0, 0, 0 );
|
|
126
|
+ printSelection( true, 0, 0, 0, 0, None );
|
125
|
127
|
return err;
|
126
|
128
|
}
|
127
|
129
|
if ( keyboard ) {
|
|
@@ -143,7 +145,7 @@ int main( int argc, char** argv ) {
|
143
|
145
|
double starti = double( start.tv_sec*1000000000L + start.tv_nsec )/1000000000.f;
|
144
|
146
|
if ( timei - starti > options->m_gracetime ) {
|
145
|
147
|
if ( ( xengine->anyKeyPressed() && keyboard ) || xengine->mouseDown( 3 ) ) {
|
146
|
|
- printSelection( true, 0, 0, 0, 0 );
|
|
148
|
+ printSelection( true, 0, 0, 0, 0, None );
|
147
|
149
|
fprintf( stderr, "User pressed key. Canceled selection.\n" );
|
148
|
150
|
state = -1;
|
149
|
151
|
running = false;
|
|
@@ -213,6 +215,7 @@ int main( int argc, char** argv ) {
|
213
|
215
|
highlight,
|
214
|
216
|
r, g, b, a );
|
215
|
217
|
}
|
|
218
|
+ windowmemory = window;
|
216
|
219
|
// If the user has let go of the mouse button, we'll just
|
217
|
220
|
// continue to the next state.
|
218
|
221
|
if ( !xengine->mouseDown( 1 ) ) {
|
|
@@ -226,12 +229,17 @@ int main( int argc, char** argv ) {
|
226
|
229
|
// We make sure the selection rectangle stays on the window we had selected
|
227
|
230
|
selection->setGeo( xmem, ymem, xmem + wmem, ymem + hmem );
|
228
|
231
|
xengine->setCursor( slop::Left );
|
|
232
|
+ // Make sure
|
|
233
|
+ window = windowmemory;
|
229
|
234
|
continue;
|
230
|
235
|
}
|
|
236
|
+ // If we're not selecting a window.
|
|
237
|
+ windowmemory = window;
|
|
238
|
+ window = None;
|
231
|
239
|
// We also detect which way the user is pulling and set the mouse icon accordingly.
|
232
|
240
|
bool x = cx > xengine->m_mousex;
|
233
|
241
|
bool y = cy > xengine->m_mousey;
|
234
|
|
- if ( selection->m_width <= 1 && selection->m_height <= 1 || minimumsize == maximumsize ) {
|
|
242
|
+ if ( selection->m_width <= 1 && selection->m_height <= 1 || ( minimumsize == maximumsize && minimumsize != 0 && maximumsize != 0 ) ) {
|
235
|
243
|
xengine->setCursor( slop::Cross );
|
236
|
244
|
} else if ( !x && !y ) {
|
237
|
245
|
xengine->setCursor( slop::LowerRightCorner );
|
|
@@ -263,7 +271,7 @@ int main( int argc, char** argv ) {
|
263
|
271
|
// Delete the rectangle, which will remove it from the screen.
|
264
|
272
|
delete selection;
|
265
|
273
|
// Print the selection :)
|
266
|
|
- printSelection( false, x, y, w, h );
|
|
274
|
+ printSelection( false, x, y, w, h, window );
|
267
|
275
|
break;
|
268
|
276
|
}
|
269
|
277
|
}
|