Skip to content

Commit faae56f

Browse files
committed
Don't use scrollbar from ScrolledWindow
1 parent 55d285b commit faae56f

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

src/ItemManager.vala

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#if WORKSPACE_SWITCHER
1212
private Gtk.Separator separator;
1313
private DynamicWorkspaceIcon dynamic_workspace_item;
14+
private Gtk.Revealer workspaces_scrollbar_revealer;
1415
#endif
1516

1617
static construct {
@@ -41,18 +42,45 @@
4142

4243
var workspace_group_scrolled = new Gtk.ScrolledWindow () {
4344
child = new ItemGroup (WorkspaceSystem.get_default ().workspaces, (obj) => new WorkspaceIconGroup ((Workspace) obj)),
45+
hscrollbar_policy = EXTERNAL,
4446
vscrollbar_policy = NEVER,
4547
propagate_natural_width = true
4648
};
4749

50+
/*
51+
* Gtk.ScrolledWindow with scrollbar policy set to ALWAYS or AUTOMATIC reserves ~30px of space for scrollbar
52+
* And it doesn't matter if the scrollbar is shown or not, the space is always reserved.
53+
* Essentially, by default workspace_group_scrolled's minimum size is 30px, to avoid this
54+
* we set scrollbar policy to EXTERNAL and handle scrollbar ourselves.
55+
*/
56+
57+
var workspaces_scrollbar = new Gtk.Scrollbar (HORIZONTAL, workspace_group_scrolled.hadjustment) {
58+
vexpand = false,
59+
valign = END
60+
};
61+
62+
workspaces_scrollbar_revealer = new Gtk.Revealer () {
63+
child = workspaces_scrollbar,
64+
vexpand = false,
65+
valign = END
66+
};
67+
68+
update_workspaces_scrollbar_revealer (workspace_group_scrolled.hadjustment);
69+
workspace_group_scrolled.hadjustment.changed.connect (update_workspaces_scrollbar_revealer);
70+
71+
var scrollbar_overlay = new Gtk.Overlay () {
72+
child = workspace_group_scrolled
73+
};
74+
scrollbar_overlay.add_overlay (workspaces_scrollbar_revealer);
75+
4876
dynamic_workspace_item = new DynamicWorkspaceIcon ();
4977
#endif
5078

5179
append (app_group_scrolled);
5280
append (background_group);
5381
#if WORKSPACE_SWITCHER
5482
append (separator_box);
55-
append (workspace_group_scrolled);
83+
append (scrollbar_overlay);
5684
append (dynamic_workspace_item);
5785
#endif
5886
overflow = VISIBLE;
@@ -172,4 +200,8 @@
172200
warning ("Tried to move neither launcher nor icon group");
173201
}
174202
}
203+
204+
private void update_workspaces_scrollbar_revealer (Gtk.Adjustment adjustment) {
205+
scrollbar_revealer.reveal_child = adjustment.upper - adjustment.lower > adjustment.page_size;
206+
}
175207
}

0 commit comments

Comments
 (0)