about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-12-13 15:56:44 +0000
committerokan <okan>2013-12-13 15:56:44 +0000
commitddb67559f63d6187921a0796f43d4c8cae6707a9 (patch)
tree439f3b2ab8b8cd26df7750788dadcf56c61c737e
parent0cad4ef6e01dd4154816dde10b753ffef3c2e44b (diff)
parent91a29396e84b49fcb942bbe476ad43e727b6cbc3 (diff)
downloadcwm-ddb67559f63d6187921a0796f43d4c8cae6707a9.tar.gz
cwm-ddb67559f63d6187921a0796f43d4c8cae6707a9.tar.xz
cwm-ddb67559f63d6187921a0796f43d4c8cae6707a9.zip
cvsimport
-rw-r--r--calmwm.h6
-rw-r--r--client.c15
-rw-r--r--conf.c2
-rw-r--r--cwmrc.55
-rw-r--r--parse.y7
-rw-r--r--xevents.c8
-rw-r--r--xutil.c10
7 files changed, 45 insertions, 8 deletions
diff --git a/calmwm.h b/calmwm.h
index f2294a9..94aea5d 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -109,6 +109,7 @@ enum cursor_font {
 enum color {
 	CWM_COLOR_BORDER_ACTIVE,
 	CWM_COLOR_BORDER_INACTIVE,
+	CWM_COLOR_BORDER_URGENCY,
 	CWM_COLOR_BORDER_GROUP,
 	CWM_COLOR_BORDER_UNGROUP,
 	CWM_COLOR_MENU_FG,
@@ -174,6 +175,7 @@ struct client_ctx {
 #define CLIENT_INPUT			0x0080
 #define CLIENT_WM_DELETE_WINDOW		0x0100
 #define CLIENT_WM_TAKE_FOCUS		0x0200
+#define CLIENT_URGENCY			0x0400
 
 #define CLIENT_HIGHLIGHT		(CLIENT_GROUP | CLIENT_UNGROUP)
 #define CLIENT_MAXFLAGS			(CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
@@ -362,9 +364,10 @@ enum {
 	_NET_WM_DESKTOP,
 	_NET_CLOSE_WINDOW,
 	_NET_WM_STATE,
-#define	_NET_WM_STATES_NITEMS	2
+#define	_NET_WM_STATES_NITEMS	3
 	_NET_WM_STATE_MAXIMIZED_VERT,
 	_NET_WM_STATE_MAXIMIZED_HORZ,
+	_NET_WM_STATE_DEMANDS_ATTENTION,
 	EWMH_NITEMS
 };
 enum {
@@ -408,6 +411,7 @@ void			 client_setname(struct client_ctx *);
 int			 client_snapcalc(int, int, int, int, int);
 void			 client_transient(struct client_ctx *);
 void			 client_unhide(struct client_ctx *);
+void			 client_urgency(struct client_ctx *);
 void			 client_vmaximize(struct client_ctx *);
 void 			 client_vtile(struct client_ctx *);
 void			 client_warp(struct client_ctx *);
diff --git a/client.c b/client.c
index 5b59fd2..a2b6322 100644
--- a/client.c
+++ b/client.c
@@ -103,6 +103,8 @@ client_init(Window win, struct screen_ctx *sc, int mapped)
 	XSelectInput(X_Dpy, cc->win, ColormapChangeMask | EnterWindowMask |
 	    PropertyChangeMask | KeyReleaseMask);
 
+	XAddToSaveSet(X_Dpy, cc->win);
+
 	client_transient(cc);
 
 	/* Notify client of its configuration. */
@@ -192,6 +194,7 @@ client_setactive(struct client_ctx *cc)
 
 	_curcc = cc;
 	cc->active = 1;
+	cc->flags &= ~CLIENT_URGENCY;
 	client_draw_border(cc);
 	conf_grab_mouse(cc->win);
 	xu_ewmh_net_active_window(sc, cc->win);
@@ -462,6 +465,12 @@ client_unhide(struct client_ctx *cc)
 }
 
 void
+client_urgency(struct client_ctx *cc)
+{
+	cc->flags |= CLIENT_URGENCY;
+}
+
+void
 client_draw_border(struct client_ctx *cc)
 {
 	struct screen_ctx	*sc = cc->sc;
@@ -482,6 +491,9 @@ client_draw_border(struct client_ctx *cc)
 	else
 		pixel = sc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel;
 
+	if (cc->flags & CLIENT_URGENCY)
+		pixel = sc->xftcolor[CWM_COLOR_BORDER_URGENCY].pixel;
+
 	XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth);
 	XSetWindowBorder(X_Dpy, cc->win, pixel);
 }
@@ -511,6 +523,9 @@ client_wm_hints(struct client_ctx *cc)
 
 	if ((cc->wmh->flags & InputHint) && (cc->wmh->input))
 		cc->flags |= CLIENT_INPUT;
+
+	if ((cc->wmh->flags & XUrgencyHint))
+		client_urgency(cc);
 }
 
 void
diff --git a/conf.c b/conf.c
index 5eadfaf..019d4fd 100644
--- a/conf.c
+++ b/conf.c
@@ -88,6 +88,7 @@ conf_ignore(struct conf *c, char *val)
 static char *color_binds[] = {
 	"#CCCCCC",	/* CWM_COLOR_BORDER_ACTIVE */
 	"#666666",	/* CWM_COLOR_BORDER_INACTIVE */
+	"#FC8814",	/* CWM_COLOR_BORDER_URGENCY */
 	"blue",		/* CWM_COLOR_BORDER_GROUP */
 	"red",		/* CWM_COLOR_BORDER_UNGROUP */
 	"black",	/* CWM_COLOR_MENU_FG */
@@ -687,6 +688,7 @@ static char *ewmhints[] = {
 	"_NET_WM_STATE",
 	"_NET_WM_STATE_MAXIMIZED_VERT",
 	"_NET_WM_STATE_MAXIMIZED_HORZ",
+	"_NET_WM_STATE_DEMANDS_ATTENTION",
 };
 
 void
diff --git a/cwmrc.5 b/cwmrc.5
index 2d00e73..3c3fc25 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -14,7 +14,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: July 8 2013 $
+.Dd $Mdocdate: November 27 2013 $
 .Dt CWMRC 5
 .Os
 .Sh NAME
@@ -125,6 +125,9 @@ Set menu background color.
 .It Ic color menufg Ar color
 Set menu foreground color.
 .Pp
+.It Ic color urgencyborder Ar color
+Set the color of the border of a window indicating urgency.
+.Pp
 .It Ic color ungroupborder Ar color
 Set the color of the border while ungrouping a window.
 .Pp
diff --git a/parse.y b/parse.y
index 0178092..c7a802a 100644
--- a/parse.y
+++ b/parse.y
@@ -72,7 +72,7 @@ typedef struct {
 %token	AUTOGROUP BIND COMMAND IGNORE
 %token	YES NO BORDERWIDTH MOVEAMOUNT
 %token	COLOR SNAPDIST
-%token	ACTIVEBORDER INACTIVEBORDER
+%token	ACTIVEBORDER INACTIVEBORDER URGENCYBORDER
 %token	GROUPBORDER UNGROUPBORDER
 %token	MENUBG MENUFG
 %token	FONTCOLOR FONTSELCOLOR
@@ -195,6 +195,10 @@ colors		: ACTIVEBORDER STRING {
 			free(conf->color[CWM_COLOR_BORDER_INACTIVE]);
 			conf->color[CWM_COLOR_BORDER_INACTIVE] = $2;
 		}
+		| URGENCYBORDER STRING {
+			free(conf->color[CWM_COLOR_BORDER_URGENCY]);
+			conf->color[CWM_COLOR_BORDER_URGENCY] = $2;
+		}
 		| GROUPBORDER STRING {
 			free(conf->color[CWM_COLOR_BORDER_GROUP]);
 			conf->color[CWM_COLOR_BORDER_GROUP] = $2;
@@ -273,6 +277,7 @@ lookup(char *s)
 		{ "snapdist",		SNAPDIST},
 		{ "sticky",		STICKY},
 		{ "ungroupborder",	UNGROUPBORDER},
+		{ "urgencyborder",	URGENCYBORDER},
 		{ "yes",		YES}
 	};
 	const struct keywords	*p;
diff --git a/xevents.c b/xevents.c
index e7eca18..b1d4c64 100644
--- a/xevents.c
+++ b/xevents.c
@@ -47,15 +47,15 @@ static void	 xev_handle_buttonpress(XEvent *);
 static void	 xev_handle_buttonrelease(XEvent *);
 static void	 xev_handle_keypress(XEvent *);
 static void	 xev_handle_keyrelease(XEvent *);
-static void	 xev_handle_expose(XEvent *);
 static void	 xev_handle_clientmessage(XEvent *);
 static void	 xev_handle_randr(XEvent *);
 static void	 xev_handle_mappingnotify(XEvent *);
-
+static void	 xev_handle_expose(XEvent *);
 
 void		(*xev_handlers[LASTEvent])(XEvent *) = {
 			[MapRequest] = xev_handle_maprequest,
 			[UnmapNotify] = xev_handle_unmapnotify,
+			[DestroyNotify] = xev_handle_destroynotify,
 			[ConfigureRequest] = xev_handle_configurerequest,
 			[PropertyNotify] = xev_handle_propertynotify,
 			[EnterNotify] = xev_handle_enternotify,
@@ -63,10 +63,9 @@ void		(*xev_handlers[LASTEvent])(XEvent *) = {
 			[ButtonRelease] = xev_handle_buttonrelease,
 			[KeyPress] = xev_handle_keypress,
 			[KeyRelease] = xev_handle_keyrelease,
-			[Expose] = xev_handle_expose,
-			[DestroyNotify] = xev_handle_destroynotify,
 			[ClientMessage] = xev_handle_clientmessage,
 			[MappingNotify] = xev_handle_mappingnotify,
+			[Expose] = xev_handle_expose,
 };
 
 static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R,
@@ -188,6 +187,7 @@ xev_handle_propertynotify(XEvent *ee)
 			break;
 		case XA_WM_HINTS:
 			client_wm_hints(cc);
+			client_draw_border(cc);
 			break;
 		case XA_WM_TRANSIENT_FOR:
 			client_transient(cc);
diff --git a/xutil.c b/xutil.c
index d14a981..de7e321 100644
--- a/xutil.c
+++ b/xutil.c
@@ -333,6 +333,9 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action,
 		{ _NET_WM_STATE_MAXIMIZED_HORZ,
 			CLIENT_HMAXIMIZED,
 			client_hmaximize },
+		{ _NET_WM_STATE_DEMANDS_ATTENTION,
+			CLIENT_URGENCY,
+			client_urgency },
 	};
 
 	for (i = 0; i < nitems(handlers); i++) {
@@ -366,6 +369,8 @@ xu_ewmh_restore_net_wm_state(struct client_ctx *cc)
 			client_hmaximize(cc);
 		if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
 			client_vmaximize(cc);
+		if (atoms[i] == ewmh[_NET_WM_STATE_DEMANDS_ATTENTION])
+			client_urgency(cc);
 	}
 	free(atoms);
 }
@@ -380,7 +385,8 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
 	atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom));
 	for (i = j = 0; i < n; i++) {
 		if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&
-		    oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
+		    oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT] &&
+		    oatoms[i] != ewmh[_NET_WM_STATE_DEMANDS_ATTENTION])
 			atoms[j++] = oatoms[i];
 	}
 	free(oatoms);
@@ -388,6 +394,8 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
 		atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ];
 	if (cc->flags & CLIENT_VMAXIMIZED)
 		atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_VERT];
+	if (cc->flags & CLIENT_URGENCY)
+		atoms[j++] = ewmh[_NET_WM_STATE_DEMANDS_ATTENTION];
 	if (j > 0)
 		XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE],
 		    XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, j);