2017-08-06 13 views
0

私はglutinを使用するプログラムを作成しています。デスクトップウィンドウをサポートしていない特定のウィンドウマネージャーのデスクトップの壁紙として使用できるように、ウィンドウオーバーライドをリダイレクトするコマンドラインフラグを提供したいタイプ。glutinでウィンドウのオーバーライドリダイレクトを行うにはどうしたらいいですか?

私は多くの研究を行い、glutinから提供されたxlibディスプレイとウィンドウを使用して、私が思うと思ったコードブロックを一緒にまとめることができました。ここに私の既存のコードです:

unsafe { 
    use glutin::os::unix::WindowExt; 
    let x_connection = std::sync::Arc::<glutin::os::unix::x11::XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap()); 
    ((*x_connection).xlib.XChangeWindowAttributes)(
     display.gl_window().get_xlib_display().unwrap() as *mut glutin::os::unix::x11::ffi::Display, 
     display.gl_window().get_xlib_window().unwrap() as glutin::os::unix::x11::ffi::XID, 
     glutin::os::unix::x11::ffi::CWOverrideRedirect, 
     &mut glutin::os::unix::x11::ffi::XSetWindowAttributes { 
      background_pixmap: 0, 
      background_pixel: 0, 
      border_pixmap: 0, 
      border_pixel: 0, 
      bit_gravity: 0, 
      win_gravity: 0, 
      backing_store: 0, 
      backing_planes: 0, 
      backing_pixel: 0, 
      save_under: 0, 
      event_mask: 0, 
      do_not_propagate_mask: 0, 
      override_redirect: 1, 
      colormap: 0, 
      cursor: 0, 
     } 
    ); 
} 

それは私にエラーを与えるものではありませんし、コンパイルしたコードの残りの部分と細かい動作しますが、それは、ウィンドウは、私がしたいようにオーバーライドリダイレクトがありません。

答えて

1

私はそれを理解しました。オーバーライドリダイレクトは、ウィンドウがマップされているときにのみ実行されるので、マップを解除して再度マップすると機能します。ここで

は、コードは以下のようになります。

unsafe { 
    use glutin::os::unix::WindowExt; 
    use glutin::os::unix::x11::XConnection; 
    use glutin::os::unix::x11::ffi::{Display, XID, CWOverrideRedirect, XSetWindowAttributes}; 
    let x_connection = std::sync::Arc::<XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap()); 
    let x_display = display.gl_window().get_xlib_display().unwrap() as *mut Display; 
    let x_window = display.gl_window().get_xlib_window().unwrap() as XID; 
    ((*x_connection).xlib.XChangeWindowAttributes)(
     x_display, 
     x_window, 
     CWOverrideRedirect, 
     &mut XSetWindowAttributes { 
      background_pixmap: 0, 
      background_pixel: 0, 
      border_pixmap: 0, 
      border_pixel: 0, 
      bit_gravity: 0, 
      win_gravity: 0, 
      backing_store: 0, 
      backing_planes: 0, 
      backing_pixel: 0, 
      save_under: 0, 
      event_mask: 0, 
      do_not_propagate_mask: 0, 
      override_redirect: 1, 
      colormap: 0, 
      cursor: 0, 
     } 
    ); 
    ((*x_connection).xlib.XUnmapWindow)(x_display, x_window); 
    ((*x_connection).xlib.XMapWindow)(x_display, x_window); 
} 
関連する問題