[55401] | 1 | /* $Id: seamless.cpp 100063 2023-06-03 17:42:36Z vboxsync $ */
|
---|
[6202] | 2 | /** @file
|
---|
[99600] | 3 | * Guest Additions - Common seamless mode wrapper service.
|
---|
[6202] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[6202] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[6202] | 26 | */
|
---|
| 27 |
|
---|
[50337] | 28 |
|
---|
[57358] | 29 | /*********************************************************************************************************************************
|
---|
| 30 | * Header files *
|
---|
| 31 | *********************************************************************************************************************************/
|
---|
[86871] | 32 | #include <new>
|
---|
| 33 |
|
---|
[50337] | 34 | #include <X11/Xlib.h>
|
---|
| 35 |
|
---|
[86871] | 36 | #include <iprt/asm.h>
|
---|
[76474] | 37 | #include <iprt/errcore.h>
|
---|
[52562] | 38 | #include <iprt/mem.h>
|
---|
[6202] | 39 |
|
---|
[86871] | 40 | #include <VBox/log.h>
|
---|
| 41 | #include <VBox/VBoxGuestLib.h>
|
---|
| 42 |
|
---|
[50337] | 43 | #include "VBoxClient.h"
|
---|
[50338] | 44 | #include "seamless.h"
|
---|
[6202] | 45 |
|
---|
[52562] | 46 |
|
---|
[86871] | 47 | /*********************************************************************************************************************************
|
---|
| 48 | * Global Variables *
|
---|
| 49 | *********************************************************************************************************************************/
|
---|
| 50 |
|
---|
[99600] | 51 | /** Pointer to the DnD interface class. */
|
---|
| 52 | static VBClSeamlessSvc *g_pSvc = NULL;
|
---|
[86871] | 53 |
|
---|
| 54 |
|
---|
[99600] | 55 | /*********************************************************************************************************************************
|
---|
| 56 | * Common functions *
|
---|
| 57 | *********************************************************************************************************************************/
|
---|
[86871] | 58 |
|
---|
[6202] | 59 | /**
|
---|
[99600] | 60 | * Reports region updates to the host.
|
---|
| 61 | *
|
---|
| 62 | * @param pRects Pointer to array of regions to report.
|
---|
| 63 | * @param cRects Number of regions in \a pRect.
|
---|
[52564] | 64 | */
|
---|
[99601] | 65 | void VBClSeamlessSendRegionUpdate(RTRECT *pRects, size_t cRects)
|
---|
[52564] | 66 | {
|
---|
[86871] | 67 | if ( cRects
|
---|
| 68 | && !pRects) /* Assertion */
|
---|
[52564] | 69 | {
|
---|
[86871] | 70 | VBClLogError(("Region update called with NULL pointer\n"));
|
---|
[52564] | 71 | return;
|
---|
| 72 | }
|
---|
| 73 | VbglR3SeamlessSendRects(cRects, pRects);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[6202] | 76 |
|
---|
[99600] | 77 | /*********************************************************************************************************************************
|
---|
| 78 | * Service wrapper *
|
---|
| 79 | *********************************************************************************************************************************/
|
---|
[86871] | 80 |
|
---|
[6202] | 81 | /**
|
---|
[99600] | 82 | * @interface_method_impl{VBCLSERVICE,pfnInit}
|
---|
[6202] | 83 | */
|
---|
[99600] | 84 | static DECLCALLBACK(int) vbclSeamlessInit(void)
|
---|
[6202] | 85 | {
|
---|
[99620] | 86 | switch (VBClGetDisplayServerType())
|
---|
[6202] | 87 | {
|
---|
[99620] | 88 | case VBGHDISPLAYSERVERTYPE_X11:
|
---|
[99600] | 89 | g_pSvc = new VBClX11SeamlessSvc();
|
---|
| 90 | break;
|
---|
[86871] | 91 |
|
---|
[100063] | 92 | case VBGHDISPLAYSERVERTYPE_PURE_WAYLAND:
|
---|
[99600] | 93 | RT_FALL_THROUGH();
|
---|
| 94 | default:
|
---|
| 95 | return VERR_NOT_SUPPORTED;
|
---|
[6202] | 96 | }
|
---|
[86871] | 97 |
|
---|
[99600] | 98 | if (!g_pSvc)
|
---|
| 99 | return VERR_NO_MEMORY;
|
---|
[86871] | 100 |
|
---|
[99600] | 101 | return g_pSvc->init();
|
---|
[6202] | 102 | }
|
---|
[50336] | 103 |
|
---|
| 104 | /**
|
---|
[86873] | 105 | * @interface_method_impl{VBCLSERVICE,pfnWorker}
|
---|
| 106 | */
|
---|
| 107 | static DECLCALLBACK(int) vbclSeamlessWorker(bool volatile *pfShutdown)
|
---|
[52562] | 108 | {
|
---|
[99603] | 109 | AssertPtrReturn(g_pSvc, VERR_NOT_IMPLEMENTED);
|
---|
[99600] | 110 | return g_pSvc->worker(pfShutdown);
|
---|
[52562] | 111 | }
|
---|
| 112 |
|
---|
[86873] | 113 | /**
|
---|
| 114 | * @interface_method_impl{VBCLSERVICE,pfnStop}
|
---|
| 115 | */
|
---|
| 116 | static DECLCALLBACK(void) vbclSeamlessStop(void)
|
---|
[52562] | 117 | {
|
---|
[99603] | 118 | if (g_pSvc)
|
---|
| 119 | g_pSvc->stop();
|
---|
[52562] | 120 | }
|
---|
| 121 |
|
---|
[86873] | 122 | /**
|
---|
| 123 | * @interface_method_impl{VBCLSERVICE,pfnTerm}
|
---|
| 124 | */
|
---|
| 125 | static DECLCALLBACK(int) vbclSeamlessTerm(void)
|
---|
[52562] | 126 | {
|
---|
[99600] | 127 | int rc = VINF_SUCCESS;
|
---|
| 128 |
|
---|
| 129 | if (g_pSvc)
|
---|
| 130 | {
|
---|
| 131 | rc = g_pSvc->term();
|
---|
| 132 |
|
---|
| 133 | delete g_pSvc;
|
---|
| 134 | g_pSvc = NULL;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | return rc;
|
---|
[52562] | 138 | }
|
---|
| 139 |
|
---|
[86871] | 140 | VBCLSERVICE g_SvcSeamless =
|
---|
[52562] | 141 | {
|
---|
[86871] | 142 | "seamless", /* szName */
|
---|
| 143 | "Seamless Mode Support", /* pszDescription */
|
---|
[98474] | 144 | ".vboxclient-seamless", /* pszPidFilePathTemplate */
|
---|
[86871] | 145 | NULL, /* pszUsage */
|
---|
| 146 | NULL, /* pszOptions */
|
---|
| 147 | NULL, /* pfnOption */
|
---|
| 148 | vbclSeamlessInit, /* pfnInit */
|
---|
| 149 | vbclSeamlessWorker, /* pfnWorker */
|
---|
| 150 | vbclSeamlessStop, /* pfnStop*/
|
---|
| 151 | vbclSeamlessTerm /* pfnTerm */
|
---|
[50337] | 152 | };
|
---|
| 153 |
|
---|