Skip to content

Tab bars rendering sometimes oscillates after switching workspace #246

@LirionTen

Description

@LirionTen

Description:

After dispatch workspace , if both source and origin workspaces contains tabbed layoutts, the tab bar from WS1 is rendered, then immediately replace by the tab bar from WS2, and back again. This produces a very noticeable flicker.

Look like the oscillation rate depends on the redraw rate of wayland. Slow when nothing is going on, faster if there's a video playing, etc'.

Reproducible:
100% here.

Repro:
hyprland.conf: input:follow_mouse = 0

Setup tabbed layouts on two workspaces, say 1 and 2.
Switch to 2, then back to 1 again and this happens.

It only seems to happen if no focus event, such as clicking a window, happens after switching to 2 and before switching back to 1. If you click a windows afetr switching then switch back, it doesn't trigger.

Workaround:
use a shell script for switching, and add a hyprctl dispatch hy3:changefocus bottom at the end to force a focus event after switching. Nothing special about bottom, it just causes the least visual jank.

Here's the script I use, which also replicates sway's "back-and-forth" feature.

hypr_switch_workspace.sh

#!/bin/bash

# Define the workspace name from the script's argument
TARGET_WORKSPACE=$1

# Use hyprctl to get the active workspace name
ACTIVE_WORKSPACE=$(hyprctl activeworkspace -j | jq -r '.name')

# Check if the requested workspace is already active
# for comparison , strip optional "name:" prefix
if [ "${TARGET_WORKSPACE##name:}" == "$ACTIVE_WORKSPACE" ]; then
  # If it is, switch to the previous workspace
  hyprctl dispatch workspace previous
else
  # Otherwise, switch to the requested workspace
  hyprctl dispatch workspace "$TARGET_WORKSPACE"
fi

# workaround flicker when changing workspace
hyprctl dispatch hy3:changefocus bottom

and

bind = $mod, 1, exec, ~/.config/hypr/scripts/hypr_switch_workspace.sh 1

etc'

The workaround does not work when moving to an empty workspace, since there is nothing there to generate a focus event with.
Another corner case is when switching to a workspace a moment before a notification appears, where the same flashing tab bar phenomena can sometimes still trigger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions