Skip to content

Commit fefabdd

Browse files
committed
VBoxClient,GuestHost: Implemented the wayland support in the --clipboard service using the guest/host bits, refactoring the gtk subprocess handling a bit. The --wayland service remains the same. bugref:10194
svn:sync-xref-src-repo-rev: r174575
1 parent 94229dc commit fefabdd

21 files changed

Lines changed: 1344 additions & 450 deletions

include/VBox/GuestHost/SharedClipboard-Wayland.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** $Id: SharedClipboard-Wayland.h 114620 2026-07-04 00:00:20Z knut.osmundsen@oracle.com $ */
1+
/** $Id: SharedClipboard-Wayland.h 114738 2026-07-21 13:40:26Z knut.osmundsen@oracle.com $ */
22
/** @file
33
* Shared Clipboard - Common Wayland code.
44
*/
@@ -236,7 +236,7 @@ typedef struct SHCLWAYLANDCTX
236236
* @param cbData Size returned by pfnQueryRemoteData.
237237
* @note May be called both inside and outside the critical section.
238238
*/
239-
DECLCALLBACKMEMBER(int, pfnQueryRemoteDataFree, (struct SHCLWAYLANDCTX *pWlCtx, void *pvData, size_t cbData));
239+
DECLCALLBACKMEMBER(void, pfnQueryRemoteDataFree, (struct SHCLWAYLANDCTX *pWlCtx, void *pvData, size_t cbData));
240240

241241
/** The popup for use with the wl_data_device_manager protocol. */
242242
VBGHWAYLANDPOPUP Popup;
@@ -265,8 +265,8 @@ VBGH_DECL(void) VbghWaylandClipboardPartialTerm(PSHCLWAYLANDCTX pThis);
265265
VBGH_DECL(int) VbghWaylandClipboardOfferAddMimeType(SHCLWLOFFERSLOT *pOfferSlot, const char *pszMimeType,
266266
const char *pszCaller);
267267

268-
VBGH_DECL(int) VbghlWaylandClipboardQueryRemoteData(PSHCLWAYLANDCTX pThis, const char *pszMimeType,
269-
void **ppvOutData, size_t *pcbOutData);
268+
VBGH_DECL(int) VbghWaylandClipboardQueryRemoteData(PSHCLWAYLANDCTX pThis, const char *pszMimeType,
269+
void **ppvOutData, size_t *pcbOutData);
270270
VBGH_DECL(int) VbghWaylandClipboardMakeDataOffering(PSHCLWAYLANDCTX pThis, const char *pszPopupTitle,
271271
const char *pszPopupClass, PRTERRINFO pErrInfo);
272272

