From 90669b6b8ab18978955a2d148ccdd1abb0b38c49 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Sat, 7 Sep 2024 07:05:43 -0700 Subject: [PATCH] WindowBehavior::moved --- CHANGELOG.md | 1 + src/window.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d197b3f..8c3ff26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `PendingApp::on_startup` accepts a callback that will be invoked once the event loop is executing. +- `WindowBehavior::moved` is called when the window moves. ### Changed diff --git a/src/window.rs b/src/window.rs index c7c0ae5..d3488aa 100644 --- a/src/window.rs +++ b/src/window.rs @@ -581,7 +581,10 @@ where } } WindowEvent::Moved(position) => { - self.position = position; + if self.position != position { + self.position = position; + behavior.moved(self); + } } WindowEvent::Destroyed => { return HandleMessageResult::Destroyed; @@ -979,6 +982,11 @@ where #[allow(unused_variables)] fn resized(&mut self, window: &mut RunningWindow) {} + /// The window has been moved. [`RunningWindow::position()`] returns the + /// current position. + #[allow(unused_variables)] + fn moved(&mut self, window: &mut RunningWindow) {} + /// The window's theme has been updated. [`RunningWindow::theme()`] /// returns the current theme. #[allow(unused_variables)]