Simplify ScreenshotUi::pointer_button()
Browse files at this commit9ff2f83db00aebffb2b7b7fefd23bfd7585926c3Parent: 7a10f712 changed files +5 -14
- src/input/mod.rs +4 -6
- src/ui/screenshot_ui.rs +1 -8
src/input/mod.rsmodified+4 -6
| @@ -2563,7 +2563,7 @@ impl State { | ||
| 2563 | 2563 | self.niri.focus_layer_surface_if_on_demand(layer_under); |
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | - if let Some(button) = button { | |
| 2566 | + if button == Some(MouseButton::Left) && self.niri.screenshot_ui.is_open() { | |
| 2567 | 2567 | let pos = pointer.current_location(); |
| 2568 | 2568 | if let Some((output, _)) = self.niri.output_under(pos) { |
| 2569 | 2569 | let output = output.clone(); |
| @@ -2578,11 +2578,9 @@ impl State { | ||
| 2578 | 2578 | point.x = min(size.w - 1, point.x); |
| 2579 | 2579 | point.y = min(size.h - 1, point.y); |
| 2580 | 2580 | |
| 2581 | - if self | |
| 2582 | - .niri | |
| 2583 | - .screenshot_ui | |
| 2584 | - .pointer_button(output, point, button, button_state) | |
| 2585 | - { | |
| 2581 | + let down = button_state == ButtonState::Pressed; | |
| 2582 | + | |
| 2583 | + if self.niri.screenshot_ui.pointer_button(output, point, down) { | |
| 2586 | 2584 | self.niri.queue_redraw_all(); |
| 2587 | 2585 | } |
| 2588 | 2586 | } |
src/ui/screenshot_ui.rsmodified+1 -8
| @@ -11,7 +11,6 @@ use niri_ipc::SizeChange; | ||
| 11 | 11 | use pango::{Alignment, FontDescription}; |
| 12 | 12 | use pangocairo::cairo::{self, ImageSurface}; |
| 13 | 13 | use smithay::backend::allocator::Fourcc; |
| 14 | -use smithay::backend::input::{ButtonState, MouseButton}; | |
| 15 | 14 | use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement}; |
| 16 | 15 | use smithay::backend::renderer::element::Kind; |
| 17 | 16 | use smithay::backend::renderer::gles::{GlesRenderer, GlesTexture}; |
| @@ -678,8 +677,7 @@ impl ScreenshotUi { | ||
| 678 | 677 | &mut self, |
| 679 | 678 | output: Output, |
| 680 | 679 | point: Point<i32, Physical>, |
| 681 | - button: MouseButton, | |
| 682 | - state: ButtonState, | |
| 680 | + down: bool, | |
| 683 | 681 | ) -> bool { |
| 684 | 682 | let Self::Open { |
| 685 | 683 | selection, |
| @@ -691,11 +689,6 @@ impl ScreenshotUi { | ||
| 691 | 689 | return false; |
| 692 | 690 | }; |
| 693 | 691 | |
| 694 | - if button != MouseButton::Left { | |
| 695 | - return false; | |
| 696 | - } | |
| 697 | - | |
| 698 | - let down = state == ButtonState::Pressed; | |
| 699 | 692 | if *mouse_down == down { |
| 700 | 693 | return false; |
| 701 | 694 | } |