include/VBox/GuestHost/Wayland.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: Wayland.h 114620 2026-07-04 00:00:20Z knut.osmundsen@oracle.com $ */
1+
/* $Id: Wayland.h 114738 2026-07-21 13:40:26Z knut.osmundsen@oracle.com $ */
22
/** @file
33
* Guest / Host common code - Wayland.
44
*/
@@ -155,8 +155,23 @@ VBGH_DECL(int) VbghWaylandReadFdToBuffer(int fd, RTMSINTERVAL cMsTi
155155
VBGH_DECL(void) VbghWaylandReadFdToBufferFree(void *pvBuf);
156156
VBGH_DECL(int) VbghWaylandWriteBufferToFd(void const *pvBuf, size_t cbBuf, int fdDst, RTMSINTERVAL cMsTimeout);
157157

158-
VBGH_DECL(int) VbghWaylandRunloopForDisplay(struct wl_display *pDisplay, RTPIPE hPipeWakeup, RTPIPE hPipeMonClose,
159-
RTMSINTERVAL cMsPollInterval, bool volatile *pfReturn);
158+
/**
159+
* Callback for servicing the VbghWaylandRunloopForDisplay wakeup pipe.
160+
*
161+
* @returns VBox status code. Any failure status leads to the pipe being
162+
* excluded from the poll.
163+
* @param hPipe The wakeup pipe (read).
164+
* @param pfReturn The return indicator, if given.
165+
* @param pvUser User argument.
166+
*/
167+
typedef DECLCALLBACKTYPE(int, FNVBGHWAYLANDRLWAKEUPPIPE,(RTPIPE hPipe, bool volatile *pfReturn, void *pvUser));
168+
/** Pointer to a FNVBGHWAYLANDRLWAKEUPPIPE function. */
169+
typedef FNVBGHWAYLANDRLWAKEUPPIPE *PFNVBGHWAYLANDRLWAKEUPPIPE;
170+
171+
VBGH_DECL(int) VbghWaylandRunloopForDisplay(struct wl_display *pDisplay, RTPIPE hPipeWakeup,
172+
PFNVBGHWAYLANDRLWAKEUPPIPE pfnWakeup, void *pvWakeupUser,
173+
RTPIPE hPipeMonClose, RTMSINTERVAL cMsPollInterval,
174+
bool volatile *pfReturn);
160175

161176
RT_C_DECLS_END
162177

include/VBox/GuestHost/WaylandPopup.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: WaylandPopup.h 114622 2026-07-04 00:18:59Z knut.osmundsen@oracle.com $ */
1+
/* $Id: WaylandPopup.h 114738 2026-07-21 13:40:26Z knut.osmundsen@oracle.com $ */
22
/** @file
33
* Guest / Host common code - Wayland Popup (for focus grabbing).
44
*/
@@ -147,6 +147,11 @@ VBGH_DECL(int) VbghWaylandPopupShow(PVBGHWAYLANDPOPUP pThis, struct VBGHWAYLAND
147147
const char *pszTitle, const char *pszClassOrId,
148148
PFNVBGHWAYLANDPOPUPONFOCUS pfnOnFocus, uint64_t u64OnFocusUser, PRTERRINFO pErrInfo);
149149

150+
struct RTPROCSTATUS;
151+
VBGH_DECL(int) VbghWaylandPopupTerminateAndWaitForChild(RTPROCESS hProcess, const char *pszProcName,
152+
RTMSINTERVAL cMsWaitBeforeKill, RTMSINTERVAL cMsWaitBetweenKills,
153+
unsigned cKills, struct RTPROCSTATUS *pProcStatus);
154+
150155
RT_C_DECLS_END
151156

152157
#endif /* !VBOX_INCLUDED_GuestHost_WaylandPopup_h */

src/VBox/Additions/x11/VBoxClient/Makefile.kmk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: Makefile.kmk 114575 2026-06-30 15:58:06Z andreas.loeffler@oracle.com $
1+
# $Id: Makefile.kmk 114738 2026-07-21 13:40:26Z knut.osmundsen@oracle.com $
22
## @file
33
# Sub-Makefile for the VirtualBox Guest Addition X11 Client.
44
#
@@ -177,6 +177,9 @@ ifdef VBOX_WITH_SHARED_CLIPBOARD
177177
VBoxClient_INCS.linux += . ../wlInclude/
178178
VBoxClient_SOURCES.linux += \
179179
clipboard-cmds.cpp \
180+
clipboard-wayland.cpp \
181+
clipboard-wayland-popup.cpp \
182+
host-input-focus.cpp \
180183
wayland-helper-xdcp-common.cpp \
181184
$(VBoxClient_0_OUTDIR)/wayland-helper-dcp.cpp \
182185
wayland-helper-edcp.cpp \

src/VBox/Additions/x11/VBoxClient/VBoxClient.h

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: VBoxClient.h 114620 2026-07-04 00:00:20Z knut.osmundsen@oracle.com $ */
1+
/* $Id: VBoxClient.h 114738 2026-07-21 13:40:26Z knut.osmundsen@oracle.com $ */
22
/** @file
33
*
44
* VirtualBox additions user session daemon.
@@ -69,6 +69,40 @@ extern VBGHDISPLAYSERVERTYPE VBClGetDisplayServerType(void);
6969
extern VBGHDISPLAYSERVERTYPE VBClGetDisplayServerTypeResolveAuto(void);
7070
extern int VBClExplicitLoadClientLibrariesForDisplayServer(VBGHDISPLAYSERVERTYPE enmType, bool fXWaylandAsPureWayland);
7171

72+
#ifdef IPRT_INCLUDED_thread_h
73+
extern int VBClStartThread(PRTTHREAD phThread, PFNRTTHREAD pfnThread, const char *pszName, void *pvUser);
74+
#endif
75+
76+
#ifdef VBOX_INCLUDED_VBoxGuestLibGuestProp_h
77+
/** Host input focus monitor state. */
78+
typedef struct VBCLHOSTINPUTFOCUSSTATE
79+
{
80+
/** @name User Settable Properties.
81+
* @{ */
82+
DECLCALLBACKMEMBER(bool, pfnFocusEnter,(struct VBCLHOSTINPUTFOCUSSTATE *pThis));
83+
DECLCALLBACKMEMBER(bool, pfnFocusExit,(struct VBCLHOSTINPUTFOCUSSTATE *pThis));
84+
bool volatile *pfShutdown;
85+
void *pvUser;
86+
/** @} */
87+
88+
/** @name Internal
89+
* @{ */
90+
RTTHREAD hThread;
91+
VBGLGSTPROPCLIENT GuestPropClient;
92+
bool volatile fShutdownInternal;
93+
/** @} */
94+
} VBCLHOSTINPUTFOCUSSTATE;
95+
#else
96+
struct VBCLHOSTINPUTFOCUSSTATE;
97+
#endif
98+
/** Pointer to host input focus monitor state. */
99+
typedef struct VBCLHOSTINPUTFOCUSSTATE *PVBCLHOSTINPUTFOCUSSTATE;
100+
101+
void VBClHostInputFocusMonitorInit(PVBCLHOSTINPUTFOCUSSTATE pState);
102+
int VBClHostInputFocusMonitorStart(PVBCLHOSTINPUTFOCUSSTATE pState, const char *pszThreadName);
103+
void VBClHostInputFocusMonitorStop(PVBCLHOSTINPUTFOCUSSTATE pState);
104+
int VBClHostInputFocusMonitorTerm(PVBCLHOSTINPUTFOCUSSTATE pState);
105+
72106
struct RTGETOPTSTATE;
73107

74108
/**

src/VBox/Additions/x11/VBoxClient/clipboard-cmds.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** $Id: clipboard-cmds.cpp 114623 2026-07-04 00:21:08Z knut.osmundsen@oracle.com $ */
1+
/** $Id: clipboard-cmds.cpp 114738 2026-07-21 13:40:26Z knut.osmundsen@oracle.com $ */
22
/** @file
33
* Guest Additions - Clipboard commands.
44
*/
@@ -627,7 +627,7 @@ static DECLCALLBACK(RTEXITCODE) vbclCmdClipboardGet(void)
627627
VBClLogError("VbghWaylandPopupShow failed: %Rrc%#RTeim\n", rc, &ErrInfo.Core);
628628
}
629629

