Description
Describe the issue
I'm using i3wm with polybar.
When I work at workspace 3, open an app, like Firefox,
Firefox has an i3 config: for_window move container to workspace 2
So firefox should run in workspace 2, and i3 still work at workspace 3.
The problem is : xworkspaces module will highlight workspace 2 as active.
Expected behavior:
xworkspaces should still highlight at workspace 3, which is the really activating workspace.
To Reproduce
Go workspace 3
Open Firefox with i3config for_window [class="Firefox"] move container to workspace 2
Environment:
- WM: i3 i3 version 4.11 (2015-09-30, branch "4.11") © 2009 Michael Stapelberg and contributors
- Distro: ubuntu 16.04
- Output of
polybar -vvv
:
polybar 3.3.0-44-g82b9ea8
Features: +alsa +curl +i3 +mpd +network(libnl) +pulseaudio +xkeyboard
Additional context
I found the problem in xworkspaces module code:
In function rebuild_desktop_states,
if (d->index == m_current_desktop)
this line used to check whether this desktop is actived.
This is the problem:
When I have workspace [1,3], active at workspace 3, m_desktop_names will be : ['1','3'] and m_current_desktop == 1.
Then I launch a app in workspace 2, but still stay in workspace 3. m_desktop_names will be updated to ['1','2','3'] by get_desktop_names, BUT m_current_desktop still be 1.
So, xworkspaces think workspace 2 is the active one.
I add a string variable m_desktop_current_name, recording the current dekstop name.
Then use
if (m_desktop_current_name == m_desktop_names[m_current_desktop])
to check active workspace,
The problem fixed.