Index: /trunk/include/VBox/VBoxGuest.h
===================================================================
--- /trunk/include/VBox/VBoxGuest.h	(revision 4349)
+++ /trunk/include/VBox/VBoxGuest.h	(revision 4350)
@@ -1346,4 +1346,6 @@
 #define VBGLR3DECL(type) type VBOXCALL
 
+/* General-purpose functions */
+
 __BEGIN_DECLS
 VBGLR3DECL(int)     VbglR3Init(void);
@@ -1353,4 +1355,7 @@
 VBGLR3DECL(int)     VbglR3GetHostTime(PRTTIMESPEC pTime);
 # endif 
+VBGLR3DECL(int)     VbglR3InterruptEventWaits(void);
+
+/* Shared clipboard */
 
 VBGLR3DECL(int)     VbglR3ClipboardConnect(uint32_t *pu32ClientId);
@@ -1361,4 +1366,10 @@
 VBGLR3DECL(int)     VbglR3ClipboardWriteData(uint32_t u32ClientId, uint32_t fFormat, void *pv, uint32_t cb);
 
+/* Seamless mode */
+
+VBGLR3DECL(int)     VbglR3SeamlessSetCap(bool bState);
+VBGLR3DECL(int)     VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode);
+VBGLR3DECL(int)     VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects);
+
 __END_DECLS
 
Index: /trunk/src/VBox/Additions/linux/xclient/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/linux/xclient/Makefile.kmk	(revision 4349)
+++ /trunk/src/VBox/Additions/linux/xclient/Makefile.kmk	(revision 4350)
@@ -26,5 +26,5 @@
 
 vboxadd-xclient_TEMPLATE = VBOXLNX32GUESTR3EXE
-vboxadd-xclient_SOURCES  = clipboard.cpp
+vboxadd-xclient_SOURCES  = clipboard.cpp main.cpp
 vboxadd-xclient_LIBPATH  = $(PATH_TARGET)/vboxadd-xclient $(VBOX_LIBPATH32_X11)
 vboxadd-xclient_LIBS     = \
Index: /trunk/src/VBox/Additions/linux/xclient/clipboard.cpp
===================================================================
--- /trunk/src/VBox/Additions/linux/xclient/clipboard.cpp	(revision 4349)
+++ /trunk/src/VBox/Additions/linux/xclient/clipboard.cpp	(revision 4350)
@@ -23,5 +23,5 @@
 #define USE_CTEXT
 
-#define LOG_GROUP LOG_GROUP_HGCM
+#define LOG_GROUP LOG_GROUP_DEV_VMM_BACKDOOR
 
 #include <vector>
@@ -33,5 +33,5 @@
 #include <VBox/VBoxGuest.h>
 #include <VBox/HostServices/VBoxClipboardSvc.h>
-
+#include <VBox/log.h>
 #include <iprt/alloc.h>
 #include <iprt/asm.h>        /* For atomic operations */
@@ -43,18 +43,15 @@
 #include <iprt/process.h>
 #include <iprt/semaphore.h>
-#include <VBox/log.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
+// #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <signal.h>
-#include <unistd.h>
-#include <getopt.h>
-
-// #include "VBoxClipboard.h"
+// #include <unistd.h>
+// #include <getopt.h>
 
 #include <X11/Xlib.h>
@@ -63,4 +60,6 @@
 #include <X11/Shell.h>
 #include <X11/X.h>
+
+#include "clipboard.h"
 
 #define VBOX_INIT_CALL(__a, __b, __c) do {                                                             \
@@ -161,6 +160,4 @@
         it. */
     RTSEMEVENT terminating;
-    /** Are we running as a daemon? */
-    bool daemonise;
 
     /** Format which we are reading from the guest clipboard (valid during a request for the
@@ -1521,32 +1518,4 @@
 }
 
-int vboxClipboardXLibErrorHandler(Display *pDisplay, XErrorEvent *pError)
-{
-    char errorText[1024];
-
-    LogFlowFunc(("\n"));
-    if (pError->error_code == BadAtom)
-    {
-        /* This can be triggered in debug builds if a guest application passes a bad atom
-           in its list of supported clipboard formats.  As such it is harmless. */
-        LogFlowFunc(("ignoring BadAtom error and returning\n"));
-        return 0;
-    }
-    vboxClipboardDisconnect();
-    XGetErrorText(pDisplay, pError->error_code, errorText, sizeof(errorText));
-    if (g_ctx.daemonise == 0)
-    {
-        cout << "An X Window protocol error occurred: " << errorText << endl
-            << "  Request code: " << int(pError->request_code) << endl
-            << "  Minor code: " << int(pError->minor_code) << endl
-            << "  Serial number of the failed request: " << int(pError->serial) << endl;
-    }
-    Log(("%s: an X Window protocol error occurred: %s.  Request code: %d, minor code: %d, serial number: %d\n",
-         __PRETTY_FUNCTION__, pError->error_code, pError->request_code, pError->minor_code,
-         pError->serial));
-    LogFlowFunc(("exiting\n"));
-    exit(1);
-}
-
 
 /**
@@ -1562,4 +1531,29 @@
     AssertReturn(g_ctx.client == 0, VERR_NOT_SUPPORTED);
 
+    /* Initialise the termination semaphore. */
+    RTSemEventCreate(&g_ctx.terminating);
+    /* Open a connection to the driver for sending requests. */
+    g_ctx.sendDevice = open(VBOXGUEST_DEVICE_NAME, O_RDWR, 0);
+    if (g_ctx.sendDevice < 0)
+    {
+        int err = errno;
+
+        Log(("Error opening kernel module! errno = %d\n", err));
+        cout << "Failed to open the VirtualBox device in the guest." << endl;
+        LogFlowFunc(("returning 1\n"));
+        return RTErrConvertFromErrno(err);
+    }
+    /* Open a connection to the driver for polling for host requests. */
+    g_ctx.receiveDevice = open(VBOXGUEST_DEVICE_NAME, O_RDWR, 0);
+    if (g_ctx.receiveDevice < 0)
+    {
+        int err = errno;
+
+        Log(("Error opening kernel module! rc = %d\n", err));
+        cout << "Failed to open the VirtualBox device in the guest" << endl;
+        LogFlowFunc(("returning 1\n"));
+        return RTErrConvertFromErrno(err);
+    }
+
     rc = ioctl(g_ctx.sendDevice, IOCTL_VBOXGUEST_CLIPBOARD_CONNECT, (void*)&g_ctx.client);
     if (rc >= 0)
