@@ -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
0 commit comments