630-
VbghWaylandRunloopForDisplay(State.Wl.GhCore.pDisplay, State.hPipeRead, NIL_RTPIPE,
630+
VbghWaylandRunloopForDisplay(State.Wl.GhCore.pDisplay, State.hPipeRead, NULL, NULL, NIL_RTPIPE,
631631
RT_SUCCESS(rc) ? RT_MS_5SEC : RT_MS_1SEC, &State.fShutdown);
632632

633633
VBClLogVerbose(2, "done (rcExit=%d).\n", State.rcExit);
@@ -760,7 +760,7 @@ static DECLCALLBACK(RTEXITCODE) vbclCmdClipboardSet(void)
760760
RTErrInfoInitStatic(&ErrInfo));
761761
if (RT_SUCCESS(rc))
762762
{
763-
VbghWaylandRunloopForDisplay(State.Wl.GhCore.pDisplay, State.hPipeRead, g_hPipeTerm,
763+
VbghWaylandRunloopForDisplay(State.Wl.GhCore.pDisplay, State.hPipeRead, NULL, NULL, g_hPipeTerm,
764764
RT_SUCCESS(rc) ? RT_MS_5SEC : RT_MS_1SEC, &State.fShutdown);
765765

766766
VBClLogVerbose(2, "done (rcExit=%d).\n", State.rcExit);

0 commit comments

Comments
 (0)