Explorar el Código

Now you can select the level of aggressiveness when removing window borders.

naelstrof hace 7 años
padre
commit
03a2956e47
Se han modificado 7 ficheros con 29 adiciones y 17 borrados
  1. 2
    2
      slop.1
  2. BIN
      slop.1.gz
  3. 7
    3
      src/main.cpp
  4. 16
    8
      src/mouse.cpp
  5. 2
    2
      src/mouse.hpp
  6. 1
    1
      src/options.hpp
  7. 1
    1
      src/slop.hpp

+ 2
- 2
slop.1 Ver fichero

@@ -39,8 +39,8 @@ This sets the vertex shader, and fragment shader combo to use when drawing the f
39 39
 .BR \-f ", " \-\-format=\fISTRING\fR
40 40
 Sets the output format for slop. Format specifiers are %x, %y, %w, %h, %i, and %g. If actual percentage signs are desired in output, use a double percentage sign like so `%%`.
41 41
 .TP
42
-.BR \-n ", " \-\-nodecorations
43
-Attempt to select child windows, instead of the surface-level windows. This will typically avoid window decorations.
42
+.BR \-n ", " \-\-nodecorations=INT
43
+Sets the level of aggressiveness when trying to remove window decroations. `0' is off, `1' will try lightly to remove decorations, and `2' will recursively descend into the root tree until it gets the deepest available visible child under the mouse. Defaults to `0'.
44 44
 .TP
45 45
 .BR \-l ", " \-\-highlight
46 46
 Instead of outlining a selection, slop will highlight it instead. This is particularly useful if the color is set to an opacity lower than 1.

BIN
slop.1.gz Ver fichero


+ 7
- 3
src/main.cpp Ver fichero

@@ -38,7 +38,7 @@ SlopOptions* getOptions( Options& options ) {
38 38
     foo->b = color.b;
39 39
     foo->a = color.a;
40 40
     options.getBool("highlight", 'l', foo->highlight);
41
-    options.getBool("nodecorations", 'n', foo->nodecorations);
41
+    options.getInt("nodecorations", 'n', foo->nodecorations);
42 42
     return foo;
43 43
 }
44 44
 
@@ -108,8 +108,12 @@ void printHelp() {
108 108
 	std::cout << "                                Set the selection rectangle's color. Supports\n";
109 109
 	std::cout << "                                  RGB or RGBA values.\n";
110 110
 	std::cout << "                                  (default=`0.5,0.5,0.5,1')\n";
111
-	std::cout << "  -n, --nodecorations           Attempt to select child windows in order to\n";
112
-	std::cout << "                                  avoid window decorations.  (default=off)\n";
111
+	std::cout << "  -n, --nodecorations=INT           Attempt to select child windows in order to\n";
112
+	std::cout << "                                  avoid window decorations. Setting this to\n";
113
+    std::cout << "                                  1 will enable a light attempt to\n";
114
+    std::cout << "                                  remove decorations. Setting this to 2 will\n";
115
+    std::cout << "                                  enable an aggressive decoration removal.\n";
116
+    std::cout << "                                  (default=`0')\n";
113 117
 	std::cout << "  -l, --highlight               Instead of outlining selections, slop\n";
114 118
 	std::cout << "                                  highlights it. This is only useful when\n";
115 119
 	std::cout << "                                  --color is set to a transparent color.\n";

+ 16
- 8
src/mouse.cpp Ver fichero

@@ -39,7 +39,7 @@ void Mouse::setCursor( int cursor ) {
39 39
                               xcursor, CurrentTime );
40 40
 }
41 41
 
42
-Mouse::Mouse(X11* x11, bool nodecorations, Window ignoreWindow ) {
42
+Mouse::Mouse(X11* x11, int nodecorations, Window ignoreWindow ) {
43 43
     this->x11 = x11;
44 44
     currentCursor = XC_cross;
45 45
     xcursor = XCreateFontCursor( x11->display, XC_cross );
@@ -83,10 +83,10 @@ Window Mouse::findWindow( Window foo ) {
83 83
     unsigned int nchildren;
84 84
     Window selectedWindow;
85 85
     XQueryTree( x11->display, foo, &root, &parent, &children, &nchildren );
86
-    // The children are ordered, so we traverse backwards.
87 86
     if ( !children || nchildren <= 0 ) {
88 87
         return foo;
89 88
     }
89
+    // The children are ordered, so we traverse backwards.
90 90
     for( int i=nchildren-1;i>=0;i-- ) {
91 91
         if ( children[i] == ignoreWindow ) {
92 92
             continue;
@@ -103,12 +103,20 @@ Window Mouse::findWindow( Window foo ) {
103 103
         if ( a <= rect.z && a >= 0 ) {
104 104
             if ( b <= rect.w && b >= 0 ) {
105 105
                 selectedWindow = children[i];
106
-                if ( !nodecorations ) {
107
-                    XFree(children);
108
-                    return selectedWindow;
109
-                } else {
110
-                    XFree(children);
111
-                    return findWindow( selectedWindow );
106
+                switch( nodecorations ) {
107
+                    case 0:
108
+                        XFree(children);
109
+                        return selectedWindow;
110
+                    case 1:
111
+                        XFree(children);
112
+                        //return findWindow( selectedWindow );
113
+                        XQueryTree( x11->display, selectedWindow, &root, &parent, &children, &nchildren );
114
+                        if ( !children || nchildren <= 0 ) {
115
+                            return selectedWindow;
116
+                        }
117
+                        return children[nchildren-1];
118
+                    case 2:
119
+                        return findWindow( selectedWindow );
112 120
                 }
113 121
             }
114 122
         }

+ 2
- 2
src/mouse.hpp Ver fichero

@@ -36,12 +36,12 @@ private:
36 36
     Cursor xcursor;
37 37
     int currentCursor;
38 38
     Window findWindow( Window foo );
39
-    bool nodecorations;
39
+    int nodecorations;
40 40
     Window ignoreWindow;
41 41
 public:
42 42
 	Window hoverWindow;
43 43
 	void update();
44
-    Mouse( X11* x11, bool nodecorations, Window ignoreWindow );
44
+    Mouse( X11* x11, int nodecorations, Window ignoreWindow );
45 45
     ~Mouse();
46 46
     void setCursor( int cursor );
47 47
     glm::vec2 getMousePos();

+ 1
- 1
src/options.hpp Ver fichero

@@ -30,7 +30,7 @@
30 30
 
31 31
 static std::string validStringArguments[] = { "bordersize", "padding", "color", "shader", "highlight", "format", "tolerance", "nodecorations", "nokeyboard", "help", "xdisplay", "version" };
32 32
 static char validCharArguments[] = { 'b', 'p', 'c', 's', 'l', 'f', 't', 'n', 'k', 'h', 'x', 'v' };
33
-static unsigned int isFlagArgument[] = { false, false, false, false, true, false, false, true, true, true, false, true };
33
+static unsigned int isFlagArgument[] = { false, false, false, false, true, false, false, false, true, true, false, true };
34 34
 static unsigned int validArgumentCount = 12;
35 35
 static unsigned int maxFloatingValues = 0;
36 36
 

+ 1
- 1
src/slop.hpp Ver fichero

@@ -44,7 +44,7 @@ public:
44 44
     float tolerance;
45 45
     bool highlight;
46 46
     bool nokeyboard;
47
-    bool nodecorations;
47
+    int nodecorations;
48 48
     std::string shader;
49 49
     float r;
50 50
     float g;