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

simple_layer example: Handle 0 width/height in configure correctly #482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 3 additions & 8 deletions examples/simple_layer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This example is horrible. Please make a better one soon.

use std::convert::TryInto;
use std::{convert::TryInto, num::NonZeroU32};

use smithay_client_toolkit::{
compositor::{CompositorHandler, CompositorState},
Expand Down Expand Up @@ -215,13 +215,8 @@ impl LayerShellHandler for SimpleLayer {
configure: LayerSurfaceConfigure,
_serial: u32,
) {
if configure.new_size.0 == 0 || configure.new_size.1 == 0 {
self.width = 256;
self.height = 256;
} else {
self.width = configure.new_size.0;
self.height = configure.new_size.1;
}
self.width = NonZeroU32::new(configure.new_size.0).map_or(256, NonZeroU32::get);
self.height = NonZeroU32::new(configure.new_size.1).map_or(256, NonZeroU32::get);

// Initiate the first draw.
if self.first_configure {
Expand Down