From 9242bb679df83437636ea23eeeaef8f4844176f0 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 27 Nov 2022 17:14:31 +0000 Subject: [PATCH 1/2] panel: Hardcode some debugging Quickly done, useful for development tests. For user control, this requires connecting to some switch. --- src/panel.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/panel.rs b/src/panel.rs index d1af0599..99ddd199 100644 --- a/src/panel.rs +++ b/src/panel.rs @@ -132,6 +132,10 @@ pub enum Command { pub struct Manager { panel: c::PanelManager, state: State, + // This should be part of State, if it ever actually gets unhardcoded. + // It's here because State doesn't need to become more complex + // until this becomes properly used. + debug: bool, } impl Manager { @@ -139,11 +143,16 @@ impl Manager { Self { panel, state: State::Hidden, + debug: false, } } // TODO: mabe send the allocated size back to state::State, // to perform layout adjustments fn set_configured(&mut self, size: Size) { + if self.debug { + eprintln!("Panel received configure {:?}", &size); + } + self.state = match self.state.clone() { State::Hidden => { // This may happen if a hide is scheduled immediately after a show. @@ -166,6 +175,10 @@ impl Manager { allocated: size, }, }; + + if self.debug { + eprintln!("Panel now {:?}", &self.state); + } } pub fn update(mgr: Wrapped, cmd: Command) { @@ -173,6 +186,10 @@ impl Manager { let mgr = mgr.clone_ref(); let mut mgr = mgr.borrow_mut(); + + if mgr.debug { + eprintln!("Panel received {:?}", &cmd); + } (*mgr).state = match (cmd, mgr.state.clone()) { (Command::Hide, State::Hidden) => State::Hidden, @@ -186,6 +203,9 @@ impl Manager { }, (Command::Show{output, height}, State::Hidden) => { let height = height.as_scaled_ceiling(); + if mgr.debug { + eprintln!("Panel requests widget {:?}", (&output.0, &height)); + } unsafe { c::panel_manager_request_widget(mgr.panel, output.0, height, copied); } State::SizeRequested{output, height} }, @@ -210,6 +230,9 @@ impl Manager { // for the purpose of handling it better somehow. State::SizeRequested{output: req_output, height: req_height} } else { + if mgr.debug { + eprintln!("Panel requests widget {:?}", (&output.0, &height)); + } // This looks weird, but should be safe. // The stack seems to handle // configure events on a dead surface. @@ -242,6 +265,10 @@ impl Manager { State::SizeRequested{output, height} } }, + }; + + if mgr.debug { + eprintln!("Panel is now {:?}", &(*mgr).state); } } } From 805c0d27fd651a5dc3acf380b656747924728dbe Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sun, 27 Nov 2022 17:50:39 +0000 Subject: [PATCH 2/2] panel: Fix resize when reusing the window When the panel window was reused, it was not re-initialized. That includes the panel size request. If the last panel size was matching a different display size (including orientation), the newly shown panel would re-use that size instead of respecting the newly requested size. --- src/panel.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/panel.c b/src/panel.c index d391a5e3..a9942c89 100644 --- a/src/panel.c +++ b/src/panel.c @@ -55,6 +55,16 @@ make_widget (struct panel_manager *self) } +// Called also from rust +/// Updates the size +void +panel_manager_resize (struct panel_manager *self, uint32_t height) +{ + phosh_layer_surface_set_size(self->window, 0, height); + phosh_layer_surface_set_exclusive_zone(self->window, height); + phosh_layer_surface_wl_surface_commit(self->window); +} + // Called from rust /// Creates a new panel widget void @@ -89,6 +99,8 @@ panel_manager_request_widget (struct panel_manager *self, struct wl_output *outp gtk_window_set_title (GTK_WINDOW(self->window), "Squeekboard"); gtk_window_set_icon_name (GTK_WINDOW(self->window), "squeekboard"); gtk_window_set_keep_above (GTK_WINDOW(self->window), TRUE); + } else { + panel_manager_resize(self, height); } if (!self->widget) { @@ -98,17 +110,6 @@ panel_manager_request_widget (struct panel_manager *self, struct wl_output *outp gtk_widget_show (GTK_WIDGET(self->window)); } -// Called from rust -/// Updates the size -void -panel_manager_resize (struct panel_manager *self, uint32_t height) -{ - phosh_layer_surface_set_size(self->window, 0, height); - phosh_layer_surface_set_exclusive_zone(self->window, height); - phosh_layer_surface_wl_surface_commit(self->window); -} - - struct panel_manager panel_manager_new(EekboardContextService *state, struct submission *submission, struct squeek_state_manager *state_manager, struct squeek_popover *popover) { struct panel_manager mgr = {