Browse Source

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

naelstrof 7 years ago
parent
commit
dbe3e4f987
3 changed files with 9 additions and 2 deletions
  1. 3
    1
      CMakeLists.txt
  2. 5
    0
      src/mouse.cpp
  3. 1
    1
      src/xslop.cpp

+ 3
- 1
CMakeLists.txt View File

6
 endif()
6
 endif()
7
 
7
 
8
 if ( NOT SLOP_LEGACY_MODE )
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
 endif()
10
 endif()
11
 
11
 
12
 project(slop)
12
 project(slop)
63
     find_package(XExt REQUIRED)
63
     find_package(XExt REQUIRED)
64
     include_directories(${XEXT_INCLUDE_DIR})
64
     include_directories(${XEXT_INCLUDE_DIR})
65
     target_link_libraries(${EXECUTABLE_NAME} ${XEXT_LIBRARIES})
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
 else()
68
 else()
67
     find_package(GLX REQUIRED)
69
     find_package(GLX REQUIRED)
68
     find_package(OpenGL REQUIRED)
70
     find_package(OpenGL REQUIRED)

+ 5
- 0
src/mouse.cpp View File

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

+ 1
- 1
src/xslop.cpp View File

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