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