Browse Source

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

naelstrof 7 years ago
parent
commit
8a4f1c20f2
2 changed files with 14 additions and 8 deletions
  1. 1
    1
      CMakeLists.txt
  2. 13
    7
      src/slop.cpp

+ 1
- 1
CMakeLists.txt View File

21
 
21
 
22
 include_directories("${PROJECT_BINARY_DIR}")
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
 # The names have to be unique unfortunately.
26
 # The names have to be unique unfortunately.
27
 set(EXECUTABLE_NAME "slop")
27
 set(EXECUTABLE_NAME "slop")

+ 13
- 7
src/slop.cpp View File

73
     resource = new Resource();
73
     resource = new Resource();
74
     // Set up x11 temporarily
74
     // Set up x11 temporarily
75
     x11 = new X11(options->xdisplay);
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
     bool success = false;
81
     bool success = false;
80
     std::string errorstring = "";
82
     std::string errorstring = "";
81
     SlopWindow* window;
83
     SlopWindow* window;
126
     // This is where we'll run through all of our stuffs
128
     // This is where we'll run through all of our stuffs
127
     while( memory.running ) {
129
     while( memory.running ) {
128
         slop::mouse->update();
130
         slop::mouse->update();
129
-        slop::keyboard->update();
131
+        if ( !options->nokeyboard ) {
132
+            slop::keyboard->update();
133
+        }
130
         // We move our statemachine forward.
134
         // We move our statemachine forward.
131
         memory.update( 1 );
135
         memory.update( 1 );
132
 
136
 
139
         std::this_thread::sleep_for(std::chrono::milliseconds(10));
143
         std::this_thread::sleep_for(std::chrono::milliseconds(10));
140
 
144
 
141
         // Then we draw the framebuffer to the screen
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
             memory.running = false;
147
             memory.running = false;
144
             if ( cancelled ) {
148
             if ( cancelled ) {
145
                 *cancelled = true;
149
                 *cancelled = true;
173
     // This is where we'll run through all of our stuffs
177
     // This is where we'll run through all of our stuffs
174
     while( memory.running ) {
178
     while( memory.running ) {
175
         slop::mouse->update();
179
         slop::mouse->update();
176
-        slop::keyboard->update();
180
+        if ( !options->nokeyboard ) {
181
+            slop::keyboard->update();
182
+        }
177
         // We move our statemachine forward.
183
         // We move our statemachine forward.
178
         memory.update( 1 );
184
         memory.update( 1 );
179
 
185
 
191
         if ( err != GL_NO_ERROR ) {
197
         if ( err != GL_NO_ERROR ) {
192
             throw err;
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
             memory.running = false;
201
             memory.running = false;
196
             if ( cancelled ) {
202
             if ( cancelled ) {
197
                 *cancelled = true;
203
                 *cancelled = true;