diff --git a/src/wmclient.cc b/src/wmclient.cc index 11e188dc9..863cec82e 100644 --- a/src/wmclient.cc +++ b/src/wmclient.cc @@ -478,6 +478,14 @@ bool YFrameClient::handleTimer(YTimer* timer) { } } } + if (fUrgencyTimer == timer) { + fUrgencyTimer = null; + xsmart h(XGetWMHints(xapp->display(), handle())); + if (h && hasbit(h->flags, XUrgencyHint)) { + h->flags &= ~XUrgencyHint; + XSetWMHints(xapp->display(), handle(), h); + } + } return false; } @@ -660,19 +668,7 @@ void YFrameClient::handleProperty(const XPropertyEvent &property) { case XA_WM_HINTS: if (new_prop) prop.wm_hints = true; - { - Drawable oldPix = iconPixmapHint(); - Drawable oldMask = iconMaskHint(); - bool oldUrge = urgencyHint(); - getWMHints(); - if (oldPix != iconPixmapHint() || oldMask != iconMaskHint()) { - refreshIcon(); - } - if (oldUrge != urgencyHint()) { - if (getFrame()) - getFrame()->setWmUrgency(urgencyHint()); - } - } + updateWMHints(); prop.wm_hints = new_prop; break; @@ -1284,14 +1280,30 @@ Pixmap YFrameClient::iconMaskHint() const { return wmHint(IconMaskHint) ? fHints->icon_mask : None; } +void YFrameClient::updateWMHints() { + Drawable oldPix = iconPixmapHint(); + Drawable oldMask = iconMaskHint(); + bool oldUrgency = urgencyHint(); + getWMHints(); + if (oldPix != iconPixmapHint() || oldMask != iconMaskHint()) { + refreshIcon(); + } + if (fUrgencyTimer) { + if (urgencyHint() == false) + fUrgencyTimer = null; + else if (getFrame() && getFrame()->focused()) + fHints->flags &= ~XUrgencyHint; + } + if (oldUrgency != urgencyHint()) { + if (getFrame()) + getFrame()->setWmUrgency(urgencyHint()); + } +} + void YFrameClient::clearUrgency() { if (urgencyHint()) { fHints->flags &= ~XUrgencyHint; - xsmart h(XGetWMHints(xapp->display(), handle())); - if (h && hasbit(h->flags, XUrgencyHint)) { - h->flags &= ~XUrgencyHint; - XSetWMHints(xapp->display(), handle(), h); - } + fUrgencyTimer->setTimer(500L, this, true); } } diff --git a/src/wmclient.h b/src/wmclient.h index 1cecdf20d..8de58fba9 100644 --- a/src/wmclient.h +++ b/src/wmclient.h @@ -213,6 +213,7 @@ class YFrameClient: public YDndWindow void setFrameState(FrameState state); void getWMHints(); + void updateWMHints(); XWMHints *hints() const { return fHints; } bool wmHint(int flag) const { return fHints && (fHints->flags & flag); } Window windowGroupHint() const; @@ -348,6 +349,7 @@ class YFrameClient: public YDndWindow long fPingTime; long fPid; lazy fPingTimer; + lazy fUrgencyTimer; ref fIcon; mstring fWindowTitle;