Add the XWAYLAND extension

This extension exists to serve one purpose: reliably identifying
Xwayland. Previous attempts at doing so included querying root window
properties, output names or input device names. All these attempts are
somewhat unreliable. Instead, let's use an extension - where that
extension is present we have an Xwayland server.

Clients should never need to do anything but check whether the extension
exists through XQueryExtension/XListExtensions.

This extension provides a single QueryVersion request only, and
that is only to provide future compatibility if we ever need anything
other than "this extension exists" functionality.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
Peter Hutterer 2022-07-29 09:46:34 +10:00
parent a3f847b750
commit ad6412624e
8 changed files with 201 additions and 3 deletions

19
COPYING-xwaylandproto Normal file
View file

@ -0,0 +1,19 @@
Copyright 2022 Red Hat, Inc.
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.

View file

@ -326,6 +326,13 @@ xinerama_HEADERS = \
xineramaprotopkgconfigdir = $(datadir)/pkgconfig xineramaprotopkgconfigdir = $(datadir)/pkgconfig
xineramaprotopkgconfig_DATA = xineramaproto.pc xineramaprotopkgconfig_DATA = xineramaproto.pc
xwaylandprotodir = $(includedir)/X11/extensions
xwaylandproto_HEADERS = \
include/X11/extensions/xwaylandproto.h
xwaylandprotopkgconfigdir = $(datadir)/pkgconfig
xwaylandprotopkgconfig_DATA = xwaylandproto.pc
if LEGACY if LEGACY
XCalibrateincludedir = $(includedir)/X11/extensions XCalibrateincludedir = $(includedir)/X11/extensions
XCalibrateinclude_HEADERS = \ XCalibrateinclude_HEADERS = \
@ -430,7 +437,8 @@ dist_doc_DATA = \
randrproto.txt \ randrproto.txt \
renderproto.txt \ renderproto.txt \
resproto.txt \ resproto.txt \
xv-protocol-v2.txt xv-protocol-v2.txt \
xwaylandproto.txt
EXTRA_DIST = \ EXTRA_DIST = \
COPYING-applewmproto \ COPYING-applewmproto \
@ -469,6 +477,7 @@ EXTRA_DIST = \
COPYING-xf86rushproto \ COPYING-xf86rushproto \
COPYING-xf86vidmodeproto \ COPYING-xf86vidmodeproto \
COPYING-xineramaproto \ COPYING-xineramaproto \
COPYING-xwaylandproto \
README.md \ README.md \
autogen.sh \ autogen.sh \
include/GL/internal/meson.build \ include/GL/internal/meson.build \

View file

@ -157,6 +157,7 @@ AC_CONFIG_FILES([applewmproto.pc
xf86vidmodeproto.pc xf86vidmodeproto.pc
xineramaproto.pc xineramaproto.pc
xproto.pc xproto.pc
xproxymngproto.pc]) xproxymngproto.pc
xwaylandproto.pc])
AC_OUTPUT AC_OUTPUT

View file

@ -87,6 +87,7 @@ install_headers(
'XvMC.h', 'XvMC.h',
'XvMCproto.h', 'XvMCproto.h',
'Xvproto.h', 'Xvproto.h',
'xwaylandproto.h',
subdir : 'X11/extensions' subdir : 'X11/extensions'
) )

View file

@ -0,0 +1,63 @@
/*
* Copyright © 2022 Red Hat, Inc.
*
* 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.
*/
#ifndef _XWAYLAND_PROTO_H_
#define _XWAYLAND_PROTO_H_
#include <X11/Xproto.h>
#define XWAYLAND_EXTENSION_NAME "XWAYLAND"
#define XWAYLAND_EXTENSION_MAJOR 1
#define XWAYLAND_EXTENSION_MINOR 0
/* Request opcodes */
#define X_XwlQueryVersion 0
#define XwlNumberRequests 1
#define XwlNumberErrors 0
#define XwlNumberEvents 0
typedef struct {
CARD8 reqType;
CARD8 xwlReqType;
CARD16 length;
CARD16 majorVersion;
CARD16 minorVersion;
} xXwlQueryVersionReq;
#define sz_xXwlQueryVersionReq 8
typedef struct {
BYTE type; /* X_Reply */
BYTE pad1;
CARD16 sequenceNumber;
CARD32 length;
CARD16 majorVersion;
CARD16 minorVersion;
CARD32 pad2;
CARD32 pad3;
CARD32 pad4;
CARD32 pad5;
CARD32 pad6;
} xXwlQueryVersionReply;
#define sz_xXwlQueryVersionReply 32
#endif

