--- ./src/if_xcmdsrv.c	2008-07-18 22:05:03.000000000 +0900
+++ ./src/if_xcmdsrv.c	2009-01-15 15:23:23.000000000 +0900
@@ -190,8 +190,10 @@
 
 static Window	LookupName __ARGS((Display *dpy, char_u *name, int delete, char_u **loose));
 static int	SendInit __ARGS((Display *dpy));
+static int	SendClientMsg __ARGS((Display *dpy, Window win, char *msg, unsigned long data));
 static int	DoRegisterName __ARGS((Display *dpy, char_u *name));
 static void	DeleteAnyLingerer __ARGS((Display *dpy, Window w));
+static int	GetWindowProp __ARGS((Display *dpy, Window win, char *propName, char_u **propValue, long_u *numItemsp));
 static int	GetRegProp __ARGS((Display *dpy, char_u **regPropp, long_u *numItemsp, int domsg));
 static int	WaitForPend __ARGS((void *p));
 static int	WaitForReply __ARGS((void *p));
@@ -883,6 +885,59 @@
     return 0;
 }
 
+/*
+ * Send a ClientMessage event.
+ */
+    static int
+SendClientMsg(dpy, win, msg, data)
+    Display *dpy;
+    Window win;
+    char *msg;
+    unsigned long data;
+{
+    XEvent event;
+    event.xclient.type = ClientMessage;
+    event.xclient.message_type = XInternAtom(dpy, msg, False);
+    event.xclient.window = win;
+    event.xclient.format = 32;
+    event.xclient.data.l[0] = data;
+    event.xclient.data.l[1] = 0;
+    event.xclient.data.l[2] = 0;
+    event.xclient.data.l[3] = 0;
+    event.xclient.data.l[4] = 0;
+ 
+    if (XSendEvent(dpy, DefaultRootWindow(dpy), False, 
+		SubstructureRedirectMask | SubstructureNotifyMask, &event))
+	return OK;
+    else
+	return FAIL;
+}
+
+/*
+ * Move the specified window to the current desktop and raise it to the
+ * top of the stack.
+ */
+    int
+activateWindow(dpy, win)
+    Display	*dpy;
+    Window	win;
+{
+    char_u	*desktop;
+    long_u	numItems;
+
+    if (GetWindowProp(dpy, DefaultRootWindow(dpy), "_NET_CURRENT_DESKTOP", 
+		&desktop, &numItems) == OK)
+    {
+	SendClientMsg(dpy, win, "_NET_WM_DESKTOP", *desktop);
+	XFree(desktop);
+    }
+
+    SendClientMsg(dpy, win, "_NET_ACTIVE_WINDOW", 0);
+    XMapRaised(dpy, win);
+    XSync(dpy, False);
+
+    return OK;
+}
 
 /*
  * Initialize the communication channels for sending commands and receiving
@@ -1096,6 +1150,39 @@
 }
 
 /*
+ * Retrieve a window property.  Return OK when successful with the
+ * property value in propValuep.
+ */
+    static int
+GetWindowProp(dpy, win, propName, propValuep, numItemsp)
+    Display	*dpy;
+    Window	win;
+    char	*propName;
+    char_u	**propValuep;
+    long_u	*numItemsp;
+{
+    int		result, actualFormat;
+    long_u	bytesAfter;
+    Atom	property;
+    Atom	actualType;
+
+    *propValuep = NULL;
+    property = XInternAtom(dpy, propName, False);
+    result = XGetWindowProperty(dpy, win, property, 0L,
+				(long)MAX_PROP_WORDS, False,
+				AnyPropertyType, &actualType,
+				&actualFormat, numItemsp, &bytesAfter,
+				propValuep);
+
+    if (result == Success && actualFormat != 0)
+	return OK;
+
+    if (*propValuep != NULL)
+	XFree(propValuep);
+    return FAIL;
+}
+
+/*
  * Read the registry property.  Delete it when it's formatted wrong.
  * Return the property in "regPropp".  "empty_prop" is used when it doesn't
  * exist yet.
--- ./src/main.c	2009-01-15 13:19:04.000000000 +0900
+++ ./src/main.c	2009-01-15 15:23:23.000000000 +0900
@@ -3099,9 +3099,10 @@
     main_msg(_("--remote <files>\tEdit <files> in a Vim server if possible"));
     main_msg(_("--remote-silent <files>  Same, don't complain if there is no server"));
     main_msg(_("--remote-wait <files>  As --remote but wait for files to have been edited"));
+    main_msg(_("--remote-raise <files>  As --remote but raise the remote window to focus"));
     main_msg(_("--remote-wait-silent <files>  Same, don't complain if there is no server"));
 # ifdef FEAT_WINDOWS
-    main_msg(_("--remote-tab[-wait][-silent] <files>  As --remote but use tab page per file"));
+    main_msg(_("--remote-tab[-wait][-raise][-silent] <files>  As --remote but use tab page per file"));
 # endif
     main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit"));
     main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result"));
@@ -3419,6 +3420,7 @@
 #define ARGTYPE_EDIT		1
 #define ARGTYPE_EDIT_WAIT	2
 #define ARGTYPE_SEND		3
+    int		raise = FALSE;
     int		silent = FALSE;
     int		tabs = FALSE;
 # ifndef FEAT_X11
@@ -3464,6 +3466,11 @@
 		    argtype = ARGTYPE_EDIT_WAIT;
 		    p += 5;
 		}
+		else if (STRNICMP(p, "-raise", 6) == 0)
+		{
+		    raise = TRUE;
+		    p += 6;
+		}
 		else if (STRNICMP(p, "-silent", 7) == 0)
 		{
 		    silent = TRUE;
@@ -3541,6 +3548,10 @@
 	    if (argtype != ARGTYPE_SEND && TOUPPER_ASC(*sname) == 'G')
 		SetForegroundWindow(srv);
 # endif
+# ifdef FEAT_X11
+	    if (ret >= 0 && raise == TRUE)
+		activateWindow(xterm_dpy, srv);
+# endif
 
 	    /*
 	     * For --remote-wait: Wait until the server did edit each
--- ./src/proto/if_xcmdsrv.pro	2008-08-09 23:31:33.000000000 +0900
+++ ./src/proto/if_xcmdsrv.pro	2009-01-15 15:23:23.000000000 +0900
@@ -8,4 +8,5 @@
 int serverReadReply __ARGS((Display *dpy, Window win, char_u **str, int localLoop));
 int serverPeekReply __ARGS((Display *dpy, Window win, char_u **str));
 void serverEventProc __ARGS((Display *dpy, XEvent *eventPtr));
+int activateWindow __ARGS((Display *dpy, Window	win));
 /* vim: set ft=c : */
