2014-03-11 16:11:39 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2011-2014 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software
|
|
|
|
|
* and its documentation for any purpose is hereby granted without
|
|
|
|
|
* fee, provided that the above copyright notice appear in all copies
|
|
|
|
|
* and that both that copyright notice and this permission notice
|
|
|
|
|
* appear in supporting documentation, and that the name of the
|
|
|
|
|
* copyright holders not be used in advertising or publicity
|
|
|
|
|
* pertaining to distribution of the software without specific,
|
|
|
|
|
* written prior permission. The copyright holders make no
|
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
|
* warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
|
|
|
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-12-18 15:00:11 +01:00
|
|
|
#include <xwayland-config.h>
|
|
|
|
|
|
2022-01-13 09:07:57 +01:00
|
|
|
#if !defined(SYSV) && !defined(WIN32)
|
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
#include <stdio.h>
|
2022-01-13 09:07:57 +01:00
|
|
|
#include <errno.h>
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2016-11-23 13:30:53 +02:00
|
|
|
#include <X11/Xatom.h>
|
2024-03-01 13:47:23 +01:00
|
|
|
|
2024-03-07 14:39:50 +01:00
|
|
|
#include "dix/dix_priv.h"
|
2024-03-01 13:47:23 +01:00
|
|
|
#include "dix/screenint_priv.h"
|
2024-02-23 20:52:02 +01:00
|
|
|
#include "os/cmdline.h"
|
2024-02-23 17:26:57 +01:00
|
|
|
#include "os/osdep.h"
|
2024-03-01 13:47:23 +01:00
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
#include <selection.h>
|
|
|
|
|
#include <micmap.h>
|
|
|
|
|
#include <misyncshm.h>
|
|
|
|
|
#include <compositeext.h>
|
2018-01-25 13:43:09 +01:00
|
|
|
#include <compint.h>
|
2014-03-11 16:11:39 -07:00
|
|
|
#include <glx_extinit.h>
|
2022-01-13 09:07:57 +01:00
|
|
|
#include <opaque.h>
|
2016-05-24 18:46:42 +08:00
|
|
|
#include <os.h>
|
xwayland: handle EAGAIN on Wayland fd
wl_display_flush() can fail with EAGAIN and Xwayland would make this a
fatal error.
When this happens, it means that Xwayland has flooded the Wayland file
descriptor, either because the Wayland compositor cannot cope or more
likely because of a deadlock situation where the Wayland compositor is
blocking, waiting for an X reply while Xwayland tries to write data to
the Wayland file descriptor.
The general consensus to avoid the deadlock is for the Wayland
compositor to never issue blocking X11 roundtrips, but in practice
blocking rountrips can occur in various places, including Xlib calls
themselves so this is not always achievable without major surgery in the
Wayland compositor/Window manager.
What this patch does is to avoid dispatching to the Wayland file
descriptor until it becomes available for writing again, while at the
same time continue processing X11 requests to release the deadlock.
This is not perfect, as there is still the possibility of another X
client hammering the connection and we'll still fail writing to the
Wayland connection eventually, but this improves things enough to avoid
a 100% repeatable crash with vlc and gtkperf.
Also, it is worth considering that window managers and Wayland
compositors such as mutter already have a higher priority than other
regular X clients thanks to XSyncSetPriority(), mitigating the risk.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1278159
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=763400
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-09-15 15:59:07 +02:00
|
|
|
#include <xserver_poll.h>
|
2016-11-23 13:30:53 +02:00
|
|
|
#include <propertyst.h>
|
2020-02-14 15:20:59 +01:00
|
|
|
#include <version-config.h>
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2024-02-28 19:06:00 +01:00
|
|
|
#include "os/auth.h"
|
|
|
|
|
|
2019-12-18 10:03:43 +01:00
|
|
|
#include "xwayland-screen.h"
|
2019-12-18 11:18:22 +01:00
|
|
|
#include "xwayland-vidmode.h"
|
2019-12-16 17:07:02 +01:00
|
|
|
|
2016-02-10 09:35:39 +01:00
|
|
|
#ifdef XF86VIDMODE
|
|
|
|
|
#include <X11/extensions/xf86vmproto.h>
|
2020-01-24 12:49:44 +01:00
|
|
|
extern _X_EXPORT Bool noXFree86VidModeExtension;
|
2016-02-10 09:35:39 +01:00
|
|
|
#endif
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
void
|
|
|
|
|
ddxGiveUp(enum ExitCode error)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OsVendorInit(void)
|
|
|
|
|
{
|
2016-07-08 15:17:05 -04:00
|
|
|
if (serverGeneration == 1)
|
|
|
|
|
ForceClockId(CLOCK_MONOTONIC);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OsVendorFatalError(const char *f, va_list args)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(DDXBEFORERESET)
|
|
|
|
|
void
|
|
|
|
|
ddxBeforeReset(void)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-02-21 15:22:57 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if INPUTTHREAD
|
|
|
|
|
/** This function is called in Xserver/os/inputthread.c when starting
|
|
|
|
|
the input thread. */
|
|
|
|
|
void
|
|
|
|
|
ddxInputThreadInit(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ddxUseMsg(void)
|
|
|
|
|
{
|
|
|
|
|
ErrorF("-rootless run rootless, requires wm support\n");
|
2022-05-12 12:04:29 +02:00
|
|
|
ErrorF("-fullscreen run fullscreen when rootful\n");
|
2022-04-26 15:28:50 +02:00
|
|
|
ErrorF("-geometry WxH set Xwayland window size when rootful\n");
|
2023-11-02 11:04:18 +01:00
|
|
|
ErrorF("-hidpi adjust to output scale when rootful\n");
|
2022-04-28 12:26:49 +02:00
|
|
|
ErrorF("-host-grab disable host keyboard shortcuts when rootful\n");
|
2024-01-12 09:37:58 +01:00
|
|
|
ErrorF("-nokeymap ignore keymap from the Wayland compositor\n");
|
2023-12-04 16:31:14 +01:00
|
|
|
ErrorF("-output specify which output to use for fullscreen when rootful\n");
|
2014-03-11 16:11:39 -07:00
|
|
|
ErrorF("-wm fd create X client for wm on given fd\n");
|
2019-07-20 00:16:43 +02:00
|
|
|
ErrorF("-initfd fd add given fd as a listen socket for initialization clients\n");
|
|
|
|
|
ErrorF("-listenfd fd add given fd as a listen socket\n");
|
2019-06-19 09:19:24 +02:00
|
|
|
ErrorF("-listen fd deprecated, use \"-listenfd\" instead\n");
|
2020-11-10 09:53:57 +01:00
|
|
|
ErrorF("-shm use shared memory for passing buffers\n");
|
2023-10-30 14:25:43 +03:00
|
|
|
#ifdef XWL_HAS_GLAMOR
|
|
|
|
|
ErrorF("-glamor [gl|es|off] use given API for Glamor acceleration. Incompatible with -shm option\n");
|
|
|
|
|
#endif
|
2021-01-27 12:37:51 +00:00
|
|
|
ErrorF("-verbose [n] verbose startup messages\n");
|
2020-02-14 15:20:59 +01:00
|
|
|
ErrorF("-version show the server version and exit\n");
|
2021-06-18 11:04:45 +02:00
|
|
|
ErrorF("-noTouchPointerEmulation disable touch pointer emulation\n");
|
2022-05-12 11:16:13 +00:00
|
|
|
ErrorF("-force-xrandr-emulation force non-native modes to be exposed when viewporter is not exposed by the compositor\n");
|
2022-05-04 14:42:41 +02:00
|
|
|
#ifdef XWL_HAS_LIBDECOR
|
2023-07-17 10:00:06 +02:00
|
|
|
ErrorF("-decorate add decorations to Xwayland when rootful\n");
|
2022-05-04 14:42:41 +02:00
|
|
|
#endif
|
2023-09-29 10:19:13 +02:00
|
|
|
#ifdef XWL_HAS_EI_PORTAL
|
|
|
|
|
ErrorF("-enable-ei-portal use the XDG portal for input emulation\n");
|
|
|
|
|
#endif
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2019-07-20 00:16:43 +02:00
|
|
|
static int init_fd = -1;
|
2018-10-23 14:33:24 -04:00
|
|
|
static int wm_fd = -1;
|
|
|
|
|
static int listen_fds[5] = { -1, -1, -1, -1, -1 };
|
2019-01-02 21:55:23 +01:00
|
|
|
static int listen_fd_count = 0;
|
2021-01-27 12:37:51 +00:00
|
|
|
static int verbosity = 0;
|
2018-10-23 14:33:24 -04:00
|
|
|
|
2020-02-14 15:20:59 +01:00
|
|
|
static void
|
|
|
|
|
xwl_show_version(void)
|
|
|
|
|
{
|
|
|
|
|
ErrorF("%s Xwayland %s (%d)\n", VENDOR_NAME, VENDOR_MAN_VERSION, VENDOR_RELEASE);
|
|
|
|
|
ErrorF("X Protocol Version %d, Revision %d\n", X_PROTOCOL, X_PROTOCOL_REVISION);
|
|
|
|
|
#if defined(BUILDERSTRING)
|
|
|
|
|
if (strlen(BUILDERSTRING))
|
|
|
|
|
ErrorF("%s\n", BUILDERSTRING);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 09:07:57 +01:00
|
|
|
static void
|
|
|
|
|
try_raising_nofile_limit(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef RLIMIT_NOFILE
|
|
|
|
|
struct rlimit rlim;
|
|
|
|
|
|
|
|
|
|
/* Only fiddle with the limit if not set explicitly from the command line */
|
|
|
|
|
if (limitNoFile >= 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
|
|
|
|
ErrorF("Failed to get the current nofile limit: %s\n", strerror(errno));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max;
|
|
|
|
|
|
|
|
|
|
if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
|
|
|
|
ErrorF("Failed to set the current nofile limit: %s\n", strerror(errno));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-06 14:10:23 +01:00
|
|
|
LogMessageVerb(X_INFO, 3, "Raising the file descriptors limit to %llu\n",
|
|
|
|
|
(long long unsigned int) rlim.rlim_max);
|
|
|
|
|
#endif /* RLIMIT_NOFILE */
|
2022-01-13 09:07:57 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-19 09:19:24 +02:00
|
|
|
static void
|
|
|
|
|
xwl_add_listen_fd(int argc, char *argv[], int i)
|
|
|
|
|
{
|
|
|
|
|
NoListenAll = TRUE;
|
|
|
|
|
if (listen_fd_count == ARRAY_SIZE(listen_fds))
|
|
|
|
|
FatalError("Too many -listen arguments given, max is %zu\n",
|
|
|
|
|
ARRAY_SIZE(listen_fds));
|
|
|
|
|
|
|
|
|
|
listen_fds[listen_fd_count++] = atoi(argv[i + 1]);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
int
|
|
|
|
|
ddxProcessArgument(int argc, char *argv[], int i)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(argv[i], "-rootless") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(argv[i], "-listen") == 0) {
|
2018-10-23 14:33:24 -04:00
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
|
|
|
|
|
2019-06-18 10:41:02 +02:00
|
|
|
/* Not an FD */
|
|
|
|
|
if (!isdigit(*argv[i + 1]))
|
|
|
|
|
return 0;
|
|
|
|
|
|
2020-12-02 12:29:15 +01:00
|
|
|
LogMessageVerb(X_WARNING, 0, "Option \"-listen\" for file descriptors is deprecated\n"
|
|
|
|
|
"Please use \"-listenfd\" instead.\n");
|
2019-06-19 09:19:24 +02:00
|
|
|
|
|
|
|
|
xwl_add_listen_fd (argc, argv, i);
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(argv[i], "-listenfd") == 0) {
|
|
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
2018-10-23 14:33:24 -04:00
|
|
|
|
2019-06-19 09:19:24 +02:00
|
|
|
xwl_add_listen_fd (argc, argv, i);
|
2014-03-11 16:11:39 -07:00
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp(argv[i], "-wm") == 0) {
|
2018-10-23 14:33:24 -04:00
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
|
|
|
|
wm_fd = atoi(argv[i + 1]);
|
2014-03-11 16:11:39 -07:00
|
|
|
return 2;
|
|
|
|
|
}
|
2019-07-20 00:16:43 +02:00
|
|
|
else if (strcmp(argv[i], "-initfd") == 0) {
|
|
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
|
|
|
|
init_fd = atoi(argv[i + 1]);
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
else if (strcmp(argv[i], "-shm") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2023-10-30 14:25:43 +03:00
|
|
|
#ifdef XWL_HAS_GLAMOR
|
|
|
|
|
else if (strcmp(argv[i], "-glamor") == 0) {
|
|
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
|
|
|
|
/* Only check here, actual work inside xwayland-screen.c */
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2021-01-27 12:37:51 +00:00
|
|
|
else if (strcmp(argv[i], "-verbose") == 0) {
|
|
|
|
|
if (++i < argc && argv[i]) {
|
|
|
|
|
char *end;
|
|
|
|
|
long val;
|
|
|
|
|
|
|
|
|
|
val = strtol(argv[i], &end, 0);
|
|
|
|
|
if (*end == '\0') {
|
|
|
|
|
verbosity = val;
|
|
|
|
|
LogSetParameter(XLOG_VERBOSITY, verbosity);
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LogSetParameter(XLOG_VERBOSITY, ++verbosity);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2020-02-14 15:20:59 +01:00
|
|
|
else if (strcmp(argv[i], "-version") == 0) {
|
|
|
|
|
xwl_show_version();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
2021-06-18 11:04:45 +02:00
|
|
|
else if (strcmp(argv[i], "-noTouchPointerEmulation") == 0) {
|
|
|
|
|
touchEmulatePointer = FALSE;
|
2021-10-22 18:19:48 +02:00
|
|
|
return 1;
|
2021-06-18 11:04:45 +02:00
|
|
|
}
|
2022-07-26 10:55:49 +02:00
|
|
|
else if (strcmp(argv[i], "-force-xrandr-emulation") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2022-04-26 15:28:50 +02:00
|
|
|
else if (strcmp(argv[i], "-geometry") == 0) {
|
|
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
2022-05-12 12:04:29 +02:00
|
|
|
else if (strcmp(argv[i], "-fullscreen") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2022-04-28 12:26:49 +02:00
|
|
|
else if (strcmp(argv[i], "-host-grab") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2022-05-04 14:42:41 +02:00
|
|
|
else if (strcmp(argv[i], "-decorate") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2023-09-29 10:19:13 +02:00
|
|
|
else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2023-12-04 16:31:14 +01:00
|
|
|
else if (strcmp(argv[i], "-output") == 0) {
|
|
|
|
|
CHECK_FOR_REQUIRED_ARGUMENTS(1);
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
2024-01-12 09:37:58 +01:00
|
|
|
else if (strcmp(argv[i], "-nokeymap") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2023-11-02 11:04:18 +01:00
|
|
|
else if (strcmp(argv[i], "-hidpi") == 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CARD32
|
|
|
|
|
add_client_fd(OsTimerPtr timer, CARD32 time, void *arg)
|
|
|
|
|
{
|
2018-10-23 14:33:24 -04:00
|
|
|
if (!AddClientOnOpenFD(wm_fd))
|
2014-03-11 16:11:39 -07:00
|
|
|
FatalError("Failed to add wm client\n");
|
|
|
|
|
|
|
|
|
|
TimerFree(timer);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-23 14:33:24 -04:00
|
|
|
listen_on_fds(void)
|
2014-03-11 16:11:39 -07:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2018-10-23 14:33:24 -04:00
|
|
|
for (i = 0; i < listen_fd_count; i++)
|
|
|
|
|
ListenOnOpenFD(listen_fds[i], FALSE);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
wm_selection_callback(CallbackListPtr *p, void *data, void *arg)
|
|
|
|
|
{
|
|
|
|
|
SelectionInfoRec *info = arg;
|
|
|
|
|
struct xwl_screen *xwl_screen = data;
|
|
|
|
|
static const char atom_name[] = "WM_S0";
|
|
|
|
|
static Atom atom_wm_s0;
|
|
|
|
|
|
|
|
|
|
if (atom_wm_s0 == None)
|
|
|
|
|
atom_wm_s0 = MakeAtom(atom_name, strlen(atom_name), TRUE);
|
|
|
|
|
if (info->selection->selection != atom_wm_s0 ||
|
|
|
|
|
info->kind != SelectionSetOwner)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-10-23 14:33:24 -04:00
|
|
|
listen_on_fds();
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
DeleteCallback(&SelectionCallback, wm_selection_callback, xwl_screen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void _X_ATTRIBUTE_PRINTF(1, 0)
|
|
|
|
|
xwl_log_handler(const char *format, va_list args)
|
|
|
|
|
{
|
|
|
|
|
char msg[256];
|
|
|
|
|
|
|
|
|
|
vsnprintf(msg, sizeof msg, format, args);
|
2023-03-08 11:46:13 +01:00
|
|
|
ErrorF("XWAYLAND: %s", msg);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2022-07-28 12:22:14 +10:00
|
|
|
#ifdef XWL_HAS_XWAYLAND_EXTENSION
|
|
|
|
|
#include <X11/extensions/xwaylandproto.h>
|
|
|
|
|
|
2023-01-27 18:00:16 +01:00
|
|
|
Bool noXwaylandExtension = FALSE;
|
2022-07-28 12:22:14 +10:00
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXwlQueryVersion(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
xXwlQueryVersionReply reply;
|
|
|
|
|
int major, minor;
|
|
|
|
|
|
|
|
|
|
REQUEST(xXwlQueryVersionReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xXwlQueryVersionReq);
|
|
|
|
|
|
|
|
|
|
if (version_compare(stuff->majorVersion, stuff->minorVersion,
|
|
|
|
|
XWAYLAND_EXTENSION_MAJOR,
|
|
|
|
|
XWAYLAND_EXTENSION_MINOR) < 0) {
|
|
|
|
|
major = stuff->majorVersion;
|
|
|
|
|
minor = stuff->minorVersion;
|
|
|
|
|
} else {
|
|
|
|
|
major = XWAYLAND_EXTENSION_MAJOR;
|
|
|
|
|
minor = XWAYLAND_EXTENSION_MINOR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reply = (xXwlQueryVersionReply) {
|
|
|
|
|
.type = X_Reply,
|
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
|
.length = 0,
|
|
|
|
|
.majorVersion = major,
|
|
|
|
|
.minorVersion = minor,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
|
swaps(&reply.sequenceNumber);
|
|
|
|
|
swapl(&reply.length);
|
|
|
|
|
swaps(&reply.majorVersion);
|
|
|
|
|
swaps(&reply.minorVersion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(reply), &reply);
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int _X_COLD
|
|
|
|
|
SProcXwlQueryVersion(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
REQUEST(xXwlQueryVersionReq);
|
|
|
|
|
|
|
|
|
|
swaps(&stuff->length);
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xXwlQueryVersionReq);
|
|
|
|
|
swaps(&stuff->majorVersion);
|
|
|
|
|
swaps(&stuff->minorVersion);
|
|
|
|
|
|
|
|
|
|
return ProcXwlQueryVersion(client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2023-01-27 18:00:16 +01:00
|
|
|
ProcXwaylandDispatch(ClientPtr client)
|
2022-07-28 12:22:14 +10:00
|
|
|
{
|
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
|
|
|
|
|
switch (stuff->data) {
|
|
|
|
|
case X_XwlQueryVersion:
|
|
|
|
|
return ProcXwlQueryVersion(client);
|
|
|
|
|
}
|
|
|
|
|
return BadRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2023-01-27 18:00:16 +01:00
|
|
|
SProcXwaylandDispatch(ClientPtr client)
|
2022-07-28 12:22:14 +10:00
|
|
|
{
|
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
|
|
|
|
|
switch (stuff->data) {
|
|
|
|
|
case X_XwlQueryVersion:
|
|
|
|
|
return SProcXwlQueryVersion(client);
|
|
|
|
|
}
|
|
|
|
|
return BadRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwlExtensionInit(void)
|
|
|
|
|
{
|
|
|
|
|
AddExtension(XWAYLAND_EXTENSION_NAME,
|
|
|
|
|
XwlNumberEvents, XwlNumberErrors,
|
2023-01-27 18:00:16 +01:00
|
|
|
ProcXwaylandDispatch, SProcXwaylandDispatch,
|
2022-07-28 12:22:14 +10:00
|
|
|
NULL, StandardMinorOpcode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-04-08 09:17:51 -07:00
|
|
|
static const ExtensionModule xwayland_extensions[] = {
|
2016-02-10 09:35:39 +01:00
|
|
|
#ifdef XF86VIDMODE
|
|
|
|
|
{ xwlVidModeExtensionInit, XF86VIDMODENAME, &noXFree86VidModeExtension },
|
|
|
|
|
#endif
|
2022-07-28 12:22:14 +10:00
|
|
|
#ifdef XWL_HAS_XWAYLAND_EXTENSION
|
2023-01-27 18:00:16 +01:00
|
|
|
{ xwlExtensionInit, XWAYLAND_EXTENSION_NAME, &noXwaylandExtension },
|
2022-07-28 12:22:14 +10:00
|
|
|
#endif
|
2014-03-11 16:11:39 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
InitOutput(ScreenInfo * screen_info, int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
int depths[] = { 1, 4, 8, 15, 16, 24, 32 };
|
|
|
|
|
int bpp[] = { 1, 8, 8, 16, 16, 32, 32 };
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(depths); i++) {
|
|
|
|
|
screen_info->formats[i].depth = depths[i];
|
|
|
|
|
screen_info->formats[i].bitsPerPixel = bpp[i];
|
|
|
|
|
screen_info->formats[i].scanlinePad = BITMAP_SCANLINE_PAD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screen_info->imageByteOrder = IMAGE_BYTE_ORDER;
|
|
|
|
|
screen_info->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
|
|
|
|
|
screen_info->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
|
|
|
|
|
screen_info->bitmapBitOrder = BITMAP_BIT_ORDER;
|
|
|
|
|
screen_info->numPixmapFormats = ARRAY_SIZE(depths);
|
|
|
|
|
|
2022-01-13 09:07:57 +01:00
|
|
|
if (serverGeneration == 1) {
|
|
|
|
|
try_raising_nofile_limit();
|
2017-05-30 16:39:49 -04:00
|
|
|
LoadExtensionList(xwayland_extensions,
|
|
|
|
|
ARRAY_SIZE(xwayland_extensions), FALSE);
|
2022-01-13 09:07:57 +01:00
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2021-02-18 12:04:48 +01:00
|
|
|
wl_log_set_handler_client(xwl_log_handler);
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
if (AddScreen(xwl_screen_init, argc, argv) == -1) {
|
|
|
|
|
FatalError("Couldn't add screen\n");
|
|
|
|
|
}
|
2015-05-05 16:43:44 -04:00
|
|
|
|
2018-01-10 13:05:45 -05:00
|
|
|
xorgGlxCreateVendor();
|
|
|
|
|
|
2015-05-05 16:43:44 -04:00
|
|
|
LocalAccessScopeUser();
|
2018-10-23 15:07:48 -04:00
|
|
|
|
2019-07-20 00:16:43 +02:00
|
|
|
if (wm_fd >= 0 || init_fd >= 0) {
|
|
|
|
|
if (wm_fd >= 0)
|
|
|
|
|
TimerSet(NULL, 0, 1, add_client_fd, NULL);
|
|
|
|
|
if (init_fd >= 0)
|
|
|
|
|
ListenOnOpenFD(init_fd, FALSE);
|
2019-01-02 21:55:23 +01:00
|
|
|
AddCallback(&SelectionCallback, wm_selection_callback, NULL);
|
2019-07-20 00:16:43 +02:00
|
|
|
}
|
|
|
|
|
else if (listen_fd_count > 0) {
|
2019-01-02 21:55:23 +01:00
|
|
|
listen_on_fds();
|
2018-10-23 15:07:48 -04:00
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|