diff options
| author | Kirill Chibisov <contact@kchibisov.com> | 2023-10-26 00:15:46 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-29 13:58:48 +0400 |
| commit | 0a2052945e62c31585a3c7ec4c0efa84ebc5d312 (patch) | |
| tree | a339cae5e7ba362d7adf18c62948eb009a368d24 /src/handlers | |
| parent | 49a8f156f34434977358ea9f0a9cb97a753d857f (diff) | |
| download | niri-0a2052945e62c31585a3c7ec4c0efa84ebc5d312.tar.gz niri-0a2052945e62c31585a3c7ec4c0efa84ebc5d312.tar.bz2 niri-0a2052945e62c31585a3c7ec4c0efa84ebc5d312.zip | |
Add support for wl_compositor@v6
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/compositor.rs | 15 | ||||
| -rw-r--r-- | src/handlers/layer_shell.rs | 8 | ||||
| -rw-r--r-- | src/handlers/mod.rs | 18 | ||||
| -rw-r--r-- | src/handlers/xdg_shell.rs | 16 |
4 files changed, 51 insertions, 6 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index 034f1ca5..71696d06 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -9,8 +9,9 @@ use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::reexports::wayland_server::{Client, Resource}; use smithay::wayland::buffer::BufferHandler; use smithay::wayland::compositor::{ - add_blocker, add_pre_commit_hook, get_parent, is_sync_subsurface, with_states, - BufferAssignment, CompositorClientState, CompositorHandler, CompositorState, SurfaceAttributes, + add_blocker, add_pre_commit_hook, get_parent, is_sync_subsurface, send_surface_state, + with_states, BufferAssignment, CompositorClientState, CompositorHandler, CompositorState, + SurfaceAttributes, }; use smithay::wayland::dmabuf::get_dmabuf; use smithay::wayland::shm::{ShmHandler, ShmState}; @@ -28,6 +29,16 @@ impl CompositorHandler for State { &client.get_data::<ClientState>().unwrap().compositor_state } + fn new_subsurface(&mut self, surface: &WlSurface, parent: &WlSurface) { + if let Some((_, output)) = self.niri.layout.find_window_and_output(parent) { + let scale = output.current_scale().integer_scale(); + let transform = output.current_transform(); + with_states(surface, |data| { + send_surface_state(surface, data, scale, transform); + }); + } + } + fn new_surface(&mut self, surface: &WlSurface) { add_pre_commit_hook::<Self, _>(surface, move |state, _dh, surface| { let maybe_dmabuf = with_states(surface, |surface_data| { diff --git a/src/handlers/layer_shell.rs b/src/handlers/layer_shell.rs index 6e0ef318..a5b1d120 100644 --- a/src/handlers/layer_shell.rs +++ b/src/handlers/layer_shell.rs @@ -3,7 +3,7 @@ use smithay::desktop::{layer_map_for_output, LayerSurface, WindowSurfaceType}; use smithay::output::Output; use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; -use smithay::wayland::compositor::with_states; +use smithay::wayland::compositor::{send_surface_state, with_states}; use smithay::wayland::shell::wlr_layer::{ Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler, WlrLayerShellState, @@ -92,6 +92,12 @@ impl State { .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) .unwrap(); + let scale = output.current_scale().integer_scale(); + let transform = output.current_transform(); + with_states(surface, |data| { + send_surface_state(surface, data, scale, transform); + }); + layer.layer_surface().send_configure(); } drop(map); diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 19742fcc..85e9e755 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -19,6 +19,7 @@ use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::reexports::wayland_server::Resource; use smithay::utils::{Logical, Rectangle, Size}; +use smithay::wayland::compositor::{send_surface_state, with_states}; use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError}; use smithay::wayland::input_method::{InputMethodHandler, PopupSurface}; use smithay::wayland::selection::data_device::{ @@ -71,6 +72,17 @@ delegate_text_input_manager!(State); impl InputMethodHandler for State { fn new_popup(&mut self, surface: PopupSurface) { + if let Some((_, output)) = surface + .get_parent() + .and_then(|parent| self.niri.layout.find_window_and_output(&parent.surface)) + { + let scale = output.current_scale().integer_scale(); + let transform = output.current_transform(); + let wl_surface = surface.wl_surface(); + with_states(wl_surface, |data| { + send_surface_state(wl_surface, data, scale, transform); + }); + } if let Err(err) = self.niri.popups.track_popup(PopupKind::from(surface)) { warn!("error tracking ime popup {err:?}"); } @@ -216,5 +228,11 @@ pub fn configure_lock_surface(surface: &LockSurface, output: &Output) { let size = output_size(output); states.size = Some(Size::from((size.w as u32, size.h as u32))); }); + let scale = output.current_scale().integer_scale(); + let transform = output.current_transform(); + let wl_surface = surface.wl_surface(); + with_states(wl_surface, |data| { + send_surface_state(wl_surface, data, scale, transform); + }); surface.send_configure(); } diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index d0532a3b..d99fbdf0 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -6,7 +6,7 @@ use smithay::reexports::wayland_server::protocol::wl_output; use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; use smithay::utils::Serial; -use smithay::wayland::compositor::with_states; +use smithay::wayland::compositor::{send_surface_state, with_states}; use smithay::wayland::shell::kde::decoration::{KdeDecorationHandler, KdeDecorationState}; use smithay::wayland::shell::xdg::decoration::XdgDecorationHandler; use smithay::wayland::shell::xdg::{ @@ -264,8 +264,18 @@ impl State { .initial_configure_sent }); if !initial_configure_sent { - // NOTE: This should never fail as the initial configure is always - // allowed. + if let Some(output) = popup.get_parent_surface().and_then(|parent| { + self.niri + .layout + .find_window_and_output(&parent) + .map(|(_, output)| output) + }) { + let scale = output.current_scale().integer_scale(); + let transform = output.current_transform(); + with_states(surface, |data| { + send_surface_state(surface, data, scale, transform); + }); + } popup.send_configure().expect("initial configure failed"); } } |
