Prechádzať zdrojové kódy

Manually reposition stalonetray

Sometimes there seems to be a gap of one icon
Thomas Dy 8 rokov pred
rodič
commit
ec5da066d4
2 zmenil súbory, kde vykonal 11 pridanie a 4 odobranie
  1. 9 4
      src/wm.rs
  2. 2 0
      src/x11.rs

+ 9 - 4
src/wm.rs

@@ -23,15 +23,20 @@ pub fn wm(tx: &Channel, _config: &Config) {
         let screen = conn.default_screen();
         let mut last_win = screen.get_active_window();
         comm::send(tx, "title", conn.get_window_name(last_win).as_ref());
-        conn.watch(screen.root, true);
-        conn.watch(last_win, true);
-        conn.flush();
 
         let stalonetray = wait_for(|| screen.search_by_class("stalonetray"));
         let panel = wait_for(|| screen.search_by_name("__panel_top"));
+        let width = xcb::get_geometry(&conn, stalonetray).get_reply().unwrap().width();
 
-        xcb::configure_window(&conn, stalonetray, &[(xcb::CONFIG_WINDOW_SIBLING as u16, panel), (xcb::CONFIG_WINDOW_STACK_MODE as u16, xcb::STACK_MODE_ABOVE)]);
+        xcb::configure_window(&conn, stalonetray, &[
+            (xcb::CONFIG_WINDOW_X as u16, (screen.width - width) as u32),
+            (xcb::CONFIG_WINDOW_SIBLING as u16, panel),
+            (xcb::CONFIG_WINDOW_STACK_MODE as u16, xcb::STACK_MODE_ABOVE)
+        ]);
         xcb::change_window_attributes(&conn, stalonetray, &[(xcb::CW_EVENT_MASK, xcb::EVENT_MASK_STRUCTURE_NOTIFY)]);
+        conn.watch(screen.root, true);
+        conn.watch(last_win, true);
+        conn.flush();
 
         conn.event_loop(&mut |event: &xcb::GenericEvent| {
             match event.response_type() {

+ 2 - 0
src/x11.rs

@@ -64,6 +64,7 @@ impl Connection {
             conn: &self,
             atoms: &self.atoms,
             root: screen.root(),
+            width: screen.width_in_pixels(),
             index: index
         }
     }
@@ -145,6 +146,7 @@ pub struct Screen<'a> {
     conn: &'a Connection,
     pub atoms: &'a Atoms,
     pub root: xcb::Window,
+    pub width: u16,
     pub index: usize
 }