Skip to content
Open
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
7 changes: 6 additions & 1 deletion anvil/src/input_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{focus::PointerFocusTarget, shell::FullscreenSurface, AnvilState};

#[cfg(feature = "udev")]
use crate::udev::UdevData;
#[cfg(feature = "udev")]
use smithay::backend::renderer::DebugFlags;

use smithay::{
Expand Down Expand Up @@ -503,6 +502,12 @@ impl<BackendData: Backend> AnvilState<BackendData> {
self.backend_data.reset_buffers(&output);
}

KeyAction::ToggleTint => {
let mut debug_flags = self.backend_data.debug_flags();
debug_flags.toggle(DebugFlags::TINT);
self.backend_data.set_debug_flags(debug_flags);
}

action => match action {
KeyAction::None
| KeyAction::Quit
Expand Down
9 changes: 7 additions & 2 deletions anvil/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ use tracing::{info, warn};
use smithay::{
backend::{
input::TabletToolDescriptor,
renderer::element::{
default_primary_scanout_output_compare, utils::select_dmabuf_feedback, RenderElementStates,
renderer::{
element::{
default_primary_scanout_output_compare, utils::select_dmabuf_feedback, RenderElementStates,
},
DebugFlags,
},
},
delegate_compositor, delegate_data_control, delegate_data_device, delegate_fractional_scale,
Expand Down Expand Up @@ -1116,4 +1119,6 @@ pub trait Backend {
fn reset_buffers(&mut self, output: &Output);
fn early_import(&mut self, surface: &WlSurface);
fn update_led_state(&mut self, led_state: LedState);
fn debug_flags(&self) -> DebugFlags;
fn set_debug_flags(&mut self, flags: DebugFlags);
}
34 changes: 16 additions & 18 deletions anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,6 @@ pub struct UdevData {
keyboards: Vec<smithay::reexports::input::Device>,
}

impl UdevData {
pub fn set_debug_flags(&mut self, flags: DebugFlags) {
if self.debug_flags != flags {
self.debug_flags = flags;

for (_, backend) in self.backends.iter_mut() {
for (_, surface) in backend.surfaces.iter_mut() {
surface.drm_output.set_debug_flags(flags);
}
}
}
}

pub fn debug_flags(&self) -> DebugFlags {
self.debug_flags
}
}

impl DmabufHandler for AnvilState<UdevData> {
fn dmabuf_state(&mut self) -> &mut DmabufState {
&mut self.backend_data.dmabuf_state.as_mut().unwrap().0
Expand Down Expand Up @@ -214,6 +196,22 @@ impl Backend for UdevData {
keyboard.led_update(led_state.into());
}
}

fn debug_flags(&self) -> DebugFlags {
self.debug_flags
}

fn set_debug_flags(&mut self, flags: DebugFlags) {
if self.debug_flags != flags {
self.debug_flags = flags;

for (_, backend) in self.backends.iter_mut() {
for (_, surface) in backend.surfaces.iter_mut() {
surface.drm_output.set_debug_flags(flags);
}
}
}
}
}

pub fn run_udev() {
Expand Down
15 changes: 11 additions & 4 deletions anvil/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use smithay::{
damage::{Error as OutputDamageTrackerError, OutputDamageTracker},
element::AsRenderElements,
gles::GlesRenderer,
ImportDma, ImportMemWl,
DebugFlags, ImportDma, ImportMemWl, Renderer,
},
winit::{self, WinitEvent, WinitGraphicsBackend},
SwapBuffersError,
Expand Down Expand Up @@ -70,7 +70,7 @@ impl DmabufHandler for AnvilState<WinitData> {
if self
.backend_data
.backend
.renderer()
.renderer_mut()
.import_dmabuf(&dmabuf, None)
.is_ok()
{
Expand All @@ -91,6 +91,12 @@ impl Backend for WinitData {
}
fn early_import(&mut self, _surface: &wl_surface::WlSurface) {}
fn update_led_state(&mut self, _led_state: LedState) {}
fn debug_flags(&self) -> DebugFlags {
self.backend.renderer().debug_flags()
}
fn set_debug_flags(&mut self, flags: DebugFlags) {
self.backend.renderer_mut().set_debug_flags(flags)
}
}

pub fn run_winit() {
Expand Down Expand Up @@ -134,7 +140,7 @@ pub fn run_winit() {
.unwrap();
#[cfg(feature = "debug")]
let fps_texture = backend
.renderer()
.renderer_mut()
.import_memory(
&fps_image.to_rgba8(),
Fourcc::Abgr8888,
Expand Down Expand Up @@ -184,7 +190,7 @@ pub fn run_winit() {
};

#[cfg(feature = "egl")]
if backend.renderer().bind_wl_display(&display.handle()).is_ok() {
if backend.renderer_mut().bind_wl_display(&display.handle()).is_ok() {
info!("EGL hardware-acceleration enabled");
};

Expand Down Expand Up @@ -228,6 +234,7 @@ pub fn run_winit() {
crate::shell::fixup_positions(&mut state.space, state.pointer.current_location());
}
WinitEvent::Input(event) => state.process_input_event_windowed(event, OUTPUT_NAME),
WinitEvent::CloseRequested => state.running.store(false, Ordering::SeqCst),
_ => (),
});

Expand Down
10 changes: 8 additions & 2 deletions anvil/src/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use smithay::{
},
egl::{EGLContext, EGLDisplay},
renderer::{
damage::OutputDamageTracker, element::AsRenderElements, gles::GlesRenderer, Bind, ImportDma,
ImportMemWl,
damage::OutputDamageTracker, element::AsRenderElements, gles::GlesRenderer, Bind, DebugFlags,
ImportDma, ImportMemWl, Renderer,
},
vulkan::{version::Version, Instance, PhysicalDevice},
x11::{WindowBuilder, X11Backend, X11Event, X11Surface},
Expand Down Expand Up @@ -94,6 +94,12 @@ impl Backend for X11Data {
}
fn early_import(&mut self, _surface: &wl_surface::WlSurface) {}
fn update_led_state(&mut self, _led_state: LedState) {}
fn debug_flags(&self) -> DebugFlags {
self.renderer.debug_flags()
}
fn set_debug_flags(&mut self, flags: DebugFlags) {
self.renderer.set_debug_flags(flags)
}
}

pub fn run_x11() {
Expand Down
7 changes: 6 additions & 1 deletion src/backend/winit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ where
}

/// Access the underlying renderer
pub fn renderer(&mut self) -> &mut R {
pub fn renderer(&self) -> &R {
&self.renderer
}

/// Mutably access the underlying renderer
pub fn renderer_mut(&mut self) -> &mut R {
&mut self.renderer
}

Expand Down
5 changes: 5 additions & 0 deletions wlcs_anvil/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use smithay::{
damage::OutputDamageTracker,
element::AsRenderElements,
test::{DummyFramebuffer, DummyRenderer},
DebugFlags,
},
},
input::pointer::{
Expand Down Expand Up @@ -46,6 +47,10 @@ impl Backend for TestState {
fn reset_buffers(&mut self, _output: &Output) {}
fn early_import(&mut self, _surface: &wl_surface::WlSurface) {}
fn update_led_state(&mut self, _led_state: smithay::input::keyboard::LedState) {}
fn debug_flags(&self) -> DebugFlags {
DebugFlags::empty()
}
fn set_debug_flags(&mut self, _flags: DebugFlags) {}
}

pub fn run(channel: Channel<WlcsEvent>) {
Expand Down
Loading