Skip to content

Commit

Permalink
fix: multiple tabswitcher bugs (workspace-based rendering, focus, ove…
Browse files Browse the repository at this point in the history
…rsizing) (#518)

* fix: multiple tabswitcher bugs (workspace-based rendering, focus, oversizing)

1. Fixed workspace-based rendering by adding missing invalidate filter during construction.
2. Fix focus issue caused by our get_time providing an incorrect event timing. Resolved by using Gdk.X11.get_server_time, need to rip that out when we switch to Wayland.
3. Fix TabSwitcher sizing not updating

Fixes:

- #515
- #517

* fix: rename get_preferred_max_children to get_visible_children

* fix: workspace blurry oversized icon #516
  • Loading branch information
JoshStrobl committed Jan 31, 2024
1 parent 8d143b6 commit 00ed13f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
31 changes: 27 additions & 4 deletions src/daemon/tabswitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Budgie {
public const string SWITCHER_DBUS_OBJECT_PATH = "/org/budgie_desktop/TabSwitcher";

public uint64 get_time() {
return (uint64) new DateTime.now().to_unix();
return (uint64) Gdk.X11.get_server_time(Gdk.get_default_root_window() as Gdk.X11.Window);
}

/**
Expand Down Expand Up @@ -207,6 +207,9 @@ namespace Budgie {

/* Get everything into position prior to the first showing */
on_monitors_changed();

/* Ensure filtering from the start */
window_box.invalidate_filter(); // Re-filter
}

private void add_window(libxfce4windowing.Window window) {
Expand All @@ -220,8 +223,6 @@ namespace Budgie {
if (get_position_in_recency(id) == -1) recency.append(id);
window_box.insert(window_widget, -1);

window_box.set_max_children_per_line(ids.size() < 8 ? ids.size() : 8);

window_widget.window_activated.connect(set_window_as_activated);

window_widget.closed.connect(remove_window);
Expand All @@ -233,7 +234,7 @@ namespace Budgie {
window_box.invalidate_filter(); // Re-filter
window_box.invalidate_sort(); // Re-sort

queue_resize();
update_sizing();
}

private bool flowbox_filter(FlowBoxChild box_child) {
Expand All @@ -255,6 +256,16 @@ namespace Budgie {
return pos1 < pos2 ? -1 : 1;
}

private uint get_visible_children() {
uint visible_children = 0;
foreach (var child in window_box.get_children()) {
var tab = child as TabSwitcherWidget;
if (show_all_windows || window_on_active_workspace(tab.window)) visible_children++;
}

return visible_children;
}

// get_position_in_recency will get the position in recency
// You might think "hey, but List has an index function, just use that!"
// No, because for whatever reason it fails at such a basic task
Expand Down Expand Up @@ -297,7 +308,9 @@ namespace Budgie {

private void on_workspace_changed() {
if (workspace_group != null) active_workspace = workspace_group.active_workspace;
update_show_all_windows();
}

public void move_switcher() {
/* Find the primary monitor bounds */
Gdk.Rectangle bounds = primary_monitor.get_geometry();
Expand All @@ -317,6 +330,7 @@ namespace Budgie {
window_box.remove(widget);
unowned List<string> entries = recency.find_custom(widget.id, strcmp);
recency.remove_link(entries);
update_sizing();
}

private void set_window_as_activated(libxfce4windowing.Window window) {
Expand All @@ -330,7 +344,16 @@ namespace Budgie {
private void update_show_all_windows() {
if (settings == null) return;
show_all_windows = settings.get_boolean(SHOW_ALL_WINDOWS_KEY);
window_box.invalidate_sort(); // Re-sort
window_box.invalidate_filter(); // Re-filter
update_sizing();
}

private void update_sizing() {
window_box.set_max_children_per_line(get_visible_children().clamp(1, 8));
window_box.queue_resize();
queue_resize();
move_switcher();
}

private bool window_on_active_workspace(libxfce4windowing.Window window) {
Expand Down
6 changes: 3 additions & 3 deletions src/panel/applets/workspaces/WindowIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Workspaces {
this.get_style_context().add_class("workspace-icon-button");
this.set_tooltip_text(window.get_name());

Gtk.Image icon = new Gtk.Image.from_pixbuf(window.get_icon(WORKSPACE_ICON_SIZE, get_scale_factor()));
Gtk.Image icon = new Gtk.Image.from_gicon(window.get_gicon(), Gtk.IconSize.INVALID);
icon.set_pixel_size(WORKSPACE_ICON_SIZE);
this.add(icon);
icon.show();
Expand All @@ -32,7 +32,7 @@ namespace Workspaces {
});

window.icon_changed.connect(() => {
icon.set_from_pixbuf(window.get_icon(WORKSPACE_ICON_SIZE, get_scale_factor()));
icon.set_from_gicon(window.get_gicon(), Gtk.IconSize.INVALID);
icon.queue_draw();
});

Expand All @@ -43,7 +43,7 @@ namespace Workspaces {
Gdk.DragAction.MOVE
);

Gtk.drag_source_set_icon_pixbuf(this, window.get_icon(WORKSPACE_ICON_SIZE, get_scale_factor()));
Gtk.drag_source_set_icon_gicon(this, window.get_gicon());

this.drag_begin.connect(on_drag_begin);
this.drag_end.connect(on_drag_end);
Expand Down

0 comments on commit 00ed13f

Please sign in to comment.