1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use crate::display_action::DisplayAction;
use crate::models::Mode;
use crate::models::WindowHandle;
use crate::state::State;
use crate::utils;
use crate::utils::modmask_lookup::Button;
use crate::utils::modmask_lookup::ModMask;
use x11_dl::xlib;
impl State {
pub fn mouse_combo_handler(
&mut self,
modmask: ModMask,
button: Button,
handle: WindowHandle,
x: i32,
y: i32,
) -> bool {
if let Some(window) = self.windows.iter().find(|w| w.handle == handle) {
if !self.disable_tile_drag || window.floating() {
let modifier = utils::modmask_lookup::into_modmask(&self.mousekey);
let act = self.build_action(modmask, button, handle, modifier);
if let Some(act) = act {
self.actions.push_back(act);
return false;
}
}
} else if self.focus_manager.behaviour.is_clickto() {
if let xlib::Button1 | xlib::Button3 = button {
if self.screens.iter().any(|s| s.root == handle) {
self.focus_workspace_with_point(x, y);
return false;
}
}
}
true
}
fn build_action(
&mut self,
mod_mask: ModMask,
button: Button,
window: WindowHandle,
modifier: ModMask,
) -> Option<DisplayAction> {
let is_mouse_key = mod_mask == modifier || mod_mask == (modifier | xlib::ShiftMask);
match button {
xlib::Button1 if is_mouse_key => {
let _ = self
.windows
.iter()
.find(|w| w.handle == window && w.can_move())?;
self.mode = Mode::ReadyToMove(window);
Some(DisplayAction::ReadyToMoveWindow(window))
}
xlib::Button3 if is_mouse_key => {
let _ = self
.windows
.iter()
.find(|w| w.handle == window && w.can_resize())?;
self.mode = Mode::ReadyToResize(window);
Some(DisplayAction::ReadyToResizeWindow(window))
}
xlib::Button1 | xlib::Button3 if self.focus_manager.behaviour.is_clickto() => {
self.focus_window(&window);
Some(DisplayAction::ReplayClick(window, button))
}
_ => None,
}
}
}