Skip to content

Commit 757f366

Browse files
committed
autohide-window : add margins to the opposite edge if autohide is disabled
The margins being mostly a matter of style, this makes it so that if a margin is applied and autohide is disabled, space is reserved on both sides of the window. However, wayfire 0.10.1 with gtk4-layer-shell 1.3 has a bug where auto exclusive zone doesn’t account for the margin size, which causes shell toplevels to go outside of the reserved space. Until this is fixed, on wayfire, this patch only prevents overlap and doesn’t cause the intended behaviour Wayfire issue : WayfireWM/wayfire#3038
1 parent 0d3d68e commit 757f366

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

src/util/wf-autohide-window.cpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,35 @@ void WayfireAutohidingWindow::m_show_uncertain()
204204

205205
void WayfireAutohidingWindow::update_position()
206206
{
207-
/* Reset old anchors */
208-
gtk_layer_set_anchor(this->gobj(), GTK_LAYER_SHELL_EDGE_TOP, false);
209-
gtk_layer_set_anchor(this->gobj(), GTK_LAYER_SHELL_EDGE_BOTTOM, false);
210-
gtk_layer_set_anchor(this->gobj(), GTK_LAYER_SHELL_EDGE_LEFT, false);
211-
gtk_layer_set_anchor(this->gobj(), GTK_LAYER_SHELL_EDGE_RIGHT, false);
207+
// reset anchors and margins
208+
for (auto edge :
209+
{GTK_LAYER_SHELL_EDGE_TOP, GTK_LAYER_SHELL_EDGE_BOTTOM, GTK_LAYER_SHELL_EDGE_LEFT,
210+
GTK_LAYER_SHELL_EDGE_RIGHT})
211+
{
212+
gtk_layer_set_anchor(this->gobj(), edge, false);
213+
gtk_layer_set_margin(this->gobj(), edge, 0);
214+
}
212215

213216
/* Set new anchor */
214217
GtkLayerShellEdge edge = get_anchor_edge(position);
215218
gtk_layer_set_anchor(this->gobj(), edge, true);
216219
gtk_layer_set_margin(this->gobj(), edge, edge_margin);
220+
if (auto_exclusive_zone)
221+
{
222+
if (edge == GTK_LAYER_SHELL_EDGE_TOP)
223+
{
224+
gtk_layer_set_margin(this->gobj(), GTK_LAYER_SHELL_EDGE_BOTTOM, edge_margin);
225+
} else if (edge == GTK_LAYER_SHELL_EDGE_BOTTOM)
226+
{
227+
gtk_layer_set_margin(this->gobj(), GTK_LAYER_SHELL_EDGE_TOP, edge_margin);
228+
} else if (edge == GTK_LAYER_SHELL_EDGE_LEFT)
229+
{
230+
gtk_layer_set_margin(this->gobj(), GTK_LAYER_SHELL_EDGE_RIGHT, edge_margin);
231+
} else if (edge == GTK_LAYER_SHELL_EDGE_RIGHT)
232+
{
233+
gtk_layer_set_margin(this->gobj(), GTK_LAYER_SHELL_EDGE_LEFT, edge_margin);
234+
}
235+
}
217236

218237
if (full_span)
219238
{

0 commit comments

Comments
 (0)