Rework the initial wayland init a bit
This commit is contained in:
+8
-1
@@ -82,16 +82,18 @@ pub struct ShmBuffer {
|
|||||||
pub mmap: MmapMut,
|
pub mmap: MmapMut,
|
||||||
pub buffer: wl_buffer::WlBuffer,
|
pub buffer: wl_buffer::WlBuffer,
|
||||||
pub refcnt: u32,
|
pub refcnt: u32,
|
||||||
|
pub id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShmBuffer {
|
impl ShmBuffer {
|
||||||
pub fn new<D>(
|
fn new<D>(
|
||||||
shm: &wl_shm::WlShm,
|
shm: &wl_shm::WlShm,
|
||||||
qh: &QueueHandle<D>,
|
qh: &QueueHandle<D>,
|
||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
stride: i32,
|
stride: i32,
|
||||||
format: wl_shm::Format,
|
format: wl_shm::Format,
|
||||||
|
id: u32,
|
||||||
) -> io::Result<ShmBuffer>
|
) -> io::Result<ShmBuffer>
|
||||||
where
|
where
|
||||||
D: Dispatch<wl_shm_pool::WlShmPool, ()> + Dispatch<wl_buffer::WlBuffer, ()> + 'static,
|
D: Dispatch<wl_shm_pool::WlShmPool, ()> + Dispatch<wl_buffer::WlBuffer, ()> + 'static,
|
||||||
@@ -108,6 +110,7 @@ impl ShmBuffer {
|
|||||||
file,
|
file,
|
||||||
mmap,
|
mmap,
|
||||||
buffer,
|
buffer,
|
||||||
|
id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,12 +125,14 @@ impl ShmBuffer {
|
|||||||
|
|
||||||
pub struct BufferManager {
|
pub struct BufferManager {
|
||||||
pub buffers: Vec<ShmBuffer>,
|
pub buffers: Vec<ShmBuffer>,
|
||||||
|
pub next_id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BufferManager {
|
impl BufferManager {
|
||||||
pub fn new() -> BufferManager {
|
pub fn new() -> BufferManager {
|
||||||
BufferManager {
|
BufferManager {
|
||||||
buffers: Vec::new(),
|
buffers: Vec::new(),
|
||||||
|
next_id: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +167,10 @@ impl BufferManager {
|
|||||||
dimensions.1,
|
dimensions.1,
|
||||||
dimensions.0 * 4,
|
dimensions.0 * 4,
|
||||||
wl_shm::Format::Argb8888,
|
wl_shm::Format::Argb8888,
|
||||||
|
self.next_id,
|
||||||
)
|
)
|
||||||
.expect("unable to add buffer");
|
.expect("unable to add buffer");
|
||||||
|
self.next_id += 1;
|
||||||
BufferView::new(&mut buf.mmap, (dimensions.0 as u32, dimensions.1 as u32));
|
BufferView::new(&mut buf.mmap, (dimensions.0 as u32, dimensions.1 as u32));
|
||||||
self.buffers.push(buf);
|
self.buffers.push(buf);
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-2
@@ -82,6 +82,7 @@ fn main() {
|
|||||||
|
|
||||||
let display = conn.display();
|
let display = conn.display();
|
||||||
display.get_registry(&qhandle, ());
|
display.get_registry(&qhandle, ());
|
||||||
|
display.sync(&qhandle, ());
|
||||||
|
|
||||||
let (ping_sender, ping_source) = calloop::ping::make_ping().unwrap();
|
let (ping_sender, ping_source) = calloop::ping::make_ping().unwrap();
|
||||||
let (keyrepeat_sender, keyrepeat_channel) = calloop::channel::channel::<RepeatMessage>();
|
let (keyrepeat_sender, keyrepeat_channel) = calloop::channel::channel::<RepeatMessage>();
|
||||||
@@ -224,12 +225,21 @@ fn main() {
|
|||||||
damage.push(Geometry::new());
|
damage.push(Geometry::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initial setup
|
||||||
|
//
|
||||||
|
while state.running && !state.ready {
|
||||||
|
event_loop
|
||||||
|
.dispatch(None, &mut state)
|
||||||
|
.expect("Could not dispatch event loop");
|
||||||
|
}
|
||||||
|
state.check_registry(&qhandle);
|
||||||
|
|
||||||
while state.running {
|
while state.running {
|
||||||
event_loop
|
event_loop
|
||||||
.dispatch(None, &mut state)
|
.dispatch(None, &mut state)
|
||||||
.expect("Could not dispatch event loop");
|
.expect("Could not dispatch event loop");
|
||||||
|
|
||||||
if !state.configured || !state.dirty {
|
if !state.configured || !state.dirty || !state.ready {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,9 +253,17 @@ fn main() {
|
|||||||
let buf = match state.bufmgr.next_buffer() {
|
let buf = match state.bufmgr.next_buffer() {
|
||||||
Some(b) => b,
|
Some(b) => b,
|
||||||
None => {
|
None => {
|
||||||
// We are still waiting for our buffer
|
if state.bufmgr.buffers.len() >= 3 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
state.add_buffer(&qhandle);
|
||||||
|
match state.bufmgr.next_buffer() {
|
||||||
|
Some(b) => b,
|
||||||
|
None => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
state.dirty = false;
|
state.dirty = false;
|
||||||
@@ -297,7 +315,9 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.ready = false;
|
||||||
surface.attach(Some(&buf.buffer), 0, 0);
|
surface.attach(Some(&buf.buffer), 0, 0);
|
||||||
|
surface.frame(&qhandle, ());
|
||||||
surface.commit();
|
surface.commit();
|
||||||
conn.flush().unwrap();
|
conn.flush().unwrap();
|
||||||
|
|
||||||
|
|||||||
+127
-96
@@ -9,7 +9,7 @@ use std::{
|
|||||||
use wayland_client::{
|
use wayland_client::{
|
||||||
protocol::{
|
protocol::{
|
||||||
wl_buffer, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat, wl_shm,
|
wl_buffer, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat, wl_shm,
|
||||||
wl_shm_pool, wl_subcompositor, wl_subsurface, wl_surface,
|
wl_shm_pool, wl_subcompositor, wl_subsurface, wl_surface, wl_callback,
|
||||||
},
|
},
|
||||||
Connection, Dispatch, QueueHandle, WEnum,
|
Connection, Dispatch, QueueHandle, WEnum,
|
||||||
};
|
};
|
||||||
@@ -54,9 +54,14 @@ pub struct BackgroundSurface {
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Protocols {
|
pub struct Protocols {
|
||||||
|
wl_compositor: Option<wl_compositor::WlCompositor>,
|
||||||
|
wl_subcompositor: Option<wl_subcompositor::WlSubcompositor>,
|
||||||
wl_shm: Option<wl_shm::WlShm>,
|
wl_shm: Option<wl_shm::WlShm>,
|
||||||
|
xdg_wm_base: Option<xdg_wm_base::XdgWmBase>,
|
||||||
xdg_activation: Option<xdg_activation_v1::XdgActivationV1>,
|
xdg_activation: Option<xdg_activation_v1::XdgActivationV1>,
|
||||||
|
zwlr_layer_shell: Option<zwlr_layer_shell_v1::ZwlrLayerShellV1>,
|
||||||
viewporter: Option<wp_viewporter::WpViewporter>,
|
viewporter: Option<wp_viewporter::WpViewporter>,
|
||||||
|
wp_single_pixel_buffer_manager: Option<wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
@@ -66,6 +71,7 @@ pub struct State {
|
|||||||
pub bg_surface: BackgroundSurface,
|
pub bg_surface: BackgroundSurface,
|
||||||
pub protocols: Protocols,
|
pub protocols: Protocols,
|
||||||
pub running: bool,
|
pub running: bool,
|
||||||
|
pub ready: bool,
|
||||||
pub dirty: bool,
|
pub dirty: bool,
|
||||||
activated: bool,
|
activated: bool,
|
||||||
pub configured: bool,
|
pub configured: bool,
|
||||||
@@ -109,6 +115,7 @@ impl State {
|
|||||||
fonts,
|
fonts,
|
||||||
events,
|
events,
|
||||||
layout,
|
layout,
|
||||||
|
ready: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +162,84 @@ impl WidgetUpdater for State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl State {
|
||||||
|
pub fn check_registry(&mut self, qh: &QueueHandle<Self>) {
|
||||||
|
let wl_compositor = self.protocols.wl_compositor.as_ref().expect("wl_compositor missing");
|
||||||
|
let main_surface = wl_compositor.create_surface(qh, ());
|
||||||
|
let bg_surface = wl_compositor.create_surface(qh, ());
|
||||||
|
self.main_surface.wl_surface = Some(main_surface.clone());
|
||||||
|
self.bg_surface.wl_surface = Some(bg_surface.clone());
|
||||||
|
self.activate(qh);
|
||||||
|
|
||||||
|
let wl_subcompositor = self.protocols.wl_subcompositor.as_ref().expect("wl_subcompositor missing");
|
||||||
|
let subsurface = wl_subcompositor.get_subsurface(&bg_surface, &main_surface, qh, ());
|
||||||
|
subsurface.place_below(&main_surface);
|
||||||
|
self.bg_surface.subsurface = Some(subsurface.clone());
|
||||||
|
|
||||||
|
match self.mode {
|
||||||
|
OperationMode::XdgToplevel => {
|
||||||
|
self.fonts.resolve();
|
||||||
|
let xdg_wm_base = self.protocols.xdg_wm_base.as_ref().expect("xdg_wm_base missing");
|
||||||
|
let xdg_surface = xdg_wm_base.get_xdg_surface(&main_surface, qh, ());
|
||||||
|
let toplevel = xdg_surface.get_toplevel(qh, ());
|
||||||
|
toplevel.set_title("wldash".into());
|
||||||
|
main_surface.commit();
|
||||||
|
|
||||||
|
self.main_surface.xdg_surface = Some((xdg_surface, toplevel));
|
||||||
|
}
|
||||||
|
OperationMode::LayerSurface(size) => {
|
||||||
|
self.fonts.resolve();
|
||||||
|
let layer_shell = self.protocols.zwlr_layer_shell.as_ref().expect("zwlr_layer_shell_v1 missing");
|
||||||
|
let layer_surface = layer_shell.get_layer_surface(
|
||||||
|
&main_surface,
|
||||||
|
None,
|
||||||
|
zwlr_layer_shell_v1::Layer::Top,
|
||||||
|
"launcher".to_string(),
|
||||||
|
qh,
|
||||||
|
(),
|
||||||
|
);
|
||||||
|
let fonts = self.fonts.unwrap();
|
||||||
|
let layout = self.layout.clone();
|
||||||
|
let min_size = layout.minimum_size(&mut fonts.borrow_mut(), self);
|
||||||
|
layer_surface.set_keyboard_interactivity(
|
||||||
|
zwlr_layer_surface_v1::KeyboardInteractivity::Exclusive,
|
||||||
|
);
|
||||||
|
layer_surface.set_anchor(
|
||||||
|
zwlr_layer_surface_v1::Anchor::Left
|
||||||
|
.union(zwlr_layer_surface_v1::Anchor::Bottom)
|
||||||
|
.union(zwlr_layer_surface_v1::Anchor::Right)
|
||||||
|
.union(zwlr_layer_surface_v1::Anchor::Top)
|
||||||
|
);
|
||||||
|
layer_surface.set_size(
|
||||||
|
max(size.0, min_size.width),
|
||||||
|
max(size.1, min_size.height),
|
||||||
|
);
|
||||||
|
|
||||||
|
main_surface.commit();
|
||||||
|
self.main_surface.layer_surface = Some(layer_surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let viewporter = self.protocols.viewporter.as_ref().expect("wp_viewporter missing");
|
||||||
|
let viewport = viewporter.get_viewport(&bg_surface, qh, ());
|
||||||
|
self.bg_surface.viewport = Some(viewport);
|
||||||
|
|
||||||
|
if let Some(background) = self.background {
|
||||||
|
let wp_single_pixel_buffer_manager = self.protocols.wp_single_pixel_buffer_manager.as_ref().expect("wp_single_pixel_buffer_manager_v1 missing");
|
||||||
|
let buffer = wp_single_pixel_buffer_manager.create_u32_rgba_buffer(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
background,
|
||||||
|
qh,
|
||||||
|
(),
|
||||||
|
);
|
||||||
|
bg_surface.attach(Some(&buffer), 0, 0);
|
||||||
|
bg_surface.damage_buffer(0, 0, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
||||||
fn event(
|
fn event(
|
||||||
state: &mut Self,
|
state: &mut Self,
|
||||||
@@ -170,26 +255,12 @@ impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
|||||||
{
|
{
|
||||||
match &interface[..] {
|
match &interface[..] {
|
||||||
"wl_compositor" => {
|
"wl_compositor" => {
|
||||||
let compositor =
|
state.protocols.wl_compositor =
|
||||||
registry.bind::<wl_compositor::WlCompositor, _, _>(name, 5, qh, ());
|
Some(registry.bind::<wl_compositor::WlCompositor, _, _>(name, 5, qh, ()));
|
||||||
let main_surface = compositor.create_surface(qh, ());
|
|
||||||
let bg_surface = compositor.create_surface(qh, ());
|
|
||||||
state.main_surface.wl_surface = Some(main_surface);
|
|
||||||
state.bg_surface.wl_surface = Some(bg_surface);
|
|
||||||
state.activate(qh);
|
|
||||||
}
|
}
|
||||||
"wl_subcompositor" => {
|
"wl_subcompositor" => {
|
||||||
let subcompositor =
|
state.protocols.wl_subcompositor =
|
||||||
registry.bind::<wl_subcompositor::WlSubcompositor, _, _>(name, 1, qh, ());
|
Some(registry.bind::<wl_subcompositor::WlSubcompositor, _, _>(name, 1, qh, ()));
|
||||||
|
|
||||||
match (&state.main_surface.wl_surface, &state.bg_surface.wl_surface) {
|
|
||||||
(Some(parent), Some(child)) => {
|
|
||||||
let subsurface = subcompositor.get_subsurface(child, parent, qh, ());
|
|
||||||
subsurface.place_below(parent);
|
|
||||||
state.bg_surface.subsurface = Some(subsurface);
|
|
||||||
}
|
|
||||||
_ => todo!("handle early subcompositor creation"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"wl_shm" => {
|
"wl_shm" => {
|
||||||
state.protocols.wl_shm =
|
state.protocols.wl_shm =
|
||||||
@@ -200,84 +271,27 @@ impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
|||||||
}
|
}
|
||||||
"xdg_wm_base" => {
|
"xdg_wm_base" => {
|
||||||
if let OperationMode::XdgToplevel = state.mode {
|
if let OperationMode::XdgToplevel = state.mode {
|
||||||
let wm_base =
|
state.protocols.xdg_wm_base =
|
||||||
registry.bind::<xdg_wm_base::XdgWmBase, _, _>(name, 2, qh, ());
|
Some(registry.bind::<xdg_wm_base::XdgWmBase, _, _>(name, 2, qh, ()));
|
||||||
match &state.main_surface.wl_surface {
|
|
||||||
Some(surface) => {
|
|
||||||
let xdg_surface = wm_base.get_xdg_surface(surface, qh, ());
|
|
||||||
let toplevel = xdg_surface.get_toplevel(qh, ());
|
|
||||||
toplevel.set_title("wldash".into());
|
|
||||||
|
|
||||||
surface.commit();
|
|
||||||
|
|
||||||
state.main_surface.xdg_surface = Some((xdg_surface, toplevel));
|
|
||||||
}
|
|
||||||
_ => todo!("handle early xdg_shell creation"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"xdg_activation_v1" => {
|
"xdg_activation_v1" => {
|
||||||
state.protocols.xdg_activation = Some(
|
state.protocols.xdg_activation = Some(
|
||||||
registry.bind::<xdg_activation_v1::XdgActivationV1, _, _>(name, 1, qh, ()),
|
registry.bind::<xdg_activation_v1::XdgActivationV1, _, _>(name, 1, qh, ()),
|
||||||
);
|
);
|
||||||
state.activate(qh);
|
|
||||||
}
|
}
|
||||||
"zwlr_layer_shell_v1" => {
|
"zwlr_layer_shell_v1" => {
|
||||||
if let OperationMode::LayerSurface(size) = state.mode {
|
if let OperationMode::LayerSurface(_) = state.mode {
|
||||||
let layer_shell = registry
|
state.protocols.zwlr_layer_shell = Some(registry
|
||||||
.bind::<zwlr_layer_shell_v1::ZwlrLayerShellV1, _, _>(name, 4, qh, ());
|
.bind::<zwlr_layer_shell_v1::ZwlrLayerShellV1, _, _>(name, 4, qh, ()));
|
||||||
state.fonts.resolve();
|
|
||||||
let fonts = state.fonts.unwrap();
|
|
||||||
let layout = state.layout.clone();
|
|
||||||
let min_size = layout.minimum_size(&mut fonts.borrow_mut(), state);
|
|
||||||
match &state.main_surface.wl_surface {
|
|
||||||
Some(surface) => {
|
|
||||||
let layer_surface = layer_shell.get_layer_surface(
|
|
||||||
surface,
|
|
||||||
None,
|
|
||||||
zwlr_layer_shell_v1::Layer::Top,
|
|
||||||
"launcher".to_string(),
|
|
||||||
qh,
|
|
||||||
(),
|
|
||||||
);
|
|
||||||
layer_surface.set_keyboard_interactivity(
|
|
||||||
zwlr_layer_surface_v1::KeyboardInteractivity::Exclusive,
|
|
||||||
);
|
|
||||||
layer_surface.set_size(
|
|
||||||
max(size.0, min_size.width),
|
|
||||||
max(size.1, min_size.height),
|
|
||||||
);
|
|
||||||
|
|
||||||
surface.commit();
|
|
||||||
state.main_surface.layer_surface = Some(layer_surface);
|
|
||||||
}
|
|
||||||
_ => todo!("handle early layer_shell creation"),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"wp_viewporter" => {
|
"wp_viewporter" => {
|
||||||
let viewporter =
|
state.protocols.viewporter =
|
||||||
registry.bind::<wp_viewporter::WpViewporter, _, _>(name, 1, qh, ());
|
Some(registry.bind::<wp_viewporter::WpViewporter, _, _>(name, 1, qh, ()));
|
||||||
match &state.bg_surface.wl_surface {
|
|
||||||
Some(surface) => {
|
|
||||||
state.bg_surface.viewport =
|
|
||||||
Some(viewporter.get_viewport(surface, qh, ()));
|
|
||||||
}
|
|
||||||
_ => todo!("handle early viewporter creation"),
|
|
||||||
}
|
|
||||||
state.protocols.viewporter = Some(viewporter);
|
|
||||||
}
|
|
||||||
"wp_single_pixel_buffer_manager_v1" if state.background.is_some() => {
|
|
||||||
let singlepixel = registry.bind::<wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1, _, _>(name, 1, qh, ());
|
|
||||||
match &state.bg_surface.wl_surface {
|
|
||||||
Some(surface) => {
|
|
||||||
let buffer =
|
|
||||||
singlepixel.create_u32_rgba_buffer(0, 0, 0, state.background.unwrap(), qh, ());
|
|
||||||
surface.attach(Some(&buffer), 0, 0);
|
|
||||||
surface.damage_buffer(0, 0, 1, 1);
|
|
||||||
}
|
|
||||||
_ => todo!("handle early single_pixel_buffer creation"),
|
|
||||||
}
|
}
|
||||||
|
"wp_single_pixel_buffer_manager_v1" => {
|
||||||
|
state.protocols.wp_single_pixel_buffer_manager = Some(registry.bind::<wp_single_pixel_buffer_manager_v1::WpSinglePixelBufferManagerV1, _, _>(name, 1, qh, ()));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -285,6 +299,24 @@ impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Dispatch<wl_callback::WlCallback, ()> for State {
|
||||||
|
fn event(
|
||||||
|
state: &mut Self,
|
||||||
|
_: &wl_callback::WlCallback,
|
||||||
|
event: wl_callback::Event,
|
||||||
|
_: &(),
|
||||||
|
_: &Connection,
|
||||||
|
_: &QueueHandle<Self>,
|
||||||
|
) {
|
||||||
|
match event {
|
||||||
|
wl_callback::Event::Done { callback_data: _ } => {
|
||||||
|
state.ready = true
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Dispatch<wl_compositor::WlCompositor, ()> for State {
|
impl Dispatch<wl_compositor::WlCompositor, ()> for State {
|
||||||
fn event(
|
fn event(
|
||||||
_: &mut Self,
|
_: &mut Self,
|
||||||
@@ -395,12 +427,12 @@ impl Dispatch<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, ()> for State {
|
|||||||
_: &Connection,
|
_: &Connection,
|
||||||
_: &QueueHandle<Self>,
|
_: &QueueHandle<Self>,
|
||||||
) {
|
) {
|
||||||
if let zwlr_layer_surface_v1::Event::Configure {
|
match event {
|
||||||
|
zwlr_layer_surface_v1::Event::Configure {
|
||||||
serial,
|
serial,
|
||||||
mut width,
|
mut width,
|
||||||
mut height,
|
mut height,
|
||||||
} = event
|
} => {
|
||||||
{
|
|
||||||
if (width, height) == (0, 0) {
|
if (width, height) == (0, 0) {
|
||||||
if state.configured {
|
if state.configured {
|
||||||
return;
|
return;
|
||||||
@@ -431,13 +463,15 @@ impl Dispatch<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, ()> for State {
|
|||||||
state,
|
state,
|
||||||
);
|
);
|
||||||
|
|
||||||
match (&state.bg_surface.wl_surface, &state.bg_surface.viewport) {
|
let surface = state.bg_surface.wl_surface.as_ref().expect("bg surface was not ready");
|
||||||
(Some(surface), Some(viewport)) => {
|
let viewport = state.bg_surface.viewport.as_ref().expect("bg viewport was not ready");
|
||||||
viewport.set_destination(dim.0, dim.1);
|
viewport.set_destination(dim.0, dim.1);
|
||||||
surface.commit();
|
surface.commit();
|
||||||
}
|
}
|
||||||
_ => todo!("handle early layer shell creation"),
|
zwlr_layer_surface_v1::Event::Closed => {
|
||||||
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -511,13 +545,10 @@ impl Dispatch<xdg_toplevel::XdgToplevel, ()> for State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !state.configured || state.dimensions != (width, height) {
|
if !state.configured || state.dimensions != (width, height) {
|
||||||
match (&state.bg_surface.wl_surface, &state.bg_surface.viewport) {
|
let surface = state.bg_surface.wl_surface.as_ref().expect("bg surface was not ready");
|
||||||
(Some(surface), Some(viewport)) => {
|
let viewport = state.bg_surface.viewport.as_ref().expect("bg viewportw as not ready");
|
||||||
viewport.set_destination(width, height);
|
viewport.set_destination(width, height);
|
||||||
surface.commit();
|
surface.commit();
|
||||||
}
|
|
||||||
_ => todo!("handle early xdg creation"),
|
|
||||||
}
|
|
||||||
|
|
||||||
state.bufmgr.clear_buffers();
|
state.bufmgr.clear_buffers();
|
||||||
state.dimensions = (width, height);
|
state.dimensions = (width, height);
|
||||||
|
|||||||
Reference in New Issue
Block a user