DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into codex/windows-integrated-titlebar
moppeeereda4f671b71a
diff --cc crates/ui-egui/src/lib.rsindex 00efede01,1db2f591d..2b0cf6ee6--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@@ -768,7 -876,9 +883,10 @@@ impl DesignApp/// Per-frame logic before layout.pub fn logic(&mut self, ctx: &egui::Context) {+ self.window_maximized = ctx.input(|i| i.viewport().maximized.unwrap_or(false));+ if self.egui_ctx.is_none() {+ self.egui_ctx = Some(ctx.clone());+ }if !self.color_applied {self.color_applied = true;if let Some(cs) = self.ui.color_settings.clone() {@@@ -1014,26 -1123,39 +1132,46 @@@r}+ /// Deliver window actions to the host without persisting them in UI preferences.+ pub(crate) fn flush_window_commands(&mut self, ctx: &egui::Context) {+ for command in std::mem::take(&mut self.pending_window_commands) {+ ctx.send_viewport_cmd(command);+ }+ }+- /// Inject synthetic events (one pointer event per frame).- pub fn raw_input_hook(&mut self, raw: &mut egui::RawInput) {- if self.synthetic.is_empty() {+ /// Keep widget clipboard output private while a queued control event is running.+ pub(crate) fn install_clipboard_guard(&mut self, ctx: &egui::Context) {+ if self.clipboard_guard_installed {return;}- let n = match self.synthetic[0] {+ let private = self.control_input_frame.clone();+ ctx.on_end_pass(+ "control clipboard",+ std::sync::Arc::new(move |ui| {+ if private.load(std::sync::atomic::Ordering::Relaxed) {+ ui.ctx().output_mut(|o| {+ o.commands.retain(|cmd| !matches!(cmd, egui::OutputCommand::CopyText(_) | egui::OutputCommand::CopyImage(_)))+ });+ }+ }),+ );+ self.clipboard_guard_installed = true;+ }++ /// Inject synthetic events (one pointer event per frame), retaining control provenance.+ pub fn raw_input_hook(&mut self, raw: &mut egui::RawInput) {+ let private = !self.control_synthetic.is_empty();+ self.control_input_frame.store(private, std::sync::atomic::Ordering::Relaxed);+ let events = if private { &mut self.control_synthetic } else { &mut self.synthetic };+ let Some(first) = events.first() else { return };+ let n = match first {egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } => 1,- _ => self.synthetic.iter().position(|e| matches!(e, egui::Event::Key { pressed: false, .. })).map_or(self.synthetic.len(), |i| i + 1),+ _ => events.iter().position(|e| matches!(e, egui::Event::Key { pressed: false, .. })).map_or(events.len(), |i| i + 1),};- if let Some(egui::Event::PointerMoved(p) | egui::Event::PointerButton { pos: p, .. }) = self.synthetic.first() {+ if let egui::Event::PointerMoved(p) | egui::Event::PointerButton { pos: p, .. } = first {raw.events.push(egui::Event::PointerMoved(*p));}- raw.events.extend(self.synthetic.drain(..n));+ raw.events.extend(events.drain(..n));}/// Lay out the whole window.