View file

@ -51,6 +51,7 @@ pcs = [
'xf86vidmodeproto', 'xf86vidmodeproto',
'xineramaproto', 'xineramaproto',
'xproto', 'xproto',
'xwaylandproto',
] ]
pc_data = configuration_data() pc_data = configuration_data()
@ -78,7 +79,8 @@ docs = files('compositeproto.txt',
'randrproto.txt', 'randrproto.txt',
'renderproto.txt', 'renderproto.txt',
'resproto.txt', 'resproto.txt',
'xv-protocol-v2.txt') 'xv-protocol-v2.txt',
'xwaylandproto.txt')
install_data(docs, install_data(docs,
install_dir: get_option('datadir') / 'doc' / 'xorgproto') install_dir: get_option('datadir') / 'doc' / 'xorgproto')

7
xwaylandproto.pc.in Normal file
View file

@ -0,0 +1,7 @@
prefix=@prefix@
includedir=@includedir@
Name: XwaylandProto
Description: Xwayland extension headers
Version: 1.0
Cflags: -I${includedir}

96
xwaylandproto.txt Normal file
View file

@ -0,0 +1,96 @@
The XWAYLAND Extension
Version 1.0
2022-07-29
1. Introduction
The XWAYLAND extension allows clients to reliably identify whether an X server
is Xwayland. It does not provide any functionality beyond the absolute minimum
to identify as extension.
Only Xwayland initializes this extension. Thus, if the extension is present,
the X server is Xwayland. Clients should not need the protocol detailed in this
document, a QueryExtension or ListExtensions request is sufficient to check
whether the extension is present.
The protocol detailed in this document is merely to future-proof this extension
in case actual functionality is added in the future.
❄ ❄ ❄ ❄ ❄ ❄ ❄
2. Version History
- 1.0, July 2022: QueryVersion request only
❄ ❄ ❄ ❄ ❄ ❄ ❄
3. Events and Errors
XWAYLAND defines no events or errrors
❄ ❄ ❄ ❄ ❄ ❄ ❄
4. Extension initialization
The name of this extension is "XWAYLAND"
┌───
XwlQueryVersion
client-major-version: CARD16
client-minor-version: CARD16
major-version: CARD16
minor-version: CARD16
└───
The client sends the highest supported version to the server
and the server replies with the highest version it supports,
but no higher than the requested version. Major versions changes
can introduce incompatibilities in existing functionality, minor
version changes introduce only backward compatible changes.
It is the clients responsibility to ensure that the server
supports a version which is compatible with its expectations.
Backwards compatible changes include addition of new
requests.
❄ ❄ ❄ ❄ ❄ ❄ ❄
Appendix A. Protocol Encoding
Syntactic Conventions
This document uses the same syntactic conventions as the core X
protocol encoding document.
A.1 Common Types
None.
A.2 Protocol Requests
┌───
XwlQueryVersion
1 CARD8 major opcode
1 0 XWAYLAND opcode
2 2 length
2 CARD16 major version
2 CARD16 minor version
1 1 Reply
1 unused
2 CARD16 sequence number
4 0 reply length
2 CARD16 major version
2 CARD16 minor version
20 unused
└───
A.3 Protocol Events
The XWAYLAND extension defines no events.
A.4 Protocol Errors
The XWAYLAND extension defines no errors.
❄ ❄ ❄ ❄ ❄ ❄ ❄