mihirlad55 / polybar-dwm-module

A dwm module for polybar
MIT License
116 stars 15 forks source link

Toggling tag when only one is available doesn't take effect until focus changes #7

Closed mihirlad55 closed 4 years ago

mihirlad55 commented 4 years ago

Right-clicking the only tag in view to toggle it out of view doesn't take effect until the cursor hovers over a client. This might have something to do with the toggleview command not rearranging the view.

mihirlad55 commented 4 years ago

This was caused by a conflict between the emptyview patch and pertag patch. The pertag patch overrode the emptyview patch causing the focus and arrange functions to not be called if the toggleview function results in no tags selected. The reason this was working fine with key bindings is the buttonpress function in dwm calls focus and arrange regardless.

mihirlad55 commented 4 years ago

For future reference, see https://github.com/mihirlad55/dwm/commit/e2650a679bed382ef921234bc67aac91c68c87f6

mihirlad55 commented 4 years ago

That was actually not the main issue. The main issue was the XMoveWindow function call that is supposed to take place in showhide would not be flushed to the XServer. Normally this wouldn't be a problem because an XEvent would being received would trigger a flush or XSync would be called from restack which would manually flush the events. However, if no client is selected, the restack function returns before XSync is called. This would result in the client still being visible since the XMoveEvent was not being flushed to the server until another XEvent took place that causes the queue to be flushed.

There are several solutions to this problem:

  1. XSync after all IPC commands - This makes the IPC patch responsible for this bug
  2. XSync even in restack even if no clients are selected - This makes the emptyview patch responsible for this bug
  3. Receive motionnotify events from external bars managed using the anybar patch - this isn't a direct solution, but it should solve the problem

I believe, this is mainly an issue of an unforeseen edge case. Though, an empty view is not something dwm was necessarily designed to allow by default. I think this would be best classified as an unforeseen edge case of the emptyview patch, since the restack function would otherwise never need to XSync if no clients are selected unless there was an empty view.

mihirlad55 commented 4 years ago

See https://github.com/mihirlad55/dwm/commit/ea047a44e6dde9fc7712b45fb7f6d9d74d82f976