Przeglądaj źródła

slop should no longer crash grabbing the keyboard

naelstrof 7 lat temu
rodzic
commit
eeadb3437a
2 zmienionych plików z 14 dodań i 2 usunięć
  1. 1
    1
      CMakeLists.txt
  2. 13
    1
      src/slop.cpp

+ 1
- 1
CMakeLists.txt Wyświetl plik

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

+ 13
- 1
src/slop.cpp Wyświetl plik

@@ -25,6 +25,10 @@ Resource* resource;
25 25
 SlopSelection GLSlopSelect( slop::SlopOptions* options, bool* cancelled, slop::SlopWindow* window );
26 26
 SlopSelection XShapeSlopSelect( slop::SlopOptions* options, bool* cancelled);
27 27
 
28
+static int TmpXError(Display * d, XErrorEvent * ev) {
29
+    return 0;
30
+}
31
+
28 32
 }
29 33
 
30 34
 using namespace slop;
@@ -69,7 +73,15 @@ slop::SlopSelection slop::SlopSelect( slop::SlopOptions* options, bool* cancelle
69 73
     resource = new Resource();
70 74
     // Set up x11 temporarily
71 75
     x11 = new X11(options->xdisplay);
72
-    keyboard = new Keyboard( x11 );
76
+    XErrorHandler ph = XSetErrorHandler(slop::TmpXError);
77
+    try {
78
+        keyboard = new Keyboard( x11 );
79
+    } catch (...) {
80
+        if ( !quiet && !options->nokeyboard) {
81
+            std::cerr << "Failed to grab keyboard, continuing...\n";
82
+        }
83
+    }
84
+    XSetErrorHandler(ph);
73 85
     bool success = false;
74 86
     std::string errorstring = "";
75 87
     SlopWindow* window;