diff --git a/src/client.c b/src/client.c
index 8d45696351167bab4ed455bf726fa63e562b30e3..b6552ad6738b2fccda7a463535cf5ed363d09e5a 100644
--- a/src/client.c
+++ b/src/client.c
@@ -3865,7 +3865,7 @@ clientButtonPress (Client *c, Window w, XfwmEventButton *event)
     frameQueueDraw (c, FALSE);
 
     TRACE ("entering button press loop");
-    eventFilterPush (display_info->xfilter, clientButtonPressEventFilter, &passdata);
+    eventFilterPushGrab (display_info->xfilter, clientButtonPressEventFilter, w, &passdata);
     gtk_main ();
     eventFilterPop (display_info->xfilter);
     TRACE ("leaving button press loop");
diff --git a/src/event_filter.c b/src/event_filter.c
index 920ede598dc99ac9d5347ad200be93fa8e8dae23..313c434457893e16ddd441b6c678a18e7fda242c 100644
--- a/src/event_filter.c
+++ b/src/event_filter.c
@@ -172,7 +172,10 @@ eventXfwmFilter (GdkXEvent *gdk_xevent, GdkEvent *gevent, gpointer data)
     while ((filterelt) && (loop == EVENT_FILTER_CONTINUE))
     {
         eventFilterStack *filterelt_next = filterelt->next;
-        loop = (*filterelt->filter) (event, filterelt->data);
+        if (filterelt->window == None || filterelt->window == event->meta.window)
+        {
+            loop = (*filterelt->filter) (event, filterelt->data);
+        }
         filterelt = filterelt_next;
     }
 
@@ -182,6 +185,12 @@ eventXfwmFilter (GdkXEvent *gdk_xevent, GdkEvent *gevent, gpointer data)
 
 eventFilterStack *
 eventFilterPush (eventFilterSetup *setup, XfwmFilter filter, gpointer data)
+{
+    return eventFilterPushGrab (setup, filter, None, data);
+}
+
+eventFilterStack *
+eventFilterPushGrab (eventFilterSetup *setup, XfwmFilter filter, Window window, gpointer data)
 {
     g_assert (filter != NULL);
     if (setup->filterstack)
@@ -189,6 +198,7 @@ eventFilterPush (eventFilterSetup *setup, XfwmFilter filter, gpointer data)
         eventFilterStack *newfilterstack =
             (eventFilterStack *) g_new (eventFilterStack, 1);
         newfilterstack->filter = filter;
+        newfilterstack->window = window;
         newfilterstack->data = data;
         newfilterstack->next = setup->filterstack;
         setup->filterstack = newfilterstack;
@@ -198,6 +208,7 @@ eventFilterPush (eventFilterSetup *setup, XfwmFilter filter, gpointer data)
         setup->filterstack =
             (eventFilterStack *) g_new (eventFilterStack, 1);
         setup->filterstack->filter = filter;
+        setup->filterstack->window = window;
         setup->filterstack->data = data;
         setup->filterstack->next = NULL;
     }
diff --git a/src/event_filter.h b/src/event_filter.h
index b9f14d073145003bc7127ff86d16e92126b4918f..36cff6cf5d0c47220edd0ed4b5023e50b3d762d6 100644
--- a/src/event_filter.h
+++ b/src/event_filter.h
@@ -47,6 +47,7 @@ typedef eventFilterStatus (*XfwmFilter) (XfwmEvent *event, gpointer data);
 typedef struct eventFilterStack
 {
     XfwmFilter filter;
+    Window window;
     gpointer data;
     struct eventFilterStack *next;
 }
@@ -64,7 +65,11 @@ GdkWindow               *eventFilterAddWin                      (GdkScreen *,
                                                                  long);
 eventFilterStack        *eventFilterPush                        (eventFilterSetup *,
                                                                  XfwmFilter,
-                                                                 gpointer );
+                                                                 gpointer);
+eventFilterStack        *eventFilterPushGrab                    (eventFilterSetup *,
+                                                                 XfwmFilter,
+                                                                 Window,
+                                                                 gpointer);
 eventFilterStack        *eventFilterPop                         (eventFilterSetup *);
 eventFilterSetup        *eventFilterInit                        (XfwmDevices *,
                                                                  gpointer);