1 | /** @file
|
---|
2 | *
|
---|
3 | * Guest client: seamless mode.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include <unistd.h>
|
---|
19 |
|
---|
20 | #include <X11/Xlib.h>
|
---|
21 |
|
---|
22 | #include "VBoxClient.h"
|
---|
23 | #include "seamless.h"
|
---|
24 |
|
---|
25 | class SeamlessService : public VBoxClient::Service
|
---|
26 | {
|
---|
27 | private:
|
---|
28 | VBoxGuestSeamless mSeamless;
|
---|
29 | public:
|
---|
30 | virtual const char *getPidFilePath()
|
---|
31 | {
|
---|
32 | return ".vboxclient-seamless.pid";
|
---|
33 | }
|
---|
34 | virtual int run(bool fDaemonised /* = false */)
|
---|
35 | {
|
---|
36 | /* Initialise threading in X11 and in Xt. */
|
---|
37 | if (!XInitThreads())
|
---|
38 | {
|
---|
39 | LogRel(("VBoxClient: error initialising threads in X11, exiting.\n"));
|
---|
40 | return VERR_NOT_SUPPORTED;
|
---|
41 | }
|
---|
42 | int rc = mSeamless.init();
|
---|
43 | if (RT_FAILURE(rc))
|
---|
44 | return rc;
|
---|
45 | /* Stay running as long as X does... */
|
---|
46 | Display *pDisplay = XOpenDisplay(NULL);
|
---|
47 | XEvent ev;
|
---|
48 | while (true)
|
---|
49 | XNextEvent(pDisplay, &ev);
|
---|
50 | return VERR_INTERRUPTED;
|
---|
51 | }
|
---|
52 | virtual void cleanup()
|
---|
53 | {
|
---|
54 | VbglR3SeamlessSetCap(false);
|
---|
55 | }
|
---|
56 | };
|
---|
57 |
|
---|
58 | VBoxClient::Service *VBoxClient::GetSeamlessService()
|
---|
59 | {
|
---|
60 | return new SeamlessService;
|
---|
61 | }
|
---|