summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-04-30 08:53:47 +0200
committerDanny Baumann <dannybaumann@web.de>2008-04-30 08:53:47 +0200
commit67e525e2c69a738801c412e10e4944d623d6c5de (patch)
treea31aedb92d370e1367efdb8ff0f836d154b4241b
parenta113f9953ef3c8daf9401d76d6fff55c1ed50422 (diff)
downloadextrawm-67e525e2c69a738801c412e10e4944d623d6c5de.tar.gz
extrawm-67e525e2c69a738801c412e10e4944d623d6c5de.tar.bz2
Also handle urgency hint.
-rw-r--r--extrawm.c68
1 files changed, 61 insertions, 7 deletions
diff --git a/extrawm.c b/extrawm.c
index 6b214b2..52564d7 100644
--- a/extrawm.c
+++ b/extrawm.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <X11/Xatom.h>
#include <compiz-core.h>
#include "extrawm_options.h"
@@ -34,6 +35,8 @@ typedef struct _DemandsAttentionWindow {
typedef struct _ExtraWMDisplay {
int screenPrivateIndex;
+
+ HandleEventProc handleEvent;
} ExtraWMDisplay;
typedef struct _ExtraWMScreen {
@@ -52,6 +55,11 @@ addAttentionWindow (CompWindow *w)
EXTRAWM_SCREEN (w->screen);
+ /* check if the window is already there */
+ for (dw = es->attentionWindows; dw; dw = dw->next)
+ if (dw->w == w)
+ return;
+
dw = malloc (sizeof (DemandsAttentionWindow));
if (!dw)
return;
@@ -85,6 +93,27 @@ removeAttentionWindow (CompWindow *w)
}
}
+static void
+updateAttentionWindow (CompWindow *w)
+{
+ XWMHints *hints;
+ Bool urgent = FALSE;
+
+ hints = XGetWMHints (w->screen->display->display, w->id);
+ if (hints)
+ {
+ if (hints->flags & XUrgencyHint)
+ urgent = TRUE;
+
+ XFree (hints);
+ }
+
+ if (urgent || (w->state & CompWindowStateDemandsAttentionMask))
+ addAttentionWindow (w);
+ else
+ removeAttentionWindow (w);
+}
+
static Bool
activateDemandsAttention (CompDisplay *d,
CompAction *action,
@@ -132,7 +161,7 @@ activateWin (CompDisplay *d,
return TRUE;
}
-static void
+static void
fullscreenWindow (CompWindow *w,
int state)
{
@@ -246,6 +275,32 @@ toggleSticky (CompDisplay *d,
}
static void
+extraWMHandleEvent (CompDisplay *d,
+ XEvent *event)
+{
+ EXTRAWM_DISPLAY (d);
+
+ UNWRAP (ed, d, handleEvent);
+ (*d->handleEvent) (d, event);
+ WRAP (ed, d, handleEvent, extraWMHandleEvent);
+
+ switch (event->type) {
+ case PropertyNotify:
+ if (event->xproperty.atom == XA_WM_HINTS)
+ {
+ CompWindow *w;
+
+ w = findWindowAtDisplay (d, event->xproperty.window);
+ if (w)
+ updateAttentionWindow (w);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void
extraWMWindowStateChangeNotify (CompWindow *w,
unsigned int lastState)
{
@@ -258,12 +313,7 @@ extraWMWindowStateChangeNotify (CompWindow *w,
WRAP (es, s, windowStateChangeNotify, extraWMWindowStateChangeNotify);
if ((w->state ^ lastState) & CompWindowStateDemandsAttentionMask)
- {
- if (w->state & CompWindowStateDemandsAttentionMask)
- addAttentionWindow (w);
- else
- removeAttentionWindow (w);
- }
+ updateAttentionWindow (w);
}
static Bool
@@ -309,6 +359,8 @@ extraWMInitDisplay (CompPlugin *p,
extrawmSetActivateInitiate (d, activateWin);
extrawmSetActivateDemandsAttentionInitiate (d, activateDemandsAttention);
+ WRAP (ed, d, handleEvent, extraWMHandleEvent);
+
d->base.privates[ExtraWMDisplayPrivateIndex].ptr = ed;
return TRUE;
@@ -322,6 +374,8 @@ extraWMFiniDisplay (CompPlugin *p,
freeScreenPrivateIndex (d, ed->screenPrivateIndex);
+ UNWRAP (ed, d, handleEvent);
+
free (ed);
}