Browse Source

added an option to disable auto-window-selection and fixed a few options in the makefile

naelstrof 10 years ago
parent
commit
fdd129c997
4 changed files with 24 additions and 7 deletions
  1. 15
    6
      main.cpp
  2. 4
    1
      makefile
  3. 4
    0
      options.cpp
  4. 1
    0
      options.hpp

+ 15
- 6
main.cpp View File

92
             case 0: {
92
             case 0: {
93
                 // If xengine has found a window we're hovering over (or if it changed)
93
                 // If xengine has found a window we're hovering over (or if it changed)
94
                 // create a rectangle around it so the user knows he/she can click on it.
94
                 // create a rectangle around it so the user knows he/she can click on it.
95
-                if ( window != xengine->m_hoverXWindow ) {
95
+                // --but only if the user wants us to
96
+                if ( window != xengine->m_hoverXWindow && options->m_window ) {
96
                     // Make sure to delete the old selection rectangle.
97
                     // Make sure to delete the old selection rectangle.
97
                     if ( windowselection ) {
98
                     if ( windowselection ) {
98
                         xengine->removeRect( windowselection ); // removeRect also dealloc's the rectangle for us.
99
                         xengine->removeRect( windowselection ); // removeRect also dealloc's the rectangle for us.
185
                     }
186
                     }
186
                 }
187
                 }
187
                 // Otherwise lets grab the window's dimensions and use those (with padding).
188
                 // Otherwise lets grab the window's dimensions and use those (with padding).
188
-                slop::WindowRectangle t = xengine->m_hoverWindow;
189
-                x = t.m_x - padding - t.m_border;
190
-                y = t.m_y - padding - t.m_border;
191
-                w = t.m_width + t.m_border + padding*2;
192
-                h = t.m_height + t.m_border + padding*2;
189
+                // --but only if the user lets us, if the user doesn't just select a single pixel there.
190
+                if ( options->m_window ) {
191
+                    slop::WindowRectangle t = xengine->m_hoverWindow;
192
+                    x = t.m_x - padding - t.m_border;
193
+                    y = t.m_y - padding - t.m_border;
194
+                    w = t.m_width + t.m_border + padding*2;
195
+                    h = t.m_height + t.m_border + padding*2;
196
+                } else {
197
+                    x = cx;
198
+                    y = cy;
199
+                    w = 1;
200
+                    h = 1;
201
+                }
193
                 printf( "X=%i\n", x );
202
                 printf( "X=%i\n", x );
194
                 printf( "Y=%i\n", y );
203
                 printf( "Y=%i\n", y );
195
                 printf( "W=%i\n", w );
204
                 printf( "W=%i\n", w );

+ 4
- 1
makefile View File

1
 CC=g++
1
 CC=g++
2
-CFLAGS=-O2 -g
2
+CCFLAGS=-O2 -g
3
 LDFLAGS=-lX11 -lXext
3
 LDFLAGS=-lX11 -lXext
4
 SOURCES=main.cpp x.cpp options.cpp
4
 SOURCES=main.cpp x.cpp options.cpp
5
 OBJECTS=$(SOURCES:.cpp=.o)
5
 OBJECTS=$(SOURCES:.cpp=.o)
11
 $(EXECUTABLE): $(OBJECTS)
11
 $(EXECUTABLE): $(OBJECTS)
12
 	$(CC) $(OBJECTS) -o $@ $(LDFLAGS)
12
 	$(CC) $(OBJECTS) -o $@ $(LDFLAGS)
13
 
13
 
14
+$(OBJECTS): %.o: %.cpp
15
+	$(CC) $(CCFLAGS) -o $@ -c $<
16
+
14
 clean:
17
 clean:
15
 	rm -rf $(OBJECTS) $(EXECUTABLE)
18
 	rm -rf $(OBJECTS) $(EXECUTABLE)
16
 
19
 

+ 4
- 0
options.cpp View File

12
     m_blue = 0;
12
     m_blue = 0;
13
     m_gracetime = 0.1;
13
     m_gracetime = 0.1;
14
     m_keyboard = true;
14
     m_keyboard = true;
15
+    m_window = true;
15
 }
16
 }
16
 
17
 
17
 void slop::Options::printHelp() {
18
 void slop::Options::printHelp() {
27
     printf( "    -x=STRING, --xdisplay=STRING   set x display (STRING must be hostname:number.screen_number format)\n" );
28
     printf( "    -x=STRING, --xdisplay=STRING   set x display (STRING must be hostname:number.screen_number format)\n" );
28
     printf( "    -c=COLOR, --color=COLOR        set selection rectangle color, COLOR is in format FLOAT,FLOAT,FLOAT\n" );
29
     printf( "    -c=COLOR, --color=COLOR        set selection rectangle color, COLOR is in format FLOAT,FLOAT,FLOAT\n" );
29
     printf( "    -g=FLOAT, --gracetime=FLOAT    set the amount of time before slop will check for keyboard cancellations in seconds.\n" );
30
     printf( "    -g=FLOAT, --gracetime=FLOAT    set the amount of time before slop will check for keyboard cancellations in seconds.\n" );
31
+    printf( "    -nw, --nowindow                disable automatically selecting a whole window on single-clicks, and instead just select a single pixel.\n" );
30
     printf( "examples\n" );
32
     printf( "examples\n" );
31
     printf( "    slop -b=10 -x=:0 -p=-30 -t=4 -c=0.5,0.5,0.5 -g=.2\n" );
33
     printf( "    slop -b=10 -x=:0 -p=-30 -t=4 -c=0.5,0.5,0.5 -g=.2\n" );
32
 }
34
 }
77
             }
79
             }
78
         } else if ( matches( arg, "-nkb", "--nokeyboard" ) ) {
80
         } else if ( matches( arg, "-nkb", "--nokeyboard" ) ) {
79
             m_keyboard = false;
81
             m_keyboard = false;
82
+        } else if ( matches( arg, "-nw", "--nowindow" ) ) {
83
+            m_window = false;
80
         } else if ( matches( arg, "-h", "--help" ) ) {
84
         } else if ( matches( arg, "-h", "--help" ) ) {
81
             printHelp();
85
             printHelp();
82
             return 2;
86
             return 2;

+ 1
- 0
options.hpp View File

20
     std::string m_xdisplay;
20
     std::string m_xdisplay;
21
     float       m_gracetime;
21
     float       m_gracetime;
22
     bool        m_keyboard;
22
     bool        m_keyboard;
23
+    bool        m_window;
23
 private:
24
 private:
24
     int         parseInt( std::string arg, int* returnInt );
25
     int         parseInt( std::string arg, int* returnInt );
25
     int         parseFloat( std::string arg, float* returnFloat );
26
     int         parseFloat( std::string arg, float* returnFloat );