anvil: allow draw_windows to take optional output coordinates
This commit is contained in:
parent
e402af4855
commit
9fd8dd9cec
|
@ -26,6 +26,7 @@ use smithay::{
|
||||||
calloop::LoopHandle,
|
calloop::LoopHandle,
|
||||||
wayland_server::protocol::{wl_buffer, wl_surface},
|
wayland_server::protocol::{wl_buffer, wl_surface},
|
||||||
},
|
},
|
||||||
|
utils::Rectangle,
|
||||||
wayland::{
|
wayland::{
|
||||||
compositor::{roles::Role, SubsurfaceRole, TraversalAction},
|
compositor::{roles::Role, SubsurfaceRole, TraversalAction},
|
||||||
data_device::DnDIconRole,
|
data_device::DnDIconRole,
|
||||||
|
@ -403,12 +404,19 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
||||||
&self,
|
&self,
|
||||||
frame: &mut Frame,
|
frame: &mut Frame,
|
||||||
window_map: &MyWindowMap,
|
window_map: &MyWindowMap,
|
||||||
|
output_rect: Option<Rectangle>,
|
||||||
compositor_token: MyCompositorToken,
|
compositor_token: MyCompositorToken,
|
||||||
) {
|
) {
|
||||||
// redraw the frame, in a simple but inneficient way
|
// redraw the frame, in a simple but inneficient way
|
||||||
{
|
{
|
||||||
let screen_dimensions = self.borrow().get_framebuffer_dimensions();
|
let screen_dimensions = self.borrow().get_framebuffer_dimensions();
|
||||||
window_map.with_windows_from_bottom_to_top(|toplevel_surface, initial_place| {
|
window_map.with_windows_from_bottom_to_top(|toplevel_surface, initial_place, bounding_box| {
|
||||||
|
// skip windows that do not overlap with a given output
|
||||||
|
if let Some(output) = output_rect {
|
||||||
|
if !output.overlaps(bounding_box) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(wl_surface) = toplevel_surface.get_surface() {
|
if let Some(wl_surface) = toplevel_surface.get_surface() {
|
||||||
// this surface is a root of a subsurface tree that needs to be drawn
|
// this surface is a root of a subsurface tree that needs to be drawn
|
||||||
self.draw_surface_tree(
|
self.draw_surface_tree(
|
||||||
|
|
|
@ -601,7 +601,12 @@ impl DrmRenderer {
|
||||||
let mut frame = drawer.draw();
|
let mut frame = drawer.draw();
|
||||||
frame.clear(None, Some((0.8, 0.8, 0.9, 1.0)), false, Some(1.0), None);
|
frame.clear(None, Some((0.8, 0.8, 0.9, 1.0)), false, Some(1.0), None);
|
||||||
// draw the surfaces
|
// draw the surfaces
|
||||||
drawer.draw_windows(&mut frame, &*self.window_map.borrow(), self.compositor_token);
|
drawer.draw_windows(
|
||||||
|
&mut frame,
|
||||||
|
&*self.window_map.borrow(),
|
||||||
|
None,
|
||||||
|
self.compositor_token,
|
||||||
|
);
|
||||||
let (x, y) = *self.pointer_location.borrow();
|
let (x, y) = *self.pointer_location.borrow();
|
||||||
// draw the dnd icon if applicable
|
// draw the dnd icon if applicable
|
||||||
{
|
{
|
||||||
|
|
|
@ -248,10 +248,10 @@ where
|
||||||
|
|
||||||
pub fn with_windows_from_bottom_to_top<Func>(&self, mut f: Func)
|
pub fn with_windows_from_bottom_to_top<Func>(&self, mut f: Func)
|
||||||
where
|
where
|
||||||
Func: FnMut(&Kind<R>, (i32, i32)),
|
Func: FnMut(&Kind<R>, (i32, i32), &Rectangle),
|
||||||
{
|
{
|
||||||
for w in self.windows.iter().rev() {
|
for w in self.windows.iter().rev() {
|
||||||
f(&w.toplevel, w.location)
|
f(&w.toplevel, w.location, &w.bbox)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ pub fn run_winit(
|
||||||
frame.clear(None, Some((0.8, 0.8, 0.9, 1.0)), false, Some(1.0), None);
|
frame.clear(None, Some((0.8, 0.8, 0.9, 1.0)), false, Some(1.0), None);
|
||||||
|
|
||||||
// draw the windows
|
// draw the windows
|
||||||
drawer.draw_windows(&mut frame, &*state.window_map.borrow(), state.ctoken);
|
drawer.draw_windows(&mut frame, &*state.window_map.borrow(), None, state.ctoken);
|
||||||
|
|
||||||
let (x, y) = *state.pointer_location.borrow();
|
let (x, y) = *state.pointer_location.borrow();
|
||||||
// draw the dnd icon if any
|
// draw the dnd icon if any
|
||||||
|
|
|
@ -17,4 +17,20 @@ impl Rectangle {
|
||||||
let (x, y) = point;
|
let (x, y) = point;
|
||||||
(x >= self.x) && (x < self.x + self.width) && (y >= self.y) && (y < self.y + self.height)
|
(x >= self.x) && (x < self.x + self.width) && (y >= self.y) && (y < self.y + self.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks whether a given rectangle overlaps with this one
|
||||||
|
pub fn overlaps(&self, other: &Rectangle) -> bool {
|
||||||
|
// if the rectangle is not outside of the other
|
||||||
|
// they must overlap
|
||||||
|
!(
|
||||||
|
// self is left of other
|
||||||
|
self.x + self.width < other.x
|
||||||
|
// self is right of other
|
||||||
|
|| self.x > other.x + other.width
|
||||||
|
// self is above of other
|
||||||
|
|| self.y + self.height < other.y
|
||||||
|
// self is below of other
|
||||||
|
|| self.y > other.y + other.height
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue