Browse Source

Fixed slop from returning the wrong window ID in certain situations.

Dalton Nell 9 years ago
parent
commit
1d53e9f23a
6 changed files with 15 additions and 4 deletions
  1. 1
    1
      README.md
  2. 1
    1
      cmdline.h
  3. 3
    1
      main.cpp
  4. 1
    1
      options.ggo
  5. 7
    0
      x.cpp
  6. 2
    0
      x.hpp

+ 1
- 1
README.md View File

@@ -67,7 +67,7 @@ Make sure to check out and install [maim](https://github.com/naelstrof/maim) too
67 67
 help
68 68
 ----
69 69
 ```text
70
-slop v3.1.4
70
+slop v3.1.5
71 71
 
72 72
 Copyright (C) 2014 Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors)
73 73
 

+ 1
- 1
cmdline.h View File

@@ -31,7 +31,7 @@ extern "C" {
31 31
 
32 32
 #ifndef CMDLINE_PARSER_VERSION
33 33
 /** @brief the program version */
34
-#define CMDLINE_PARSER_VERSION "v3.1.4"
34
+#define CMDLINE_PARSER_VERSION "v3.1.5"
35 35
 #endif
36 36
 
37 37
 /** @brief Where the command line options are stored */

+ 3
- 1
main.cpp View File

@@ -213,7 +213,9 @@ int main( int argc, char** argv ) {
213 213
                     } else {
214 214
                         selection->setGeo( t.m_x, t.m_y, t.m_x + t.m_width, t.m_y + t.m_height );
215 215
                     }
216
-                    window = xengine->m_hoverWindow;
216
+                    //window = xengine->m_hoverWindow;
217
+                    // Since WindowRectangle can select different windows depending on click location...
218
+                    window = t.getWindow();
217 219
                 }
218 220
                 // If the user clicked we move on to the next state.
219 221
                 if ( xengine->mouseDown( 1 ) ) {

+ 1
- 1
options.ggo View File

@@ -1,5 +1,5 @@
1 1
 package "slop"
2
-version "v3.1.4"
2
+version "v3.1.5"
3 3
 usage "slop [options]"
4 4
 description "slop (Select Operation) is an application that queries for a selection from the user and prints the region to stdout."
5 5
 versiontext "Copyright (C) 2014 Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors)"

+ 7
- 0
x.cpp View File

@@ -288,6 +288,10 @@ void slop::WindowRectangle::applyPadding( int padding ) {
288 288
     }
289 289
 }
290 290
 
291
+Window slop::WindowRectangle::getWindow() {
292
+    return m_window;
293
+}
294
+
291 295
 void slop::WindowRectangle::applyMinMaxSize( int minimumsize, int maximumsize ) {
292 296
     if ( minimumsize > maximumsize && maximumsize > 0 ) {
293 297
         fprintf( stderr, "Error: minimumsize is greater than maximumsize.\n" );
@@ -337,6 +341,8 @@ void slop::WindowRectangle::setGeometry( Window win, bool decorations ) {
337 341
             status = XQueryTree( xengine->m_display, test, &root, &parent, &childlist, &ujunk);
338 342
             free( childlist );
339 343
         }
344
+        // test contains the window we're screenshotting.
345
+        m_window = test;
340 346
         // Once found, proceed normally.
341 347
         if ( test && parent == root && status ) {
342 348
             XWindowAttributes attr;
@@ -362,4 +368,5 @@ void slop::WindowRectangle::setGeometry( Window win, bool decorations ) {
362 368
     m_height = attr.height;
363 369
     m_border = attr.border_width;
364 370
     XTranslateCoordinates( xengine->m_display, win, attr.root, -attr.border_width, -attr.border_width, &(m_x), &(m_y), &junk );
371
+    m_window = win;
365 372
 }

+ 2
- 0
x.hpp View File

@@ -56,7 +56,9 @@ public:
56 56
     unsigned int m_width;
57 57
     unsigned int m_height;
58 58
     unsigned int m_border;
59
+    Window       m_window;
59 60
     bool         m_decorations;
61
+    Window       getWindow();
60 62
     void         setGeometry( Window win, bool decorations );
61 63
     void         applyPadding( int padding );
62 64
     void         applyMinMaxSize( int minimumsize, int maximumsize );