VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11.cpp@ 78228

Last change on this file since 78228 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.9 KB
Line 
1/* $Id: tstSeamlessX11.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * Linux seamless guest additions simulator in host.
4 */
5
6/*
7 * Copyright (C) 2007-2019 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 <stdlib.h> /* exit() */
19
20#include <iprt/errcore.h>
21#include <iprt/initterm.h>
22#include <iprt/semaphore.h>
23#include <iprt/stream.h>
24#include <VBox/VBoxGuestLib.h>
25
26#include "../seamless.h"
27
28static RTSEMEVENT eventSem;
29
30/** Exit with a fatal error. */
31void vbclFatalError(char *pszMessage)
32{
33 RTPrintf("Fatal error: %s", pszMessage);
34 exit(1);
35}
36
37int VBClStartVTMonitor()
38{
39 return VINF_SUCCESS;
40}
41
42int VbglR3SeamlessSendRects(uint32_t cRects, PRTRECT pRects)
43{
44 RTPrintf("Received rectangle update (%u rectangles):\n", cRects);
45 for (unsigned i = 0; i < cRects; ++i)
46 {
47 RTPrintf(" xLeft: %d yTop: %d xRight: %d yBottom: %d\n",
48 pRects[i].xLeft, pRects[i].yTop, pRects[i].xRight,
49 pRects[i].yBottom);
50 }
51 return VINF_SUCCESS;
52}
53
54int VbglR3SeamlessSetCap(bool bState)
55{
56 RTPrintf("%s\n", bState ? "Seamless capability set"
57 : "Seamless capability unset");
58 return VINF_SUCCESS;
59}
60
61int VbglR3CtlFilterMask(uint32_t u32OrMask, uint32_t u32NotMask)
62{
63 RTPrintf("IRQ filter mask changed. Or mask: 0x%x. Not mask: 0x%x\n",
64 u32OrMask, u32NotMask);
65 return VINF_SUCCESS;
66}
67
68int VbglR3SeamlessWaitEvent(VMMDevSeamlessMode *pMode)
69{
70 static bool active = false;
71
72 int rc = VINF_SUCCESS;
73 if (!active)
74 {
75 active = true;
76 *pMode = VMMDev_Seamless_Visible_Region;
77 }
78 else
79 rc = RTSemEventWait(eventSem, RT_INDEFINITE_WAIT);
80 return rc;
81}
82
83VBGLR3DECL(int) VbglR3InitUser(void) { return VINF_SUCCESS; }
84VBGLR3DECL(void) VbglR3Term(void) {}
85
86/**
87 * Xlib error handler for certain errors that we can't avoid.
88 */
89int vboxClientXLibErrorHandler(Display *pDisplay, XErrorEvent *pError)
90{
91 char errorText[1024];
92
93 if (pError->error_code == BadWindow)
94 {
95 /* This can be triggered if a guest application destroys a window before we notice. */
96 RTPrintf("ignoring BadAtom error and returning\n");
97 return 0;
98 }
99 XGetErrorText(pDisplay, pError->error_code, errorText, sizeof(errorText));
100 RTPrintf("An X Window protocol error occurred: %s\n"
101 " Request code: %d\n"
102 " Minor code: %d\n"
103 " Serial number of the failed request: %d\n\n"
104 "exiting.\n",
105 errorText, (int)pError->request_code, (int)pError->minor_code,
106 (int)pError->serial);
107 exit(1);
108}
109
110int main( int argc, char **argv)
111{
112 int rc = VINF_SUCCESS;
113
114 RTR3InitExe(argc, &argv, 0);
115 RTPrintf("VirtualBox guest additions X11 seamless mode testcase\n");
116 if (0 == XInitThreads())
117 {
118 RTPrintf("Failed to initialise X11 threading, exiting.\n");
119 exit(1);
120 }
121 /* Set an X11 error handler, so that we don't die when we get unavoidable errors. */
122 XSetErrorHandler(vboxClientXLibErrorHandler);
123 RTPrintf("\nType Ctrl-C to exit...\n");
124 RTSemEventCreate(&eventSem);
125 /** Our instance of the seamless class. */
126 SeamlessMain seamless;
127 LogRel(("Starting seamless Guest Additions...\n"));
128 rc = seamless.init();
129 if (rc != VINF_SUCCESS)
130 {
131 RTPrintf("Failed to initialise seamless Additions, rc = %Rrc\n", rc);
132 }
133 rc = seamless.run();
134 if (rc != VINF_SUCCESS)
135 {
136 RTPrintf("Failed to run seamless Additions, rc = %Rrc\n", rc);
137 }
138 return rc;
139}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette