Fix disappearing cursor after tty switch
This commit is contained in:
parent
5411209bb5
commit
310bc94a20
|
@ -24,8 +24,8 @@ pub struct DrmBackend<A: Device + 'static> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct DrmBackendInternal<A: Device + 'static> {
|
pub(crate) struct DrmBackendInternal<A: Device + 'static> {
|
||||||
context: Rc<EGLContext<Gbm<framebuffer::Info>, GbmDevice<A>>>,
|
pub(crate) context: Rc<EGLContext<Gbm<framebuffer::Info>, GbmDevice<A>>>,
|
||||||
cursor: Cell<BufferObject<()>>,
|
pub(crate) cursor: Cell<(BufferObject<()>, (u32, u32))>,
|
||||||
current_frame_buffer: Cell<framebuffer::Info>,
|
current_frame_buffer: Cell<framebuffer::Info>,
|
||||||
front_buffer: Cell<SurfaceBufferHandle<framebuffer::Info>>,
|
front_buffer: Cell<SurfaceBufferHandle<framebuffer::Info>>,
|
||||||
next_buffer: Cell<Option<SurfaceBufferHandle<framebuffer::Info>>>,
|
next_buffer: Cell<Option<SurfaceBufferHandle<framebuffer::Info>>>,
|
||||||
|
@ -96,14 +96,14 @@ impl<A: Device + 'static> DrmBackend<A> {
|
||||||
})?;
|
})?;
|
||||||
front_bo.set_userdata(fb).unwrap();
|
front_bo.set_userdata(fb).unwrap();
|
||||||
|
|
||||||
let cursor = Cell::new(context
|
let cursor = Cell::new((context
|
||||||
.create_buffer_object(
|
.create_buffer_object(
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
GbmFormat::ARGB8888,
|
GbmFormat::ARGB8888,
|
||||||
BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE,
|
BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE,
|
||||||
)
|
)
|
||||||
.chain_err(|| ErrorKind::GbmInitFailed)?);
|
.chain_err(|| ErrorKind::GbmInitFailed)?, (0,0)));
|
||||||
|
|
||||||
Ok(DrmBackend {
|
Ok(DrmBackend {
|
||||||
backend: Rc::new(DrmBackendInternal {
|
backend: Rc::new(DrmBackendInternal {
|
||||||
|
@ -455,7 +455,7 @@ impl<A: Device + 'static> GraphicsBackend for DrmBackend<A> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// and store it
|
// and store it
|
||||||
self.backend.cursor.set(cursor);
|
self.backend.cursor.set((cursor, hotspot));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ use drm::control::{connector, crtc, encoder, Mode, ResourceInfo};
|
||||||
use drm::control::Device as ControlDevice;
|
use drm::control::Device as ControlDevice;
|
||||||
use drm::control::framebuffer;
|
use drm::control::framebuffer;
|
||||||
use drm::result::Error as DrmError;
|
use drm::result::Error as DrmError;
|
||||||
use gbm::Device as GbmDevice;
|
use gbm::{Device as GbmDevice, BufferObject};
|
||||||
use nix;
|
use nix;
|
||||||
use nix::sys::stat::{self, dev_t, fstat};
|
use nix::sys::stat::{self, dev_t, fstat};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -655,6 +655,25 @@ impl<A: ControlDevice + 'static> SessionObserver for StateToken<DrmDevice<A>> {
|
||||||
"Failed to activate crtc ({:?}) again. Error: {}", crtc, err
|
"Failed to activate crtc ({:?}) again. Error: {}", crtc, err
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// reset cursor
|
||||||
|
{
|
||||||
|
let &(ref cursor, ref hotspot) : &(BufferObject<()>, (u32, u32))
|
||||||
|
= unsafe { &*backend.cursor.as_ptr() };
|
||||||
|
if crtc::set_cursor2(
|
||||||
|
&*backend.context,
|
||||||
|
*crtc,
|
||||||
|
cursor,
|
||||||
|
((*hotspot).0 as i32, (*hotspot).1 as i32),
|
||||||
|
).is_err()
|
||||||
|
{
|
||||||
|
if let Err(err) = crtc::set_cursor(&*backend.context, *crtc, cursor) {
|
||||||
|
error!(
|
||||||
|
device.logger,
|
||||||
|
"Failed to reset cursor. Error: {}", err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
crtcs.push(*crtc);
|
crtcs.push(*crtc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue