浏览代码

added delay to legacy updates to fix lag, and prevented mouse from selecting unmapped windows

naelstrof 7 年前
父节点
当前提交
dbe3e4f987
共有 3 个文件被更改,包括 9 次插入2 次删除
  1. 3
    1
      CMakeLists.txt
  2. 5
    0
      src/mouse.cpp
  3. 1
    1
      src/xslop.cpp

+ 3
- 1
CMakeLists.txt 查看文件

@@ -6,7 +6,7 @@ if ( NOT CMAKE_INSTALL_PREFIX )
6 6
 endif()
7 7
 
8 8
 if ( NOT SLOP_LEGACY_MODE )
9
-    set(SLOP_LEGACY_MODE FALSE CACHE BOOL "Legacy mode requires the XShape extension, is laggy, isn't guaranteed to be invisible on shutdown, isn't guaranteed to support opacity, and doesn't support custom shaders. Though it still might be desired since it doesn't require OpenGL to use.")
9
+    set(SLOP_LEGACY_MODE FALSE CACHE BOOL "Legacy mode requires the XShape extension, is laggy, isn't guaranteed to be invisible on shutdown, isn't guaranteed to support opacity, doesn't support custom shaders, and requires C++11 for the sleep_for functions. Though it still might be desired since it doesn't require OpenGL to use.")
10 10
 endif()
11 11
 
12 12
 project(slop)
@@ -63,6 +63,8 @@ if ( SLOP_LEGACY_MODE )
63 63
     find_package(XExt REQUIRED)
64 64
     include_directories(${XEXT_INCLUDE_DIR})
65 65
     target_link_libraries(${EXECUTABLE_NAME} ${XEXT_LIBRARIES})
66
+    set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 11)
67
+    set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
66 68
 else()
67 69
     find_package(GLX REQUIRED)
68 70
     find_package(OpenGL REQUIRED)

+ 5
- 0
src/mouse.cpp 查看文件

@@ -91,6 +91,11 @@ Window Mouse::findWindow( Window foo ) {
91 91
         if ( children[i] == ignoreWindow ) {
92 92
             continue;
93 93
         }
94
+        XWindowAttributes attr;         
95
+        XGetWindowAttributes( x11->display, children[i], &attr );
96
+        if ( attr.map_state != IsViewable ) {
97
+            continue;
98
+        }
94 99
         glm::vec4 rect = getWindowGeometry(children[i], false);
95 100
         float a = pos.x - rect.x;
96 101
         float b = pos.y - rect.y;

+ 1
- 1
src/xslop.cpp 查看文件

@@ -96,8 +96,8 @@ SlopSelection SlopSelect( SlopOptions* options, bool* cancelled ) {
96 96
         memory.draw( fake );
97 97
 
98 98
         // X11 explodes if we update as fast as possible, here's a tiny sleep.
99
-        //std::this_thread::sleep_for(std::chrono::milliseconds(10));
100 99
         XFlush(x11->display);
100
+        std::this_thread::sleep_for(std::chrono::milliseconds(10));
101 101
 
102 102
         // Then we draw the framebuffer to the screen
103 103
         if ( keyboard->anyKeyDown() || mouse->getButton( 3 ) ) {