VirtualBox

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

Last change on this file since 68444 was 67796, checked in by vboxsync, 8 years ago

bugref:8524: Additions/linux: play nicely with distribution-installed Additions
Remove old VbglR3InterruptEventWaits() leftover from seamless.cpp.

Since the VbglR3InterruptEventWaits() API in VBoxGuest is rather clumsy, we
decided to forbid use of VbglR3WaitEvent() in a VBoxGuest session after
VbglR3InterruptEventWaits() has been called. This change removes the last
use of it (there were only two in the whole tree) which conflicts with that:
a sanity test in seamless.cpp which is testing something no longer relevant
in the current code.

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