@@ -1579,6 +1573,4 @@
         return VERR_NOT_SUPPORTED;
     }
-    /* Set an X11 error handler, so that we don't die when we get BadAtom errors. */
-    XSetErrorHandler(vboxClipboardXLibErrorHandler);
     LogFlowFunc(("returned VINF_SUCCESS\n"));
     return VINF_SUCCESS;
@@ -1684,101 +1676,2 @@
     return rc;
 }
-
-
-/**
- * Become a daemon process
- */
-void vboxDaemonise(void)
-{
-    /* First fork and exit the parent process, so that we are sure we are not session leader. */
-    if (fork() != 0)
-    {
-        exit(0);
-    }
-    /* Detach from the controlling terminal by creating our own session. */
-    setsid();
-    /* And change to the root directory to avoid holding the one we were started in open. */
-    chdir("/");
-    /* Close the standard files. */
-    close(0);
-    close(1);
-    close(2);
-}
-
-int main(int argc, char *argv[])
-{
-    int rc;
-
-    /* Parse our option(s) */
-    g_ctx.daemonise = 1;
-    while (1)
-    {
-        static struct option sOpts[] =
-        {
-            {"nodaemon", 0, 0, 'd'},
-            {0, 0, 0, 0}
-        };
-        int cOpt = getopt_long(argc, argv, "", sOpts, 0);
-        if (cOpt == -1)
-        {
-            if (optind < argc)
-            {
-                cout << "Unrecognized command line argument: " << argv[argc] << endl;
-                exit(1);
-            }
-            break;
-        }
-        switch(cOpt)
-        {
-        case 'd':
-            g_ctx.daemonise = 0;
-            break;
-        default:
-            cout << "Unrecognized command line option: " << static_cast<char>(cOpt) << endl;
-        case '?':
-            exit(1);
-        }
-    }
-    /* Initialise our runtime before all else. */
-    RTR3Init(false);
-    LogFlowFunc(("\n"));
-    /* Initialise threading in Xt before we start any new threads. */
-    XtToolkitThreadInitialize();
-    /* Initialise the termination semaphore. */
-    RTSemEventCreate(&g_ctx.terminating);
-    /* Open a connection to the driver for sending requests. */
-    g_ctx.sendDevice = open(VBOXGUEST_DEVICE_NAME, O_RDWR, 0);
-    if (g_ctx.sendDevice < 0)
-    {
-        Log(("Error opening kernel module! errno = %d\n", errno));
-        cout << "Failed to open the VirtualBox device in the guest." << endl;
-        LogFlowFunc(("returning 1\n"));
-        return 1;
-    }
-    /* Open a connection to the driver for polling for host requests. */
-    g_ctx.receiveDevice = open(VBOXGUEST_DEVICE_NAME, O_RDWR, 0);
-    if (g_ctx.receiveDevice < 0)
-    {
-        Log(("Error opening kernel module! rc = %d\n", errno));
-        cout << "Failed to open the VirtualBox device in the guest" << endl;
-        LogFlowFunc(("returning 1\n"));
-        return 1;
-    }
-    /* Connect to the host clipboard. */
-    rc = vboxClipboardConnect();
-    if (rc != VINF_SUCCESS)
-    {
-        Log(("vboxClipboardConnect failed with rc = %d\n", rc));
-        cout << "Failed to connect to the host clipboard." << endl;
-        LogFlowFunc(("returning 1\n"));
-        return 1;
-    }
-    if (g_ctx.daemonise == 1)
-    {
-        vboxDaemonise();
-    }
-    vboxClipboardMain();
-    vboxClipboardDisconnect();
-    LogFlowFunc(("returning 0\n"));
-    return 0;
-}
