forked from michael/leanshot
get active window
This commit is contained in:
parent
a9511b94de
commit
f9126c4f83
2 changed files with 16 additions and 6 deletions
10
src/gui.rs
10
src/gui.rs
|
@ -20,12 +20,10 @@ impl GUI {
|
||||||
|
|
||||||
/// Get the active window.
|
/// Get the active window.
|
||||||
pub fn get_active_window(&self) -> Result<Window, ScreenshotError> {
|
pub fn get_active_window(&self) -> Result<Window, ScreenshotError> {
|
||||||
Ok(self.display.get_default_root_window()?)
|
self.display
|
||||||
// let mut window: Window = self.display.get_default_root_window();
|
.get_input_focus()
|
||||||
// let mut revert_to_return: i32 = RevertToParent;
|
.map(|(window, _)| window)
|
||||||
// unsafe { XGetInputFocus(self.display, &mut window, &mut revert_to_return) };
|
.map_err(|err| err.into())
|
||||||
// unsafe { XMapRaised(self.display, window) };
|
|
||||||
// window
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Brings up an interactive selection GUI.
|
/// Brings up an interactive selection GUI.
|
||||||
|
|
|
@ -38,6 +38,18 @@ impl Display {
|
||||||
};
|
};
|
||||||
Ok(window)
|
Ok(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// eturns the focus window and the current focus state.
|
||||||
|
pub fn get_input_focus(&self) -> Result<(Window, i32), X11Error> {
|
||||||
|
let mut focus_return: x::Window = 0;
|
||||||
|
let mut revert_to_return = 0;
|
||||||
|
unsafe { x::XGetInputFocus(self.inner, &mut focus_return, &mut revert_to_return) };
|
||||||
|
let window = Window {
|
||||||
|
display: self.inner,
|
||||||
|
inner: focus_return,
|
||||||
|
};
|
||||||
|
return Ok((window, revert_to_return));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Display {
|
impl Drop for Display {
|
||||||
|
|
Loading…
Reference in a new issue