Set urgency hint for new mail / activity changes #96

Closed
jotrk opened this Issue Jul 20, 2013 · 11 comments

Projects

None yet

2 participants

@jotrk
jotrk commented Jul 20, 2013

Hello,

it would be great if FireTray could set the Urgency Hint bit (http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.4) when new mail arrives or on other activity.
In gtk.jsm the gtk_window_set_urgency_hint() is already bound, but I couldn't figure which callback is used for activity changes.
There's updateMsgCountWithCb() but I lost track after that.
Please add this feature, it would be very useful.

@foudfou
Owner
foudfou commented Jul 20, 2013

Hi, I think this is already implemented in v0.4.6 (see 3aca4f6). v0.4.6 is available on addons.mozilla.org. Please confirm it works for you.

@jotrk
jotrk commented Jul 20, 2013

Hi,

I've tried it several times now and I'm quite sure that the Urgency bit is not set when new mail arrives. I peeked at the commit and got the impression that the Urgency bit is only set for chat windows.

@jotrk
jotrk commented Jul 20, 2013

From your given commit I figured the missing bits out. I'm not sure if this is the right place (you probably want FiretrayMessaging to be abstract w/o linux/gtk specific stuff in there).
However, this works for me. If you could add such feature in a future version I'd be very happy. Thanks you! :)

diff --git a/src/modules/FiretrayMessaging.jsm b/src/modules/FiretrayMessaging.jsm
index 05780f8..f8d6c89 100644
--- a/src/modules/FiretrayMessaging.jsm
+++ b/src/modules/FiretrayMessaging.jsm
@@ -10,6 +10,7 @@ Cu.import("resource:///modules/mailServices.js");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/PluralForm.jsm");
 Cu.import("resource://firetray/commons.js");
+Cu.import("resource://firetray/ctypes/linux/gtk.jsm");

 const FLDRS_UNINTERESTING = {
   Archive:   Ci.nsMsgFolderFlags.Archive,
@@ -209,8 +210,17 @@ firetray.Messaging = {
       firetray.Handler.setIconImageDefault();
       firetray.Handler.setIconTooltipDefault();

+      for (let xid in firetray.Handler.windows) {
+        gtk.gtk_window_set_urgency_hint(firetray.Handler.gtkWindows.get(xid), false);
+      }
+
     } else if (msgCount > 0) {
       let prefMailNotification = firetray.Utils.prefService.getIntPref('mail_notification_type');
+
+      for (let xid in firetray.Handler.windows) {
+        gtk.gtk_window_set_urgency_hint(firetray.Handler.gtkWindows.get(xid), true);
+      }
+
       switch (prefMailNotification) {
       case FIRETRAY_NOTIFICATION_MESSAGE_COUNT:
         let prefIconTextColor = firetray.Utils.prefService.getCharPref("icon_text_color");
@foudfou
Owner
foudfou commented Jul 21, 2013

Oh you're right: it's implemented for chat notifications. I'll implement it for mail notification when I get a chance.

@foudfou
Owner
foudfou commented Jul 22, 2013

Can you give a try at the urgency branch (419ac2d) ?

@jotrk
jotrk commented Jul 22, 2013

I tried it out by sending several emails from/to various accounts but results were unreliable at best. I got the urgency hint once, but wasn't able to reproduce it. I'm sorry to say that most of the time it didn't work.
[Edit] Alright, it seems that it works once after starting TBird. After that it's missing [/Edit]

@foudfou
Owner
foudfou commented Jul 22, 2013

Ok so I need to know about your env to reproduce the problem. If you can build a VM that would make things easier.

@foudfou
Owner
foudfou commented Jul 22, 2013

I could reproduce the problem with openbox. I need to rely on the focus-in event instead of MapNotify...

@jotrk
jotrk commented Jul 23, 2013

Hi, glad you figured that one out. Afaik, urxvt resets the urgency hint on the focus-in event too.
There are some window managers which use a virtual root for virtual desktops, i.e. reparent the windows to a virtual root, whereas others map/unmap windows.
For the wms implementing virtual roots mapnotify is not a reliable event then. :)

@foudfou
Owner
foudfou commented Jul 23, 2013

Hi, can you try 6615219 ? Tested with fluxbox, openbox and i3.

@jotrk
jotrk commented Jul 23, 2013

Works perfect! You're awesome! Thank you very much. :)

@foudfou foudfou closed this Jul 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment