diff options
| author | Christian Meissl <meissl.christian@gmail.com> | 2024-02-24 18:17:51 +0100 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-30 05:04:58 -0700 |
| commit | eb190e3f9447e4d49cfdcb5a0093443ca8b684fe (patch) | |
| tree | 7845bc23b9ed43bb75464d2dff5442d2d02285c5 /src/niri.rs | |
| parent | 80bb0d5876f8fae43791a8d6e52a38d3c1e01a72 (diff) | |
| download | niri-eb190e3f9447e4d49cfdcb5a0093443ca8b684fe.tar.gz niri-eb190e3f9447e4d49cfdcb5a0093443ca8b684fe.tar.bz2 niri-eb190e3f9447e4d49cfdcb5a0093443ca8b684fe.zip | |
handle role specific buffer offset
Diffstat (limited to 'src/niri.rs')
| -rw-r--r-- | src/niri.rs | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/niri.rs b/src/niri.rs index bdebe8bd..a2c81ae6 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -17,6 +17,7 @@ use niri_config::{ DEFAULT_BACKGROUND_COLOR, }; use smithay::backend::allocator::Fourcc; +use smithay::backend::input::Keycode; use smithay::backend::renderer::damage::OutputDamageTracker; use smithay::backend::renderer::element::memory::MemoryRenderBufferRenderElement; use smithay::backend::renderer::element::solid::{SolidColorBuffer, SolidColorRenderElement}; @@ -248,7 +249,7 @@ pub struct Niri { pub seat: Seat<State>, /// Scancodes of the keys to suppress. - pub suppressed_keys: HashSet<u32>, + pub suppressed_keys: HashSet<Keycode>, pub bind_cooldown_timers: HashMap<Key, RegistrationToken>, pub bind_repeat_timer: Option<RegistrationToken>, pub keyboard_focus: KeyboardFocus, @@ -259,7 +260,7 @@ pub struct Niri { pub cursor_manager: CursorManager, pub cursor_texture_cache: CursorTextureCache, pub cursor_shape_manager_state: CursorShapeManagerState, - pub dnd_icon: Option<WlSurface>, + pub dnd_icon: Option<DndIcon>, pub pointer_focus: PointerFocus, /// Whether the pointer is hidden, for example due to a previous touch input. /// @@ -304,6 +305,12 @@ pub struct Niri { pub mapped_cast_output: HashMap<Window, Output>, } +#[derive(Debug)] +pub struct DndIcon { + pub surface: WlSurface, + pub offset: Point<i32, Logical>, +} + pub struct OutputState { pub global: GlobalId, pub frame_clock: FrameClock, @@ -2588,8 +2595,8 @@ impl Niri { let output_scale = Scale::from(output.current_scale().fractional_scale()); - let (mut pointer_elements, pointer_pos) = match render_cursor { - RenderCursor::Hidden => (vec![], pointer_pos.to_physical_precise_round(output_scale)), + let mut pointer_elements = match render_cursor { + RenderCursor::Hidden => vec![], RenderCursor::Surface { surface, hotspot } => { let pointer_pos = (pointer_pos - hotspot.to_f64()).to_physical_precise_round(output_scale); @@ -2603,7 +2610,7 @@ impl Niri { Kind::Cursor, ); - (pointer_elements, pointer_pos) + pointer_elements } RenderCursor::Named { icon, @@ -2619,7 +2626,7 @@ impl Niri { let mut pointer_elements = vec![]; let pointer_element = match MemoryRenderBufferRenderElement::from_buffer( renderer, - pointer_pos.to_f64(), + pointer_pos, &texture, None, None, @@ -2636,14 +2643,16 @@ impl Niri { pointer_elements.push(OutputRenderElements::NamedPointer(element)); } - (pointer_elements, pointer_pos) + pointer_elements } }; - if let Some(dnd_icon) = &self.dnd_icon { + if let Some(dnd_icon) = self.dnd_icon.as_ref() { + let pointer_pos = + (pointer_pos + dnd_icon.offset.to_f64()).to_physical_precise_round(output_scale); pointer_elements.extend(render_elements_from_surface_tree( renderer, - dnd_icon, + &dnd_icon.surface, pointer_pos, output_scale, 1., @@ -2684,6 +2693,7 @@ impl Niri { let dnd = self .dnd_icon .as_ref() + .map(|icon| &icon.surface) .map(|surface| (surface, bbox_from_surface_tree(surface, surface_pos))); // FIXME we basically need to pick the largest scale factor across the overlapping @@ -2745,7 +2755,7 @@ impl Niri { } cursor_image => { // There's no cursor surface, but there might be a DnD icon. - let Some(surface) = &self.dnd_icon else { + let Some(surface) = self.dnd_icon.as_ref().map(|icon| &icon.surface) else { return; }; @@ -3267,7 +3277,7 @@ impl Niri { ); } - if let Some(surface) = &self.dnd_icon { + if let Some(surface) = self.dnd_icon.as_ref().map(|icon| &icon.surface) { with_surface_tree_downward( surface, (), @@ -3405,7 +3415,7 @@ impl Niri { ); } - if let Some(surface) = &self.dnd_icon { + if let Some(surface) = self.dnd_icon.as_ref().map(|icon| &icon.surface) { send_dmabuf_feedback_surface_tree( surface, output, @@ -3507,7 +3517,7 @@ impl Niri { ); } - if let Some(surface) = &self.dnd_icon { + if let Some(surface) = self.dnd_icon.as_ref().map(|icon| &icon.surface) { send_frames_surface_tree( surface, output, @@ -3575,7 +3585,7 @@ impl Niri { } } - if let Some(surface) = &self.dnd_icon { + if let Some(surface) = &self.dnd_icon.as_ref().map(|icon| &icon.surface) { send_frames_surface_tree( surface, output, @@ -3614,7 +3624,7 @@ impl Niri { ); } - if let Some(surface) = &self.dnd_icon { + if let Some(surface) = self.dnd_icon.as_ref().map(|icon| &icon.surface) { take_presentation_feedback_surface_tree( surface, &mut feedback, |
