Skip to content

Commit

Permalink
Merge pull request #423 from Smithay/feature/desktop_abstractions
Browse files Browse the repository at this point in the history
Desktop abstractions
  • Loading branch information
Drakulix authored Jan 7, 2022
2 parents 5697836 + 9f5bf25 commit 24b30e5
Show file tree
Hide file tree
Showing 40 changed files with 3,644 additions and 352 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ jobs:
- backend_session_logind
- backend_session_libseat
- backend_x11
- desktop
- renderer_gl
- wayland_frontend
- xwayland
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
- `X11Surface::buffer` now additionally returns the age of the buffer
- `X11Surface` now has an explicit `submit` function
- `X11Surface` is now multi-window capable.
- `Renderer::clear` now expects a second argument to optionally only clear parts of the buffer/surface
- `Transform::transform_size` now takes a `Size` instead of two `u32`
- `Gles2Renderer` now automatically flips the `render` result to account for OpenGLs coordinate system

### Additions

Expand All @@ -45,6 +48,7 @@
- Add support for the zxdg-foreign-v2 protocol.
- Support for `xdg_wm_base` protocol version 3
- Added the option to initialize the dmabuf global with a client filter
- `wayland::output::Output` now has user data attached to it and more functions to query its properties

#### Backends

Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ drm = { version = "0.5.0", optional = true }
drm-ffi = { version = "0.2.0", optional = true }
gbm = { version = "0.7.0", optional = true, default-features = false, features = ["drm-support"] }
input = { version = "0.7", default-features = false, features=["libinput_1_14"], optional = true }
indexmap = { version = "1.7", optional = true }
lazy_static = "1"
libc = "0.2.103"
libseat= { version = "0.1.1", optional = true }
Expand All @@ -39,7 +40,7 @@ rand = "0.8.4"
slog = "2"
slog-stdlog = { version = "4", optional = true }
tempfile = { version = "3.0", optional = true }
thiserror = "1.0.7"
thiserror = "1.0.25"
udev = { version = "0.6", optional = true }
wayland-commons = { version = "0.29.0", optional = true }
wayland-egl = { version = "0.29.0", optional = true }
Expand All @@ -59,7 +60,7 @@ gl_generator = { version = "0.14", optional = true }
pkg-config = { version = "0.3.17", optional = true }

