Index: gdictsrc/gdict-applet.c
===================================================================
RCS file: /cvs/gnome/gdict/gdict/gdict-applet.c,v
retrieving revision 1.84
diff -p -u -r1.84 gdict-applet.c
--- gdictsrc/gdict-applet.c	23 Dec 2004 15:41:45 -0000	1.84
+++ gdictsrc/gdict-applet.c	4 Jan 2005 23:33:35 -0000
@@ -15,6 +15,7 @@
 #endif
 
 #include <gtk/gtk.h>
+#include <gdk/gdkx.h>
 #include <glib/gi18n.h>
 #include <panel-applet.h>
 
@@ -54,6 +55,80 @@ entry_activate_cb (GtkEntry *entry, gpoi
 }
 
 static gboolean
+entry_button_press_event (GtkWidget *widget,
+			  GdkEventButton *event,
+			  GDictApplet *applet)
+{
+       g_print ("gtk_widget_get_toplevel (widget)->window = 0x%lx\n",
+                gtk_widget_get_toplevel (widget)->window);
+       /*
+       g_print ("gtk_widget_get_toplevel (applet->applet_widget)->window = 0x%lx\n",
+                gtk_widget_get_toplevel (applet->applet_widget)->window);
+       */
+
+       g_print ("GDK_WINDOW_XWINDOW (gtk_widget_get_toplevel (widget)->window) = 0x%lx\n",
+                GDK_WINDOW_XWINDOW (gtk_widget_get_toplevel (widget)->window));
+
+       /* This call will fail, because the applet's toplevel window is
+        * not the same as the panel's toplevel window; the applet and
+        * panel are in different processes
+        */
+       gdk_window_focus (gtk_widget_get_toplevel (widget)->window, event->time);
+
+       /* Here is a method that does work which requires manual user
+        * assistance in the form of research to find a window id and
+        * recompiling upon every login or restart of the panel, and
+        * which only works for a single panel, and is as hacky as can
+        * be...  in short, great stuff :-)
+	*
+        * This ultra ugly hack is necessary, because the slightly less ugly hack
+        *    gdk_window_focus (0xe00024, event->time);
+        * doesn't work because 0xe00024 is an Xwindow id (that's what
+        * I can get from xprop), and gdk_window_focus wants a
+        * GdkWindow* (which we don't have).  The below is basically a
+        * copy of gdk_window_focus, but modified since I want to use
+        * an XID instead of an GdkWindow*
+        *
+        * To get this to work, you first have to replace 0xe00024 with
+        * the XID of the panel window that you are interested in.  To
+        * find that use
+        *   xprop -root | grep ^_NET_CLIENT_LIST
+        * followed by a lot of
+        *   xprop -id <some id> | grep ^WM_NAME
+        * to check each id from _NET_CLIENT_LIST to find out which one
+        * is the panel you want.  Then recompile, install, and restart
+        * gdict.
+        */
+    {
+      XEvent xev;
+      GdkDisplay *display;
+      GdkWindow *window;
+
+      window = gtk_widget_get_toplevel (widget)->window;
+      display = gdk_drawable_get_display (window);
+
+      xev.xclient.type = ClientMessage;
+      xev.xclient.serial = 0;
+      xev.xclient.send_event = True;
+      xev.xclient.window = 0xe00024;
+      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 */
+      xev.xclient.data.l[1] = event->time;
+      xev.xclient.data.l[2] = None; /* currently active window */
+      xev.xclient.data.l[3] = 0;
+      xev.xclient.data.l[4] = 0;
+
+      XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_ROOT_WINDOW(), False,
+                  SubstructureRedirectMask | SubstructureNotifyMask,
+                  &xev);
+    }
+
+       return FALSE;
+}
+
+
+static gboolean
 image_clicked (GtkWidget *w, GdkEventButton *event, gpointer data)
 {
 	GDictApplet *applet = data;
@@ -153,6 +228,8 @@ setup_applet_widgets (GDictApplet *apple
 
  	g_signal_connect (G_OBJECT (applet->entry_widget), "activate",
  			  G_CALLBACK (entry_activate_cb), applet);
+	g_signal_connect (G_OBJECT (applet->entry_widget), "button_press_event",
+			  G_CALLBACK (entry_button_press_event), applet);
 	g_signal_connect (G_OBJECT (eventbox), "button_release_event",
  			  G_CALLBACK (image_clicked), applet);
  	g_signal_connect (G_OBJECT (eventbox), "drag_data_received",
