diff -u pwm-20010309.orig/ChangeLog pwm-20010309/ChangeLog
--- pwm-20010309.orig/ChangeLog	2001-03-09 17:20:04.000000000 +0200
+++ pwm-20010309/ChangeLog	2002-12-10 07:02:52.000000000 +0200
@@ -1,4 +1,7 @@
 
+2002-12-10:
+  * Autoraise support by Cougar <cougar@random.ee>
+
 2001-03-09:
   * Allow windows to move themselves
 
diff -u pwm-20010309.orig/config.h pwm-20010309/config.h
--- pwm-20010309.orig/config.h	2000-12-31 18:54:57.000000000 +0200
+++ pwm-20010309/config.h	2002-12-10 00:27:52.000000000 +0200
@@ -95,6 +95,7 @@
 #define CF_BAR_MAX_WIDTH_Q (GRDATA->bar_max_width_q)
 #define CF_TAB_MIN_WIDTH (GRDATA->tab_min_width)
 
+#define	CF_AUTORAISE_TIME (GRDATA->autoraise_time)
 
 /* Drawing
  */
diff -u pwm-20010309.orig/config.txt pwm-20010309/config.txt
--- pwm-20010309.orig/config.txt	2001-01-10 07:33:31.000000000 +0200
+++ pwm-20010309/config.txt	2002-12-10 07:39:03.000000000 +0200
@@ -124,6 +124,11 @@
 		# this percentage of screen space are moved opaquely).
 		# Default is 100 - all moves are opaque.
 		opaque_move <percentage>
+
+		# This is time in milliseconds after which duration of focus,
+		# focused window will be raised automatically.
+		# Use -1 or let it undefined to avoid this feature.
+		autoraise_time <ms>
 	}
 
 
diff -u pwm-20010309.orig/draw.h pwm-20010309/draw.h
--- pwm-20010309.orig/draw.h	2000-12-31 18:54:57.000000000 +0200
+++ pwm-20010309/draw.h	2002-12-10 00:15:40.000000000 +0200
@@ -44,6 +44,8 @@
 	WColorGroup act_base_colors, act_sel_colors;
 	WColorGroup tab_colors, tab_sel_colors;
 	WColorGroup base_colors, sel_colors;
+
+	int autoraise_time;
 	
 	/* other data */
 	int bar_height;
diff -u pwm-20010309.orig/event.c pwm-20010309/event.c
--- pwm-20010309.orig/event.c	2001-03-09 17:19:16.000000000 +0200
+++ pwm-20010309/event.c	2002-12-10 08:24:44.000000000 +0200
@@ -303,6 +303,15 @@
 }
 	   
 
+static void autoraise_handler()
+{
+	if(wglobal.current_winobj==NULL)
+		return;
+	reset_timer();
+	raise_winobj(wglobal.current_winobj);
+}
+
+
 static void handle_enter_window(XEvent *ev)
 {
 	XEnterWindowEvent *eev=&(ev->xcrossing);
@@ -331,10 +340,9 @@
 #endif
 	
 	if(eev->window==eev->root){
-		if(!eev->same_screen)
-			thing=(WThing*)wglobal.current_winobj;
-		else
+		if(eev->mode==NotifyInferior || wglobal.current_winobj==NULL)
 			return;
+		thing=(WThing*)wglobal.current_winobj;
 	}else{
 		thing=find_thing(eev->window);
 
@@ -348,6 +356,14 @@
 	}
 	
 	do_set_focus(thing);
+
+	if(wglobal.current_winobj==NULL)
+		return;
+	if(CF_AUTORAISE_TIME==0){
+		raise_winobj(wglobal.current_winobj);
+	}else if(CF_AUTORAISE_TIME>0){
+		set_timer(CF_AUTORAISE_TIME, autoraise_handler);
+	}
 }
 
 
diff -u pwm-20010309.orig/readconfig.c pwm-20010309/readconfig.c
--- pwm-20010309.orig/readconfig.c	2001-01-10 07:33:31.000000000 +0200
+++ pwm-20010309/readconfig.c	2002-12-10 00:21:00.000000000 +0200
@@ -752,6 +752,22 @@
 }
 
 
+static bool opt_screen_autoraise_time(Tokenizer *tokz, int n, Token *toks)
+{
+	int i=TOK_LONG_VAL(&(toks[1]));
+
+	if(tmp_screen==NULL)
+		return TRUE;
+	
+	if(i<0)
+		i=-1;
+	
+	GRDATA->autoraise_time=i;
+	
+	return TRUE;
+}
+
+
 static bool begin_screen(Tokenizer *tokz, int n, Token *toks)
 {	
 	int i;
@@ -958,6 +974,7 @@
 	{"workspaces", "l?l", opt_screen_workspaces, NULL},
 	{"opaque_move", "l", opt_screen_opaque_move, NULL},
 	{"dock", "s?i+", opt_screen_dock, NULL},
+	{"autoraise_time", "l", opt_screen_autoraise_time, NULL},
 	
 	{"#end", NULL, end_screen, NULL},
 	{"#cancel", NULL, end_screen, NULL},
diff -u pwm-20010309.orig/screen.c pwm-20010309/screen.c
--- pwm-20010309.orig/screen.c	2000-12-31 18:54:57.000000000 +0200
+++ pwm-20010309/screen.c	2002-12-10 00:17:02.000000000 +0200
@@ -280,6 +280,8 @@
 	grdata->bar_min_width=10;
 	grdata->bar_max_width_q=0.95;
 	grdata->tab_min_width=10;
+
+	grdata->autoraise_time=-1;
 	
 	return TRUE;
 }
