Skip to content

Commit

Permalink
Fix broken drawer textures after scale change
Browse files Browse the repository at this point in the history
This fixes an issue with the arrow at the bottom of the drawer, where it
would turn into a solid black rectangle after the scale is changed.

This is due to the renderer being resized, invalidating the subtexture
and thus requiring a redraw. To fix this we now redraw the arrow
whenever the scale or size of the window has changed.

Closes #30.
  • Loading branch information
chrisduerr committed Dec 1, 2024
1 parent 94fc260 commit 827710b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/drawer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Drawer {

/// Check if the panel owns this surface.
pub fn owns_surface(&self, surface: &WlSurface) -> bool {
self.window.as_ref().map_or(false, |window| window.wl_surface() == surface)
self.window.as_ref().is_some_and(|window| window.wl_surface() == surface)
}

/// Update the DPI scale factor.
Expand Down Expand Up @@ -387,6 +387,8 @@ impl Drawer {
// Resize if the surface exists already.
if self.renderer.has_surface() {
let _ = self.renderer.resize(size, self.scale_factor);
self.closing_icon = None;
self.opening_icon = None;
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ impl TouchHandler for State {

// Handle short taps.
if !drawer.offsetting {
if last_tap.map_or(false, |tap| tap.elapsed() <= MAX_DOUBLE_TAP_DURATION) {
if last_tap.is_some_and(|tap| tap.elapsed() <= MAX_DOUBLE_TAP_DURATION) {
// Remove delayed single-tap callback.
if let Some(source) = self.tap_timeout.take() {
self.event_loop.remove(source);
Expand All @@ -488,7 +488,7 @@ impl TouchHandler for State {
TimeoutAction::Drop
});
self.tap_timeout = source.ok();
} else if self.panel_height.map_or(false, |panel_height| {
} else if self.panel_height.is_some_and(|panel_height| {
self.touch_start.1 >= panel_height as f64 - HANDLE_HEIGHT as f64
}) {
// Immediately close drawer, since handle has no double-tap.
Expand Down

0 comments on commit 827710b

Please sign in to comment.