fix(corner-radius): force redraw after corner radius change
This commit is contained in:
parent
ce655d2063
commit
4e30513673
2 changed files with 35 additions and 25 deletions
|
|
@ -22,23 +22,37 @@ impl CornerRadiusHandler for State {
|
|||
|
||||
fn set_corner_radius(
|
||||
&mut self,
|
||||
_toplevel: &cosmic_corner_radius_toplevel_v1::CosmicCornerRadiusToplevelV1,
|
||||
_data: &CornerRadiusData,
|
||||
_top_left: u32,
|
||||
_top_right: u32,
|
||||
_bottom_right: u32,
|
||||
_bottom_left: u32,
|
||||
_: &cosmic_corner_radius_toplevel_v1::CosmicCornerRadiusToplevelV1,
|
||||
data: &CornerRadiusData,
|
||||
) {
|
||||
// TODO force redraw? of focus element?
|
||||
if force_redraw(self, data).is_none() {
|
||||
tracing::warn!("Failed to force redraw for corner radius change.");
|
||||
}
|
||||
}
|
||||
|
||||
fn unset_corner_radius(
|
||||
&mut self,
|
||||
_toplevel: &cosmic_corner_radius_toplevel_v1::CosmicCornerRadiusToplevelV1,
|
||||
_data: &CornerRadiusData,
|
||||
_: &cosmic_corner_radius_toplevel_v1::CosmicCornerRadiusToplevelV1,
|
||||
data: &CornerRadiusData,
|
||||
) {
|
||||
// TODO force redraw?
|
||||
if force_redraw(self, data).is_none() {
|
||||
tracing::warn!("Failed to force redraw for corner radius reset.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn force_redraw(state: &mut State, data: &CornerRadiusData) -> Option<()> {
|
||||
let guard = data.lock().unwrap();
|
||||
|
||||
let toplevel = guard.toplevel.upgrade().ok()?;
|
||||
|
||||
let surface = state.common.xdg_shell_state.get_toplevel(&toplevel)?;
|
||||
|
||||
let guard = state.common.shell.read();
|
||||
let output = guard.visible_output_for_surface(surface.wl_surface())?;
|
||||
|
||||
state.backend.schedule_render(output);
|
||||
Some(())
|
||||
}
|
||||
|
||||
delegate_corner_radius!(State);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use cosmic_protocols::corner_radius::v1::server::{
|
|||
};
|
||||
use smithay::reexports::{
|
||||
wayland_protocols::xdg::shell::server::xdg_toplevel::XdgToplevel,
|
||||
wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch, Resource},
|
||||
wayland_server::{Client, Dispatch, DisplayHandle, GlobalDispatch, Resource, Weak},
|
||||
};
|
||||
use smithay::wayland::compositor::with_states;
|
||||
use smithay::wayland::shell::xdg::ToplevelSurface;
|
||||
|
|
@ -50,10 +50,6 @@ pub trait CornerRadiusHandler {
|
|||
&mut self,
|
||||
toplevel: &cosmic_corner_radius_toplevel_v1::CosmicCornerRadiusToplevelV1,
|
||||
data: &CornerRadiusData,
|
||||
top_left: u32,
|
||||
top_right: u32,
|
||||
bottom_right: u32,
|
||||
bottom_left: u32,
|
||||
);
|
||||
fn unset_corner_radius(
|
||||
&mut self,
|
||||
|
|
@ -110,7 +106,13 @@ where
|
|||
corner_radius_state.instances.retain(|i| i != _resource);
|
||||
}
|
||||
cosmic_corner_radius_manager_v1::Request::GetCornerRadius { id, toplevel } => {
|
||||
let data = CornerRadiusData::default();
|
||||
let data = Mutex::new(CornerRadiusInternal {
|
||||
toplevel: toplevel.downgrade(),
|
||||
top_left: 0,
|
||||
top_right: 0,
|
||||
bottom_right: 0,
|
||||
bottom_left: 0,
|
||||
});
|
||||
let instance = data_init.init(id, data);
|
||||
|
||||
if let Some(surface) = state.toplevel_from_resource(&toplevel) {
|
||||
|
|
@ -178,14 +180,7 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
_state.set_corner_radius(
|
||||
resource,
|
||||
data,
|
||||
top_left,
|
||||
top_right,
|
||||
bottom_right,
|
||||
bottom_left,
|
||||
);
|
||||
_state.set_corner_radius(resource, data);
|
||||
}
|
||||
cosmic_corner_radius_toplevel_v1::Request::UnsetRadius => {
|
||||
_state.unset_corner_radius(resource, data);
|
||||
|
|
@ -197,8 +192,9 @@ where
|
|||
|
||||
pub type CornerRadiusData = Mutex<CornerRadiusInternal>;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug)]
|
||||
pub struct CornerRadiusInternal {
|
||||
pub toplevel: Weak<XdgToplevel>,
|
||||
pub top_left: u8,
|
||||
pub top_right: u8,
|
||||
pub bottom_right: u8,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue