Skip to content

Commit 31286a3

Browse files
mrsteve0924trigg
authored andcommitted
panel: avoid edge animation when orientation changes
Assisted-by: ChatGPT:GPT-5.6 Sol Signed-off-by: steve finkel <mrsteve0924@verizon.net>
1 parent 70959f3 commit 31286a3

2 files changed

Lines changed: 47 additions & 5 deletions

File tree

‎src/util/wf-autohide-window.cpp‎

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,60 @@ void WayfireAutohidingWindow::update_position()
258258
return;
259259
}
260260

261+
const auto new_position = check_position(position);
262+
263+
const auto is_vertical_position = [] (const std::string& pos)
264+
{
265+
return (pos == WF_WINDOW_POSITION_LEFT) ||
266+
(pos == WF_WINDOW_POSITION_RIGHT);
267+
};
268+
269+
const bool new_vertical = is_vertical_position(new_position);
270+
271+
const bool orientation_changed =
272+
!previous_position.empty() &&
273+
(is_vertical_position(previous_position) != new_vertical);
274+
261275
// need different measurements depending on position
262-
if ((edge == GTK_LAYER_SHELL_EDGE_LEFT) || (edge == GTK_LAYER_SHELL_EDGE_RIGHT))
276+
if (new_vertical)
263277
{
264278
get_allocated_height_or_width = &Gtk::Widget::get_allocated_width;
265279
} else
266280
{
267281
get_allocated_height_or_width = &Gtk::Widget::get_allocated_height;
268282
}
269283

270-
/* When the position changes, show an animation from the new edge. */
271-
autohide_animation.animate(-(this->*get_allocated_height_or_width)(), 0);
272-
start_draw_timer();
273-
m_show_uncertain();
284+
if (orientation_changed)
285+
{
286+
/*
287+
* GTK still has the allocation from the previous orientation here.
288+
* Animating the layer-shell margin while the window is being
289+
* reallocated can make the panel disappear. Show it immediately
290+
* when changing orientation instead.
291+
*/
292+
autohide_animation.set(0, 0);
293+
294+
if (get_surface())
295+
{
296+
wl_surface_commit(get_wl_surface());
297+
}
298+
299+
queue_draw();
300+
301+
if (should_autohide())
302+
{
303+
schedule_hide(autohide_hide_delay);
304+
}
305+
} else
306+
{
307+
/* When the position changes, show an animation from the new edge. */
308+
autohide_animation.animate(
309+
-(this->*get_allocated_height_or_width)(), 0);
310+
start_draw_timer();
311+
m_show_uncertain();
312+
}
313+
314+
previous_position = new_position;
274315
setup_hotspot();
275316
}
276317

‎src/util/wf-autohide-window.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class WayfireAutohidingWindow : public Gtk::Window
9191

9292
WfOption<std::string> position;
9393
WfOption<bool> full_span;
94+
std::string previous_position;
9495
void update_position();
9596

9697
WfOption<int> minimal_width;

0 commit comments

Comments
 (0)