Browse Source

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

naelstrof 7 years ago
parent
commit
03a2956e47
7 changed files with 29 additions and 17 deletions
  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 View File

39
 .BR \-f ", " \-\-format=\fISTRING\fR
39
 .BR \-f ", " \-\-format=\fISTRING\fR
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 `%%`.
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
 .TP
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
 .TP
44
 .TP
45
 .BR \-l ", " \-\-highlight
45
 .BR \-l ", " \-\-highlight
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.
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 View File


+ 7
- 3
src/main.cpp View File

38
     foo->b = color.b;
38
     foo->b = color.b;
39
     foo->a = color.a;
39
     foo->a = color.a;
40
     options.getBool("highlight", 'l', foo->highlight);
40
     options.getBool("highlight", 'l', foo->highlight);
41
-    options.getBool("nodecorations", 'n', foo->nodecorations);
41
+    options.getInt("nodecorations", 'n', foo->nodecorations);
42
     return foo;
42
     return foo;
43
 }
43
 }
44
 
44
 
108
 	std::cout << "                                Set the selection rectangle's color. Supports\n";
108
 	std::cout << "                                Set the selection rectangle's color. Supports\n";
109
 	std::cout << "                                  RGB or RGBA values.\n";
109
 	std::cout << "                                  RGB or RGBA values.\n";
110
 	std::cout << "                                  (default=`0.5,0.5,0.5,1')\n";
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
 	std::cout << "  -l, --highlight               Instead of outlining selections, slop\n";
117
 	std::cout << "  -l, --highlight               Instead of outlining selections, slop\n";
114
 	std::cout << "                                  highlights it. This is only useful when\n";
118
 	std::cout << "                                  highlights it. This is only useful when\n";
115
 	std::cout << "                                  --color is set to a transparent color.\n";
119
 	std::cout << "                                  --color is set to a transparent color.\n";

+ 16
- 8
src/mouse.cpp View File

39
                               xcursor, CurrentTime );
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
     this->x11 = x11;
43
     this->x11 = x11;
44
     currentCursor = XC_cross;
44
     currentCursor = XC_cross;
45
     xcursor = XCreateFontCursor( x11->display, XC_cross );
45
     xcursor = XCreateFontCursor( x11->display, XC_cross );
83
     unsigned int nchildren;
83
     unsigned int nchildren;
84
     Window selectedWindow;
84
     Window selectedWindow;
85
     XQueryTree( x11->display, foo, &root, &parent, &children, &nchildren );
85
     XQueryTree( x11->display, foo, &root, &parent, &children, &nchildren );
86
-    // The children are ordered, so we traverse backwards.
87
     if ( !children || nchildren <= 0 ) {
86
     if ( !children || nchildren <= 0 ) {
88
         return foo;
87
         return foo;
89
     }
88
     }
89
+    // The children are ordered, so we traverse backwards.
90
     for( int i=nchildren-1;i>=0;i-- ) {
90
     for( int i=nchildren-1;i>=0;i-- ) {
91
         if ( children[i] == ignoreWindow ) {
91
         if ( children[i] == ignoreWindow ) {
92
             continue;
92
             continue;
103
         if ( a <= rect.z && a >= 0 ) {
103
         if ( a <= rect.z && a >= 0 ) {
104
             if ( b <= rect.w && b >= 0 ) {
104
             if ( b <= rect.w && b >= 0 ) {
105
                 selectedWindow = children[i];
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 View File

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

+ 1
- 1
src/options.hpp View File

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

+ 1
- 1
src/slop.hpp View File

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