[features]
default = ["backend_drm", "backend_gbm", "backend_libinput", "backend_udev", "backend_session_logind", "backend_winit", "renderer_gl", "xwayland", "wayland_frontend", "slog-stdlog", "backend_x11"]
default = ["backend_drm", "backend_gbm", "backend_libinput", "backend_udev", "backend_session_logind", "backend_winit", "desktop", "renderer_gl", "xwayland", "wayland_frontend", "slog-stdlog", "backend_x11"]
backend_winit = ["winit", "wayland-server/dlopen", "backend_egl", "wayland-egl", "renderer_gl"]
backend_x11 = ["x11rb", "x11rb/dri3", "x11rb/xfixes", "x11rb/present", "x11rb_event_source", "backend_gbm", "backend_drm", "backend_egl"]
backend_drm = ["drm", "drm-ffi"]
Expand All @@ -71,6 +72,7 @@ backend_udev = ["udev", "input/udev"]
backend_session_logind = ["dbus", "backend_session", "pkg-config"]
backend_session_elogind = ["backend_session_logind"]
backend_session_libseat = ["backend_session", "libseat"]
desktop = ["indexmap", "wayland_frontend"]
renderer_gl = ["gl_generator", "backend_egl"]
use_system_lib = ["wayland_frontend", "wayland-sys", "wayland-server/use_system_lib"]
wayland_frontend = ["wayland-server", "wayland-commons", "wayland-protocols", "tempfile"]
Expand Down
2 changes: 2 additions & 0 deletions anvil/src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ where
buffer_scale,
output_scale as f64,
Transform::Normal, /* TODO */
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
1.0,
) {
result = Err(err.into());
Expand Down Expand Up @@ -355,6 +356,7 @@ where
_ => unreachable!(),
},
Rectangle::from_loc_and_size((offset_x, 0.0), (22.0 * output_scale, 35.0 * output_scale)),
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
Transform::Normal,
1.0,
)
Expand Down
5 changes: 4 additions & 1 deletion anvil/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ pub fn render_layers_and_windows(
output_scale: f32,
logger: &Logger,
) -> Result<(), SwapBuffersError> {
frame.clear([0.8, 0.8, 0.9, 1.0])?;
frame.clear(
[0.8, 0.8, 0.9, 1.0],
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
)?;

for layer in [Layer::Background, Layer::Bottom] {
draw_layers(
Expand Down
135 changes: 64 additions & 71 deletions anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use smithay::{
},
utils::{
signaling::{Linkable, SignalToken, Signaler},
Logical, Point,
Logical, Point, Rectangle,
},
wayland::{
output::{Mode, PhysicalProperties},
Expand Down Expand Up @@ -743,92 +743,82 @@ fn render_surface(

// and draw to our buffer
match renderer
.render(
mode.size,
Transform::Flipped180, // Scanout is rotated
|renderer, frame| {
render_layers_and_windows(
renderer,
frame,
window_map,
output_geometry,
output_scale,
logger,
)?;

// set cursor
if output_geometry.to_f64().contains(pointer_location) {
let (ptr_x, ptr_y) = pointer_location.into();
let relative_ptr_location =
Point::<i32, Logical>::from((ptr_x as i32, ptr_y as i32)) - output_geometry.loc;
// draw the dnd icon if applicable
{
if let Some(ref wl_surface) = dnd_icon.as_ref() {
if wl_surface.as_ref().is_alive() {
draw_dnd_icon(
renderer,
frame,
wl_surface,
relative_ptr_location,
output_scale,
logger,
)?;
}
}
}

// draw the cursor as relevant
{
// reset the cursor if the surface is no longer alive
let mut reset = false;
if let CursorImageStatus::Image(ref surface) = *cursor_status {
reset = !surface.as_ref().is_alive();
}
if reset {
*cursor_status = CursorImageStatus::Default;
}

if let CursorImageStatus::Image(ref wl_surface) = *cursor_status {
draw_cursor(
.render(mode.size, Transform::Normal, |renderer, frame| {
render_layers_and_windows(renderer, frame, window_map, output_geometry, output_scale, logger)?;

// set cursor
if output_geometry.to_f64().contains(pointer_location) {
let (ptr_x, ptr_y) = pointer_location.into();
let relative_ptr_location =
Point::<i32, Logical>::from((ptr_x as i32, ptr_y as i32)) - output_geometry.loc;
// draw the dnd icon if applicable
{
if let Some(ref wl_surface) = dnd_icon.as_ref() {
if wl_surface.as_ref().is_alive() {
draw_dnd_icon(
renderer,
frame,
wl_surface,
relative_ptr_location,
output_scale,
logger,
)?;
} else {
frame.render_texture_at(
pointer_image,
relative_ptr_location
.to_f64()
.to_physical(output_scale as f64)
.to_i32_round(),
1,
output_scale as f64,
Transform::Normal,
1.0,
)?;
}
}
}

#[cfg(feature = "debug")]
{
draw_fps(
// draw the cursor as relevant
{
// reset the cursor if the surface is no longer alive
let mut reset = false;
if let CursorImageStatus::Image(ref surface) = *cursor_status {
reset = !surface.as_ref().is_alive();
}
if reset {
*cursor_status = CursorImageStatus::Default;
}

if let CursorImageStatus::Image(ref wl_surface) = *cursor_status {
draw_cursor(
renderer,
frame,
fps_texture,
wl_surface,
relative_ptr_location,
output_scale,
logger,
)?;
} else {
frame.render_texture_at(
pointer_image,
relative_ptr_location
.to_f64()
.to_physical(output_scale as f64)
.to_i32_round(),
1,
output_scale as f64,
surface.fps.avg().round() as u32,
Transform::Normal,
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
1.0,
)?;

surface.fps.tick();
}
}

Ok(())
},
)
#[cfg(feature = "debug")]
{
draw_fps(
renderer,
frame,
fps_texture,
output_scale as f64,
surface.fps.avg().round() as u32,
)?;

surface.fps.tick();
}
}

Ok(())
})
.map_err(Into::<SwapBuffersError>::into)
.and_then(|x| x)
.map_err(Into::<SwapBuffersError>::into)
Expand Down Expand Up @@ -873,7 +863,10 @@ fn initial_render(surface: &mut RenderSurface, renderer: &mut Gles2Renderer) ->
renderer
.render((1, 1).into(), Transform::Normal, |_, frame| {
frame
.clear([0.8, 0.8, 0.9, 1.0])
.clear(
[0.8, 0.8, 0.9, 1.0],
&[Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX))],
)
.map_err(Into::<SwapBuffersError>::into)
})
.map_err(Into::<SwapBuffersError>::into)
Expand Down
Loading

0 comments on commit 24b30e5

Please sign in to comment.