Przeglądaj źródła

fixed failing to grab keyboard

naelstrof 10 lat temu
rodzic
commit
67130952ca
1 zmienionych plików z 7 dodań i 3 usunięć
  1. 7
    3
      x.cpp

+ 7
- 3
x.cpp Wyświetl plik

@@ -61,7 +61,8 @@ int slop::XEngine::init( std::string display ) {
61 61
     m_screen    = ScreenOfDisplay( m_display, DefaultScreen( m_display ) );
62 62
     m_visual    = DefaultVisual  ( m_display, XScreenNumberOfScreen( m_screen ) );
63 63
     m_colormap  = DefaultColormap( m_display, XScreenNumberOfScreen( m_screen ) );
64
-    m_root      = RootWindow     ( m_display, XScreenNumberOfScreen( m_screen ) );
64
+    //m_root      = RootWindow     ( m_display, XScreenNumberOfScreen( m_screen ) );
65
+    m_root      = DefaultRootWindow( m_display );
65 66
 
66 67
     m_good = true;
67 68
     return 0;
@@ -71,14 +72,17 @@ int slop::XEngine::grabKeyboard() {
71 72
     if ( !m_good ) {
72 73
         return 1;
73 74
     }
74
-    int err = XGrabKeyboard( m_display, m_root, False,
75
+    XGrabKey( m_display, AnyKey, AnyModifier, m_root, False, GrabModeAsync, GrabModeAsync );
76
+    // For whatever we fail to grab the keyboard 100% of the time if slop is launched in the background.
77
+    /*int err = XGrabKeyboard( m_display, m_root, False,
75 78
                              GrabModeAsync, GrabModeAsync, CurrentTime );
76 79
     if ( err != GrabSuccess ) {
77 80
         fprintf( stderr, "Error: Failed to grab X keyboard.\n" );
78 81
         fprintf( stderr, "This can be caused by launching slop incorrectly.\n" );
79 82
         fprintf( stderr, "gnome-session launches it fine from keyboard binds.\n" );
80 83
         return 1;
81
-    }
84
+    }*/
85
+    return 0;
82 86
 }
83 87
 
84 88
 int slop::XEngine::releaseKeyboard() {