Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WayVR: wl_output protocol support #106

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/wayvr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ That's it; you're all set!

### Supported software

- Basically all Qt applications (they work out of the box)
- Basically all Qt and GTK applications (they work out of the box)
- Most XWayland applications via `cage`

### XWayland
Expand Down
7 changes: 6 additions & 1 deletion src/backend/wayvr/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use smithay::reexports::wayland_server;
use smithay::reexports::wayland_server::protocol::{wl_buffer, wl_seat, wl_surface};
use smithay::reexports::wayland_server::Resource;
use smithay::wayland::buffer::BufferHandler;
use smithay::wayland::output::OutputHandler;
use smithay::wayland::shm::{ShmHandler, ShmState};
use smithay::{
delegate_compositor, delegate_data_device, delegate_seat, delegate_shm, delegate_xdg_shell,
delegate_compositor, delegate_data_device, delegate_output, delegate_seat, delegate_shm,
delegate_xdg_shell,
};
use std::collections::HashSet;
use std::os::fd::OwnedFd;
Expand Down Expand Up @@ -168,11 +170,14 @@ impl ShmHandler for Application {
}
}

impl OutputHandler for Application {}

delegate_xdg_shell!(Application);
delegate_compositor!(Application);
delegate_shm!(Application);
delegate_seat!(Application);
delegate_data_device!(Application);
delegate_output!(Application);

pub fn send_frames_surface_tree(surface: &wl_surface::WlSurface, time: u32) {
with_surface_tree_downward(
Expand Down
8 changes: 4 additions & 4 deletions src/backend/wayvr/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ impl Display {

let mut frame = renderer.render(size, Transform::Normal)?;

let clear_opacity = if self.displayed_windows.is_empty() {
0.5
let clear_color = if self.displayed_windows.is_empty() {
Color32F::new(1.0, 1.0, 1.0, 0.5)
} else {
0.0
Color32F::new(0.0, 0.0, 0.0, 0.0)
};

frame.clear(Color32F::new(1.0, 1.0, 1.0, clear_opacity), &[damage])?;
frame.clear(clear_color, &[damage])?;

draw_render_elements(&mut frame, 1.0, &elements, &[damage])?;

Expand Down
24 changes: 24 additions & 0 deletions src/backend/wayvr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use smallvec::SmallVec;
use smithay::{
backend::renderer::gles::GlesRenderer,
input::SeatState,
output::{Mode, Output},
reexports::wayland_server::{self, backend::ClientId},
wayland::{
compositor,
Expand Down Expand Up @@ -114,6 +115,29 @@ impl WayVR {
let data_device = DataDeviceState::new::<Application>(&dh);
let mut seat = seat_state.new_wl_seat(&dh, "wayvr");

let dummy_width = 1280;
let dummy_height = 720;
let dummy_milli_hz = 60000; /* refresh rate in millihertz */

let output = Output::new(
String::from("wayvr_display"),
smithay::output::PhysicalProperties {
size: (dummy_width, dummy_height).into(),
subpixel: smithay::output::Subpixel::None,
make: String::from("Completely Legit"),
model: String::from("Virtual WayVR Display"),
},
);

let mode = Mode {
refresh: dummy_milli_hz,
size: (dummy_width, dummy_height).into(),
};

output.change_current_state(Some(mode), None, None, None);
output.set_preferred(mode);
let _global = output.create_global::<Application>(&dh);

let seat_keyboard = seat.add_keyboard(
Default::default(),
config.keyboard_repeat_delay_ms as i32,
Expand Down
Loading