Skip to content

Commit

Permalink
Delay clearing the urgency flag in the client for half a second.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed May 17, 2024
1 parent ebb8358 commit ca61a8f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/wmclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,14 @@ bool YFrameClient::handleTimer(YTimer* timer) {
}
}
}
if (fUrgencyTimer == timer) {
fUrgencyTimer = null;
xsmart<XWMHints> h(XGetWMHints(xapp->display(), handle()));
if (h && hasbit(h->flags, XUrgencyHint)) {
h->flags &= ~XUrgencyHint;
XSetWMHints(xapp->display(), handle(), h);
}
}

return false;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<XWMHints> h(XGetWMHints(xapp->display(), handle()));
if (h && hasbit(h->flags, XUrgencyHint)) {
h->flags &= ~XUrgencyHint;
XSetWMHints(xapp->display(), handle(), h);
}
fUrgencyTimer->setTimer(500L, this, true);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/wmclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -348,6 +349,7 @@ class YFrameClient: public YDndWindow
long fPingTime;
long fPid;
lazy<YTimer> fPingTimer;
lazy<YTimer> fUrgencyTimer;
ref<YIcon> fIcon;

mstring fWindowTitle;
Expand Down

0 comments on commit ca61a8f

Please sign in to comment.