소스 검색

Don't attempt to grab keyboard if --nokeyboard. Thanks #63

naelstrof 7 년 전
부모
커밋
8a4f1c20f2
2개의 변경된 파일14개의 추가작업 그리고 8개의 파일을 삭제
  1. 1
    1
      CMakeLists.txt
  2. 13
    7
      src/slop.cpp

+ 1
- 1
CMakeLists.txt 파일 보기

@@ -21,7 +21,7 @@ endif()
21 21
 
22 22
 include_directories("${PROJECT_BINARY_DIR}")
23 23
 
24
-add_definitions(-DSLOP_VERSION="v5.3.30")
24
+add_definitions(-DSLOP_VERSION="v5.3.31")
25 25
 
26 26
 # The names have to be unique unfortunately.
27 27
 set(EXECUTABLE_NAME "slop")

+ 13
- 7
src/slop.cpp 파일 보기

@@ -73,9 +73,11 @@ slop::SlopSelection slop::SlopSelect( slop::SlopOptions* options, bool* cancelle
73 73
     resource = new Resource();
74 74
     // Set up x11 temporarily
75 75
     x11 = new X11(options->xdisplay);
76
-    XErrorHandler ph = XSetErrorHandler(slop::TmpXError);
77
-    keyboard = new Keyboard( x11 );
78
-    XSetErrorHandler(ph);
76
+    if ( !options->nokeyboard ) {
77
+        XErrorHandler ph = XSetErrorHandler(slop::TmpXError);
78
+        keyboard = new Keyboard( x11 );
79
+        XSetErrorHandler(ph);
80
+    }
79 81
     bool success = false;
80 82
     std::string errorstring = "";
81 83
     SlopWindow* window;
@@ -126,7 +128,9 @@ slop::SlopSelection slop::XShapeSlopSelect( slop::SlopOptions* options, bool* ca
126 128
     // This is where we'll run through all of our stuffs
127 129
     while( memory.running ) {
128 130
         slop::mouse->update();
129
-        slop::keyboard->update();
131
+        if ( !options->nokeyboard ) {
132
+            slop::keyboard->update();
133
+        }
130 134
         // We move our statemachine forward.
131 135
         memory.update( 1 );
132 136
 
@@ -139,7 +143,7 @@ slop::SlopSelection slop::XShapeSlopSelect( slop::SlopOptions* options, bool* ca
139 143
         std::this_thread::sleep_for(std::chrono::milliseconds(10));
140 144
 
141 145
         // Then we draw the framebuffer to the screen
142
-        if ( (slop::keyboard->anyKeyDown() && !options->nokeyboard) || slop::mouse->getButton( 3 ) ) {
146
+        if ( (!options->nokeyboard && slop::keyboard->anyKeyDown()) || slop::mouse->getButton( 3 ) ) {
143 147
             memory.running = false;
144 148
             if ( cancelled ) {
145 149
                 *cancelled = true;
@@ -173,7 +177,9 @@ slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, bool* cancel
173 177
     // This is where we'll run through all of our stuffs
174 178
     while( memory.running ) {
175 179
         slop::mouse->update();
176
-        slop::keyboard->update();
180
+        if ( !options->nokeyboard ) {
181
+            slop::keyboard->update();
182
+        }
177 183
         // We move our statemachine forward.
178 184
         memory.update( 1 );
179 185
 
@@ -191,7 +197,7 @@ slop::SlopSelection slop::GLSlopSelect( slop::SlopOptions* options, bool* cancel
191 197
         if ( err != GL_NO_ERROR ) {
192 198
             throw err;
193 199
         }
194
-        if ( (slop::keyboard->anyKeyDown() && !options->nokeyboard) || slop::mouse->getButton( 3 ) ) {
200
+        if ( (!options->nokeyboard && slop::keyboard->anyKeyDown()) || slop::mouse->getButton( 3 ) ) {
195 201
             memory.running = false;
196 202
             if ( cancelled ) {
197 203
                 *cancelled = true;