mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Use early return
This commit is contained in:
+45
-44
@@ -3065,56 +3065,57 @@ impl State {
|
|||||||
fn on_tablet_tool_tip<I: InputBackend>(&mut self, event: I::TabletToolTipEvent) {
|
fn on_tablet_tool_tip<I: InputBackend>(&mut self, event: I::TabletToolTipEvent) {
|
||||||
let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());
|
let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());
|
||||||
|
|
||||||
if let Some(tool) = tool {
|
let Some(tool) = tool else {
|
||||||
let is_overview_open = self.niri.layout.is_overview_open();
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
match event.tip_state() {
|
let is_overview_open = self.niri.layout.is_overview_open();
|
||||||
TabletToolTipState::Down => {
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
|
||||||
tool.tip_down(serial, event.time_msec());
|
|
||||||
|
|
||||||
if let Some(pos) = self.niri.tablet_cursor_location {
|
match event.tip_state() {
|
||||||
let under = self.niri.contents_under(pos);
|
TabletToolTipState::Down => {
|
||||||
if let Some((window, _)) = under.window {
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
if let Some(output) = is_overview_open.then_some(under.output).flatten()
|
tool.tip_down(serial, event.time_msec());
|
||||||
{
|
|
||||||
let mut workspaces = self.niri.layout.workspaces();
|
if let Some(pos) = self.niri.tablet_cursor_location {
|
||||||
if let Some(ws_idx) = workspaces.find_map(|(_, ws_idx, ws)| {
|
let under = self.niri.contents_under(pos);
|
||||||
ws.windows().any(|w| w.window == window).then_some(ws_idx)
|
if let Some((window, _)) = under.window {
|
||||||
}) {
|
if let Some(output) = is_overview_open.then_some(under.output).flatten() {
|
||||||
drop(workspaces);
|
let mut workspaces = self.niri.layout.workspaces();
|
||||||
self.niri.layout.focus_output(&output);
|
if let Some(ws_idx) = workspaces.find_map(|(_, ws_idx, ws)| {
|
||||||
self.niri.layout.toggle_overview_to_workspace(ws_idx);
|
ws.windows().any(|w| w.window == window).then_some(ws_idx)
|
||||||
}
|
}) {
|
||||||
|
drop(workspaces);
|
||||||
|
self.niri.layout.focus_output(&output);
|
||||||
|
self.niri.layout.toggle_overview_to_workspace(ws_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.niri.layout.activate_window(&window);
|
|
||||||
|
|
||||||
// FIXME: granular.
|
|
||||||
self.niri.queue_redraw_all();
|
|
||||||
} else if let Some((output, ws)) = is_overview_open
|
|
||||||
.then(|| self.niri.workspace_under(false, pos))
|
|
||||||
.flatten()
|
|
||||||
{
|
|
||||||
let ws_idx = self.niri.layout.find_workspace_by_id(ws.id()).unwrap().0;
|
|
||||||
|
|
||||||
self.niri.layout.focus_output(&output);
|
|
||||||
self.niri.layout.toggle_overview_to_workspace(ws_idx);
|
|
||||||
|
|
||||||
// FIXME: granular.
|
|
||||||
self.niri.queue_redraw_all();
|
|
||||||
} else if let Some(output) = under.output {
|
|
||||||
self.niri.layout.focus_output(&output);
|
|
||||||
|
|
||||||
// FIXME: granular.
|
|
||||||
self.niri.queue_redraw_all();
|
|
||||||
}
|
}
|
||||||
self.niri.focus_layer_surface_if_on_demand(under.layer);
|
|
||||||
|
self.niri.layout.activate_window(&window);
|
||||||
|
|
||||||
|
// FIXME: granular.
|
||||||
|
self.niri.queue_redraw_all();
|
||||||
|
} else if let Some((output, ws)) = is_overview_open
|
||||||
|
.then(|| self.niri.workspace_under(false, pos))
|
||||||
|
.flatten()
|
||||||
|
{
|
||||||
|
let ws_idx = self.niri.layout.find_workspace_by_id(ws.id()).unwrap().0;
|
||||||
|
|
||||||
|
self.niri.layout.focus_output(&output);
|
||||||
|
self.niri.layout.toggle_overview_to_workspace(ws_idx);
|
||||||
|
|
||||||
|
// FIXME: granular.
|
||||||
|
self.niri.queue_redraw_all();
|
||||||
|
} else if let Some(output) = under.output {
|
||||||
|
self.niri.layout.focus_output(&output);
|
||||||
|
|
||||||
|
// FIXME: granular.
|
||||||
|
self.niri.queue_redraw_all();
|
||||||
}
|
}
|
||||||
|
self.niri.focus_layer_surface_if_on_demand(under.layer);
|
||||||
}
|
}
|
||||||
TabletToolTipState::Up => {
|
}
|
||||||
tool.tip_up(event.time_msec());
|
TabletToolTipState::Up => {
|
||||||
}
|
tool.tip_up(event.time_msec());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user