anvil: Render software cursors again
This commit is contained in:
parent
3d8cf0e458
commit
45cd37373a
|
@ -34,7 +34,7 @@ gl_generator = "0.14"
|
||||||
default = [ "winit", "udev", "logind", "xwayland" ]
|
default = [ "winit", "udev", "logind", "xwayland" ]
|
||||||
egl = [ "smithay/use_system_lib" ]
|
egl = [ "smithay/use_system_lib" ]
|
||||||
winit = [ "smithay/backend_winit" ]
|
winit = [ "smithay/backend_winit" ]
|
||||||
udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm", "smithay/backend_gbm", "smithay/backend_egl", "smithay/backend_session", "input", "image"]
|
udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm", "smithay/backend_gbm", "smithay/backend_egl", "smithay/backend_session", "input", "image", "smithay/image"]
|
||||||
logind = [ "smithay/backend_session_logind" ]
|
logind = [ "smithay/backend_session_logind" ]
|
||||||
elogind = ["logind", "smithay/backend_session_elogind" ]
|
elogind = ["logind", "smithay/backend_session_elogind" ]
|
||||||
xwayland = [ "smithay/xwayland", "x11rb" ]
|
xwayland = [ "smithay/xwayland", "x11rb" ]
|
||||||
|
|
|
@ -25,9 +25,12 @@ use smithay::{
|
||||||
},
|
},
|
||||||
egl::{EGLDisplay, EGLContext},
|
egl::{EGLDisplay, EGLContext},
|
||||||
renderer::{
|
renderer::{
|
||||||
Renderer,
|
|
||||||
gles2::Gles2Renderer,
|
|
||||||
Transform,
|
Transform,
|
||||||
|
Renderer,
|
||||||
|
gles2::{
|
||||||
|
Gles2Renderer,
|
||||||
|
Gles2Texture,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
||||||
session::{auto::AutoSession, Session, Signal as SessionSignal},
|
session::{auto::AutoSession, Session, Signal as SessionSignal},
|
||||||
|
@ -495,6 +498,12 @@ impl<Data: 'static> UdevHandlerImpl<Data> {
|
||||||
&self.logger,
|
&self.logger,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
let pointer_image = {
|
||||||
|
let context = EGLContext::new_shared(&egl, &context, self.logger.clone()).unwrap();
|
||||||
|
let mut renderer = unsafe { Gles2Renderer::new(context, self.logger.clone()).unwrap() };
|
||||||
|
renderer.import_bitmap(&self.pointer_image).expect("Failed to load pointer")
|
||||||
|
};
|
||||||
|
|
||||||
// Set the handler.
|
// Set the handler.
|
||||||
// Note: if you replicate this (very simple) structure, it is rather easy
|
// Note: if you replicate this (very simple) structure, it is rather easy
|
||||||
// to introduce reference cycles with Rc. Be sure about your drop order
|
// to introduce reference cycles with Rc. Be sure about your drop order
|
||||||
|
@ -505,7 +514,7 @@ impl<Data: 'static> UdevHandlerImpl<Data> {
|
||||||
window_map: self.window_map.clone(),
|
window_map: self.window_map.clone(),
|
||||||
output_map: self.output_map.clone(),
|
output_map: self.output_map.clone(),
|
||||||
pointer_location: self.pointer_location.clone(),
|
pointer_location: self.pointer_location.clone(),
|
||||||
pointer_image: self.pointer_image.clone(),
|
pointer_image: pointer_image,
|
||||||
cursor_status: self.cursor_status.clone(),
|
cursor_status: self.cursor_status.clone(),
|
||||||
dnd_icon: self.dnd_icon.clone(),
|
dnd_icon: self.dnd_icon.clone(),
|
||||||
logger: self.logger.clone(),
|
logger: self.logger.clone(),
|
||||||
|
@ -645,7 +654,7 @@ pub struct DrmRenderer {
|
||||||
window_map: Rc<RefCell<MyWindowMap>>,
|
window_map: Rc<RefCell<MyWindowMap>>,
|
||||||
output_map: Rc<RefCell<Vec<MyOutput>>>,
|
output_map: Rc<RefCell<Vec<MyOutput>>>,
|
||||||
pointer_location: Rc<RefCell<(f64, f64)>>,
|
pointer_location: Rc<RefCell<(f64, f64)>>,
|
||||||
pointer_image: ImageBuffer<Rgba<u8>, Vec<u8>>,
|
pointer_image: Gles2Texture,
|
||||||
cursor_status: Arc<Mutex<CursorImageStatus>>,
|
cursor_status: Arc<Mutex<CursorImageStatus>>,
|
||||||
dnd_icon: Arc<Mutex<Option<wl_surface::WlSurface>>>,
|
dnd_icon: Arc<Mutex<Option<wl_surface::WlSurface>>>,
|
||||||
logger: ::slog::Logger,
|
logger: ::slog::Logger,
|
||||||
|
@ -673,6 +682,9 @@ impl DrmRenderer {
|
||||||
&mut *self.output_map.borrow_mut(),
|
&mut *self.output_map.borrow_mut(),
|
||||||
&self.compositor_token,
|
&self.compositor_token,
|
||||||
&*self.pointer_location.borrow(),
|
&*self.pointer_location.borrow(),
|
||||||
|
&self.pointer_image,
|
||||||
|
&*self.dnd_icon.lock().unwrap(),
|
||||||
|
&mut *self.cursor_status.lock().unwrap(),
|
||||||
&self.logger
|
&self.logger
|
||||||
);
|
);
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
|
@ -742,6 +754,9 @@ impl DrmRenderer {
|
||||||
output_map: &mut Vec<MyOutput>,
|
output_map: &mut Vec<MyOutput>,
|
||||||
compositor_token: &CompositorToken<Roles>,
|
compositor_token: &CompositorToken<Roles>,
|
||||||
pointer_location: &(f64, f64),
|
pointer_location: &(f64, f64),
|
||||||
|
pointer_image: &Gles2Texture,
|
||||||
|
dnd_icon: &Option<wl_surface::WlSurface>,
|
||||||
|
cursor_status: &mut CursorImageStatus,
|
||||||
logger: &slog::Logger,
|
logger: &slog::Logger,
|
||||||
) -> Result<(), SwapBuffersError> {
|
) -> Result<(), SwapBuffersError> {
|
||||||
surface.frame_submitted()?;
|
surface.frame_submitted()?;
|
||||||
|
@ -780,45 +795,39 @@ impl DrmRenderer {
|
||||||
let ptr_y = ptr_y.trunc().abs() as i32 - y as i32;
|
let ptr_y = ptr_y.trunc().abs() as i32 - y as i32;
|
||||||
|
|
||||||
// set cursor
|
// set cursor
|
||||||
/*
|
|
||||||
if ptr_x >= 0 && ptr_x < width as i32 && ptr_y >= 0 && ptr_y < height as i32 {
|
if ptr_x >= 0 && ptr_x < width as i32 && ptr_y >= 0 && ptr_y < height as i32 {
|
||||||
let _ = drawer.borrow().set_cursor_position(ptr_x as u32, ptr_y as u32);
|
|
||||||
|
|
||||||
// draw the dnd icon if applicable
|
// draw the dnd icon if applicable
|
||||||
{
|
{
|
||||||
let guard = self.dnd_icon.lock().unwrap();
|
if let Some(ref wl_surface) = dnd_icon.as_ref() {
|
||||||
if let Some(ref surface) = *guard {
|
if wl_surface.as_ref().is_alive() {
|
||||||
if surface.as_ref().is_alive() {
|
draw_dnd_icon(surface, wl_surface, (ptr_x, ptr_y), compositor_token.clone(), logger);
|
||||||
drawer.draw_dnd_icon(&mut frame, surface, (ptr_x, ptr_y), self.compositor_token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// draw the cursor as relevant
|
// draw the cursor as relevant
|
||||||
{
|
{
|
||||||
let mut guard = self.cursor_status.lock().unwrap();
|
|
||||||
// reset the cursor if the surface is no longer alive
|
// reset the cursor if the surface is no longer alive
|
||||||
let mut reset = false;
|
let mut reset = false;
|
||||||
if let CursorImageStatus::Image(ref surface) = *guard {
|
if let CursorImageStatus::Image(ref surface) = *cursor_status {
|
||||||
reset = !surface.as_ref().is_alive();
|
reset = !surface.as_ref().is_alive();
|
||||||
}
|
}
|
||||||
if reset {
|
if reset {
|
||||||
*guard = CursorImageStatus::Default;
|
*cursor_status = CursorImageStatus::Default;
|
||||||
}
|
}
|
||||||
if let CursorImageStatus::Image(ref surface) = *guard {
|
|
||||||
drawer.draw_software_cursor(
|
if let CursorImageStatus::Image(ref wl_surface) = *cursor_status {
|
||||||
&mut frame,
|
draw_cursor(
|
||||||
surface,
|
surface,
|
||||||
|
wl_surface,
|
||||||
(ptr_x, ptr_y),
|
(ptr_x, ptr_y),
|
||||||
self.compositor_token,
|
compositor_token.clone(),
|
||||||
|
logger,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
drawer.draw_hardware_cursor(&self.pointer_image, (2, 2), (ptr_x, ptr_y));
|
surface.render_texture_at(pointer_image, (ptr_x, ptr_y), Transform::Normal, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
drawer.clear_cursor();
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
surface.finish()
|
surface.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue