Index: gnome-panel/panel-applet-frame.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-applet-frame.c,v
retrieving revision 1.134
diff -p -u -r1.134 panel-applet-frame.c
--- gnome-panel/panel-applet-frame.c	2 Jan 2005 17:46:12 -0000	1.134
+++ gnome-panel/panel-applet-frame.c	6 Jan 2005 09:29:30 -0000
@@ -54,6 +54,7 @@
 #define PROPERTY_FLAGS      "panel-applet-flags"
 #define PROPERTY_SIZE_HINTS "panel-applet-size-hints"
 #define PROPERTY_LOCKED_DOWN "panel-applet-locked-down"
+#define PROPERTY_PANEL_XID  "panel-xwindow-xid"
 
 
 struct _PanelAppletFramePrivate {
@@ -1219,11 +1220,13 @@ panel_applet_frame_construct_moniker (Pa
 
 	retval = g_strdup_printf (
 			"%s!prefs_key=/apps/panel/applets/%s/prefs;"
-			"background=%s;orient=%s;size=%s;locked_down=%s",
+			"background=%s;orient=%s;size=%s;locked_down=%s;"
+			"panel_xwindow_xid=0x%lx",
 			iid, id, bg_str,
 			panel_applet_frame_get_orient_string (frame, panel),
 			panel_applet_frame_get_size_string (frame, panel),
-			locked_down ? "true" : "false");
+			locked_down ? "true" : "false",
+			GDK_WINDOW_XWINDOW (gtk_widget_get_toplevel (GTK_WIDGET (panel))->window));
 
 	g_free (bg_str);
 
Index: libpanel-applet/panel-applet.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-applet.c,v
retrieving revision 1.90
diff -p -u -r1.90 panel-applet.c
--- libpanel-applet/panel-applet.c	17 Aug 2004 12:03:48 -0000	1.90
+++ libpanel-applet/panel-applet.c	6 Jan 2005 09:29:30 -0000
@@ -70,6 +70,7 @@ struct _PanelAppletPrivate {
 	PanelAppletOrient           orient;
 	guint                       size;
 	char                       *background;
+	XID                         containing_panel_xwindow_xid;
 
         int                        *size_hints;
         int                         size_hints_len;
@@ -98,6 +99,7 @@ static guint panel_applet_signals [LAST_
 #define PROPERTY_FLAGS      "panel-applet-flags"
 #define PROPERTY_SIZE_HINTS "panel-applet-size-hints"
 #define PROPERTY_LOCKED_DOWN "panel-applet-locked-down"
+#define PROPERTY_PANEL_XID  "panel-xwindow-xid"
 
 enum {
 	PROPERTY_ORIENT_IDX,
@@ -105,7 +107,8 @@ enum {
 	PROPERTY_BACKGROUND_IDX,
 	PROPERTY_FLAGS_IDX,
 	PROPERTY_SIZE_HINTS_IDX,
-	PROPERTY_LOCKED_DOWN_IDX
+	PROPERTY_LOCKED_DOWN_IDX,
+	PROPERTY_PANEL_XID_IDX
 };
 
 static void
@@ -325,6 +328,34 @@ panel_applet_get_locked_down (PanelApple
 }
 
 void
+panel_applet_request_focus (PanelApplet  *applet,
+			    guint32       timestamp)
+{
+	XEvent xev;
+	GdkDisplay *display;
+	GdkWindow *window;
+
+	window = gtk_widget_get_toplevel (GTK_WIDGET (applet))->window;
+	display = gdk_drawable_get_display (window);
+
+	xev.xclient.type = ClientMessage;
+	xev.xclient.serial = 0;
+	xev.xclient.send_event = True;
+	xev.xclient.window = applet->priv->containing_panel_xwindow_xid;
+	xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,                                                                        "_NET_ACTIVE_WINDOW");
+	xev.xclient.format = 32;
+	xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
+	xev.xclient.data.l[1] = timestamp;
+	xev.xclient.data.l[2] = None; /* "currently active window", supposedly */
+	xev.xclient.data.l[3] = 0;
+	xev.xclient.data.l[4] = 0;
+
+	XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_ROOT_WINDOW(), False,
+	            SubstructureRedirectMask | SubstructureNotifyMask,
+	            &xev);
+}
+
+void
 panel_applet_setup_menu (PanelApplet        *applet,
 			 const gchar        *xml,
 			 const BonoboUIVerb *verb_list,
@@ -937,6 +968,10 @@ panel_applet_get_prop (BonoboPropertyBag
 	case PROPERTY_LOCKED_DOWN_IDX:
 		BONOBO_ARG_SET_BOOLEAN (arg, applet->priv->locked_down);
 		break;
+	case PROPERTY_PANEL_XID_IDX:
+		BONOBO_ARG_SET_LONG (arg, 
+				     applet->priv->containing_panel_xwindow_xid);
+		break;
 	default:
 		g_assert_not_reached ();
 		break;
@@ -1040,6 +1075,10 @@ panel_applet_set_prop (BonoboPropertyBag
 	case PROPERTY_LOCKED_DOWN_IDX:
 		applet->priv->locked_down = BONOBO_ARG_GET_BOOLEAN (arg);
 		break;
+	case PROPERTY_PANEL_XID_IDX:
+		applet->priv->containing_panel_xwindow_xid =
+			BONOBO_ARG_GET_LONG (arg);
+		break;
 	default:
 		g_assert_not_reached ();
 		break;
@@ -1103,6 +1142,14 @@ panel_applet_property_bag (PanelApplet *
 				 _("The Applet's containing Panel is locked down"),
 				 Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE);
 
+	bonobo_property_bag_add (sack,
+				 PROPERTY_PANEL_XID,
+				 PROPERTY_PANEL_XID_IDX,
+				 BONOBO_ARG_LONG,
+				 NULL,
+				 _("The Applet's containing Panel's xwindow xid"),
+				 Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE);
+
 	return sack;
 }
 
@@ -1238,6 +1285,13 @@ panel_applet_item_handler_get_object (Bo
 				val = TRUE;
 			bonobo_pbclient_set_boolean (BONOBO_OBJREF (applet->priv->prop_sack),
 						     PROPERTY_LOCKED_DOWN, val, NULL);
+		} else if (!strcmp (option->key, "panel_xwindow_xid")) {
+			char * endptr;
+			XID    xwindow_xid;
+			xwindow_xid = strtoul (option->value, &endptr, 0);
+			bonobo_pbclient_set_long (
+				BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_PANEL_XID,
+				xwindow_xid, NULL);
 		}
 	}
 
@@ -1365,6 +1419,7 @@ panel_applet_instance_init (PanelApplet 
 	applet->priv->flags  = PANEL_APPLET_FLAGS_NONE;
 	applet->priv->orient = PANEL_APPLET_ORIENT_UP;
 	applet->priv->size   = GNOME_Vertigo_PANEL_MEDIUM;
+	applet->priv->containing_panel_xwindow_xid = None;
 
 	applet->priv->moving_focus_out = FALSE;
 
Index: libpanel-applet/panel-applet.h
===================================================================
RCS file: /cvs/gnome/gnome-panel/libpanel-applet/panel-applet.h,v
retrieving revision 1.36
diff -p -u -r1.36 panel-applet.h
--- libpanel-applet/panel-applet.h	15 Sep 2003 22:10:46 -0000	1.36
+++ libpanel-applet/panel-applet.h	6 Jan 2005 09:29:30 -0000
@@ -128,6 +128,9 @@ void      	   panel_applet_set_size_hint
 
 gboolean           panel_applet_get_locked_down      (PanelApplet  *applet);
 
+void               panel_applet_request_focus        (PanelApplet  *applet,
+						      guint32       timestamp);
+
 BonoboControl     *panel_applet_get_control          (PanelApplet  *applet);
 BonoboUIComponent *panel_applet_get_popup_component  (PanelApplet  *applet);
 
