elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
9.3k stars 382 forks source link

[BUG] :onhover and :onhoverlost in eventbox are raced #822

Open Wallboy opened 1 year ago

Wallboy commented 1 year ago

Checklist before submitting an issue

Description of the bug

When you use the :onhover and :onhoverlost attributes in an eventbox where you call eww update var=value and you mouse over this event box really quick, which command that gets handled by the daemon first can be quite random.

Reproducing the issue

(defvar color "black")

(defwindow bug_hover
           :stacking "bg"
           :geometry (geometry :x "0px"
                               :y "0px"
                               :anchor "center")
           :windowtype "desktop"
           :wm-ignore false
     (eventbox :onhover "${EWW_CMD} update color=red" :onhoverlost "${EWW_CMD} update color=black"
        (box :width 200 :height 20 :style "background-color: ${color};")
     )
)

Mouse over this box really quickly up and down and you'll notice that sometimes the box stays red even after you mouse off of it.

If you look at the logs, the daemon sometimes actually processes the :onhoverlost event first before the :onhover event. So there is a race issue going on here.

Expected behaviour

You should always expect the :onhover event to be triggered before the :onhoverlost event.

Additional context

My best guess is this is because of how another eww process has to run just to update a variable, so there is no guarantee which "eww update var=value" wins the race to get their command first to the daemon.

A way to change variables internally without the need of a separate process call would likely alleviate this.

umi2002 commented 1 year ago

I have the same problem. Any news on how to fix this?

Adog64 commented 9 months ago

I have also had this issue. If I move my mouse too quickly over a widget, it is possible that it stays in the hovered state until I go back and slowly mouse over the widget.