1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/modules
Matthias Viehweger 52f0623315 feat(xworkspaces): Support occupied workspaces (#882)
A workspace is occupied if it is not active and there is at least one window managed by the WM (`_NET_CLIENT_LIST`) that has set `_NET_WM_DESKTOP` to that workspace.

The behavior when `_NET_WM_DESKTOP` is not set is not yet clear but this is unlikely to happen since most WMs will position windows on some desktop.

Closes #874
Fixes #1444
Fixes #1033 

* Set Desktop OCCUPIED if a window moves there

This covers more of an edge-case. I did this first by accident, it might
vanish later on.

* Replace tracking change of WS with currently used WS

* Untrack occupied workspaces

* Track windows and their desktops in pairs

* Match type of occupied_desktops with current_desktop

Because the index needs to be matched later on, type mismatches would be non-ideal.

* Recreate the occupied desktops everytime and remove duplicates

* Readd support for moving windows to other desktops

* Use less characters to empty the vector

* Rename variable storing the desktops

* Recount windows on every occasion

This alone simplifies the management and the lookup for occupation of a
workspace

* Keep track of number of windows in every workspace

* Add debugging output that shall be removed before merging

* Remove obsolete TODO

* m_client_list should always be diff'd, since the desktop may change

Therefore we update the desktop-count tally every time the client_list
changes. It may just be a desktop-change without a change of
clients.size()...

* Add more logging-spam to understand window/desktop lifecycle

* Lock event-handler to serialize handling of events

* Fix occupied workspace counting and change to bool array

Also, performance improvements when diffing new and old client lists

* Fix crash when all clients are removed

* Conform to linter and styleguide

* Shorten conditional as it is standard enough

Since this only guards against 0-divisions, it can be shortened
without risking too much confusion down the road.

* Guard against multiple threads accessing and modifying data

Fixes #1444

Modification of internal data happens through the handle-method, while
the build-method tries to access the data structures for display. Since
some modifications clear e.g. the m_viewports, references may become
invalid between looping over them an accessing them.

The mutex should guard against this simultanuous access.

* Do not 'adopt_lock', because calls come from very different threads

To my understanding, adopt_lock has some dependency on the mutex-ownership. Since
the lock is once called from the inside (in handle) and once from the outside (in
build), there might be a problem. After brief testing, the segfaults happened fewer
times.

See #1444

* Also listen to _NET_WM_DESKTOP

In order to move a window from one desktop to another, it is sufficient
to set the desktop-property of that window. xmonad fires a lot of events
in the case of moving a window, herbstluftwm only updates the
_NET_WM_DESKTOP-atom of the window.

This change reloads the clientlist in order to correctly set the
desktop state "occupied".

* Describe need and use of mutex

It might be possible to relieve the guard in xworkspaces_module::handle,
but I am unsure about this. Since xmonad emits a lot of events on almost
every minor change, I would let the guard keep its post, avoiding
race-conditions in event-handling.

* Give temporary variables better names

* Clarify purpose of loop

About 80% of this comment are taken from
https://github.com/jaagr/polybar/pull/882#discussion_r255317363

* Remove merge-remainder

* Use a simpler method to list occupied desktops.

Co-authored-by: Jérôme Boulmier <jerome.boulmier@outlook.fr>

* Document m_clients field
2019-10-21 10:00:38 +02:00
..
meta fix(modules): Only add reset tag on non-empty modules 2019-08-22 22:42:30 +02:00
alsa.hpp feat(alsa): add volume interval option 2018-08-07 11:52:38 +02:00
backlight.hpp refactor: Cleanup 2017-01-11 03:07:28 +01:00
battery.hpp feat(battery): add %percentage_raw% token (#1756) 2019-05-14 15:01:54 +02:00
bspwm.hpp feat(bspwm): Support marked flag for focused nodes 2019-01-08 17:14:39 +01:00
counter.hpp refactor(modules): Move setup to constructor 2016-12-21 08:00:09 +01:00
cpu.hpp feat(cpu): Add ramp-coreload-spacing (#1472) 2018-10-16 01:11:05 +02:00
date.hpp doc: Convert @ to \ doxygen commands 2018-11-04 19:28:27 -08:00
fs.hpp fix(fs): Calculate free bytes properly 2019-01-17 08:31:48 +01:00
github.hpp feat(github): add support for github enterprise (#1841) 2019-08-04 20:58:25 +02:00
i3.hpp fix(i3): Surround ws names with quotes (#1798) 2019-06-04 23:34:16 +02:00
ipc.hpp refactor(ipc): Cleanup 2017-01-14 00:27:29 +01:00
memory.hpp feat(mem): Add ramp and bar for swap (#1325) 2018-09-14 20:42:04 +02:00
menu.hpp feat(menu): Add expand-right option (#658) 2017-08-29 13:25:41 -07:00
mpd.hpp refactor(mpd): Replace icon-repeatone with icon-single 2018-06-23 10:14:30 +02:00
network.hpp feat(net): Add unknown-as-up option 2018-03-04 23:09:18 +01:00
pulseaudio.hpp feat(pulse): Show volume in decibels (#1894) 2019-10-09 02:13:57 +02:00
script.hpp feat(script): Add %pid% token for tail commands 2018-01-21 14:41:52 -08:00
systray.hpp wip(systray): Add module base 2017-01-01 21:28:28 +01:00
temperature.hpp feat(temp): Configurable lower bound for ramp (#1706) 2019-04-07 18:36:09 +02:00
text.hpp refactor(clang-tidy): Apply fixes 2016-12-23 15:54:06 +01:00
unsupported.hpp refactor(alsa): rename and move volume -> alsa 2018-01-23 14:33:11 +01:00
xbacklight.hpp typo: replace 'alot' with 'a lot' (#1634) 2019-01-29 17:54:38 +01:00
xkeyboard.hpp feat(xkeyboard): Customizable indicators and layouts (#1559) 2019-02-24 22:35:39 +01:00
xwindow.hpp feat(xwindow): Add label-empty 2018-04-02 00:00:16 +02:00
xworkspaces.hpp feat(xworkspaces): Support occupied workspaces (#882) 2019-10-21 10:00:38 +02:00