diff --git a/src/config.c b/src/config.c
index 2f70453..1ecfd95 100644
--- a/src/config.c
+++ b/src/config.c
@@ -38,8 +38,13 @@
 /**
  *
  */
-GSList *file_window_open_list = NULL;
-GSList *file_window_close_list = NULL;
+GSList *event_lists[W_NUM_EVENTS] = { NULL, NULL, NULL, NULL };
+const char *event_names[W_NUM_EVENTS] = {
+	"window_open",
+	"window_close",
+	"window_focus",
+	"window_blur",
+};
 
 
 /**
@@ -152,11 +157,14 @@ gboolean is_in_list(GSList *list, gchar *filename)
  */
 gboolean is_in_any_list(gchar *filename)
 {
-	gboolean result = FALSE;
+	win_event_type i;
 
-	if (is_in_list(file_window_close_list, filename)) result = TRUE;
+	for (i=0; i < W_NUM_EVENTS; i++) {
+		if (is_in_list(event_lists[i], filename))
+			return TRUE;
+	}
 
-	return result;
+	return FALSE;
 }
 
 
@@ -201,9 +209,15 @@ int load_config(gchar *filename)
 
 		run_script(config_lua_state);
 
-		file_window_close_list = get_table_of_strings(config_lua_state,
+		event_lists[W_CLOSE] = get_table_of_strings(config_lua_state,
 		                         script_folder,
 		                         "scripts_window_close");
+		event_lists[W_FOCUS] = get_table_of_strings(config_lua_state,
+		                         script_folder,
+		                         "scripts_window_focus");
+		event_lists[W_BLUR]  = get_table_of_strings(config_lua_state,
+		                         script_folder,
+		                         "scripts_window_blur");
 	}
 
 	// add the files in the folder to our linked list
@@ -227,7 +241,7 @@ int load_config(gchar *filename)
 		g_free(temp_filename);
 	}
 
-	file_window_open_list = temp_window_open_file_list;
+	event_lists[W_OPEN] = temp_window_open_file_list;
 EXITPOINT:
 	if (config_lua_state)
 		done_script(config_lua_state);
@@ -240,7 +254,7 @@ EXITPOINT:
 /**
  *
  */
-void unalloacte_file_list(GSList *file_list)
+void unallocate_file_list(GSList *file_list)
 {
 	if (file_list) {
 
@@ -261,11 +275,11 @@ void unalloacte_file_list(GSList *file_list)
  */
 void clear_file_lists()
 {
-	if (file_window_open_list) {
-		unalloacte_file_list(file_window_open_list);
-	}
+	win_event_type i = 0;
 
-	if (file_window_close_list) {
-		unalloacte_file_list(file_window_close_list);
+	for (i = 0; i < W_NUM_EVENTS; i++) {
+		if (event_lists[i]) {
+			unallocate_file_list(event_lists[i]);
+		}
 	}
 }
diff --git a/src/config.h b/src/config.h
index 75454bb..c41bcdb 100644
--- a/src/config.h
+++ b/src/config.h
@@ -26,8 +26,16 @@ int load_config(gchar *config_filename);
 
 void clear_file_lists();
 
-extern GSList *file_window_open_list;
-extern GSList *file_window_close_list;
+typedef enum {
+	W_OPEN,
+	W_CLOSE,
+	W_FOCUS,
+	W_BLUR,
+	W_NUM_EVENTS /* keep this at the end */
+} win_event_type;
+
+extern GSList *event_lists[W_NUM_EVENTS];
+extern const char *event_names[W_NUM_EVENTS];
 
 // Our git version which is defined through some magic in the build system
 extern const char *gitversion;
diff --git a/src/devilspie2.c b/src/devilspie2.c
index bd5edca..30fade5 100644
--- a/src/devilspie2.c
+++ b/src/devilspie2.c
@@ -76,7 +76,7 @@ static void load_list_of_scripts(WnckScreen *screen, WnckWindow *window,
 	set_current_window(window);
 
 	// for every file in the folder - load the script
-	if (file_window_open_list != NULL) {
+	if (event_lists[W_OPEN] != NULL) {
 
 		while(temp_file_list) {
 			gchar *filename = (gchar*)temp_file_list->data;
@@ -104,7 +104,7 @@ static void load_list_of_scripts(WnckScreen *screen, WnckWindow *window,
  */
 static void window_opened_cb(WnckScreen *screen, WnckWindow *window)
 {
-	load_list_of_scripts(screen, window, file_window_open_list);
+	load_list_of_scripts(screen, window, event_lists[W_OPEN]);
 }
 
 
@@ -113,7 +113,19 @@ static void window_opened_cb(WnckScreen *screen, WnckWindow *window)
  */
 static void window_closed_cb(WnckScreen *screen, WnckWindow *window)
 {
-	load_list_of_scripts(screen, window, file_window_close_list);
+	load_list_of_scripts(screen, window, event_lists[W_CLOSE]);
+}
+
+/**
+ *
+ */
+static void window_changed_cb(WnckScreen *screen, WnckWindow *window)
+{
+	WnckWindow *cur;
+
+	load_list_of_scripts(screen, window, event_lists[W_BLUR]);
+	cur = wnck_screen_get_active_window(screen);
+	load_list_of_scripts(screen, cur, event_lists[W_FOCUS]);
 }
 
 
@@ -138,6 +150,8 @@ void init_screens()
 		                 (GCallback)window_opened_cb, NULL);
 		g_signal_connect(screen, "window-closed",
 		                 (GCallback)window_closed_cb, NULL);
+		g_signal_connect(screen, "active-window-changed",
+		                 (GCallback)window_changed_cb, NULL);
 	}
 }
 
@@ -203,31 +217,31 @@ void print_list(GSList *list)
  */
 void print_script_lists()
 {
+	gboolean have_any_files = FALSE;
+	win_event_type i;
+
 	if (debug)
 		printf("------------\n");
 
-	if ((file_window_open_list == NULL) && (file_window_close_list == NULL)) {
+	for (i = 0; i < W_NUM_EVENTS; i++) {
+		if (event_lists[i])
+			have_any_files = TRUE;
+		// If we are running debug mode - print the list of files:
+		if (debug) {
+			printf(_("List of Lua files handling \"%s\" events in folder:"),
+				   event_names[i]);
+			printf("\n");
+			if (event_lists[i]) {
+				print_list(event_lists[i]);
+			}
+		}
+	}
+
+	if (!have_any_files) {
 		printf("%s", _("No script files found in the script folder - exiting."));
 		printf("\n\n");
 		exit(EXIT_SUCCESS);
 	}
-
-	// If we are running debug mode - print the list of files:
-	if (debug) {
-		printf(_("List of Lua files handling \"%s\" events in folder:"),
-		       "window_open");
-		printf("\n");
-		if (file_window_open_list)
-			print_list(file_window_open_list);
-	}
-
-	if (debug) {
-		printf(_("List of Lua files handling \"%s\" events in folder:"),
-		       "window_close");
-		printf("\n");
-		if (file_window_close_list)
-			print_list(file_window_close_list);
-	}
 }
 
 
