浏览代码

slop should no longer crash grabbing the keyboard

naelstrof 8 年前
父节点
当前提交
eeadb3437a
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 1
    1
      CMakeLists.txt
  2. 13
    1
      src/slop.cpp

+ 1
- 1
CMakeLists.txt 查看文件

21
 
21
 
22
 include_directories("${PROJECT_BINARY_DIR}")
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
 # 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
- 1
src/slop.cpp 查看文件

25
 SlopSelection GLSlopSelect( slop::SlopOptions* options, bool* cancelled, slop::SlopWindow* window );
25
 SlopSelection GLSlopSelect( slop::SlopOptions* options, bool* cancelled, slop::SlopWindow* window );
26
 SlopSelection XShapeSlopSelect( slop::SlopOptions* options, bool* cancelled);
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
 using namespace slop;
34
 using namespace slop;
69
     resource = new Resource();
73
     resource = new Resource();
70
     // Set up x11 temporarily
74
     // Set up x11 temporarily
71
     x11 = new X11(options->xdisplay);
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
     bool success = false;
85
     bool success = false;
74
     std::string errorstring = "";
86
     std::string errorstring = "";
75
     SlopWindow* window;
87
     SlopWindow* window;