Skip to content

Commit 638ca60

Browse files
authored
Merge pull request #323 from MaxVerevkin/remove-unnecessary-result
remove unnecessary Result in `CompositorState::create_surface`
2 parents e5d7c90 + 0f2a3f3 commit 638ca60

File tree

8 files changed

+12
-19
lines changed

8 files changed

+12
-19
lines changed

examples/generic_simple_window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn main() {
6666
.expect("Failed to create pool");
6767
simple_window.pool = Some(pool);
6868

69-
let surface = simple_window.compositor_state.create_surface(&qh).unwrap();
69+
let surface = simple_window.compositor_state.create_surface(&qh);
7070

7171
let window = Window::builder()
7272
.title("A wayland window")

examples/image_viewer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() {
5858
// We'll need the image in RGBA for drawing it
5959
let image = image.to_rgba8();
6060

61-
let surface = state.compositor_state.create_surface(&qh).unwrap();
61+
let surface = state.compositor_state.create_surface(&qh);
6262

6363
pool_size += image.width() * image.height() * 4;
6464

examples/image_viewporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn main() {
6060
// We'll need the image in RGBA for drawing it
6161
let image = image.to_rgba8();
6262

63-
let surface = state.compositor_state.create_surface(&qh).unwrap();
63+
let surface = state.compositor_state.create_surface(&qh);
6464

6565
pool_size += image.width() * image.height() * 4;
6666

examples/pointer_theme_window.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ fn main() {
4848
let pool = SlotPool::new(width as usize * height as usize * 4, &shm_state)
4949
.expect("Failed to create pool");
5050

51-
let window_surface = compositor_state.create_surface(&qh).unwrap();
52-
let pointer_surface = compositor_state.create_surface(&qh).unwrap();
51+
let window_surface = compositor_state.create_surface(&qh);
52+
let pointer_surface = compositor_state.create_surface(&qh);
5353

5454
let window = Window::builder()
5555
.title("A wayland window")

examples/simple_layer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ fn main() {
6262
.expect("Failed to create pool");
6363
simple_layer.pool = Some(pool);
6464

65-
let surface = simple_layer.compositor_state.create_surface(&qh).unwrap();
65+
let surface = simple_layer.compositor_state.create_surface(&qh);
6666

6767
let layer = LayerSurface::builder()
6868
.size((256, 256))
6969
.anchor(Anchor::BOTTOM)
7070
.keyboard_interactivity(KeyboardInteractivity::OnDemand)
7171
.namespace("sample_layer")
72-
.map(&qh, &mut simple_layer.layer_state, surface, Layer::Top)
72+
.map(&qh, &simple_layer.layer_state, surface, Layer::Top)
7373
.expect("layer surface creation");
7474

7575
simple_layer.layer = Some(layer);

examples/simple_window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn main() {
7272
.expect("Failed to create pool");
7373
simple_window.pool = Some(pool);
7474

75-
let surface = simple_window.compositor_state.create_surface(&qh).unwrap();
75+
let surface = simple_window.compositor_state.create_surface(&qh);
7676

7777
let window = Window::builder()
7878
.title("A wayland window")

src/compositor.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ impl CompositorState {
6969
&self.wl_compositor
7070
}
7171

72-
pub fn create_surface<D>(
73-
&self,
74-
qh: &QueueHandle<D>,
75-
) -> Result<wl_surface::WlSurface, GlobalError>
72+
pub fn create_surface<D>(&self, qh: &QueueHandle<D>) -> wl_surface::WlSurface
7673
where
7774
D: Dispatch<wl_surface::WlSurface, SurfaceData> + 'static,
7875
{
@@ -83,14 +80,12 @@ impl CompositorState {
8380
&self,
8481
qh: &QueueHandle<D>,
8582
data: U,
86-
) -> Result<wl_surface::WlSurface, GlobalError>
83+
) -> wl_surface::WlSurface
8784
where
8885
D: Dispatch<wl_surface::WlSurface, U> + 'static,
8986
U: SurfaceDataExt + 'static,
9087
{
91-
let surface = self.wl_compositor.create_surface(qh, data);
92-
93-
Ok(surface)
88+
self.wl_compositor.create_surface(qh, data)
9489
}
9590
}
9691

src/seat/pointer/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,9 @@ impl ThemedPointer {
506506
if surface.version() >= 4 {
507507
surface.damage_buffer(0, 0, w as i32, h as i32);
508508
} else {
509-
let scale = self.scale;
510-
511509
// surface is old and does not support damage_buffer, so we damage
512510
// in surface coordinates and hope it is not rescaled
513-
surface.damage(0, 0, w as i32 / scale as i32, h as i32 / scale as i32);
511+
surface.damage(0, 0, w as i32 / self.scale, h as i32 / self.scale);
514512
}
515513

516514
// Commit the surface to place the cursor image in the compositor's memory.

0 commit comments

Comments
 (0)