|
11 | 11 | #if WORKSPACE_SWITCHER |
12 | 12 | private Gtk.Separator separator; |
13 | 13 | private DynamicWorkspaceIcon dynamic_workspace_item; |
| 14 | + private Gtk.Revealer workspaces_scrollbar_revealer; |
14 | 15 | #endif |
15 | 16 |
|
16 | 17 | static construct { |
|
41 | 42 |
|
42 | 43 | var workspace_group_scrolled = new Gtk.ScrolledWindow () { |
43 | 44 | child = new ItemGroup (WorkspaceSystem.get_default ().workspaces, (obj) => new WorkspaceIconGroup ((Workspace) obj)), |
| 45 | + hscrollbar_policy = EXTERNAL, |
44 | 46 | vscrollbar_policy = NEVER, |
45 | 47 | propagate_natural_width = true |
46 | 48 | }; |
47 | 49 |
|
| 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 | + |
48 | 76 | dynamic_workspace_item = new DynamicWorkspaceIcon (); |
49 | 77 | #endif |
50 | 78 |
|
51 | 79 | append (app_group_scrolled); |
52 | 80 | append (background_group); |
53 | 81 | #if WORKSPACE_SWITCHER |
54 | 82 | append (separator_box); |
55 | | - append (workspace_group_scrolled); |
| 83 | + append (scrollbar_overlay); |
56 | 84 | append (dynamic_workspace_item); |
57 | 85 | #endif |
58 | 86 | overflow = VISIBLE; |
|
172 | 200 | warning ("Tried to move neither launcher nor icon group"); |
173 | 201 | } |
174 | 202 | } |
| 203 | + |
| 204 | + private void update_workspaces_scrollbar_revealer (Gtk.Adjustment adjustment) { |
| 205 | + scrollbar_revealer.reveal_child = adjustment.upper - adjustment.lower > adjustment.page_size; |
| 206 | + } |
175 | 207 | } |
0 commit comments