-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ratpoison: add 0010-Notification-on-urgency-flag.patch, relbump
- Loading branch information
Showing
3 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
From 809f81ba75cb8e0b134f9dacfb027c7a9ec6d292 Mon Sep 17 00:00:00 2001 | ||
From: Alexandr Savca <[email protected]> | ||
Date: Sun, 12 May 2024 18:46:35 +0300 | ||
Subject: [PATCH] Notification on urgency flag | ||
|
||
Slightly modified original patch by Eoin McLoughlin (see below). | ||
|
||
Original message: | ||
I was in IRC briefly last night enquiring about getting notifications | ||
for non-visible windows which want the user's attention (bells in | ||
xterms, message notifications in pidgin, that sort of thing) | ||
|
||
I've attached a simple patch which adds functionality for detecting when | ||
windows want attention, and displays a message showing the name and id | ||
of the window. This is done by means of sending an echo command (which, | ||
admittedly may not be the correct way to do this) to ratpoison. | ||
|
||
I'm finding it quite useful so far, as I've previously missed urgent | ||
windows due to a C-t Q or similar. | ||
|
||
Eoin McLoughlin. | ||
|
||
Reference: | ||
https://lists.nongnu.org/archive/html/ratpoison-devel/2009-11/msg00004.htm | ||
https://lists.nongnu.org/archive/html/ratpoison-devel/2009-11/msg00005.htm | ||
--- | ||
src/events.c | 14 ++++++++++++++ | ||
src/manage.c | 10 ++++++++++ | ||
src/manage.h | 1 + | ||
3 files changed, 25 insertions(+) | ||
|
||
diff --git a/src/events.c b/src/events.c | ||
index 4808d29..8031d3d 100644 | ||
--- a/src/events.c | ||
+++ b/src/events.c | ||
@@ -632,6 +632,20 @@ property_notify (XEvent *ev) | ||
win->transient = XGetTransientForHint (dpy, win->w, &win->transient_for); | ||
break; | ||
|
||
+ case XA_WM_HINTS: | ||
+ PRINT_DEBUG (("Additional hints\n")); | ||
+ | ||
+ if (has_urgency_flag (win)) | ||
+ { | ||
+ rp_group *g = groups_find_group_by_window (win); | ||
+ rp_window_elem *elem = group_find_window (&g->mapped_windows, win); | ||
+ char* commandStr = xsprintf ("echo Window %i (%s) in group %i wants attention", | ||
+ elem->number, win->wm_name, g->number); | ||
+ command (0, commandStr); | ||
+ free (commandStr); | ||
+ } | ||
+ break; | ||
+ | ||
default: | ||
PRINT_DEBUG (("Unhandled property notify event: %ld\n", ev->xproperty.atom)); | ||
break; | ||
diff --git a/src/manage.c b/src/manage.c | ||
index 78be591..9cc428f 100644 | ||
--- a/src/manage.c | ||
+++ b/src/manage.c | ||
@@ -173,6 +173,16 @@ update_normal_hints (rp_window *win) | ||
#endif | ||
} | ||
|
||
+/* Return non-zero if window hints have urgency flag set */ | ||
+int | ||
+has_urgency_flag (rp_window *win) | ||
+{ | ||
+ XWMHints *hints = XGetWMHints (dpy, win->w); | ||
+ int has_urgency = (hints->flags & XUrgencyHint) == XUrgencyHint; | ||
+ | ||
+ XFree (hints); | ||
+ return has_urgency; | ||
+} | ||
|
||
static char * | ||
get_wmname (Window w) | ||
diff --git a/src/manage.h b/src/manage.h | ||
index 8001e09..ed80179 100644 | ||
--- a/src/manage.h | ||
+++ b/src/manage.h | ||
@@ -32,6 +32,7 @@ void scanwins (void); | ||
void unmanage (rp_window *w); | ||
int update_window_name (rp_window *win); | ||
void update_normal_hints (rp_window *win); | ||
+int has_urgency_flag (rp_window *win); | ||
void rename_current_window (void); | ||
void set_state (rp_window *win, int state); | ||
long get_state (rp_window *win); | ||
-- | ||
2.45.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters