pax_global_header 0000666 0000000 0000000 00000000064 14607133730 0014516 g ustar 00root root 0000000 0000000 52 comment=c8e43d028ff99364168ec7cc51236e827bd1813b
go-x11-client-1.0.2/ 0000775 0000000 0000000 00000000000 14607133730 0014006 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/.github/ 0000775 0000000 0000000 00000000000 14607133730 0015346 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/.github/workflows/ 0000775 0000000 0000000 00000000000 14607133730 0017403 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/.github/workflows/backup-to-gitlab.yml 0000664 0000000 0000000 00000000537 14607133730 0023260 0 ustar 00root root 0000000 0000000 name: backup to gitlab
on: [push]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
backup-to-gitlabwh:
uses: linuxdeepin/.github/.github/workflows/backup-to-gitlabwh.yml@master
secrets: inherit
backup-to-gitee:
uses: linuxdeepin/.github/.github/workflows/backup-to-gitee.yml@master
secrets: inherit
go-x11-client-1.0.2/.github/workflows/call-auto-tag.yml 0000664 0000000 0000000 00000000517 14607133730 0022563 0 ustar 00root root 0000000 0000000 name: auto tag
on:
pull_request_target:
types: [opened, synchronize, closed]
paths:
- "debian/changelog"
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
auto_tag:
uses: linuxdeepin/.github/.github/workflows/auto-tag.yml@master
secrets: inherit
go-x11-client-1.0.2/.github/workflows/call-build-distribution.yml 0000664 0000000 0000000 00000000432 14607133730 0024652 0 ustar 00root root 0000000 0000000 name: Call build-distribution
on:
push:
paths-ignore:
- ".github/workflows/**"
pull_request_target:
paths-ignore:
- ".github/workflows/**"
jobs:
check_job:
uses: linuxdeepin/.github/.github/workflows/build-distribution.yml@master
secrets: inherit
go-x11-client-1.0.2/.github/workflows/call-chatOps.yml 0000664 0000000 0000000 00000000242 14607133730 0022436 0 ustar 00root root 0000000 0000000 name: chatOps
on:
issue_comment:
types: [created]
jobs:
chatopt:
uses: linuxdeepin/.github/.github/workflows/chatOps.yml@master
secrets: inherit
go-x11-client-1.0.2/.github/workflows/call-clacheck.yml 0000664 0000000 0000000 00000000525 14607133730 0022576 0 ustar 00root root 0000000 0000000 name: Call CLA check
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
clacheck:
uses: linuxdeepin/.github/.github/workflows/cla-check.yml@master
secrets: inherit
go-x11-client-1.0.2/.github/workflows/call-commitlint.yml 0000664 0000000 0000000 00000000364 14607133730 0023221 0 ustar 00root root 0000000 0000000 name: Call commitlint
on:
pull_request_target:
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
check_job:
uses: linuxdeepin/.github/.github/workflows/commitlint.yml@master
go-x11-client-1.0.2/.github/workflows/call-license-check.yml 0000664 0000000 0000000 00000000552 14607133730 0023536 0 ustar 00root root 0000000 0000000 name: Call License and README Check
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: read
concurrency:
group: ${{ github.workflow }}-pull/${{ github.event.number }}
cancel-in-progress: true
jobs:
license-check:
uses: linuxdeepin/.github/.github/workflows/license-check.yml@master
go-x11-client-1.0.2/.gitlab-ci.yml 0000664 0000000 0000000 00000000141 14607133730 0016436 0 ustar 00root root 0000000 0000000 include:
- remote: 'https://gitlab.deepin.io/dev-tools/letmeci/raw/master/gitlab-ci/dde.yml'
go-x11-client-1.0.2/.obs/ 0000775 0000000 0000000 00000000000 14607133730 0014647 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/.obs/workflows.yml 0000664 0000000 0000000 00000002223 14607133730 0017426 0 ustar 00root root 0000000 0000000 test_build:
steps:
- link_package:
source_project: deepin:Develop:dde
source_package: %{SCM_REPOSITORY_NAME}
target_project: deepin:CI
- configure_repositories:
project: deepin:CI
repositories:
- name: deepin_develop
paths:
- target_project: deepin:CI
target_repository: deepin_develop
architectures:
- x86_64
- aarch64
- name: debian
paths:
- target_project: deepin:CI
target_repository: debian_sid
architectures:
- x86_64
- name: archlinux
paths:
- target_project: deepin:CI
target_repository: archlinux
architectures:
- x86_64
filters:
event: pull_request
tag_build:
steps:
- trigger_services:
project: deepin:Unstable:dde
package: %{SCM_REPOSITORY_NAME}
filters:
event: tag_push
commit_build:
steps:
- trigger_services:
project: deepin:Develop:dde
package: %{SCM_REPOSITORY_NAME}
filters:
event: push
go-x11-client-1.0.2/.packit.yaml 0000664 0000000 0000000 00000001132 14607133730 0016220 0 ustar 00root root 0000000 0000000 # See the documentation for more information:
# https://packit.dev/docs/configuration/
specfile_path: rpm/golang-github-linuxdeepin-go-x11-client.spec
# add or remove files that should be synced
synced_files:
- rpm/golang-github-linuxdeepin-go-x11-client.spec
- .packit.yaml
upstream_package_name: go-x11-client
# downstream (Fedora) RPM package name
downstream_package_name: golang-github-linuxdeepin-go-x11-client
actions:
fix-spec-file: |
bash -c "sed -i -r \"0,/Version:/ s/Version:(\s*)\S*/Version:\1${PACKIT_PROJECT_VERSION}/\" rpm/golang-github-linuxdeepin-go-x11-client.spec"
go-x11-client-1.0.2/.reuse/ 0000775 0000000 0000000 00000000000 14607133730 0015207 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/.reuse/dep5 0000664 0000000 0000000 00000002720 14607133730 0015770 0 ustar 00root root 0000000 0000000 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: go-x11-client
Upstream-Contact: UnionTech Software Technology Co., Ltd. <>
Source: https://github.com/linuxdeepin/go-x11-client
# gitignore clang-format gitreview .tx
Files: .gitignore .clang-format .gitreview .mailmap .tx/config
Copyright: None
License: CC0-1.0
# README
Files: *.md README README.zh_CN.md
Copyright: UnionTech Software Technology Co., Ltd.
License: CC-BY-4.0
# Project file
Files: *Makefile*
Copyright: None
License: CC0-1.0
# ci
Files: .github/* .gitlab-ci.yml .obs/workflows.yml
Copyright: None
License: CC0-1.0
# sh
Files: gen.sh util/tool/gen-keysymdef/gen.sh
Copyright: None
License: GPL-3.0-or-later
# debian rpm archlinux
Files: debian/* rpm/* archlinux/*
Copyright: None
License: CC0-1.0
# README
Files: *.md src/gi/README README.zh_CN.md
Copyright: UnionTech Software Technology Co., Ltd.
License: CC-BY-4.0
# docs documentation
Files: docs/* documentation/*
Copyright: UnionTech Software Technology Co., Ltd.
License: GPL-3.0-or-later
# org xml json yaml html yml css in ui
Files: *.org *.xml *.json *.yaml *.html *.yml *.css *.devhelp2 *.in *.ui
Copyright: UnionTech Software Technology Co., Ltd.
License: GPL-3.0-or-later
# png svg jpg gif
Files: *.png *.svg *.jpg *.gif
Copyright: UnionTech Software Technology Co., Ltd.
License: GPL-3.0-or-later
# test file
Files: *testdata/*
Copyright: UnionTech Software Technology Co., Ltd.
License: GPL-3.0-or-later
go-x11-client-1.0.2/CHANGELOG.md 0000664 0000000 0000000 00000003254 14607133730 0015623 0 ustar 00root root 0000000 0000000 [0.4.1] 2019-04-03
* fix: build failed
[0.4.0] 2019-03-27
* feat: add util xcursor
[0.3.0] 2019-02-26
* chore: use WriteBool and ReadBool
* feat: xkb add more functions
* chore: exts use new reader
* chore: xproto event use new reader
* feat: implement new Reader
* feat: add ext xkb
* feat: delete other error types, leaving only the Error type
* chore: continue to replace uint64 with SeqNum
* feat: use special seqNum to indicate error
* fix: requestCheck do not unlock c.ioMu before return
* chore: replace uint64 with SeqNum
* feat: reduce memory usage for encoding requests
# [0.2.0] - 2018-11-23
* fix: readSetup
# [0.1.0] - 2018-10-25
* fix(wm/ewmh): get icon failed
* feat: add WriteSelectionNotifyEvent
* chore: add makefile for `sw_64`
# [0.0.4] - 2018-07-19
* fix: requestCheck method
* feat: add ext shm
* feat: add ext render
* feat: support ge generic event
* feat: add ext input
* fix: readMapNotifyEvent no set Window field
* fix: conn read blocked when event chan full
* feat(ext/randr): add more events
* fix(ext/randr): name typo
* feat: add ext xfixes
* fead: handle conn read write error
* feat: Conn add method IDUsedCount
* fix: wrong call NewError
* feat: add resource id allocator
* feat: conn add atom cache
* fix: ewmh _NET_SUPPORTING_WM_CHECK is not root property
* feat: add ext randr
* feat: add ext dpms and screensaver
* chore: call log.Print if env DEBUG_X11_CLIENT = 1
* chore(deb): set env DH_GOLANG_EXCLUDES
* feat: handwriting encode decode part
* fix: atom WM_CHANGE_STATE not found
# [0.0.3] - 2018-03-07
* remove usr/bin
* expand event chan buffer size
* fix: Adapt lintian
go-x11-client-1.0.2/LICENSE 0000664 0000000 0000000 00000104513 14607133730 0015017 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
go-x11-client-1.0.2/LICENSES/ 0000775 0000000 0000000 00000000000 14607133730 0015213 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/LICENSES/CC-BY-4.0.txt 0000664 0000000 0000000 00000041177 14607133730 0017062 0 ustar 00root root 0000000 0000000 Creative Commons Attribution 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 – Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 – Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. Downstream recipients.
A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
Section 3 – License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 – Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 – Disclaimer of Warranties and Limitation of Liability.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 – Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 – Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 – Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.
go-x11-client-1.0.2/LICENSES/CC0-1.0.txt 0000664 0000000 0000000 00000015610 14607133730 0016620 0 ustar 00root root 0000000 0000000 Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
go-x11-client-1.0.2/LICENSES/GPL-3.0-or-later.txt 0000664 0000000 0000000 00000103556 14607133730 0020431 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see .
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read .
go-x11-client-1.0.2/Makefile 0000664 0000000 0000000 00000000534 14607133730 0015450 0 ustar 00root root 0000000 0000000 PREFIX = /usr
GOSITE_DIR = ${PREFIX}/share/gocode
GOPKG_PERFIX = github.com/linuxdeepin/go-x11-client
SRC_DIR=${DESTDIR}${GOSITE_DIR}/src/${GOPKG_PERFIX}
all: build
build:
echo ignore build
print_gopath:
GOPATH="${CURDIR}/${GOPATH_DIR}:${GOPATH}"
install:
mkdir -p ${SRC_DIR}
cp *.go ${SRC_DIR}
cp -r ext ${SRC_DIR}
cp -r util ${SRC_DIR}
go-x11-client-1.0.2/README.md 0000664 0000000 0000000 00000002646 14607133730 0015275 0 ustar 00root root 0000000 0000000 # go-x11-client
**Description**:
go-x11-client it is a X11 protocol go language binding.
## Dependencies
You can also check the "Depends" provided in the debian/control file.
### Build dependencies
You can also check the "Build-Depends" provided in the debian/control file.
## Installation
### Deepin
Install prerequisites
```
$ sudo apt-get build-dep go-x11-client
```
Build
```
$ GOPATH=/usr/share/gocode make
```
Install
If you have isolated testing build environment (say a docker container), you can install it directly.
```
$ sudo make install
```
generate package files and install go-x11-client with it.
```
$ debuild -uc -us ...
$ sudo dpkg -i ../golang-github-linuxdeepin-go-x11-client.deb
```
## Usage
go get github.com/linuxdeepin/go-x11-client
## Getting help
Any usage issues can ask for help via
* [Gitter](https://gitter.im/orgs/linuxdeepin/rooms)
* [IRC channel](https://webchat.freenode.net/?channels=deepin)
* [Forum](https://bbs.deepin.org)
* [WiKi](https://wiki.deepin.org/)
## Getting involved
We encourage you to report issues and contribute changes.
* [Contribution guide for developers](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers-en). (English)
* [开发者代码贡献指南](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers) (中文)
## License
go-x11-client is licensed under [GPL-3.0-or-later](LICENSE).
go-x11-client-1.0.2/README.zh_CN.md 0000664 0000000 0000000 00000002665 14607133730 0016276 0 ustar 00root root 0000000 0000000 # go-x11-client
**Description**:
go-x11-client是一个用go语言实现与X11协议进行绑定的项目。
## 依赖
请查看“debian/control”文件中提供的“Depends”。
### 编译依赖
请查看“debian/control”文件中提供的“Build-Depends”。
## 安装
### Deepin
go-x11-client需要预安装以下包
```
$ sudo apt-get build-dep go-x11-client
```
构建
```
$ GOPATH=/usr/share/gocode make
```
安装
如果你有独立的测试构建环境(比如一个 docker 容器),你可以直接安装它。
```
$ sudo make install
```
生成包文件并安装 go-x11-client
```
$ debuild -uc -us ...
$ sudo dpkg -i ../golang-github-linuxdeepin-go-x11-client.deb
```
## 用法
go get github.com/linuxdeepin/go-x11-client
## 获得帮助
如果您遇到任何其他问题,您可能还会发现这些渠道很有用:
* [Gitter](https://gitter.im/orgs/linuxdeepin/rooms)
* [IRC channel](https://webchat.freenode.net/?channels=deepin)
* [Forum](https://bbs.deepin.org)
* [WiKi](https://wiki.deepin.org/)
## 贡献指南
我们鼓励您报告问题并做出更改
* [Contribution guide for developers](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers-en). (English)
* [开发者代码贡献指南](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers) (中文)
## License
go-x11-client项目在 [GPL-3.0-or-later](LICENSE)下发布。
go-x11-client-1.0.2/archlinux/ 0000775 0000000 0000000 00000000000 14607133730 0016003 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/archlinux/PKGBUILD 0000664 0000000 0000000 00000002732 14607133730 0017133 0 ustar 00root root 0000000 0000000 # Maintainer: justforlxz
pkgname=golang-github-linuxdeepin-go-x11-client-git
pkgver=0.6.8.r2.g9476531
pkgrel=1
sourcename=go-x11-client
pkgsourcename="golang-github-linuxdeepin-go-x11-client"
sourcetars=("$pkgsourcename"_"$pkgver".tar.xz)
sourcedir="$sourcename"
pkgdesc='X11 protocol go language binding'
arch=('any')
url="https://github.com/linuxdeepin/go-x11-client"
license=('GPL')
conflicts=('golang-github-linuxdeepin-go-x11-client')
provides=('golang-github-linuxdeepin-go-x11-client')
groups=('deepin-git')
depends=('golang-golang-x-text')
makedepends=('git' 'go' 'xorg-server-xvfb' 'golang-github-stretchr-testify' 'golang-gopkg-check.v1' 'golang-gopkg-yaml.v3')
checkdepends=('xorg-server-xvfb' 'golang-github-stretchr-testify' 'golang-gopkg-check.v1' 'golang-gopkg-yaml.v3' 'git')
source=("${sourcetars[@]}")
sha512sums=('SKIP')
prepare() {
cd $sourcedir
rm -rf tools
}
check() {
export GOPATH="$srcdir/build:/usr/share/gocode"
export GO111MODULE=off
mkdir -p "$srcdir"/build/src/github.com/linuxdeepin
cp -a "$srcdir/$sourcedir" "$srcdir"/build/src/github.com/linuxdeepin/go-x11-client
cd "$srcdir"/build/src/github.com/linuxdeepin/go-x11-client
xvfb-run go test -v $(go list ./...)
}
package() {
mkdir -p "$pkgdir"/usr/share/gocode/src/github.com/linuxdeepin
cp -a "$srcdir/$sourcedir" "$pkgdir"/usr/share/gocode/src/github.com/linuxdeepin/go-x11-client
rm -r "$pkgdir"/usr/share/gocode/src/github.com/linuxdeepin/go-x11-client/debian
}
go-x11-client-1.0.2/atom.go 0000664 0000000 0000000 00000004240 14607133730 0015275 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"sync"
)
type AtomCache struct {
atoms map[string]Atom
atomNames map[Atom]string
mu sync.RWMutex
}
func (ac *AtomCache) getVal(name string) (val Atom, ok bool) {
ac.mu.RLock()
val, ok = ac.atoms[name]
ac.mu.RUnlock()
return
}
func (ac *AtomCache) getName(val Atom) (name string, ok bool) {
ac.mu.RLock()
name, ok = ac.atomNames[val]
ac.mu.RUnlock()
return
}
func (ac *AtomCache) store(name string, val Atom) {
ac.mu.Lock()
ac.atoms[name] = val
ac.atomNames[val] = name
ac.mu.Unlock()
}
func NewAtomCache() *AtomCache {
ac := &AtomCache{
atoms: make(map[string]Atom),
atomNames: make(map[Atom]string),
}
return ac
}
var defaultAtomCache *AtomCache
var defaultAtomCacheMu sync.Mutex
func (c *Conn) getAtomCache() *AtomCache {
c.atomCacheMu.Lock()
if c.atomCache == nil {
// try default atom cache
defaultAtomCacheMu.Lock()
if defaultAtomCache == nil {
defaultAtomCache = NewAtomCache()
}
c.atomCache = defaultAtomCache
defaultAtomCacheMu.Unlock()
}
v := c.atomCache
c.atomCacheMu.Unlock()
return v
}
func (c *Conn) SetAtomCache(ac *AtomCache) {
c.atomCacheMu.Lock()
c.atomCache = ac
c.atomCacheMu.Unlock()
}
func (c *Conn) GetAtomCache() (ac *AtomCache) {
c.atomCacheMu.Lock()
ac = c.atomCache
c.atomCacheMu.Unlock()
return
}
func (c *Conn) GetAtom(name string) (Atom, error) {
return c.getAtom(false, name)
}
func (c *Conn) GetAtomExisting(name string) (Atom, error) {
return c.getAtom(true, name)
}
func (c *Conn) getAtom(onlyIfExists bool, name string) (Atom, error) {
ac := c.getAtomCache()
val, ok := ac.getVal(name)
if ok {
return val, nil
}
reply, err := InternAtom(c, onlyIfExists, name).Reply(c)
if err != nil {
return AtomNone, err
}
ac.store(name, reply.Atom)
return reply.Atom, nil
}
func (c *Conn) GetAtomName(atom Atom) (string, error) {
ac := c.getAtomCache()
name, ok := ac.getName(atom)
if ok {
return name, nil
}
reply, err := GetAtomName(c, atom).Reply(c)
if err != nil {
return "", err
}
ac.store(reply.Name, atom)
return reply.Name, nil
}
go-x11-client-1.0.2/auth.go 0000664 0000000 0000000 00000004562 14607133730 0015305 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
/*
auth.go contains functions to facilitate the parsing of .Xauthority files.
It is largely unmodified from the original XGB package that I forked.
*/
import (
"encoding/binary"
"errors"
"io"
"os"
)
// readAuthority reads the X authority file for the DISPLAY.
// If hostname == "" or hostname == "localhost",
// then use the system's hostname (as returned by os.Hostname) instead.
func readAuthority(hostname, display string) (
name string, data []byte, err error) {
// b is a scratch buffer to use and should be at least 256 bytes long
// (i.e. it should be able to hold a hostname).
b := make([]byte, 256)
// As per /usr/include/X11/Xauth.h.
const familyLocal = 256
const familyWild = 65535
if len(hostname) == 0 || hostname == "localhost" {
hostname, err = os.Hostname()
if err != nil {
return "", nil, err
}
}
fname := os.Getenv("XAUTHORITY")
if len(fname) == 0 {
home := os.Getenv("HOME")
if len(home) == 0 {
err = errors.New("Xauthority not found: $XAUTHORITY, $HOME not set")
return "", nil, err
}
fname = home + "/.Xauthority"
}
r, err := os.Open(fname)
if err != nil {
return "", nil, err
}
defer r.Close()
for {
var family uint16
if err := binary.Read(r, binary.BigEndian, &family); err != nil {
return "", nil, err
}
addr, err := getString(r, b)
if err != nil {
return "", nil, err
}
disp, err := getString(r, b)
if err != nil {
return "", nil, err
}
name0, err := getString(r, b)
if err != nil {
return "", nil, err
}
data0, err := getBytes(r, b)
if err != nil {
return "", nil, err
}
addrmatch := (family == familyWild) ||
(family == familyLocal && addr == hostname)
dispmatch := (disp == "") || (disp == display)
if addrmatch && dispmatch {
return name0, data0, nil
}
}
}
func getBytes(r io.Reader, b []byte) ([]byte, error) {
var n uint16
if err := binary.Read(r, binary.BigEndian, &n); err != nil {
return nil, err
} else if n > uint16(len(b)) {
return nil, errors.New("bytes too long for buffer")
}
if _, err := io.ReadFull(r, b[0:n]); err != nil {
return nil, err
}
return b[0:n], nil
}
func getString(r io.Reader, b []byte) (string, error) {
b, err := getBytes(r, b)
if err != nil {
return "", err
}
return string(b), nil
}
go-x11-client-1.0.2/client_message_data.go 0000664 0000000 0000000 00000002232 14607133730 0020307 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
type ClientMessageData struct {
data []byte
}
func ClientMessageDataRead(r *Reader, v *ClientMessageData) int {
v.data = r.MustReadBytes(20)
return 20
}
func writeClientMessageData(w *Writer, v *ClientMessageData) int {
w.WriteNBytes(20, v.data)
return 20
}
func (v *ClientMessageData) GetData8() []byte {
return v.data
}
func (v *ClientMessageData) GetData16() []uint16 {
ret := make([]uint16, 10)
idx := 0
for i := 0; i < 20; i += 2 {
ret[idx] = Get16(v.data[i : i+2])
idx++
}
return ret
}
func (v *ClientMessageData) GetData32() []uint32 {
ret := make([]uint32, 5)
idx := 0
for i := 0; i < 20; i += 4 {
ret[idx] = Get32(v.data[i : i+4])
idx++
}
return ret
}
func (v *ClientMessageData) SetData8(p *[20]byte) {
v.data = p[:]
}
func (v *ClientMessageData) SetData16(p *[10]uint16) {
w := NewWriter()
for i := 0; i < 10; i++ {
w.Write2b(p[i])
}
v.data = w.Bytes()
}
func (v *ClientMessageData) SetData32(p *[5]uint32) {
w := NewWriter()
for i := 0; i < 5; i++ {
w.Write4b(p[i])
}
v.data = w.Bytes()
}
go-x11-client-1.0.2/conn.go 0000664 0000000 0000000 00000003730 14607133730 0015275 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"bufio"
"errors"
"fmt"
"log"
"net"
"os"
"sync"
"sync/atomic"
)
var Logger *log.Logger
var debugEnabled bool
func init() {
if os.Getenv("DEBUG_X11_CLIENT") == "1" {
debugEnabled = true
Logger = log.New(os.Stderr, "[x] ", log.Lshortfile)
}
}
func logPrintln(v ...interface{}) {
if debugEnabled {
_ = Logger.Output(2, fmt.Sprintln(v...))
}
}
func logPrintf(format string, v ...interface{}) {
if debugEnabled {
_ = Logger.Output(2, fmt.Sprintf(format, v...))
}
}
type Conn struct {
conn net.Conn
closed int32
bufReader *bufio.Reader
host string
display string
DisplayNumber int
ScreenNumber int
setup *Setup
ioMu sync.Mutex
in in
out out
ext ext
ridAllocator resourceIdAllocator
atomCache *AtomCache
atomCacheMu sync.Mutex
errorCb func(err *Error)
}
func (c *Conn) GetSetup() *Setup {
return c.setup
}
func (c *Conn) GetDefaultScreen() *Screen {
return &c.setup.Roots[c.ScreenNumber]
}
func (c *Conn) isClosed() bool {
return 1 == atomic.LoadInt32(&c.closed)
}
func (c *Conn) markClosed() {
atomic.StoreInt32(&c.closed, 1)
}
func (c *Conn) Close() {
if c.isClosed() {
return
}
c.markClosed()
c.conn.Close()
c.in.eventsCond.Signal()
go func() {
c.ioMu.Lock()
c.in.wakeUpAllReaders()
c.ioMu.Unlock()
}()
}
var errConnClosed = errors.New("conn closed")
func (c *Conn) AddEventChan(eventChan chan<- GenericEvent) {
if c.isClosed() || eventChan == nil {
return
}
c.in.addEventChan(eventChan)
}
func (c *Conn) RemoveEventChan(eventChan chan<- GenericEvent) {
if eventChan == nil {
return
}
c.in.removeEventChan(eventChan)
}
func (c *Conn) SetErrorCallback(fn func(err *Error)) {
c.errorCb = fn
}
func (c *Conn) MakeAndAddEventChan(bufSize int) chan GenericEvent {
ch := make(chan GenericEvent, bufSize)
c.AddEventChan(ch)
return ch
}
go-x11-client-1.0.2/conn_connect.go 0000664 0000000 0000000 00000010664 14607133730 0017012 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"bufio"
"errors"
"fmt"
"io"
"net"
"os"
"strconv"
"strings"
)
func NewConn() (*Conn, error) {
return NewConnDisplay("")
}
func NewConnDisplay(display string) (*Conn, error) {
c := new(Conn)
err := c.connectDisplay(display)
if err != nil {
return nil, err
}
c.bufReader = bufio.NewReader(c.conn)
c.in.init(&c.ioMu)
c.out.bw = bufio.NewWriter(c.conn)
c.ridAllocator.init(c.setup.ResourceIdBase, c.setup.ResourceIdMask)
go c.readLoop()
go c.eventSendLoop()
return c, nil
}
func (c *Conn) connectDisplay(display string) error {
err := c.dial(display)
if err != nil {
return err
}
return c.postConnect()
}
// dial initializes the actual net connection with X.
func (c *Conn) dial(display string) error {
if len(display) == 0 {
display = os.Getenv("DISPLAY")
}
display0 := display
if len(display) == 0 {
return errors.New("empty display string")
}
colonIdx := strings.LastIndex(display, ":")
if colonIdx < 0 {
return errors.New("bad display string: " + display0)
}
var protocol, socket string
if display[0] == '/' {
socket = display[0:colonIdx]
} else {
slashIdx := strings.LastIndex(display, "/")
if slashIdx >= 0 {
protocol = display[0:slashIdx]
c.host = display[slashIdx+1 : colonIdx]
} else {
c.host = display[0:colonIdx]
}
}
display = display[colonIdx+1:]
if len(display) == 0 {
return errors.New("bad display string: " + display0)
}
var scr string
dotIdx := strings.LastIndex(display, ".")
if dotIdx < 0 {
c.display = display[0:]
} else {
c.display = display[0:dotIdx]
scr = display[dotIdx+1:]
}
var err error
c.DisplayNumber, err = strconv.Atoi(c.display)
if err != nil || c.DisplayNumber < 0 {
return errors.New("bad display string: " + display0)
}
if scr != "" {
c.ScreenNumber, err = strconv.Atoi(scr)
if err != nil {
return errors.New("bad display string: " + display0)
}
}
logPrintf("socket: %q, protocol: %q\n", socket, protocol)
// Connect to server
if len(socket) != 0 {
c.conn, err = net.Dial("unix", socket+":"+c.display)
} else if len(c.host) != 0 {
if protocol == "" {
protocol = "tcp"
}
logPrintln("dial tcp")
c.conn, err = net.Dial(protocol,
c.host+":"+strconv.Itoa(6000+c.DisplayNumber))
} else {
logPrintln("dial unix")
c.conn, err = net.Dial("unix", "/tmp/.X11-unix/X"+c.display)
}
if err != nil {
return errors.New("cannot connect to " + display0 + ": " + err.Error())
}
return nil
}
// do the postConnect action after Conn get it's underly net.Conn
func (c *Conn) postConnect() error {
// Get authentication data
authName, authData, err := readAuthority(c.host, c.display)
noAuth := false
if err != nil {
logPrintf("Could not get authority info: %v", err)
logPrintln("Trying connection without authority info...")
authName = ""
authData = []byte{}
noAuth = true
}
// Assume that the authentication protocol is "MIT-MAGIC-COOKIE-1".
if !noAuth && (authName != "MIT-MAGIC-COOKIE-1" || len(authData) != 16) {
return errors.New("unsupported auth protocol " + authName)
}
bufLen := 12 + len(authName) + Pad(len(authName)) + len(authData) + Pad(len(authData))
buf := make([]byte, bufLen)
buf[0] = 0x6c
buf[1] = 0
Put16(buf[2:], 11)
Put16(buf[4:], 0)
Put16(buf[6:], uint16(len(authName)))
Put16(buf[8:], uint16(len(authData)))
Put16(buf[10:], 0)
copy(buf[12:], []byte(authName))
copy(buf[12+len(authName)+Pad(len(authName)):], authData)
if _, err = c.conn.Write(buf); err != nil {
return err
}
head := make([]byte, 8)
if _, err = io.ReadFull(c.conn, head[0:8]); err != nil {
return err
}
respType := head[0]
major := Get16(head[2:])
minor := Get16(head[4:])
dataLen := Get16(head[6:])
if major != 11 || minor != 0 {
return fmt.Errorf("x protocol version mismatch: %d.%d", major, minor)
}
buf = make([]byte, 8+dataLen*4)
copy(buf, head)
if _, err = io.ReadFull(c.conn, buf[8:]); err != nil {
return err
}
if respType == ResponseTypeError {
reasonLen := head[1]
reason := buf[8 : 8+reasonLen]
return fmt.Errorf("x protocol authentication refused: %s",
string(reason))
}
var setup Setup
r := NewReaderFromData(buf)
err = readSetup(r, &setup)
if err != nil {
return err
}
c.setup = &setup
/* Make sure requested screen number is in bounds for this server */
if c.ScreenNumber >= len(setup.Roots) {
return errors.New("invalid screen")
}
return nil
}
go-x11-client-1.0.2/conn_in.go 0000664 0000000 0000000 00000017014 14607133730 0015763 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"container/list"
"io"
"sync"
)
const (
ResponseTypeError = 0
ResponseTypeReply = 1
)
//enum xcb_send_request_flags_t {
//XCB_REQUEST_CHECKED = 1 << 0,
//XCB_REQUEST_RAW = 1 << 1,
//XCB_REQUEST_DISCARD_REPLY = 1 << 2,
//XCB_REQUEST_REPLY_FDS = 1 << 3
//};
const (
RequestChecked = 1 << 0
RequestRaw = 1 << 1 // ?
RequestDiscardReply = 1 << 2
RequestReplyFds = 1 << 3 // ?
)
//typedef struct {
//uint8_t response_type; [>*< Type of the response <]
//uint8_t pad0; [>*< Padding <]
//uint16_t sequence; [>*< Sequence number <]
//uint32_t length; [>*< Length of the response <]
//} xcb_generic_reply_t;
type GenericReply struct {
responseType uint8
sequence uint16
length uint32
}
func NewGenericReply(buf []byte) *GenericReply {
r := &GenericReply{}
r.responseType = buf[0]
// skip pad buf[1]
r.sequence = Get16(buf[2:])
r.length = Get32(buf[4:])
return r
}
// go c.readLoop
func (c *Conn) readLoop() {
for {
err := c.readPacket()
if err != nil {
c.Close()
return
}
}
}
func (c *Conn) readPacket() error {
length := 32
buf := make([]byte, length)
_, err := io.ReadFull(c.bufReader, buf)
if err != nil {
return err
}
genReply := NewGenericReply(buf)
logPrintf("genReply: %#v\n", genReply)
if (genReply.responseType == ResponseTypeReply ||
genReply.responseType == GeGenericEventCode) && genReply.length > 0 {
length += int(genReply.length) * 4
// grow buf
biggerBuf := make([]byte, length)
copy(biggerBuf[:32], buf)
_, err = io.ReadFull(c.bufReader, biggerBuf[32:])
if err != nil {
return err
}
buf = biggerBuf
}
c.ioMu.Lock()
defer c.ioMu.Unlock()
// update c.in.request*
// KeymapNotifyEvent 没有 sequence
if genReply.responseType != KeymapNotifyEventCode {
lastRead := c.in.requestRead
c.in.requestRead = (lastRead & 0xffffffffffff0000) | SeqNum(genReply.sequence)
if c.in.requestRead < lastRead {
c.in.requestRead += 0x10000
}
if c.in.requestRead > c.in.requestExpected {
c.in.requestExpected = c.in.requestRead
}
if c.in.requestRead != lastRead {
// 这个 reply 是对一个新的请求的 reply
curReply := c.in.currentReply
if curReply != nil && curReply.Len() != 0 {
c.in.replies[lastRead] = curReply
c.in.currentReply = nil
}
c.in.requestCompleted = c.in.requestRead - 1
}
c.in.removeFinishedPendingReplies()
if genReply.responseType == ResponseTypeError {
c.in.requestCompleted = c.in.requestRead
}
c.in.removeFinishedReaders()
}
var pend *PendingReply
if genReply.responseType == ResponseTypeReply ||
genReply.responseType == ResponseTypeError {
if prFront := c.in.pendingReplies.Front(); prFront != nil {
pend = prFront.Value.(*PendingReply)
if !(pend.firstRequest <= c.in.requestRead &&
c.in.requestRead <= pend.lastRequest) {
pend = nil
}
}
}
logPrintf("pend %#v\n", pend)
if pend != nil && pend.flags&RequestDiscardReply != 0 {
// discard reply
logPrintln("discard reply", c.in.requestRead)
return nil
}
/* reply, or checked error */
if genReply.responseType == ResponseTypeReply ||
(genReply.responseType == ResponseTypeError &&
pend != nil && pend.flags&RequestChecked != 0) {
if c.in.currentReply == nil {
c.in.currentReply = list.New()
}
c.in.currentReply.PushBack(buf)
logPrintf("pushBack buf %d len=%d\n", c.in.requestRead, len(buf))
front := c.in.readers.Front()
if front != nil {
reader := front.Value.(*ReplyReader)
if reader.request == c.in.requestRead {
logPrintf("readPacket reader %d signal\n", reader.request)
reader.cond.Signal()
}
}
return nil
}
/* event, or unchecked error */
// not special event
if genReply.responseType == ResponseTypeError {
// is unchecked error
if c.errorCb != nil {
c.errorCb(c.NewError(buf))
} else {
c.in.addEvent(GenericEvent(buf))
}
} else {
// is event
c.in.addEvent(GenericEvent(buf))
}
return nil
}
func (c *Conn) pollForReply(request SeqNum) (replyBuf []byte, isErr, stop bool) {
if c.isClosed() {
stop = true
return
}
logPrintln("pollForReply", request)
var front *list.Element
if request < c.in.requestRead {
/* We've read requests past the one we want, so if it has replies we have
* them all and they're in the replies map. */
l := c.in.replies[request]
logPrintln("reply in replies map")
if l != nil {
// pop front
front = l.Front()
if front != nil {
l.Remove(front)
}
if l.Len() == 0 {
delete(c.in.replies, request)
}
}
} else if request == c.in.requestRead && c.in.currentReply != nil && c.in.currentReply.Front() != nil {
/* We're currently processing the responses to the request we want, and we
* have a reply ready to return. So just return it without blocking. */
logPrintln("reply in currentReply")
front = c.in.currentReply.Front()
c.in.currentReply.Remove(front)
} else if request == c.in.requestCompleted {
/* We know this request can't have any more replies, and we've already
* established it doesn't have a reply now. Don't bother blocking. */
logPrintln("request completed")
stop = true
return
} else {
/* We may have more replies on the way for this request: block until we're sure. */
// stop = false
return
}
if front != nil {
replyBuf = front.Value.([]byte)
respType := replyBuf[0]
if respType == ResponseTypeError {
isErr = true
}
}
stop = true
return
}
func (c *Conn) waitForReply(request SeqNum) (replyBuf []byte, err error) {
err = c.out.flushTo(request)
if err != nil {
c.Close()
return nil, err
}
cond := sync.NewCond(&c.ioMu)
r := c.in.insertNewReader(request, cond)
var isErr bool
var stop bool
for {
replyBuf, isErr, stop = c.pollForReply(request)
if stop {
break
}
logPrintf("waitForReply reader %d wait\n", request)
cond.Wait()
}
if c.isClosed() {
return nil, errConnClosed
}
c.in.removeReader(r)
c.in.wakeUpNextReader()
if isErr {
return nil, c.NewError(replyBuf)
}
return replyBuf, nil
}
func (c *Conn) WaitForReply(request SeqNum) (replyBuf []byte, err error) {
if c.isClosed() {
return nil, errConnClosed
}
err = request.err()
if err != nil {
return nil, err
}
c.ioMu.Lock()
replyBuf, err = c.waitForReply(request)
c.ioMu.Unlock()
return
}
type VoidCookie SeqNum
func (cookie VoidCookie) Check(c *Conn) error {
if c.isClosed() {
return errConnClosed
}
err := SeqNum(cookie).err()
if err != nil {
return err
}
return c.requestCheck(SeqNum(cookie))
}
func (c *Conn) requestCheck(request SeqNum) error {
c.ioMu.Lock()
if request >= c.in.requestExpected &&
request > c.in.requestCompleted {
// send sync request
c.sendSync()
err := c.out.flushTo(c.out.request)
if err != nil {
c.ioMu.Unlock()
return err
}
}
replyBuf, err := c.waitForReply(request)
c.ioMu.Unlock()
if err != nil {
return err
} else {
// if not err, replyBuf must be nil
if replyBuf != nil {
panic("replyBuf is not nil")
}
}
return nil
}
func (c *Conn) pollForEvent() (ev GenericEvent) {
f := c.in.events.Front()
if f != nil {
ev = f.Value.(GenericEvent)
c.in.events.Remove(f)
}
return
}
func (c *Conn) waitForEvent() (ev GenericEvent) {
for {
if c.isClosed() {
return nil
}
ev = c.pollForEvent()
if ev != nil {
break
}
c.in.eventsCond.Wait()
}
return ev
}
func (c *Conn) eventSendLoop() {
for {
c.ioMu.Lock()
ev := c.waitForEvent()
c.ioMu.Unlock()
if ev == nil {
c.in.closeEventChans()
return
}
c.in.sendEvent(ev)
}
}
go-x11-client-1.0.2/conn_out.go 0000664 0000000 0000000 00000013153 14607133730 0016164 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"bufio"
"errors"
"io"
"math"
)
func (c *Conn) Flush() (err error) {
c.ioMu.Lock()
err = c.out.flushTo(c.out.request)
c.ioMu.Unlock()
if err != nil {
c.Close()
}
return
}
func (c *Conn) sendSync() {
header := RequestHeader{
Opcode: GetInputFocusOpcode,
Length: 4,
}
logPrintln("sendSync")
c.sendRequest(false, 0, RequestDiscardReply,
header.toBytes(), nil)
}
func (c *Conn) SendSync() {
c.ioMu.Lock()
c.sendSync()
c.ioMu.Unlock()
}
// sequence number
type SeqNum uint64
const (
seqNumConnClosed SeqNum = 0
seqNumExtNotPresent SeqNum = math.MaxUint64 - iota
seqNumQueryExtErr
)
var errExtNotPresent = errors.New("extension not present")
var errQueryExtErr = errors.New("query extension error")
func (n SeqNum) err() error {
switch n {
case seqNumConnClosed:
return errConnClosed
case seqNumExtNotPresent:
return errExtNotPresent
case seqNumQueryExtErr:
return errQueryExtErr
default:
return nil
}
}
type out struct {
request SeqNum
requestWritten SeqNum
bw *bufio.Writer
}
func (o *out) flushTo(request SeqNum) error {
if !(request <= o.request) {
panic("assert request < o.request failed")
}
if o.requestWritten >= request {
return nil
}
logPrintln("flushTo", request)
err := o.bw.Flush()
if err != nil {
return err
}
o.requestWritten = o.request
return nil
}
func (c *Conn) writeRequest(header []byte, body RequestBody) error {
_, err := c.out.bw.Write(header)
if err != nil {
return err
}
var emptyBuf [3]byte
for _, data := range body {
_, err = c.out.bw.Write(data)
if err != nil {
return err
}
pad := Pad(len(data))
if pad > 0 {
_, err = c.out.bw.Write(emptyBuf[:pad])
if err != nil {
return err
}
}
}
return nil
}
func (c *Conn) sendRequest(noReply bool, workaround uint, flags uint, header []byte, body RequestBody) {
if c.isClosed() {
return
}
c.out.request++
if !noReply {
// has reply
c.in.requestExpected = c.out.request
}
logPrintln("sendRequest seq:", c.out.request)
if workaround != 0 || flags != 0 {
c.in.expectReply(c.out.request, workaround, flags)
}
err := c.writeRequest(header, body)
if err != nil {
logPrintln("write error:", err)
c.Close()
return
}
if c.out.bw.Buffered() == 0 {
// write all the data of request to c.conn
c.out.requestWritten = c.out.request
}
}
type ProtocolRequest struct {
Ext *Extension
NoReply bool
Header RequestHeader
Body RequestBody
}
// return sequence id
func (c *Conn) SendRequest(flags uint, req *ProtocolRequest) SeqNum {
if c.isClosed() {
return seqNumConnClosed
}
// process data auto field
// set the major opcode, and the minor opcode for extensions
if req.Ext != nil {
extension := c.GetExtensionData(req.Ext)
if extension == nil {
return seqNumQueryExtErr
}
if !extension.Present {
return seqNumExtNotPresent
}
req.Header.Opcode = extension.MajorOpcode
}
var requestLen uint64
requestLen = 4
for _, data := range req.Body {
requestLen += uint64(len(data))
requestLen += uint64(Pad(len(data)))
}
req.Header.Length = requestLen
header := req.Header.toBytes()
c.ioMu.Lock()
c.sendRequest(req.NoReply, 0, flags, header, req.Body)
request := c.out.request
c.ioMu.Unlock()
return request
}
type RequestHeader struct {
Opcode uint8 // major opcode
Data uint8 // data or minor opcode
Length uint64 // unit is byte
}
func (rh RequestHeader) toBytes() []byte {
b := make([]byte, 4)
b[0] = rh.Opcode
b[1] = rh.Data
if rh.Length&3 != 0 {
panic("length is not a multiple of 4")
}
length := uint16(rh.Length)
length >>= 2
b[2] = byte(length)
b[3] = byte(length >> 8)
return b
}
type FixedSizeBuf struct {
data []byte
offset int
}
func (b *FixedSizeBuf) Write1b(v uint8) *FixedSizeBuf {
b.data[b.offset] = v
b.offset++
return b
}
// byte order: least significant byte first
func (b *FixedSizeBuf) Write2b(v uint16) *FixedSizeBuf {
b.data[b.offset] = byte(v)
b.data[b.offset+1] = byte(v >> 8)
b.offset += 2
return b
}
func (b *FixedSizeBuf) Write4b(v uint32) *FixedSizeBuf {
b.data[b.offset] = byte(v)
b.data[b.offset+1] = byte(v >> 8)
b.data[b.offset+2] = byte(v >> 16)
b.data[b.offset+3] = byte(v >> 24)
b.offset += 4
return b
}
func (b *FixedSizeBuf) Write8b(v uint64) *FixedSizeBuf {
b.data[b.offset] = byte(v)
b.data[b.offset+1] = byte(v >> 8)
b.data[b.offset+2] = byte(v >> 16)
b.data[b.offset+3] = byte(v >> 24)
b.data[b.offset+4] = byte(v >> 32)
b.data[b.offset+5] = byte(v >> 40)
b.data[b.offset+6] = byte(v >> 48)
b.data[b.offset+7] = byte(v >> 56)
b.offset += 8
return b
}
func (b *FixedSizeBuf) WritePad(n int) *FixedSizeBuf {
b.offset += n
return b
}
func (b *FixedSizeBuf) WriteString(s string) *FixedSizeBuf {
n := copy(b.data[b.offset:], s)
b.offset += n
if n != len(s) {
panic(io.ErrShortWrite)
}
return b
}
func (b *FixedSizeBuf) WriteBytes(p []byte) *FixedSizeBuf {
n := copy(b.data[b.offset:], p)
b.offset += n
if n != len(p) {
panic(io.ErrShortWrite)
}
return b
}
func (b *FixedSizeBuf) WriteBool(v bool) *FixedSizeBuf {
return b.Write1b(BoolToUint8(v))
}
func (b *FixedSizeBuf) End() {
if len(b.data) != b.offset {
panic("not end")
}
}
func (b *FixedSizeBuf) Bytes() []byte {
return b.data
}
func NewFixedSizeBuf(size int) *FixedSizeBuf {
return &FixedSizeBuf{
data: make([]byte, size),
}
}
type RequestBody [][]byte
func (rb *RequestBody) AddBlock(n int) *FixedSizeBuf {
b := NewFixedSizeBuf(n * 4)
*rb = append(*rb, b.data)
return b
}
func (rb *RequestBody) AddBytes(data []byte) {
*rb = append(*rb, data)
}
go-x11-client-1.0.2/const.go 0000664 0000000 0000000 00000001000 14607133730 0015452 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
const (
// None is the universal null resource or null atom parameter value for many core X requests
None = 0
// CurrentTime can be used in most requests that take an Timestamp
CurrentTime = 0
// NoSymbol fills in unused entries in Keysym tables
NoSymbol = 0
// CopyFromParent can be used for many CreateWindow parameters */
CopyFromParent = 0
True = 1
False = 0
)
go-x11-client-1.0.2/debian/ 0000775 0000000 0000000 00000000000 14607133730 0015230 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/debian/changelog 0000664 0000000 0000000 00000001534 14607133730 0017105 0 ustar 00root root 0000000 0000000 golang-github-linuxdeepin-go-x11-client (1.0.2) unstable; urgency=medium
* Add GrabCheckedV2
-- quezhiyong Fri, 12 Apr 2024 13:17:30 +0800
golang-github-linuxdeepin-go-x11-client (1.0.1) unstable; urgency=medium
* modify changelog for V23 beta
-- linxin Wed, 29 Mar 2023 11:46:38 +0800
golang-github-linuxdeepin-go-x11-client (1.0.0.0) unstable; urgency=medium
* release 1.0.0.0
-- Tue, 14 June 2022 17:11:13 +0800
golang-github-linuxdeepin-go-x11-client (0.0.3) unstable; urgency=medium
* adapt license and copyright
-- dengbo Wed, 14 Sep 2022 16:27:01 +0000
golang-github-linuxdeepin-go-x11-client (0.0.2-1) unstable; urgency=medium
* update
-- Deepin Packages Builder Fri, 15 Dec 2017 17:12:00 +0800
go-x11-client-1.0.2/debian/compat 0000664 0000000 0000000 00000000003 14607133730 0016427 0 ustar 00root root 0000000 0000000 10
go-x11-client-1.0.2/debian/control 0000664 0000000 0000000 00000001531 14607133730 0016633 0 ustar 00root root 0000000 0000000 Source: golang-github-linuxdeepin-go-x11-client
Section: devel
Priority: extra
Maintainer: Deepin Packages Builder
Build-Depends: debhelper (>= 10),
dh-golang,
golang-any,
golang-gopkg-check.v1-dev,
golang-golang-x-text-dev (>=0.0~git20161013),
golang-github-stretchr-testify-dev (>=1.1.4)
Standards-Version: 4.0.0
Homepage: https://github.com/linuxdeepin/go-x11-client
XS-Go-Import-Path: github.com/linuxdeepin/go-x11-client
Testsuite: autopkgtest-pkg-go
Package: golang-github-linuxdeepin-go-x11-client-dev
Architecture: all
Depends: ${shlibs:Depends},
${misc:Depends},
golang-github-gavv-monotime-dev,
golang-gopkg-check.v1-dev
Description: deepin go x11 client
mirrored from https://cr.deepin.io/#/admin/projects/go-x11-client
go-x11-client-1.0.2/debian/copyright 0000664 0000000 0000000 00000001647 14607133730 0017173 0 ustar 00root root 0000000 0000000 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: go-x11-client
Files: *
Copyright: 2017 Deepin Technology Co., Ltd.
License: GPL-3+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
go-x11-client-1.0.2/debian/gbp.conf 0000664 0000000 0000000 00000000036 14607133730 0016646 0 ustar 00root root 0000000 0000000 [DEFAULT]
pristine-tar = True
go-x11-client-1.0.2/debian/rules 0000775 0000000 0000000 00000000436 14607133730 0016313 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
export GOCACHE := /tmp/gocache
export DH_GOLANG_EXCLUDES := tools/gen util/tool/gen-keysymdef
ifeq ($(DEB_BUILD_ARCH),sw_64)
%:
dh $@
else
%:
dh $@ --buildsystem=golang --with=golang
endif
override_dh_auto_clean:
dh_auto_clean --
rm -fr obj-x86_64-linux-gnu
go-x11-client-1.0.2/debian/source/ 0000775 0000000 0000000 00000000000 14607133730 0016530 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/debian/source/format 0000664 0000000 0000000 00000000015 14607133730 0017737 0 ustar 00root root 0000000 0000000 3.0 (native)
go-x11-client-1.0.2/debian/watch 0000664 0000000 0000000 00000000413 14607133730 0016257 0 ustar 00root root 0000000 0000000 version=3
opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/golang-github-linuxdeepin-go-x11-client-\$1\.tar\.gz/,\
uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/\$1~\$2\$3/ \
https://github.com/linuxdeepin/go-x11-client/tags .*/v?(\d\S*)\.tar\.gz
go-x11-client-1.0.2/error.go 0000664 0000000 0000000 00000003621 14607133730 0015470 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import "fmt"
type Error struct {
conn *Conn
Code uint8 // ErrorCode
Sequence uint16 // Sequence number
ResourceID uint32 // Resource ID for requests with side effects only
MinorCode uint16 // Minor opcode of the failed request
MajorCode uint8 // Major opcode of the failed request
}
func (err *Error) Error() string {
var errDesc string
var errName string
if 1 <= err.Code && err.Code <= 127 {
// core error code in range [1,127]
errName = errorCodeNameMap[err.Code]
} else {
// is ext error
errName = err.conn.ext.getExtErrName(err.Code)
}
if errName != "" {
errDesc = " (" + errName + ")"
}
var majorCodeDesc, minorCodeDesc string
if 1 <= err.MajorCode && err.MajorCode <= 127 {
// is core request
reqName := requestOpcodeNameMap[uint(err.MajorCode)]
if reqName != "" {
majorCodeDesc = " (" + reqName + ")"
}
} else {
// is ext request
ext := err.conn.ext.getExtByMajorOpcode(err.MajorCode)
if ext != nil {
reqName := ext.reqOpcodeNameMap[uint(err.MinorCode)]
if reqName != "" {
minorCodeDesc = " (" + reqName + ")"
}
majorCodeDesc = " (" + ext.name + ")"
}
}
return fmt.Sprintf("x.Error: %d%s, sequence: %d, resource id: %d,"+
" major code: %d%s, minor code: %d%s",
err.Code, errDesc, err.Sequence, err.ResourceID,
err.MajorCode, majorCodeDesc,
err.MinorCode, minorCodeDesc)
}
func newError(data []byte) *Error {
var v Error
responseType := data[0]
if responseType != ResponseTypeError {
panic("not error")
}
b := 1
v.Code = data[b]
b += 1
v.Sequence = Get16(data[b:])
b += 2
v.ResourceID = Get32(data[b:])
b += 4
v.MinorCode = Get16(data[b:])
b += 2
v.MajorCode = data[b]
return &v
}
func (c *Conn) NewError(data []byte) *Error {
err := newError(data)
err.conn = c
return err
}
go-x11-client-1.0.2/event.go 0000664 0000000 0000000 00000000700 14607133730 0015453 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"fmt"
)
type GenericEvent []byte
func (ge GenericEvent) GetEventCode() uint8 {
return ge[0] &^ 0x80
}
func (ge GenericEvent) Real() bool {
return ge[0]&0x80 == 0
}
func (ge GenericEvent) String() string {
return fmt.Sprintf("GenericEvent{ EventCode: %d, Real: %v }", ge.GetEventCode(), ge.Real())
}
go-x11-client-1.0.2/ext/ 0000775 0000000 0000000 00000000000 14607133730 0014606 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/bigrequests/ 0000775 0000000 0000000 00000000000 14607133730 0017143 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/bigrequests/auto.go 0000664 0000000 0000000 00000001035 14607133730 0020441 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package bigrequests
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: BigRequests
const MajorVersion = 0
const MinorVersion = 0
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
const EnableOpcode = 0
type EnableCookie x.SeqNum
var requestOpcodeNameMap = map[uint]string{
EnableOpcode: "Enable",
}
func init() {
_ext = x.NewExtension("BIG-REQUESTS", 0, nil, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/bigrequests/bigreq.go 0000664 0000000 0000000 00000000760 14607133730 0020746 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package bigrequests
import "github.com/linuxdeepin/go-x11-client"
// #WREQ
func encodeEnable() (b x.RequestBody) {
return
}
type EnableReply struct {
MaximumRequestLength uint32
}
func readEnableReply(r *x.Reader, v *EnableReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MaximumRequestLength = r.Read4b() // 3
return nil
}
go-x11-client-1.0.2/ext/bigrequests/bigreq_req_auto.go 0000664 0000000 0000000 00000001372 14607133730 0022645 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package bigrequests
import x "github.com/linuxdeepin/go-x11-client"
func Enable(conn *x.Conn) EnableCookie {
body := encodeEnable()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: EnableOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return EnableCookie(seq)
}
func (cookie EnableCookie) Reply(conn *x.Conn) (*EnableReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply EnableReply
err = readEnableReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
go-x11-client-1.0.2/ext/composite/ 0000775 0000000 0000000 00000000000 14607133730 0016610 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/composite/auto.go 0000664 0000000 0000000 00000002622 14607133730 0020111 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package composite
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Composite
const MajorVersion = 0
const MinorVersion = 4
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// enum Redirect
const (
RedirectAutomatic = 0
RedirectManual = 1
)
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
const RedirectWindowOpcode = 1
const RedirectSubwindowsOpcode = 2
const UnredirectWindowOpcode = 3
const UnredirectSubwindowsOpcode = 4
const CreateRegionFromBorderClipOpcode = 5
const NameWindowPixmapOpcode = 6
const GetOverlayWindowOpcode = 7
type GetOverlayWindowCookie x.SeqNum
const ReleaseOverlayWindowOpcode = 8
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
RedirectWindowOpcode: "RedirectWindow",
RedirectSubwindowsOpcode: "RedirectSubwindows",
UnredirectWindowOpcode: "UnredirectWindow",
UnredirectSubwindowsOpcode: "UnredirectSubwindows",
CreateRegionFromBorderClipOpcode: "CreateRegionFromBorderClip",
NameWindowPixmapOpcode: "NameWindowPixmap",
GetOverlayWindowOpcode: "GetOverlayWindow",
ReleaseOverlayWindowOpcode: "ReleaseOverlayWindow",
}
func init() {
_ext = x.NewExtension("Composite", 0, nil, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/composite/composite.go 0000664 0000000 0000000 00000002714 14607133730 0021145 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package composite
import "github.com/linuxdeepin/go-x11-client"
// #WREQ
func encodeQueryVersion(majorVersion, minorVersion uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(majorVersion).
Write4b(minorVersion).
End()
return
}
type QueryVersionReply struct {
MajorVersion uint32
MinorVersion uint32
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read4b()
v.MinorVersion = r.Read4b() // 4
return nil
}
// #WREQ
func encodeRedirectWindow(window x.Window, update uint8) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write1b(update).
WritePad(3).
End()
return
}
// #WREQ
func encodeRedirectSubwindows(window x.Window, update uint8) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write1b(update).
WritePad(3).
End()
return
}
// #WREQ
func encodeUnredirectWindow(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
// #WREQ
func encodeUnredirectSubwindows(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
// #WREQ
func encodeNameWindowPixmap(window x.Window, pixmap x.Pixmap) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write4b(uint32(pixmap)).
End()
return
}
go-x11-client-1.0.2/ext/composite/composite_req_auto.go 0000664 0000000 0000000 00000007731 14607133730 0023050 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package composite
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, majorVersion, minorVersion uint32) QueryVersionCookie {
body := encodeQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func RedirectWindow(conn *x.Conn, window x.Window, update uint8) {
body := encodeRedirectWindow(window, update)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RedirectWindowOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func RedirectWindowChecked(conn *x.Conn, window x.Window, update uint8) x.VoidCookie {
body := encodeRedirectWindow(window, update)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RedirectWindowOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func RedirectSubwindows(conn *x.Conn, window x.Window, update uint8) {
body := encodeRedirectSubwindows(window, update)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RedirectSubwindowsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func RedirectSubwindowsChecked(conn *x.Conn, window x.Window, update uint8) x.VoidCookie {
body := encodeRedirectSubwindows(window, update)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RedirectSubwindowsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func UnredirectWindow(conn *x.Conn, window x.Window) {
body := encodeUnredirectWindow(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnredirectWindowOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func UnredirectWindowChecked(conn *x.Conn, window x.Window) x.VoidCookie {
body := encodeUnredirectWindow(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnredirectWindowOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func UnredirectSubwindows(conn *x.Conn, window x.Window) {
body := encodeUnredirectSubwindows(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnredirectSubwindowsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func UnredirectSubwindowsChecked(conn *x.Conn, window x.Window) x.VoidCookie {
body := encodeUnredirectSubwindows(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnredirectSubwindowsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func NameWindowPixmap(conn *x.Conn, window x.Window, pixmap x.Pixmap) {
body := encodeNameWindowPixmap(window, pixmap)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: NameWindowPixmapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func NameWindowPixmapChecked(conn *x.Conn, window x.Window, pixmap x.Pixmap) x.VoidCookie {
body := encodeNameWindowPixmap(window, pixmap)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: NameWindowPixmapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/damage/ 0000775 0000000 0000000 00000000000 14607133730 0016024 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/damage/auto.go 0000664 0000000 0000000 00000002457 14607133730 0017333 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package damage
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Damage
const MajorVersion = 1
const MinorVersion = 1
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// simple ('xcb', 'Damage', 'DAMAGE')
type Damage uint32
// enum ReportLevel
const (
ReportLevelRawRectangles = 0
ReportLevelDeltaRectangles = 1
ReportLevelBoundingBox = 2
ReportLevelNonEmpty = 3
)
const BadDamageErrorCode = 0
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
const CreateOpcode = 1
const DestroyOpcode = 2
const SubtractOpcode = 3
const AddOpcode = 4
const NotifyEventCode = 0
func NewNotifyEvent(data []byte) (*NotifyEvent, error) {
var ev NotifyEvent
r := x.NewReaderFromData(data)
err := readNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
var errorCodeNameMap = map[uint8]string{
BadDamageErrorCode: "BadDamage",
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
CreateOpcode: "Create",
DestroyOpcode: "Destroy",
SubtractOpcode: "Subtract",
AddOpcode: "Add",
}
func init() {
_ext = x.NewExtension("DAMAGE", 0, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/damage/damage.go 0000664 0000000 0000000 00000003056 14607133730 0017575 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package damage
import (
x "github.com/linuxdeepin/go-x11-client"
)
type NotifyEvent struct {
Level uint8
Sequence uint16
Drawable x.Drawable
Damage Damage
Timestamp x.Timestamp
Area x.Rectangle
Geometry x.Rectangle
}
func readNotifyEvent(r *x.Reader, v *NotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Level, v.Sequence = r.ReadEventHeader()
v.Drawable = x.Drawable(r.Read4b())
v.Damage = Damage(r.Read4b())
v.Timestamp = x.Timestamp(r.Read4b()) // 4
v.Area = x.ReadRectangle(r) // 6
v.Geometry = x.ReadRectangle(r) // 8
return nil
}
// #WREQ
func encodeQueryVersion(majorVersion, minorVersion uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(majorVersion).
Write4b(minorVersion).
End()
return
}
type QueryVersionReply struct {
MajorVersion uint32
MinorVersion uint32
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read4b()
v.MinorVersion = r.Read4b() // 4
return nil
}
// #WREQ
func encodeCreate(damage Damage, drawable x.Drawable, level uint8) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(damage)).
Write4b(uint32(drawable)).
Write1b(level).
WritePad(3).
End()
return
}
// #WREQ
func encodeDestroy(damage Damage) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(damage)).
End()
return
}
// #WREQ
//func Subtract() {
//
//}
go-x11-client-1.0.2/ext/damage/damage_req_auto.go 0000664 0000000 0000000 00000004014 14607133730 0021467 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package damage
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, majorVersion, minorVersion uint32) QueryVersionCookie {
body := encodeQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func Create(conn *x.Conn, damage Damage, drawable x.Drawable, level uint8) {
body := encodeCreate(damage, drawable, level)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateChecked(conn *x.Conn, damage Damage, drawable x.Drawable, level uint8) x.VoidCookie {
body := encodeCreate(damage, drawable, level)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Destroy(conn *x.Conn, damage Damage) {
body := encodeDestroy(damage)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DestroyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DestroyChecked(conn *x.Conn, damage Damage) x.VoidCookie {
body := encodeDestroy(damage)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DestroyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/dpms/ 0000775 0000000 0000000 00000000000 14607133730 0015551 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/dpms/auto.go 0000664 0000000 0000000 00000002163 14607133730 0017052 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package dpms
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: DPMS
const MajorVersion = 0
const MinorVersion = 0
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
const GetVersionOpcode = 0
type GetVersionCookie x.SeqNum
const CapableOpcode = 1
type CapableCookie x.SeqNum
const GetTimeoutsOpcode = 2
type GetTimeoutsCookie x.SeqNum
const SetTimeoutsOpcode = 3
const EnableOpcode = 4
const DisableOpcode = 5
// enum DPMSMode
const (
DPMSModeOn = 0
DPMSModeStandby = 1
DPMSModeSuspend = 2
DPMSModeOff = 3
)
const ForceLevelOpcode = 6
const InfoOpcode = 7
type InfoCookie x.SeqNum
var requestOpcodeNameMap = map[uint]string{
GetVersionOpcode: "GetVersion",
CapableOpcode: "Capable",
GetTimeoutsOpcode: "GetTimeouts",
SetTimeoutsOpcode: "SetTimeouts",
EnableOpcode: "Enable",
DisableOpcode: "Disable",
ForceLevelOpcode: "ForceLevel",
InfoOpcode: "Info",
}
func init() {
_ext = x.NewExtension("DPMS", 0, nil, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/dpms/dpms.go 0000664 0000000 0000000 00000004245 14607133730 0017050 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package dpms
import "github.com/linuxdeepin/go-x11-client"
// #WREQ
func encodeGetVersion(clientMajorVersion, clientMinorVersion uint16) (b x.RequestBody) {
b.AddBlock(1).
Write2b(clientMajorVersion).
Write2b(clientMinorVersion).
End()
return
}
type GetVersionReply struct {
ServerMajorVersion uint16
ServerMinorVersion uint16
}
func readGetVersionReply(r *x.Reader, v *GetVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.ServerMajorVersion = r.Read2b()
v.ServerMinorVersion = r.Read2b() // 3
return nil
}
// #WREQ
func encodeCapable() (b x.RequestBody) {
return
}
type CapableReply struct {
Capable bool
}
func readCapableReply(r *x.Reader, v *CapableReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Capable = r.ReadBool() // 3
return nil
}
// #WREQ
func encodeGetTimeouts() (b x.RequestBody) {
return
}
type GetTimeoutsReply struct {
StandbyTimeout uint16
SuspendTimeout uint16
OffTimeout uint16
}
func readGetTimeoutsReply(r *x.Reader, v *GetTimeoutsReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.StandbyTimeout = r.Read2b()
v.SuspendTimeout = r.Read2b()
v.OffTimeout = r.Read2b() // 4
return nil
}
// #WREQ
func encodeSetTimeouts(standbyTimeout, suspendTimeout, offTimeout uint16) (b x.RequestBody) {
b.AddBlock(2).
Write2b(standbyTimeout).
Write2b(suspendTimeout).
Write2b(offTimeout).
WritePad(2).
End()
return
}
// #WREQ
func encodeEnable() (b x.RequestBody) {
return
}
// #WREQ
func encodeDisable() (b x.RequestBody) {
return
}
// #WREQ
func encodeForceLevel(powerLevel uint16) (b x.RequestBody) {
b.AddBlock(1).
Write2b(powerLevel).
WritePad(2).
End()
return
}
// #WREQ
func encodeInfo() (b x.RequestBody) {
return
}
type InfoReply struct {
PowerLevel uint16
State bool
}
func readInfoReply(r *x.Reader, v *InfoReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.PowerLevel = r.Read2b()
v.State = r.ReadBool() // 3
return nil
}
go-x11-client-1.0.2/ext/dpms/dpms_req_auto.go 0000664 0000000 0000000 00000011474 14607133730 0020751 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package dpms
import x "github.com/linuxdeepin/go-x11-client"
func GetVersion(conn *x.Conn, clientMajorVersion, clientMinorVersion uint16) GetVersionCookie {
body := encodeGetVersion(clientMajorVersion, clientMinorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetVersionCookie(seq)
}
func (cookie GetVersionCookie) Reply(conn *x.Conn) (*GetVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetVersionReply
err = readGetVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func Capable(conn *x.Conn) CapableCookie {
body := encodeCapable()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: CapableOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return CapableCookie(seq)
}
func (cookie CapableCookie) Reply(conn *x.Conn) (*CapableReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply CapableReply
err = readCapableReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetTimeouts(conn *x.Conn) GetTimeoutsCookie {
body := encodeGetTimeouts()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetTimeoutsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetTimeoutsCookie(seq)
}
func (cookie GetTimeoutsCookie) Reply(conn *x.Conn) (*GetTimeoutsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetTimeoutsReply
err = readGetTimeoutsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetTimeouts(conn *x.Conn, standbyTimeout, suspendTimeout, offTimeout uint16) {
body := encodeSetTimeouts(standbyTimeout, suspendTimeout, offTimeout)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetTimeoutsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetTimeoutsChecked(conn *x.Conn, standbyTimeout, suspendTimeout, offTimeout uint16) x.VoidCookie {
body := encodeSetTimeouts(standbyTimeout, suspendTimeout, offTimeout)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetTimeoutsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Enable(conn *x.Conn) {
body := encodeEnable()
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: EnableOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func EnableChecked(conn *x.Conn) x.VoidCookie {
body := encodeEnable()
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: EnableOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Disable(conn *x.Conn) {
body := encodeDisable()
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DisableOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DisableChecked(conn *x.Conn) x.VoidCookie {
body := encodeDisable()
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DisableOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ForceLevel(conn *x.Conn, powerLevel uint16) {
body := encodeForceLevel(powerLevel)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ForceLevelOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ForceLevelChecked(conn *x.Conn, powerLevel uint16) x.VoidCookie {
body := encodeForceLevel(powerLevel)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ForceLevelOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Info(conn *x.Conn) InfoCookie {
body := encodeInfo()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: InfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return InfoCookie(seq)
}
func (cookie InfoCookie) Reply(conn *x.Conn) (*InfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply InfoReply
err = readInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
go-x11-client-1.0.2/ext/ge/ 0000775 0000000 0000000 00000000000 14607133730 0015201 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/ge/auto.go 0000664 0000000 0000000 00000001070 14607133730 0016476 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package ge
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: GenericEvent
const MajorVersion = 1
const MinorVersion = 0
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
}
func init() {
_ext = x.NewExtension("Generic Event Extension", 0, nil, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/ge/ge.go 0000664 0000000 0000000 00000001214 14607133730 0016121 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package ge
import "github.com/linuxdeepin/go-x11-client"
// #WREQ
func encodeQueryVersion(majorVersion, minorVersion uint16) (b x.RequestBody) {
b.AddBlock(1).
Write2b(majorVersion).
Write2b(minorVersion).
End()
return
}
type QueryVersionReply struct {
MajorVersion uint16
MinorVersion uint16
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read2b()
v.MinorVersion = r.Read2b() // 3
return nil
}
go-x11-client-1.0.2/ext/ge/ge_req_auto.go 0000664 0000000 0000000 00000001544 14607133730 0020026 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package ge
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, majorVersion, minorVersion uint16) QueryVersionCookie {
body := encodeQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
go-x11-client-1.0.2/ext/input/ 0000775 0000000 0000000 00000000000 14607133730 0015745 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/input/auto.go 0000664 0000000 0000000 00000063245 14607133730 0017256 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Input
const MajorVersion = 2
const MinorVersion = 3
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// simple ('xcb', 'Input', 'EventClass')
type EventClass uint32
// simple ('xcb', 'Input', 'KeyCode')
type KeyCode uint8
// simple ('xcb', 'Input', 'DeviceId')
type DeviceId uint16
// simple ('xcb', 'Input', 'FP1616')
type Fp1616 int32
const GetExtensionVersionOpcode = 1
type GetExtensionVersionCookie x.SeqNum
// enum DeviceUse
const (
DeviceUseIsXPointer = 0
DeviceUseIsXKeyboard = 1
DeviceUseIsXExtensionDevice = 2
DeviceUseIsXExtensionKeyboard = 3
DeviceUseIsXExtensionPointer = 4
)
// enum InputClass
const (
InputClassKey = 0
InputClassButton = 1
InputClassValuator = 2
InputClassFeedback = 3
InputClassProximity = 4
InputClassFocus = 5
InputClassOther = 6
)
// enum ValuatorMode
const (
ValuatorModeRelative = 0
ValuatorModeAbsolute = 1
)
const ListInputDevicesOpcode = 2
type ListInputDevicesCookie x.SeqNum
// simple ('xcb', 'Input', 'EventTypeBase')
type EventTypeBase uint8
const OpenDeviceOpcode = 3
type OpenDeviceCookie x.SeqNum
const CloseDeviceOpcode = 4
const SetDeviceModeOpcode = 5
type SetDeviceModeCookie x.SeqNum
const SelectExtensionEventOpcode = 6
const GetSelectedExtensionEventsOpcode = 7
type GetSelectedExtensionEventsCookie x.SeqNum
// enum PropagateMode
const (
PropagateModeAddToList = 0
PropagateModeDeleteFromList = 1
)
const ChangeDeviceDontPropagateListOpcode = 8
const GetDeviceDontPropagateListOpcode = 9
type GetDeviceDontPropagateListCookie x.SeqNum
const GetDeviceMotionEventsOpcode = 10
type GetDeviceMotionEventsCookie x.SeqNum
const ChangeKeyboardDeviceOpcode = 11
type ChangeKeyboardDeviceCookie x.SeqNum
const ChangePointerDeviceOpcode = 12
type ChangePointerDeviceCookie x.SeqNum
const GrabDeviceOpcode = 13
type GrabDeviceCookie x.SeqNum
const UngrabDeviceOpcode = 14
// enum ModifierDevice
const (
ModifierDeviceUseXKeyboard = 255
)
const GrabDeviceKeyOpcode = 15
const UngrabDeviceKeyOpcode = 16
const GrabDeviceButtonOpcode = 17
const UngrabDeviceButtonOpcode = 18
// enum DeviceInputMode
const (
DeviceInputModeAsyncThisDevice = 0
DeviceInputModeSyncThisDevice = 1
DeviceInputModeReplayThisDevice = 2
DeviceInputModeAsyncOtherDevices = 3
DeviceInputModeAsyncAll = 4
DeviceInputModeSyncAll = 5
)
const AllowDeviceEventsOpcode = 19
const GetDeviceFocusOpcode = 20
type GetDeviceFocusCookie x.SeqNum
const SetDeviceFocusOpcode = 21
// enum FeedbackClass
const (
FeedbackClassKeyboard = 0
FeedbackClassPointer = 1
FeedbackClassString = 2
FeedbackClassInteger = 3
FeedbackClassLed = 4
FeedbackClassBell = 5
)
const GetFeedbackControlOpcode = 22
type GetFeedbackControlCookie x.SeqNum
// enum ChangeFeedbackControlMask
const (
ChangeFeedbackControlMaskKeyClickPercent = 1
ChangeFeedbackControlMaskPercent = 2
ChangeFeedbackControlMaskPitch = 4
ChangeFeedbackControlMaskDuration = 8
ChangeFeedbackControlMaskLed = 16
ChangeFeedbackControlMaskLedMode = 32
ChangeFeedbackControlMaskKey = 64
ChangeFeedbackControlMaskAutoRepeatMode = 128
ChangeFeedbackControlMaskString = 1
ChangeFeedbackControlMaskInteger = 1
ChangeFeedbackControlMaskAccelNum = 1
ChangeFeedbackControlMaskAccelDenom = 2
ChangeFeedbackControlMaskThreshold = 4
)
const ChangeFeedbackControlOpcode = 23
const GetDeviceKeyMappingOpcode = 24
type GetDeviceKeyMappingCookie x.SeqNum
const ChangeDeviceKeyMappingOpcode = 25
const GetDeviceModifierMappingOpcode = 26
type GetDeviceModifierMappingCookie x.SeqNum
const SetDeviceModifierMappingOpcode = 27
type SetDeviceModifierMappingCookie x.SeqNum
const GetDeviceButtonMappingOpcode = 28
type GetDeviceButtonMappingCookie x.SeqNum
const SetDeviceButtonMappingOpcode = 29
type SetDeviceButtonMappingCookie x.SeqNum
// enum ValuatorStateModeMask
const (
ValuatorStateModeMaskDeviceModeAbsolute = 1
ValuatorStateModeMaskOutOfProximity = 2
)
const QueryDeviceStateOpcode = 30
type QueryDeviceStateCookie x.SeqNum
const DeviceBellOpcode = 32
const SetDeviceValuatorsOpcode = 33
type SetDeviceValuatorsCookie x.SeqNum
// enum DeviceControl
const (
DeviceControlResolution = 1
DeviceControlAbsCalib = 2
DeviceControlCore = 3
DeviceControlEnable = 4
DeviceControlAbsArea = 5
)
const GetDeviceControlOpcode = 34
type GetDeviceControlCookie x.SeqNum
const ChangeDeviceControlOpcode = 35
type ChangeDeviceControlCookie x.SeqNum
const ListDevicePropertiesOpcode = 36
type ListDevicePropertiesCookie x.SeqNum
// enum PropertyFormat
const (
PropertyFormat8Bits = 8
PropertyFormat16Bits = 16
PropertyFormat32Bits = 32
)
const ChangeDevicePropertyOpcode = 37
const DeleteDevicePropertyOpcode = 38
const GetDevicePropertyOpcode = 39
type GetDevicePropertyCookie x.SeqNum
// enum Device
const (
DeviceAll = 0
DeviceAllMaster = 1
)
const XIQueryPointerOpcode = 40
type XIQueryPointerCookie x.SeqNum
const XIWarpPointerOpcode = 41
const XIChangeCursorOpcode = 42
// enum HierarchyChangeType
const (
HierarchyChangeTypeAddMaster = 1
HierarchyChangeTypeRemoveMaster = 2
HierarchyChangeTypeAttachSlave = 3
HierarchyChangeTypeDetachSlave = 4
)
// enum ChangeMode
const (
ChangeModeAttach = 1
ChangeModeFloat = 2
)
const XIChangeHierarchyOpcode = 43
const XISetClientPointerOpcode = 44
const XIGetClientPointerOpcode = 45
type XIGetClientPointerCookie x.SeqNum
// enum XIEventMask
const (
XIEventMaskDeviceChanged = 2
XIEventMaskKeyPress = 4
XIEventMaskKeyRelease = 8
XIEventMaskButtonPress = 16
XIEventMaskButtonRelease = 32
XIEventMaskMotion = 64
XIEventMaskEnter = 128
XIEventMaskLeave = 256
XIEventMaskFocusIn = 512
XIEventMaskFocusOut = 1024
XIEventMaskHierarchy = 2048
XIEventMaskProperty = 4096
XIEventMaskRawKeyPress = 8192
XIEventMaskRawKeyRelease = 16384
XIEventMaskRawButtonPress = 32768
XIEventMaskRawButtonRelease = 65536
XIEventMaskRawMotion = 131072
XIEventMaskTouchBegin = 262144
XIEventMaskTouchUpdate = 524288
XIEventMaskTouchEnd = 1048576
XIEventMaskTouchOwnership = 2097152
XIEventMaskRawTouchBegin = 4194304
XIEventMaskRawTouchUpdate = 8388608
XIEventMaskRawTouchEnd = 16777216
XIEventMaskBarrierHit = 33554432
XIEventMaskBarrierLeave = 67108864
)
const XISelectEventsOpcode = 46
const XIQueryVersionOpcode = 47
type XIQueryVersionCookie x.SeqNum
// enum DeviceClassType
const (
DeviceClassTypeKey = 0
DeviceClassTypeButton = 1
DeviceClassTypeValuator = 2
DeviceClassTypeScroll = 3
DeviceClassTypeTouch = 8
)
// enum DeviceType
const (
DeviceTypeMasterPointer = 1
DeviceTypeMasterKeyboard = 2
DeviceTypeSlavePointer = 3
DeviceTypeSlaveKeyboard = 4
DeviceTypeFloatingSlave = 5
)
// enum ScrollFlags
const (
ScrollFlagsNoEmulation = 1
ScrollFlagsPreferred = 2
)
// enum ScrollType
const (
ScrollTypeVertical = 1
ScrollTypeHorizontal = 2
)
// enum TouchMode
const (
TouchModeDirect = 1
TouchModeDependent = 2
)
const XIQueryDeviceOpcode = 48
type XIQueryDeviceCookie x.SeqNum
const XISetFocusOpcode = 49
const XIGetFocusOpcode = 50
type XIGetFocusCookie x.SeqNum
// enum GrabOwner
const (
GrabOwnerNoOwner = 0
GrabOwnerOwner = 1
)
const XIGrabDeviceOpcode = 51
type XIGrabDeviceCookie x.SeqNum
const XIUngrabDeviceOpcode = 52
// enum EventMode
const (
EventModeAsyncDevice = 0
EventModeSyncDevice = 1
EventModeReplayDevice = 2
EventModeAsyncPairedDevice = 3
EventModeAsyncPair = 4
EventModeSyncPair = 5
EventModeAcceptTouch = 6
EventModeRejectTouch = 7
)
const XIAllowEventsOpcode = 53
// enum GrabMode22
const (
GrabMode22Sync = 0
GrabMode22Async = 1
GrabMode22Touch = 2
)
// enum GrabType
const (
GrabTypeButton = 0
GrabTypeKeycode = 1
GrabTypeEnter = 2
GrabTypeFocusIn = 3
GrabTypeTouchBegin = 4
)
// enum ModifierMask
const (
ModifierMaskAny = 2147483648
)
const XIPassiveGrabDeviceOpcode = 54
type XIPassiveGrabDeviceCookie x.SeqNum
const XIPassiveUngrabDeviceOpcode = 55
const XIListPropertiesOpcode = 56
type XIListPropertiesCookie x.SeqNum
const XIChangePropertyOpcode = 57
const XIDeletePropertyOpcode = 58
const XIGetPropertyOpcode = 59
type XIGetPropertyCookie x.SeqNum
const XIGetSelectedEventsOpcode = 60
type XIGetSelectedEventsCookie x.SeqNum
const XIBarrierReleasePointerOpcode = 61
const DeviceValuatorEventCode = 0
func NewDeviceValuatorEvent(data []byte) (*DeviceValuatorEvent, error) {
var ev DeviceValuatorEvent
r := x.NewReaderFromData(data)
err := readDeviceValuatorEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum MoreEventsMask
const (
MoreEventsMaskMoreEvents = 128
)
const DeviceKeyPressEventCode = 1
func NewDeviceKeyPressEvent(data []byte) (*DeviceKeyPressEvent, error) {
var ev DeviceKeyPressEvent
r := x.NewReaderFromData(data)
err := readDeviceKeyPressEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceKeyReleaseEventCode = 2
func NewDeviceKeyReleaseEvent(data []byte) (*DeviceKeyReleaseEvent, error) {
var ev DeviceKeyReleaseEvent
r := x.NewReaderFromData(data)
err := readDeviceKeyReleaseEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceButtonPressEventCode = 3
func NewDeviceButtonPressEvent(data []byte) (*DeviceButtonPressEvent, error) {
var ev DeviceButtonPressEvent
r := x.NewReaderFromData(data)
err := readDeviceButtonPressEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceButtonReleaseEventCode = 4
func NewDeviceButtonReleaseEvent(data []byte) (*DeviceButtonReleaseEvent, error) {
var ev DeviceButtonReleaseEvent
r := x.NewReaderFromData(data)
err := readDeviceButtonReleaseEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceMotionNotifyEventCode = 5
func NewDeviceMotionNotifyEvent(data []byte) (*DeviceMotionNotifyEvent, error) {
var ev DeviceMotionNotifyEvent
r := x.NewReaderFromData(data)
err := readDeviceMotionNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceFocusInEventCode = 6
func NewDeviceFocusInEvent(data []byte) (*DeviceFocusInEvent, error) {
var ev DeviceFocusInEvent
r := x.NewReaderFromData(data)
err := readDeviceFocusInEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceFocusOutEventCode = 7
func NewDeviceFocusOutEvent(data []byte) (*DeviceFocusOutEvent, error) {
var ev DeviceFocusOutEvent
r := x.NewReaderFromData(data)
err := readDeviceFocusOutEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const ProximityInEventCode = 8
func NewProximityInEvent(data []byte) (*ProximityInEvent, error) {
var ev ProximityInEvent
r := x.NewReaderFromData(data)
err := readProximityInEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const ProximityOutEventCode = 9
func NewProximityOutEvent(data []byte) (*ProximityOutEvent, error) {
var ev ProximityOutEvent
r := x.NewReaderFromData(data)
err := readProximityOutEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum ClassesReportedMask
const (
ClassesReportedMaskOutOfProximity = 128
ClassesReportedMaskDeviceModeAbsolute = 64
ClassesReportedMaskReportingValuators = 4
ClassesReportedMaskReportingButtons = 2
ClassesReportedMaskReportingKeys = 1
)
const DeviceStateNotifyEventCode = 10
func NewDeviceStateNotifyEvent(data []byte) (*DeviceStateNotifyEvent, error) {
var ev DeviceStateNotifyEvent
r := x.NewReaderFromData(data)
err := readDeviceStateNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceMappingNotifyEventCode = 11
func NewDeviceMappingNotifyEvent(data []byte) (*DeviceMappingNotifyEvent, error) {
var ev DeviceMappingNotifyEvent
r := x.NewReaderFromData(data)
err := readDeviceMappingNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum ChangeDevice
const (
ChangeDeviceNewPointer = 0
ChangeDeviceNewKeyboard = 1
)
const ChangeDeviceNotifyEventCode = 12
func NewChangeDeviceNotifyEvent(data []byte) (*ChangeDeviceNotifyEvent, error) {
var ev ChangeDeviceNotifyEvent
r := x.NewReaderFromData(data)
err := readChangeDeviceNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceKeyStateNotifyEventCode = 13
func NewDeviceKeyStateNotifyEvent(data []byte) (*DeviceKeyStateNotifyEvent, error) {
var ev DeviceKeyStateNotifyEvent
r := x.NewReaderFromData(data)
err := readDeviceKeyStateNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DeviceButtonStateNotifyEventCode = 14
func NewDeviceButtonStateNotifyEvent(data []byte) (*DeviceButtonStateNotifyEvent, error) {
var ev DeviceButtonStateNotifyEvent
r := x.NewReaderFromData(data)
err := readDeviceButtonStateNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum DeviceChange
const (
DeviceChangeAdded = 0
DeviceChangeRemoved = 1
DeviceChangeEnabled = 2
DeviceChangeDisabled = 3
DeviceChangeUnrecoverable = 4
DeviceChangeControlChanged = 5
)
const DevicePresenceNotifyEventCode = 15
func NewDevicePresenceNotifyEvent(data []byte) (*DevicePresenceNotifyEvent, error) {
var ev DevicePresenceNotifyEvent
r := x.NewReaderFromData(data)
err := readDevicePresenceNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const DevicePropertyNotifyEventCode = 16
func NewDevicePropertyNotifyEvent(data []byte) (*DevicePropertyNotifyEvent, error) {
var ev DevicePropertyNotifyEvent
r := x.NewReaderFromData(data)
err := readDevicePropertyNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum ChangeReason
const (
ChangeReasonSlaveSwitch = 1
ChangeReasonDeviceChange = 2
)
const DeviceChangedEventCode = 1
func NewDeviceChangedEvent(data []byte) (*DeviceChangedEvent, error) {
var ev DeviceChangedEvent
r := x.NewReaderFromData(data)
err := readDeviceChangedEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum KeyEventFlags
const (
KeyEventFlagsKeyRepeat = 65536
)
const KeyPressEventCode = 2
func NewKeyPressEvent(data []byte) (*KeyPressEvent, error) {
var ev KeyPressEvent
r := x.NewReaderFromData(data)
err := readKeyPressEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const KeyReleaseEventCode = 3
func NewKeyReleaseEvent(data []byte) (*KeyReleaseEvent, error) {
var ev KeyReleaseEvent
r := x.NewReaderFromData(data)
err := readKeyReleaseEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum PointerEventFlags
const (
PointerEventFlagsPointerEmulated = 65536
)
const ButtonPressEventCode = 4
func NewButtonPressEvent(data []byte) (*ButtonPressEvent, error) {
var ev ButtonPressEvent
r := x.NewReaderFromData(data)
err := readButtonPressEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const ButtonReleaseEventCode = 5
func NewButtonReleaseEvent(data []byte) (*ButtonReleaseEvent, error) {
var ev ButtonReleaseEvent
r := x.NewReaderFromData(data)
err := readButtonReleaseEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const MotionEventCode = 6
func NewMotionEvent(data []byte) (*MotionEvent, error) {
var ev MotionEvent
r := x.NewReaderFromData(data)
err := readMotionEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum NotifyMode
const (
NotifyModeNormal = 0
NotifyModeGrab = 1
NotifyModeUngrab = 2
NotifyModeWhileGrabbed = 3
NotifyModePassiveGrab = 4
NotifyModePassiveUngrab = 5
)
// enum NotifyDetail
const (
NotifyDetailAncestor = 0
NotifyDetailVirtual = 1
NotifyDetailInferior = 2
NotifyDetailNonlinear = 3
NotifyDetailNonlinearVirtual = 4
NotifyDetailPointer = 5
NotifyDetailPointerRoot = 6
NotifyDetailNone = 7
)
const EnterEventCode = 7
func NewEnterEvent(data []byte) (*EnterEvent, error) {
var ev EnterEvent
r := x.NewReaderFromData(data)
err := readEnterEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const LeaveEventCode = 8
func NewLeaveEvent(data []byte) (*LeaveEvent, error) {
var ev LeaveEvent
r := x.NewReaderFromData(data)
err := readLeaveEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const FocusInEventCode = 9
func NewFocusInEvent(data []byte) (*FocusInEvent, error) {
var ev FocusInEvent
r := x.NewReaderFromData(data)
err := readFocusInEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const FocusOutEventCode = 10
func NewFocusOutEvent(data []byte) (*FocusOutEvent, error) {
var ev FocusOutEvent
r := x.NewReaderFromData(data)
err := readFocusOutEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum HierarchyMask
const (
HierarchyMaskMasterAdded = 1
HierarchyMaskMasterRemoved = 2
HierarchyMaskSlaveAdded = 4
HierarchyMaskSlaveRemoved = 8
HierarchyMaskSlaveAttached = 16
HierarchyMaskSlaveDetached = 32
HierarchyMaskDeviceEnabled = 64
HierarchyMaskDeviceDisabled = 128
)
const HierarchyEventCode = 11
func NewHierarchyEvent(data []byte) (*HierarchyEvent, error) {
var ev HierarchyEvent
r := x.NewReaderFromData(data)
err := readHierarchyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum PropertyFlag
const (
PropertyFlagDeleted = 0
PropertyFlagCreated = 1
PropertyFlagModified = 2
)
const PropertyEventCode = 12
func NewPropertyEvent(data []byte) (*PropertyEvent, error) {
var ev PropertyEvent
r := x.NewReaderFromData(data)
err := readPropertyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawKeyPressEventCode = 13
func NewRawKeyPressEvent(data []byte) (*RawKeyPressEvent, error) {
var ev RawKeyPressEvent
r := x.NewReaderFromData(data)
err := readRawKeyPressEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawKeyReleaseEventCode = 14
func NewRawKeyReleaseEvent(data []byte) (*RawKeyReleaseEvent, error) {
var ev RawKeyReleaseEvent
r := x.NewReaderFromData(data)
err := readRawKeyReleaseEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawButtonPressEventCode = 15
func NewRawButtonPressEvent(data []byte) (*RawButtonPressEvent, error) {
var ev RawButtonPressEvent
r := x.NewReaderFromData(data)
err := readRawButtonPressEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawButtonReleaseEventCode = 16
func NewRawButtonReleaseEvent(data []byte) (*RawButtonReleaseEvent, error) {
var ev RawButtonReleaseEvent
r := x.NewReaderFromData(data)
err := readRawButtonReleaseEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawMotionEventCode = 17
func NewRawMotionEvent(data []byte) (*RawMotionEvent, error) {
var ev RawMotionEvent
r := x.NewReaderFromData(data)
err := readRawMotionEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum TouchEventFlags
const (
TouchEventFlagsTouchPendingEnd = 65536
TouchEventFlagsTouchEmulatingPointer = 131072
)
const TouchBeginEventCode = 18
func NewTouchBeginEvent(data []byte) (*TouchBeginEvent, error) {
var ev TouchBeginEvent
r := x.NewReaderFromData(data)
err := readTouchBeginEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const TouchUpdateEventCode = 19
func NewTouchUpdateEvent(data []byte) (*TouchUpdateEvent, error) {
var ev TouchUpdateEvent
r := x.NewReaderFromData(data)
err := readTouchUpdateEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const TouchEndEventCode = 20
func NewTouchEndEvent(data []byte) (*TouchEndEvent, error) {
var ev TouchEndEvent
r := x.NewReaderFromData(data)
err := readTouchEndEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum TouchOwnershipFlags
const (
TouchOwnershipFlagsNone = 0
)
const TouchOwnershipEventCode = 21
func NewTouchOwnershipEvent(data []byte) (*TouchOwnershipEvent, error) {
var ev TouchOwnershipEvent
r := x.NewReaderFromData(data)
err := readTouchOwnershipEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawTouchBeginEventCode = 22
func NewRawTouchBeginEvent(data []byte) (*RawTouchBeginEvent, error) {
var ev RawTouchBeginEvent
r := x.NewReaderFromData(data)
err := readRawTouchBeginEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawTouchUpdateEventCode = 23
func NewRawTouchUpdateEvent(data []byte) (*RawTouchUpdateEvent, error) {
var ev RawTouchUpdateEvent
r := x.NewReaderFromData(data)
err := readRawTouchUpdateEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const RawTouchEndEventCode = 24
func NewRawTouchEndEvent(data []byte) (*RawTouchEndEvent, error) {
var ev RawTouchEndEvent
r := x.NewReaderFromData(data)
err := readRawTouchEndEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum BarrierFlags
const (
BarrierFlagsPointerReleased = 1
BarrierFlagsDeviceIsGrabbed = 2
)
const BarrierHitEventCode = 25
func NewBarrierHitEvent(data []byte) (*BarrierHitEvent, error) {
var ev BarrierHitEvent
r := x.NewReaderFromData(data)
err := readBarrierHitEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const BarrierLeaveEventCode = 26
func NewBarrierLeaveEvent(data []byte) (*BarrierLeaveEvent, error) {
var ev BarrierLeaveEvent
r := x.NewReaderFromData(data)
err := readBarrierLeaveEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const SendExtensionEventOpcode = 31
const DeviceErrorCode = 0
const EventErrorCode = 1
const ModeErrorCode = 2
const DeviceBusyErrorCode = 3
const ClassErrorCode = 4
var errorCodeNameMap = map[uint8]string{
DeviceErrorCode: "BadDevice",
EventErrorCode: "BadEvent",
ModeErrorCode: "BadMode",
DeviceBusyErrorCode: "DeviceBusy",
ClassErrorCode: "BadClass",
}
var requestOpcodeNameMap = map[uint]string{
GetExtensionVersionOpcode: "GetExtensionVersion",
ListInputDevicesOpcode: "ListInputDevices",
OpenDeviceOpcode: "OpenDevice",
CloseDeviceOpcode: "CloseDevice",
SetDeviceModeOpcode: "SetDeviceMode",
SelectExtensionEventOpcode: "SelectExtensionEvent",
GetSelectedExtensionEventsOpcode: "GetSelectedExtensionEvents",
ChangeDeviceDontPropagateListOpcode: "ChangeDeviceDontPropagateList",
GetDeviceDontPropagateListOpcode: "GetDeviceDontPropagateList",
GetDeviceMotionEventsOpcode: "GetDeviceMotionEvents",
ChangeKeyboardDeviceOpcode: "ChangeKeyboardDevice",
ChangePointerDeviceOpcode: "ChangePointerDevice",
GrabDeviceOpcode: "GrabDevice",
UngrabDeviceOpcode: "UngrabDevice",
GrabDeviceKeyOpcode: "GrabDeviceKey",
UngrabDeviceKeyOpcode: "UngrabDeviceKey",
GrabDeviceButtonOpcode: "GrabDeviceButton",
UngrabDeviceButtonOpcode: "UngrabDeviceButton",
AllowDeviceEventsOpcode: "AllowDeviceEvents",
GetDeviceFocusOpcode: "GetDeviceFocus",
SetDeviceFocusOpcode: "SetDeviceFocus",
GetFeedbackControlOpcode: "GetFeedbackControl",
ChangeFeedbackControlOpcode: "ChangeFeedbackControl",
GetDeviceKeyMappingOpcode: "GetDeviceKeyMapping",
ChangeDeviceKeyMappingOpcode: "ChangeDeviceKeyMapping",
GetDeviceModifierMappingOpcode: "GetDeviceModifierMapping",
SetDeviceModifierMappingOpcode: "SetDeviceModifierMapping",
GetDeviceButtonMappingOpcode: "GetDeviceButtonMapping",
SetDeviceButtonMappingOpcode: "SetDeviceButtonMapping",
QueryDeviceStateOpcode: "QueryDeviceState",
DeviceBellOpcode: "DeviceBell",
SetDeviceValuatorsOpcode: "SetDeviceValuators",
GetDeviceControlOpcode: "GetDeviceControl",
ChangeDeviceControlOpcode: "ChangeDeviceControl",
ListDevicePropertiesOpcode: "ListDeviceProperties",
ChangeDevicePropertyOpcode: "ChangeDeviceProperty",
DeleteDevicePropertyOpcode: "DeleteDeviceProperty",
GetDevicePropertyOpcode: "GetDeviceProperty",
XIQueryPointerOpcode: "XIQueryPointer",
XIWarpPointerOpcode: "XIWarpPointer",
XIChangeCursorOpcode: "XIChangeCursor",
XIChangeHierarchyOpcode: "XIChangeHierarchy",
XISetClientPointerOpcode: "XISetClientPointer",
XIGetClientPointerOpcode: "XIGetClientPointer",
XISelectEventsOpcode: "XISelectEvents",
XIQueryVersionOpcode: "XIQueryVersion",
XIQueryDeviceOpcode: "XIQueryDevice",
XISetFocusOpcode: "XISetFocus",
XIGetFocusOpcode: "XIGetFocus",
XIGrabDeviceOpcode: "XIGrabDevice",
XIUngrabDeviceOpcode: "XIUngrabDevice",
XIAllowEventsOpcode: "XIAllowEvents",
XIPassiveGrabDeviceOpcode: "XIPassiveGrabDevice",
XIPassiveUngrabDeviceOpcode: "XIPassiveUngrabDevice",
XIListPropertiesOpcode: "XIListProperties",
XIChangePropertyOpcode: "XIChangeProperty",
XIDeletePropertyOpcode: "XIDeleteProperty",
XIGetPropertyOpcode: "XIGetProperty",
XIGetSelectedEventsOpcode: "XIGetSelectedEvents",
XIBarrierReleasePointerOpcode: "XIBarrierReleasePointer",
SendExtensionEventOpcode: "SendExtensionEvent",
}
func init() {
_ext = x.NewExtension("XInputExtension", 4, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/input/input.go 0000664 0000000 0000000 00000050064 14607133730 0017440 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import (
"github.com/linuxdeepin/go-x11-client"
)
// FP1616 size: 1 * 4b
func readFP1616(r *x.Reader) float32 {
value := int32(r.Read4b())
ret := float32(value) / float32(1<<16)
return ret
}
func writeFP1616(b *x.FixedSizeBuf, value float32) {
b.Write4b(uint32(int32(value * float32(1<<16))))
}
// FP3232 size: 2 * 4b
func readFP3232(r *x.Reader) float64 {
integral := int32(r.Read4b())
frac := r.Read4b() // 2
ret := float64(integral) + (float64(frac) * (1.0 / (1 << 32)))
return ret
}
// #WREQ
func encodeXIQueryVersion(majorVersion, minorVersion uint16) (b x.RequestBody) {
b.AddBlock(1).
Write2b(majorVersion).
Write2b(minorVersion).
End()
return
}
type XIQueryVersionReply struct {
MajorVersion uint16
MinorVersion uint16
}
func readXIQueryVersionReply(r *x.Reader, v *XIQueryVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read2b()
v.MinorVersion = r.Read2b() // 3
return nil
}
// #WREQ
func encodeXIQueryDevice(deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(1).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
type XIQueryDeviceReply struct {
Infos []XIDeviceInfo
}
func readXIQueryDeviceReply(r *x.Reader, v *XIQueryDeviceReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
infosLen := int(r.Read2b())
r.ReadPad(22) // 8
if infosLen > 0 {
v.Infos = make([]XIDeviceInfo, infosLen)
for i := 0; i < infosLen; i++ {
err := readXIDeviceInfo(r, &v.Infos[i])
if err != nil {
return err
}
}
}
return nil
}
type XIDeviceInfo struct {
Id DeviceId
Type uint16
Attachment DeviceId
Enabled bool
Name string
Classes []DeviceClass
}
func readXIDeviceInfo(r *x.Reader, v *XIDeviceInfo) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.Id = DeviceId(r.Read2b())
v.Type = r.Read2b()
v.Attachment = DeviceId(r.Read2b())
classesLen := int(r.Read2b())
nameLen := int(r.Read2b())
v.Enabled = r.ReadBool()
r.ReadPad(1) // 3
var err error
v.Name, err = r.ReadStrWithPad(nameLen)
if err != nil {
return err
}
// classes
if classesLen > 0 {
v.Classes = make([]DeviceClass, classesLen)
for i := 0; i < classesLen; i++ {
v.Classes[i], err = readDeviceClass(r)
if err != nil {
return err
}
}
}
return nil
}
type DeviceClass interface {
GetDeviceClassType() uint16
GetSourceId() DeviceId
}
func readDeviceClass(r *x.Reader) (DeviceClass, error) {
var gdc GenericDeviceClass
err := readGenericDeviceClass(r, &gdc)
if err != nil {
return nil, err
}
dataReader := x.NewReaderFromData(gdc.Data)
var ret DeviceClass = &gdc
switch gdc.Type {
case DeviceClassTypeKey:
var c KeyClass
c.SourceId = gdc.SourceId
err := readKeyClass(dataReader, &c)
if err != nil {
return nil, err
}
ret = &c
case DeviceClassTypeButton:
var c ButtonClass
c.SourceId = gdc.SourceId
err := readButtonClass(dataReader, &c)
if err != nil {
return nil, err
}
ret = &c
case DeviceClassTypeValuator:
var c ValuatorClass
c.SourceId = gdc.SourceId
err := readValuatorClass(dataReader, &c)
if err != nil {
return nil, err
}
ret = &c
case DeviceClassTypeScroll:
var c ScrollClass
c.SourceId = gdc.SourceId
err := readScrollClass(dataReader, &c)
if err != nil {
return nil, err
}
ret = &c
case DeviceClassTypeTouch:
var c TouchClass
c.SourceId = gdc.SourceId
err := readTouchClass(dataReader, &c)
if err != nil {
return nil, err
}
ret = &c
}
return ret, nil
}
type GenericDeviceClass struct {
Type uint16
Len uint16
SourceId DeviceId
Data []byte
}
func (dc *GenericDeviceClass) GetDeviceClassType() uint16 {
return dc.Type
}
func (dc *GenericDeviceClass) GetSourceId() DeviceId {
return dc.SourceId
}
func readGenericDeviceClass(r *x.Reader, v *GenericDeviceClass) error {
if !r.RemainAtLeast(6) {
return x.ErrDataLenShort
}
v.Type = r.Read2b()
v.Len = r.Read2b()
v.SourceId = DeviceId(r.Read2b())
// TODO: 检查传入 ReadBytes 的值大于 0
var err error
v.Data, err = r.ReadBytes((int(v.Len) * 4) - 6)
if err != nil {
return err
}
return nil
}
type KeyClass struct {
SourceId DeviceId
NumKeys uint16
Keys []uint32
}
func (*KeyClass) GetDeviceClassType() uint16 {
return DeviceClassTypeKey
}
func (kc *KeyClass) GetSourceId() DeviceId {
return kc.SourceId
}
func readKeyClass(r *x.Reader, v *KeyClass) error {
if !r.RemainAtLeast(2) {
return x.ErrDataLenShort
}
v.NumKeys = r.Read2b()
numKeys := int(v.NumKeys)
if numKeys > 0 {
if !r.RemainAtLeast4b(numKeys) {
return x.ErrDataLenShort
}
v.Keys = make([]uint32, numKeys)
for i := 0; i < numKeys; i++ {
v.Keys[i] = r.Read4b()
}
}
return nil
}
type ButtonClass struct {
SourceId DeviceId
NumButtons uint16
State []uint32
Labels []x.Atom
}
func (*ButtonClass) GetDeviceClassType() uint16 {
return DeviceClassTypeButton
}
func (bc *ButtonClass) GetSourceId() DeviceId {
return bc.SourceId
}
func readButtonClass(r *x.Reader, v *ButtonClass) error {
if !r.RemainAtLeast(2) {
return x.ErrDataLenShort
}
v.NumButtons = r.Read2b()
numButtons := int(v.NumButtons)
stateLen := (numButtons + 31) / 32
if stateLen > 0 {
if !r.RemainAtLeast4b(stateLen) {
return x.ErrDataLenShort
}
v.State = make([]uint32, stateLen)
for i := 0; i < stateLen; i++ {
v.State[i] = r.Read4b()
}
}
if numButtons > 0 {
if !r.RemainAtLeast4b(numButtons) {
return x.ErrDataLenShort
}
v.Labels = make([]x.Atom, numButtons)
for i := 0; i < numButtons; i++ {
v.Labels[i] = x.Atom(r.Read4b())
}
}
return nil
}
// also called AxisClass
type ValuatorClass struct {
SourceId DeviceId
Number uint16
Label x.Atom
Min float64
Max float64
Value float64
Resolution uint32
Mode uint8
}
func (*ValuatorClass) GetDeviceClassType() uint16 {
return DeviceClassTypeValuator
}
func (vc *ValuatorClass) GetSourceId() DeviceId {
return vc.SourceId
}
func readValuatorClass(r *x.Reader, v *ValuatorClass) error {
if !r.RemainAtLeast(20) {
return x.ErrDataLenShort
}
v.Number = r.Read2b()
v.Label = x.Atom(r.Read4b())
v.Min = readFP3232(r)
v.Max = readFP3232(r)
v.Value = readFP3232(r) // 12b
v.Resolution = r.Read4b()
v.Mode = r.Read1b()
r.ReadPad(3) // 20b
return nil
}
type ScrollClass struct {
SourceId DeviceId
Number uint16
ScrollType uint16
Flags uint32
Increment float64
}
func (*ScrollClass) GetDeviceClassType() uint16 {
return DeviceClassTypeScroll
}
func (sc *ScrollClass) GetSourceId() DeviceId {
return sc.SourceId
}
func readScrollClass(r *x.Reader, v *ScrollClass) error {
if !r.RemainAtLeast(18) {
return x.ErrDataLenShort
}
v.Number = r.Read2b()
v.ScrollType = r.Read2b()
r.ReadPad(2)
v.Flags = r.Read4b()
v.Increment = readFP3232(r) // 18b
return nil
}
type TouchClass struct {
SourceId DeviceId
Mode uint8
NumTouches uint8
}
func (*TouchClass) GetDeviceClassType() uint16 {
return DeviceClassTypeTouch
}
func (tc *TouchClass) GetSourceId() DeviceId {
return tc.SourceId
}
func readTouchClass(r *x.Reader, v *TouchClass) error {
if !r.RemainAtLeast(2) {
return x.ErrDataLenShort
}
v.Mode = r.Read1b()
v.NumTouches = r.Read1b()
return nil
}
// #WREQ
func encodeXISelectEvents(window x.Window, masks []EventMask) (b x.RequestBody) {
var masksSize int
for _, mask := range masks {
masksSize += mask.getSizeIn4b()
}
b0 := b.AddBlock(2 + masksSize).
Write4b(uint32(window)).
Write2b(uint16(len(masks))).
WritePad(2)
for _, mask := range masks {
writeEventMask(b0, mask)
}
b0.End()
return
}
type EventMask struct {
DeviceId DeviceId
Mask []uint32
}
func (ev *EventMask) getSizeIn4b() int {
return 1 + len(ev.Mask)
}
func writeEventMask(b *x.FixedSizeBuf, v EventMask) {
maskLen := len(v.Mask)
b.Write2b(uint16(v.DeviceId)).
Write2b(uint16(maskLen))
for _, mask := range v.Mask {
b.Write4b(mask)
}
}
func readEventMask(r *x.Reader, v *EventMask) error {
if !r.RemainAtLeast(4) {
return x.ErrDataLenShort
}
v.DeviceId = DeviceId(r.Read2b())
maskLen := int(r.Read2b())
if maskLen > 0 {
if !r.RemainAtLeast4b(maskLen) {
return x.ErrDataLenShort
}
v.Mask = make([]uint32, maskLen)
for i := 0; i < maskLen; i++ {
v.Mask[i] = r.Read4b()
}
}
return nil
}
// #WREQ
func encodeXIGetSelectedEvents(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type XIGetSelectedEventsReply struct {
Masks []EventMask
}
func readXIGetSelectedEventsReply(r *x.Reader, v *XIGetSelectedEventsReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
masksLen := int(r.Read2b())
r.ReadPad(22) // 8
if masksLen > 0 {
v.Masks = make([]EventMask, masksLen)
for i := 0; i < masksLen; i++ {
err := readEventMask(r, &v.Masks[i])
if err != nil {
return err
}
}
}
return nil
}
// #WREQ
func encodeXIQueryPointer(window x.Window, deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
type XIQueryPointerReply struct {
Root x.Window
Child x.Window
RootX float32
RootY float32
WinX float32
WinY float32
SameScreen bool
Buttons []uint32
Mods ModifierInfo
Group GroupInfo
}
func readXIQueryPointerReply(r *x.Reader, v *XIQueryPointerReply) error {
if !r.RemainAtLeast4b(14) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Root = x.Window(r.Read4b())
v.Child = x.Window(r.Read4b()) // 4
v.RootX = readFP1616(r)
v.RootY = readFP1616(r)
v.WinX = readFP1616(r)
v.WinY = readFP1616(r) // 8
v.SameScreen = r.ReadBool()
r.ReadPad(1)
buttonsLen := int(r.Read2b()) // 9
// mods
readModifierInfo(r, &v.Mods) // 13
// group
readGroupInfo(r, &v.Group) // 14
if buttonsLen > 0 {
if !r.RemainAtLeast4b(buttonsLen) {
return x.ErrDataLenShort
}
v.Buttons = make([]uint32, buttonsLen)
for i := 0; i < buttonsLen; i++ {
v.Buttons[i] = r.Read4b()
}
}
return nil
}
// size: 4 * 4b
type ModifierInfo struct {
Base uint32
Latched uint32
Locked uint32
Effective uint32
}
func readModifierInfo(r *x.Reader, v *ModifierInfo) {
v.Base = r.Read4b()
v.Latched = r.Read4b()
v.Locked = r.Read4b()
v.Effective = r.Read4b()
}
// size: 1 * 4b
type GroupInfo struct {
Base uint8
Latched uint8
Locked uint8
Effective uint8
}
func readGroupInfo(r *x.Reader, v *GroupInfo) {
v.Base = r.Read1b()
v.Latched = r.Read1b()
v.Locked = r.Read1b()
v.Effective = r.Read1b()
}
// #WREQ
func encodeXIWarpPointer(srcWin, dstWin x.Window, srcX, srcY float32, srcWidth,
srcHeight uint16, dstX, dstY float32, deviceId DeviceId) (b x.RequestBody) {
b0 := b.AddBlock(8).
Write4b(uint32(srcWin)).
Write4b(uint32(dstWin))
writeFP1616(b0, srcX)
writeFP1616(b0, srcY)
b0.Write2b(srcWidth).
Write2b(srcHeight)
writeFP1616(b0, dstX)
writeFP1616(b0, dstY)
b0.Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
// #WREQ
func encodeXIChangeCursor(window x.Window, cursor x.Cursor, deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(window)).
Write4b(uint32(cursor)).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
// #WREQ
func encodeXIChangeHierarchy(changes []HierarchyChange) (b x.RequestBody) {
var changesSize int
for _, change := range changes {
changesSize += int(change.getLen())
}
b0 := b.AddBlock(1 + changesSize).
Write1b(uint8(len(changes))).
WritePad(3)
for _, change := range changes {
writeHierarchyChange(b0, change)
}
b0.End()
return
}
func writeHierarchyChange(b *x.FixedSizeBuf, v HierarchyChange) {
b.Write2b(v.getHierarchyType())
b.Write2b(v.getLen() + 1)
v.writeTo(b)
}
type HierarchyChange interface {
writeTo(b *x.FixedSizeBuf)
getHierarchyType() uint16
getLen() uint16 // Length in 4 byte units.
}
// size (1 + (len(Name) + pad(len(name))) / 4) * 4 byte
type AddMaster struct {
SendCore bool
Enable bool
Name string
}
func (am *AddMaster) writeTo(b *x.FixedSizeBuf) {
nameLen := len(am.Name)
b.Write2b(uint16(nameLen))
b.WriteBool(am.SendCore)
b.WriteBool(am.Enable)
b.WriteString(am.Name)
b.WritePad(x.Pad(nameLen))
}
func (*AddMaster) getHierarchyType() uint16 {
return HierarchyChangeTypeAddMaster
}
func (am *AddMaster) getLen() uint16 {
nameLen := len(am.Name)
return uint16(1 + (nameLen+x.Pad(nameLen))/4)
}
// size 2 * 4byte
type RemoveMaster struct {
DeviceId DeviceId
ReturnMode uint8
ReturnPointer DeviceId
ReturnKeyboard DeviceId
}
func (rm *RemoveMaster) writeTo(b *x.FixedSizeBuf) {
b.Write2b(uint16(rm.DeviceId))
b.Write1b(rm.ReturnMode)
b.WritePad(1)
b.Write2b(uint16(rm.ReturnPointer))
b.Write2b(uint16(rm.ReturnKeyboard))
}
func (*RemoveMaster) getHierarchyType() uint16 {
return HierarchyChangeTypeRemoveMaster
}
func (rm *RemoveMaster) getLen() uint16 {
return 2
}
// size 1 * 4 byte
type AttachSlave struct {
DeviceId DeviceId
Master DeviceId
}
func (as *AttachSlave) writeTo(b *x.FixedSizeBuf) {
b.Write2b(uint16(as.DeviceId))
b.Write2b(uint16(as.Master))
}
func (*AttachSlave) getHierarchyType() uint16 {
return HierarchyChangeTypeAttachSlave
}
func (as *AttachSlave) getLen() uint16 {
return 1
}
// size 1 * 4 byte
type DetachSlave struct {
DeviceId DeviceId
}
func (ds *DetachSlave) writeTo(b *x.FixedSizeBuf) {
b.Write2b(uint16(ds.DeviceId))
b.WritePad(2)
}
func (*DetachSlave) getHierarchyType() uint16 {
return HierarchyChangeTypeDetachSlave
}
func (ds *DetachSlave) getLen() uint16 {
return 1
}
// #WREQ
func encodeXISetClientPointer(window x.Window, deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
// #WREQ
func encodeXIGetClientPointer(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type XIGetClientPointerReply struct {
Set bool
DeviceId DeviceId
}
func readXIGetClientPointerReply(r *x.Reader, v *XIGetClientPointerReply) error {
if r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Set = r.ReadBool()
r.ReadPad(1)
v.DeviceId = DeviceId(r.Read2b()) // 3
return nil
}
// #WREQ
func encodeXISetFocus(focus x.Window, time x.Timestamp, deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(focus)).
Write4b(uint32(time)).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
// #WREQ
func encodeXIGetFocus(deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(1).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
type XIGetFocusReply struct {
Focus x.Window
}
func readXIGetFocusReply(r *x.Reader, v *XIGetFocusReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Focus = x.Window(r.Read4b()) // 3
return nil
}
// #WREQ
func encodeXIGrabDevice(window x.Window, time x.Timestamp, cursor x.Cursor, deviceId DeviceId,
mode, pairedDeviceMode uint8, ownerEvents bool, masks []EventMask) (b x.RequestBody) {
var masksSize int
for _, mask := range masks {
masksSize += mask.getSizeIn4b()
}
b0 := b.AddBlock(5 + masksSize).
Write4b(uint32(window)).
Write4b(uint32(time)).
Write4b(uint32(cursor)).
Write2b(uint16(deviceId)).
Write1b(mode).
Write1b(pairedDeviceMode).
WriteBool(ownerEvents).
WritePad(1).
Write2b(uint16(len(masks)))
for _, mask := range masks {
writeEventMask(b0, mask)
}
b0.End()
return
}
type XIGrabDeviceReply struct {
Status uint8
}
func readXIGrabDeviceReply(r *x.Reader, v *XIGrabDeviceReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Status = r.Read1b() // 3
return nil
}
// #WREQ
func encodeXIUngrabDevice(time x.Timestamp, deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(time)).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
// #WREQ
func encodeXIAllowEvents(time x.Timestamp, deviceId DeviceId, eventMode uint8,
touchId uint32, grabWindow x.Window) (b x.RequestBody) {
b.AddBlock(4).
Write4b(uint32(time)).
Write2b(uint16(deviceId)).
Write1b(eventMode).
WritePad(1).
Write4b(touchId).
Write4b(uint32(grabWindow)).
End()
return
}
// #WREQ
func encodeXIPassiveGrabDevice(grabWindow x.Window, cursor x.Cursor, detail uint32,
deviceId DeviceId, grabType, grabMode, pairedDeviceMode uint8, ownerEvents bool,
masks []uint32, modifiers []uint32) (b x.RequestBody) {
b0 := b.AddBlock(7 + len(masks) + len(modifiers)).
WritePad(4). // unused time field
Write4b(uint32(grabWindow)).
Write4b(uint32(cursor)).
Write4b(detail). // 4
Write2b(uint16(deviceId)).
Write2b(uint16(len(modifiers))).
Write2b(uint16(len(masks))).
Write1b(grabType).
Write1b(grabMode). // 6
Write1b(pairedDeviceMode).
WriteBool(ownerEvents).
WritePad(2) // 7
for _, mask := range masks {
b0.Write4b(mask)
}
for _, mod := range modifiers {
b0.Write4b(mod)
}
b0.End()
return
}
type XIPassiveGrabDeviceReply struct {
Modifiers []GrabModifierInfo
}
func readXIPassiveGrabDeviceReply(r *x.Reader, v *XIPassiveGrabDeviceReply) error {
if r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
modifiersLen := int(r.Read2b())
r.ReadPad(22) // 8
if modifiersLen > 0 {
if !r.RemainAtLeast4b(2 * modifiersLen) {
return x.ErrDataLenShort
}
v.Modifiers = make([]GrabModifierInfo, modifiersLen)
for i := 0; i < modifiersLen; i++ {
readGrabModifierInfo(r, &v.Modifiers[i])
}
}
return nil
}
// size: 2 * 4b
type GrabModifierInfo struct {
Modifiers uint32
Status uint8
}
func readGrabModifierInfo(r *x.Reader, v *GrabModifierInfo) {
v.Modifiers = r.Read4b()
v.Status = r.Read1b()
r.ReadPad(3)
}
// #WREQ
func encodeXIPassiveUngrabDevice(grabWindow x.Window, detail uint32,
deviceId DeviceId, grabType uint8, modifiers []uint32) (b x.RequestBody) {
b0 := b.AddBlock(4 + len(modifiers)).
Write4b(uint32(grabWindow)).
Write4b(detail).
Write2b(uint16(deviceId)).
Write2b(uint16(len(modifiers))).
Write1b(grabType).
WritePad(3)
for _, mod := range modifiers {
b0.Write4b(mod)
}
b0.End()
return
}
// #WREQ
func encodeXIListProperties(deviceId DeviceId) (b x.RequestBody) {
b.AddBlock(1).
Write2b(uint16(deviceId)).
WritePad(2).
End()
return
}
type XIListPropertiesReply struct {
Properties []x.Atom
}
func readXIListPropertiesReply(r *x.Reader, v *XIListPropertiesReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
propertiesLen := int(r.Read2b())
r.ReadPad(22)
if propertiesLen > 0 {
if !r.RemainAtLeast4b(propertiesLen) {
return x.ErrDataLenShort
}
v.Properties = make([]x.Atom, propertiesLen)
for i := 0; i < propertiesLen; i++ {
v.Properties[i] = x.Atom(r.Read4b())
}
}
return nil
}
// #WREQ
func encodeXIChangeProperty(deviceId DeviceId, mode uint8, format uint8,
property x.Atom, Type x.Atom, data []byte) (b x.RequestBody) {
dataLen := len(data)
b.AddBlock(4).
Write2b(uint16(deviceId)).
Write1b(mode).
Write1b(format).
Write4b(uint32(property)).
Write4b(uint32(Type)).
Write4b(uint32(dataLen / (int(format) / 8))).
End()
b.AddBytes(data)
return
}
// #WREQ
func encodeXIDeleteProperty(deviceId DeviceId, property x.Atom) (b x.RequestBody) {
b.AddBlock(2).
Write2b(uint16(deviceId)).
WritePad(2).
Write4b(uint32(property)).
End()
return
}
// #WREQ
func encodeXIGetProperty(deviceId DeviceId, delete bool, property x.Atom,
Type x.Atom, offset, len uint32) (b x.RequestBody) {
b.AddBlock(5).
Write2b(uint16(deviceId)).
WriteBool(delete).
WritePad(1).
Write4b(uint32(property)).
Write4b(uint32(Type)).
Write4b(offset).
Write4b(len).
End()
return
}
type XIGetPropertyReply struct {
Type x.Atom
BytesAfter uint32
NumItems uint32
Format uint8
Data []byte
}
func readXIGetPropertyReply(r *x.Reader, v *XIGetPropertyReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Type = x.Atom(r.Read4b())
v.BytesAfter = r.Read4b()
v.NumItems = r.Read4b() // 5
v.Format = r.Read1b()
// unused
r.ReadPad(11) // 8
n := int(v.NumItems) * int(v.Format/8)
var err error
v.Data, err = r.ReadBytes(n)
return err
}
go-x11-client-1.0.2/ext/input/input1.go 0000664 0000000 0000000 00000003464 14607133730 0017523 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import (
"github.com/linuxdeepin/go-x11-client"
)
// #WREQ
func encodeOpenDevice(deviceId uint8) (b x.RequestBody) {
b.AddBlock(1).
Write1b(deviceId).
WritePad(3).
End()
return
}
type OpenDeviceReply struct {
XIReplyType uint8
ClassInfos []ClassInfo
}
func readOpenDeviceReply(r *x.Reader, v *OpenDeviceReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.XIReplyType, _ = r.ReadReplyHeader()
classInfosLen := int(r.Read1b())
r.ReadPad(23) // 8
if classInfosLen > 0 {
if !r.RemainAtLeast(2 * classInfosLen) {
return x.ErrDataLenShort
}
v.ClassInfos = make([]ClassInfo, classInfosLen)
for i := 0; i < classInfosLen; i++ {
v.ClassInfos[i] = readClassInfo(r)
}
}
return nil
}
func FindTypeAndClass(deviceId uint8, classInfos []ClassInfo,
classId uint8, eventCode uint8) (Type uint8, class EventClass) {
for _, classInfo := range classInfos {
if classInfo.ClassId == classId {
Type = classInfo.EventTypeBase + eventCode
class = EventClass(uint32(deviceId)<<8 | uint32(Type))
}
}
return
}
// size: 2b
type ClassInfo struct {
ClassId uint8
EventTypeBase uint8
}
func readClassInfo(r *x.Reader) ClassInfo {
var v ClassInfo
v.ClassId = r.Read1b()
v.EventTypeBase = r.Read1b()
return v
}
// #WREQ
func encodeCloseDevice(deviceId uint8) (b x.RequestBody) {
b.AddBlock(1).
Write1b(deviceId).
WritePad(3).
End()
return
}
// #WREQ
func encodeSelectExtensionEvent(window x.Window, classes []EventClass) (b x.RequestBody) {
b0 := b.AddBlock(2 + len(classes)).
Write4b(uint32(window)).
Write2b(uint16(len(classes))).
WritePad(2)
for _, class := range classes {
b0.Write4b(uint32(class))
}
b0.End()
return
}
go-x11-client-1.0.2/ext/input/input1_req_auto.go 0000664 0000000 0000000 00000004042 14607133730 0021413 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import x "github.com/linuxdeepin/go-x11-client"
func OpenDevice(conn *x.Conn, deviceId uint8) OpenDeviceCookie {
body := encodeOpenDevice(deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: OpenDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return OpenDeviceCookie(seq)
}
func (cookie OpenDeviceCookie) Reply(conn *x.Conn) (*OpenDeviceReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply OpenDeviceReply
err = readOpenDeviceReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CloseDevice(conn *x.Conn, deviceId uint8) {
body := encodeCloseDevice(deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CloseDeviceOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CloseDeviceChecked(conn *x.Conn, deviceId uint8) x.VoidCookie {
body := encodeCloseDevice(deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CloseDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SelectExtensionEvent(conn *x.Conn, window x.Window, classes []EventClass) {
body := encodeSelectExtensionEvent(window, classes)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectExtensionEventOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SelectExtensionEventChecked(conn *x.Conn, window x.Window, classes []EventClass) x.VoidCookie {
body := encodeSelectExtensionEvent(window, classes)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectExtensionEventOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/input/input_event.go 0000664 0000000 0000000 00000041764 14607133730 0020650 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import (
"github.com/linuxdeepin/go-x11-client"
"github.com/linuxdeepin/go-x11-client/ext/xfixes"
)
type EventHeader struct {
DeviceId DeviceId
Time x.Timestamp
}
// ge event
type HierarchyEvent struct {
EventHeader
Flags uint32
Infos []HierarchyInfo
}
// size: 3 * 4b
type HierarchyInfo struct {
DeviceId DeviceId
Attachment DeviceId
Type uint8
Enabled bool
Flags uint32
}
func readHierarchyInfo(r *x.Reader, v *HierarchyInfo) {
v.DeviceId = DeviceId(r.Read2b())
v.Attachment = DeviceId(r.Read2b())
v.Type = r.Read1b()
v.Enabled = r.ReadBool()
r.ReadPad(2)
v.Flags = r.Read4b() // 3
}
// EventHeader size: 6b
func readEventHeader(r *x.Reader) EventHeader {
var v EventHeader
v.DeviceId = DeviceId(r.Read2b())
v.Time = x.Timestamp(r.Read4b())
return v
}
func readHierarchyEvent(r *x.Reader, v *HierarchyEvent) error {
if !r.RemainAtLeast(22) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.Flags = r.Read4b()
infosLen := int(r.Read2b())
r.ReadPad(10) // 22b
if infosLen > 0 {
v.Infos = make([]HierarchyInfo, infosLen)
for i := 0; i < infosLen; i++ {
readHierarchyInfo(r, &v.Infos[i])
}
}
return nil
}
type DeviceChangedEvent struct {
EventHeader
SourceId DeviceId
Reason uint8
Classes []DeviceClass
}
func readDeviceChangedEvent(r *x.Reader, v *DeviceChangedEvent) error {
if !r.RemainAtLeast(22) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
classesLen := int(r.Read2b())
v.SourceId = DeviceId(r.Read2b())
v.Reason = r.Read1b()
r.ReadPad(11) // 22b
if classesLen > 0 {
v.Classes = make([]DeviceClass, classesLen)
for i := 0; i < classesLen; i++ {
var err error
v.Classes[i], err = readDeviceClass(r)
if err != nil {
return err
}
}
}
return nil
}
// ge event
type DeviceEvent struct {
EventHeader
Detail uint32
Root x.Window
Event x.Window
Child x.Window
RootX float32
RootY float32
EventX float32
EventY float32
SourceId DeviceId
Flags uint32
Mods ModifierInfo
Group GroupInfo
ButtonMask []uint32
ValuatorMask []uint32
AxisValues []float32
}
func readDeviceEvent(r *x.Reader, v *DeviceEvent) error {
if !r.RemainAtLeast(70) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.Detail = r.Read4b()
v.Root = x.Window(r.Read4b())
v.Event = x.Window(r.Read4b())
v.Child = x.Window(r.Read4b()) // 22b
v.RootX = readFP1616(r)
v.RootY = readFP1616(r)
v.EventX = readFP1616(r)
v.EventY = readFP1616(r) // 38b
buttonsLen := int(r.Read2b())
valuatorsLen := int(r.Read2b())
v.SourceId = DeviceId(r.Read2b())
r.ReadPad(2) // 46b
v.Flags = r.Read4b()
readModifierInfo(r, &v.Mods)
readGroupInfo(r, &v.Group) // 70b
if buttonsLen > 0 {
if !r.RemainAtLeast4b(buttonsLen) {
return x.ErrDataLenShort
}
v.ButtonMask = make([]uint32, buttonsLen)
for i := 0; i < buttonsLen; i++ {
v.ButtonMask[i] = r.Read4b()
}
}
if valuatorsLen > 0 {
if !r.RemainAtLeast4b(valuatorsLen) {
return x.ErrDataLenShort
}
v.ValuatorMask = make([]uint32, valuatorsLen)
for i := 0; i < valuatorsLen; i++ {
v.ValuatorMask[i] = r.Read4b()
}
}
// TODO AxisValue
return nil
}
type KeyPressEvent struct {
DeviceEvent
}
func readKeyPressEvent(r *x.Reader, v *KeyPressEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type KeyReleaseEvent struct {
DeviceEvent
}
func readKeyReleaseEvent(r *x.Reader, v *KeyReleaseEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type ButtonPressEvent struct {
DeviceEvent
}
func readButtonPressEvent(r *x.Reader, v *ButtonPressEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type ButtonReleaseEvent struct {
DeviceEvent
}
func readButtonReleaseEvent(r *x.Reader, v *ButtonReleaseEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type MotionEvent struct {
DeviceEvent
}
func readMotionEvent(r *x.Reader, v *MotionEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
// ge event
type EnterLeaveEvent struct {
EventHeader
SourceId DeviceId
Mode uint8
Detail uint8
Root x.Window
Event x.Window
Child x.Window
RootX float32
RootY float32
EventX float32
EventY float32
SameScreen bool
Focus bool
Mods ModifierInfo
Group GroupInfo
Buttons []uint32
}
func readEnterLeaveEvent(r *x.Reader, v *EnterLeaveEvent) error {
if !r.RemainAtLeast(62) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.SourceId = DeviceId(r.Read2b())
v.Mode = r.Read1b()
v.Detail = r.Read1b() // 10b
v.Root = x.Window(r.Read4b())
v.Event = x.Window(r.Read4b())
v.Child = x.Window(r.Read4b()) // 22b
v.RootX = readFP1616(r)
v.RootY = readFP1616(r)
v.EventX = readFP1616(r)
v.EventY = readFP1616(r) // 38b
v.SameScreen = r.ReadBool()
v.Focus = r.ReadBool()
buttonsLen := int(r.Read2b()) // 42b
readModifierInfo(r, &v.Mods)
readGroupInfo(r, &v.Group) // 62b
if buttonsLen > 0 {
if !r.RemainAtLeast4b(buttonsLen) {
return x.ErrDataLenShort
}
v.Buttons = make([]uint32, buttonsLen)
for i := 0; i < buttonsLen; i++ {
v.Buttons[i] = r.Read4b()
}
}
return nil
}
type EnterEvent struct {
EnterLeaveEvent
}
func readEnterEvent(r *x.Reader, v *EnterEvent) error {
return readEnterLeaveEvent(r, &v.EnterLeaveEvent)
}
type LeaveEvent struct {
EnterLeaveEvent
}
func readLeaveEvent(r *x.Reader, v *LeaveEvent) error {
return readEnterLeaveEvent(r, &v.EnterLeaveEvent)
}
type FocusInEvent struct {
EnterLeaveEvent
}
func readFocusInEvent(r *x.Reader, v *FocusInEvent) error {
return readEnterLeaveEvent(r, &v.EnterLeaveEvent)
}
type FocusOutEvent struct {
EnterLeaveEvent
}
func readFocusOutEvent(r *x.Reader, v *FocusOutEvent) error {
return readEnterLeaveEvent(r, &v.EnterLeaveEvent)
}
// ge event
type PropertyEvent struct {
EventHeader
Property x.Atom
What uint8
}
func readPropertyEvent(r *x.Reader, v *PropertyEvent) error {
if !r.RemainAtLeast(11) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.Property = x.Atom(r.Read4b())
v.What = r.Read1b() // 11b
return nil
}
// ge event
type RawEvent struct {
EventHeader
Detail uint32
SourceId DeviceId
Flags uint32
ValuatorMask []uint32
AxisValues []float32
AxisValuesRaw []float32
}
func readRawEvent(r *x.Reader, v *RawEvent) error {
if !r.RemainAtLeast(22) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.Detail = r.Read4b()
v.SourceId = DeviceId(r.Read2b())
valuatorsLen := int(r.Read2b()) // 14b
v.Flags = r.Read4b()
r.ReadPad(4) // 22b
if valuatorsLen > 0 {
if !r.RemainAtLeast4b(valuatorsLen) {
return x.ErrDataLenShort
}
v.ValuatorMask = make([]uint32, valuatorsLen)
for i := 0; i < valuatorsLen; i++ {
v.ValuatorMask[i] = r.Read4b()
}
}
// TODO: axisValues
// TODO: axisValuesRaw
return nil
}
type RawKeyPressEvent struct {
RawEvent
}
func readRawKeyPressEvent(r *x.Reader, v *RawKeyPressEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type RawKeyReleaseEvent struct {
RawEvent
}
func readRawKeyReleaseEvent(r *x.Reader, v *RawKeyReleaseEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type RawButtonPressEvent struct {
RawEvent
}
func readRawButtonPressEvent(r *x.Reader, v *RawButtonPressEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type RawButtonReleaseEvent struct {
RawEvent
}
func readRawButtonReleaseEvent(r *x.Reader, v *RawButtonReleaseEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type RawMotionEvent struct {
RawEvent
}
func readRawMotionEvent(r *x.Reader, v *RawMotionEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type TouchBeginEvent struct {
DeviceEvent
}
func readTouchBeginEvent(r *x.Reader, v *TouchBeginEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type TouchUpdateEvent struct {
DeviceEvent
}
func readTouchUpdateEvent(r *x.Reader, v *TouchUpdateEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type TouchEndEvent struct {
DeviceEvent
}
func readTouchEndEvent(r *x.Reader, v *TouchEndEvent) error {
return readDeviceEvent(r, &v.DeviceEvent)
}
type TouchOwnershipEvent struct {
EventHeader
TouchId uint32
Root x.Window
Event x.Window
Child x.Window
SourceId DeviceId
Flags uint32
}
func readTouchOwnershipEvent(r *x.Reader, v *TouchOwnershipEvent) error {
if !r.RemainAtLeast(30) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.TouchId = r.Read4b() // 10b
v.Root = x.Window(r.Read4b())
v.Event = x.Window(r.Read4b())
v.Child = x.Window(r.Read4b())
v.SourceId = DeviceId(r.Read2b())
r.ReadPad(2)
v.Flags = r.Read4b() // 30b
return nil
}
type RawTouchBeginEvent struct {
RawEvent
}
func readRawTouchBeginEvent(r *x.Reader, v *RawTouchBeginEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type RawTouchUpdateEvent struct {
RawEvent
}
func readRawTouchUpdateEvent(r *x.Reader, v *RawTouchUpdateEvent) error {
return readRawEvent(r, &v.RawEvent)
}
type RawTouchEndEvent struct {
RawEvent
}
func readRawTouchEndEvent(r *x.Reader, v *RawTouchEndEvent) error {
return readRawEvent(r, &v.RawEvent)
}
// ge event
type BarrierEvent struct {
EventHeader
EventId uint32
Root x.Window
Event x.Window
Barrier xfixes.Barrier
DTime uint32
Flags uint32
SourceId DeviceId
RootX float32
RootY float32
DX float64
DY float64
}
func readBarrierEvent(r *x.Reader, v *BarrierEvent) error {
if !r.RemainAtLeast(58) {
return x.ErrDataLenShort
}
v.EventHeader = readEventHeader(r)
v.EventId = r.Read4b() // 10b
v.Root = x.Window(r.Read4b())
v.Event = x.Window(r.Read4b())
v.Barrier = xfixes.Barrier(r.Read4b())
v.DTime = r.Read4b()
v.Flags = r.Read4b()
v.SourceId = DeviceId(r.Read2b())
r.ReadPad(2) // 34b
v.RootX = readFP1616(r)
v.RootY = readFP1616(r)
v.DX = readFP3232(r)
v.DY = readFP3232(r) //58b
return nil
}
type BarrierHitEvent struct {
BarrierEvent
}
func readBarrierHitEvent(r *x.Reader, v *BarrierHitEvent) error {
return readBarrierEvent(r, &v.BarrierEvent)
}
type BarrierLeaveEvent struct {
BarrierHitEvent
}
func readBarrierLeaveEvent(r *x.Reader, v *BarrierLeaveEvent) error {
return readBarrierEvent(r, &v.BarrierEvent)
}
type DeviceValuatorEvent struct {
DeviceId uint8
Sequence uint16
DeviceState uint16
FirstValuator uint8
Valuators []int32
}
func readDeviceValuatorEvent(r *x.Reader, v *DeviceValuatorEvent) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
v.DeviceId, v.Sequence = r.ReadEventHeader()
v.DeviceState = r.Read2b()
valuatorsLen := int(r.Read1b())
v.FirstValuator = r.Read1b() // 2
if valuatorsLen > 0 {
if !r.RemainAtLeast4b(valuatorsLen) {
return x.ErrDataLenShort
}
v.Valuators = make([]int32, valuatorsLen)
for i := 0; i < valuatorsLen; i++ {
v.Valuators[i] = int32(r.Read4b())
}
}
return nil
}
type DeviceKeyEvent struct {
Detail uint8
Sequence uint16
Time x.Timestamp
Root x.Window
Event x.Window
Child x.Window
RootX int16
RootY int16
EventX int16
EventY int16
State uint16
SameScreen bool
DeviceId uint8
}
func readDeviceKeyEvent(r *x.Reader, v *DeviceKeyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Detail, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.Root = x.Window(r.Read4b())
v.Event = x.Window(r.Read4b())
v.Child = x.Window(r.Read4b()) // 5
v.RootX = int16(r.Read2b())
v.RootY = int16(r.Read2b())
v.EventX = int16(r.Read2b())
v.EventY = int16(r.Read2b())
v.State = r.Read2b()
v.SameScreen = r.ReadBool()
v.DeviceId = r.Read1b() // 8
return nil
}
type DeviceKeyPressEvent struct {
DeviceKeyEvent
}
func readDeviceKeyPressEvent(r *x.Reader, v *DeviceKeyPressEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type DeviceKeyReleaseEvent struct {
DeviceKeyEvent
}
func readDeviceKeyReleaseEvent(r *x.Reader, v *DeviceKeyReleaseEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type DeviceButtonPressEvent struct {
DeviceKeyEvent
}
func readDeviceButtonPressEvent(r *x.Reader, v *DeviceButtonPressEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type DeviceButtonReleaseEvent struct {
DeviceKeyEvent
}
func readDeviceButtonReleaseEvent(r *x.Reader, v *DeviceButtonReleaseEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type DeviceMotionNotifyEvent struct {
DeviceKeyEvent
}
func readDeviceMotionNotifyEvent(r *x.Reader, v *DeviceMotionNotifyEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type DeviceFocusEvent struct {
Detail uint8
Sequence uint16
Time x.Timestamp
Window x.Window
Mode uint8
DeviceId uint8
}
func readDeviceFocusEvent(r *x.Reader, v *DeviceFocusEvent) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
v.Detail, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.Window = x.Window(r.Read4b())
v.Mode = r.Read1b()
v.DeviceId = r.Read1b() // 4
return nil
}
type DeviceFocusInEvent struct {
DeviceFocusEvent
}
func readDeviceFocusInEvent(r *x.Reader, v *DeviceFocusInEvent) error {
return readDeviceFocusEvent(r, &v.DeviceFocusEvent)
}
type DeviceFocusOutEvent struct {
DeviceFocusEvent
}
func readDeviceFocusOutEvent(r *x.Reader, v *DeviceFocusOutEvent) error {
return readDeviceFocusEvent(r, &v.DeviceFocusEvent)
}
type ProximityInEvent struct {
DeviceKeyEvent
}
func readProximityInEvent(r *x.Reader, v *ProximityInEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type ProximityOutEvent struct {
DeviceKeyEvent
}
func readProximityOutEvent(r *x.Reader, v *ProximityOutEvent) error {
return readDeviceKeyEvent(r, &v.DeviceKeyEvent)
}
type DeviceStateNotifyEvent struct {
DeviceId uint8
Sequence uint16
Time x.Timestamp
NumKeys uint8
NumButtons uint8
NumValuators uint8
ClassesReported uint8
Buttons []uint8 // len 4
Keys []uint8 // len 4
Valuators []uint32 // len 3
}
func readDeviceStateNotifyEvent(r *x.Reader, v *DeviceStateNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceId, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.NumKeys = r.Read1b()
v.NumButtons = r.Read1b()
v.NumValuators = r.Read1b()
v.ClassesReported = r.Read1b() // 3
v.Buttons = r.MustReadBytes(4)
v.Keys = r.MustReadBytes(4)
v.Valuators = make([]uint32, 3) // 8
for i := 0; i < 3; i++ {
v.Valuators[i] = r.Read4b()
}
return nil
}
type DeviceMappingNotifyEvent struct {
DeviceId uint8
Sequence uint16
Request uint8
FirstKeycode x.Keycode
Count uint8
Time x.Timestamp
}
func readDeviceMappingNotifyEvent(r *x.Reader, v *DeviceMappingNotifyEvent) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.DeviceId, v.Sequence = r.ReadEventHeader()
v.Request = r.Read1b()
v.FirstKeycode = x.Keycode(r.Read1b())
v.Count = r.Read1b()
r.ReadPad(1)
v.Time = x.Timestamp(r.Read4b()) // 3
return nil
}
type ChangeDeviceNotifyEvent struct {
DeviceId uint8
Sequence uint16
Time x.Timestamp
Request uint8
}
func readChangeDeviceNotifyEvent(r *x.Reader, v *ChangeDeviceNotifyEvent) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.DeviceId, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.Request = r.Read1b() // 3
return nil
}
type DeviceKeyStateNotifyEvent struct {
DeviceId uint8
Sequence uint16
Keys []uint8 // len: 28
}
func readDeviceKeyStateNotifyEvent(r *x.Reader, v *DeviceKeyStateNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceId, v.Sequence = r.ReadEventHeader()
v.Keys = r.MustReadBytes(28) // 8
return nil
}
type DeviceButtonStateNotifyEvent struct {
DeviceId uint8
Sequence uint16
Buttons []uint8 // len: 28
}
func readDeviceButtonStateNotifyEvent(r *x.Reader, v *DeviceButtonStateNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceId, v.Sequence = r.ReadEventHeader()
v.Buttons = r.MustReadBytes(28) // 8
return nil
}
type DevicePresenceNotifyEvent struct {
Sequence uint16
Time x.Timestamp
DevChange uint8
DeviceId uint8
Control uint16
}
func readDevicePresenceNotifyEvent(r *x.Reader, v *DevicePresenceNotifyEvent) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
_, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.DevChange = r.Read1b()
v.DeviceId = r.Read1b()
v.Control = r.Read2b() // 3
return nil
}
type DevicePropertyNotifyEvent struct {
State uint8
Sequence uint16
Time x.Timestamp
Property x.Atom
DeviceId uint8
}
func readDevicePropertyNotifyEvent(r *x.Reader, v *DevicePropertyNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.State, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.Property = x.Atom(r.Read4b())
r.ReadPad(19)
v.DeviceId = r.Read1b() // 8
return nil
}
go-x11-client-1.0.2/ext/input/input_req_auto.go 0000664 0000000 0000000 00000036346 14607133730 0021346 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import x "github.com/linuxdeepin/go-x11-client"
func XIQueryVersion(conn *x.Conn, majorVersion, minorVersion uint16) XIQueryVersionCookie {
body := encodeXIQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIQueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIQueryVersionCookie(seq)
}
func (cookie XIQueryVersionCookie) Reply(conn *x.Conn) (*XIQueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIQueryVersionReply
err = readXIQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIQueryDevice(conn *x.Conn, deviceId DeviceId) XIQueryDeviceCookie {
body := encodeXIQueryDevice(deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIQueryDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIQueryDeviceCookie(seq)
}
func (cookie XIQueryDeviceCookie) Reply(conn *x.Conn) (*XIQueryDeviceReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIQueryDeviceReply
err = readXIQueryDeviceReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XISelectEvents(conn *x.Conn, window x.Window, masks []EventMask) {
body := encodeXISelectEvents(window, masks)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XISelectEventsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XISelectEventsChecked(conn *x.Conn, window x.Window, masks []EventMask) x.VoidCookie {
body := encodeXISelectEvents(window, masks)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XISelectEventsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIGetSelectedEvents(conn *x.Conn, window x.Window) XIGetSelectedEventsCookie {
body := encodeXIGetSelectedEvents(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIGetSelectedEventsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIGetSelectedEventsCookie(seq)
}
func (cookie XIGetSelectedEventsCookie) Reply(conn *x.Conn) (*XIGetSelectedEventsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIGetSelectedEventsReply
err = readXIGetSelectedEventsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIQueryPointer(conn *x.Conn, window x.Window, deviceId DeviceId) XIQueryPointerCookie {
body := encodeXIQueryPointer(window, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIQueryPointerOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIQueryPointerCookie(seq)
}
func (cookie XIQueryPointerCookie) Reply(conn *x.Conn) (*XIQueryPointerReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIQueryPointerReply
err = readXIQueryPointerReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIWarpPointer(conn *x.Conn, srcWin, dstWin x.Window, srcX, srcY float32, srcWidth, srcHeight uint16, dstX, dstY float32, deviceId DeviceId) {
body := encodeXIWarpPointer(srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIWarpPointerOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIWarpPointerChecked(conn *x.Conn, srcWin, dstWin x.Window, srcX, srcY float32, srcWidth, srcHeight uint16, dstX, dstY float32, deviceId DeviceId) x.VoidCookie {
body := encodeXIWarpPointer(srcWin, dstWin, srcX, srcY, srcWidth, srcHeight, dstX, dstY, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIWarpPointerOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIChangeCursor(conn *x.Conn, window x.Window, cursor x.Cursor, deviceId DeviceId) {
body := encodeXIChangeCursor(window, cursor, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIChangeCursorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIChangeCursorChecked(conn *x.Conn, window x.Window, cursor x.Cursor, deviceId DeviceId) x.VoidCookie {
body := encodeXIChangeCursor(window, cursor, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIChangeCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIChangeHierarchy(conn *x.Conn, changes []HierarchyChange) {
body := encodeXIChangeHierarchy(changes)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIChangeHierarchyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIChangeHierarchyChecked(conn *x.Conn, changes []HierarchyChange) x.VoidCookie {
body := encodeXIChangeHierarchy(changes)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIChangeHierarchyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XISetClientPointer(conn *x.Conn, window x.Window, deviceId DeviceId) {
body := encodeXISetClientPointer(window, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XISetClientPointerOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XISetClientPointerChecked(conn *x.Conn, window x.Window, deviceId DeviceId) x.VoidCookie {
body := encodeXISetClientPointer(window, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XISetClientPointerOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIGetClientPointer(conn *x.Conn, window x.Window) XIGetClientPointerCookie {
body := encodeXIGetClientPointer(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIGetClientPointerOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIGetClientPointerCookie(seq)
}
func (cookie XIGetClientPointerCookie) Reply(conn *x.Conn) (*XIGetClientPointerReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIGetClientPointerReply
err = readXIGetClientPointerReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XISetFocus(conn *x.Conn, focus x.Window, time x.Timestamp, deviceId DeviceId) {
body := encodeXISetFocus(focus, time, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XISetFocusOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XISetFocusChecked(conn *x.Conn, focus x.Window, time x.Timestamp, deviceId DeviceId) x.VoidCookie {
body := encodeXISetFocus(focus, time, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XISetFocusOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIGetFocus(conn *x.Conn, deviceId DeviceId) XIGetFocusCookie {
body := encodeXIGetFocus(deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIGetFocusOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIGetFocusCookie(seq)
}
func (cookie XIGetFocusCookie) Reply(conn *x.Conn) (*XIGetFocusReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIGetFocusReply
err = readXIGetFocusReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIGrabDevice(conn *x.Conn, window x.Window, time x.Timestamp, cursor x.Cursor, deviceId DeviceId, mode, pairedDeviceMode uint8, ownerEvents bool, masks []EventMask) XIGrabDeviceCookie {
body := encodeXIGrabDevice(window, time, cursor, deviceId, mode, pairedDeviceMode, ownerEvents, masks)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIGrabDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIGrabDeviceCookie(seq)
}
func (cookie XIGrabDeviceCookie) Reply(conn *x.Conn) (*XIGrabDeviceReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIGrabDeviceReply
err = readXIGrabDeviceReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIUngrabDevice(conn *x.Conn, time x.Timestamp, deviceId DeviceId) {
body := encodeXIUngrabDevice(time, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIUngrabDeviceOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIUngrabDeviceChecked(conn *x.Conn, time x.Timestamp, deviceId DeviceId) x.VoidCookie {
body := encodeXIUngrabDevice(time, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIUngrabDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIAllowEvents(conn *x.Conn, time x.Timestamp, deviceId DeviceId, eventMode uint8, touchId uint32, grabWindow x.Window) {
body := encodeXIAllowEvents(time, deviceId, eventMode, touchId, grabWindow)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIAllowEventsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIAllowEventsChecked(conn *x.Conn, time x.Timestamp, deviceId DeviceId, eventMode uint8, touchId uint32, grabWindow x.Window) x.VoidCookie {
body := encodeXIAllowEvents(time, deviceId, eventMode, touchId, grabWindow)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIAllowEventsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIPassiveGrabDevice(conn *x.Conn, grabWindow x.Window, cursor x.Cursor, detail uint32, deviceId DeviceId, grabType, grabMode, pairedDeviceMode uint8, ownerEvents bool, masks []uint32, modifiers []uint32) XIPassiveGrabDeviceCookie {
body := encodeXIPassiveGrabDevice(grabWindow, cursor, detail, deviceId, grabType, grabMode, pairedDeviceMode, ownerEvents, masks, modifiers)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIPassiveGrabDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIPassiveGrabDeviceCookie(seq)
}
func (cookie XIPassiveGrabDeviceCookie) Reply(conn *x.Conn) (*XIPassiveGrabDeviceReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIPassiveGrabDeviceReply
err = readXIPassiveGrabDeviceReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIPassiveUngrabDevice(conn *x.Conn, grabWindow x.Window, detail uint32, deviceId DeviceId, grabType uint8, modifiers []uint32) {
body := encodeXIPassiveUngrabDevice(grabWindow, detail, deviceId, grabType, modifiers)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIPassiveUngrabDeviceOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIPassiveUngrabDeviceChecked(conn *x.Conn, grabWindow x.Window, detail uint32, deviceId DeviceId, grabType uint8, modifiers []uint32) x.VoidCookie {
body := encodeXIPassiveUngrabDevice(grabWindow, detail, deviceId, grabType, modifiers)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIPassiveUngrabDeviceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIListProperties(conn *x.Conn, deviceId DeviceId) XIListPropertiesCookie {
body := encodeXIListProperties(deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIListPropertiesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIListPropertiesCookie(seq)
}
func (cookie XIListPropertiesCookie) Reply(conn *x.Conn) (*XIListPropertiesReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIListPropertiesReply
err = readXIListPropertiesReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func XIChangeProperty(conn *x.Conn, deviceId DeviceId, mode uint8, format uint8, property x.Atom, Type x.Atom, data []byte) {
body := encodeXIChangeProperty(deviceId, mode, format, property, Type, data)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIChangePropertyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIChangePropertyChecked(conn *x.Conn, deviceId DeviceId, mode uint8, format uint8, property x.Atom, Type x.Atom, data []byte) x.VoidCookie {
body := encodeXIChangeProperty(deviceId, mode, format, property, Type, data)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIChangePropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIDeleteProperty(conn *x.Conn, deviceId DeviceId, property x.Atom) {
body := encodeXIDeleteProperty(deviceId, property)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIDeletePropertyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func XIDeletePropertyChecked(conn *x.Conn, deviceId DeviceId, property x.Atom) x.VoidCookie {
body := encodeXIDeleteProperty(deviceId, property)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: XIDeletePropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func XIGetProperty(conn *x.Conn, deviceId DeviceId, delete bool, property x.Atom, Type x.Atom, offset, len uint32) XIGetPropertyCookie {
body := encodeXIGetProperty(deviceId, delete, property, Type, offset, len)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: XIGetPropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return XIGetPropertyCookie(seq)
}
func (cookie XIGetPropertyCookie) Reply(conn *x.Conn) (*XIGetPropertyReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply XIGetPropertyReply
err = readXIGetPropertyReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
go-x11-client-1.0.2/ext/randr/ 0000775 0000000 0000000 00000000000 14607133730 0015714 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/randr/auto.go 0000664 0000000 0000000 00000017773 14607133730 0017232 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package randr
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: RandR
const MajorVersion = 1
const MinorVersion = 6
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// simple ('xcb', 'RandR', 'MODE')
type Mode uint32
// simple ('xcb', 'RandR', 'CRTC')
type Crtc uint32
// simple ('xcb', 'RandR', 'OUTPUT')
type Output uint32
// simple ('xcb', 'RandR', 'PROVIDER')
type Provider uint32
// simple ('xcb', 'RandR', 'LEASE')
type Lease uint32
const BadOutputErrorCode = 0
const BadCrtcErrorCode = 1
const BadModeErrorCode = 2
const BadProviderErrorCode = 3
// enum Rotation
const (
RotationRotate0 = 1
RotationRotate90 = 2
RotationRotate180 = 4
RotationRotate270 = 8
RotationReflectX = 16
RotationReflectY = 32
)
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
// enum SetConfig
const (
SetConfigSuccess = 0
SetConfigInvalidConfigTime = 1
SetConfigInvalidTime = 2
SetConfigFailed = 3
)
const SetScreenConfigOpcode = 2
type SetScreenConfigCookie x.SeqNum
// enum NotifyMask
const (
NotifyMaskScreenChange = 1
NotifyMaskCrtcChange = 2
NotifyMaskOutputChange = 4
NotifyMaskOutputProperty = 8
NotifyMaskProviderChange = 16
NotifyMaskProviderProperty = 32
NotifyMaskResourceChange = 64
NotifyMaskLease = 128
)
const SelectInputOpcode = 4
const GetScreenInfoOpcode = 5
type GetScreenInfoCookie x.SeqNum
const GetScreenSizeRangeOpcode = 6
type GetScreenSizeRangeCookie x.SeqNum
const SetScreenSizeOpcode = 7
// enum ModeFlag
const (
ModeFlagHsyncPositive = 1
ModeFlagHsyncNegative = 2
ModeFlagVsyncPositive = 4
ModeFlagVsyncNegative = 8
ModeFlagInterlace = 16
ModeFlagDoubleScan = 32
ModeFlagCsync = 64
ModeFlagCsyncPositive = 128
ModeFlagCsyncNegative = 256
ModeFlagHskewPresent = 512
ModeFlagBcast = 1024
ModeFlagPixelMultiplex = 2048
ModeFlagDoubleClock = 4096
ModeFlagHalveClock = 8192
)
const GetScreenResourcesOpcode = 8
type GetScreenResourcesCookie x.SeqNum
// enum Connection
const (
ConnectionConnected = 0
ConnectionDisconnected = 1
ConnectionUnknown = 2
)
const GetOutputInfoOpcode = 9
type GetOutputInfoCookie x.SeqNum
const ListOutputPropertiesOpcode = 10
type ListOutputPropertiesCookie x.SeqNum
const QueryOutputPropertyOpcode = 11
type QueryOutputPropertyCookie x.SeqNum
const ConfigureOutputPropertyOpcode = 12
const ChangeOutputPropertyOpcode = 13
const DeleteOutputPropertyOpcode = 14
const GetOutputPropertyOpcode = 15
type GetOutputPropertyCookie x.SeqNum
const CreateModeOpcode = 16
type CreateModeCookie x.SeqNum
const DestroyModeOpcode = 17
const AddOutputModeOpcode = 18
const DeleteOutputModeOpcode = 19
const GetCrtcInfoOpcode = 20
type GetCrtcInfoCookie x.SeqNum
const SetCrtcConfigOpcode = 21
type SetCrtcConfigCookie x.SeqNum
const GetCrtcGammaSizeOpcode = 22
type GetCrtcGammaSizeCookie x.SeqNum
const GetCrtcGammaOpcode = 23
type GetCrtcGammaCookie x.SeqNum
const SetCrtcGammaOpcode = 24
const GetScreenResourcesCurrentOpcode = 25
type GetScreenResourcesCurrentCookie x.SeqNum
// enum Transform
const (
TransformUnit = 1
TransformScaleUp = 2
TransformScaleDown = 4
TransformProjective = 8
)
const SetCrtcTransformOpcode = 26
const GetCrtcTransformOpcode = 27
type GetCrtcTransformCookie x.SeqNum
const GetPanningOpcode = 28
type GetPanningCookie x.SeqNum
const SetPanningOpcode = 29
type SetPanningCookie x.SeqNum
const SetOutputPrimaryOpcode = 30
const GetOutputPrimaryOpcode = 31
type GetOutputPrimaryCookie x.SeqNum
const GetProvidersOpcode = 32
type GetProvidersCookie x.SeqNum
// enum ProviderCapability
const (
ProviderCapabilitySourceOutput = 1
ProviderCapabilitySinkOutput = 2
ProviderCapabilitySourceOffload = 4
ProviderCapabilitySinkOffload = 8
)
const GetProviderInfoOpcode = 33
type GetProviderInfoCookie x.SeqNum
const SetProviderOffloadSinkOpcode = 34
const SetProviderOutputSourceOpcode = 35
const ListProviderPropertiesOpcode = 36
type ListProviderPropertiesCookie x.SeqNum
const QueryProviderPropertyOpcode = 37
type QueryProviderPropertyCookie x.SeqNum
const ConfigureProviderPropertyOpcode = 38
const ChangeProviderPropertyOpcode = 39
const DeleteProviderPropertyOpcode = 40
const GetProviderPropertyOpcode = 41
type GetProviderPropertyCookie x.SeqNum
const ScreenChangeNotifyEventCode = 0
func NewScreenChangeNotifyEvent(data []byte) (*ScreenChangeNotifyEvent, error) {
var ev ScreenChangeNotifyEvent
r := x.NewReaderFromData(data)
err := readScreenChangeNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
// enum Notify
const (
NotifyCrtcChange = 0
NotifyOutputChange = 1
NotifyOutputProperty = 2
NotifyProviderChange = 3
NotifyProviderProperty = 4
NotifyResourceChange = 5
NotifyLease = 6
)
const GetMonitorsOpcode = 42
type GetMonitorsCookie x.SeqNum
const SetMonitorOpcode = 43
const DeleteMonitorOpcode = 44
const CreateLeaseOpcode = 45
type CreateLeaseCookie x.SeqNum
const FreeLeaseOpcode = 46
const NotifyEventCode = 1
func NewNotifyEvent(data []byte) (*NotifyEvent, error) {
var ev NotifyEvent
r := x.NewReaderFromData(data)
err := readNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
var errorCodeNameMap = map[uint8]string{
BadOutputErrorCode: "BadOutput",
BadCrtcErrorCode: "BadCrtc",
BadModeErrorCode: "BadMode",
BadProviderErrorCode: "BadProvider",
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
SetScreenConfigOpcode: "SetScreenConfig",
SelectInputOpcode: "SelectInput",
GetScreenInfoOpcode: "GetScreenInfo",
GetScreenSizeRangeOpcode: "GetScreenSizeRange",
SetScreenSizeOpcode: "SetScreenSize",
GetScreenResourcesOpcode: "GetScreenResources",
GetOutputInfoOpcode: "GetOutputInfo",
ListOutputPropertiesOpcode: "ListOutputProperties",
QueryOutputPropertyOpcode: "QueryOutputProperty",
ConfigureOutputPropertyOpcode: "ConfigureOutputProperty",
ChangeOutputPropertyOpcode: "ChangeOutputProperty",
DeleteOutputPropertyOpcode: "DeleteOutputProperty",
GetOutputPropertyOpcode: "GetOutputProperty",
CreateModeOpcode: "CreateMode",
DestroyModeOpcode: "DestroyMode",
AddOutputModeOpcode: "AddOutputMode",
DeleteOutputModeOpcode: "DeleteOutputMode",
GetCrtcInfoOpcode: "GetCrtcInfo",
SetCrtcConfigOpcode: "SetCrtcConfig",
GetCrtcGammaSizeOpcode: "GetCrtcGammaSize",
GetCrtcGammaOpcode: "GetCrtcGamma",
SetCrtcGammaOpcode: "SetCrtcGamma",
GetScreenResourcesCurrentOpcode: "GetScreenResourcesCurrent",
SetCrtcTransformOpcode: "SetCrtcTransform",
GetCrtcTransformOpcode: "GetCrtcTransform",
GetPanningOpcode: "GetPanning",
SetPanningOpcode: "SetPanning",
SetOutputPrimaryOpcode: "SetOutputPrimary",
GetOutputPrimaryOpcode: "GetOutputPrimary",
GetProvidersOpcode: "GetProviders",
GetProviderInfoOpcode: "GetProviderInfo",
SetProviderOffloadSinkOpcode: "SetProviderOffloadSink",
SetProviderOutputSourceOpcode: "SetProviderOutputSource",
ListProviderPropertiesOpcode: "ListProviderProperties",
QueryProviderPropertyOpcode: "QueryProviderProperty",
ConfigureProviderPropertyOpcode: "ConfigureProviderProperty",
ChangeProviderPropertyOpcode: "ChangeProviderProperty",
DeleteProviderPropertyOpcode: "DeleteProviderProperty",
GetProviderPropertyOpcode: "GetProviderProperty",
GetMonitorsOpcode: "GetMonitors",
SetMonitorOpcode: "SetMonitor",
DeleteMonitorOpcode: "DeleteMonitor",
CreateLeaseOpcode: "CreateLease",
FreeLeaseOpcode: "FreeLease",
}
func init() {
_ext = x.NewExtension("RANDR", 3, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/randr/randr.go 0000664 0000000 0000000 00000071412 14607133730 0017356 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package randr
import (
"errors"
"math"
"github.com/linuxdeepin/go-x11-client/ext/render"
"github.com/linuxdeepin/go-x11-client"
)
const (
StatusSuccess = 0
StatusInvalidConfigTime = 1
StatusInvalidTime = 2
StatusFailed = 3
)
// #WREQ
func encodeQueryVersion(clientMajorVersion, clientMinorVersion uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(clientMajorVersion).
Write4b(clientMinorVersion).
End()
return
}
type QueryVersionReply struct {
ServerMajorVersion uint32
ServerMinorVersion uint32
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.ServerMajorVersion = r.Read4b()
v.ServerMinorVersion = r.Read4b() // 4
return nil
}
// #WREQ
func encodeSetScreenConfig(window x.Window, timestamp x.Timestamp, configTimestamp x.Timestamp,
sizeID uint16, rotation uint16, rate uint16) (b x.RequestBody) {
b.AddBlock(5).
Write4b(uint32(window)).
Write4b(uint32(timestamp)).
Write4b(uint32(configTimestamp)). // 3
Write2b(uint16(sizeID)).
Write2b(rotation).
Write2b(rate).
WritePad(2). // 5
End()
return
}
type SetScreenConfigReply struct {
Status uint8
NewTimestamp x.Timestamp
ConfigTimestamp x.Timestamp
Root x.Window
SubpixelOrder uint16
}
func readSetScreenConfigReply(r *x.Reader, v *SetScreenConfigReply) error {
if !r.RemainAtLeast4b(6) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.NewTimestamp = x.Timestamp(r.Read4b())
v.ConfigTimestamp = x.Timestamp(r.Read4b()) // 4
v.Root = x.Window(r.Read4b())
v.SubpixelOrder = r.Read2b() // 6
return nil
}
// #WREQ
func encodeGetScreenInfo(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window))
return
}
type GetScreenInfoReply struct {
Rotations uint8
Root x.Window
Timestamp x.Timestamp
ConfigTimestamp x.Timestamp
NSizes uint16
SizeID uint16
Rotation uint16
Rate uint16
NInfo uint16 // useless
Sizes []ScreenSize
Rates []RefreshRates
}
func readGetScreenInfoReply(r *x.Reader, v *GetScreenInfoReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Rotations, _ = r.ReadReplyHeader()
v.Root = x.Window(r.Read4b())
v.Timestamp = x.Timestamp(r.Read4b())
v.ConfigTimestamp = x.Timestamp(r.Read4b()) // 5
v.NSizes = r.Read2b()
v.SizeID = r.Read2b()
v.Rotation = r.Read2b()
v.Rate = r.Read2b()
v.NInfo = r.Read2b()
r.ReadPad(2) // 8
if v.NSizes > 0 {
if !r.RemainAtLeast4b(2 * int(v.NSizes)) {
return x.ErrDataLenShort
}
v.Sizes = make([]ScreenSize, v.NSizes)
for i := 0; i < int(v.NSizes); i++ {
v.Sizes[i] = readScreenSize(r)
}
}
nRefreshRates := int(v.NSizes)
if nRefreshRates > 0 {
v.Rates = make([]RefreshRates, nRefreshRates)
for i := 0; i < nRefreshRates; i++ {
err := readRefreshRates(r, &v.Rates[i])
if err != nil {
return err
}
}
}
return nil
}
// size: 2 * 4b
type ScreenSize struct {
Width uint16 // pixels
Height uint16
MWidth uint16 // millimeters
MHeight uint16
}
func readScreenSize(r *x.Reader) (v ScreenSize) {
v.Width = r.Read2b()
v.Height = r.Read2b()
v.MWidth = r.Read2b()
v.MHeight = r.Read2b()
return
}
// size: ?
type RefreshRates struct {
NRates uint16
Rates []uint16
}
func readRefreshRates(r *x.Reader, v *RefreshRates) error {
if !r.RemainAtLeast(2) {
return x.ErrDataLenShort
}
v.NRates = r.Read2b()
if v.NRates > 0 {
if !r.RemainAtLeast(2 * int(v.NRates)) {
return x.ErrDataLenShort
}
v.Rates = make([]uint16, v.NRates)
for i := 0; i < int(v.NRates); i++ {
v.Rates[i] = r.Read2b()
}
}
return nil
}
// #WREQ
func encodeGetScreenSizeRange(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type GetScreenSizeRangeReply struct {
MinWidth uint16
MinHeight uint16
MaxWidth uint16
MaxHeight uint16
}
func readGetScreenSizeRangeReply(r *x.Reader, v *GetScreenSizeRangeReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
v.MinWidth = r.Read2b()
v.MinHeight = r.Read2b()
v.MaxWidth = r.Read2b()
v.MaxHeight = r.Read2b() // 4
return nil
}
// #WREQ
func encodeSetScreenSize(window x.Window, width, height uint16,
mmWidth, mmHeight uint32) (b x.RequestBody) {
b.AddBlock(4).
Write4b(uint32(window)).
Write2b(width).
Write2b(height).
Write4b(mmWidth).
Write4b(mmHeight).
End()
return
}
// #WREQ
func encodeGetCrtcInfo(crtc Crtc, configTimestamp x.Timestamp) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(crtc)).
Write4b(uint32(configTimestamp)).
End()
return
}
type GetCrtcInfoReply struct {
Status uint8
Timestamp x.Timestamp
X int16
Y int16
Width uint16
Height uint16
Mode Mode
Rotation uint16
Rotations uint16
Outputs []Output
PossibleOutputs []Output
}
func readGetCrtcInfoReply(r *x.Reader, v *GetCrtcInfoReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b())
v.X = int16(r.Read2b())
v.Y = int16(r.Read2b())
v.Width = r.Read2b()
v.Height = r.Read2b() // 5
v.Mode = Mode(r.Read4b())
v.Rotation = r.Read2b()
v.Rotations = r.Read2b()
outputsLen := int(r.Read2b())
possibleOutputsLen := int(r.Read2b()) // 8
if outputsLen > 0 {
if !r.RemainAtLeast4b(outputsLen) {
return x.ErrDataLenShort
}
v.Outputs = make([]Output, outputsLen)
for i := 0; i < outputsLen; i++ {
v.Outputs[i] = Output(r.Read4b())
}
}
if possibleOutputsLen > 0 {
if !r.RemainAtLeast4b(possibleOutputsLen) {
return x.ErrDataLenShort
}
v.PossibleOutputs = make([]Output, possibleOutputsLen)
for i := 0; i < possibleOutputsLen; i++ {
v.PossibleOutputs[i] = Output(r.Read4b())
}
}
return nil
}
// #WREQ
func encodeGetOutputInfo(output Output, configTimestamp x.Timestamp) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(output)).
Write4b(uint32(configTimestamp)).
End()
return
}
type GetOutputInfoReply struct {
Status uint8
Timestamp x.Timestamp
Crtc Crtc
MmWidth uint32
MmHeight uint32
Connection uint8
SubPixelOrder uint8
NumPreferred uint16
Crtcs []Crtc
Modes []Mode
Clones []Output
Name string
}
func readGetOutputInfoReply(r *x.Reader, v *GetOutputInfoReply) error {
if !r.RemainAtLeast4b(9) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b())
v.Crtc = Crtc(r.Read4b())
v.MmWidth = r.Read4b() // 5
v.MmHeight = r.Read4b()
v.Connection = r.Read1b()
v.SubPixelOrder = r.Read1b()
crtcsLen := int(r.Read2b())
modesLen := int(r.Read2b())
v.NumPreferred = r.Read2b() // 8
if int(v.NumPreferred) > modesLen {
return errors.New("numPreferred > modesLen")
}
clonesLen := int(r.Read2b())
nameLen := int(r.Read2b()) // 9
if crtcsLen > 0 {
if !r.RemainAtLeast4b(crtcsLen) {
return x.ErrDataLenShort
}
v.Crtcs = make([]Crtc, crtcsLen)
for i := 0; i < crtcsLen; i++ {
v.Crtcs[i] = Crtc(r.Read4b())
}
}
if modesLen > 0 {
if !r.RemainAtLeast4b(modesLen) {
return x.ErrDataLenShort
}
v.Modes = make([]Mode, modesLen)
for i := 0; i < modesLen; i++ {
v.Modes[i] = Mode(r.Read4b())
}
}
if clonesLen > 0 {
if !r.RemainAtLeast4b(clonesLen) {
return x.ErrDataLenShort
}
v.Clones = make([]Output, clonesLen)
for i := 0; i < clonesLen; i++ {
v.Clones[i] = Output(r.Read4b())
}
}
var err error
v.Name, err = r.ReadString(nameLen)
return err
}
func (r *GetOutputInfoReply) GetPreferredMode() Mode {
if r.NumPreferred == 0 || len(r.Modes) == 0 {
return 0
}
return r.Modes[r.NumPreferred-1]
}
// #WREQ
func encodeGetScreenResources(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type GetScreenResourcesReply struct {
Timestamp x.Timestamp
ConfigTimestamp x.Timestamp
Crtcs []Crtc
Outputs []Output // size: xgb.Pad((int(NumOutputs) * 4))
Modes []ModeInfo
}
// size: 8 * 4b
type ModeInfo struct {
Id uint32
Width uint16
Height uint16
DotClock uint32
HSyncStart uint16
HSyncEnd uint16
HTotal uint16
HSkew uint16
VSyncStart uint16
VSyncEnd uint16
VTotal uint16
nameLen uint16
Name string
ModeFlags uint32
}
func readModeInfo(r *x.Reader, v *ModeInfo) {
v.Id = r.Read4b()
v.Width = r.Read2b()
v.Height = r.Read2b()
v.DotClock = r.Read4b()
v.HSyncStart = r.Read2b()
v.HSyncEnd = r.Read2b()
v.HTotal = r.Read2b()
v.HSkew = r.Read2b() // 5
v.VSyncStart = r.Read2b()
v.VSyncEnd = r.Read2b()
v.VTotal = r.Read2b()
v.nameLen = r.Read2b()
v.ModeFlags = r.Read4b() // 8
}
func writeModeInfo(b *x.FixedSizeBuf, v *ModeInfo) {
b.Write4b(v.Id).
Write2b(v.Width).
Write2b(v.Height).
Write4b(v.DotClock).
Write2b(v.HSyncStart).
Write2b(v.HSyncEnd).
Write2b(v.HTotal).
Write2b(v.HSkew).
Write2b(v.VSyncStart).
Write2b(v.VSyncEnd).
Write2b(v.VTotal).
Write2b(v.nameLen).
Write4b(v.ModeFlags)
}
func readGetScreenResourcesReply(r *x.Reader, v *GetScreenResourcesReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Timestamp = x.Timestamp(r.Read4b())
v.ConfigTimestamp = x.Timestamp(r.Read4b())
crtcsLen := int(r.Read2b())
outputsLen := int(r.Read2b()) // 5
modesLen := int(r.Read2b())
// namesLen
modeNamesLen := int(r.Read2b())
// unused
r.ReadPad(8) // 8
if crtcsLen > 0 {
if !r.RemainAtLeast4b(crtcsLen) {
return x.ErrDataLenShort
}
v.Crtcs = make([]Crtc, crtcsLen)
for i := 0; i < crtcsLen; i++ {
v.Crtcs[i] = Crtc(r.Read4b())
}
}
if outputsLen > 0 {
if !r.RemainAtLeast4b(outputsLen) {
return x.ErrDataLenShort
}
v.Outputs = make([]Output, outputsLen)
for i := 0; i < outputsLen; i++ {
v.Outputs[i] = Output(r.Read4b())
}
}
if modesLen > 0 {
if !r.RemainAtLeast4b(8 * modesLen) {
return x.ErrDataLenShort
}
v.Modes = make([]ModeInfo, modesLen)
for i := 0; i < modesLen; i++ {
readModeInfo(r, &v.Modes[i])
}
}
var b int
for i := 0; i < modesLen; i++ {
modeNameLen := int(v.Modes[i].nameLen)
b += modeNameLen
var err error
v.Modes[i].Name, err = r.ReadString(modeNameLen)
if err != nil {
return err
}
}
if b != modeNamesLen {
return errors.New("mode names len not equal")
}
return nil
}
// #WREQ
func encodeGetScreenResourcesCurrent(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type GetScreenResourcesCurrentReply GetScreenResourcesReply
func readGetScreenResourcesCurrentReply(r *x.Reader, v *GetScreenResourcesCurrentReply) error {
return readGetScreenResourcesReply(r, (*GetScreenResourcesReply)(v))
}
// #WREQ
func encodeSetCrtcTransform(crtc Crtc, transform *render.Transform, filter string,
filterParams []render.Fixed) (b x.RequestBody) {
filter = x.TruncateStr(filter, math.MaxUint16)
buf := b.AddBlock(11 + x.SizeIn4bWithPad(len(filter)) + len(filterParams)).
Write4b(uint32(crtc))
render.WriteTransform(buf, transform) // 10
buf.Write2b(uint16(len(filter))).
WritePad(2). // 11
WriteString(filter).
WritePad(x.Pad(len(filter)))
for _, value := range filterParams {
buf.Write4b(uint32(value)) // +len(filterParams)
}
buf.End()
return
}
// #WREQ
func encodeGetCrtcTransform(crtc Crtc) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(crtc)).
End()
return
}
type GetCrtcTransformReply struct {
PendingTransform render.Transform
HasTransform bool
CurrentTransform render.Transform
PendingLen uint16
PendingNParams uint16
CurrentLen uint16
CurrentNParams uint16
PendingFilter string
PendingParams []render.Fixed
CurrentFilter string
CurrentParams []render.Fixed
}
func readGetCrtcTransformReply(r *x.Reader, v *GetCrtcTransformReply) error {
if !r.RemainAtLeast4b(24) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
render.ReadTransform(r, &v.PendingTransform) // 11
v.HasTransform = r.ReadBool()
r.ReadPad(3) // 12
render.ReadTransform(r, &v.CurrentTransform) // 21
r.ReadPad(4) // 22
v.PendingLen = r.Read2b()
v.PendingNParams = r.Read2b() // 23
v.CurrentLen = r.Read2b()
v.CurrentNParams = r.Read2b() // 24
var err error
v.PendingFilter, err = r.ReadStrWithPad(int(v.PendingLen))
if err != nil {
return err
}
if v.PendingNParams > 0 {
if !r.RemainAtLeast4b(int(v.PendingNParams)) {
return x.ErrDataLenShort
}
v.PendingParams = make([]render.Fixed, v.PendingNParams)
for i := 0; i < int(v.PendingNParams); i++ {
v.PendingParams[i] = render.Fixed(r.Read4b())
}
}
v.CurrentFilter, err = r.ReadStrWithPad(int(v.CurrentLen))
if err != nil {
return err
}
if v.CurrentNParams > 0 {
if !r.RemainAtLeast4b(int(v.CurrentNParams)) {
return x.ErrDataLenShort
}
v.CurrentParams = make([]render.Fixed, v.CurrentNParams)
for i := 0; i < int(v.CurrentNParams); i++ {
v.CurrentParams[i] = render.Fixed(r.Read4b())
}
}
return nil
}
// size: 6 * 4b
type Panning struct {
Left, Top, Width, Height uint16
TrackLeft, TrackTop, TrackWidth, TrackHeight uint16
BorderLeft, BorderTop, BorderRight, BorderBottom int16
}
func readPanning(r *x.Reader, v *Panning) {
v.Left = r.Read2b()
v.Top = r.Read2b()
v.Width = r.Read2b()
v.Height = r.Read2b()
v.TrackLeft = r.Read2b()
v.TrackTop = r.Read2b()
v.TrackWidth = r.Read2b()
v.TrackHeight = r.Read2b()
v.BorderLeft = int16(r.Read2b())
v.BorderTop = int16(r.Read2b())
v.BorderRight = int16(r.Read2b())
v.BorderBottom = int16(r.Read2b())
}
func writePanning(b *x.FixedSizeBuf, v *Panning) {
b.Write2b(v.Left)
b.Write2b(v.Top)
b.Write2b(v.Width)
b.Write2b(v.Height)
b.Write2b(v.TrackLeft)
b.Write2b(v.TrackTop)
b.Write2b(v.TrackWidth)
b.Write2b(v.TrackHeight)
b.Write2b(uint16(v.BorderLeft))
b.Write2b(uint16(v.TrackTop))
b.Write2b(uint16(v.BorderRight))
b.Write2b(uint16(v.BorderBottom))
}
// #WREQ
func encodeGetPanning(crtc Crtc) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(crtc)).
End()
return
}
type GetPanningReply struct {
Status uint8
Timestamp x.Timestamp
Panning
}
func readGetPanningReply(r *x.Reader, v *GetPanningReply) error {
if !r.RemainAtLeast4b(9) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b()) // 3
readPanning(r, &v.Panning) // 9
return nil
}
// #WREQ
func encodeSetPanning(crtc Crtc, timestamp x.Timestamp, panning *Panning) (b x.RequestBody) {
buf := b.AddBlock(8).
Write4b(uint32(crtc)).
Write4b(uint32(timestamp))
writePanning(buf, panning)
return
}
type SetPanningReply struct {
Status uint8
Timestamp x.Timestamp
}
func readSetPanningReply(r *x.Reader, v *SetPanningReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b()) // 3
return nil
}
// #WREQ
func encodeSetOutputPrimary(window x.Window, output Output) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write4b(uint32(output)).
End()
return
}
// #WREQ
func encodeGetOutputPrimary(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type GetOutputPrimaryReply struct {
Output Output
}
func readGetOutputPrimaryReply(r *x.Reader, v *GetOutputPrimaryReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.Output = Output(r.Read4b()) // 3
return nil
}
// #WREQ
func encodeListOutputProperties(output Output) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(output)).
End()
return
}
type ListOutputPropertiesReply struct {
NumAtoms uint16
Atoms []x.Atom
}
func readListOutputPropertiesReply(r *x.Reader, v *ListOutputPropertiesReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
v.NumAtoms = r.Read2b()
r.ReadPad(22) // 8
if v.NumAtoms > 0 {
if !r.RemainAtLeast4b(int(v.NumAtoms)) {
return x.ErrDataLenShort
}
v.Atoms = make([]x.Atom, v.NumAtoms)
for i := 0; i < int(v.NumAtoms); i++ {
v.Atoms[i] = x.Atom(r.Read4b())
}
}
return nil
}
// #WREQ
func encodeQueryOutputProperty(output Output, property x.Atom) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(output)).
Write4b(uint32(property)).
End()
return
}
type QueryOutputPropertyReply struct {
Pending bool
Range bool
Immutable bool
ValidValues []int32
}
func readQueryOutputPropertyReply(r *x.Reader, v *QueryOutputPropertyReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
_, length := r.ReadReplyHeader()
v.Pending = r.ReadBool()
v.Range = r.ReadBool()
v.Immutable = r.ReadBool()
r.ReadPad(21) // 8
if length > 0 {
if !r.RemainAtLeast4b(int(length)) {
return x.ErrDataLenShort
}
v.ValidValues = make([]int32, length)
for i := 0; i < int(length); i++ {
v.ValidValues[i] = int32(r.Read4b())
}
}
return nil
}
// #WREQ
func encodeConfigureOutputProperty(output Output, property x.Atom, pending, range0 bool,
values []int32) (b x.RequestBody) {
buf := b.AddBlock(3 + len(values)).
Write4b(uint32(output)).
Write4b(uint32(property)).
WriteBool(pending).
WriteBool(range0).
WritePad(2) // 3
for _, value := range values {
buf.Write4b(uint32(value))
}
return
}
// #WREQ
func encodeChangeOutputProperty(output Output, property x.Atom, type0 x.Atom,
format, mode uint8, data []byte) (b x.RequestBody) {
numUnits := uint32(len(data) / (int(format) / 8))
b.AddBlock(5).
Write4b(uint32(output)).
Write4b(uint32(property)).
Write4b(uint32(type0)). // 3
Write1b(format).
Write1b(mode).
WritePad(2).
Write4b(numUnits). // 5
End()
b.AddBytes(data)
return
}
// #WREQ
func encodeDeleteOutputProperty(output Output, property x.Atom) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(output)).
Write4b(uint32(property)).
End()
return
}
// #WREQ
func encodeGetOutputProperty(output Output, property, Type x.Atom,
longOffset, longLength uint32, delete, pending bool) (b x.RequestBody) {
b.AddBlock(6).
Write4b(uint32(output)).
Write4b(uint32(property)).
Write4b(uint32(Type)).
Write4b(longOffset).
Write4b(longLength). // 5
WriteBool(delete).
WriteBool(pending).
WritePad(2). // 6
End()
return
}
type GetOutputPropertyReply struct {
Format byte
Type x.Atom
BytesAfter uint32
ValueLen uint32
Value []byte
}
func readGetOutputPropertyReply(r *x.Reader, v *GetOutputPropertyReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Format, _ = r.ReadReplyHeader()
v.Type = x.Atom(r.Read4b())
v.BytesAfter = r.Read4b()
v.ValueLen = r.Read4b() // 5
// unused
r.ReadPad(12) // 8
var err error
n := int(v.ValueLen) * int(v.Format/8)
v.Value, err = r.ReadBytes(n)
return err
}
// #WREQ
func encodeCreateMode(window x.Window, modeInfo *ModeInfo) (b x.RequestBody) {
modeInfo.Name = x.TruncateStr(modeInfo.Name, math.MaxUint16)
modeInfo.nameLen = uint16(len(modeInfo.Name))
buf := b.AddBlock(9).
Write4b(uint32(window))
writeModeInfo(buf, modeInfo)
buf.End()
b.AddBytes([]byte(modeInfo.Name))
return
}
type CreateModeReply struct {
Mode Mode
}
func readCreateModeReply(r *x.Reader, v *CreateModeReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
v.Mode = Mode(r.Read4b())
return nil
}
// #WREQ
func encodeDestroyMode(mode Mode) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(mode)).
End()
return
}
// #WREQ
func encodeAddOutputMode(output Output, mode Mode) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(output)).
Write4b(uint32(mode)).
End()
return
}
// #WREQ
func encodeDeleteOutputMode(output Output, mode Mode) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(output)).
Write4b(uint32(mode)).
End()
return
}
// #WREQ
func encodeSetCrtcConfig(crtc Crtc, timestamp, configTimestamp x.Timestamp,
X, y int16, mode Mode, rotation uint16, outputs []Output) (b x.RequestBody) {
b0 := b.AddBlock(6 + len(outputs)).
Write4b(uint32(crtc)).
Write4b(uint32(timestamp)).
Write4b(uint32(configTimestamp)).
Write2b(uint16(X)).
Write2b(uint16(y)).
Write4b(uint32(mode)).
Write2b(rotation).
WritePad(2)
for _, output := range outputs {
b0.Write4b(uint32(output))
}
b0.End()
return
}
type SetCrtcConfigReply struct {
Status uint8
Timestamp x.Timestamp
}
func readSetCrtcConfigReply(r *x.Reader, v *SetCrtcConfigReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b()) // 3
return nil
}
// #WREQ
func encodeSelectInput(window x.Window, enable uint16) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write2b(enable).
WritePad(2).
End()
return
}
// #WREQ
func encodeGetCrtcGammaSize(crtc Crtc) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(crtc)).
End()
return
}
type GetCrtcGammaSizeReply struct {
Size uint16
}
func readGetCrtcGammaSizeReply(r *x.Reader, v *GetCrtcGammaSizeReply) error {
r.Read1b()
r.Read1b()
// seq
r.Read2b()
// length
r.Read4b()
v.Size = r.Read2b()
r.ReadPad(22)
return nil
}
// #WREQ
func encodeGetCrtcGamma(crtc Crtc) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(crtc)).
End()
return
}
type GetCrtcGammaReply struct {
Size uint16
Red []uint16
Green []uint16
Blue []uint16
}
func readGetCrtcGammaReply(r *x.Reader, v *GetCrtcGammaReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
v.Size = r.Read2b()
r.ReadPad(22) // 8
if v.Size > 0 {
if !r.RemainAtLeast(3 * (2*int(v.Size) + x.Pad(2*int(v.Size)))) {
return x.ErrDataLenShort
}
v.Red = make([]uint16, v.Size)
for i := 0; i < int(v.Size); i++ {
v.Red[i] = r.Read2b()
}
r.ReadPad(x.Pad(int(v.Size) * 2))
v.Green = make([]uint16, v.Size)
for i := 0; i < int(v.Size); i++ {
v.Green[i] = r.Read2b()
}
r.ReadPad(x.Pad(int(v.Size) * 2))
v.Blue = make([]uint16, v.Size)
for i := 0; i < int(v.Size); i++ {
v.Blue[i] = r.Read2b()
}
}
return nil
}
// #WREQ
func encodeSetCrtcGamma(crtc Crtc, red, green, blue []uint16) (b x.RequestBody) {
size := len(red)
if len(green) != size {
panic("assert len(green) != size failed")
}
if len(blue) != size {
panic("assert len(blue) != size failed")
}
b0 := b.AddBlock(2 + x.SizeIn4bWithPad(6*size)).
Write4b(uint32(crtc)).
Write2b(uint16(size)).
WritePad(2)
for _, value := range red {
b0.Write2b(value)
}
for _, value := range green {
b0.Write2b(value)
}
for _, value := range blue {
b0.Write2b(value)
}
b0.WritePad(x.Pad(6 * size))
return
}
// #WREQ
func encodeGetProviders(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
type GetProvidersReply struct {
Timestamp x.Timestamp
NumProviders uint16
Providers []Provider
}
func readGetProvidersReply(r *x.Reader, v *GetProvidersReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b()) // 3
v.NumProviders = r.Read2b()
r.ReadPad(18) // 8
if v.NumProviders > 0 {
if !r.RemainAtLeast4b(int(v.NumProviders)) {
return x.ErrDataLenShort
}
v.Providers = make([]Provider, v.NumProviders)
for i := 0; i < int(v.NumProviders); i++ {
v.Providers[i] = Provider(r.Read4b())
}
}
return nil
}
// #WREQ
func encodeGetProviderInfo(provider Provider, configTimestamp x.Timestamp) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(provider)).
Write4b(uint32(configTimestamp)).
End()
return
}
type GetProviderInfoReply struct {
Status uint8
Timestamp x.Timestamp
Capabilities uint32
NumCrtcs uint16
NumOutputs uint16
NumAssociatedProviders uint16
NameLen uint16
Crtcs []Crtc
Outputs []Output
AssociatedProviders []Provider
AssociatedCapability []uint32
Name string
}
func readGetProviderInfoReply(r *x.Reader, v *GetProviderInfoReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Status, _ = r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b())
v.Capabilities = r.Read4b()
v.NumCrtcs = r.Read2b()
v.NumOutputs = r.Read2b()
v.NumAssociatedProviders = r.Read2b()
v.NameLen = r.Read2b() // 6
r.ReadPad(8) // 8
if v.NumCrtcs > 0 {
if !r.RemainAtLeast4b(int(v.NumCrtcs)) {
return x.ErrDataLenShort
}
v.Crtcs = make([]Crtc, v.NumCrtcs)
for i := 0; i < int(v.NumCrtcs); i++ {
v.Crtcs[i] = Crtc(r.Read4b())
}
}
if v.NumOutputs > 0 {
if !r.RemainAtLeast4b(int(v.NumOutputs)) {
return x.ErrDataLenShort
}
v.Outputs = make([]Output, v.NumOutputs)
for i := 0; i < int(v.NumOutputs); i++ {
v.Outputs[i] = Output(r.Read4b())
}
}
if v.NumAssociatedProviders > 0 {
if !r.RemainAtLeast4b(2 * int(v.NumAssociatedProviders)) {
return x.ErrDataLenShort
}
v.AssociatedProviders = make([]Provider, v.NumAssociatedProviders)
for i := 0; i < int(v.NumAssociatedProviders); i++ {
v.AssociatedProviders[i] = Provider(r.Read4b())
}
v.AssociatedCapability = make([]uint32, v.NumAssociatedProviders)
for i := 0; i < int(v.NumAssociatedProviders); i++ {
v.AssociatedCapability[i] = r.Read4b()
}
}
if v.NameLen > 0 {
var err error
v.Name, err = r.ReadString(int(v.NameLen))
if err != nil {
return err
}
}
return nil
}
// #WREQ
func encodeSetProviderOffloadSink(provider, sinkProvider Provider,
configTimestamp x.Timestamp) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(provider)).
Write4b(uint32(sinkProvider)).
Write4b(uint32(configTimestamp)).
End()
return
}
// #WREQ
func encodeSetProviderOutputSource(provider, sourceProvider Provider,
configTimestamp x.Timestamp) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(provider)).
Write4b(uint32(sourceProvider)).
Write4b(uint32(configTimestamp)).
End()
return
}
// #WREQ
func encodeListProviderProperties(provider Provider) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(provider)).
End()
return
}
type ListProviderPropertiesReply struct {
NumAtoms uint16
Atoms []x.Atom
}
func readListProviderPropertiesReply(r *x.Reader, v *ListProviderPropertiesReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadReplyHeader()
v.NumAtoms = r.Read2b()
r.ReadPad(22) // 8
if v.NumAtoms > 0 {
if !r.RemainAtLeast4b(int(v.NumAtoms)) {
return x.ErrDataLenShort
}
v.Atoms = make([]x.Atom, v.NumAtoms)
for i := 0; i < int(v.NumAtoms); i++ {
v.Atoms[i] = x.Atom(r.Read4b())
}
}
return nil
}
// #WREQ
func encodeGetMonitors(window x.Window, getActive bool) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
WriteBool(getActive).
WritePad(3).
End()
return
}
type GetMonitorsReply struct {
Timestamp x.Timestamp
NMonitors uint32
NOutputs uint32
Monitors []MonitorInfo
}
// size: (6 + NOutputs) * 4b
type MonitorInfo struct {
Name x.Atom
Primary bool
Automatic bool
NOutputs uint16
X, Y int16
Width, Height uint16 // pixels
MmWidth, MmHeight uint32 // in millimeters
Outputs []Output
}
func readMonitorInfo(r *x.Reader, v *MonitorInfo) error {
if !r.RemainAtLeast4b(6) {
return x.ErrDataLenShort
}
v.Name = x.Atom(r.Read4b())
v.Primary = r.ReadBool()
v.Automatic = r.ReadBool()
v.NOutputs = r.Read2b()
v.X = int16(r.Read2b())
v.Y = int16(r.Read2b())
v.Width = r.Read2b()
v.Height = r.Read2b()
v.MmWidth = r.Read4b()
v.MmHeight = r.Read4b() // 6
if v.NOutputs > 0 {
v.Outputs = make([]Output, v.NOutputs)
for i := 0; i < int(v.NOutputs); i++ {
v.Outputs[i] = Output(r.Read4b())
}
}
return nil
}
func writeMonitorInfo(b *x.FixedSizeBuf, v *MonitorInfo) {
v.NOutputs = uint16(len(v.Outputs))
b.Write4b(uint32(v.Name)).
WriteBool(v.Primary).
WriteBool(v.Automatic).
Write2b(v.NOutputs).
Write2b(uint16(v.X)).
Write2b(uint16(v.Y)).
Write2b(v.Width).
Write2b(v.Height).
Write4b(v.MmWidth).
Write4b(v.MmHeight) // 6
for _, o := range v.Outputs {
b.Write4b(uint32(o))
}
}
func readGetMonitorsReply(r *x.Reader, v *GetMonitorsReply) error {
r.ReadReplyHeader()
v.Timestamp = x.Timestamp(r.Read4b())
v.NMonitors = r.Read4b()
v.NOutputs = r.Read4b()
r.ReadPad(12)
if v.NMonitors > 0 {
v.Monitors = make([]MonitorInfo, v.NMonitors)
for i := 0; i < int(v.NMonitors); i++ {
err := readMonitorInfo(r, &v.Monitors[i])
if err != nil {
return err
}
}
}
return nil
}
// #WREQ
func encodeSetMonitor(window x.Window, monitorInfo *MonitorInfo) (b x.RequestBody) {
sizeIn4b := 7 + len(monitorInfo.Outputs)
buf := b.AddBlock(sizeIn4b).
Write4b(uint32(window))
writeMonitorInfo(buf, monitorInfo)
buf.End()
return
}
// #WREQ
func encodeDeleteMonitor(window x.Window, name x.Atom) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write4b(uint32(name)).
End()
return
}
go-x11-client-1.0.2/ext/randr/randr_event.go 0000664 0000000 0000000 00000010611 14607133730 0020551 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package randr
import "github.com/linuxdeepin/go-x11-client"
type ScreenChangeNotifyEvent struct {
Rotation uint8
Sequence uint16
Timestamp x.Timestamp
ConfigTimestamp x.Timestamp
Root x.Window
RequestWindow x.Window
SizeID uint16
SubpixelOrder uint16
Width uint16
Height uint16
MmWidth uint16
MmHeight uint16
}
func readScreenChangeNotifyEvent(r *x.Reader, v *ScreenChangeNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.Rotation, v.Sequence = r.ReadEventHeader()
v.Timestamp = x.Timestamp(r.Read4b())
v.ConfigTimestamp = x.Timestamp(r.Read4b())
v.Root = x.Window(r.Read4b())
v.RequestWindow = x.Window(r.Read4b()) // 5
v.SizeID = r.Read2b()
v.SubpixelOrder = r.Read2b()
v.Width = r.Read2b()
v.Height = r.Read2b()
v.MmWidth = r.Read2b()
v.MmHeight = r.Read2b() // 8
return nil
}
type NotifyEvent struct {
SubCode uint8
Sequence uint16
Data []byte
}
func readNotifyEvent(r *x.Reader, v *NotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.SubCode, v.Sequence = r.ReadEventHeader()
v.Data = r.MustReadBytes(28) // 8
return nil
}
func (e *NotifyEvent) NewCrtcChangeNotifyEvent() (*CrtcChangeNotifyEvent, error) {
var ev CrtcChangeNotifyEvent
r := x.NewReaderFromData(e.Data)
err := readCrtcChangeNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
func (e *NotifyEvent) NewOutputChangeNotifyEvent() (*OutputChangeNotifyEvent, error) {
var ev OutputChangeNotifyEvent
r := x.NewReaderFromData(e.Data)
err := readOutputChangeNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
func (e *NotifyEvent) NewOutputPropertyNotifyEvent() (*OutputPropertyNotifyEvent,
error) {
var ev OutputPropertyNotifyEvent
r := x.NewReaderFromData(e.Data)
err := readOutputPropertyNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
func (e *NotifyEvent) NewResourceChangeNotifyEvent() (*ResourceChangeNotifyEvent,
error) {
var ev ResourceChangeNotifyEvent
r := x.NewReaderFromData(e.Data)
err := readResourceChangeNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
type CrtcChangeNotifyEvent struct {
Timestamp x.Timestamp
Window x.Window
Crtc Crtc
Mode Mode
Rotation uint16
X, Y int16
Width, Height uint16
}
func readCrtcChangeNotifyEvent(r *x.Reader, v *CrtcChangeNotifyEvent) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
v.Timestamp = x.Timestamp(r.Read4b())
v.Window = x.Window(r.Read4b())
v.Crtc = Crtc(r.Read4b())
v.Mode = Mode(r.Read4b())
v.Rotation = r.Read2b()
r.ReadPad(2) // 5
v.X = int16(r.Read2b())
v.Y = int16(r.Read2b())
v.Width = r.Read2b()
v.Height = r.Read2b() // 7
return nil
}
type OutputChangeNotifyEvent struct {
Timestamp x.Timestamp
ConfigTimestamp x.Timestamp
Window x.Window
Output Output
Crtc Crtc
Mode Mode
Rotation uint16
Connection uint8
SubPixelOrder uint8
}
func readOutputChangeNotifyEvent(r *x.Reader, v *OutputChangeNotifyEvent) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
v.Timestamp = x.Timestamp(r.Read4b())
v.ConfigTimestamp = x.Timestamp(r.Read4b())
v.Window = x.Window(r.Read4b())
v.Output = Output(r.Read4b())
v.Crtc = Crtc(r.Read4b()) // 5
v.Mode = Mode(r.Read4b())
v.Rotation = r.Read2b()
v.Connection = r.Read1b()
v.SubPixelOrder = r.Read1b() // 7
return nil
}
type OutputPropertyNotifyEvent struct {
Window x.Window
Output Output
Atom x.Atom
Timestamp x.Timestamp
Status uint8
}
func readOutputPropertyNotifyEvent(r *x.Reader, v *OutputPropertyNotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
v.Window = x.Window(r.Read4b())
v.Output = Output(r.Read4b())
v.Atom = x.Atom(r.Read4b())
v.Timestamp = x.Timestamp(r.Read4b())
v.Status = r.Read1b() // 5
return nil
}
type ResourceChangeNotifyEvent struct {
Timestamp x.Timestamp
Window x.Window
}
func readResourceChangeNotifyEvent(r *x.Reader, v *ResourceChangeNotifyEvent) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
v.Timestamp = x.Timestamp(r.Read4b())
v.Window = x.Window(r.Read4b())
return nil
}
go-x11-client-1.0.2/ext/randr/randr_req_auto.go 0000664 0000000 0000000 00000064560 14607133730 0021263 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package randr
import x "github.com/linuxdeepin/go-x11-client"
import "github.com/linuxdeepin/go-x11-client/ext/render"
func QueryVersion(conn *x.Conn, clientMajorVersion, clientMinorVersion uint32) QueryVersionCookie {
body := encodeQueryVersion(clientMajorVersion, clientMinorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetScreenConfig(conn *x.Conn, window x.Window, timestamp x.Timestamp, configTimestamp x.Timestamp, sizeID uint16, rotation uint16, rate uint16) SetScreenConfigCookie {
body := encodeSetScreenConfig(window, timestamp, configTimestamp, sizeID, rotation, rate)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: SetScreenConfigOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return SetScreenConfigCookie(seq)
}
func (cookie SetScreenConfigCookie) Reply(conn *x.Conn) (*SetScreenConfigReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply SetScreenConfigReply
err = readSetScreenConfigReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetScreenInfo(conn *x.Conn, window x.Window) GetScreenInfoCookie {
body := encodeGetScreenInfo(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetScreenInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetScreenInfoCookie(seq)
}
func (cookie GetScreenInfoCookie) Reply(conn *x.Conn) (*GetScreenInfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetScreenInfoReply
err = readGetScreenInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetScreenSizeRange(conn *x.Conn, window x.Window) GetScreenSizeRangeCookie {
body := encodeGetScreenSizeRange(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetScreenSizeRangeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetScreenSizeRangeCookie(seq)
}
func (cookie GetScreenSizeRangeCookie) Reply(conn *x.Conn) (*GetScreenSizeRangeReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetScreenSizeRangeReply
err = readGetScreenSizeRangeReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetScreenSize(conn *x.Conn, window x.Window, width, height uint16, mmWidth, mmHeight uint32) {
body := encodeSetScreenSize(window, width, height, mmWidth, mmHeight)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetScreenSizeOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetScreenSizeChecked(conn *x.Conn, window x.Window, width, height uint16, mmWidth, mmHeight uint32) x.VoidCookie {
body := encodeSetScreenSize(window, width, height, mmWidth, mmHeight)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetScreenSizeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetCrtcInfo(conn *x.Conn, crtc Crtc, configTimestamp x.Timestamp) GetCrtcInfoCookie {
body := encodeGetCrtcInfo(crtc, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCrtcInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCrtcInfoCookie(seq)
}
func (cookie GetCrtcInfoCookie) Reply(conn *x.Conn) (*GetCrtcInfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCrtcInfoReply
err = readGetCrtcInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetOutputInfo(conn *x.Conn, output Output, configTimestamp x.Timestamp) GetOutputInfoCookie {
body := encodeGetOutputInfo(output, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetOutputInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetOutputInfoCookie(seq)
}
func (cookie GetOutputInfoCookie) Reply(conn *x.Conn) (*GetOutputInfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetOutputInfoReply
err = readGetOutputInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetScreenResources(conn *x.Conn, window x.Window) GetScreenResourcesCookie {
body := encodeGetScreenResources(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetScreenResourcesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetScreenResourcesCookie(seq)
}
func (cookie GetScreenResourcesCookie) Reply(conn *x.Conn) (*GetScreenResourcesReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetScreenResourcesReply
err = readGetScreenResourcesReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetScreenResourcesCurrent(conn *x.Conn, window x.Window) GetScreenResourcesCurrentCookie {
body := encodeGetScreenResourcesCurrent(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetScreenResourcesCurrentOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetScreenResourcesCurrentCookie(seq)
}
func (cookie GetScreenResourcesCurrentCookie) Reply(conn *x.Conn) (*GetScreenResourcesCurrentReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetScreenResourcesCurrentReply
err = readGetScreenResourcesCurrentReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetCrtcTransform(conn *x.Conn, crtc Crtc, transform *render.Transform, filter string, filterParams []render.Fixed) {
body := encodeSetCrtcTransform(crtc, transform, filter, filterParams)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCrtcTransformOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetCrtcTransformChecked(conn *x.Conn, crtc Crtc, transform *render.Transform, filter string, filterParams []render.Fixed) x.VoidCookie {
body := encodeSetCrtcTransform(crtc, transform, filter, filterParams)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCrtcTransformOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetCrtcTransform(conn *x.Conn, crtc Crtc) GetCrtcTransformCookie {
body := encodeGetCrtcTransform(crtc)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCrtcTransformOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCrtcTransformCookie(seq)
}
func (cookie GetCrtcTransformCookie) Reply(conn *x.Conn) (*GetCrtcTransformReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCrtcTransformReply
err = readGetCrtcTransformReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetPanning(conn *x.Conn, crtc Crtc) GetPanningCookie {
body := encodeGetPanning(crtc)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetPanningOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetPanningCookie(seq)
}
func (cookie GetPanningCookie) Reply(conn *x.Conn) (*GetPanningReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetPanningReply
err = readGetPanningReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetPanning(conn *x.Conn, crtc Crtc, timestamp x.Timestamp, panning *Panning) SetPanningCookie {
body := encodeSetPanning(crtc, timestamp, panning)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: SetPanningOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return SetPanningCookie(seq)
}
func (cookie SetPanningCookie) Reply(conn *x.Conn) (*SetPanningReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply SetPanningReply
err = readSetPanningReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetOutputPrimary(conn *x.Conn, window x.Window, output Output) {
body := encodeSetOutputPrimary(window, output)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetOutputPrimaryOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetOutputPrimaryChecked(conn *x.Conn, window x.Window, output Output) x.VoidCookie {
body := encodeSetOutputPrimary(window, output)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetOutputPrimaryOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetOutputPrimary(conn *x.Conn, window x.Window) GetOutputPrimaryCookie {
body := encodeGetOutputPrimary(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetOutputPrimaryOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetOutputPrimaryCookie(seq)
}
func (cookie GetOutputPrimaryCookie) Reply(conn *x.Conn) (*GetOutputPrimaryReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetOutputPrimaryReply
err = readGetOutputPrimaryReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func ListOutputProperties(conn *x.Conn, output Output) ListOutputPropertiesCookie {
body := encodeListOutputProperties(output)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: ListOutputPropertiesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return ListOutputPropertiesCookie(seq)
}
func (cookie ListOutputPropertiesCookie) Reply(conn *x.Conn) (*ListOutputPropertiesReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply ListOutputPropertiesReply
err = readListOutputPropertiesReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func QueryOutputProperty(conn *x.Conn, output Output, property x.Atom) QueryOutputPropertyCookie {
body := encodeQueryOutputProperty(output, property)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryOutputPropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryOutputPropertyCookie(seq)
}
func (cookie QueryOutputPropertyCookie) Reply(conn *x.Conn) (*QueryOutputPropertyReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryOutputPropertyReply
err = readQueryOutputPropertyReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func ConfigureOutputProperty(conn *x.Conn, output Output, property x.Atom, pending, range0 bool, values []int32) {
body := encodeConfigureOutputProperty(output, property, pending, range0, values)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ConfigureOutputPropertyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ConfigureOutputPropertyChecked(conn *x.Conn, output Output, property x.Atom, pending, range0 bool, values []int32) x.VoidCookie {
body := encodeConfigureOutputProperty(output, property, pending, range0, values)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ConfigureOutputPropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ChangeOutputProperty(conn *x.Conn, output Output, property x.Atom, type0 x.Atom, format, mode uint8, data []byte) {
body := encodeChangeOutputProperty(output, property, type0, format, mode, data)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeOutputPropertyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ChangeOutputPropertyChecked(conn *x.Conn, output Output, property x.Atom, type0 x.Atom, format, mode uint8, data []byte) x.VoidCookie {
body := encodeChangeOutputProperty(output, property, type0, format, mode, data)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeOutputPropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func DeleteOutputProperty(conn *x.Conn, output Output, property x.Atom) {
body := encodeDeleteOutputProperty(output, property)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeleteOutputPropertyOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DeleteOutputPropertyChecked(conn *x.Conn, output Output, property x.Atom) x.VoidCookie {
body := encodeDeleteOutputProperty(output, property)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeleteOutputPropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetOutputProperty(conn *x.Conn, output Output, property, Type x.Atom, longOffset, longLength uint32, delete, pending bool) GetOutputPropertyCookie {
body := encodeGetOutputProperty(output, property, Type, longOffset, longLength, delete, pending)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetOutputPropertyOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetOutputPropertyCookie(seq)
}
func (cookie GetOutputPropertyCookie) Reply(conn *x.Conn) (*GetOutputPropertyReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetOutputPropertyReply
err = readGetOutputPropertyReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CreateMode(conn *x.Conn, window x.Window, modeInfo *ModeInfo) CreateModeCookie {
body := encodeCreateMode(window, modeInfo)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: CreateModeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return CreateModeCookie(seq)
}
func (cookie CreateModeCookie) Reply(conn *x.Conn) (*CreateModeReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply CreateModeReply
err = readCreateModeReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func DestroyMode(conn *x.Conn, mode Mode) {
body := encodeDestroyMode(mode)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DestroyModeOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DestroyModeChecked(conn *x.Conn, mode Mode) x.VoidCookie {
body := encodeDestroyMode(mode)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DestroyModeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func AddOutputMode(conn *x.Conn, output Output, mode Mode) {
body := encodeAddOutputMode(output, mode)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AddOutputModeOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func AddOutputModeChecked(conn *x.Conn, output Output, mode Mode) x.VoidCookie {
body := encodeAddOutputMode(output, mode)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AddOutputModeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func DeleteOutputMode(conn *x.Conn, output Output, mode Mode) {
body := encodeDeleteOutputMode(output, mode)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeleteOutputModeOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DeleteOutputModeChecked(conn *x.Conn, output Output, mode Mode) x.VoidCookie {
body := encodeDeleteOutputMode(output, mode)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeleteOutputModeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetCrtcConfig(conn *x.Conn, crtc Crtc, timestamp, configTimestamp x.Timestamp, X, y int16, mode Mode, rotation uint16, outputs []Output) SetCrtcConfigCookie {
body := encodeSetCrtcConfig(crtc, timestamp, configTimestamp, X, y, mode, rotation, outputs)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: SetCrtcConfigOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return SetCrtcConfigCookie(seq)
}
func (cookie SetCrtcConfigCookie) Reply(conn *x.Conn) (*SetCrtcConfigReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply SetCrtcConfigReply
err = readSetCrtcConfigReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SelectInput(conn *x.Conn, window x.Window, enable uint16) {
body := encodeSelectInput(window, enable)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectInputOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SelectInputChecked(conn *x.Conn, window x.Window, enable uint16) x.VoidCookie {
body := encodeSelectInput(window, enable)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectInputOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetCrtcGammaSize(conn *x.Conn, crtc Crtc) GetCrtcGammaSizeCookie {
body := encodeGetCrtcGammaSize(crtc)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCrtcGammaSizeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCrtcGammaSizeCookie(seq)
}
func (cookie GetCrtcGammaSizeCookie) Reply(conn *x.Conn) (*GetCrtcGammaSizeReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCrtcGammaSizeReply
err = readGetCrtcGammaSizeReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetCrtcGamma(conn *x.Conn, crtc Crtc) GetCrtcGammaCookie {
body := encodeGetCrtcGamma(crtc)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCrtcGammaOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCrtcGammaCookie(seq)
}
func (cookie GetCrtcGammaCookie) Reply(conn *x.Conn) (*GetCrtcGammaReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCrtcGammaReply
err = readGetCrtcGammaReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetCrtcGamma(conn *x.Conn, crtc Crtc, red, green, blue []uint16) {
body := encodeSetCrtcGamma(crtc, red, green, blue)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCrtcGammaOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetCrtcGammaChecked(conn *x.Conn, crtc Crtc, red, green, blue []uint16) x.VoidCookie {
body := encodeSetCrtcGamma(crtc, red, green, blue)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCrtcGammaOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetProviders(conn *x.Conn, window x.Window) GetProvidersCookie {
body := encodeGetProviders(window)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetProvidersOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetProvidersCookie(seq)
}
func (cookie GetProvidersCookie) Reply(conn *x.Conn) (*GetProvidersReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetProvidersReply
err = readGetProvidersReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetProviderInfo(conn *x.Conn, provider Provider, configTimestamp x.Timestamp) GetProviderInfoCookie {
body := encodeGetProviderInfo(provider, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetProviderInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetProviderInfoCookie(seq)
}
func (cookie GetProviderInfoCookie) Reply(conn *x.Conn) (*GetProviderInfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetProviderInfoReply
err = readGetProviderInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetProviderOffloadSink(conn *x.Conn, provider, sinkProvider Provider, configTimestamp x.Timestamp) {
body := encodeSetProviderOffloadSink(provider, sinkProvider, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetProviderOffloadSinkOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetProviderOffloadSinkChecked(conn *x.Conn, provider, sinkProvider Provider, configTimestamp x.Timestamp) x.VoidCookie {
body := encodeSetProviderOffloadSink(provider, sinkProvider, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetProviderOffloadSinkOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetProviderOutputSource(conn *x.Conn, provider, sourceProvider Provider, configTimestamp x.Timestamp) {
body := encodeSetProviderOutputSource(provider, sourceProvider, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetProviderOutputSourceOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetProviderOutputSourceChecked(conn *x.Conn, provider, sourceProvider Provider, configTimestamp x.Timestamp) x.VoidCookie {
body := encodeSetProviderOutputSource(provider, sourceProvider, configTimestamp)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetProviderOutputSourceOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ListProviderProperties(conn *x.Conn, provider Provider) ListProviderPropertiesCookie {
body := encodeListProviderProperties(provider)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: ListProviderPropertiesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return ListProviderPropertiesCookie(seq)
}
func (cookie ListProviderPropertiesCookie) Reply(conn *x.Conn) (*ListProviderPropertiesReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply ListProviderPropertiesReply
err = readListProviderPropertiesReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetMonitors(conn *x.Conn, window x.Window, getActive bool) GetMonitorsCookie {
body := encodeGetMonitors(window, getActive)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetMonitorsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetMonitorsCookie(seq)
}
func (cookie GetMonitorsCookie) Reply(conn *x.Conn) (*GetMonitorsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetMonitorsReply
err = readGetMonitorsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetMonitor(conn *x.Conn, window x.Window, monitorInfo *MonitorInfo) {
body := encodeSetMonitor(window, monitorInfo)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetMonitorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetMonitorChecked(conn *x.Conn, window x.Window, monitorInfo *MonitorInfo) x.VoidCookie {
body := encodeSetMonitor(window, monitorInfo)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetMonitorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func DeleteMonitor(conn *x.Conn, window x.Window, name x.Atom) {
body := encodeDeleteMonitor(window, name)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeleteMonitorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DeleteMonitorChecked(conn *x.Conn, window x.Window, name x.Atom) x.VoidCookie {
body := encodeDeleteMonitor(window, name)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeleteMonitorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/record/ 0000775 0000000 0000000 00000000000 14607133730 0016064 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/record/auto.go 0000664 0000000 0000000 00000003173 14607133730 0017367 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package record
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Record
const MajorVersion = 1
const MinorVersion = 13
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// simple ('xcb', 'Record', 'CONTEXT')
type Context uint32
// simple ('xcb', 'Record', 'ElementHeader')
type ElementHeader uint8
// enum HType
const (
HTypeFromServerTime = 1
HTypeFromClientTime = 2
HTypeFromClientSequence = 4
)
// simple ('xcb', 'Record', 'ClientSpec')
type ClientSpec uint32
// enum CS
const (
CSCurrentClients = 1
CSFutureClients = 2
CSAllClients = 3
)
const BadContextErrorCode = 0
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
const CreateContextOpcode = 1
const RegisterClientsOpcode = 2
const UnregisterClientsOpcode = 3
const GetContextOpcode = 4
type GetContextCookie x.SeqNum
const EnableContextOpcode = 5
type EnableContextCookie x.SeqNum
const DisableContextOpcode = 6
const FreeContextOpcode = 7
var errorCodeNameMap = map[uint8]string{
BadContextErrorCode: "BadContext",
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
CreateContextOpcode: "CreateContext",
RegisterClientsOpcode: "RegisterClients",
UnregisterClientsOpcode: "UnregisterClients",
GetContextOpcode: "GetContext",
EnableContextOpcode: "EnableContext",
DisableContextOpcode: "DisableContext",
FreeContextOpcode: "FreeContext",
}
func init() {
_ext = x.NewExtension("RECORD", 0, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/record/record.go 0000664 0000000 0000000 00000014406 14607133730 0017676 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package record
import (
"github.com/linuxdeepin/go-x11-client"
)
// size: 2b
type Range8 struct {
First uint8
Last uint8
}
func writeRange8(b *x.FixedSizeBuf, v Range8) {
b.Write1b(v.First)
b.Write1b(v.Last)
}
func readRange8(r *x.Reader) Range8 {
var v Range8
v.First = r.Read1b()
v.Last = r.Read1b()
return v
}
// size: 4b
type Range16 struct {
First uint16
Last uint16
}
func readRange16(r *x.Reader) Range16 {
var v Range16
v.First = r.Read2b()
v.Last = r.Read2b()
return v
}
func writeRange16(b *x.FixedSizeBuf, v Range16) {
b.Write2b(v.First)
b.Write2b(v.Last)
}
// size: 6b
type ExtRange struct {
Major Range8
Minor Range16
}
func readExtRange(r *x.Reader) (v ExtRange) {
v.Major = readRange8(r)
v.Minor = readRange16(r)
return
}
func writeExtRange(b *x.FixedSizeBuf, v ExtRange) {
writeRange8(b, v.Major)
writeRange16(b, v.Minor)
}
// size: 6 * 4b
type Range struct {
CoreRequests Range8
CoreReplies Range8
ExtRequests ExtRange
ExtReplies ExtRange
DeliveredEvents Range8
DeviceEvents Range8
Errors Range8
ClientStarted bool
ClientDied bool
}
func writeRange(b *x.FixedSizeBuf, v *Range) {
writeRange8(b, v.CoreRequests)
writeRange8(b, v.CoreReplies)
writeExtRange(b, v.ExtRequests)
writeExtRange(b, v.ExtReplies)
writeRange8(b, v.DeliveredEvents)
writeRange8(b, v.DeviceEvents)
writeRange8(b, v.Errors)
b.WriteBool(v.ClientStarted).
WriteBool(v.ClientDied)
}
func readRange(r *x.Reader, v *Range) {
v.CoreRequests = readRange8(r)
v.CoreReplies = readRange8(r)
v.ExtRequests = readExtRange(r)
v.ExtRequests = readExtRange(r)
v.DeliveredEvents = readRange8(r)
v.DeviceEvents = readRange8(r)
v.Errors = readRange8(r)
v.ClientStarted = r.ReadBool()
v.ClientDied = r.ReadBool()
}
type ClientInfo struct {
ClientResource ClientSpec
InterceptedProtocol []Range
}
func readClientInfo(r *x.Reader, v *ClientInfo) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
v.ClientResource = ClientSpec(r.Read4b())
interceptedProtocolLen := int(r.Read4b()) // 2
if interceptedProtocolLen > 0 {
if !r.RemainAtLeast4b(6 * interceptedProtocolLen) {
return x.ErrDataLenShort
}
v.InterceptedProtocol = make([]Range, interceptedProtocolLen)
for i := 0; i < interceptedProtocolLen; i++ {
readRange(r, &v.InterceptedProtocol[i])
}
}
return nil
}
// #WREQ
func encodeQueryVersion(majorVersion, minorVersion uint16) (b x.RequestBody) {
b.AddBlock(1).
Write2b(majorVersion).
Write2b(minorVersion).
End()
return
}
type QueryVersionReply struct {
MajorVersion uint16
MinorVersion uint16
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read2b()
v.MinorVersion = r.Read2b() // 3
return nil
}
// #WREQ
func encodeCreateContext(context Context, elementHeader ElementHeader,
clientSpecs []ClientSpec, ranges []Range) (b x.RequestBody) {
clientSpecsLen := len(clientSpecs)
rangesLen := len(ranges)
b0 := b.AddBlock(4 + clientSpecsLen + rangesLen*6).
Write4b(uint32(context)).
Write1b(uint8(elementHeader)).
WritePad(3).
Write4b(uint32(clientSpecsLen)).
Write4b(uint32(rangesLen))
for _, clientSpec := range clientSpecs {
b0.Write4b(uint32(clientSpec))
}
for i := 0; i < rangesLen; i++ {
writeRange(b0, &ranges[i])
}
b0.End()
return
}
// #WREQ
func encodeRegisterClients(context Context, elementHeader ElementHeader,
clientSpecs []ClientSpec, ranges []Range) (b x.RequestBody) {
clientSpecsLen := len(clientSpecs)
rangesLen := len(ranges)
b0 := b.AddBlock(4 + clientSpecsLen + rangesLen*6).
Write4b(uint32(context)).
Write1b(uint8(elementHeader)).
WritePad(3).
Write4b(uint32(clientSpecsLen)).
Write4b(uint32(rangesLen))
for _, clientSpec := range clientSpecs {
b0.Write4b(uint32(clientSpec))
}
for i := 0; i < rangesLen; i++ {
writeRange(b0, &ranges[i])
}
b0.End()
return
}
// #WREQ
func encodeUnregisterClients(context Context, clientSpecs []ClientSpec) (b x.RequestBody) {
clientSpecsLen := len(clientSpecs)
b0 := b.AddBlock(2 + clientSpecsLen).
Write4b(uint32(context)).
Write4b(uint32(clientSpecsLen))
for _, clientSpec := range clientSpecs {
b0.Write4b(uint32(clientSpec))
}
b0.End()
return
}
// #WREQ
func encodeGetContext(context Context) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(context)).
End()
return
}
type GetContextReply struct {
Enabled bool
ElementHeader ElementHeader
InterceptedClients []ClientInfo
}
func readGetContextReply(r *x.Reader, v *GetContextReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
enabled, _ := r.ReadReplyHeader()
v.Enabled = x.Uint8ToBool(enabled)
v.ElementHeader = ElementHeader(r.Read1b())
r.ReadPad(3)
interceptedClientsLen := int(r.Read4b()) // 4
if interceptedClientsLen > 0 {
v.InterceptedClients = make([]ClientInfo, interceptedClientsLen)
for i := 0; i < interceptedClientsLen; i++ {
err := readClientInfo(r, &v.InterceptedClients[i])
if err != nil {
return err
}
}
}
return nil
}
// #WREQ
func encodeEnableContext(context Context) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(context)).
End()
return
}
type EnableContextReply struct {
Category uint8
ElementHeader ElementHeader
ClientSwapped bool
XidBase uint32
ServerTime x.Timestamp
RecSequenceNum uint32
Data []uint8
}
func readEnableContextReply(r *x.Reader, v *EnableContextReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
var replyLen uint32
v.Category, replyLen = r.ReadReplyHeader() // 2
v.ElementHeader = ElementHeader(r.Read1b())
v.ClientSwapped = r.ReadBool()
r.ReadPad(2) // 3
v.XidBase = r.Read4b()
v.ServerTime = x.Timestamp(r.Read4b())
v.RecSequenceNum = r.Read4b() // 6
// unused
r.ReadPad(8) // 8
dataLen := 4 * int(replyLen)
var err error
v.Data, err = r.ReadBytes(dataLen)
return err
}
// #WREQ
func encodeDisableContext(context Context) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(context)).
End()
return
}
// #WREQ
func encodeFreeContext(context Context) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(context)).
End()
return
}
go-x11-client-1.0.2/ext/record/record_req_auto.go 0000664 0000000 0000000 00000013007 14607133730 0021571 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package record
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, majorVersion, minorVersion uint16) QueryVersionCookie {
body := encodeQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CreateContext(conn *x.Conn, context Context, elementHeader ElementHeader, clientSpecs []ClientSpec, ranges []Range) {
body := encodeCreateContext(context, elementHeader, clientSpecs, ranges)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateContextOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateContextChecked(conn *x.Conn, context Context, elementHeader ElementHeader, clientSpecs []ClientSpec, ranges []Range) x.VoidCookie {
body := encodeCreateContext(context, elementHeader, clientSpecs, ranges)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateContextOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func RegisterClients(conn *x.Conn, context Context, elementHeader ElementHeader, clientSpecs []ClientSpec, ranges []Range) {
body := encodeRegisterClients(context, elementHeader, clientSpecs, ranges)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RegisterClientsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func RegisterClientsChecked(conn *x.Conn, context Context, elementHeader ElementHeader, clientSpecs []ClientSpec, ranges []Range) x.VoidCookie {
body := encodeRegisterClients(context, elementHeader, clientSpecs, ranges)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RegisterClientsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func UnregisterClients(conn *x.Conn, context Context, clientSpecs []ClientSpec) {
body := encodeUnregisterClients(context, clientSpecs)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnregisterClientsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func UnregisterClientsChecked(conn *x.Conn, context Context, clientSpecs []ClientSpec) x.VoidCookie {
body := encodeUnregisterClients(context, clientSpecs)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnregisterClientsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetContext(conn *x.Conn, context Context) GetContextCookie {
body := encodeGetContext(context)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetContextOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetContextCookie(seq)
}
func (cookie GetContextCookie) Reply(conn *x.Conn) (*GetContextReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetContextReply
err = readGetContextReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func EnableContext(conn *x.Conn, context Context) EnableContextCookie {
body := encodeEnableContext(context)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: EnableContextOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return EnableContextCookie(seq)
}
func (cookie EnableContextCookie) Reply(conn *x.Conn) (*EnableContextReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply EnableContextReply
err = readEnableContextReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func DisableContext(conn *x.Conn, context Context) {
body := encodeDisableContext(context)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DisableContextOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DisableContextChecked(conn *x.Conn, context Context) x.VoidCookie {
body := encodeDisableContext(context)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DisableContextOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func FreeContext(conn *x.Conn, context Context) {
body := encodeFreeContext(context)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreeContextOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func FreeContextChecked(conn *x.Conn, context Context) x.VoidCookie {
body := encodeFreeContext(context)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreeContextOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/render/ 0000775 0000000 0000000 00000000000 14607133730 0016065 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/render/auto.go 0000664 0000000 0000000 00000014467 14607133730 0017400 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package render
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Render
const MajorVersion = 0
const MinorVersion = 11
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// enum PictType
const (
PictTypeIndexed = 0
PictTypeDirect = 1
)
// enum Picture
const (
PictureNone = 0
)
// enum PictOp
const (
PictOpClear = 0
PictOpSrc = 1
PictOpDst = 2
PictOpOver = 3
PictOpOverReverse = 4
PictOpIn = 5
PictOpInReverse = 6
PictOpOut = 7
PictOpOutReverse = 8
PictOpAtop = 9
PictOpAtopReverse = 10
PictOpXor = 11
PictOpAdd = 12
PictOpSaturate = 13
PictOpDisjointClear = 16
PictOpDisjointSrc = 17
PictOpDisjointDst = 18
PictOpDisjointOver = 19
PictOpDisjointOverReverse = 20
PictOpDisjointIn = 21
PictOpDisjointInReverse = 22
PictOpDisjointOut = 23
PictOpDisjointOutReverse = 24
PictOpDisjointAtop = 25
PictOpDisjointAtopReverse = 26
PictOpDisjointXor = 27
PictOpConjointClear = 32
PictOpConjointSrc = 33
PictOpConjointDst = 34
PictOpConjointOver = 35
PictOpConjointOverReverse = 36
PictOpConjointIn = 37
PictOpConjointInReverse = 38
PictOpConjointOut = 39
PictOpConjointOutReverse = 40
PictOpConjointAtop = 41
PictOpConjointAtopReverse = 42
PictOpConjointXor = 43
PictOpMultiply = 48
PictOpScreen = 49
PictOpOverlay = 50
PictOpDarken = 51
PictOpLighten = 52
PictOpColorDodge = 53
PictOpColorBurn = 54
PictOpHardLight = 55
PictOpSoftLight = 56
PictOpDifference = 57
PictOpExclusion = 58
PictOpHSLHue = 59
PictOpHSLSaturation = 60
PictOpHSLColor = 61
PictOpHSLLuminosity = 62
)
// enum PolyEdge
const (
PolyEdgeSharp = 0
PolyEdgeSmooth = 1
)
// enum PolyMode
const (
PolyModePrecise = 0
PolyModeImprecise = 1
)
// enum CP
const (
CPRepeat = 1
CPAlphaMap = 2
CPAlphaXOrigin = 4
CPAlphaYOrigin = 8
CPClipXOrigin = 16
CPClipYOrigin = 32
CPClipMask = 64
CPGraphicsExposure = 128
CPSubwindowMode = 256
CPPolyEdge = 512
CPPolyMode = 1024
CPDither = 2048
CPComponentAlpha = 4096
)
// enum SubPixel
const (
SubPixelUnknown = 0
SubPixelHorizontalRGB = 1
SubPixelHorizontalBGR = 2
SubPixelVerticalRGB = 3
SubPixelVerticalBGR = 4
SubPixelNone = 5
)
// enum Repeat
const (
RepeatNone = 0
RepeatNormal = 1
RepeatPad = 2
RepeatReflect = 3
)
// simple ('xcb', 'Render', 'GLYPH')
type Glyph uint32
// simple ('xcb', 'Render', 'GLYPHSET')
type GlyphSet uint32
// simple ('xcb', 'Render', 'PICTURE')
type Picture uint32
// simple ('xcb', 'Render', 'PICTFORMAT')
type PictFormat uint32
// simple ('xcb', 'Render', 'FIXED')
type Fixed int32
const PictFormatErrorCode = 0
const PictureErrorCode = 1
const PictOpErrorCode = 2
const GlyphSetErrorCode = 3
const GlyphErrorCode = 4
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
const QueryPictFormatsOpcode = 1
type QueryPictFormatsCookie x.SeqNum
const QueryPictIndexValuesOpcode = 2
type QueryPictIndexValuesCookie x.SeqNum
const CreatePictureOpcode = 4
const ChangePictureOpcode = 5
const SetPictureClipRectanglesOpcode = 6
const FreePictureOpcode = 7
const CompositeOpcode = 8
const TrapezoidsOpcode = 10
const TrianglesOpcode = 11
const TriStripOpcode = 12
const TriFanOpcode = 13
const CreateGlyphSetOpcode = 17
const ReferenceGlyphSetOpcode = 18
const FreeGlyphSetOpcode = 19
const AddGlyphsOpcode = 20
const FreeGlyphsOpcode = 22
const CompositeGlyphs8Opcode = 23
const CompositeGlyphs16Opcode = 24
const CompositeGlyphs32Opcode = 25
const FillRectanglesOpcode = 26
const CreateCursorOpcode = 27
const SetPictureTransformOpcode = 28
const QueryFiltersOpcode = 29
type QueryFiltersCookie x.SeqNum
const SetPictureFilterOpcode = 30
const CreateAnimCursorOpcode = 31
const AddTrapsOpcode = 32
const CreateSolidFillOpcode = 33
const CreateLinearGradientOpcode = 34
const CreateRadialGradientOpcode = 35
const CreateConicalGradientOpcode = 36
var errorCodeNameMap = map[uint8]string{
PictFormatErrorCode: "BadPictFormat",
PictureErrorCode: "BadPicture",
PictOpErrorCode: "BadPictOp",
GlyphSetErrorCode: "BadGlyphSet",
GlyphErrorCode: "BadGlyph",
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
QueryPictFormatsOpcode: "QueryPictFormats",
QueryPictIndexValuesOpcode: "QueryPictIndexValues",
CreatePictureOpcode: "CreatePicture",
ChangePictureOpcode: "ChangePicture",
SetPictureClipRectanglesOpcode: "SetPictureClipRectangles",
FreePictureOpcode: "FreePicture",
CompositeOpcode: "Composite",
TrapezoidsOpcode: "Trapezoids",
TrianglesOpcode: "Triangles",
TriStripOpcode: "TriStrip",
TriFanOpcode: "TriFan",
CreateGlyphSetOpcode: "CreateGlyphSet",
ReferenceGlyphSetOpcode: "ReferenceGlyphSet",
FreeGlyphSetOpcode: "FreeGlyphSet",
AddGlyphsOpcode: "AddGlyphs",
FreeGlyphsOpcode: "FreeGlyphs",
CompositeGlyphs8Opcode: "CompositeGlyphs8",
CompositeGlyphs16Opcode: "CompositeGlyphs16",
CompositeGlyphs32Opcode: "CompositeGlyphs32",
FillRectanglesOpcode: "FillRectangles",
CreateCursorOpcode: "CreateCursor",
SetPictureTransformOpcode: "SetPictureTransform",
QueryFiltersOpcode: "QueryFilters",
SetPictureFilterOpcode: "SetPictureFilter",
CreateAnimCursorOpcode: "CreateAnimCursor",
AddTrapsOpcode: "AddTraps",
CreateSolidFillOpcode: "CreateSolidFill",
CreateLinearGradientOpcode: "CreateLinearGradient",
CreateRadialGradientOpcode: "CreateRadialGradient",
CreateConicalGradientOpcode: "CreateConicalGradient",
}
func init() {
_ext = x.NewExtension("RENDER", 4, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/render/render.go 0000664 0000000 0000000 00000041673 14607133730 0017706 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package render
import (
"math"
"github.com/linuxdeepin/go-x11-client"
)
const fixedOne = 1 << 16
func ToFixed(v float64) Fixed {
return Fixed(v * fixedOne)
}
func (f Fixed) ToFloat64() float64 {
return float64(f) / fixedOne
}
// #WREQ
func encodeQueryVersion(majorVersion, minorVersion uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(majorVersion).
Write4b(minorVersion).
End()
return
}
type QueryVersionReply struct {
MajorVersion, MinorVersion uint32
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read4b()
v.MinorVersion = r.Read4b() // 4
return nil
}
// #WREQ
func encodeQueryPictFormats() (b x.RequestBody) {
return
}
type QueryPictFormatsReply struct {
Formats []PictFormatInfo
Screens []PictScreen
NumDepths uint32
NumVisuals uint32
SubPixels []uint32
}
// size: 7 * 4b
type PictFormatInfo struct {
Id PictFormat
Type uint8
Depth uint8
Direct DirectFormat
Colormap x.Colormap
}
func readPictFormatInfo(r *x.Reader, v *PictFormatInfo) {
v.Id = PictFormat(r.Read4b())
v.Type = r.Read1b()
v.Depth = r.Read1b()
r.ReadPad(2) // 2
readDirectFormat(r, &v.Direct)
v.Colormap = x.Colormap(r.Read4b()) // 7
}
// size: 4 * 4b
type DirectFormat struct {
RedShift uint16
RedMask uint16
GreenShift uint16
GreenMask uint16
BlueShift uint16
BlueMask uint16
AlphaShift uint16
AlphaMask uint16
}
func readDirectFormat(r *x.Reader, v *DirectFormat) {
v.RedShift = r.Read2b()
v.RedMask = r.Read2b()
v.GreenShift = r.Read2b()
v.GreenMask = r.Read2b()
v.BlueShift = r.Read2b()
v.BlueMask = r.Read2b()
v.AlphaShift = r.Read2b()
v.AlphaMask = r.Read2b()
}
type PictScreen struct {
Fallback PictFormat
Depths []PictDepth
}
func readPictScreen(r *x.Reader, v *PictScreen) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
depthsLen := int(r.Read4b())
v.Fallback = PictFormat(r.Read4b()) // 2
if depthsLen > 0 {
v.Depths = make([]PictDepth, depthsLen)
for i := 0; i < depthsLen; i++ {
err := readPictDepth(r, &v.Depths[i])
if err != nil {
return err
}
}
}
return nil
}
type PictDepth struct {
Depth uint8
Visuals []PictVisual
}
func readPictDepth(r *x.Reader, v *PictDepth) error {
v.Depth = r.Read1b()
r.ReadPad(1)
visualsLen := int(r.Read2b())
r.ReadPad(4) // 2
if visualsLen > 0 {
if !r.RemainAtLeast4b(2 * visualsLen) {
return x.ErrDataLenShort
}
v.Visuals = make([]PictVisual, visualsLen)
for i := 0; i < visualsLen; i++ {
v.Visuals[i] = readPictVisual(r)
}
}
return nil
}
// size: 2 * 4b
type PictVisual struct {
Visual x.VisualID
Format PictFormat
}
func readPictVisual(r *x.Reader) PictVisual {
var v PictVisual
v.Visual = x.VisualID(r.Read4b())
v.Format = PictFormat(r.Read4b())
return v
}
func readQueryPictFormatsReply(r *x.Reader, v *QueryPictFormatsReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
formatsLen := int(r.Read4b())
screensLen := int(r.Read4b())
v.NumDepths = r.Read4b() // 5
v.NumVisuals = r.Read4b()
subPixelsLen := int(r.Read4b())
r.ReadPad(4) // 8
if formatsLen > 0 {
if !r.RemainAtLeast4b(7 * formatsLen) {
return x.ErrDataLenShort
}
v.Formats = make([]PictFormatInfo, formatsLen)
for i := 0; i < formatsLen; i++ {
readPictFormatInfo(r, &v.Formats[i])
}
}
if screensLen > 0 {
v.Screens = make([]PictScreen, screensLen)
for i := 0; i < screensLen; i++ {
err := readPictScreen(r, &v.Screens[i])
if err != nil {
return err
}
}
}
if subPixelsLen > 0 {
if !r.RemainAtLeast4b(subPixelsLen) {
return x.ErrDataLenShort
}
v.SubPixels = make([]uint32, subPixelsLen)
for i := 0; i < subPixelsLen; i++ {
v.SubPixels[i] = r.Read4b()
}
}
return nil
}
// #WREQ
func encodeQueryPictIndexValues(format PictFormat) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(format)).
End()
return
}
// size: 3 * 4b
type IndexValue struct {
Pixel uint32
Red uint16
Green uint16
Blue uint16
Alpha uint16
}
func readIndexValue(r *x.Reader, v *IndexValue) {
v.Pixel = r.Read4b()
v.Red = r.Read2b()
v.Green = r.Read2b()
v.Blue = r.Read2b()
v.Alpha = r.Read2b()
}
type QueryPictIndexValuesReply struct {
Values []IndexValue
}
func readQueryPictIndexValuesReply(r *x.Reader, v *QueryPictIndexValuesReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
valuesLen := int(r.Read4b())
r.ReadPad(20) // 8
if valuesLen > 0 {
if !r.RemainAtLeast4b(3 * valuesLen) {
return x.ErrDataLenShort
}
v.Values = make([]IndexValue, valuesLen)
for i := 0; i < valuesLen; i++ {
readIndexValue(r, &v.Values[i])
}
}
return nil
}
// #WREQ
func encodeQueryFilters(drawable x.Drawable) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(drawable)).
End()
return
}
type QueryFiltersReply struct {
Aliases []uint16
Filters []string
}
func readQueryFiltersReply(r *x.Reader, v *QueryFiltersReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
aliasesLen := int(r.Read4b())
filtersLen := int(r.Read4b())
r.ReadPad(16) // 8
if aliasesLen > 0 {
pad := x.Pad(2 * aliasesLen)
if !r.RemainAtLeast(2*aliasesLen + pad) {
return x.ErrDataLenShort
}
v.Aliases = make([]uint16, aliasesLen)
for i := 0; i < aliasesLen; i++ {
v.Aliases[i] = r.Read2b()
}
r.ReadPad(pad)
}
if filtersLen > 0 {
v.Filters = make([]string, filtersLen)
var err error
for i := 0; i < filtersLen; i++ {
v.Filters[i], err = x.ReadStr(r)
if err != nil {
return err
}
}
}
return nil
}
// #WREQ
func encodeCreatePicture(pid Picture, drawable x.Drawable, format PictFormat,
valueMask uint32, valueList []uint32) (b x.RequestBody) {
b0 := b.AddBlock(4 + len(valueList)).
Write4b(uint32(pid)).
Write4b(uint32(drawable)).
Write4b(uint32(format)).
Write4b(valueMask)
for _, value := range valueList {
b0.Write4b(value)
}
b0.End()
return
}
// #WREQ
func encodeChangePicture(picture Picture, valueMask uint32, valueList []uint32) (b x.RequestBody) {
b0 := b.AddBlock(2 + len(valueList)).
Write4b(uint32(picture)).
Write4b(valueMask)
for _, value := range valueList {
b0.Write4b(value)
}
b0.End()
return
}
// #WREQ
func encodeSetPictureClipRectangles(picture Picture, clipXOrigin,
clipYOrigin int16, rectangles []x.Rectangle) (b x.RequestBody) {
b0 := b.AddBlock(2 + 2*len(rectangles)).
Write4b(uint32(picture)).
Write2b(uint16(clipXOrigin)).
Write2b(uint16(clipYOrigin))
for _, rect := range rectangles {
x.WriteRectangle(b0, rect)
}
b0.End()
return
}
// size: 9 * 4b
type Transform struct {
Matrix11 Fixed
Matrix12 Fixed
Matrix13 Fixed
Matrix21 Fixed
Matrix22 Fixed
Matrix23 Fixed
Matrix31 Fixed
Matrix32 Fixed
Matrix33 Fixed
}
func WriteTransform(b *x.FixedSizeBuf, v *Transform) {
b.Write4b(uint32(v.Matrix11))
b.Write4b(uint32(v.Matrix12))
b.Write4b(uint32(v.Matrix13))
b.Write4b(uint32(v.Matrix21))
b.Write4b(uint32(v.Matrix22))
b.Write4b(uint32(v.Matrix23))
b.Write4b(uint32(v.Matrix31))
b.Write4b(uint32(v.Matrix32))
b.Write4b(uint32(v.Matrix33))
}
func ReadTransform(r *x.Reader, v *Transform) {
v.Matrix11 = Fixed(r.Read4b())
v.Matrix12 = Fixed(r.Read4b())
v.Matrix13 = Fixed(r.Read4b())
v.Matrix21 = Fixed(r.Read4b())
v.Matrix22 = Fixed(r.Read4b())
v.Matrix23 = Fixed(r.Read4b())
v.Matrix31 = Fixed(r.Read4b())
v.Matrix32 = Fixed(r.Read4b())
v.Matrix33 = Fixed(r.Read4b())
}
// #WREQ
func encodeSetPictureTransform(picture Picture, transform *Transform) (b x.RequestBody) {
b0 := b.AddBlock(10).
Write4b(uint32(picture))
WriteTransform(b0, transform)
b0.End()
return
}
// #WREQ
func encodeSetPictureFilter(picture Picture, filter string, values []Fixed) (b x.RequestBody) {
filter = x.TruncateStr(filter, math.MaxUint16)
filterLen := len(filter)
b0 := b.AddBlock(2 + x.SizeIn4bWithPad(filterLen) + len(values)).
Write4b(uint32(picture)).
Write2b(uint16(filterLen)).
WritePad(2).
WriteString(filter).
WritePad(x.Pad(filterLen))
for _, value := range values {
b0.Write4b(uint32(value))
}
b0.End()
return
}
// #WREQ
func encodeFreePicture(picture Picture) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(picture)).
End()
return
}
// #WREQ
func encodeComposite(op uint8, src, mask, dst Picture, srcX, srcY,
maskX, maskY, dstX, dstY int16, width, height uint16) (b x.RequestBody) {
b.AddBlock(8).
Write1b(op).
WritePad(3).
Write4b(uint32(src)).
Write4b(uint32(mask)).
Write4b(uint32(dst)).
Write2b(uint16(srcX)).
Write2b(uint16(srcY)).
Write2b(uint16(maskX)).
Write2b(uint16(maskY)).
Write2b(uint16(dstX)).
Write2b(uint16(dstY)).
Write2b(width).
Write2b(height).
End()
return
}
// size: 2 * 4b
type Color struct {
Red, Green, Blue, Alpha uint16
}
func writeColor(b *x.FixedSizeBuf, v Color) {
b.Write2b(v.Red)
b.Write2b(v.Green)
b.Write2b(v.Blue)
b.Write2b(v.Alpha)
}
// #WREQ
func encodeFillRectangles(op uint8, dst Picture, color Color,
rects []x.Rectangle) (b x.RequestBody) {
b0 := b.AddBlock(4 + 2*len(rects)).
Write1b(op).
WritePad(3).
Write4b(uint32(dst))
writeColor(b0, color)
for _, rect := range rects {
x.WriteRectangle(b0, rect)
}
b0.End()
return
}
// size: 10 * 4b
type Trapezoid struct {
Top Fixed
Bottom Fixed
Left LineFixed
Right LineFixed
}
func writeTrapezoid(b *x.FixedSizeBuf, v *Trapezoid) {
b.Write4b(uint32(v.Top))
b.Write4b(uint32(v.Bottom))
writeLineFixed(b, v.Left)
writeLineFixed(b, v.Right)
}
// size: 4 * 4b
type LineFixed struct {
P1 PointFixed
P2 PointFixed
}
func writeLineFixed(b *x.FixedSizeBuf, v LineFixed) {
writePointFixed(b, v.P1)
writePointFixed(b, v.P2)
}
// size: 2 * 4b
type PointFixed struct {
X Fixed
Y Fixed
}
func writePointFixed(b *x.FixedSizeBuf, v PointFixed) {
b.Write4b(uint32(v.X))
b.Write4b(uint32(v.Y))
}
// #WREQ
func encodeTrapezoids(op uint8, src, dst Picture, maskFormat PictFormat,
srcX, srcY int16, traps []Trapezoid) (b x.RequestBody) {
b0 := b.AddBlock(5 + 10*len(traps)).
Write1b(op).
WritePad(3).
Write4b(uint32(src)).
Write4b(uint32(dst)).
Write4b(uint32(maskFormat)).
Write2b(uint16(srcX)).
Write2b(uint16(srcY))
for _, trap := range traps {
writeTrapezoid(b0, &trap)
}
b0.End()
return
}
// size: 6 * 4b
type Triangle struct {
P1 PointFixed
P2 PointFixed
P3 PointFixed
}
func writeTriangle(b *x.FixedSizeBuf, v Triangle) {
writePointFixed(b, v.P1)
writePointFixed(b, v.P2)
writePointFixed(b, v.P3)
}
// #WREQ
func encodeTriangles(op uint8, src, dst Picture, maskFormat PictFormat,
srcX, srcY int16, triangles []Triangle) (b x.RequestBody) {
b0 := b.AddBlock(5 + 6*len(triangles)).
Write1b(op).
WritePad(3).
Write4b(uint32(src)).
Write4b(uint32(dst)).
Write4b(uint32(maskFormat)).
Write2b(uint16(srcX)).
Write2b(uint16(srcY))
for _, triangle := range triangles {
writeTriangle(b0, triangle)
}
b0.End()
return
}
// #WREQ
func encodeTriStrip(op uint8, src, dst Picture, maskFormat PictFormat,
srcX, srcY int16, points []PointFixed) (b x.RequestBody) {
b0 := b.AddBlock(5 + len(points)*2).
Write1b(op).
WritePad(3).
Write4b(uint32(src)).
Write4b(uint32(dst)).
Write4b(uint32(maskFormat)).
Write2b(uint16(srcX)).
Write2b(uint16(srcY))
for _, p := range points {
writePointFixed(b0, p)
}
b0.End()
return
}
// #WREQ
func encodeTriFan(op uint8, src, dst Picture, maskFormat PictFormat,
srcX, srcY int16, points []PointFixed) (b x.RequestBody) {
b0 := b.AddBlock(5 + len(points)*2).
Write1b(op).
WritePad(3).
Write4b(uint32(src)).
Write4b(uint32(dst)).
Write4b(uint32(maskFormat)).
Write2b(uint16(srcX)).
Write2b(uint16(srcY))
for _, p := range points {
writePointFixed(b0, p)
}
b0.End()
return
}
// #WREQ
func encodeCreateGlyphSet(gsId GlyphSet, format PictFormat) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(gsId)).
Write4b(uint32(format)).
End()
return
}
// #WREQ
func encodeReferenceGlyphSet(gsId, existing GlyphSet) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(gsId)).
Write4b(uint32(existing)).
End()
return
}
// #WREQ
func encodeFreeGlyphSet(glyphSet GlyphSet) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(glyphSet)).
End()
return
}
// size: 3 * 4b
type GlyphInfo struct {
Width uint16
Height uint16
X int16
Y int16
XOff int16
YOff int16
}
func writeGlyphInfo(b *x.FixedSizeBuf, v GlyphInfo) {
b.Write2b(v.Width)
b.Write2b(v.Height)
b.Write2b(uint16(v.X))
b.Write2b(uint16(v.Y))
b.Write2b(uint16(v.XOff))
b.Write2b(uint16(v.YOff))
}
// #WREQ
func encodeAddGlyphs(glyphSet GlyphSet, glyphIds []uint32, glyphs []GlyphInfo,
data []byte) (b x.RequestBody) {
b0 := b.AddBlock(2 + len(glyphs)*3).
Write4b(uint32(glyphSet)).
Write4b(uint32(len(glyphIds)))
for _, gi := range glyphs {
writeGlyphInfo(b0, gi)
}
b0.End()
b.AddBytes(data)
return
}
// #WREQ
func encodeFreeGlyphs(glyphSet GlyphSet, glyphs []Glyph) (b x.RequestBody) {
b0 := b.AddBlock(1 + len(glyphs)).
Write4b(uint32(glyphSet))
for _, g := range glyphs {
b0.Write4b(uint32(g))
}
b0.End()
return
}
func encodeCompositeGlyphsN(op uint8, src, dst Picture, maskFormat PictFormat,
glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) (b x.RequestBody) {
b.AddBlock(6).
Write1b(op).
WritePad(3).
Write4b(uint32(src)).
Write4b(uint32(dst)).
Write4b(uint32(maskFormat)).
Write4b(uint32(glyphSet)).
Write2b(uint16(srcX)).
Write2b(uint16(srcY)).
End()
b.AddBytes(glyphCmds)
return
}
// #WREQ
func encodeCompositeGlyphs8(op uint8, src, dst Picture, maskFormat PictFormat,
glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) (b x.RequestBody) {
return encodeCompositeGlyphsN(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
}
// #WREQ
func encodeCompositeGlyphs16(op uint8, src, dst Picture, maskFormat PictFormat,
glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) (b x.RequestBody) {
return encodeCompositeGlyphsN(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
}
// #WREQ
func encodeCompositeGlyphs32(op uint8, src, dst Picture, maskFormat PictFormat,
glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) (b x.RequestBody) {
return encodeCompositeGlyphsN(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
}
// #WREQ
func encodeCreateCursor(cid x.Cursor, source Picture, X, y uint16) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(cid)).
Write4b(uint32(source)).
Write2b(X).
Write2b(y).
End()
return
}
// size: 2 * 4b
type AnimCursorElt struct {
Cursor x.Cursor
Delay uint32
}
func writeAnimCursorElt(b *x.FixedSizeBuf, v AnimCursorElt) {
b.Write4b(uint32(v.Cursor))
b.Write4b(v.Delay)
}
// #WREQ
func encodeCreateAnimCursor(cid x.Cursor, cursors []AnimCursorElt) (b x.RequestBody) {
b0 := b.AddBlock(1 + len(cursors)*2).
Write4b(uint32(cid))
for _, c := range cursors {
writeAnimCursorElt(b0, c)
}
b0.End()
return
}
// size: 3 * 4b
type SpanFixed struct {
L, R, Y Fixed
}
// size: 6 * 4b
type Trap struct {
Top SpanFixed
Bot SpanFixed
}
func writeSpanFixed(b *x.FixedSizeBuf, v SpanFixed) {
b.Write4b(uint32(v.L))
b.Write4b(uint32(v.R))
b.Write4b(uint32(v.Y))
}
func writeTrap(b *x.FixedSizeBuf, v *Trap) {
writeSpanFixed(b, v.Top)
writeSpanFixed(b, v.Bot)
}
// #WREQ
func encodeAddTraps(picture Picture, xOff, yOff int16, traps []Trap) (b x.RequestBody) {
b0 := b.AddBlock(2 + len(traps)*6).
Write4b(uint32(picture)).
Write2b(uint16(xOff)).
Write2b(uint16(yOff))
for _, trap := range traps {
writeTrap(b0, &trap)
}
b0.End()
return
}
// #WREQ
func encodeCreateSolidFill(pid Picture, color Color) (b x.RequestBody) {
b0 := b.AddBlock(3).
Write4b(uint32(pid))
writeColor(b0, color)
b0.End()
return
}
// #WREQ
func encodeCreateLinearGradient(picture Picture, p1, p2 PointFixed,
stops []Fixed, colors []Color) (b x.RequestBody) {
b0 := b.AddBlock(6 + len(stops) + 2*len(colors)).
Write4b(uint32(picture))
writePointFixed(b0, p1)
writePointFixed(b0, p2)
b0.Write4b(uint32(len(stops)))
for _, s := range stops {
b0.Write4b(uint32(s))
}
for _, c := range colors {
writeColor(b0, c)
}
b0.End()
return
}
// #WREQ
func encodeCreateRadialGradient(picture Picture, inner, outer PointFixed,
innerRadius, outerRadius Fixed, stops []Fixed, colors []Color) (b x.RequestBody) {
b0 := b.AddBlock(8 + len(stops) + 2*len(colors)).
Write4b(uint32(picture))
writePointFixed(b0, inner)
writePointFixed(b0, outer)
b0.Write4b(uint32(innerRadius)).
Write4b(uint32(outerRadius)).
Write4b(uint32(len(stops)))
for _, s := range stops {
b0.Write4b(uint32(s))
}
for _, c := range colors {
writeColor(b0, c)
}
b0.End()
return
}
// #WREQ
func encodeCreateConicalGradient(picture Picture, center PointFixed,
angle Fixed, stops []Fixed, colors []Color) (b x.RequestBody) {
b0 := b.AddBlock(4 + len(stops) + 2*len(colors)).
Write4b(uint32(picture))
writePointFixed(b0, center)
b0.Write4b(uint32(angle))
for _, s := range stops {
b0.Write4b(uint32(s))
}
for _, c := range colors {
writeColor(b0, c)
}
b0.End()
return
}
go-x11-client-1.0.2/ext/render/render_req_auto.go 0000664 0000000 0000000 00000054576 14607133730 0021613 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package render
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, majorVersion, minorVersion uint32) QueryVersionCookie {
body := encodeQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func QueryPictFormats(conn *x.Conn) QueryPictFormatsCookie {
body := encodeQueryPictFormats()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryPictFormatsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryPictFormatsCookie(seq)
}
func (cookie QueryPictFormatsCookie) Reply(conn *x.Conn) (*QueryPictFormatsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryPictFormatsReply
err = readQueryPictFormatsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func QueryPictIndexValues(conn *x.Conn, format PictFormat) QueryPictIndexValuesCookie {
body := encodeQueryPictIndexValues(format)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryPictIndexValuesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryPictIndexValuesCookie(seq)
}
func (cookie QueryPictIndexValuesCookie) Reply(conn *x.Conn) (*QueryPictIndexValuesReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryPictIndexValuesReply
err = readQueryPictIndexValuesReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func QueryFilters(conn *x.Conn, drawable x.Drawable) QueryFiltersCookie {
body := encodeQueryFilters(drawable)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryFiltersOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryFiltersCookie(seq)
}
func (cookie QueryFiltersCookie) Reply(conn *x.Conn) (*QueryFiltersReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryFiltersReply
err = readQueryFiltersReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CreatePicture(conn *x.Conn, pid Picture, drawable x.Drawable, format PictFormat, valueMask uint32, valueList []uint32) {
body := encodeCreatePicture(pid, drawable, format, valueMask, valueList)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePictureOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreatePictureChecked(conn *x.Conn, pid Picture, drawable x.Drawable, format PictFormat, valueMask uint32, valueList []uint32) x.VoidCookie {
body := encodeCreatePicture(pid, drawable, format, valueMask, valueList)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePictureOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ChangePicture(conn *x.Conn, picture Picture, valueMask uint32, valueList []uint32) {
body := encodeChangePicture(picture, valueMask, valueList)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangePictureOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ChangePictureChecked(conn *x.Conn, picture Picture, valueMask uint32, valueList []uint32) x.VoidCookie {
body := encodeChangePicture(picture, valueMask, valueList)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangePictureOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetPictureClipRectangles(conn *x.Conn, picture Picture, clipXOrigin, clipYOrigin int16, rectangles []x.Rectangle) {
body := encodeSetPictureClipRectangles(picture, clipXOrigin, clipYOrigin, rectangles)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetPictureClipRectanglesOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetPictureClipRectanglesChecked(conn *x.Conn, picture Picture, clipXOrigin, clipYOrigin int16, rectangles []x.Rectangle) x.VoidCookie {
body := encodeSetPictureClipRectangles(picture, clipXOrigin, clipYOrigin, rectangles)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetPictureClipRectanglesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetPictureTransform(conn *x.Conn, picture Picture, transform *Transform) {
body := encodeSetPictureTransform(picture, transform)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetPictureTransformOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetPictureTransformChecked(conn *x.Conn, picture Picture, transform *Transform) x.VoidCookie {
body := encodeSetPictureTransform(picture, transform)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetPictureTransformOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetPictureFilter(conn *x.Conn, picture Picture, filter string, values []Fixed) {
body := encodeSetPictureFilter(picture, filter, values)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetPictureFilterOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetPictureFilterChecked(conn *x.Conn, picture Picture, filter string, values []Fixed) x.VoidCookie {
body := encodeSetPictureFilter(picture, filter, values)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetPictureFilterOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func FreePicture(conn *x.Conn, picture Picture) {
body := encodeFreePicture(picture)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreePictureOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func FreePictureChecked(conn *x.Conn, picture Picture) x.VoidCookie {
body := encodeFreePicture(picture)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreePictureOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Composite(conn *x.Conn, op uint8, src, mask, dst Picture, srcX, srcY, maskX, maskY, dstX, dstY int16, width, height uint16) {
body := encodeComposite(op, src, mask, dst, srcX, srcY, maskX, maskY, dstX, dstY, width, height)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CompositeChecked(conn *x.Conn, op uint8, src, mask, dst Picture, srcX, srcY, maskX, maskY, dstX, dstY int16, width, height uint16) x.VoidCookie {
body := encodeComposite(op, src, mask, dst, srcX, srcY, maskX, maskY, dstX, dstY, width, height)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func FillRectangles(conn *x.Conn, op uint8, dst Picture, color Color, rects []x.Rectangle) {
body := encodeFillRectangles(op, dst, color, rects)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FillRectanglesOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func FillRectanglesChecked(conn *x.Conn, op uint8, dst Picture, color Color, rects []x.Rectangle) x.VoidCookie {
body := encodeFillRectangles(op, dst, color, rects)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FillRectanglesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Trapezoids(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, traps []Trapezoid) {
body := encodeTrapezoids(op, src, dst, maskFormat, srcX, srcY, traps)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TrapezoidsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func TrapezoidsChecked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, traps []Trapezoid) x.VoidCookie {
body := encodeTrapezoids(op, src, dst, maskFormat, srcX, srcY, traps)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TrapezoidsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Triangles(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, triangles []Triangle) {
body := encodeTriangles(op, src, dst, maskFormat, srcX, srcY, triangles)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TrianglesOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func TrianglesChecked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, triangles []Triangle) x.VoidCookie {
body := encodeTriangles(op, src, dst, maskFormat, srcX, srcY, triangles)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TrianglesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func TriStrip(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, points []PointFixed) {
body := encodeTriStrip(op, src, dst, maskFormat, srcX, srcY, points)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TriStripOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func TriStripChecked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, points []PointFixed) x.VoidCookie {
body := encodeTriStrip(op, src, dst, maskFormat, srcX, srcY, points)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TriStripOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func TriFan(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, points []PointFixed) {
body := encodeTriFan(op, src, dst, maskFormat, srcX, srcY, points)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TriFanOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func TriFanChecked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, srcX, srcY int16, points []PointFixed) x.VoidCookie {
body := encodeTriFan(op, src, dst, maskFormat, srcX, srcY, points)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TriFanOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateGlyphSet(conn *x.Conn, gsId GlyphSet, format PictFormat) {
body := encodeCreateGlyphSet(gsId, format)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateGlyphSetOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateGlyphSetChecked(conn *x.Conn, gsId GlyphSet, format PictFormat) x.VoidCookie {
body := encodeCreateGlyphSet(gsId, format)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateGlyphSetOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ReferenceGlyphSet(conn *x.Conn, gsId, existing GlyphSet) {
body := encodeReferenceGlyphSet(gsId, existing)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ReferenceGlyphSetOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ReferenceGlyphSetChecked(conn *x.Conn, gsId, existing GlyphSet) x.VoidCookie {
body := encodeReferenceGlyphSet(gsId, existing)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ReferenceGlyphSetOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func FreeGlyphSet(conn *x.Conn, glyphSet GlyphSet) {
body := encodeFreeGlyphSet(glyphSet)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreeGlyphSetOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func FreeGlyphSetChecked(conn *x.Conn, glyphSet GlyphSet) x.VoidCookie {
body := encodeFreeGlyphSet(glyphSet)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreeGlyphSetOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func AddGlyphs(conn *x.Conn, glyphSet GlyphSet, glyphIds []uint32, glyphs []GlyphInfo, data []byte) {
body := encodeAddGlyphs(glyphSet, glyphIds, glyphs, data)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AddGlyphsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func AddGlyphsChecked(conn *x.Conn, glyphSet GlyphSet, glyphIds []uint32, glyphs []GlyphInfo, data []byte) x.VoidCookie {
body := encodeAddGlyphs(glyphSet, glyphIds, glyphs, data)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AddGlyphsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func FreeGlyphs(conn *x.Conn, glyphSet GlyphSet, glyphs []Glyph) {
body := encodeFreeGlyphs(glyphSet, glyphs)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreeGlyphsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func FreeGlyphsChecked(conn *x.Conn, glyphSet GlyphSet, glyphs []Glyph) x.VoidCookie {
body := encodeFreeGlyphs(glyphSet, glyphs)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FreeGlyphsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CompositeGlyphs8(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) {
body := encodeCompositeGlyphs8(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeGlyphs8Opcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CompositeGlyphs8Checked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) x.VoidCookie {
body := encodeCompositeGlyphs8(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeGlyphs8Opcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CompositeGlyphs16(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) {
body := encodeCompositeGlyphs16(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeGlyphs16Opcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CompositeGlyphs16Checked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) x.VoidCookie {
body := encodeCompositeGlyphs16(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeGlyphs16Opcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CompositeGlyphs32(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) {
body := encodeCompositeGlyphs32(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeGlyphs32Opcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CompositeGlyphs32Checked(conn *x.Conn, op uint8, src, dst Picture, maskFormat PictFormat, glyphSet GlyphSet, srcX, srcY int16, glyphCmds []byte) x.VoidCookie {
body := encodeCompositeGlyphs32(op, src, dst, maskFormat, glyphSet, srcX, srcY, glyphCmds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CompositeGlyphs32Opcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateCursor(conn *x.Conn, cid x.Cursor, source Picture, X, y uint16) {
body := encodeCreateCursor(cid, source, X, y)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateCursorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateCursorChecked(conn *x.Conn, cid x.Cursor, source Picture, X, y uint16) x.VoidCookie {
body := encodeCreateCursor(cid, source, X, y)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateAnimCursor(conn *x.Conn, cid x.Cursor, cursors []AnimCursorElt) {
body := encodeCreateAnimCursor(cid, cursors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateAnimCursorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateAnimCursorChecked(conn *x.Conn, cid x.Cursor, cursors []AnimCursorElt) x.VoidCookie {
body := encodeCreateAnimCursor(cid, cursors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateAnimCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func AddTraps(conn *x.Conn, picture Picture, xOff, yOff int16, traps []Trap) {
body := encodeAddTraps(picture, xOff, yOff, traps)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AddTrapsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func AddTrapsChecked(conn *x.Conn, picture Picture, xOff, yOff int16, traps []Trap) x.VoidCookie {
body := encodeAddTraps(picture, xOff, yOff, traps)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AddTrapsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateSolidFill(conn *x.Conn, pid Picture, color Color) {
body := encodeCreateSolidFill(pid, color)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateSolidFillOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateSolidFillChecked(conn *x.Conn, pid Picture, color Color) x.VoidCookie {
body := encodeCreateSolidFill(pid, color)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateSolidFillOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateLinearGradient(conn *x.Conn, picture Picture, p1, p2 PointFixed, stops []Fixed, colors []Color) {
body := encodeCreateLinearGradient(picture, p1, p2, stops, colors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateLinearGradientOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateLinearGradientChecked(conn *x.Conn, picture Picture, p1, p2 PointFixed, stops []Fixed, colors []Color) x.VoidCookie {
body := encodeCreateLinearGradient(picture, p1, p2, stops, colors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateLinearGradientOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateRadialGradient(conn *x.Conn, picture Picture, inner, outer PointFixed, innerRadius, outerRadius Fixed, stops []Fixed, colors []Color) {
body := encodeCreateRadialGradient(picture, inner, outer, innerRadius, outerRadius, stops, colors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRadialGradientOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateRadialGradientChecked(conn *x.Conn, picture Picture, inner, outer PointFixed, innerRadius, outerRadius Fixed, stops []Fixed, colors []Color) x.VoidCookie {
body := encodeCreateRadialGradient(picture, inner, outer, innerRadius, outerRadius, stops, colors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRadialGradientOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateConicalGradient(conn *x.Conn, picture Picture, center PointFixed, angle Fixed, stops []Fixed, colors []Color) {
body := encodeCreateConicalGradient(picture, center, angle, stops, colors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateConicalGradientOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateConicalGradientChecked(conn *x.Conn, picture Picture, center PointFixed, angle Fixed, stops []Fixed, colors []Color) x.VoidCookie {
body := encodeCreateConicalGradient(picture, center, angle, stops, colors)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateConicalGradientOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/screensaver/ 0000775 0000000 0000000 00000000000 14607133730 0017126 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/screensaver/auto.go 0000664 0000000 0000000 00000002603 14607133730 0020426 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package screensaver
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: ScreenSaver
const MajorVersion = 1
const MinorVersion = 1
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// enum Kind
const (
KindBlanked = 0
KindInternal = 1
KindExternal = 2
)
// enum Event
const (
EventNotifyMask = 1
EventCycleMask = 2
)
// enum State
const (
StateOff = 0
StateOn = 1
StateCycle = 2
StateDisabled = 3
)
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
const QueryInfoOpcode = 1
type QueryInfoCookie x.SeqNum
const SelectInputOpcode = 2
const SetAttributesOpcode = 3
const UnsetAttributesOpcode = 4
const SuspendOpcode = 5
const NotifyEventCode = 0
func NewNotifyEvent(data []byte) (*NotifyEvent, error) {
var ev NotifyEvent
r := x.NewReaderFromData(data)
err := readNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
QueryInfoOpcode: "QueryInfo",
SelectInputOpcode: "SelectInput",
SetAttributesOpcode: "SetAttributes",
UnsetAttributesOpcode: "UnsetAttributes",
SuspendOpcode: "Suspend",
}
func init() {
_ext = x.NewExtension("MIT-SCREEN-SAVER", 0, nil, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/screensaver/screensaver.go 0000664 0000000 0000000 00000005434 14607133730 0022003 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package screensaver
import "github.com/linuxdeepin/go-x11-client"
type NotifyEvent struct {
State uint8
Sequence uint16
Time x.Timestamp
Root x.Window
Window x.Window
Kind uint8
Forced bool
}
func readNotifyEvent(r *x.Reader, v *NotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
v.State, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.Root = x.Window(r.Read4b())
v.Window = x.Window(r.Read4b())
v.Kind = r.Read1b()
v.Forced = r.ReadBool() // 5
return nil
}
// #WREQ
func encodeQueryVersion(clientMajorVersion, clientMinorVersion uint8) (b x.RequestBody) {
b.AddBlock(1).
Write1b(clientMajorVersion).
Write1b(clientMinorVersion).
WritePad(2).
End()
return
}
type QueryVersionReply struct {
ServerMajorVersion uint16
ServerMinorVersion uint16
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.ServerMajorVersion = r.Read2b()
v.ServerMinorVersion = r.Read2b() // 3
return nil
}
// #WREQ
func encodeQueryInfo(drawable x.Drawable) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(drawable)).
End()
return
}
type QueryInfoReply struct {
State uint8
SaverWindow x.Window
MsUntilServer uint32
MsSinceUserInput uint32
EventMask uint32
Kind uint8
}
func readQueryInfoReply(r *x.Reader, v *QueryInfoReply) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
v.State, _ = r.ReadReplyHeader()
v.SaverWindow = x.Window(r.Read4b())
v.MsUntilServer = r.Read4b()
v.MsSinceUserInput = r.Read4b()
v.EventMask = r.Read4b() // 6
v.Kind = r.Read1b() // 7
return nil
}
// #WREQ
func encodeSelectInput(drawable x.Drawable, eventMask uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(drawable)).
Write4b(eventMask).
End()
return
}
// #WREQ
func encodeSetAttributes(drawable x.Drawable, X, y int16, width, height,
boardWidth uint16, class, depth uint8, visual x.VisualID, valueMask uint32,
valueList []uint32) (b x.RequestBody) {
b0 := b.AddBlock(6 + len(valueList)).
Write4b(uint32(drawable)).
Write2b(uint16(X)).
Write2b(uint16(y)).
Write2b(width).
Write2b(height).
Write2b(boardWidth).
Write1b(class).
Write1b(depth).
Write4b(uint32(visual)).
Write4b(valueMask)
for _, value := range valueList {
b0.Write4b(value)
}
b0.End()
return
}
// #WREQ
func encodeUnsetAttributes(drawable x.Drawable) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(drawable)).
End()
return
}
// #WREQ
func encodeSuspend(suspend bool) (b x.RequestBody) {
b.AddBlock(1).
WriteBool(suspend).
WritePad(3).
End()
return
}
go-x11-client-1.0.2/ext/screensaver/screensaver_req_auto.go 0000664 0000000 0000000 00000010346 14607133730 0023700 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package screensaver
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, clientMajorVersion, clientMinorVersion uint8) QueryVersionCookie {
body := encodeQueryVersion(clientMajorVersion, clientMinorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func QueryInfo(conn *x.Conn, drawable x.Drawable) QueryInfoCookie {
body := encodeQueryInfo(drawable)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryInfoCookie(seq)
}
func (cookie QueryInfoCookie) Reply(conn *x.Conn) (*QueryInfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryInfoReply
err = readQueryInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SelectInput(conn *x.Conn, drawable x.Drawable, eventMask uint32) {
body := encodeSelectInput(drawable, eventMask)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectInputOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SelectInputChecked(conn *x.Conn, drawable x.Drawable, eventMask uint32) x.VoidCookie {
body := encodeSelectInput(drawable, eventMask)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectInputOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetAttributes(conn *x.Conn, drawable x.Drawable, X, y int16, width, height, boardWidth uint16, class, depth uint8, visual x.VisualID, valueMask uint32, valueList []uint32) {
body := encodeSetAttributes(drawable, X, y, width, height, boardWidth, class, depth, visual, valueMask, valueList)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetAttributesOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetAttributesChecked(conn *x.Conn, drawable x.Drawable, X, y int16, width, height, boardWidth uint16, class, depth uint8, visual x.VisualID, valueMask uint32, valueList []uint32) x.VoidCookie {
body := encodeSetAttributes(drawable, X, y, width, height, boardWidth, class, depth, visual, valueMask, valueList)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetAttributesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func UnsetAttributes(conn *x.Conn, drawable x.Drawable) {
body := encodeUnsetAttributes(drawable)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnsetAttributesOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func UnsetAttributesChecked(conn *x.Conn, drawable x.Drawable) x.VoidCookie {
body := encodeUnsetAttributes(drawable)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnsetAttributesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Suspend(conn *x.Conn, suspend bool) {
body := encodeSuspend(suspend)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SuspendOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SuspendChecked(conn *x.Conn, suspend bool) x.VoidCookie {
body := encodeSuspend(suspend)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SuspendOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/shm/ 0000775 0000000 0000000 00000000000 14607133730 0015375 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/shm/auto.go 0000664 0000000 0000000 00000002640 14607133730 0016676 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package shm
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Shm
const MajorVersion = 1
const MinorVersion = 2
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// simple ('xcb', 'Shm', 'SEG')
type Seg uint32
const CompletionEventCode = 0
func NewCompletionEvent(data []byte) (*CompletionEvent, error) {
var ev CompletionEvent
r := x.NewReaderFromData(data)
err := readCompletionEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const BadSegErrorCode = 0
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
const AttachOpcode = 1
const DetachOpcode = 2
const PutImageOpcode = 3
const GetImageOpcode = 4
type GetImageCookie x.SeqNum
const CreatePixmapOpcode = 5
const AttachFdOpcode = 6
const CreateSegmentOpcode = 7
type CreateSegmentCookie x.SeqNum
var errorCodeNameMap = map[uint8]string{
BadSegErrorCode: "BadSeg",
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
AttachOpcode: "Attach",
DetachOpcode: "Detach",
PutImageOpcode: "PutImage",
GetImageOpcode: "GetImage",
CreatePixmapOpcode: "CreatePixmap",
AttachFdOpcode: "AttachFd",
CreateSegmentOpcode: "CreateSegment",
}
func init() {
_ext = x.NewExtension("MIT-SHM", 0, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/shm/shm.go 0000664 0000000 0000000 00000005723 14607133730 0016522 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package shm
import "github.com/linuxdeepin/go-x11-client"
type CompletionEvent struct {
Sequence uint16
}
func readCompletionEvent(r *x.Reader, v *CompletionEvent) error {
if !r.RemainAtLeast4b(1) {
return x.ErrDataLenShort
}
_, v.Sequence = r.ReadEventHeader()
return nil
}
// #WREQ
func encodeQueryVersion() (b x.RequestBody) {
return
}
type QueryVersionReply struct {
SharedPixmaps bool
MajorVersion uint16
MinorVersion uint16
Uid uint16
Gid uint16
PixmapFormat uint8
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
sharedPixmaps, _ := r.ReadReplyHeader()
v.SharedPixmaps = x.Uint8ToBool(sharedPixmaps)
v.MajorVersion = r.Read2b()
v.MinorVersion = r.Read2b()
v.Uid = r.Read2b()
v.Gid = r.Read2b()
v.PixmapFormat = r.Read1b() // 5
return nil
}
// #WREQ
func encodeAttach(shmSeg Seg, shmId uint32, readOnly bool) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(shmSeg)).
Write4b(shmId).
WriteBool(readOnly).
WritePad(3).
End()
return
}
// #WREQ
func encodeDetach(shmSeg Seg) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(shmSeg)).
End()
return
}
// #WREQ
func encodePutImage(drawable x.Drawable, gc x.GContext, totalWidth,
totalHeight, srcX, srcY, srcWidth, srcHeight uint16, dstX, dstY int16,
depth, format uint8, sendEvent bool, shmSeg Seg, offset uint32) (b x.RequestBody) {
b.AddBlock(9).
Write4b(uint32(drawable)).
Write4b(uint32(gc)).
Write2b(totalWidth).
Write2b(totalHeight).
Write2b(srcX).
Write2b(srcY).
Write2b(srcWidth).
Write2b(srcHeight).
Write2b(uint16(dstX)).
Write2b(uint16(dstY)).
Write1b(depth).
Write1b(format).
WriteBool(sendEvent).
WritePad(1).
Write4b(uint32(shmSeg)).
Write4b(offset).
End()
return
}
// #WREQ
func encodeGetImage(drawable x.Drawable, X, y int16, width, height uint16,
planeMask uint32, format uint8, shmSeg Seg, offset uint32) (b x.RequestBody) {
b.AddBlock(7).
Write4b(uint32(drawable)).
Write2b(uint16(X)).
Write2b(uint16(y)).
Write2b(width).
Write2b(height).
Write4b(planeMask).
Write1b(format).
WritePad(3).
Write4b(uint32(shmSeg)).
Write4b(offset).
End()
return
}
type GetImageReply struct {
Depth uint8
Visual x.VisualID
Size uint32
}
func readGetImageReply(r *x.Reader, v *GetImageReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
v.Depth, _ = r.ReadReplyHeader()
v.Visual = x.VisualID(r.Read4b())
v.Size = r.Read4b() // 4
return nil
}
// #WREQ
func encodeCreatePixmap(pid x.Pixmap, drawable x.Drawable,
width, height uint16, depth uint8, shmSeg Seg, offset uint32) (b x.RequestBody) {
b.AddBlock(6).
Write4b(uint32(pid)).
Write4b(uint32(drawable)).
Write2b(width).
Write2b(height).
Write1b(depth).
WritePad(3).
Write4b(uint32(shmSeg)).
Write4b(offset).
End()
return
}
go-x11-client-1.0.2/ext/shm/shm_req_auto.go 0000664 0000000 0000000 00000011122 14607133730 0020407 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package shm
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn) QueryVersionCookie {
body := encodeQueryVersion()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func Attach(conn *x.Conn, shmSeg Seg, shmId uint32, readOnly bool) {
body := encodeAttach(shmSeg, shmId, readOnly)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AttachOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func AttachChecked(conn *x.Conn, shmSeg Seg, shmId uint32, readOnly bool) x.VoidCookie {
body := encodeAttach(shmSeg, shmId, readOnly)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AttachOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Detach(conn *x.Conn, shmSeg Seg) {
body := encodeDetach(shmSeg)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DetachOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DetachChecked(conn *x.Conn, shmSeg Seg) x.VoidCookie {
body := encodeDetach(shmSeg)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DetachOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func PutImage(conn *x.Conn, drawable x.Drawable, gc x.GContext, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight uint16, dstX, dstY int16, depth, format uint8, sendEvent bool, shmSeg Seg, offset uint32) {
body := encodePutImage(drawable, gc, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight, dstX, dstY, depth, format, sendEvent, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: PutImageOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func PutImageChecked(conn *x.Conn, drawable x.Drawable, gc x.GContext, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight uint16, dstX, dstY int16, depth, format uint8, sendEvent bool, shmSeg Seg, offset uint32) x.VoidCookie {
body := encodePutImage(drawable, gc, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight, dstX, dstY, depth, format, sendEvent, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: PutImageOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetImage(conn *x.Conn, drawable x.Drawable, X, y int16, width, height uint16, planeMask uint32, format uint8, shmSeg Seg, offset uint32) GetImageCookie {
body := encodeGetImage(drawable, X, y, width, height, planeMask, format, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetImageOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetImageCookie(seq)
}
func (cookie GetImageCookie) Reply(conn *x.Conn) (*GetImageReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetImageReply
err = readGetImageReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CreatePixmap(conn *x.Conn, pid x.Pixmap, drawable x.Drawable, width, height uint16, depth uint8, shmSeg Seg, offset uint32) {
body := encodeCreatePixmap(pid, drawable, width, height, depth, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePixmapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreatePixmapChecked(conn *x.Conn, pid x.Pixmap, drawable x.Drawable, width, height uint16, depth uint8, shmSeg Seg, offset uint32) x.VoidCookie {
body := encodeCreatePixmap(pid, drawable, width, height, depth, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePixmapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/test/ 0000775 0000000 0000000 00000000000 14607133730 0015565 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/test/auto.go 0000664 0000000 0000000 00000001503 14607133730 0017063 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package test
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: Test
const MajorVersion = 2
const MinorVersion = 2
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
const GetVersionOpcode = 0
type GetVersionCookie x.SeqNum
// enum Cursor
const (
CursorNone = 0
CursorCurrent = 1
)
const CompareCursorOpcode = 1
type CompareCursorCookie x.SeqNum
const FakeInputOpcode = 2
const GrabControlOpcode = 3
var requestOpcodeNameMap = map[uint]string{
GetVersionOpcode: "GetVersion",
CompareCursorOpcode: "CompareCursor",
FakeInputOpcode: "FakeInput",
GrabControlOpcode: "GrabControl",
}
func init() {
_ext = x.NewExtension("XTEST", 0, nil, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/test/test.go 0000664 0000000 0000000 00000003151 14607133730 0017073 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package test
import (
x "github.com/linuxdeepin/go-x11-client"
)
// #WREQ
func encodeGetVersion(majorVersion uint8, minorVersion uint16) (b x.RequestBody) {
b.AddBlock(1).
Write1b(majorVersion).
WritePad(1).
Write2b(minorVersion).
End()
return
}
type GetVersionReply struct {
MajorVersion uint8
MinorVersion uint16
}
func readGetVersionReply(r *x.Reader, v *GetVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.MajorVersion, _ = r.ReadReplyHeader()
v.MinorVersion = r.Read2b() // 3
return nil
}
// #WREQ
func encodeCompareCursor(window x.Window, cursor x.Cursor) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write4b(uint32(cursor)).
End()
return
}
type CompareCursorReply struct {
Same bool
}
func readCompareCursorReply(r *x.Reader, v *CompareCursorReply) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
same, _ := r.ReadReplyHeader() // 2
v.Same = x.Uint8ToBool(same)
return nil
}
// #WREQ
func encodeFakeInput(evType uint8, detail uint8, time x.Timestamp, root x.Window,
rootX, rootY int16, deviceId uint8) (b x.RequestBody) {
b.AddBlock(8).
Write1b(evType).
Write1b(detail).
WritePad(2).
Write4b(uint32(time)).
Write4b(uint32(root)).
WritePad(8).
Write2b(uint16(rootX)).
Write2b(uint16(rootY)).
WritePad(7).
Write1b(deviceId).
End()
return
}
// #WREQ
func encodeGrabControl(impervious bool) (b x.RequestBody) {
b.AddBlock(1).
WriteBool(impervious).
WritePad(3).
End()
return
}
go-x11-client-1.0.2/ext/test/test_req_auto.go 0000664 0000000 0000000 00000005565 14607133730 0021005 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package test
import x "github.com/linuxdeepin/go-x11-client"
func GetVersion(conn *x.Conn, majorVersion uint8, minorVersion uint16) GetVersionCookie {
body := encodeGetVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetVersionCookie(seq)
}
func (cookie GetVersionCookie) Reply(conn *x.Conn) (*GetVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetVersionReply
err = readGetVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CompareCursor(conn *x.Conn, window x.Window, cursor x.Cursor) CompareCursorCookie {
body := encodeCompareCursor(window, cursor)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: CompareCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return CompareCursorCookie(seq)
}
func (cookie CompareCursorCookie) Reply(conn *x.Conn) (*CompareCursorReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply CompareCursorReply
err = readCompareCursorReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func FakeInput(conn *x.Conn, evType uint8, detail uint8, time x.Timestamp, root x.Window, rootX, rootY int16, deviceId uint8) {
body := encodeFakeInput(evType, detail, time, root, rootX, rootY, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FakeInputOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func FakeInputChecked(conn *x.Conn, evType uint8, detail uint8, time x.Timestamp, root x.Window, rootX, rootY int16, deviceId uint8) x.VoidCookie {
body := encodeFakeInput(evType, detail, time, root, rootX, rootY, deviceId)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: FakeInputOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GrabControl(conn *x.Conn, impervious bool) {
body := encodeGrabControl(impervious)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: GrabControlOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func GrabControlChecked(conn *x.Conn, impervious bool) x.VoidCookie {
body := encodeGrabControl(impervious)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: GrabControlOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/xfixes/ 0000775 0000000 0000000 00000000000 14607133730 0016114 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/xfixes/auto.go 0000664 0000000 0000000 00000011752 14607133730 0017421 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xfixes
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: XFixes
const MajorVersion = 5
const MinorVersion = 0
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
const QueryVersionOpcode = 0
type QueryVersionCookie x.SeqNum
// enum SaveSetMode
const (
SaveSetModeInsert = 0
SaveSetModeDelete = 1
)
// enum SaveSetTarget
const (
SaveSetTargetNearest = 0
SaveSetTargetRoot = 1
)
// enum SaveSetMapping
const (
SaveSetMappingMap = 0
SaveSetMappingUnmap = 1
)
const ChangeSaveSetOpcode = 1
// enum SelectionEvent
const (
SelectionEventSetSelectionOwner = 0
SelectionEventSelectionWindowDestroy = 1
SelectionEventSelectionClientClose = 2
)
// enum SelectionEventMask
const (
SelectionEventMaskSetSelectionOwner = 1
SelectionEventMaskSelectionWindowDestroy = 2
SelectionEventMaskSelectionClientClose = 4
)
const SelectionNotifyEventCode = 0
func NewSelectionNotifyEvent(data []byte) (*SelectionNotifyEvent, error) {
var ev SelectionNotifyEvent
r := x.NewReaderFromData(data)
err := readSelectionNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const SelectSelectionInputOpcode = 2
// enum CursorNotify
const (
CursorNotifyDisplayCursor = 0
)
// enum CursorNotifyMask
const (
CursorNotifyMaskDisplayCursor = 1
)
const CursorNotifyEventCode = 1
func NewCursorNotifyEvent(data []byte) (*CursorNotifyEvent, error) {
var ev CursorNotifyEvent
r := x.NewReaderFromData(data)
err := readCursorNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const SelectCursorInputOpcode = 3
const GetCursorImageOpcode = 4
type GetCursorImageCookie x.SeqNum
// simple ('xcb', 'XFixes', 'REGION')
type Region uint32
const BadRegionErrorCode = 0
// enum Region
const (
RegionNone = 0
)
const CreateRegionOpcode = 5
const CreateRegionFromBitmapOpcode = 6
const CreateRegionFromWindowOpcode = 7
const CreateRegionFromGCOpcode = 8
const CreateRegionFromPictureOpcode = 9
const DestroyRegionOpcode = 10
const SetRegionOpcode = 11
const CopyRegionOpcode = 12
const UnionRegionOpcode = 13
const IntersectRegionOpcode = 14
const SubtractRegionOpcode = 15
const InvertRegionOpcode = 16
const TranslateRegionOpcode = 17
const RegionExtentsOpcode = 18
const FetchRegionOpcode = 19
type FetchRegionCookie x.SeqNum
const SetGCClipRegionOpcode = 20
const SetWindowShapeRegionOpcode = 21
const SetPictureClipRegionOpcode = 22
const SetCursorNameOpcode = 23
const GetCursorNameOpcode = 24
type GetCursorNameCookie x.SeqNum
const GetCursorImageAndNameOpcode = 25
type GetCursorImageAndNameCookie x.SeqNum
const ChangeCursorOpcode = 26
const ChangeCursorByNameOpcode = 27
const ExpandRegionOpcode = 28
const HideCursorOpcode = 29
const ShowCursorOpcode = 30
// simple ('xcb', 'XFixes', 'BARRIER')
type Barrier uint32
// enum BarrierDirections
const (
BarrierDirectionsPositiveX = 1
BarrierDirectionsPositiveY = 2
BarrierDirectionsNegativeX = 4
BarrierDirectionsNegativeY = 8
)
const CreatePointerBarrierOpcode = 31
const DeletePointerBarrierOpcode = 32
var errorCodeNameMap = map[uint8]string{
BadRegionErrorCode: "BadRegion",
}
var requestOpcodeNameMap = map[uint]string{
QueryVersionOpcode: "QueryVersion",
ChangeSaveSetOpcode: "ChangeSaveSet",
SelectSelectionInputOpcode: "SelectSelectionInput",
SelectCursorInputOpcode: "SelectCursorInput",
GetCursorImageOpcode: "GetCursorImage",
CreateRegionOpcode: "CreateRegion",
CreateRegionFromBitmapOpcode: "CreateRegionFromBitmap",
CreateRegionFromWindowOpcode: "CreateRegionFromWindow",
CreateRegionFromGCOpcode: "CreateRegionFromGC",
CreateRegionFromPictureOpcode: "CreateRegionFromPicture",
DestroyRegionOpcode: "DestroyRegion",
SetRegionOpcode: "SetRegion",
CopyRegionOpcode: "CopyRegion",
UnionRegionOpcode: "UnionRegion",
IntersectRegionOpcode: "IntersectRegion",
SubtractRegionOpcode: "SubtractRegion",
InvertRegionOpcode: "InvertRegion",
TranslateRegionOpcode: "TranslateRegion",
RegionExtentsOpcode: "RegionExtents",
FetchRegionOpcode: "FetchRegion",
SetGCClipRegionOpcode: "SetGCClipRegion",
SetWindowShapeRegionOpcode: "SetWindowShapeRegion",
SetPictureClipRegionOpcode: "SetPictureClipRegion",
SetCursorNameOpcode: "SetCursorName",
GetCursorNameOpcode: "GetCursorName",
GetCursorImageAndNameOpcode: "GetCursorImageAndName",
ChangeCursorOpcode: "ChangeCursor",
ChangeCursorByNameOpcode: "ChangeCursorByName",
ExpandRegionOpcode: "ExpandRegion",
HideCursorOpcode: "HideCursor",
ShowCursorOpcode: "ShowCursor",
CreatePointerBarrierOpcode: "CreatePointerBarrier",
DeletePointerBarrierOpcode: "DeletePointerBarrier",
}
func init() {
_ext = x.NewExtension("XFIXES", 0, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/xfixes/xfixes.go 0000664 0000000 0000000 00000023221 14607133730 0017751 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xfixes
import (
"math"
"github.com/linuxdeepin/go-x11-client"
)
// #WREQ
func encodeQueryVersion(majorVersion, minorVersion uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(majorVersion).
Write4b(minorVersion).
End()
return
}
type QueryVersionReply struct {
MajorVersion uint32
MinorVersion uint32
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.MajorVersion = r.Read4b()
v.MinorVersion = r.Read4b() // 4
return nil
}
// #WREQ
func encodeChangeSaveSet(mode, target, map0 uint8, window x.Window) (b x.RequestBody) {
b.AddBlock(2).
Write1b(mode).
Write1b(target).
Write1b(map0).
WritePad(1).
Write4b(uint32(window)).
End()
return
}
type SelectionNotifyEvent struct {
Subtype uint8
Sequence uint16
Window x.Window
Owner x.Window
Selection x.Atom
Timestamp x.Timestamp
SelectionTimestamp x.Timestamp
}
func readSelectionNotifyEvent(r *x.Reader, v *SelectionNotifyEvent) error {
if !r.RemainAtLeast4b(6) {
return x.ErrDataLenShort
}
v.Subtype, v.Sequence = r.ReadEventHeader()
v.Window = x.Window(r.Read4b())
v.Owner = x.Window(r.Read4b())
v.Selection = x.Atom(r.Read4b())
v.Timestamp = x.Timestamp(r.Read4b())
v.SelectionTimestamp = x.Timestamp(r.Read4b()) // 6
return nil
}
// #WREQ
func encodeSelectSelectionInput(window x.Window, selection x.Atom,
eventMask uint32) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(window)).
Write4b(uint32(selection)).
Write4b(eventMask).
End()
return
}
type CursorNotifyEvent struct {
Subtype uint8
Sequence uint16
Window x.Window
CursorSerial uint32
Timestamp x.Timestamp
Name x.Atom
}
func readCursorNotifyEvent(r *x.Reader, v *CursorNotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
v.Subtype, v.Sequence = r.ReadEventHeader()
v.Window = x.Window(r.Read4b())
v.CursorSerial = r.Read4b()
v.Timestamp = x.Timestamp(r.Read4b())
v.Name = x.Atom(r.Read4b()) // 5
return nil
}
// #WREQ
func encodeSelectCursorInput(window x.Window, eventMask uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(window)).
Write4b(eventMask).
End()
return
}
// #WREQ
func encodeGetCursorImage() (b x.RequestBody) {
return
}
type GetCursorImageReply struct {
X int16
Y int16
Width uint16
Height uint16
XHot uint16
YHot uint16
CursorSerial uint32
CursorImage []uint32
}
func readGetCursorImageReply(r *x.Reader, v *GetCursorImageReply) error {
if !r.RemainAtLeast4b(6) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.X = int16(r.Read2b())
v.Y = int16(r.Read2b())
v.Width = r.Read2b()
v.Height = r.Read2b()
v.XHot = r.Read2b()
v.YHot = r.Read2b()
v.CursorSerial = r.Read4b() // 6
dataLen := int(v.Width) * int(v.Height)
if dataLen > 0 {
if !r.RemainAtLeast4b(dataLen) {
return x.ErrDataLenShort
}
v.CursorImage = make([]uint32, dataLen)
for i := 0; i < dataLen; i++ {
v.CursorImage[i] = r.Read4b()
}
}
return nil
}
// #WREQ
func encodeCreateRegion(region Region, rects []x.Rectangle) (b x.RequestBody) {
b0 := b.AddBlock(1 + 2*len(rects)).
Write4b(uint32(region))
for _, rect := range rects {
x.WriteRectangle(b0, rect)
}
b0.End()
return
}
// #WREQ
func encodeCreateRegionFromBitmap(region Region, bitmap x.Pixmap) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(region)).
Write4b(uint32(bitmap)).
End()
return
}
// #WREQ
//func encodeCreateRegionFromWindow
// #WREQ
func encodeCreateRegionFromGC(region Region, gc x.GContext) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(region)).
Write4b(uint32(gc)).
End()
return
}
// #WREQ
//func encodeCreateRegionFromPicture
// #WREQ
func encodeDestroyRegion(region Region) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(region)).
End()
return
}
// #WREQ
func encodeSetRegion(region Region, rects []x.Rectangle) (b x.RequestBody) {
b0 := b.AddBlock(1 + 2*len(rects)).
Write4b(uint32(region))
for _, rect := range rects {
x.WriteRectangle(b0, rect)
}
b0.End()
return
}
// #WREQ
func encodeCopyRegion(source, destination Region) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(source)).
Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeUnionRegion(source1, source2, destination Region) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(source1)).
Write4b(uint32(source2)).
Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeIntersectRegion(source1, source2, destination Region) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(source1)).
Write4b(uint32(source2)).
Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeSubtractRegion(source1, source2, destination Region) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(source1)).
Write4b(uint32(source2)).
Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeInvertRegion(source Region, bounds x.Rectangle, destination Region) (b x.RequestBody) {
b0 := b.AddBlock(4).
Write4b(uint32(source))
x.WriteRectangle(b0, bounds)
b0.Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeTranslateRegion(region Region, dx, dy int16) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(region)).
Write2b(uint16(dx)).
Write2b(uint16(dy)).
End()
return
}
// #WREQ
func encodeRegionExtents(source, destination Region) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(source)).
Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeFetchRegion(region Region) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(region)).
End()
return
}
type FetchRegionReply struct {
Extents x.Rectangle
Rectangles []x.Rectangle
}
func readFetchRegionReply(r *x.Reader, v *FetchRegionReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
_, replyLen := r.ReadReplyHeader()
v.Extents = x.ReadRectangle(r) // 4
r.ReadPad(16) // 8
rectanglesLen := int(replyLen / 2)
if rectanglesLen > 0 {
if !r.RemainAtLeast4b(2 * rectanglesLen) {
return x.ErrDataLenShort
}
v.Rectangles = make([]x.Rectangle, rectanglesLen)
for i := 0; i < rectanglesLen; i++ {
v.Rectangles[i] = x.ReadRectangle(r)
}
}
return nil
}
// #WREQ
func encodeSetGCClipRegion(gc x.GContext, clipXOrigin, clipYOrigin int16,
region Region) (b x.RequestBody) {
b.AddBlock(3).
Write4b(uint32(gc)).
Write4b(uint32(region)).
Write2b(uint16(clipXOrigin)).
Write2b(uint16(clipYOrigin)).
End()
return
}
// #WREQ
func encodeSetCursorName(cursor x.Cursor, name string) (b x.RequestBody) {
name = x.TruncateStr(name, math.MaxUint16)
nameLen := len(name)
b.AddBlock(2 + x.SizeIn4bWithPad(nameLen)).
Write4b(uint32(cursor)).
Write2b(uint16(nameLen)).
WritePad(2).
WriteString(name).
WritePad(x.Pad(nameLen)).
End()
return
}
// #WREQ
func encodeGetCursorImageAndName() (b x.RequestBody) {
return
}
type GetCursorImageAndNameReply struct {
X, Y int16
Width, Height uint16
XHot, YHot uint16
CursorSerial uint32
CursorAtom x.Atom
CursorName string
CursorImage []uint32
}
func readGetCursorImageAndNameReply(r *x.Reader, v *GetCursorImageAndNameReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.X = int16(r.Read2b())
v.Y = int16(r.Read2b())
v.Width = r.Read2b()
v.Height = r.Read2b()
v.XHot = r.Read2b()
v.YHot = r.Read2b() // 5
v.CursorSerial = r.Read4b()
v.CursorAtom = x.Atom(r.Read4b())
cursorNameLen := int(r.Read2b())
r.ReadPad(2) // 8
dataLen := int(v.Width) * int(v.Height)
if dataLen > 0 {
if !r.RemainAtLeast4b(dataLen) {
return x.ErrDataLenShort
}
v.CursorImage = make([]uint32, dataLen)
for i := 0; i < dataLen; i++ {
v.CursorImage[i] = r.Read4b()
}
}
var err error
v.CursorName, err = r.ReadString(cursorNameLen)
return err
}
// #WREQ
func encodeChangeCursor(source, destination x.Cursor) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(source)).
Write4b(uint32(destination)).
End()
return
}
// #WREQ
func encodeChangeCursorByName(src x.Cursor, name string) (b x.RequestBody) {
name = x.TruncateStr(name, math.MaxUint16)
nameLen := len(name)
b.AddBlock(2 + x.SizeIn4bWithPad(nameLen)).
Write4b(uint32(src)).
Write2b(uint16(nameLen)).
WritePad(2).
WriteString(name).
WritePad(x.Pad(nameLen)).
End()
return
}
// #WREQ
func encodeExpandRegion(source, destination Region, left, right,
top, bottom uint16) (b x.RequestBody) {
b.AddBlock(4).
Write4b(uint32(source)).
Write4b(uint32(destination)).
Write2b(left).
Write2b(right).
Write2b(top).
Write2b(bottom).
End()
return
}
// #WREQ
func encodeHideCursor(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
// #WREQ
func encodeShowCursor(window x.Window) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(window)).
End()
return
}
// #WREQ
func encodeCreatePointerBarrier(barrier Barrier, drawable x.Drawable,
x1, y1, x2, y2 int16, directions uint32, devices []uint16) (b x.RequestBody) {
devicesLen := len(devices)
b0 := b.AddBlock(6 + x.SizeIn4bWithPad(devicesLen*2)).
Write4b(uint32(barrier)).
Write4b(uint32(drawable)).
Write2b(uint16(x1)).
Write2b(uint16(y1)).
Write2b(uint16(x2)).
Write2b(uint16(y2)).
Write4b(directions).
WritePad(2).
Write2b(uint16(len(devices)))
for _, device := range devices {
b0.Write2b(device)
}
b0.WritePad(x.Pad(devicesLen * 2))
b0.End()
return
}
// #WREQ
func encodeDeletePointerBarrier(barrier Barrier) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(barrier)).
End()
return
}
go-x11-client-1.0.2/ext/xfixes/xfixes_req_auto.go 0000664 0000000 0000000 00000044523 14607133730 0021660 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xfixes
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn, majorVersion, minorVersion uint32) QueryVersionCookie {
body := encodeQueryVersion(majorVersion, minorVersion)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func ChangeSaveSet(conn *x.Conn, mode, target, map0 uint8, window x.Window) {
body := encodeChangeSaveSet(mode, target, map0, window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeSaveSetOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ChangeSaveSetChecked(conn *x.Conn, mode, target, map0 uint8, window x.Window) x.VoidCookie {
body := encodeChangeSaveSet(mode, target, map0, window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeSaveSetOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SelectSelectionInput(conn *x.Conn, window x.Window, selection x.Atom, eventMask uint32) {
body := encodeSelectSelectionInput(window, selection, eventMask)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectSelectionInputOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SelectSelectionInputChecked(conn *x.Conn, window x.Window, selection x.Atom, eventMask uint32) x.VoidCookie {
body := encodeSelectSelectionInput(window, selection, eventMask)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectSelectionInputOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SelectCursorInput(conn *x.Conn, window x.Window, eventMask uint32) {
body := encodeSelectCursorInput(window, eventMask)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectCursorInputOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SelectCursorInputChecked(conn *x.Conn, window x.Window, eventMask uint32) x.VoidCookie {
body := encodeSelectCursorInput(window, eventMask)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectCursorInputOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetCursorImage(conn *x.Conn) GetCursorImageCookie {
body := encodeGetCursorImage()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCursorImageOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCursorImageCookie(seq)
}
func (cookie GetCursorImageCookie) Reply(conn *x.Conn) (*GetCursorImageReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCursorImageReply
err = readGetCursorImageReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CreateRegion(conn *x.Conn, region Region, rects []x.Rectangle) {
body := encodeCreateRegion(region, rects)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateRegionChecked(conn *x.Conn, region Region, rects []x.Rectangle) x.VoidCookie {
body := encodeCreateRegion(region, rects)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateRegionFromBitmap(conn *x.Conn, region Region, bitmap x.Pixmap) {
body := encodeCreateRegionFromBitmap(region, bitmap)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRegionFromBitmapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateRegionFromBitmapChecked(conn *x.Conn, region Region, bitmap x.Pixmap) x.VoidCookie {
body := encodeCreateRegionFromBitmap(region, bitmap)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRegionFromBitmapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreateRegionFromGC(conn *x.Conn, region Region, gc x.GContext) {
body := encodeCreateRegionFromGC(region, gc)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRegionFromGCOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreateRegionFromGCChecked(conn *x.Conn, region Region, gc x.GContext) x.VoidCookie {
body := encodeCreateRegionFromGC(region, gc)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreateRegionFromGCOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func DestroyRegion(conn *x.Conn, region Region) {
body := encodeDestroyRegion(region)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DestroyRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DestroyRegionChecked(conn *x.Conn, region Region) x.VoidCookie {
body := encodeDestroyRegion(region)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DestroyRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetRegion(conn *x.Conn, region Region, rects []x.Rectangle) {
body := encodeSetRegion(region, rects)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetRegionChecked(conn *x.Conn, region Region, rects []x.Rectangle) x.VoidCookie {
body := encodeSetRegion(region, rects)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CopyRegion(conn *x.Conn, source, destination Region) {
body := encodeCopyRegion(source, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CopyRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CopyRegionChecked(conn *x.Conn, source, destination Region) x.VoidCookie {
body := encodeCopyRegion(source, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CopyRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func UnionRegion(conn *x.Conn, source1, source2, destination Region) {
body := encodeUnionRegion(source1, source2, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnionRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func UnionRegionChecked(conn *x.Conn, source1, source2, destination Region) x.VoidCookie {
body := encodeUnionRegion(source1, source2, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: UnionRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func IntersectRegion(conn *x.Conn, source1, source2, destination Region) {
body := encodeIntersectRegion(source1, source2, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: IntersectRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func IntersectRegionChecked(conn *x.Conn, source1, source2, destination Region) x.VoidCookie {
body := encodeIntersectRegion(source1, source2, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: IntersectRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SubtractRegion(conn *x.Conn, source1, source2, destination Region) {
body := encodeSubtractRegion(source1, source2, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SubtractRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SubtractRegionChecked(conn *x.Conn, source1, source2, destination Region) x.VoidCookie {
body := encodeSubtractRegion(source1, source2, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SubtractRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func InvertRegion(conn *x.Conn, source Region, bounds x.Rectangle, destination Region) {
body := encodeInvertRegion(source, bounds, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: InvertRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func InvertRegionChecked(conn *x.Conn, source Region, bounds x.Rectangle, destination Region) x.VoidCookie {
body := encodeInvertRegion(source, bounds, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: InvertRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func TranslateRegion(conn *x.Conn, region Region, dx, dy int16) {
body := encodeTranslateRegion(region, dx, dy)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TranslateRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func TranslateRegionChecked(conn *x.Conn, region Region, dx, dy int16) x.VoidCookie {
body := encodeTranslateRegion(region, dx, dy)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: TranslateRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func RegionExtents(conn *x.Conn, source, destination Region) {
body := encodeRegionExtents(source, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RegionExtentsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func RegionExtentsChecked(conn *x.Conn, source, destination Region) x.VoidCookie {
body := encodeRegionExtents(source, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: RegionExtentsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func FetchRegion(conn *x.Conn, region Region) FetchRegionCookie {
body := encodeFetchRegion(region)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: FetchRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return FetchRegionCookie(seq)
}
func (cookie FetchRegionCookie) Reply(conn *x.Conn) (*FetchRegionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply FetchRegionReply
err = readFetchRegionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetGCClipRegion(conn *x.Conn, gc x.GContext, clipXOrigin, clipYOrigin int16, region Region) {
body := encodeSetGCClipRegion(gc, clipXOrigin, clipYOrigin, region)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetGCClipRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetGCClipRegionChecked(conn *x.Conn, gc x.GContext, clipXOrigin, clipYOrigin int16, region Region) x.VoidCookie {
body := encodeSetGCClipRegion(gc, clipXOrigin, clipYOrigin, region)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetGCClipRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetCursorName(conn *x.Conn, cursor x.Cursor, name string) {
body := encodeSetCursorName(cursor, name)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCursorNameOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetCursorNameChecked(conn *x.Conn, cursor x.Cursor, name string) x.VoidCookie {
body := encodeSetCursorName(cursor, name)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCursorNameOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetCursorImageAndName(conn *x.Conn) GetCursorImageAndNameCookie {
body := encodeGetCursorImageAndName()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCursorImageAndNameOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCursorImageAndNameCookie(seq)
}
func (cookie GetCursorImageAndNameCookie) Reply(conn *x.Conn) (*GetCursorImageAndNameReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCursorImageAndNameReply
err = readGetCursorImageAndNameReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func ChangeCursor(conn *x.Conn, source, destination x.Cursor) {
body := encodeChangeCursor(source, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeCursorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ChangeCursorChecked(conn *x.Conn, source, destination x.Cursor) x.VoidCookie {
body := encodeChangeCursor(source, destination)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ChangeCursorByName(conn *x.Conn, src x.Cursor, name string) {
body := encodeChangeCursorByName(src, name)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeCursorByNameOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ChangeCursorByNameChecked(conn *x.Conn, src x.Cursor, name string) x.VoidCookie {
body := encodeChangeCursorByName(src, name)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ChangeCursorByNameOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ExpandRegion(conn *x.Conn, source, destination Region, left, right, top, bottom uint16) {
body := encodeExpandRegion(source, destination, left, right, top, bottom)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ExpandRegionOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ExpandRegionChecked(conn *x.Conn, source, destination Region, left, right, top, bottom uint16) x.VoidCookie {
body := encodeExpandRegion(source, destination, left, right, top, bottom)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ExpandRegionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func HideCursor(conn *x.Conn, window x.Window) {
body := encodeHideCursor(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: HideCursorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func HideCursorChecked(conn *x.Conn, window x.Window) x.VoidCookie {
body := encodeHideCursor(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: HideCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func ShowCursor(conn *x.Conn, window x.Window) {
body := encodeShowCursor(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ShowCursorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func ShowCursorChecked(conn *x.Conn, window x.Window) x.VoidCookie {
body := encodeShowCursor(window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: ShowCursorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func CreatePointerBarrier(conn *x.Conn, barrier Barrier, drawable x.Drawable, x1, y1, x2, y2 int16, directions uint32, devices []uint16) {
body := encodeCreatePointerBarrier(barrier, drawable, x1, y1, x2, y2, directions, devices)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePointerBarrierOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreatePointerBarrierChecked(conn *x.Conn, barrier Barrier, drawable x.Drawable, x1, y1, x2, y2 int16, directions uint32, devices []uint16) x.VoidCookie {
body := encodeCreatePointerBarrier(barrier, drawable, x1, y1, x2, y2, directions, devices)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePointerBarrierOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func DeletePointerBarrier(conn *x.Conn, barrier Barrier) {
body := encodeDeletePointerBarrier(barrier)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeletePointerBarrierOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DeletePointerBarrierChecked(conn *x.Conn, barrier Barrier) x.VoidCookie {
body := encodeDeletePointerBarrier(barrier)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DeletePointerBarrierOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
go-x11-client-1.0.2/ext/xkb/ 0000775 0000000 0000000 00000000000 14607133730 0015372 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/ext/xkb/auto.go 0000664 0000000 0000000 00000037113 14607133730 0016676 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xkb
import x "github.com/linuxdeepin/go-x11-client"
// _ns.ext_name: xkb
const MajorVersion = 1
const MinorVersion = 0
var _ext *x.Extension
func Ext() *x.Extension {
return _ext
}
// enum Const
const (
ConstMaxLegalKeyCode = 255
ConstPerKeyBitArraySize = 32
ConstKeyNameLength = 4
)
// enum EventType
const (
EventTypeNewKeyboardNotify = 1
EventTypeMapNotify = 2
EventTypeStateNotify = 4
EventTypeControlsNotify = 8
EventTypeIndicatorStateNotify = 16
EventTypeIndicatorMapNotify = 32
EventTypeNamesNotify = 64
EventTypeCompatMapNotify = 128
EventTypeBellNotify = 256
EventTypeActionMessage = 512
EventTypeAccessXNotify = 1024
EventTypeExtensionDeviceNotify = 2048
)
// enum NKNDetail
const (
NKNDetailKeycodes = 1
NKNDetailGeometry = 2
NKNDetailDeviceId = 4
)
// enum AXNDetail
const (
AXNDetailSkPress = 1
AXNDetailSkAccept = 2
AXNDetailSkReject = 4
AXNDetailSkRelease = 8
AXNDetailBkAccept = 16
AXNDetailBkReject = 32
AXNDetailAxkWarning = 64
)
// enum MapPart
const (
MapPartKeyTypes = 1
MapPartKeySyms = 2
MapPartModifierMap = 4
MapPartExplicitComponents = 8
MapPartKeyActions = 16
MapPartKeyBehaviors = 32
MapPartVirtualMods = 64
MapPartVirtualModMap = 128
)
// enum SetMapFlags
const (
SetMapFlagsResizeTypes = 1
SetMapFlagsRecomputeActions = 2
)
// enum StatePart
const (
StatePartModifierState = 1
StatePartModifierBase = 2
StatePartModifierLatch = 4
StatePartModifierLock = 8
StatePartGroupState = 16
StatePartGroupBase = 32
StatePartGroupLatch = 64
StatePartGroupLock = 128
StatePartCompatState = 256
StatePartGrabMods = 512
StatePartCompatGrabMods = 1024
StatePartLookupMods = 2048
StatePartCompatLookupMods = 4096
StatePartPointerButtons = 8192
)
// enum BoolCtrl
const (
BoolCtrlRepeatKeys = 1
BoolCtrlSlowKeys = 2
BoolCtrlBounceKeys = 4
BoolCtrlStickyKeys = 8
BoolCtrlMouseKeys = 16
BoolCtrlMouseKeysAccel = 32
BoolCtrlAccessXKeys = 64
BoolCtrlAccessXTimeoutMask = 128
BoolCtrlAccessXFeedbackMask = 256
BoolCtrlAudibleBellMask = 512
BoolCtrlOverlay1Mask = 1024
BoolCtrlOverlay2Mask = 2048
BoolCtrlIgnoreGroupLockMask = 4096
)
// enum Control
const (
ControlGroupsWrap = 134217728
ControlInternalMods = 268435456
ControlIgnoreLockMods = 536870912
ControlPerKeyRepeat = 1073741824
ControlControlsEnabled = 2147483648
)
// enum AXOption
const (
AXOptionSkPressFb = 1
AXOptionSkAcceptFb = 2
AXOptionFeatureFb = 4
AXOptionSlowWarnFb = 8
AXOptionIndicatorFb = 16
AXOptionStickyKeysFb = 32
AXOptionTwoKeys = 64
AXOptionLatchToLock = 128
AXOptionSkReleaseFb = 256
AXOptionSkRejectFb = 512
AXOptionBkRejectFb = 1024
AXOptionDumbBell = 2048
)
// simple ('xcb', 'xkb', 'DeviceSpec')
type DeviceSpec uint16
// enum LedClassResult
const (
LedClassResultKbdFeedbackClass = 0
LedClassResultLedFeedbackClass = 4
)
// enum LedClass
const (
LedClassKbdFeedbackClass = 0
LedClassLedFeedbackClass = 4
LedClassDfltXiClass = 768
LedClassAllXiClasses = 1280
)
// simple ('xcb', 'xkb', 'LedClassSpec')
type LedClassSpec uint16
// enum BellClassResult
const (
BellClassResultKbdFeedbackClass = 0
BellClassResultBellFeedbackClass = 5
)
// enum BellClass
const (
BellClassKbdFeedbackClass = 0
BellClassBellFeedbackClass = 5
BellClassDfltXiClass = 768
)
// simple ('xcb', 'xkb', 'BellClassSpec')
type BellClassSpec uint16
// enum ID
const (
IDUseCoreKbd = 256
IDUseCorePtr = 512
IDDfltXiClass = 768
IDDfltXiId = 1024
IDAllXiClass = 1280
IDAllXiId = 1536
IDXiNone = 65280
)
// simple ('xcb', 'xkb', 'IDSpec')
type IdSpec uint16
// enum Group
const (
Group1 = 0
Group2 = 1
Group3 = 2
Group4 = 3
)
// enum Groups
const (
GroupsAny = 254
GroupsAll = 255
)
// enum SetOfGroup
const (
SetOfGroupGroup1 = 1
SetOfGroupGroup2 = 2
SetOfGroupGroup3 = 4
SetOfGroupGroup4 = 8
)
// enum SetOfGroups
const (
SetOfGroupsAny = 128
)
// enum GroupsWrap
const (
GroupsWrapWrapIntoRange = 0
GroupsWrapClampIntoRange = 64
GroupsWrapRedirectIntoRange = 128
)
// enum VModsHigh
const (
VModsHigh15 = 128
VModsHigh14 = 64
VModsHigh13 = 32
VModsHigh12 = 16
VModsHigh11 = 8
VModsHigh10 = 4
VModsHigh9 = 2
VModsHigh8 = 1
)
// enum VModsLow
const (
VModsLow7 = 128
VModsLow6 = 64
VModsLow5 = 32
VModsLow4 = 16
VModsLow3 = 8
VModsLow2 = 4
VModsLow1 = 2
VModsLow0 = 1
)
// enum VMod
const (
VMod15 = 32768
VMod14 = 16384
VMod13 = 8192
VMod12 = 4096
VMod11 = 2048
VMod10 = 1024
VMod9 = 512
VMod8 = 256
VMod7 = 128
VMod6 = 64
VMod5 = 32
VMod4 = 16
VMod3 = 8
VMod2 = 4
VMod1 = 2
VMod0 = 1
)
// enum Explicit
const (
ExplicitVModMap = 128
ExplicitBehavior = 64
ExplicitAutoRepeat = 32
ExplicitInterpret = 16
ExplicitKeyType4 = 8
ExplicitKeyType3 = 4
ExplicitKeyType2 = 2
ExplicitKeyType1 = 1
)
// enum SymInterpretMatch
const (
SymInterpretMatchNoneOf = 0
SymInterpretMatchAnyOfOrNone = 1
SymInterpretMatchAnyOf = 2
SymInterpretMatchAllOf = 3
SymInterpretMatchExactly = 4
)
// enum SymInterpMatch
const (
SymInterpMatchLevelOneOnly = 128
SymInterpMatchOpMask = 127
)
// enum IMFlag
const (
IMFlagNoExplicit = 128
IMFlagNoAutomatic = 64
IMFlagLedDrivesKb = 32
)
// enum IMModsWhich
const (
IMModsWhichUseCompat = 16
IMModsWhichUseEffective = 8
IMModsWhichUseLocked = 4
IMModsWhichUseLatched = 2
IMModsWhichUseBase = 1
)
// enum IMGroupsWhich
const (
IMGroupsWhichUseCompat = 16
IMGroupsWhichUseEffective = 8
IMGroupsWhichUseLocked = 4
IMGroupsWhichUseLatched = 2
IMGroupsWhichUseBase = 1
)
// enum CMDetail
const (
CMDetailSymInterp = 1
CMDetailGroupCompat = 2
)
// enum NameDetail
const (
NameDetailKeycodes = 1
NameDetailGeometry = 2
NameDetailSymbols = 4
NameDetailPhysSymbols = 8
NameDetailTypes = 16
NameDetailCompat = 32
NameDetailKeyTypeNames = 64
NameDetailKtLevelNames = 128
NameDetailIndicatorNames = 256
NameDetailKeyNames = 512
NameDetailKeyAliases = 1024
NameDetailVirtualModNames = 2048
NameDetailGroupNames = 4096
NameDetailRgNames = 8192
)
// enum GBNDetail
const (
GBNDetailTypes = 1
GBNDetailCompatMap = 2
GBNDetailClientSymbols = 4
GBNDetailServerSymbols = 8
GBNDetailIndicatorMaps = 16
GBNDetailKeyNames = 32
GBNDetailGeometry = 64
GBNDetailOtherNames = 128
)
// enum XIFeature
const (
XIFeatureKeyboards = 1
XIFeatureButtonActions = 2
XIFeatureIndicatorNames = 4
XIFeatureIndicatorMaps = 8
XIFeatureIndicatorState = 16
)
// enum PerClientFlag
const (
PerClientFlagDetectableAutoRepeat = 1
PerClientFlagGrabsUseXkbState = 2
PerClientFlagAutoResetControls = 4
PerClientFlagLookupStateWhenGrabbed = 8
PerClientFlagSendEventUsesXkbState = 16
)
// enum BehaviorType
const (
BehaviorTypeDefault = 0
BehaviorTypeLock = 1
BehaviorTypeRadioGroup = 2
BehaviorTypeOverlay1 = 3
BehaviorTypeOverlay2 = 4
BehaviorTypePermamentLock = 129
BehaviorTypePermamentRadioGroup = 130
BehaviorTypePermamentOverlay1 = 131
BehaviorTypePermamentOverlay2 = 132
)
// simple ('xcb', 'xkb', 'STRING8')
type String8 byte
// enum DoodadType
const (
DoodadTypeOutline = 1
DoodadTypeSolid = 2
DoodadTypeText = 3
DoodadTypeIndicator = 4
DoodadTypeLogo = 5
)
// enum Error
const (
ErrorBadDevice = 255
ErrorBadClass = 254
ErrorBadId = 253
)
const KeyboardErrorCode = 0
// enum SA
const (
SAClearLocks = 1
SALatchToLock = 2
SAUseModMapMods = 4
SAGroupAbsolute = 4
)
// enum SAType
const (
SATypeNoAction = 0
SATypeSetMods = 1
SATypeLatchMods = 2
SATypeLockMods = 3
SATypeSetGroup = 4
SATypeLatchGroup = 5
SATypeLockGroup = 6
SATypeMovePtr = 7
SATypePtrBtn = 8
SATypeLockPtrBtn = 9
SATypeSetPtrDflt = 10
SATypeIsoLock = 11
SATypeTerminate = 12
SATypeSwitchScreen = 13
SATypeSetControls = 14
SATypeLockControls = 15
SATypeActionMessage = 16
SATypeRedirectKey = 17
SATypeDeviceBtn = 18
SATypeLockDeviceBtn = 19
SATypeDeviceValuator = 20
)
// enum SAMovePtrFlag
const (
SAMovePtrFlagNoAcceleration = 1
SAMovePtrFlagMoveAbsoluteX = 2
SAMovePtrFlagMoveAbsoluteY = 4
)
// enum SASetPtrDfltFlag
const (
SASetPtrDfltFlagDfltBtnAbsolute = 4
SASetPtrDfltFlagAffectDfltButton = 1
)
// enum SAIsoLockFlag
const (
SAIsoLockFlagNoLock = 1
SAIsoLockFlagNoUnlock = 2
SAIsoLockFlagUseModMapMods = 4
SAIsoLockFlagGroupAbsolute = 4
SAIsoLockFlagIsoDfltIsGroup = 8
)
// enum SAIsoLockNoAffect
const (
SAIsoLockNoAffectCtrls = 8
SAIsoLockNoAffectPtr = 16
SAIsoLockNoAffectGroup = 32
SAIsoLockNoAffectMods = 64
)
// enum SwitchScreenFlag
const (
SwitchScreenFlagApplication = 1
SwitchScreenFlagAbsolute = 4
)
// enum BoolCtrlsHigh
const (
BoolCtrlsHighAccessXFeedback = 1
BoolCtrlsHighAudibleBell = 2
BoolCtrlsHighOverlay1 = 4
BoolCtrlsHighOverlay2 = 8
BoolCtrlsHighIgnoreGroupLock = 16
)
// enum BoolCtrlsLow
const (
BoolCtrlsLowRepeatKeys = 1
BoolCtrlsLowSlowKeys = 2
BoolCtrlsLowBounceKeys = 4
BoolCtrlsLowStickyKeys = 8
BoolCtrlsLowMouseKeys = 16
BoolCtrlsLowMouseKeysAccel = 32
BoolCtrlsLowAccessXKeys = 64
BoolCtrlsLowAccessXTimeout = 128
)
// enum ActionMessageFlag
const (
ActionMessageFlagOnPress = 1
ActionMessageFlagOnRelease = 2
ActionMessageFlagGenKeyEvent = 4
)
// enum LockDeviceFlags
const (
LockDeviceFlagsNoLock = 1
LockDeviceFlagsNoUnlock = 2
)
// enum SAValWhat
const (
SAValWhatIgnoreVal = 0
SAValWhatSetValMin = 1
SAValWhatSetValCenter = 2
SAValWhatSetValMax = 3
SAValWhatSetValRelative = 4
SAValWhatSetValAbsolute = 5
)
const UseExtensionOpcode = 0
type UseExtensionCookie x.SeqNum
const SelectEventsOpcode = 1
const BellOpcode = 3
const GetStateOpcode = 4
type GetStateCookie x.SeqNum
const LatchLockStateOpcode = 5
const GetControlsOpcode = 6
type GetControlsCookie x.SeqNum
const SetControlsOpcode = 7
const GetMapOpcode = 8
type GetMapCookie x.SeqNum
const SetMapOpcode = 9
const GetCompatMapOpcode = 10
type GetCompatMapCookie x.SeqNum
const SetCompatMapOpcode = 11
const GetIndicatorStateOpcode = 12
type GetIndicatorStateCookie x.SeqNum
const GetIndicatorMapOpcode = 13
type GetIndicatorMapCookie x.SeqNum
const SetIndicatorMapOpcode = 14
const GetNamedIndicatorOpcode = 15
type GetNamedIndicatorCookie x.SeqNum
const SetNamedIndicatorOpcode = 16
const GetNamesOpcode = 17
type GetNamesCookie x.SeqNum
const SetNamesOpcode = 18
const PerClientFlagsOpcode = 21
type PerClientFlagsCookie x.SeqNum
const ListComponentsOpcode = 22
type ListComponentsCookie x.SeqNum
const GetKbdByNameOpcode = 23
type GetKbdByNameCookie x.SeqNum
const GetDeviceInfoOpcode = 24
type GetDeviceInfoCookie x.SeqNum
const SetDeviceInfoOpcode = 25
const SetDebuggingFlagsOpcode = 101
type SetDebuggingFlagsCookie x.SeqNum
const NewKeyboardNotifyEventCode = 0
func NewNewKeyboardNotifyEvent(data []byte) (*NewKeyboardNotifyEvent, error) {
var ev NewKeyboardNotifyEvent
r := x.NewReaderFromData(data)
err := readNewKeyboardNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const MapNotifyEventCode = 1
func NewMapNotifyEvent(data []byte) (*MapNotifyEvent, error) {
var ev MapNotifyEvent
r := x.NewReaderFromData(data)
err := readMapNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const StateNotifyEventCode = 2
func NewStateNotifyEvent(data []byte) (*StateNotifyEvent, error) {
var ev StateNotifyEvent
r := x.NewReaderFromData(data)
err := readStateNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const ControlsNotifyEventCode = 3
func NewControlsNotifyEvent(data []byte) (*ControlsNotifyEvent, error) {
var ev ControlsNotifyEvent
r := x.NewReaderFromData(data)
err := readControlsNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const IndicatorStateNotifyEventCode = 4
func NewIndicatorStateNotifyEvent(data []byte) (*IndicatorStateNotifyEvent, error) {
var ev IndicatorStateNotifyEvent
r := x.NewReaderFromData(data)
err := readIndicatorStateNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const IndicatorMapNotifyEventCode = 5
func NewIndicatorMapNotifyEvent(data []byte) (*IndicatorMapNotifyEvent, error) {
var ev IndicatorMapNotifyEvent
r := x.NewReaderFromData(data)
err := readIndicatorMapNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const NamesNotifyEventCode = 6
func NewNamesNotifyEvent(data []byte) (*NamesNotifyEvent, error) {
var ev NamesNotifyEvent
r := x.NewReaderFromData(data)
err := readNamesNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const CompatMapNotifyEventCode = 7
func NewCompatMapNotifyEvent(data []byte) (*CompatMapNotifyEvent, error) {
var ev CompatMapNotifyEvent
r := x.NewReaderFromData(data)
err := readCompatMapNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const BellNotifyEventCode = 8
func NewBellNotifyEvent(data []byte) (*BellNotifyEvent, error) {
var ev BellNotifyEvent
r := x.NewReaderFromData(data)
err := readBellNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const ActionMessageEventCode = 9
func NewActionMessageEvent(data []byte) (*ActionMessageEvent, error) {
var ev ActionMessageEvent
r := x.NewReaderFromData(data)
err := readActionMessageEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const AccessXNotifyEventCode = 10
func NewAccessXNotifyEvent(data []byte) (*AccessXNotifyEvent, error) {
var ev AccessXNotifyEvent
r := x.NewReaderFromData(data)
err := readAccessXNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
const ExtensionDeviceNotifyEventCode = 11
func NewExtensionDeviceNotifyEvent(data []byte) (*ExtensionDeviceNotifyEvent, error) {
var ev ExtensionDeviceNotifyEvent
r := x.NewReaderFromData(data)
err := readExtensionDeviceNotifyEvent(r, &ev)
if err != nil {
return nil, err
}
return &ev, nil
}
var errorCodeNameMap = map[uint8]string{
KeyboardErrorCode: "BadKeyboard",
}
var requestOpcodeNameMap = map[uint]string{
UseExtensionOpcode: "UseExtension",
SelectEventsOpcode: "SelectEvents",
BellOpcode: "Bell",
GetStateOpcode: "GetState",
LatchLockStateOpcode: "LatchLockState",
GetControlsOpcode: "GetControls",
SetControlsOpcode: "SetControls",
GetMapOpcode: "GetMap",
SetMapOpcode: "SetMap",
GetCompatMapOpcode: "GetCompatMap",
SetCompatMapOpcode: "SetCompatMap",
GetIndicatorStateOpcode: "GetIndicatorState",
GetIndicatorMapOpcode: "GetIndicatorMap",
SetIndicatorMapOpcode: "SetIndicatorMap",
GetNamedIndicatorOpcode: "GetNamedIndicator",
SetNamedIndicatorOpcode: "SetNamedIndicator",
GetNamesOpcode: "GetNames",
SetNamesOpcode: "SetNames",
PerClientFlagsOpcode: "PerClientFlags",
ListComponentsOpcode: "ListComponents",
GetKbdByNameOpcode: "GetKbdByName",
GetDeviceInfoOpcode: "GetDeviceInfo",
SetDeviceInfoOpcode: "SetDeviceInfo",
SetDebuggingFlagsOpcode: "SetDebuggingFlags",
}
func init() {
_ext = x.NewExtension("XKEYBOARD", 0, errorCodeNameMap, requestOpcodeNameMap)
}
go-x11-client-1.0.2/ext/xkb/xkb.go 0000664 0000000 0000000 00000172353 14607133730 0016520 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xkb
import (
"bytes"
"math"
"sort"
"github.com/linuxdeepin/go-x11-client"
)
// #WREQ
func encodeUseExtension(wantedMajor, wantedMinor uint16) (b x.RequestBody) {
b.AddBlock(1).
Write2b(wantedMajor).
Write2b(wantedMinor).
End()
return
}
type UseExtensionReply struct {
Supported bool
ServerMajor uint16
ServerMinor uint16
}
func readUseExtensionReply(r *x.Reader, v *UseExtensionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
supported, _ := r.ReadReplyHeader()
v.Supported = x.Uint8ToBool(supported)
v.ServerMajor = r.Read2b()
v.ServerMinor = r.Read2b() // 3
return nil
}
// #WREQ vararg:options
func encodeSelectEvents(deviceSpec DeviceSpec, options ...SelectOption) (b x.RequestBody) {
var affectWhich, clear, selectAll, affectMap, mapDetail uint16
w := x.NewWriter()
sort.Sort(selectOptions(options))
for _, option := range options {
affectWhich |= option.affectEvent()
switch o := option.(type) {
case selectOptionAll:
selectAll |= o.eventType
case selectOptionClear:
clear |= o.eventType
case selectOptionDetail:
affect, detail := o.getAffectDetail()
switch o.eventType {
case EventTypeNewKeyboardNotify, EventTypeStateNotify, EventTypeNamesNotify,
EventTypeAccessXNotify, EventTypeExtensionDeviceNotify:
w.Write2b(uint16(affect))
w.Write2b(uint16(detail))
case EventTypeControlsNotify, EventTypeIndicatorStateNotify,
EventTypeIndicatorMapNotify:
w.Write4b(uint32(affect))
w.Write4b(uint32(detail))
case EventTypeCompatMapNotify, EventTypeBellNotify, EventTypeActionMessage:
w.Write1b(uint8(affect))
w.Write1b(uint8(detail))
case EventTypeMapNotify:
affectMap = uint16(affect)
mapDetail = uint16(detail)
}
}
}
b.AddBlock(3).
Write2b(uint16(deviceSpec)).
Write2b(affectWhich).
Write2b(clear).
Write2b(selectAll).
Write2b(affectMap).
Write2b(mapDetail).End()
b.AddBytes(w.Bytes())
return
}
type selectOptions []SelectOption
func (v selectOptions) Len() int {
return len(v)
}
func (v selectOptions) Less(i, j int) bool {
return v[i].affectEvent() < v[j].affectEvent()
}
func (v selectOptions) Swap(i, j int) {
v[i], v[j] = v[j], v[i]
}
type SelectOption interface {
affectEvent() uint16
}
type selectOptionClear struct {
eventType uint16
}
func (v selectOptionClear) affectEvent() uint16 {
return v.eventType
}
type selectOptionAll struct {
eventType uint16
}
func (v selectOptionAll) affectEvent() uint16 {
return v.eventType
}
type selectOptionDetail struct {
eventType uint16
detail map[uint]bool
}
func (v selectOptionDetail) affectEvent() uint16 {
return v.eventType
}
func (v selectOptionDetail) getAffectDetail() (affect, detail uint) {
for key, value := range v.detail {
affect |= key
if value {
detail |= key
}
}
return
}
func SelectAll(eventType uint16) SelectOption {
return selectOptionAll{eventType}
}
func SelectDetail(eventType uint16, detail map[uint]bool) SelectOption {
return selectOptionDetail{eventType: eventType, detail: detail}
}
func SelectClear(eventType uint16) SelectOption {
return selectOptionClear{eventType}
}
// #WREQ
func encodeBell(deviceSpec DeviceSpec, bellClass BellClassSpec, bellID IdSpec,
percent int8, forceSound, eventOnly bool, pitch, duration int16,
name x.Atom, window x.Window) (b x.RequestBody) {
b.AddBlock(6).
Write2b(uint16(deviceSpec)).
Write2b(uint16(bellClass)). // 1
Write2b(uint16(bellID)).
Write1b(uint8(percent)).
WriteBool(forceSound). // 2
WriteBool(eventOnly).
WritePad(1).
Write2b(uint16(pitch)). // 3
Write2b(uint16(duration)).
WritePad(2). // 4
Write4b(uint32(name)).
Write4b(uint32(window)).
End()
return
}
// #WREQ
func encodeGetState(deviceSpec DeviceSpec) (b x.RequestBody) {
b.AddBlock(1).
Write2b(uint16(deviceSpec)).
WritePad(2).
End()
return
}
type GetStateReply struct {
DeviceID uint8
Mods uint8
BaseMods uint8
LatchedMods uint8
LockedMods uint8
Group uint8
LockedGroup uint8
BaseGroup int16
LatchedGroup int16
CompatState uint8
GrabMods uint8
CompatGrabMods uint8
LookupMods uint8
CompatLookupMods uint8
PtrBtnState uint16
}
func readGetStateReply(r *x.Reader, v *GetStateReply) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.Mods = r.Read1b()
v.BaseMods = r.Read1b()
v.LatchedMods = r.Read1b()
v.LockedMods = r.Read1b() // 3
v.Group = r.Read1b()
v.LockedGroup = r.Read1b()
v.BaseGroup = int16(r.Read2b())
v.LatchedGroup = int16(r.Read2b())
v.CompatState = r.Read1b()
v.GrabMods = r.Read1b() // 5
v.CompatGrabMods = r.Read1b()
v.LookupMods = r.Read1b()
v.CompatLookupMods = r.Read1b()
r.ReadPad(1) // 6
v.PtrBtnState = r.Read2b() // 7
return nil
}
// #WREQ
func encodeLatchLockState(deviceSpec DeviceSpec, affectModLocks, modLocks uint8,
lockGroup bool, groupLock, affectModLatches, modLatches uint8, latchGroup bool,
groupLatch uint16) (b x.RequestBody) {
b.AddBlock(3).
Write2b(uint16(deviceSpec)).
Write1b(affectModLocks).
Write1b(modLocks). // 1
WriteBool(lockGroup).
Write1b(groupLock).
Write1b(affectModLatches).
Write1b(modLatches). // 2
WritePad(1).
WriteBool(latchGroup).
Write2b(groupLatch). // 3
End()
return
}
// #WREQ
func encodeGetControls(deviceSpec DeviceSpec) (b x.RequestBody) {
b.AddBlock(1).
Write2b(uint16(deviceSpec)).
WritePad(2).
End()
return
}
type GetControlsReply struct {
DeviceID uint8
Controls
}
func readGetControlsReply(r *x.Reader, v *GetControlsReply) error {
if !r.RemainAtLeast4b(15) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.MouseKeysDefaultBtn = r.Read1b()
v.NumGroups = r.Read1b()
v.GroupsWrap = r.Read1b()
v.Internal.Mask = r.Read1b() // 3
v.IgnoreLock.Mask = r.Read1b()
v.Internal.RealMods = r.Read1b()
v.IgnoreLock.RealMods = r.Read1b()
r.ReadPad(1) // 4
v.Internal.VirtualMods = r.Read2b()
v.IgnoreLock.VirtualMods = r.Read2b() // 5
v.RepeatDelay = r.Read2b()
v.RepeatInterval = r.Read2b()
v.SlowKeysDelay = r.Read2b()
v.DebounceDelay = r.Read2b()
v.MouseKeysDelay = r.Read2b()
v.MouseKeysInterval = r.Read2b() // 8
v.MouseKeysTimeToMax = r.Read2b()
v.MouseKeysMaxSpeed = r.Read2b()
v.MouseKeysCurve = int16(r.Read2b())
v.AccessXOption = r.Read2b() // 10
v.AccessXTimeout = r.Read2b()
v.AccessXTimeoutOptionsMask = r.Read2b()
v.AccessXTimeoutOptionsValues = r.Read2b()
r.ReadPad(2) // 12
v.AccessXTimeoutMask = r.Read4b()
v.AccessXTimeoutValues = r.Read4b()
v.EnabledControls = r.Read4b() // 15
var err error
v.PerKeyRepeat, err = r.ReadBytes(ConstPerKeyBitArraySize)
return err
}
// size: 1 * 4b
type ModDef struct {
// RealMods | VirtualMods mapped to real modifiers
Mask uint8
// real modifier bits
RealMods uint8
// virtual modifier bits
VirtualMods uint16
}
func readModDef(r *x.Reader) (v ModDef) {
v.Mask = r.Read1b()
v.RealMods = r.Read1b()
v.VirtualMods = r.Read2b()
return v
}
func writeModDef(b *x.FixedSizeBuf, v ModDef) {
b.Write1b(v.Mask).
Write1b(v.RealMods).
Write2b(v.VirtualMods)
}
type Controls struct {
MouseKeysDefaultBtn uint8
NumGroups uint8
GroupsWrap uint8
Internal ModDef
IgnoreLock ModDef
EnabledControls uint32
RepeatDelay uint16
RepeatInterval uint16
SlowKeysDelay uint16
DebounceDelay uint16
MouseKeysDelay uint16
MouseKeysInterval uint16
MouseKeysTimeToMax uint16
MouseKeysMaxSpeed uint16
MouseKeysCurve int16
AccessXOption uint16
AccessXTimeout uint16
AccessXTimeoutOptionsMask uint16
AccessXTimeoutOptionsValues uint16
AccessXTimeoutMask uint32
AccessXTimeoutValues uint32
PerKeyRepeat []byte // len 32
}
// #WREQ
func encodeSetControls(deviceSpec DeviceSpec,
affectInternalRealMods, affectIgnoreLockRealMods uint8,
affectInternalVirtualMods, affectIgnoreLockVirtualMods uint16,
affectEnabledControls, changeControls uint32, c *Controls) (b x.RequestBody) {
b.AddBlock(16).
Write2b(uint16(deviceSpec)).
Write1b(affectInternalRealMods).
Write1b(c.Internal.RealMods). // 1
Write1b(affectIgnoreLockRealMods).
Write1b(c.IgnoreLock.RealMods).
Write2b(affectInternalVirtualMods). // 2
Write2b(c.Internal.VirtualMods).
Write2b(affectIgnoreLockVirtualMods). // 3
Write2b(c.IgnoreLock.VirtualMods).
Write1b(c.MouseKeysDefaultBtn).
Write1b(c.GroupsWrap). // 4
Write2b(c.AccessXOption).
WritePad(2). // 5
Write4b(affectEnabledControls).
Write4b(c.EnabledControls).
Write4b(changeControls). // 8
Write2b(c.RepeatDelay).
Write2b(c.RepeatInterval). // 9
Write2b(c.SlowKeysDelay).
Write2b(c.DebounceDelay).
Write2b(c.MouseKeysDelay).
Write2b(c.MouseKeysInterval).
Write2b(c.MouseKeysTimeToMax).
Write2b(c.MouseKeysMaxSpeed).
Write2b(uint16(c.MouseKeysCurve)).
Write2b(c.AccessXTimeout). // 13
Write4b(c.AccessXTimeoutMask).
Write4b(c.AccessXTimeoutValues).
Write2b(c.AccessXTimeoutOptionsMask).
Write2b(c.AccessXTimeoutOptionsValues). // 16
End()
b.AddBytes(c.PerKeyRepeat)
return
}
type GetMapPartOptions struct {
Partial uint16
FirstType uint8
NTypes uint8
FirstKeySym x.Keycode
NKeySyms uint8
FirstKeyAction x.Keycode
NKeyActions uint8
FirstKeyBehavior x.Keycode
NKeyBehavior uint8
VirtualMods uint16
FirstKeyExplicit x.Keycode
NKeyExplicit uint8
FirstModMapKey x.Keycode
NModMapKeys uint8
FirstVModMapKey x.Keycode
NVModMapKeys uint8
}
// #WREQ
func encodeGetMap(deviceSpec DeviceSpec, full uint16, opt *GetMapPartOptions) (b x.RequestBody) {
if opt == nil {
opt = &GetMapPartOptions{}
} else {
if opt.NTypes != 0 || opt.FirstType != 0 {
opt.Partial |= MapPartKeyTypes
}
if opt.NKeySyms != 0 || opt.FirstKeySym != 0 {
opt.Partial |= MapPartKeySyms
}
if opt.NKeyActions != 0 || opt.FirstKeyAction != 0 {
opt.Partial |= MapPartKeyActions
}
if opt.NKeyBehavior != 0 || opt.FirstKeyBehavior != 0 {
opt.Partial |= MapPartKeyBehaviors
}
if opt.NKeyExplicit != 0 || opt.FirstKeyExplicit != 0 {
opt.Partial |= MapPartExplicitComponents
}
if opt.NModMapKeys != 0 || opt.FirstModMapKey != 0 {
opt.Partial |= MapPartModifierMap
}
if opt.NVModMapKeys != 0 || opt.FirstVModMapKey != 0 {
opt.Partial |= MapPartVirtualModMap
}
if opt.VirtualMods != 0 {
opt.Partial |= MapPartVirtualMods
}
}
b.AddBlock(6).
Write2b(uint16(deviceSpec)).
Write2b(full).
Write2b(opt.Partial).
Write1b(opt.FirstType).
Write1b(opt.NTypes). // 2
Write1b(uint8(opt.FirstKeySym)).
Write1b(opt.NKeySyms).
Write1b(uint8(opt.FirstKeyAction)).
Write1b(opt.NKeyActions).
Write1b(uint8(opt.FirstKeyBehavior)).
Write1b(opt.NKeyBehavior).
Write2b(opt.VirtualMods). // 4
Write1b(uint8(opt.FirstKeyExplicit)).
Write1b(opt.NKeyExplicit).
Write1b(uint8(opt.FirstModMapKey)).
Write1b(opt.NVModMapKeys).
Write1b(uint8(opt.FirstVModMapKey)).
Write1b(opt.NVModMapKeys).
WritePad(2). // 6
End()
return
}
type GetMapReply struct {
DeviceID uint8
MinKeyCode x.Keycode
MaxKeyCode x.Keycode
Present uint16
FirstType uint8
NTypes uint8
TotalTypes uint8
FirstKeySym x.Keycode
TotalSyms uint16
NKeySyms uint8
FirstKeyAction x.Keycode
TotalActions uint16
NKeyActions uint8
FirstKeyBehavior x.Keycode
NKeyBehaviors uint8
TotalKeyBehaviors uint8
FirstKeyExplicit x.Keycode
NKeyExplicit uint8
TotalKeyExplicit uint8
FirstModMapKey x.Keycode
NModMapKeys uint8
TotalModMapKeys uint8
FirstVModMapKey x.Keycode
NVModMapKeys uint8
TotalVModMapKeys uint8
VirtualMods uint16
Types []KeyType
Syms []KeySymMap
ActionsCount []uint8
Actions []Action
Behaviors []SetBehavior
VMods []uint8
Explicit []SetExplicit
ModMap []KeyModMap
VModMap []KeyVModMap
}
type KeyType struct {
ModsMask uint8
ModsMods uint8
ModsVMods uint16
NumLevels uint8
NMapEntries uint8
HasPreserve bool
Map []KTMapEntry
Preserve []ModDef
}
type SetKeyType struct {
Mask uint8
RealMods uint8
VirtualMods uint16
NumLevels uint8
NMapEntries uint8
Preserve bool
Entries []KTSetMapEntry
PreserveEntries []KTSetMapEntry
}
func writeSetKeyType(w *x.FixedSizeBuf, v *SetKeyType) {
w.Write1b(v.Mask).
Write1b(v.RealMods).
Write2b(v.VirtualMods).
Write1b(v.NumLevels).
Write1b(v.NMapEntries).
WriteBool(v.Preserve).
WritePad(1) // 2
for i := 0; i < int(v.NMapEntries); i++ {
writeKTSetMapEntry(w, v.Entries[i]) // v.NMapEntries
}
if v.Preserve {
for i := 0; i < int(v.NMapEntries); i++ {
writeKTSetMapEntry(w, v.PreserveEntries[i])
}
}
}
func (v *SetKeyType) sizeIn4b() int {
n := 4 + int(v.NMapEntries)
if v.Preserve {
n += int(v.NMapEntries)
}
return n
}
func readKeyType(r *x.Reader, v *KeyType) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
v.ModsMask = r.Read1b()
v.ModsMods = r.Read1b()
v.ModsVMods = r.Read2b()
v.NumLevels = r.Read1b()
v.NMapEntries = r.Read1b()
v.HasPreserve = r.ReadBool()
r.ReadPad(1) // 2
if v.NMapEntries > 0 {
if !r.RemainAtLeast4b(3 * int(v.NMapEntries)) {
return x.ErrDataLenShort
}
v.Map = make([]KTMapEntry, v.NMapEntries)
for i := 0; i < int(v.NMapEntries); i++ {
readKTMapEntry(r, &v.Map[i])
}
if v.HasPreserve {
v.Preserve = make([]ModDef, v.NMapEntries)
for i := 0; i < int(v.NMapEntries); i++ {
v.Preserve[i] = readModDef(r)
}
}
}
return nil
}
// size: 1 * 4b
type KTSetMapEntry struct {
Level uint8
RealMods uint8
VirtualMods uint16
}
func writeKTSetMapEntry(w *x.FixedSizeBuf, v KTSetMapEntry) {
w.Write1b(v.Level).
Write1b(v.RealMods).
Write2b(v.VirtualMods)
}
// key type map entry, size: 2 * 4b
type KTMapEntry struct {
Active bool
ModsMask uint8
Level uint8
ModsMods uint8
ModsVMods uint16
}
func readKTMapEntry(r *x.Reader, v *KTMapEntry) {
v.Active = r.ReadBool()
v.ModsMask = r.Read1b()
v.Level = r.Read1b()
v.ModsMods = r.Read1b()
v.ModsVMods = r.Read2b()
r.ReadPad(2) // 2
}
type KeySymMap struct {
KtIndex []uint8 // length 4
GroupInfo uint8
Width uint8
NSyms uint16
Syms []x.Keysym
}
func readKeySymMap(r *x.Reader, v *KeySymMap) error {
if !r.RemainAtLeast4b(2) {
return x.ErrDataLenShort
}
v.KtIndex = r.MustReadBytes(4)
v.GroupInfo = r.Read1b()
v.Width = r.Read1b()
v.NSyms = r.Read2b() // 2
if v.NSyms > 0 {
if !r.RemainAtLeast4b(int(v.NSyms)) {
return x.ErrDataLenShort
}
v.Syms = make([]x.Keysym, v.NSyms)
for i := 0; i < int(v.NSyms); i++ {
v.Syms[i] = x.Keysym(r.Read4b())
}
}
return nil
}
func writeKeySymMap(b *x.FixedSizeBuf, v *KeySymMap) {
b.WriteBytes(v.KtIndex).
Write1b(v.GroupInfo).
Write1b(v.Width).
Write2b(v.NSyms)
for _, sym := range v.Syms {
b.Write4b(uint32(sym))
}
}
func (v *KeySymMap) sizeIn4b() int {
return 2 + len(v.Syms)
}
// size: 2 * 4b
type Action interface {
Type() uint8 // TODO: rename ActionType
writeTo(b *x.FixedSizeBuf)
}
var readActionFuncArray = [...]func(r *x.Reader) Action{
readSANoAction, // 0
readSASetMods,
readSALatchMods,
readSALockMods,
readSASetGroup,
readSALatchGroup,
readSALockGroup, // 6
readSAMovePtr,
readSAPtrBtn,
readSALockPtrBtn,
readSASetPtrDflt, // 10
readSAIsoLock,
readSATerminate,
readSASwitchScreen,
readSASetControls,
readSALockControls, // 15
readSAActionMessage,
readSARedirectKey,
readSADeviceBtn,
readSALockDeviceBtn,
readSADeviceValuator, // 20
}
func readAction(r *x.Reader) Action {
type0 := r.Read1b()
data := r.MustReadBytes(7) // 2
dataR := x.NewReaderFromData(data)
if type0 <= SATypeDeviceValuator {
action := readActionFuncArray[type0](dataR)
return action
}
// out of range
return UnknownAction{type0: type0, data: data}
}
func writeAction(b *x.FixedSizeBuf, act Action) {
b.Write1b(act.Type())
act.writeTo(b)
}
// Action NoAction
type SANoAction struct {
}
func (SANoAction) Type() uint8 {
return SATypeNoAction
}
func (SANoAction) writeTo(b *x.FixedSizeBuf) {
b.WritePad(7)
}
func readSANoAction(r *x.Reader) Action {
return SANoAction{}
}
// Action SetMods
type SASetMods struct {
Flags uint8
Mask uint8
RealMods uint8
VMods uint16
}
func (SASetMods) Type() uint8 {
return SATypeSetMods
}
func readSASetMods(r *x.Reader) Action {
var v SASetMods
readSASetModsAux(r, &v)
return v
}
func readSASetModsAux(r *x.Reader, v *SASetMods) {
v.Flags = r.Read1b()
v.Mask = r.Read1b()
v.RealMods = r.Read1b()
vModsHigh := r.Read1b()
vModsLow := r.Read1b()
v.VMods = uint16(vModsHigh)<<8 | uint16(vModsLow)
}
func (v SASetMods) writeTo(b *x.FixedSizeBuf) {
vmodsHigh := uint8(v.VMods >> 8)
vmodsLow := uint8(v.VMods)
b.Write1b(v.Flags).
Write1b(v.Mask).
Write1b(v.RealMods).
Write1b(vmodsHigh).
Write1b(vmodsLow). // 5b
WritePad(2)
}
// Action LatchMods
type SALatchMods SASetMods
func (SALatchMods) Type() uint8 {
return SATypeLatchMods
}
func readSALatchMods(r *x.Reader) Action {
var v SALatchMods
readSASetModsAux(r, (*SASetMods)(&v))
return v
}
func (v SALatchMods) writeTo(b *x.FixedSizeBuf) {
SASetMods(v).writeTo(b)
}
// Action LockMods
type SALockMods SASetMods
func (SALockMods) Type() uint8 {
return SATypeLockMods
}
func readSALockMods(r *x.Reader) Action {
var v SALockMods
readSASetModsAux(r, (*SASetMods)(&v))
return v
}
func (v SALockMods) writeTo(b *x.FixedSizeBuf) {
SASetMods(v).writeTo(b)
}
// Action SetGroup
type SASetGroup struct {
Flags uint8
Group int8
}
func (SASetGroup) Type() uint8 {
return SATypeSetGroup
}
func readSASetGroup(r *x.Reader) Action {
var v SASetGroup
readSASetGroupAux(r, &v)
return v
}
func readSASetGroupAux(r *x.Reader, v *SASetGroup) {
v.Flags = r.Read1b()
v.Group = int8(r.Read1b())
}
func (v SASetGroup) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
Write1b(uint8(v.Group)).
WritePad(5)
}
// Action LatchGroup
type SALatchGroup SASetGroup
func (SALatchGroup) Type() uint8 {
return SATypeLatchGroup
}
func readSALatchGroup(r *x.Reader) Action {
var v SALatchGroup
readSASetGroupAux(r, (*SASetGroup)(&v))
return v
}
func (v SALatchGroup) writeTo(b *x.FixedSizeBuf) {
SASetGroup(v).writeTo(b)
}
// Action LockGroup
type SALockGroup SASetGroup
func (SALockGroup) Type() uint8 {
return SATypeLockGroup
}
func readSALockGroup(r *x.Reader) Action {
var v SALockGroup
readSASetGroupAux(r, (*SASetGroup)(&v))
return v
}
func (v SALockGroup) writeTo(b *x.FixedSizeBuf) {
SASetGroup(v).writeTo(b)
}
// Action MovePtr
type SAMovePtr struct {
Flags uint8
X int16
Y int16
}
func (SAMovePtr) Type() uint8 {
return SATypeMovePtr
}
func readSAMovePtr(r *x.Reader) Action {
var v SAMovePtr
v.Flags = r.Read1b()
xHigh := int8(r.Read1b())
xLow := r.Read1b()
v.X = int16(xHigh)<<8 | int16(xLow)
yHigh := int8(r.Read1b())
yLow := r.Read1b()
v.Y = int16(yHigh)<<8 | int16(yLow)
return v
}
func (v SAMovePtr) writeTo(b *x.FixedSizeBuf) {
xHigh := int8(v.X >> 8)
xLow := uint8(v.X)
yHigh := int8(v.Y >> 8)
yLow := uint8(v.Y)
b.Write1b(v.Flags).
Write1b(uint8(xHigh)).
Write1b(xLow).
Write1b(uint8(yHigh)).
Write1b(yLow). // 5
WritePad(2)
}
// Action PtrBtn
type SAPtrBtn struct {
Flags uint8
Count uint8
Button uint8
}
func (SAPtrBtn) Type() uint8 {
return SATypePtrBtn
}
func readSAPtrBtn(r *x.Reader) Action {
var v SAPtrBtn
v.Flags = r.Read1b()
v.Count = r.Read1b()
v.Button = r.Read1b()
return v
}
func (v SAPtrBtn) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
Write1b(v.Count).
Write1b(v.Button).
WritePad(4)
}
// Action LockPtrBtn
type SALockPtrBtn struct {
Flags uint8
Button uint8
}
func (SALockPtrBtn) Type() uint8 {
return SATypeLockPtrBtn
}
func readSALockPtrBtn(r *x.Reader) Action {
var v SALockPtrBtn
v.Flags = r.Read1b()
r.ReadPad(1)
v.Button = r.Read1b()
return v
}
func (v SALockPtrBtn) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
Write1b(v.Button).
WritePad(5)
}
// Action SetPtrDflt
type SASetPtrDflt struct {
Flags uint8
Affect uint8
Value int8
}
func (SASetPtrDflt) Type() uint8 {
return SATypeSetPtrDflt
}
func readSASetPtrDflt(r *x.Reader) Action {
var v SASetPtrDflt
v.Flags = r.Read1b()
v.Affect = r.Read1b()
v.Value = int8(r.Read1b())
return v
}
func (v SASetPtrDflt) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
Write1b(v.Affect).
Write1b(uint8(v.Value)).
WritePad(4)
}
// Action Iso Lock
type SAIsoLock struct {
Flags uint8
Mask uint8
RealMods uint8
Group int8
Affect uint8
VMods uint16
}
func (SAIsoLock) Type() uint8 {
return SATypeIsoLock
}
func readSAIsoLock(r *x.Reader) Action {
var v SAIsoLock
v.Flags = r.Read1b()
v.Mask = r.Read1b()
v.RealMods = r.Read1b()
v.Group = int8(r.Read1b())
v.Affect = r.Read1b()
vModsHigh := r.Read1b()
vModsLow := r.Read1b()
v.VMods = uint16(vModsHigh)<<8 | uint16(vModsLow)
return v
}
func (v SAIsoLock) writeTo(b *x.FixedSizeBuf) {
vModsHigh := uint8(v.VMods >> 8)
vModsLow := uint8(v.VMods)
b.Write1b(v.Flags).
Write1b(v.Mask).
Write1b(v.RealMods).
Write1b(uint8(v.Group)).
Write1b(v.Affect).
Write1b(vModsHigh).
Write1b(vModsLow) // 7b
}
// Action Terminate
type SATerminate struct {
}
func (SATerminate) Type() uint8 {
return SATypeTerminate
}
func readSATerminate(r *x.Reader) Action {
return SATerminate{}
}
func (SATerminate) writeTo(b *x.FixedSizeBuf) {
b.WritePad(7)
}
// Action Switch Screen
type SASwitchScreen struct {
Flags uint8
NewScreen int8
}
func (SASwitchScreen) Type() uint8 {
return SATypeSwitchScreen
}
func readSASwitchScreen(r *x.Reader) Action {
var v SASwitchScreen
v.Flags = r.Read1b()
v.NewScreen = int8(r.Read1b())
return v
}
func (v SASwitchScreen) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
Write1b(uint8(v.NewScreen)).
WritePad(5)
}
// Action SetControls
type SASetControls struct {
BoolCtrls uint16
}
func (SASetControls) Type() uint8 {
return SATypeSetControls
}
func readSASetControls(r *x.Reader) Action {
var v SASetControls
readSASetControlsAux(r, &v)
return v
}
func readSASetControlsAux(r *x.Reader, v *SASetControls) {
r.ReadPad(3)
boolCtrlsHigh := r.Read1b()
boolCtrlsLow := r.Read1b()
v.BoolCtrls = uint16(boolCtrlsHigh)<<8 | uint16(boolCtrlsLow)
}
func (v SASetControls) writeTo(b *x.FixedSizeBuf) {
boolCtrlsHigh := uint8(v.BoolCtrls >> 8)
boolCtrlsLow := uint8(v.BoolCtrls)
b.WritePad(3).
Write1b(boolCtrlsHigh).
Write1b(boolCtrlsLow).
WritePad(2)
}
// Action LockControls
type SALockControls SASetControls
func (SALockControls) Type() uint8 {
return SATypeLockControls
}
func readSALockControls(r *x.Reader) Action {
var v SALockControls
readSASetControlsAux(r, (*SASetControls)(&v))
return v
}
func (v SALockControls) writeTo(b *x.FixedSizeBuf) {
SASetControls(v).writeTo(b)
}
// Action ActionMessage
type SAActionMessage struct {
Flags uint8
Message []byte // length 6
}
func (SAActionMessage) Type() uint8 {
return SATypeActionMessage
}
func readSAActionMessage(r *x.Reader) Action {
var v SAActionMessage
v.Flags = r.Read1b()
v.Message = r.MustReadBytes(6)
return v
}
func (v SAActionMessage) writeTo(b *x.FixedSizeBuf) {
if len(v.Message) != 6 {
panic("length of message is not 6")
}
b.Write1b(v.Flags).
WriteBytes(v.Message)
}
// Action RedirectKey
type SARedirectKey struct {
NewKey x.Keycode
Mask uint8
RealModifiers uint8
VModsMask uint16
VMods uint16
}
func (SARedirectKey) Type() uint8 {
return SATypeRedirectKey
}
func readSARedirectKey(r *x.Reader) Action {
var v SARedirectKey
v.NewKey = x.Keycode(r.Read1b())
v.Mask = r.Read1b()
v.RealModifiers = r.Read1b()
vModsMaskHigh := r.Read1b()
vModsMaskLow := r.Read1b()
v.VModsMask = uint16(vModsMaskHigh)<<8 | uint16(vModsMaskLow)
vModsHigh := r.Read1b()
vModsLow := r.Read1b()
v.VMods = uint16(vModsHigh)<<8 | uint16(vModsLow)
return v
}
func (v SARedirectKey) writeTo(b *x.FixedSizeBuf) {
vModsMaskHigh := uint8(v.VModsMask >> 8)
vModsMaskLow := uint8(v.VModsMask)
vModsHigh := uint8(v.VMods >> 8)
vModsLow := uint8(v.VMods)
b.Write1b(uint8(v.NewKey)).
Write1b(v.Mask).
Write1b(v.RealModifiers).
Write1b(vModsMaskHigh).
Write1b(vModsMaskLow).
Write1b(vModsHigh).
Write1b(vModsLow) // 7b
}
// Action DeviceBtn
type SADeviceBtn struct {
Flags uint8
Count uint8
Button uint8
Device uint8
}
func (SADeviceBtn) Type() uint8 {
return SATypeDeviceBtn
}
func readSADeviceBtn(r *x.Reader) Action {
var v SADeviceBtn
v.Flags = r.Read1b()
v.Count = r.Read1b()
v.Button = r.Read1b()
v.Device = r.Read1b()
return v
}
func (v SADeviceBtn) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
Write1b(v.Count).
Write1b(v.Button).
Write1b(v.Device).
WritePad(3)
}
// Action LockDeviceBtn
type SALockDeviceBtn struct {
Flags uint8
Button uint8
Device uint8
}
func (SALockDeviceBtn) Type() uint8 {
return SATypeLockDeviceBtn
}
func readSALockDeviceBtn(r *x.Reader) Action {
var v SALockDeviceBtn
v.Flags = r.Read1b()
r.ReadPad(1)
v.Button = r.Read1b()
v.Device = r.Read1b()
return v
}
func (v SALockDeviceBtn) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Flags).
WritePad(1).
Write1b(v.Button).
Write1b(v.Device). // 4b
WritePad(3)
}
// Action DeviceValuator
type SADeviceValuator struct {
Device uint8
Val1What uint8
Val1Index uint8
Val1Value uint8
Val2What uint8
Val2Index uint8
Val2Value uint8
}
func (SADeviceValuator) Type() uint8 {
return SATypeDeviceValuator
}
func readSADeviceValuator(r *x.Reader) Action {
var v SADeviceValuator
v.Device = r.Read1b()
v.Val1What = r.Read1b()
v.Val1Index = r.Read1b()
v.Val1Value = r.Read1b()
v.Val2What = r.Read1b()
v.Val2Index = r.Read1b()
v.Val2Value = r.Read1b()
return v
}
func (v SADeviceValuator) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Device).
Write1b(v.Val1What).
Write1b(v.Val1Index).
Write1b(v.Val1Value).
Write1b(v.Val2What).
Write1b(v.Val2Index).
Write1b(v.Val2Value) // 7b
}
type UnknownAction struct {
type0 uint8
data []byte // length 7
}
func (v UnknownAction) Type() uint8 {
return v.type0
}
func (v UnknownAction) writeTo(b *x.FixedSizeBuf) {
if len(v.data) != 7 {
panic("length of data is not 7")
}
b.WriteBytes(v.data)
}
// size: 1 * 4b
type SetBehavior struct {
Keycode x.Keycode
Behavior Behavior
}
func readSetBehavior(r *x.Reader, v *SetBehavior) {
v.Keycode = x.Keycode(r.Read1b())
v.Behavior = readBehavior(r)
r.ReadPad(1) // 1
}
func writeSetBehavior(b *x.FixedSizeBuf, v SetBehavior) {
b.Write1b(uint8(v.Keycode))
writeBehavior(b, v.Behavior)
b.WritePad(1)
}
// size: 2b
type Behavior interface {
Type() uint8
writeTo(b *x.FixedSizeBuf)
}
func readBehavior(r *x.Reader) Behavior {
type0 := r.Read1b()
data := r.Read1b()
switch type0 {
case BehaviorTypeDefault:
return DefaultBehavior{}
case BehaviorTypeLock:
return LockBehavior{}
case BehaviorTypeRadioGroup:
return RadioGroupBehavior{data}
case BehaviorTypeOverlay1:
return Overlay1Behavior{x.Keycode(data)}
case BehaviorTypeOverlay2:
return Overlay2Behavior{x.Keycode(data)}
case BehaviorTypePermamentLock:
return PermamentLockBehavior{}
case BehaviorTypePermamentRadioGroup:
return PermamentRadioGroupBehavior{data}
case BehaviorTypePermamentOverlay1:
return PermamentOverlay1Behavior{}
case BehaviorTypePermamentOverlay2:
return PermamentOverlay1Behavior{}
default:
return UnknownBehavior{type0, data}
}
}
func writeBehavior(b *x.FixedSizeBuf, v Behavior) {
b.Write1b(v.Type())
v.writeTo(b)
}
type UnknownBehavior struct {
type0 uint8
Data uint8
}
func (v UnknownBehavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Data)
}
func (v UnknownBehavior) Type() uint8 {
return v.type0
}
type DefaultBehavior struct {
}
func (DefaultBehavior) writeTo(b *x.FixedSizeBuf) {
b.WritePad(1)
}
func (DefaultBehavior) Type() uint8 {
return BehaviorTypeDefault
}
type LockBehavior struct {
}
func (LockBehavior) writeTo(b *x.FixedSizeBuf) {
b.WritePad(1)
}
func (LockBehavior) Type() uint8 {
return BehaviorTypeLock
}
type RadioGroupBehavior struct {
Group uint8
}
func (v RadioGroupBehavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Group)
}
func (RadioGroupBehavior) Type() uint8 {
return BehaviorTypeRadioGroup
}
type Overlay1Behavior struct {
Key x.Keycode
}
func (v Overlay1Behavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(uint8(v.Key))
}
func (Overlay1Behavior) Type() uint8 {
return BehaviorTypeOverlay1
}
type Overlay2Behavior Overlay1Behavior
func (v Overlay2Behavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(uint8(v.Key))
}
func (Overlay2Behavior) Type() uint8 {
return BehaviorTypeOverlay2
}
type PermamentLockBehavior LockBehavior
func (PermamentLockBehavior) writeTo(b *x.FixedSizeBuf) {
b.WritePad(1)
}
func (PermamentLockBehavior) Type() uint8 {
return BehaviorTypePermamentLock
}
type PermamentRadioGroupBehavior RadioGroupBehavior
func (v PermamentRadioGroupBehavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(v.Group)
}
func (PermamentRadioGroupBehavior) Type() uint8 {
return BehaviorTypePermamentRadioGroup
}
type PermamentOverlay1Behavior Overlay1Behavior
func (v PermamentOverlay1Behavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(uint8(v.Key))
}
func (PermamentOverlay1Behavior) Type() uint8 {
return BehaviorTypePermamentOverlay1
}
type PermamentOverlay2Behavior Overlay1Behavior
func (v PermamentOverlay2Behavior) writeTo(b *x.FixedSizeBuf) {
b.Write1b(uint8(v.Key))
}
func (PermamentOverlay2Behavior) Type() uint8 {
return BehaviorTypePermamentOverlay2
}
// size: 2b
type SetExplicit struct {
Keycode x.Keycode
Explicit uint8
}
func readSetExplicit(r *x.Reader) SetExplicit {
var v SetExplicit
v.Keycode = x.Keycode(r.Read1b())
v.Explicit = r.Read1b()
return v
}
func writeSetExplicit(b *x.FixedSizeBuf, v SetExplicit) {
b.Write1b(uint8(v.Keycode))
b.Write1b(v.Explicit)
}
// size: 2b
type KeyModMap struct {
Keycode x.Keycode
Mods uint8
}
func readKeyModMap(r *x.Reader) KeyModMap {
var v KeyModMap
v.Keycode = x.Keycode(r.Read1b())
v.Mods = r.Read1b()
return v
}
func writeKeyModMap(b *x.FixedSizeBuf, v KeyModMap) {
b.Write1b(uint8(v.Keycode)).
Write1b(v.Mods)
}
// size: 1 * 4b
type KeyVModMap struct {
Keycode x.Keycode
VMods uint16
}
func readKeyVModMap(r *x.Reader) KeyVModMap {
var v KeyVModMap
v.Keycode = x.Keycode(r.Read1b())
r.ReadPad(1)
v.VMods = r.Read2b()
return v
}
func writeKeyVModMap(b *x.FixedSizeBuf, v KeyVModMap) {
b.Write1b(uint8(v.Keycode)).
WritePad(1).
Write2b(v.VMods)
}
func readGetMapReply(r *x.Reader, v *GetMapReply) error {
if !r.RemainAtLeast4b(10) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
r.ReadPad(2)
v.MinKeyCode = x.Keycode(r.Read1b())
v.MaxKeyCode = x.Keycode(r.Read1b()) // 3
v.Present = r.Read2b()
v.FirstType = r.Read1b()
v.NTypes = r.Read1b()
v.TotalTypes = r.Read1b()
v.FirstKeySym = x.Keycode(r.Read1b())
v.TotalSyms = r.Read2b() // 5
v.NKeySyms = r.Read1b()
v.FirstKeyAction = x.Keycode(r.Read1b())
v.TotalActions = r.Read2b()
v.NKeyActions = r.Read1b()
v.FirstKeyBehavior = x.Keycode(r.Read1b())
v.NKeyBehaviors = r.Read1b()
v.TotalKeyBehaviors = r.Read1b()
v.FirstKeyExplicit = x.Keycode(r.Read1b())
v.NKeyExplicit = r.Read1b()
v.TotalKeyBehaviors = r.Read1b()
v.FirstModMapKey = x.Keycode(r.Read1b()) // 8
v.NModMapKeys = r.Read1b()
v.TotalModMapKeys = r.Read1b()
v.FirstVModMapKey = x.Keycode(r.Read1b())
v.NVModMapKeys = r.Read1b()
v.TotalVModMapKeys = r.Read1b()
r.ReadPad(1)
v.VirtualMods = r.Read2b() // 10
if v.Present&MapPartKeyTypes != 0 && v.NTypes > 0 {
v.Types = make([]KeyType, v.NTypes)
for i := 0; i < int(v.NTypes); i++ {
err := readKeyType(r, &v.Types[i])
if err != nil {
return err
}
}
}
if v.Present&MapPartKeySyms != 0 && v.NKeySyms > 0 {
v.Syms = make([]KeySymMap, v.NKeySyms)
for i := 0; i < int(v.NKeySyms); i++ {
err := readKeySymMap(r, &v.Syms[i])
if err != nil {
return err
}
}
}
if v.Present&MapPartKeyActions != 0 {
if v.NKeyActions > 0 {
var err error
v.ActionsCount, err = r.ReadBytesWithPad(int(v.NKeyActions))
if err != nil {
return err
}
}
if v.TotalActions > 0 {
if !r.RemainAtLeast4b(2 * int(v.TotalActions)) {
return x.ErrDataLenShort
}
v.Actions = make([]Action, v.TotalActions)
for i := 0; i < int(v.TotalActions); i++ {
v.Actions[i] = readAction(r)
}
}
}
if v.Present&MapPartKeyBehaviors != 0 && v.TotalKeyBehaviors > 0 {
if !r.RemainAtLeast4b(int(v.TotalKeyBehaviors)) {
return x.ErrDataLenShort
}
v.Behaviors = make([]SetBehavior, v.TotalKeyBehaviors)
for i := 0; i < int(v.TotalKeyBehaviors); i++ {
readSetBehavior(r, &v.Behaviors[i])
}
}
if v.Present&MapPartVirtualMods != 0 {
length := x.PopCount(int(v.VirtualMods))
if length > 0 {
var err error
v.VMods, err = r.ReadBytesWithPad(length)
if err != nil {
return err
}
}
}
if v.Present&MapPartExplicitComponents != 0 && v.TotalKeyExplicit > 0 {
n := int(v.TotalKeyExplicit) * 2
pad := x.Pad(n)
if !r.RemainAtLeast(n + pad) {
return x.ErrDataLenShort
}
v.Explicit = make([]SetExplicit, v.TotalKeyExplicit)
for i := 0; i < int(v.TotalKeyExplicit); i++ {
v.Explicit[i] = readSetExplicit(r)
}
r.ReadPad(pad)
}
if v.Present&MapPartModifierMap != 0 && v.TotalModMapKeys > 0 {
n := int(v.TotalModMapKeys) * 2
pad := x.Pad(n)
if !r.RemainAtLeast(n + pad) {
return x.ErrDataLenShort
}
v.ModMap = make([]KeyModMap, v.TotalModMapKeys)
for i := 0; i < int(v.TotalModMapKeys); i++ {
v.ModMap[i] = readKeyModMap(r)
}
r.ReadPad(pad)
}
if v.Present&MapPartVirtualModMap != 0 && v.TotalVModMapKeys > 0 {
if !r.RemainAtLeast4b(int(v.TotalVModMapKeys)) {
return x.ErrDataLenShort
}
v.VModMap = make([]KeyVModMap, v.TotalVModMapKeys)
for i := 0; i < int(v.TotalVModMapKeys); i++ {
v.VModMap[i] = readKeyVModMap(r)
}
}
return nil
}
type SetMapValue struct {
MinKeyCode x.Keycode
MaxKeyCode x.Keycode
//Present uint16
FirstType uint8
NTypes uint8 // Types
TotalTypes uint8
FirstKeySym x.Keycode
TotalSyms uint16
NKeySyms uint8 // Syms
FirstKeyAction x.Keycode
TotalActions uint16 // Actions
NKeyActions uint8 // ActionsCount
FirstKeyBehavior x.Keycode
NKeyBehaviors uint8
TotalKeyBehaviors uint8 // Behaviors
FirstKeyExplicit x.Keycode
NKeyExplicit uint8
TotalKeyExplicit uint8 // Explicit
FirstModMapKey x.Keycode
NModMapKeys uint8
TotalModMapKeys uint8 // modMap
FirstVModMapKey x.Keycode
NVModMapKeys uint8
TotalVModMapKeys uint8 // vModMap
VirtualMods uint16 // VMods
Types []SetKeyType
Syms []KeySymMap
ActionsCount []uint8
Actions []Action
Behaviors []SetBehavior
VMods []uint8
Explicit []SetExplicit
ModMap []KeyModMap
VModMap []KeyVModMap
}
// #WREQ
func encodeSetMap(deviceSpec DeviceSpec, flags uint16, m *SetMapValue) (b x.RequestBody) {
var present uint16
if m.NTypes > 0 {
present |= MapPartKeyTypes
}
if m.NKeySyms > 0 {
present |= MapPartKeySyms
}
if m.NKeyActions > 0 || m.TotalActions > 0 {
present |= MapPartKeyActions
}
if m.TotalKeyBehaviors > 0 {
present |= MapPartKeyBehaviors
}
if m.VirtualMods != 0 {
present |= MapPartVirtualMods
}
if m.TotalKeyExplicit > 0 {
present |= MapPartExplicitComponents
}
if m.TotalModMapKeys > 0 {
present |= MapPartModifierMap
}
if m.TotalVModMapKeys > 0 {
present |= MapPartVirtualModMap
}
// block size in 4b
size := 8
for i := 0; i < int(m.NTypes); i++ {
size += m.Types[i].sizeIn4b()
}
for i := 0; i < int(m.NKeySyms); i++ {
size += m.Syms[i].sizeIn4b()
}
size += x.SizeIn4bWithPad(len(m.ActionsCount))
size += 2 * len(m.Actions)
size += len(m.Behaviors)
size += x.SizeIn4bWithPad(len(m.VMods))
size += x.SizeIn4bWithPad(len(m.Explicit) * 2)
size += x.SizeIn4bWithPad(len(m.ModMap) * 2)
size += len(m.VModMap)
b0 := b.AddBlock(size).
Write2b(uint16(deviceSpec)).
Write2b(present).
Write2b(flags).
Write1b(uint8(m.MinKeyCode)).
Write1b(uint8(m.MaxKeyCode)). // 2
Write1b(m.FirstType).
Write1b(m.NTypes).
Write1b(uint8(m.FirstKeySym)).
Write1b(m.NKeySyms). // 3
Write2b(m.TotalSyms).
Write1b(uint8(m.FirstKeyAction)).
Write1b(m.NKeyActions).
Write2b(m.TotalActions).
Write1b(uint8(m.FirstKeyBehavior)).
Write1b(m.NKeyBehaviors). // 5
Write1b(m.TotalKeyBehaviors).
Write1b(uint8(m.FirstKeyExplicit)).
Write1b(m.NKeyExplicit).
Write1b(m.TotalKeyExplicit).
Write1b(uint8(m.FirstModMapKey)).
Write1b(m.NModMapKeys).
Write1b(m.TotalModMapKeys).
Write1b(uint8(m.FirstVModMapKey)). // 7
Write1b(m.NVModMapKeys).
Write1b(m.TotalVModMapKeys).
Write2b(m.VirtualMods) // 8
for i := 0; i < int(m.NTypes); i++ {
writeSetKeyType(b0, &m.Types[i])
}
for i := 0; i < int(m.NKeySyms); i++ {
writeKeySymMap(b0, &m.Syms[i])
}
b0.WriteBytes(m.ActionsCount)
b0.WritePad(x.Pad(len(m.ActionsCount)))
for _, act := range m.Actions {
writeAction(b0, act)
}
for _, b := range m.Behaviors {
writeSetBehavior(b0, b)
}
b0.WriteBytes(m.VMods)
b0.WritePad(x.Pad(len(m.VMods)))
for _, e := range m.Explicit {
writeSetExplicit(b0, e)
}
b0.WritePad(x.Pad(len(m.Explicit) * 2))
for _, m := range m.ModMap {
writeKeyModMap(b0, m)
}
b0.WritePad(x.Pad(len(m.ModMap) * 2))
for _, v := range m.VModMap {
writeKeyVModMap(b0, v)
}
b0.End()
return
}
// #WREQ
func encodeGetCompatMap(deviceSpec DeviceSpec, groups uint8, getAllSI bool,
firstSI, NSI uint16) (b x.RequestBody) {
b.AddBlock(2).
Write2b(uint16(deviceSpec)).
Write1b(groups).
WriteBool(getAllSI).
Write2b(firstSI).
Write2b(NSI).
End()
return
}
type GetCompatMapReply struct {
DeviceID uint8
GroupsRtrn uint8
FirstSIRtrn uint16
NSIRtrn uint16
NTotalSI uint16
SIRtrn []SymInterpret
GroupRtrn []ModDef
}
func readGetCompatMapReply(r *x.Reader, v *GetCompatMapReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.GroupsRtrn = r.Read1b()
r.ReadPad(1)
v.FirstSIRtrn = r.Read2b()
v.NSIRtrn = r.Read2b()
v.NTotalSI = r.Read2b() // 4
r.ReadPad(16) // 8
if v.NSIRtrn > 0 {
if !r.RemainAtLeast4b(4 * int(v.NSIRtrn)) {
return x.ErrDataLenShort
}
v.SIRtrn = make([]SymInterpret, v.NSIRtrn)
for i := 0; i < int(v.NSIRtrn); i++ {
readSymInterpret(r, &v.SIRtrn[i])
}
}
if v.GroupsRtrn > 0 {
length := x.PopCount(int(v.GroupsRtrn))
if !r.RemainAtLeast4b(length) {
return x.ErrDataLenShort
}
v.GroupRtrn = make([]ModDef, length)
for i := 0; i < length; i++ {
v.GroupRtrn[i] = readModDef(r)
}
}
return nil
}
// size: 4 * 4b
type SymInterpret struct {
Sym x.Keysym
Mods uint8
Match uint8
VirtualMod uint8
Flags uint8
Action Action
}
func readSymInterpret(r *x.Reader, v *SymInterpret) {
v.Sym = x.Keysym(r.Read4b())
v.Mods = r.Read1b()
v.Match = r.Read1b()
v.VirtualMod = r.Read1b()
v.Flags = r.Read1b()
v.Action = readAction(r)
}
func writeSymInterpret(b *x.FixedSizeBuf, v *SymInterpret) {
b.Write4b(uint32(v.Sym)).
Write1b(v.Mods).
Write1b(v.Match).
Write1b(v.VirtualMod).
Write1b(v.Flags)
writeAction(b, v.Action)
}
type SetCompatMapValue struct {
RecomputeActions bool
TruncateSI bool
Groups uint8
FirstSI uint16
NSI uint16
SI []SymInterpret
GroupMaps []ModDef
}
// #WREQ
func encodeSetCompatMap(deviceSpec DeviceSpec, v *SetCompatMapValue) (b x.RequestBody) {
v.NSI = uint16(len(v.SI))
b0 := b.AddBlock(3 + 4*len(v.SI)).
Write2b(uint16(deviceSpec)).
WritePad(1).
WriteBool(v.RecomputeActions).
WriteBool(v.TruncateSI).
Write1b(v.Groups).
Write2b(v.FirstSI).
Write2b(v.NSI).
WritePad(2) // 3
for i := 0; i < len(v.SI); i++ {
writeSymInterpret(b0, &v.SI[i])
}
nGroup := x.PopCount(int(v.Groups))
for i := 0; i < nGroup; i++ {
writeModDef(b0, v.GroupMaps[i])
}
b0.End()
return b
}
// #WREQ
func encodeGetIndicatorState(deviceSpec DeviceSpec) (b x.RequestBody) {
b.AddBlock(1).
Write2b(uint16(deviceSpec)).
WritePad(2).
End()
return
}
type GetIndicatorStateReply struct {
DeviceID uint8
State uint32
}
func readGetIndicatorStateReply(r *x.Reader, v *GetIndicatorStateReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.State = r.Read4b()
return nil
}
// #WREQ
func encodeGetIndicatorMap(deviceSpec DeviceSpec, which uint32) (b x.RequestBody) {
b.AddBlock(2).
Write2b(uint16(deviceSpec)).
WritePad(2).
Write4b(which)
return
}
type GetIndicatorMapReply struct {
DeviceID uint8
Which uint32
RealIndicators uint32
NIndicators uint8
Maps []IndicatorMap
}
// size: 3 * 4b
type IndicatorMap struct {
Flags uint8
WhichGroups uint8
Groups uint8
WhichMods uint8
Mods uint8
RealMods uint8
VMods uint16
Ctrls uint32
}
func readIndicatorMap(r *x.Reader, v *IndicatorMap) {
v.Flags = r.Read1b()
v.WhichGroups = r.Read1b()
v.Groups = r.Read1b()
v.WhichMods = r.Read1b()
v.Mods = r.Read1b()
v.RealMods = r.Read1b()
v.VMods = r.Read2b()
v.Ctrls = r.Read4b()
}
func writeIndicatorMap(b *x.FixedSizeBuf, v *IndicatorMap) {
b.Write1b(v.Flags).
Write1b(v.WhichGroups).
Write1b(v.Groups).
Write1b(v.WhichGroups).
Write1b(v.Mods).
Write1b(v.RealMods).
Write2b(v.VMods).
Write4b(v.Ctrls)
}
func readGetIndicatorMapReply(r *x.Reader, v *GetIndicatorMapReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.Which = r.Read4b()
v.RealIndicators = r.Read4b() // 4
v.NIndicators = r.Read1b()
r.ReadPad(15) // 8
mapsLen := x.PopCount(int(v.Which))
if mapsLen > 0 {
if !r.RemainAtLeast4b(3 * mapsLen) {
return x.ErrDataLenShort
}
v.Maps = make([]IndicatorMap, mapsLen)
for i := 0; i < mapsLen; i++ {
readIndicatorMap(r, &v.Maps[i])
}
}
return nil
}
// #WREQ
func encodeSetIndicatorMap(deviceSpec DeviceSpec, which uint32,
maps []IndicatorMap) (b x.RequestBody) {
mapsLen := x.PopCount(int(which))
b0 := b.AddBlock(2 + 3*mapsLen).
Write2b(uint16(deviceSpec)).
WritePad(2).
Write4b(which)
for i := 0; i < mapsLen; i++ {
writeIndicatorMap(b0, &maps[i])
}
b0.End()
return
}
// #WREQ
func encodeGetNamedIndicator(deviceSpec DeviceSpec, ledClass LedClassSpec,
ledID IdSpec, indicator x.Atom) (b x.RequestBody) {
b.AddBlock(3).
Write2b(uint16(deviceSpec)).
Write2b(uint16(ledClass)).
Write2b(uint16(ledID)).
WritePad(2).
Write4b(uint32(indicator)).
End()
return
}
type GetNamedIndicatorReply struct {
DeviceID uint8
Indicator x.Atom
Found bool
On bool
RealIndicator bool
Ndx uint8
Map IndicatorMap
Supported bool
}
func readGetNamedIndicatorReply(r *x.Reader, v *GetNamedIndicatorReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.Indicator = x.Atom(r.Read4b()) // 3
v.Found = r.ReadBool()
v.On = r.ReadBool()
v.RealIndicator = r.ReadBool()
v.Ndx = r.Read1b() // 4
readIndicatorMap(r, &v.Map) // 7
v.Supported = r.ReadBool() // 8
return nil
}
// #WREQ
func encodeSetNamedIndicator(deviceSpec DeviceSpec, ledClass LedClassSpec,
ledID IdSpec, indicator x.Atom, setState, on, setMap, createMap bool,
map0 *IndicatorMap) (b x.RequestBody) {
b.AddBlock(7).
Write2b(uint16(deviceSpec)).
Write2b(uint16(ledClass)).
Write2b(uint16(ledID)).
WritePad(2). // 2
Write4b(uint32(indicator)).
WriteBool(setState).
WriteBool(on).
WriteBool(setMap).
WriteBool(createMap). // 4
WritePad(1).
Write1b(map0.Flags).
Write1b(map0.WhichGroups).
Write1b(map0.Groups). // 5
Write1b(map0.WhichMods).
Write1b(map0.RealMods).
Write2b(map0.VMods).
Write4b(map0.Ctrls). // 7
End()
// NOTE: map0.Mods is not used
return
}
// #WREQ
func encodeGetNames(deviceSpec DeviceSpec, which uint32) (b x.RequestBody) {
b.AddBlock(2).
Write2b(uint16(deviceSpec)).
WritePad(2).
Write4b(which).
End()
return
}
type GetNamesReply struct {
DeviceID uint8
Which uint32
MinKeyCode x.Keycode
MaxKeyCode x.Keycode
NTypes uint8
Groups uint8
VirtualMods uint16
FirstKey x.Keycode
NKeys uint8
Indicators uint32
NRadioGroups uint8
NKeyAliases uint8
NKTLevels uint16
KeycodesName x.Atom
GeometryName x.Atom
SymbolsName x.Atom
PhysSymbolsName x.Atom
TypesName x.Atom
CompatName x.Atom
TypeNames []x.Atom
NLevelsPerType []uint8
KTLevelNames []x.Atom
IndicatorNames []x.Atom
VirtualModNames []x.Atom
GroupNames []x.Atom
KeyNames []string
KeyAliases []KeyAlias
RadioGroupNames []x.Atom
}
// size: 1 * 4b
//type KeyName struct {
// Name []byte // length 4
//}
func readKeyName(r *x.Reader) string {
return bytesToStr(r.MustReadBytes(4))
}
func writeKeyName(b *x.FixedSizeBuf, str string) {
writeStr4b(b, str)
}
func writeStr4b(b *x.FixedSizeBuf, str string) {
if len(str) >= 4 {
b.WriteBytes([]byte(str[:4]))
} else {
b.WriteBytes([]byte(str))
b.WritePad(4 - len(str))
}
}
func bytesToStr(data []byte) string {
idx := bytes.IndexByte(data, 0)
if idx != -1 {
return string(data[:idx])
}
return string(data)
}
// size: 2 * 4b
type KeyAlias struct {
Real string
Alias string
}
func readKeyAlias(r *x.Reader) KeyAlias {
var v KeyAlias
v.Real = bytesToStr(r.MustReadBytes(4))
v.Alias = bytesToStr(r.MustReadBytes(4))
return v
}
func writeKeyAlias(b *x.FixedSizeBuf, v KeyAlias) {
writeStr4b(b, v.Real)
writeStr4b(b, v.Alias)
}
//type KeyAlias struct {
// Real []byte // length 4
// Alias []byte // length 4
//}
func readGetNamesReply(r *x.Reader, v *GetNamesReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.Which = r.Read4b()
v.MinKeyCode = x.Keycode(r.Read1b())
v.MaxKeyCode = x.Keycode(r.Read1b())
v.NTypes = r.Read1b()
v.Groups = r.Read1b() // 4
v.VirtualMods = r.Read2b()
v.FirstKey = x.Keycode(r.Read1b())
v.NKeys = r.Read1b()
v.Indicators = r.Read4b()
v.NRadioGroups = r.Read1b()
v.NKeyAliases = r.Read1b()
v.NKTLevels = r.Read2b()
r.ReadPad(4) // 8
// in 4b
var valueListSize int
if v.Which&NameDetailKeycodes != 0 {
valueListSize++
}
if v.Which&NameDetailGeometry != 0 {
valueListSize++
}
if v.Which&NameDetailSymbols != 0 {
valueListSize++
}
if v.Which&NameDetailPhysSymbols != 0 {
valueListSize++
}
if v.Which&NameDetailTypes != 0 {
valueListSize++
}
if v.Which&NameDetailCompat != 0 {
valueListSize++
}
if v.Which&NameDetailKeyTypeNames != 0 {
valueListSize += int(v.NTypes)
}
if !r.RemainAtLeast4b(valueListSize) {
return x.ErrDataLenShort
}
if v.Which&NameDetailKeycodes != 0 {
v.KeycodesName = x.Atom(r.Read4b())
}
if v.Which&NameDetailGeometry != 0 {
v.GeometryName = x.Atom(r.Read4b())
}
if v.Which&NameDetailSymbols != 0 {
v.SymbolsName = x.Atom(r.Read4b())
}
if v.Which&NameDetailPhysSymbols != 0 {
v.PhysSymbolsName = x.Atom(r.Read4b())
}
if v.Which&NameDetailTypes != 0 {
v.TypesName = x.Atom(r.Read4b())
}
if v.Which&NameDetailCompat != 0 {
v.CompatName = x.Atom(r.Read4b())
}
if v.Which&NameDetailKeyTypeNames != 0 && v.NTypes > 0 {
v.TypeNames = make([]x.Atom, v.NTypes)
for i := 0; i < int(v.NTypes); i++ {
v.TypeNames[i] = x.Atom(r.Read4b())
}
}
if v.Which&NameDetailKtLevelNames != 0 {
var err error
v.NLevelsPerType, err = r.ReadBytesWithPad(int(v.NTypes))
if err != nil {
return err
}
var sum int
for _, value := range v.NLevelsPerType {
sum += int(value)
}
if sum > 0 {
if !r.RemainAtLeast4b(sum) {
return x.ErrDataLenShort
}
v.KTLevelNames = make([]x.Atom, sum)
for i := 0; i < sum; i++ {
v.KTLevelNames[i] = x.Atom(r.Read4b())
}
}
}
valueListSize = 0
if v.Which&NameDetailIndicatorNames != 0 {
valueListSize += x.PopCount(int(v.Indicators))
}
if v.Which&NameDetailVirtualModNames != 0 {
valueListSize += x.PopCount(int(v.VirtualMods))
}
if v.Which&NameDetailGroupNames != 0 {
valueListSize += x.PopCount(int(v.Groups))
}
if v.Which&NameDetailKeyNames != 0 {
valueListSize += int(v.NKeys)
}
if v.Which&NameDetailKeyAliases != 0 {
valueListSize += 2 * int(v.NKeyAliases)
}
if v.Which&NameDetailRgNames != 0 {
valueListSize += int(v.NRadioGroups)
}
if !r.RemainAtLeast4b(valueListSize) {
return x.ErrDataLenShort
}
if v.Which&NameDetailIndicatorNames != 0 {
n := x.PopCount(int(v.Indicators))
if n > 0 {
v.IndicatorNames = make([]x.Atom, n)
for i := 0; i < n; i++ {
v.IndicatorNames[i] = x.Atom(r.Read4b())
}
}
}
if v.Which&NameDetailVirtualModNames != 0 {
n := x.PopCount(int(v.VirtualMods))
if n > 0 {
v.VirtualModNames = make([]x.Atom, n)
for i := 0; i < n; i++ {
v.VirtualModNames[i] = x.Atom(r.Read4b())
}
}
}
if v.Which&NameDetailGroupNames != 0 {
n := x.PopCount(int(v.Groups))
if n > 0 {
v.GroupNames = make([]x.Atom, n)
for i := 0; i < n; i++ {
v.GroupNames[i] = x.Atom(r.Read4b())
}
}
}
if v.Which&NameDetailKeyNames != 0 && v.NKeys > 0 {
v.KeyNames = make([]string, v.NKeys)
for i := 0; i < int(v.NKeys); i++ {
v.KeyNames[i] = readKeyName(r)
}
}
if v.Which&NameDetailKeyAliases != 0 && v.NKeyAliases > 0 {
v.KeyAliases = make([]KeyAlias, v.NKeyAliases)
for i := 0; i < int(v.NKeyAliases); i++ {
v.KeyAliases[i] = readKeyAlias(r)
}
}
if v.Which&NameDetailRgNames != 0 && v.NRadioGroups > 0 {
v.RadioGroupNames = make([]x.Atom, v.NRadioGroups)
for i := 0; i < int(v.NRadioGroups); i++ {
v.RadioGroupNames[i] = x.Atom(r.Read4b())
}
}
return nil
}
type SetNamesRequest struct {
DeviceSpec DeviceSpec
VirtualMods uint16
Which uint32
FirstType uint8
NTypes uint8
FirstKTLevel uint8
NKTLevels uint8
Indicators uint32
Groups uint8
NRadioGroups uint8
FirstKey x.Keycode
NKeys uint8
NKeyAliases uint8
TotalKTLevelNames uint16
KeycodesName x.Atom
GeometryName x.Atom
SymbolsName x.Atom
PhysSymbolsName x.Atom
TypesName x.Atom
CompatName x.Atom
TypeNames []x.Atom
NLevelsPerType []uint8
KTLevelNames []x.Atom
IndicatorNames []x.Atom
VirtualModNames []x.Atom
GroupNames []x.Atom
KeyNames []string
KeyAliases []KeyAlias
RadioGroupNames []x.Atom
}
// #WREQ
func encodeSetNames(r *SetNamesRequest) (b x.RequestBody) {
// in 4b
valueListSize := 0
if r.Which&NameDetailKeycodes != 0 {
valueListSize++
}
if r.Which&NameDetailGeometry != 0 {
valueListSize++
}
if r.Which&NameDetailSymbols != 0 {
valueListSize++
}
if r.Which&NameDetailPhysSymbols != 0 {
valueListSize++
}
if r.Which&NameDetailTypes != 0 {
valueListSize++
}
if r.Which&NameDetailCompat != 0 {
valueListSize++
}
if r.Which&NameDetailKeyTypeNames != 0 {
valueListSize += int(r.NTypes)
}
if r.Which&NameDetailKtLevelNames != 0 {
sum := 0
for _, value := range r.NLevelsPerType {
sum += int(value)
}
valueListSize += x.SizeIn4bWithPad(len(r.NLevelsPerType)) + sum
}
if r.Which&NameDetailIndicatorNames != 0 {
valueListSize += x.PopCount(int(r.Indicators))
}
if r.Which&NameDetailVirtualModNames != 0 {
valueListSize += x.PopCount(int(r.VirtualMods))
}
if r.Which&NameDetailGroupNames != 0 {
valueListSize += x.PopCount(int(r.Groups))
}
if r.Which&NameDetailKeyNames != 0 {
valueListSize += int(r.NKeys)
}
if r.Which&NameDetailKeyAliases != 0 {
valueListSize += 3 * int(r.NKeyAliases)
}
if r.Which&NameDetailRgNames != 0 {
valueListSize += int(r.NRadioGroups)
}
b0 := b.AddBlock(6 + valueListSize).
Write2b(uint16(r.DeviceSpec)).
Write2b(r.VirtualMods).
Write4b(r.Which). // 2
Write1b(r.FirstType).
Write1b(r.NTypes).
Write1b(r.FirstKTLevel).
Write1b(r.NKTLevels). // 3
Write4b(r.Indicators).
Write1b(r.Groups).
Write1b(r.NRadioGroups).
Write1b(uint8(r.FirstKey)).
Write1b(r.NKeys). // 5
Write1b(r.NKeyAliases).
WritePad(1).
Write2b(r.TotalKTLevelNames) // 6
if r.Which&NameDetailKeycodes != 0 {
b0.Write4b(uint32(r.KeycodesName))
}
if r.Which&NameDetailGeometry != 0 {
b0.Write4b(uint32(r.GeometryName))
}
if r.Which&NameDetailSymbols != 0 {
b0.Write4b(uint32(r.SymbolsName))
}
if r.Which&NameDetailPhysSymbols != 0 {
b0.Write4b(uint32(r.PhysSymbolsName))
}
if r.Which&NameDetailTypes != 0 {
b0.Write4b(uint32(r.TypesName))
}
if r.Which&NameDetailCompat != 0 {
b0.Write4b(uint32(r.CompatName))
}
if r.Which&NameDetailKeyTypeNames != 0 {
for i := 0; i < int(r.NTypes); i++ {
b0.Write4b(uint32(r.TypeNames[i]))
}
}
if r.Which&NameDetailKtLevelNames != 0 {
b0.WriteBytes(r.NLevelsPerType)
b0.WritePad(x.Pad(len(r.NLevelsPerType)))
sum := 0
for _, value := range r.NLevelsPerType {
sum += int(value)
}
for i := 0; i < sum; i++ {
b0.Write4b(uint32(r.KTLevelNames[i]))
}
}
if r.Which&NameDetailIndicatorNames != 0 {
n := x.PopCount(int(r.Indicators))
for i := 0; i < n; i++ {
b0.Write4b(uint32(r.IndicatorNames[i]))
}
}
if r.Which&NameDetailVirtualModNames != 0 {
n := x.PopCount(int(r.VirtualMods))
for i := 0; i < n; i++ {
b0.Write4b(uint32(r.VirtualModNames[i]))
}
}
if r.Which&NameDetailGroupNames != 0 {
n := x.PopCount(int(r.Groups))
for i := 0; i < n; i++ {
b0.Write4b(uint32(r.GroupNames[i]))
}
}
if r.Which&NameDetailKeyNames != 0 {
for i := 0; i < int(r.NKeys); i++ {
writeKeyName(b0, r.KeyNames[i])
}
}
if r.Which&NameDetailKeyAliases != 0 {
for i := 0; i < int(r.NKeyAliases); i++ {
writeKeyAlias(b0, r.KeyAliases[i])
}
}
if r.Which&NameDetailRgNames != 0 {
for i := 0; i < int(r.NRadioGroups); i++ {
b0.Write4b(uint32(r.RadioGroupNames[i]))
}
}
return
}
// TODO: GetGeometry
// TODO: SetGeometry
// #WREQ
func encodePerClientFlags(deviceSpec DeviceSpec, change, value, ctrlsToChange,
autoCtrls, autoCtrlsValues uint32) (b x.RequestBody) {
b.AddBlock(6).
Write2b(uint16(deviceSpec)).
WritePad(2).
Write4b(change).
Write4b(value). // 3
Write4b(ctrlsToChange).
Write4b(autoCtrls).
Write4b(autoCtrlsValues). // 6
End()
return
}
type PerClientFlagsReply struct {
DeviceID uint8
Supported uint32
Value uint32
AutoCtrls uint32
AutoCtrlsValues uint32
}
func readPerClientFlagsReply(r *x.Reader, v *PerClientFlagsReply) error {
if !r.RemainAtLeast4b(6) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.Supported = r.Read4b()
v.Value = r.Read4b() // 4
v.AutoCtrls = r.Read4b()
v.AutoCtrlsValues = r.Read4b() // 6
return nil
}
type ComponentNames struct {
KeymapsSpec string
KeycodesSpec string
TypesSpec string
CompatMapSpec string
SymbolsSpec string
GeometrySpec string
}
// #WREQ
func encodeListComponents(deviceSpec DeviceSpec, maxNames uint16,
cn *ComponentNames) (b x.RequestBody) {
keymapsSpec := x.TruncateStr(cn.KeymapsSpec, math.MaxUint8)
keycodesSpec := x.TruncateStr(cn.KeycodesSpec, math.MaxUint8)
typesSpec := x.TruncateStr(cn.TypesSpec, math.MaxUint8)
compatMapSpec := x.TruncateStr(cn.CompatMapSpec, math.MaxUint8)
symbolsSpec := x.TruncateStr(cn.SymbolsSpec, math.MaxUint8)
geometrySpec := x.TruncateStr(cn.GeometrySpec, math.MaxUint8)
specsLen := 6 +
len(keymapsSpec) + len(keycodesSpec) + len(typesSpec) +
len(compatMapSpec) + len(symbolsSpec) + len(geometrySpec)
b.AddBlock(1 + x.SizeIn4bWithPad(specsLen)).
Write2b(uint16(deviceSpec)).
Write2b(maxNames).
Write1b(uint8(len(keymapsSpec))).
WriteString(keymapsSpec).
Write1b(uint8(len(keycodesSpec))).
WriteString(keycodesSpec).
Write1b(uint8(len(typesSpec))).
WriteString(typesSpec).
Write1b(uint8(len(compatMapSpec))).
WriteString(compatMapSpec).
Write1b(uint8(len(symbolsSpec))).
WriteString(symbolsSpec).
Write1b(uint8(len(geometrySpec))).
WriteString(geometrySpec).
WritePad(x.Pad(specsLen)).
End()
return
}
type ListComponentsReply struct {
DeviceID uint8
NKeymaps uint16
NKeycodes uint16
NTypes uint16
NCompatMaps uint16
NSymbols uint16
NGeometries uint16
Extra uint16
Keymaps []int
Keycodes []int
Types []int
CompatMaps []int
Symbols []int
Geometries []int
}
func readListComponentsReply(r *x.Reader, v *ListComponentsReply) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.NKeymaps = r.Read2b()
v.NKeycodes = r.Read2b()
v.NTypes = r.Read2b()
v.NCompatMaps = r.Read2b()
v.NSymbols = r.Read2b()
v.NGeometries = r.Read2b() // 5
v.Extra = r.Read2b()
r.ReadPad(10) // 8
// TODO:
return nil
}
// TODO: GetKbdByName
// #WREQ
func encodeGetDeviceInfo(deviceSpec DeviceSpec, wanted uint16, allButtons bool,
FirstButton, nButtons uint8, ledClass LedClassSpec, ledID IdSpec) (b x.RequestBody) {
b.AddBlock(3).
Write2b(uint16(deviceSpec)).
Write2b(wanted).
WriteBool(allButtons).
Write1b(FirstButton).
Write1b(nButtons).
WritePad(1). // 2
Write2b(uint16(ledClass)).
Write2b(uint16(ledID)). // 3
End()
return
}
type GetDeviceInfoReply struct {
DeviceID uint8
Present uint16
Supported uint16
Unsupported uint16
NDeviceLedFBs uint16
FirstBtnWanted uint8
NBtnsWanted uint8
FirstBtnRtrn uint8
NBtnsRtrn uint8
TotalBtns uint8
HasOwnState bool
DfltKbdFB uint16
DfltLedFB uint16
DevType x.Atom
NameLen uint16
Name string
BtnActions []Action
Leds []DeviceLedInfo
}
type DeviceLedInfo struct {
LedClass LedClassSpec
LedID IdSpec
NamesPresent uint32
MapsPresent uint32
PhysIndicators uint32
State uint32
Names []x.Atom
Maps []IndicatorMap
}
func readDeviceLedInfo(r *x.Reader, v *DeviceLedInfo) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
v.LedClass = LedClassSpec(r.Read2b())
v.LedID = IdSpec(r.Read2b())
v.NamesPresent = r.Read4b()
v.MapsPresent = r.Read4b()
v.PhysIndicators = r.Read4b()
v.State = r.Read4b() // 5
if v.NamesPresent != 0 {
n := x.PopCount(int(v.NamesPresent))
if !r.RemainAtLeast4b(n) {
return x.ErrDataLenShort
}
v.Names = make([]x.Atom, n)
for i := 0; i < n; i++ {
v.Names[i] = x.Atom(r.Read4b())
}
}
if v.MapsPresent != 0 {
n := x.PopCount(int(v.MapsPresent))
if !r.RemainAtLeast4b(3 * n) {
return x.ErrDataLenShort
}
v.Maps = make([]IndicatorMap, n)
for i := 0; i < n; i++ {
readIndicatorMap(r, &v.Maps[i])
}
}
return nil
}
func (v *DeviceLedInfo) sizeIn4b() int {
return 5 + x.PopCount(int(v.NamesPresent)) + 3*x.PopCount(int(v.MapsPresent))
}
func writeDeviceLedInfo(b *x.FixedSizeBuf, v *DeviceLedInfo) {
b.Write2b(uint16(v.LedClass)).
Write2b(uint16(v.LedID)). // 1
Write4b(v.NamesPresent).
Write4b(v.MapsPresent).
Write4b(v.PhysIndicators).
Write4b(v.State) // 5
if v.NamesPresent != 0 {
n := x.PopCount(int(v.NamesPresent))
for i := 0; i < n; i++ {
b.Write4b(uint32(v.Names[i]))
}
}
if v.MapsPresent != 0 {
n := x.PopCount(int(v.MapsPresent))
for i := 0; i < n; i++ {
writeIndicatorMap(b, &v.Maps[i])
}
}
}
func readGetDeviceInfoReply(r *x.Reader, v *GetDeviceInfoReply) error {
if !r.RemainAtLeast(34) {
return x.ErrDataLenShort
}
v.DeviceID, _ = r.ReadReplyHeader()
v.Present = r.Read2b()
v.Supported = r.Read2b()
v.Unsupported = r.Read2b()
v.NDeviceLedFBs = r.Read2b() // 4
v.FirstBtnWanted = r.Read1b()
v.NBtnsWanted = r.Read1b()
v.FirstBtnRtrn = r.Read1b()
v.NBtnsRtrn = r.Read1b()
v.TotalBtns = r.Read1b()
v.HasOwnState = r.ReadBool()
v.DfltKbdFB = r.Read2b() // 6
v.DfltLedFB = r.Read2b()
r.ReadPad(2)
v.DevType = x.Atom(r.Read4b()) // 8
v.NameLen = r.Read2b() // 34b
var err error
v.Name, err = r.ReadStrWithPad(int(v.NameLen))
if err != nil {
return err
}
if v.NBtnsRtrn > 0 {
if !r.RemainAtLeast4b(2 * int(v.NBtnsRtrn)) {
return x.ErrDataLenShort
}
v.BtnActions = make([]Action, v.NBtnsRtrn)
for i := 0; i < int(v.NBtnsRtrn); i++ {
v.BtnActions[i] = readAction(r)
}
}
if v.NDeviceLedFBs > 0 {
v.Leds = make([]DeviceLedInfo, v.NDeviceLedFBs)
for i := 0; i < int(v.NDeviceLedFBs); i++ {
err = readDeviceLedInfo(r, &v.Leds[i])
if err != nil {
return err
}
}
}
return nil
}
// #WREQ
func encodeSetDeviceInfo(deviceSpec DeviceSpec, firstBtn uint8,
change uint16, btnActions []Action, leds []DeviceLedInfo) (b x.RequestBody) {
var nBtns uint8
if len(btnActions) > math.MaxUint8 {
nBtns = math.MaxUint8
btnActions = btnActions[:math.MaxUint8]
}
var nDeviceLedFB uint16
if len(leds) > math.MaxUint16 {
nDeviceLedFB = math.MaxUint16
leds = leds[:math.MaxUint16]
}
ledsSize := 0
for i := 0; i < len(leds); i++ {
ledsSize += leds[i].sizeIn4b()
}
b0 := b.AddBlock(2 + 2*int(nBtns) + ledsSize).
Write2b(uint16(deviceSpec)).
Write1b(firstBtn).
Write1b(nBtns).
Write2b(change).
Write2b(nDeviceLedFB) // 2
for _, a := range btnActions {
writeAction(b0, a)
}
for i := 0; i < len(leds); i++ {
writeDeviceLedInfo(b0, &leds[i])
}
return
}
// #WREQ
func encodeSetDebuggingFlags(affectFlags, flags, affectCtrls, ctrls uint32,
message string) (b x.RequestBody) {
message = x.TruncateStr(message, math.MaxUint16)
msgLength := len(message)
b.AddBlock(5 + x.SizeIn4bWithPad(msgLength)).
Write2b(uint16(msgLength)).
WritePad(2).
Write4b(affectCtrls). // 2
Write4b(flags).
Write4b(affectCtrls).
Write4b(ctrls). // 5
WriteString(message).
WritePad(x.Pad(msgLength)).
End()
return
}
type SetDebuggingFlagsReply struct {
CurrentFlags uint32
CurrentCtrls uint32
SupportedFlags uint32
SupportedCtrls uint32
}
func readSetDebuggingFlagsReply(r *x.Reader, v *SetDebuggingFlagsReply) error {
if !r.RemainAtLeast4b(6) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.CurrentFlags = r.Read4b() // 3
v.CurrentCtrls = r.Read4b()
v.SupportedFlags = r.Read4b()
v.SupportedCtrls = r.Read4b() // 6
return nil
}
go-x11-client-1.0.2/ext/xkb/xkb_event.go 0000664 0000000 0000000 00000021254 14607133730 0017712 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xkb
import "github.com/linuxdeepin/go-x11-client"
// size: 9b
type eventHeader struct {
XkbType uint8
Sequence uint16
Time x.Timestamp
DeviceID uint8
}
func readEventHeader(r *x.Reader, v *eventHeader) {
v.XkbType, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.DeviceID = r.Read1b()
}
type NewKeyboardNotifyEvent struct {
eventHeader
OldDeviceID uint8
MinKeyCode x.Keycode
MaxKeyCode x.Keycode
OldMinKeyCode x.Keycode
OldMaxKeyCode x.Keycode
RequestMajor uint8
RequestMinor uint8
Changed uint16
}
func readNewKeyboardNotifyEvent(r *x.Reader, v *NewKeyboardNotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.OldDeviceID = r.Read1b()
v.MinKeyCode = x.Keycode(r.Read1b())
v.MaxKeyCode = x.Keycode(r.Read1b()) // 3
v.OldMinKeyCode = x.Keycode(r.Read1b())
v.OldMaxKeyCode = x.Keycode(r.Read1b())
v.RequestMajor = r.Read1b()
v.RequestMinor = r.Read1b()
v.Changed = r.Read2b() // 5
return nil
}
type MapNotifyEvent struct {
eventHeader
PtrBtnActions uint8
Changed uint16
MinKeyCode x.Keycode
MaxKeyCode x.Keycode
FirstType uint8
NTypes uint8
FirstKeySym x.Keycode
NKeySyms uint8
FirstKeyAct x.Keycode
NKeyActs uint8
FirstKeyBehavior x.Keycode
NKeyBehavior uint8
FirstKeyExplicit x.Keycode
NKeyExplicit uint8
FirstModMapKey x.Keycode
NModMapKeys uint8
FirstVModMapKey x.Keycode
NVModMapKeys uint8
VirtualMods uint16
}
func readMapNotifyEvent(r *x.Reader, v *MapNotifyEvent) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.PtrBtnActions = r.Read1b()
v.Changed = r.Read2b()
v.MinKeyCode = x.Keycode(r.Read1b()) // 3
v.MaxKeyCode = x.Keycode(r.Read1b())
v.FirstType = r.Read1b()
v.NTypes = r.Read1b()
v.FirstKeySym = x.Keycode(r.Read1b())
v.NKeySyms = r.Read1b()
v.FirstKeyAct = x.Keycode(r.Read1b())
v.NKeyActs = r.Read1b()
v.FirstKeyBehavior = x.Keycode(r.Read1b())
v.NKeyBehavior = r.Read1b()
v.FirstKeyExplicit = x.Keycode(r.Read1b())
v.NKeyExplicit = r.Read1b()
v.FirstModMapKey = x.Keycode(r.Read1b())
v.NModMapKeys = r.Read1b()
v.FirstVModMapKey = x.Keycode(r.Read1b())
v.NVModMapKeys = r.Read1b()
v.VirtualMods = r.Read2b() // 7
return nil
}
type StateNotifyEvent struct {
eventHeader
Mods uint8
BaseMods uint8
LatchedMods uint8
LockedMods uint8
Group uint8
BaseGroup int16
LatchedGroup int16
LockedGroup uint8
CompatState uint8
GrabMods uint8
CompatGrabMods uint8
LookupMods uint8
CompatLookupMods uint8
PtrBtnState uint16
Changed uint16
Keycode x.Keycode
EventType uint8
RequestMajor uint8
RequestMinor uint8
}
func readStateNotifyEvent(r *x.Reader, v *StateNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.Mods = r.Read1b()
v.BaseMods = r.Read1b()
v.LatchedMods = r.Read1b() // 3
v.LockedMods = r.Read1b()
v.Group = r.Read1b()
v.BaseGroup = int16(r.Read2b())
v.LatchedGroup = int16(r.Read2b())
v.LockedGroup = r.Read1b()
v.CompatState = r.Read1b()
v.GrabMods = r.Read1b()
v.CompatGrabMods = r.Read1b()
v.LookupMods = r.Read1b()
v.CompatLookupMods = r.Read1b()
v.PtrBtnState = r.Read2b()
v.Changed = r.Read2b()
v.Keycode = x.Keycode(r.Read1b())
v.EventType = r.Read1b()
v.RequestMajor = r.Read1b()
v.RequestMinor = r.Read1b() // 8
return nil
}
type ControlsNotifyEvent struct {
eventHeader
NumGroups uint8
ChangedControls uint32
EnabledControls uint32
EnabledControlChanges uint32
Keycode x.Keycode
EventType uint8
RequestMajor uint8
RequestMinor uint8
}
func readControlsNotifyEvent(r *x.Reader, v *ControlsNotifyEvent) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.NumGroups = r.Read1b()
r.ReadPad(2) // 3
v.ChangedControls = r.Read4b()
v.EnabledControls = r.Read4b()
v.EnabledControlChanges = r.Read4b()
v.Keycode = x.Keycode(r.Read1b())
v.EventType = r.Read1b()
v.RequestMajor = r.Read1b()
v.RequestMinor = r.Read1b() // 7
return nil
}
type IndicatorStateNotifyEvent struct {
eventHeader
State uint32
StateChanged uint32
}
func readIndicatorStateNotifyEvent(r *x.Reader, v *IndicatorStateNotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
r.ReadPad(3) // 3
v.State = r.Read4b()
v.StateChanged = r.Read4b() // 5
return nil
}
type IndicatorMapNotifyEvent struct {
eventHeader
State uint32
MapChanged uint32
}
func readIndicatorMapNotifyEvent(r *x.Reader, v *IndicatorMapNotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
r.ReadPad(3) // 3
v.State = r.Read4b()
v.MapChanged = r.Read4b() // 5
return nil
}
type NamesNotifyEvent struct {
eventHeader
Changed uint16
FirstType uint8
NTypes uint8
FirstLevelName uint8
NLevelNames uint8
NRadioGroups uint8
NKeyAliases uint8
ChangedGroupNames uint8
ChangedVirtualMods uint16
FirstKey x.Keycode
NKeys uint8
ChangedIndicators uint32
}
func readNamesNotifyEvent(r *x.Reader, v *NamesNotifyEvent) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
r.ReadPad(1)
v.Changed = r.Read2b() // 3
v.FirstType = r.Read1b()
v.NTypes = r.Read1b()
v.FirstLevelName = r.Read1b()
v.NLevelNames = r.Read1b()
r.ReadPad(1)
v.NRadioGroups = r.Read1b()
v.NKeyAliases = r.Read1b()
v.ChangedGroupNames = r.Read1b()
v.ChangedVirtualMods = r.Read2b()
v.FirstKey = x.Keycode(r.Read1b())
v.NKeys = r.Read1b()
v.ChangedIndicators = r.Read4b() // 7
return nil
}
type CompatMapNotifyEvent struct {
eventHeader
ChangedGroup uint8
FirstSI uint16
NSI uint16
NTotalSI uint16
}
func readCompatMapNotifyEvent(r *x.Reader, v *CompatMapNotifyEvent) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.ChangedGroup = r.Read1b()
v.FirstSI = r.Read2b() // 3
v.NSI = r.Read2b()
v.NTotalSI = r.Read2b()
return nil
}
type BellNotifyEvent struct {
eventHeader
BellClass uint8
BellID uint8
Percent uint8
Pitch uint16
Duration uint16
Name x.Atom
Window x.Window
EventOnly bool
}
func readBellNotifyEvent(r *x.Reader, v *BellNotifyEvent) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.BellClass = r.Read1b()
v.BellID = r.Read1b()
v.Percent = r.Read1b() // 3
v.Pitch = r.Read2b()
v.Duration = r.Read2b()
v.Name = x.Atom(r.Read4b())
v.Window = x.Window(r.Read4b())
v.EventOnly = r.ReadBool() // 7
return nil
}
type ActionMessageEvent struct {
eventHeader
Keycode x.Keycode
Press bool
KeyEventFollows bool
Mods uint8
Group uint8
Message string
}
func readActionMessageEvent(r *x.Reader, v *ActionMessageEvent) error {
if !r.RemainAtLeast(22) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.Keycode = x.Keycode(r.Read1b())
v.Press = r.ReadBool()
v.KeyEventFollows = r.ReadBool() // 3
v.Mods = r.Read1b()
v.Group = r.Read1b()
msg := r.MustReadBytes(8)
v.Message = bytesToStr(msg) // 22b
return nil
}
type AccessXNotifyEvent struct {
eventHeader
Keycode x.Keycode
Detail uint16
SlowKeysDelay uint16
DebounceDelay uint16
}
func readAccessXNotifyEvent(r *x.Reader, v *AccessXNotifyEvent) error {
if !r.RemainAtLeast4b(4) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
v.Keycode = x.Keycode(r.Read1b())
v.Detail = r.Read2b() // 3
v.SlowKeysDelay = r.Read2b()
v.DebounceDelay = r.Read2b() // 4
return nil
}
type ExtensionDeviceNotifyEvent struct {
eventHeader
Reason uint16
LedClass uint16
LedID uint16
LedsDefined uint32
LedState uint32
FirstButton uint8
NButtons uint8
Supported uint16
Unsupported uint16
}
func readExtensionDeviceNotifyEvent(r *x.Reader, v *ExtensionDeviceNotifyEvent) error {
if !r.RemainAtLeast4b(8) {
return x.ErrDataLenShort
}
readEventHeader(r, &v.eventHeader)
r.ReadPad(1)
v.Reason = r.Read2b() // 3
v.LedClass = r.Read2b()
v.LedID = r.Read2b()
v.LedsDefined = r.Read4b()
v.LedState = r.Read4b()
v.FirstButton = r.Read1b()
v.NButtons = r.Read1b()
v.Supported = r.Read2b()
v.Unsupported = r.Read2b() // 8
return nil
}
go-x11-client-1.0.2/ext/xkb/xkb_req_auto.go 0000664 0000000 0000000 00000042715 14607133730 0020415 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package xkb
import x "github.com/linuxdeepin/go-x11-client"
func UseExtension(conn *x.Conn, wantedMajor, wantedMinor uint16) UseExtensionCookie {
body := encodeUseExtension(wantedMajor, wantedMinor)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: UseExtensionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return UseExtensionCookie(seq)
}
func (cookie UseExtensionCookie) Reply(conn *x.Conn) (*UseExtensionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply UseExtensionReply
err = readUseExtensionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SelectEvents(conn *x.Conn, deviceSpec DeviceSpec, options ...SelectOption) {
body := encodeSelectEvents(deviceSpec, options...)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectEventsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SelectEventsChecked(conn *x.Conn, deviceSpec DeviceSpec, options ...SelectOption) x.VoidCookie {
body := encodeSelectEvents(deviceSpec, options...)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SelectEventsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Bell(conn *x.Conn, deviceSpec DeviceSpec, bellClass BellClassSpec, bellID IdSpec, percent int8, forceSound, eventOnly bool, pitch, duration int16, name x.Atom, window x.Window) {
body := encodeBell(deviceSpec, bellClass, bellID, percent, forceSound, eventOnly, pitch, duration, name, window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: BellOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func BellChecked(conn *x.Conn, deviceSpec DeviceSpec, bellClass BellClassSpec, bellID IdSpec, percent int8, forceSound, eventOnly bool, pitch, duration int16, name x.Atom, window x.Window) x.VoidCookie {
body := encodeBell(deviceSpec, bellClass, bellID, percent, forceSound, eventOnly, pitch, duration, name, window)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: BellOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetState(conn *x.Conn, deviceSpec DeviceSpec) GetStateCookie {
body := encodeGetState(deviceSpec)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetStateOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetStateCookie(seq)
}
func (cookie GetStateCookie) Reply(conn *x.Conn) (*GetStateReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetStateReply
err = readGetStateReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func LatchLockState(conn *x.Conn, deviceSpec DeviceSpec, affectModLocks, modLocks uint8, lockGroup bool, groupLock, affectModLatches, modLatches uint8, latchGroup bool, groupLatch uint16) {
body := encodeLatchLockState(deviceSpec, affectModLocks, modLocks, lockGroup, groupLock, affectModLatches, modLatches, latchGroup, groupLatch)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: LatchLockStateOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func LatchLockStateChecked(conn *x.Conn, deviceSpec DeviceSpec, affectModLocks, modLocks uint8, lockGroup bool, groupLock, affectModLatches, modLatches uint8, latchGroup bool, groupLatch uint16) x.VoidCookie {
body := encodeLatchLockState(deviceSpec, affectModLocks, modLocks, lockGroup, groupLock, affectModLatches, modLatches, latchGroup, groupLatch)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: LatchLockStateOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetControls(conn *x.Conn, deviceSpec DeviceSpec) GetControlsCookie {
body := encodeGetControls(deviceSpec)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetControlsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetControlsCookie(seq)
}
func (cookie GetControlsCookie) Reply(conn *x.Conn) (*GetControlsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetControlsReply
err = readGetControlsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetControls(conn *x.Conn, deviceSpec DeviceSpec, affectInternalRealMods, affectIgnoreLockRealMods uint8, affectInternalVirtualMods, affectIgnoreLockVirtualMods uint16, affectEnabledControls, changeControls uint32, c *Controls) {
body := encodeSetControls(deviceSpec, affectInternalRealMods, affectIgnoreLockRealMods, affectInternalVirtualMods, affectIgnoreLockVirtualMods, affectEnabledControls, changeControls, c)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetControlsOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetControlsChecked(conn *x.Conn, deviceSpec DeviceSpec, affectInternalRealMods, affectIgnoreLockRealMods uint8, affectInternalVirtualMods, affectIgnoreLockVirtualMods uint16, affectEnabledControls, changeControls uint32, c *Controls) x.VoidCookie {
body := encodeSetControls(deviceSpec, affectInternalRealMods, affectIgnoreLockRealMods, affectInternalVirtualMods, affectIgnoreLockVirtualMods, affectEnabledControls, changeControls, c)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetControlsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetMap(conn *x.Conn, deviceSpec DeviceSpec, full uint16, opt *GetMapPartOptions) GetMapCookie {
body := encodeGetMap(deviceSpec, full, opt)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetMapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetMapCookie(seq)
}
func (cookie GetMapCookie) Reply(conn *x.Conn) (*GetMapReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetMapReply
err = readGetMapReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetMap(conn *x.Conn, deviceSpec DeviceSpec, flags uint16, m *SetMapValue) {
body := encodeSetMap(deviceSpec, flags, m)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetMapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetMapChecked(conn *x.Conn, deviceSpec DeviceSpec, flags uint16, m *SetMapValue) x.VoidCookie {
body := encodeSetMap(deviceSpec, flags, m)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetMapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetCompatMap(conn *x.Conn, deviceSpec DeviceSpec, groups uint8, getAllSI bool, firstSI, NSI uint16) GetCompatMapCookie {
body := encodeGetCompatMap(deviceSpec, groups, getAllSI, firstSI, NSI)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetCompatMapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetCompatMapCookie(seq)
}
func (cookie GetCompatMapCookie) Reply(conn *x.Conn) (*GetCompatMapReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetCompatMapReply
err = readGetCompatMapReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetCompatMap(conn *x.Conn, deviceSpec DeviceSpec, v *SetCompatMapValue) {
body := encodeSetCompatMap(deviceSpec, v)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCompatMapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetCompatMapChecked(conn *x.Conn, deviceSpec DeviceSpec, v *SetCompatMapValue) x.VoidCookie {
body := encodeSetCompatMap(deviceSpec, v)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetCompatMapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetIndicatorState(conn *x.Conn, deviceSpec DeviceSpec) GetIndicatorStateCookie {
body := encodeGetIndicatorState(deviceSpec)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetIndicatorStateOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetIndicatorStateCookie(seq)
}
func (cookie GetIndicatorStateCookie) Reply(conn *x.Conn) (*GetIndicatorStateReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetIndicatorStateReply
err = readGetIndicatorStateReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetIndicatorMap(conn *x.Conn, deviceSpec DeviceSpec, which uint32) GetIndicatorMapCookie {
body := encodeGetIndicatorMap(deviceSpec, which)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetIndicatorMapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetIndicatorMapCookie(seq)
}
func (cookie GetIndicatorMapCookie) Reply(conn *x.Conn) (*GetIndicatorMapReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetIndicatorMapReply
err = readGetIndicatorMapReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetIndicatorMap(conn *x.Conn, deviceSpec DeviceSpec, which uint32, maps []IndicatorMap) {
body := encodeSetIndicatorMap(deviceSpec, which, maps)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetIndicatorMapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetIndicatorMapChecked(conn *x.Conn, deviceSpec DeviceSpec, which uint32, maps []IndicatorMap) x.VoidCookie {
body := encodeSetIndicatorMap(deviceSpec, which, maps)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetIndicatorMapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetNamedIndicator(conn *x.Conn, deviceSpec DeviceSpec, ledClass LedClassSpec, ledID IdSpec, indicator x.Atom) GetNamedIndicatorCookie {
body := encodeGetNamedIndicator(deviceSpec, ledClass, ledID, indicator)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetNamedIndicatorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetNamedIndicatorCookie(seq)
}
func (cookie GetNamedIndicatorCookie) Reply(conn *x.Conn) (*GetNamedIndicatorReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetNamedIndicatorReply
err = readGetNamedIndicatorReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetNamedIndicator(conn *x.Conn, deviceSpec DeviceSpec, ledClass LedClassSpec, ledID IdSpec, indicator x.Atom, setState, on, setMap, createMap bool, map0 *IndicatorMap) {
body := encodeSetNamedIndicator(deviceSpec, ledClass, ledID, indicator, setState, on, setMap, createMap, map0)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetNamedIndicatorOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetNamedIndicatorChecked(conn *x.Conn, deviceSpec DeviceSpec, ledClass LedClassSpec, ledID IdSpec, indicator x.Atom, setState, on, setMap, createMap bool, map0 *IndicatorMap) x.VoidCookie {
body := encodeSetNamedIndicator(deviceSpec, ledClass, ledID, indicator, setState, on, setMap, createMap, map0)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetNamedIndicatorOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetNames(conn *x.Conn, deviceSpec DeviceSpec, which uint32) GetNamesCookie {
body := encodeGetNames(deviceSpec, which)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetNamesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetNamesCookie(seq)
}
func (cookie GetNamesCookie) Reply(conn *x.Conn) (*GetNamesReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetNamesReply
err = readGetNamesReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetNames(conn *x.Conn, r *SetNamesRequest) {
body := encodeSetNames(r)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetNamesOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetNamesChecked(conn *x.Conn, r *SetNamesRequest) x.VoidCookie {
body := encodeSetNames(r)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetNamesOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func PerClientFlags(conn *x.Conn, deviceSpec DeviceSpec, change, value, ctrlsToChange, autoCtrls, autoCtrlsValues uint32) PerClientFlagsCookie {
body := encodePerClientFlags(deviceSpec, change, value, ctrlsToChange, autoCtrls, autoCtrlsValues)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: PerClientFlagsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return PerClientFlagsCookie(seq)
}
func (cookie PerClientFlagsCookie) Reply(conn *x.Conn) (*PerClientFlagsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply PerClientFlagsReply
err = readPerClientFlagsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func ListComponents(conn *x.Conn, deviceSpec DeviceSpec, maxNames uint16, cn *ComponentNames) ListComponentsCookie {
body := encodeListComponents(deviceSpec, maxNames, cn)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: ListComponentsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return ListComponentsCookie(seq)
}
func (cookie ListComponentsCookie) Reply(conn *x.Conn) (*ListComponentsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply ListComponentsReply
err = readListComponentsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func GetDeviceInfo(conn *x.Conn, deviceSpec DeviceSpec, wanted uint16, allButtons bool, FirstButton, nButtons uint8, ledClass LedClassSpec, ledID IdSpec) GetDeviceInfoCookie {
body := encodeGetDeviceInfo(deviceSpec, wanted, allButtons, FirstButton, nButtons, ledClass, ledID)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetDeviceInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetDeviceInfoCookie(seq)
}
func (cookie GetDeviceInfoCookie) Reply(conn *x.Conn) (*GetDeviceInfoReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetDeviceInfoReply
err = readGetDeviceInfoReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func SetDeviceInfo(conn *x.Conn, deviceSpec DeviceSpec, firstBtn uint8, change uint16, btnActions []Action, leds []DeviceLedInfo) {
body := encodeSetDeviceInfo(deviceSpec, firstBtn, change, btnActions, leds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetDeviceInfoOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func SetDeviceInfoChecked(conn *x.Conn, deviceSpec DeviceSpec, firstBtn uint8, change uint16, btnActions []Action, leds []DeviceLedInfo) x.VoidCookie {
body := encodeSetDeviceInfo(deviceSpec, firstBtn, change, btnActions, leds)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: SetDeviceInfoOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func SetDebuggingFlags(conn *x.Conn, affectFlags, flags, affectCtrls, ctrls uint32, message string) SetDebuggingFlagsCookie {
body := encodeSetDebuggingFlags(affectFlags, flags, affectCtrls, ctrls, message)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: SetDebuggingFlagsOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return SetDebuggingFlagsCookie(seq)
}
func (cookie SetDebuggingFlagsCookie) Reply(conn *x.Conn) (*SetDebuggingFlagsReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply SetDebuggingFlagsReply
err = readSetDebuggingFlagsReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
go-x11-client-1.0.2/extension.go 0000664 0000000 0000000 00000006070 14607133730 0016354 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"sync"
)
type ReadErrorFunc func(*Reader) Error
type lazyReplyTag uint
const (
lazyNone lazyReplyTag = iota
lazyCookie
lazyForced
)
type Extension struct {
id int
name string // extension-xname
maxErrCode uint8
errCodeNameMap map[uint8]string
reqOpcodeNameMap map[uint]string
}
func (ext *Extension) Name() string {
return ext.name
}
var nextExtId = 1
// only call it in init() func
func NewExtension(name string, maxErrCode uint8,
errCodeNameMap map[uint8]string, reqOpcodeNameMap map[uint]string) *Extension {
id := nextExtId
nextExtId++
return &Extension{
id: id,
name: name,
maxErrCode: maxErrCode,
errCodeNameMap: errCodeNameMap,
reqOpcodeNameMap: reqOpcodeNameMap,
}
}
type lazyReply struct {
tag lazyReplyTag
reply *QueryExtensionReply
cookie QueryExtensionCookie
}
type extAndData struct {
ext *Extension
reply *lazyReply
}
type ext struct {
mu sync.RWMutex
extensions []extAndData
}
func (e *ext) grow(n int) {
if n <= len(e.extensions) {
return
}
logPrintf("ext grow %d -> %d\n", len(e.extensions), n)
bigger := make([]extAndData, n)
copy(bigger, e.extensions)
e.extensions = bigger
}
func (e *ext) getById(id int) *extAndData {
if id > len(e.extensions) {
e.grow(id * 2)
}
return &e.extensions[id-1]
}
func (e *ext) getExtByMajorOpcode(majorOpcode uint8) *Extension {
for _, extAndData := range e.extensions {
ext := extAndData.ext
lzr := extAndData.reply
if ext != nil && lzr != nil && lzr.reply != nil {
if majorOpcode == lzr.reply.MajorOpcode {
return ext
}
}
}
return nil
}
func (e *ext) getExtErrName(errCode uint8) string {
for _, extAndData := range e.extensions {
ext := extAndData.ext
lzr := extAndData.reply
if ext != nil && lzr != nil && lzr.reply != nil {
base := lzr.reply.FirstError
max := lzr.reply.FirstError + ext.maxErrCode
if base <= errCode && errCode <= max {
return ext.errCodeNameMap[errCode-base]
}
}
}
return ""
}
func (e *ext) getLazyReply(conn *Conn, ext *Extension) (lzr *lazyReply) {
extAndData := e.getById(ext.id)
if extAndData.ext == nil {
// init extAndData
extAndData.ext = ext
extAndData.reply = &lazyReply{tag: lazyNone}
}
lzr = extAndData.reply
// lazyReply tag: lazyNone -> lazyCookie
if lzr.tag == lazyNone {
lzr.tag = lazyCookie
lzr.cookie = QueryExtension(conn, ext.name)
}
return
}
func (e *ext) getExtData(c *Conn, ext *Extension) *QueryExtensionReply {
lzr := e.getLazyReply(c, ext)
// lazyReply tag: lazyCookie -> lazyForced
if lzr.tag == lazyCookie {
lzr.tag = lazyForced
lzr.reply, _ = lzr.cookie.Reply(c)
}
return lzr.reply
}
func (c *Conn) GetExtensionData(ext *Extension) *QueryExtensionReply {
c.ext.mu.Lock()
data := c.ext.getExtData(c, ext)
c.ext.mu.Unlock()
return data
}
func (c *Conn) PrefetchExtensionData(ext *Extension) {
c.ext.mu.Lock()
c.ext.getLazyReply(c, ext)
c.ext.mu.Unlock()
}
go-x11-client-1.0.2/gen.sh 0000775 0000000 0000000 00000004460 14607133730 0015122 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -x
set -e
goClient='python2 tools/go_client.py'
reqCodeGen=tools/gen/gen
$goClient -o xproto_auto.go /usr/share/xcb/xproto.xml
env GOPACKAGE=x $reqCodeGen xproto.go > xproto_auto_req.go
$goClient -o ext/record/auto.go /usr/share/xcb/record.xml
env GOPACKAGE=record $reqCodeGen -e ext/record/record.go > ext/record/record_req_auto.go
$goClient -o ext/test/auto.go /usr/share/xcb/xtest.xml
env GOPACKAGE=test $reqCodeGen -e ext/test/test.go > ext/test/test_req_auto.go
$goClient -o ext/damage/auto.go /usr/share/xcb/damage.xml
env GOPACKAGE=damage $reqCodeGen -e ext/damage/damage.go > ext/damage/damage_req_auto.go
$goClient -o ext/composite/auto.go /usr/share/xcb/composite.xml
env GOPACKAGE=composite $reqCodeGen -e ext/composite/composite.go > ext/composite/composite_req_auto.go
$goClient -o ext/screensaver/auto.go /usr/share/xcb/screensaver.xml
env GOPACKAGE=screensaver $reqCodeGen -e ext/screensaver/screensaver.go > ext/screensaver/screensaver_req_auto.go
$goClient -o ext/dpms/auto.go /usr/share/xcb/dpms.xml
env GOPACKAGE=dpms $reqCodeGen -e ext/dpms/dpms.go > ext/dpms/dpms_req_auto.go
$goClient -o ext/randr/auto.go /usr/share/xcb/randr.xml
env GOPACKAGE=randr $reqCodeGen -e -extra-exts render ext/randr/randr.go > ext/randr/randr_req_auto.go
$goClient -o ext/xfixes/auto.go /usr/share/xcb/xfixes.xml
env GOPACKAGE=xfixes $reqCodeGen -e ext/xfixes/xfixes.go > ext/xfixes/xfixes_req_auto.go
$goClient -o ext/input/auto.go /usr/share/xcb/xinput.xml
env GOPACKAGE=input $reqCodeGen -e ext/input/input.go > ext/input/input_req_auto.go
env GOPACKAGE=input $reqCodeGen -e ext/input/input1.go > ext/input/input1_req_auto.go
$goClient -p ge -o ext/ge/auto.go /usr/share/xcb/ge.xml
env GOPACKAGE=ge $reqCodeGen -e ext/ge/ge.go > ext/ge/ge_req_auto.go
$goClient -o ext/render/auto.go /usr/share/xcb/render.xml
env GOPACKAGE=render $reqCodeGen -e ext/render/render.go > ext/render/render_req_auto.go
$goClient -o ext/shm/auto.go /usr/share/xcb/shm.xml
env GOPACKAGE=shm $reqCodeGen -e ext/shm/shm.go > ext/shm/shm_req_auto.go
$goClient -o ext/bigrequests/auto.go /usr/share/xcb/bigreq.xml
env GOPACKAGE=bigrequests $reqCodeGen -e ext/bigrequests/bigreq.go > ext/bigrequests/bigreq_req_auto.go
$goClient -o ext/xkb/auto.go /usr/share/xcb/xkb.xml
env GOPACKAGE=xkb $reqCodeGen -e ext/xkb/xkb.go > ext/xkb/xkb_req_auto.go
go-x11-client-1.0.2/help.go 0000664 0000000 0000000 00000006165 14607133730 0015275 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
/*
help.go is meant to contain a rough hodge podge of functions that are mainly
used in the auto generated code. Indeed, several functions here are simple
wrappers so that the sub-packages don't need to be smart about which stdlib
packages to import.
Also, the 'Get..' and 'Put..' functions are used through the core xgb package
too. (xgbutil uses them too.)
*/
import (
"fmt"
//"github.com/gavv/monotime"
"strings"
)
//func GetServerCurrentTime() Timestamp {
// now := monotime.Now()
// ns := now.Nanoseconds()
// return Timestamp(ns / 1e6)
//}
// StringsJoin is an alias to strings.Join. It allows us to avoid having to
// import 'strings' in each of the generated Go files.
func StringsJoin(ss []string, sep string) string {
return strings.Join(ss, sep)
}
// Sprintf is so we don't need to import 'fmt' in the generated Go files.
func Sprintf(format string, v ...interface{}) string {
return fmt.Sprintf(format, v...)
}
// Errorf is just a wrapper for fmt.Errorf. Exists for the same reason
// that 'stringsJoin' and 'sprintf' exists.
func Errorf(format string, v ...interface{}) error {
return fmt.Errorf(format, v...)
}
func Pad(e int) int {
// pad(E) = (4 - (E mod 4)) mod 4
return (4 - (e % 4)) % 4
}
// PopCount counts the number of bits set in a value list mask.
func PopCount(mask0 int) int {
mask := uint32(mask0)
n := 0
for i := uint32(0); i < 32; i++ {
if mask&(1<> 8)
}
// Put32 takes a 32 bit integer and copies it into a byte slice.
func Put32(buf []byte, v uint32) {
buf[0] = byte(v)
buf[1] = byte(v >> 8)
buf[2] = byte(v >> 16)
buf[3] = byte(v >> 24)
}
// Put64 takes a 64 bit integer and copies it into a byte slice.
func Put64(buf []byte, v uint64) {
buf[0] = byte(v)
buf[1] = byte(v >> 8)
buf[2] = byte(v >> 16)
buf[3] = byte(v >> 24)
buf[4] = byte(v >> 32)
buf[5] = byte(v >> 40)
buf[6] = byte(v >> 48)
buf[7] = byte(v >> 56)
}
// Get16 constructs a 16 bit integer from the beginning of a byte slice.
func Get16(buf []byte) uint16 {
v := uint16(buf[0])
v |= uint16(buf[1]) << 8
return v
}
// Get32 constructs a 32 bit integer from the beginning of a byte slice.
func Get32(buf []byte) uint32 {
v := uint32(buf[0])
v |= uint32(buf[1]) << 8
v |= uint32(buf[2]) << 16
v |= uint32(buf[3]) << 24
return v
}
// Get64 constructs a 64 bit integer from the beginning of a byte slice.
func Get64(buf []byte) uint64 {
v := uint64(buf[0])
v |= uint64(buf[1]) << 8
v |= uint64(buf[2]) << 16
v |= uint64(buf[3]) << 24
v |= uint64(buf[4]) << 32
v |= uint64(buf[5]) << 40
v |= uint64(buf[6]) << 48
v |= uint64(buf[7]) << 56
return v
}
func BoolToUint8(b bool) uint8 {
if b {
return 1
}
return 0
}
func Uint8ToBool(v uint8) bool {
return v != 0
}
func TruncateStr(s string, n int) string {
if len(s) > n {
return s[:n]
}
return s
}
go-x11-client-1.0.2/in.go 0000664 0000000 0000000 00000010413 14607133730 0014742 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"container/list"
"fmt"
"os"
"sync"
)
type in struct {
requestExpected SeqNum
requestRead SeqNum
requestCompleted SeqNum
currentReply *list.List
replies map[SeqNum]*list.List
pendingReplies *list.List
readers *list.List
events *list.List
eventsCond *sync.Cond
eventChans []chan<- GenericEvent
chansMu sync.Mutex
}
func (in *in) init(ioMu *sync.Mutex) {
in.replies = make(map[SeqNum]*list.List)
in.pendingReplies = list.New()
in.readers = list.New()
in.events = list.New()
in.eventsCond = sync.NewCond(ioMu)
}
func (in *in) addEventChan(eventChan chan<- GenericEvent) {
in.chansMu.Lock()
for _, ch := range in.eventChans {
if ch == eventChan {
// exist
in.chansMu.Unlock()
return
}
}
// COW
newEventChans := make([]chan<- GenericEvent, len(in.eventChans)+1)
copy(newEventChans, in.eventChans)
newEventChans[len(newEventChans)-1] = eventChan
in.eventChans = newEventChans
in.chansMu.Unlock()
}
func (in *in) removeEventChan(eventChan chan<- GenericEvent) {
in.chansMu.Lock()
chans := in.eventChans
var found bool
for _, ch := range chans {
if ch == eventChan {
found = true
break
}
}
if !found {
// not found
in.chansMu.Unlock()
return
}
// COW
newEventChans := make([]chan<- GenericEvent, 0, len(in.eventChans)-1)
for _, ch := range chans {
if ch != eventChan {
newEventChans = append(newEventChans, ch)
}
}
in.eventChans = newEventChans
in.chansMu.Unlock()
}
func (in *in) addEvent(e GenericEvent) {
logPrintln("add event", e)
if in.events.Len() > 0xfff {
_, _ = fmt.Fprintf(os.Stderr, " too many events are not processed, len: %d\n",
in.events.Len())
}
in.events.PushBack(e)
in.eventsCond.Signal()
}
func (in *in) sendEvent(e GenericEvent) {
in.chansMu.Lock()
eventChans := in.eventChans
in.chansMu.Unlock()
for _, ch := range eventChans {
ch <- e
}
}
func (in *in) closeEventChans() {
in.chansMu.Lock()
for _, ch := range in.eventChans {
close(ch)
}
in.chansMu.Unlock()
}
type ReplyReader struct {
request SeqNum
cond *sync.Cond
}
func (in *in) insertNewReader(request SeqNum, cond *sync.Cond) *ReplyReader {
r := &ReplyReader{
request: request,
cond: cond,
}
var mark *list.Element
l := in.readers
for e := l.Front(); e != nil; e = e.Next() {
reader := e.Value.(*ReplyReader)
if reader.request >= request {
mark = e
break
}
}
if mark != nil {
logPrintf("insertNewReader %d before %d\n", request, mark.Value.(*ReplyReader).request)
l.InsertBefore(r, mark)
} else {
logPrintf("insertNewReader %d at end\n", request)
l.PushBack(r)
}
return r
}
func (in *in) removeReader(r *ReplyReader) {
l := in.readers
for e := l.Front(); e != nil; e = e.Next() {
reader := e.Value.(*ReplyReader)
if reader.request == r.request {
logPrintln("remove reader", reader.request)
l.Remove(e)
break
}
}
}
func (in *in) removeFinishedReaders() {
l := in.readers
e := l.Front()
for e != nil {
reader := e.Value.(*ReplyReader)
if reader.request <= in.requestCompleted {
reader.cond.Signal()
logPrintln("remove finished reader", reader.request)
tmp := e
e = e.Next()
l.Remove(tmp)
} else {
break
}
}
}
func (in *in) wakeUpAllReaders() {
l := in.readers
for e := l.Front(); e != nil; e = e.Next() {
reader := e.Value.(*ReplyReader)
reader.cond.Signal()
}
}
func (in *in) wakeUpNextReader() {
if in.readers.Front() != nil {
reader := in.readers.Front().Value.(*ReplyReader)
logPrintln("wake up next reader", reader.request)
reader.cond.Signal()
}
}
type PendingReply struct {
firstRequest SeqNum
lastRequest SeqNum
workaround uint
flags uint
}
func (in *in) expectReply(request SeqNum, workaround uint, flags uint) {
pend := &PendingReply{
firstRequest: request,
lastRequest: request,
workaround: workaround,
flags: flags,
}
in.pendingReplies.PushBack(pend)
}
func (in *in) removeFinishedPendingReplies() {
l := in.pendingReplies
e := l.Front()
for e != nil {
pend := e.Value.(*PendingReply)
if pend.lastRequest <= in.requestCompleted {
// remove pend from list
tmp := e
e = e.Next()
l.Remove(tmp)
} else {
break
}
}
}
go-x11-client-1.0.2/reader.go 0000664 0000000 0000000 00000004676 14607133730 0015614 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"bytes"
"errors"
)
var ErrDataLenShort = errors.New("data length is short")
type Reader struct {
pos int
data []byte
}
func NewReaderFromData(data []byte) *Reader {
return &Reader{
data: data,
}
}
func (r *Reader) Pos() int {
return r.pos
}
func (r *Reader) Read1b() uint8 {
v := r.data[r.pos]
r.pos++
return v
}
func (r *Reader) Read2b() uint16 {
v := uint16(r.data[r.pos])
v |= uint16(r.data[r.pos+1]) << 8
r.pos += 2
return v
}
func (r *Reader) Read4b() uint32 {
v := uint32(r.data[r.pos])
v |= uint32(r.data[r.pos+1]) << 8
v |= uint32(r.data[r.pos+2]) << 16
v |= uint32(r.data[r.pos+3]) << 24
r.pos += 4
return v
}
func (r *Reader) MustReadBytes(n int) []byte {
v := r.data[r.pos : r.pos+n]
r.pos += n
return v
}
func (r *Reader) ReadBytes(n int) ([]byte, error) {
if !r.RemainAtLeast(n) {
return nil, ErrDataLenShort
}
v := r.data[r.pos : r.pos+n]
r.pos += n
return v, nil
}
func (r *Reader) ReadBytesWithPad(n int) ([]byte, error) {
total := n + Pad(n)
if !r.RemainAtLeast(total) {
return nil, ErrDataLenShort
}
v := r.data[r.pos : r.pos+n]
r.pos += total
return v, nil
}
func (r *Reader) ReadString(n int) (string, error) {
v, err := r.ReadBytes(n)
if err != nil {
return "", err
}
return string(v), nil
}
func (r *Reader) ReadStrWithPad(n int) (string, error) {
v, err := r.ReadBytesWithPad(n)
if err != nil {
return "", err
}
return string(v), nil
}
func (r *Reader) ReadNulTermStr() string {
idx := bytes.IndexByte(r.data[r.pos:], 0)
var v []byte
if idx == -1 {
v = r.data[r.pos:]
r.pos = len(r.data)
} else {
v = r.data[r.pos : r.pos+idx]
r.pos += idx
}
return string(v)
}
func (r *Reader) ReadBool() bool {
return Uint8ToBool(r.Read1b())
}
func (r *Reader) ReadPad(n int) {
if r.pos+n > len(r.data) {
panic("index out of range")
}
r.pos += n
}
func (r *Reader) Reset() {
r.pos = 0
}
func (r *Reader) RemainAtLeast(n int) bool {
return r.pos+n <= len(r.data)
}
func (r *Reader) RemainAtLeast4b(n int) bool {
return r.RemainAtLeast(n << 2)
}
func (r *Reader) ReadReplyHeader() (data uint8, length uint32) {
r.ReadPad(1)
data = r.Read1b()
// seq
r.ReadPad(2)
// length
length = r.Read4b() // 2
return
}
func (r *Reader) ReadEventHeader() (data uint8, seq uint16) {
r.ReadPad(1)
data = r.Read1b()
// seq
seq = r.Read2b() // 1
return
}
go-x11-client-1.0.2/reader_test.go 0000664 0000000 0000000 00000004055 14607133730 0016642 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"testing"
. "gopkg.in/check.v1"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }
type MySuite struct {
r *Reader
}
var _ = Suite(&MySuite{})
func (s *MySuite) SetUpTest(c *C) {
buf := []byte{1, 2, 3, 4, 5, 6, 7, 8}
s.r = NewReaderFromData(buf)
}
func (s *MySuite) TestReaderReadBytes(c *C) {
v, err := s.r.ReadBytes(4)
c.Assert(v, DeepEquals, []byte{1, 2, 3, 4})
c.Assert(err, IsNil)
v, err = s.r.ReadBytes(3)
c.Assert(v, DeepEquals, []byte{5, 6, 7})
c.Assert(err, IsNil)
}
func (s *MySuite) TestReaderReadBytesWithPad(c *C) {
v, err := s.r.ReadBytesWithPad(3)
c.Assert(v, DeepEquals, []byte{1, 2, 3})
c.Assert(s.r.Pos(), Equals, 4)
c.Assert(err, IsNil)
}
func (s *MySuite) TestReaderRead1b(c *C) {
for i := 1; i <= 8; i++ {
c.Assert(s.r.Read1b(), Equals, uint8(i))
}
}
func (s *MySuite) TestReaderRead2b(c *C) {
results := []uint16{0x0201, 0x0403, 0x0605, 0x0807}
for _, result := range results {
c.Assert(s.r.Read2b(), Equals, result)
}
}
func (s *MySuite) TestReaderRead4b(c *C) {
results := []uint32{0x04030201, 0x08070605}
for _, result := range results {
c.Assert(s.r.Read4b(), Equals, result)
}
}
func (s *MySuite) TestReaderReadNulTermStr(c *C) {
data := []byte{'h', 'e', 'l', 'l', 'o'}
r := NewReaderFromData(data)
str := r.ReadNulTermStr()
c.Assert(str, Equals, "hello")
c.Assert(r.Pos(), Equals, 5)
data = []byte{'h', 'e', 'l', 'l', 'o', 0, 'w', 'o', 'r', 'l', 'd'}
r = NewReaderFromData(data)
str = r.ReadNulTermStr()
c.Assert(str, Equals, "hello")
c.Assert(r.Pos(), Equals, 5)
}
func (s *MySuite) TestReaderRemainAtLeast(c *C) {
s.r.ReadPad(3)
c.Assert(s.r.RemainAtLeast(5), Equals, true)
c.Assert(s.r.RemainAtLeast(6), Equals, false)
s.r.Reset()
c.Assert(s.r.RemainAtLeast4b(0), Equals, true)
c.Assert(s.r.RemainAtLeast4b(1), Equals, true)
c.Assert(s.r.RemainAtLeast4b(2), Equals, true)
c.Assert(s.r.RemainAtLeast4b(3), Equals, false)
}
go-x11-client-1.0.2/resource_id.go 0000664 0000000 0000000 00000003266 14607133730 0016647 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package x
import (
"errors"
"math/big"
"sync"
)
func (c *Conn) AllocID() (uint32, error) {
return c.ridAllocator.alloc()
}
func (c *Conn) FreeID(rid uint32) error {
return c.ridAllocator.free(rid)
}
func (c *Conn) IDUsedCount() int {
return c.ridAllocator.usedCount()
}
type resourceIdAllocator struct {
mu sync.Mutex
base uint32
mask uint32
last uint32
bitmap *big.Int
allAllocated bool
}
func (ra *resourceIdAllocator) init(base, mask uint32) {
ra.base = base
ra.mask = mask
ra.bitmap = big.NewInt(0)
}
var errOutOfResourceIds = errors.New("out of resource ids")
func (ra *resourceIdAllocator) alloc() (uint32, error) {
ra.mu.Lock()
defer ra.mu.Unlock()
if ra.allAllocated {
return 0, errOutOfResourceIds
}
i := ra.last
for ra.bitmap.Bit(int(i)) == 1 {
i++
if i > ra.mask {
i = 0
}
if i == ra.last {
ra.allAllocated = true
return 0, errOutOfResourceIds
}
}
ra.bitmap.SetBit(ra.bitmap, int(i), 1)
ra.last = i
return ra.base | i, nil
}
func (ra *resourceIdAllocator) free(rid uint32) error {
ra.mu.Lock()
defer ra.mu.Unlock()
i := rid & ra.mask
if rid-i != ra.base {
return errors.New("resource id outside range")
}
if ra.bitmap.Bit(int(i)) == 0 {
return errors.New("resource id not used")
}
ra.bitmap.SetBit(ra.bitmap, int(i), 0)
ra.allAllocated = false
return nil
}
func (ra *resourceIdAllocator) usedCount() int {
ra.mu.Lock()
count := 0
bitLen := ra.bitmap.BitLen()
for i := 0; i < bitLen; i++ {
if ra.bitmap.Bit(i) == 1 {
count++
}
}
ra.mu.Unlock()
return count
}
go-x11-client-1.0.2/rpm/ 0000775 0000000 0000000 00000000000 14607133730 0014604 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/rpm/golang-github-linuxdeepin-go-x11-client.spec 0000664 0000000 0000000 00000002505 14607133730 0025021 0 ustar 00root root 0000000 0000000 # Run tests in check section
# disable for bootstrapping
%bcond_with check
%global with_debug 1
%if 0%{?with_debug}
%global debug_package %{nil}
%endif
%global provider github
%global provider_tld com
%global project linuxdeepin
%global repo go-x11-client
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
Name: golang-github-linuxdeepin-go-x11-client
Version: 0.6.7
Release: 1
Summary: A X11 client Go bindings for Deepin Desktop Environment
License: GPLv3
URL: %{gourl}
Source0: %{name}_%{version}.orig.tar.xz
BuildRequires: compiler(go-compiler)
%description
%{summary}.
%package devel
Summary: %{summary}
BuildArch: noarch
BuildRequires: gocode
%description devel
%{summary}.
%prep
%forgeautosetup
%install
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
for file in $(find . -iname "*.go") ; do
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
done
%files devel -f devel.file-list
%doc README
%license LICENSE
%changelog
* Thu Mar 19 2021 uoser - 0.6.7-1
- Update to 0.6.7
go-x11-client-1.0.2/tools/ 0000775 0000000 0000000 00000000000 14607133730 0015146 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/tools/common.py 0000664 0000000 0000000 00000017210 14607133730 0017011 0 ustar 00root root 0000000 0000000 # SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
import re
_no_import_x = True
_ns = None
_lines = []
_level = 0
_cname_re = re.compile('([A-Z0-9][a-z]+|[A-Z0-9]+(?![a-z])|[a-z]+)')
_cname_special_cases = {
# names in xproto.xml
'GCONTEXT': 'GContext',
'VISUALID': 'VisualID',
'VISUALTYPE': 'VisualType',
'RGB': 'RGB',
'FONTPROP': 'FontProp',
'CHARINFO': 'CharInfo',
'TIMECOORD': 'TimeCoord',
'COLORITEM': 'ColorItem',
'DECnet': 'DECnet',
# in render.xml
'GLYPHSET': 'GlyphSet',
'PICTFORMAT': 'PictFormat',
'DIRECTFORMAT': 'DirectFormat',
'PICTFORMINFO': 'PictFormInfo',
'PICTVISUAL': 'PictVisual',
'PICTDEPTH': 'PictDepth',
'PICTSCREEN': 'PictScreen',
'INDEXVALUE': 'IndexValue',
'POINTFIX': 'PointFix',
'LINEFIX': 'LineFix',
'GLYPHINFO': 'GlyphInfo',
'ANIMCURSORELT': 'AnimCursorElt',
'SPANFIX': 'SpanFix',
}
_simple_type_map = {
'uint8_t': 'uint8',
'uint16_t': 'uint16',
'uint32_t': 'uint32',
'uint64_t': 'uint64',
'int8_t': 'int8',
'int16_t': 'int16',
'int32_t': 'int32',
'int64_t': 'int64',
'char': 'byte', # []byte => string
'float': 'float32',
'double': 'float64',
}
# readonly
# ingore bigreq
_ext_names = ['Shm', 'XF86Dri', 'RandR', 'Xv', 'DPMS', 'Xinerama',
'Test', 'XCMisc', 'Res', 'XvMC', 'Composite', 'ScreenSaver',
'SELinux', 'XF86VidMode', 'Present', 'DRI3', 'Input',
'GenericEvent', 'Render', 'Xevie', 'XFixes', 'Glx', 'Sync',
'XPrint', 'Shape', 'xkb', 'Damage', 'DRI2', 'Record' ]
# xml filename => go pkg name
# if the value is '-', it means that the value is equal to the key
_ext_header_pkgname_map = {
'composite': '-',
'damage': '-',
'dpms': '-',
'dri2': '-',
'dri3': '-',
'ge': 'genericevent',
'glx': '-',
'present': '-',
'randr': '-',
'record': '-',
'render': '-',
'res': '-',
'screensaver': '-',
'shape': '-',
'shm': '-',
'sync': '-',
'xc_misc': 'xcmisc',
'xevie': '-',
'xf86dir': '-',
'xf86vidmode': '-',
'xfixes': '-',
'xinerama': '-',
'xinput': 'input',
'xkb': '-',
'xprint': '-',
'xselinux': 'selinux',
'xtest': 'test',
'xv': '-',
'xvmc': '-',
}
def is_int(x):
try:
int(x)
return True
except:
return False
def l(fmt, *args):
_lines[_level].append(fmt % args)
def todo(msg=''):
l('// TODO %s', msg)
def set_level(idx):
global _level
while len(_lines) <= idx:
_lines.append([])
_level = idx
def output_lines(fh):
for list in _lines:
for line in list:
fh.write(line)
fh.write('\n')
fh.close()
def set_namespace(val):
global _ns
_ns = val
def get_namespace():
global _ns
return _ns
def set_no_import_x(val):
global _no_import_x
_no_import_x = val
def lib_id(_id):
global _no_import_x
if _no_import_x:
return _id
else:
return "x." + _id
def get_type_name(name):
# type of name is tuple of str
if len(name) == 1:
# uintX intX
return _simple_type_map.get(name[0], name[0])
pkg_name, name = split_pkg_and_type(name)
type_name = ''.join([n_item(x) for x in name])
# check result
assert type_name[0].isupper()
global _ns
if _ns.is_ext and pkg_name != '' and pkg_name != get_go_pkg_name(_ns.ext_name):
# add pkg ident
type_name = pkg_name + '.' + type_name
return type_name
def split_pkg_and_type(name):
assert len(name) >= 2
if len(name) == 2 :
# ex. xcb COLORMAP
assert name[0] == 'xcb'
return ('x', name[1:])
elif len(name) >= 3:
assert name[0] == 'xcb'
global _ns
global _ext_names
if name[1] == _ns.ext_name or name[1] in _ext_names:
# name[1] is ext name
# ex. xcb RandR ScreenSize
return (get_go_pkg_name(name[1]), name[2:])
else:
# ex. xcb CreateWindow ValueList
return ('x', name[1:])
# go pkg name is _ns.ext_name.lower()
def get_go_pkg_name(ext_name):
# TODO adjust package name
return ext_name.lower()
def header_to_go_pkg_name(header):
global _ext_header_pkgname_map
pkg_name = _ext_header_pkgname_map[header]
if pkg_name == '-':
pkg_name = header
return pkg_name
def remove_prefix(name):
# remove xcb
if name[0] == 'xcb':
name = name[1:]
# remove ext name
if _ns.is_ext and name[0] == _ns.ext_name:
name = name[1:]
return name
def split_name(str):
split = _cname_re.finditer(str)
name_parts = [match.group(0) for match in split]
return name_parts
# value_list => value, list => ValueList
# CreateWindow => Create, Window => CreateWindow
def n_item(str):
'''
Does C-name conversion on a single string fragment.
Uses a regexp with some hard-coded special cases.
'''
if str in _cname_special_cases:
return _cname_special_cases[str]
else:
split = _cname_re.finditer(str)
name_parts = [match.group(0) for match in split]
return ''.join([x.title() for x in name_parts])
def get_request_name(name):
# print "get_request_name, name:", name
name = remove_prefix(name)
req_name = ''.join(name)
if not req_name[0].isupper():
raise Exception('first char of request name is not upper case')
return req_name
# field_name_test => FieldNameTest
def get_field_name(name):
if name is None:
return ''
return ''.join([x.title() for x in name.split('_')])
class FieldClassifyModel():
def do(self, field):
if field.type.is_pad:
# pad
if field.type.fixed_size():
return self.pad_FS(field)
else:
return self.pad_VS(field)
elif field.type.is_simple:
# simple
return self.simple(field)
elif field.type.is_container:
# containter
if field.type.fixed_size():
return self.container_FS(field)
else:
return self.container_VS(field)
elif field.type.is_list:
# list
if field.type.nmemb is None:
# VL
if field.type.member.fixed_size():
# MFS
return self.list_VL_MFS(field)
else:
# MVS
return self.list_VL_MVS(field)
else:
# CL
if field.type.member.fixed_size():
#MFS
return self.list_CL_MFS(field)
else:
#MVS
return self.list_CL_MVS(field)
def pad_FS(self, field):
raise Exception('abstract method not overridden!')
def pad_VS(self, field):
raise Exception('abstract method not overridden!')
def simple(self, field):
raise Exception('abstract method not overridden!')
def container_FS(self, field):
raise Exception('abstract method not overridden!')
def container_VS(self, field):
raise Exception('abstract method not overridden!')
def list_CL_MFS(self, field):
raise Exception('abstract method not overridden!')
def list_CL_MVS(self, field):
raise Exception('abstract method not overridden!')
def list_VL_MFS(self, field):
raise Exception('abstract method not overridden!')
def list_VL_MVS(self, field):
raise Exception('abstract method not overridden!')
go-x11-client-1.0.2/tools/enum.py 0000664 0000000 0000000 00000006076 14607133730 0016475 0 ustar 00root root 0000000 0000000 # SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
from common import *
_enum_to_str_list = [
# xproto.xml
('xcb', 'VisualClass'),
('xcb', 'EventMask'),
('xcb', 'BackingStore'),
('xcb', 'ImageOrder'),
('xcb', 'ModMask'),
('xcb', 'ButtonMask'),
('xcb', 'KeyButMask'),
('xcb', 'Motion'),
('xcb', 'NotifyDetail'),
('xcb', 'NotifyMode'),
('xcb', 'Visibility'),
('xcb', 'Place'),
('xcb', 'ColormapState'),
('xcb', 'Mapping'),
('xcb', 'WindowClass'),
('xcb', 'Gravity'),
('xcb', 'MapState'),
('xcb', 'ConfigWindow'),
('xcb', 'GrabStatus'),
('xcb', 'FontDraw'),
('xcb', 'StackMode'),
('xcb', 'Blanking'),
('xcb', 'Exposures'),
('xcb', 'MappingStatus'),
# TODO
# screensaver.xml
('xcb', 'ScreenSaver', 'Kind'),
('xcb', 'ScreenSaver', 'State'),
]
def get_enum_prefix(name):
pkg_name, name = split_pkg_and_type(name)
# check result
enum_prefix = ''.join(name)
assert enum_prefix[0].isupper()
_ns = get_namespace()
if _ns.is_ext and pkg_name != '' and pkg_name != get_go_pkg_name(_ns.ext_name):
# add pkg ident
enum_prefix = pkg_name + '.' + enum_prefix
return enum_prefix
_cname_special_cases = {
'VISUALID': 'VisualID',
}
_item_name_special_list = [
# xproto.xml
'YX',
'XY',
'DE',
'RGB',
'LSB',
'MSB',
'WM',
# render.xml
'BGR',
'HSL',
]
def get_enum_item_name(name):
if name in _cname_special_cases:
return _cname_special_cases[name]
name_parts = split_name(name)
result = []
for x in name_parts:
if x in _item_name_special_list:
result.append(x)
else:
result.append(x.title())
return ''.join(result)
def define_go_enum_to_string_func(prefix, self):
if len(self.values) < 2:
return
if not self.name in _enum_to_str_list:
return
l('\nfunc %sEnumToStr(v int) string {', prefix)
if len(self.bits) > 0:
l('strv := []string{}')
l('switch {')
for (item_name, val) in self.values:
val = int(val)
if val == 0:
continue
l('case v & %s%s > 0:', prefix, item_name)
l(' strv = append(strv, "%s")', item_name)
l('}') # end switch
l('return "[" + strings.Join(strv, "|") + "]"')
else:
items = dict()
# key is val, value is list of item_name
for (item_name, val) in self.values:
val = int(val)
if val in items:
items[val].append(item_name)
# items[val] = items[val].append(item_name)
else:
items[val] = [ item_name ]
l('switch v {')
for k in sorted(items.keys()):
l('case %d:', k)
l(' return "%s"', ' or '.join(items[k]))
# case default
l('default:')
l('return ""')
l('}') # end switch
l('}') # end func
go-x11-client-1.0.2/tools/gen/ 0000775 0000000 0000000 00000000000 14607133730 0015717 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/tools/gen/main.go 0000664 0000000 0000000 00000013473 14607133730 0017202 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"bytes"
"flag"
"fmt"
"go/ast"
"go/format"
"go/parser"
"go/printer"
"go/token"
"log"
"os"
"strings"
"github.com/linuxdeepin/go-lib/strv"
)
var optIsExt bool
var optExtraExts string
func init() {
flag.BoolVar(&optIsExt, "e", false, "is ext")
flag.StringVar(&optExtraExts, "extra-exts", "", "")
}
var xPrefix string
func astNodeToStr(fileSet *token.FileSet, node interface{}) (string, error) {
var buf bytes.Buffer
err := printer.Fprint(&buf, fileSet, node)
if err != nil {
return "", err
}
return buf.String(), nil
}
type Generator struct {
buf bytes.Buffer
}
func (g *Generator) p(format string, args ...interface{}) {
_, err := fmt.Fprintf(&g.buf, format, args...)
if err != nil {
log.Fatal(err)
}
}
func (g *Generator) format() []byte {
src, err := format.Source(g.buf.Bytes())
if err != nil {
log.Println("warning: internal error: invalid Go generated:", err)
return g.buf.Bytes()
}
return src
}
type requestFunc struct {
name string
encodeFuncName string
encodeFuncArgs string
args string
noReply bool
}
func main() {
log.SetFlags(log.Lshortfile)
goPackage := os.Getenv("GOPACKAGE")
log.Println(goPackage)
// parse file
if goPackage != "x" {
xPrefix = "x."
}
fs := token.NewFileSet()
flag.Parse()
name := flag.Arg(0)
f, err := parser.ParseFile(fs, name, nil, parser.ParseComments)
if err != nil {
log.Fatal(err)
}
var requestFuncs []*requestFunc
var hasReplyRequests strv.Strv
ast.Inspect(f, func(node ast.Node) bool {
funcDel, ok := node.(*ast.FuncDecl)
if !ok {
return true
}
if funcDel.Recv != nil {
// is method
return false
}
funcName := funcDel.Name.Name
if strings.HasPrefix(funcName, "encode") {
docText := funcDel.Doc.Text()
if !strings.Contains(docText, "#WREQ") {
return false
}
wreqOption := strings.TrimSpace(strings.TrimPrefix(docText, "#WREQ"))
wreqOptions := strings.Split(wreqOption, " ")
var varargs []string
for _, value := range wreqOptions {
if strings.HasPrefix(value, "vararg:") {
varargs = append(varargs, value[len("vararg:"):])
}
}
params := funcDel.Type.Params.List
var args []string
var encodeFuncArgs []string
for _, param := range params {
log.Println(param.Names)
var paramNames []string
for _, name := range param.Names {
paramNames = append(paramNames, name.Name)
}
typeStr, err := astNodeToStr(fs, param.Type)
if err != nil {
log.Fatal(err)
}
argNamesType := strings.Join(paramNames, ",") + " " + typeStr
args = append(args, argNamesType)
for _, value := range paramNames {
if strv.Strv(varargs).Contains(value) {
value = "options..."
}
encodeFuncArgs = append(encodeFuncArgs, value)
}
}
requestFuncs = append(requestFuncs, &requestFunc{
encodeFuncName: funcName,
encodeFuncArgs: strings.Join(encodeFuncArgs, ","),
name: strings.TrimPrefix(funcName, "encode"),
args: strings.Join(args, ","),
})
} else if strings.HasPrefix(funcName, "read") &&
strings.HasSuffix(funcName, "Reply") {
reqName := strings.TrimPrefix(funcName, "read")
reqName = strings.TrimSuffix(reqName, "Reply")
hasReplyRequests = append(hasReplyRequests, reqName)
}
return false
})
log.Println(hasReplyRequests)
for _, reqFunc := range requestFuncs {
if !hasReplyRequests.Contains(reqFunc.name) {
reqFunc.noReply = true
}
}
//spew.Dump(requestFuncs)
g := &Generator{}
g.p("package %s\n", goPackage)
const pkgPathBase = "github.com/linuxdeepin/go-x11-client"
if goPackage != "x" {
g.p("import x \"%s\"\n", pkgPathBase)
}
extraExts := strings.Split(optExtraExts, ",")
for _, e := range extraExts {
if e == "" {
continue
}
g.p("import \"%s/ext/%s\"\n", pkgPathBase, e)
}
for _, reqFunc := range requestFuncs {
if reqFunc.noReply {
g.pRequestFunc(reqFunc, false)
g.pRequestFunc(reqFunc, true)
} else {
g.pRequestFunc(reqFunc, true)
// cookie Reply method
g.p("\nfunc (cookie %sCookie) Reply(conn *%sConn) (*%sReply, error) {\n",
reqFunc.name, xPrefix, reqFunc.name)
g.p(`replyBuf, err := conn.WaitForReply(%sSeqNum(cookie))
if err != nil {
return nil, err
}
r := %sNewReaderFromData(replyBuf)
var reply %sReply
err = read%sReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
`, xPrefix, xPrefix, reqFunc.name, reqFunc.name)
}
}
_, err = os.Stdout.Write(g.format())
if err != nil {
log.Fatal(err)
}
}
func (g *Generator) pRequestFunc(reqFunc *requestFunc, check bool) {
returnType := xPrefix + "VoidCookie"
if !reqFunc.noReply {
// has reply
returnType = reqFunc.name + "Cookie"
} else if !check {
// no reply + no check
returnType = ""
}
funcName := reqFunc.name
sendReqFlag := "0"
if check {
sendReqFlag = xPrefix + "RequestChecked"
}
if reqFunc.noReply && check {
funcName += "Checked"
}
g.p("\nfunc %s(conn *%sConn, %s) %s {\n", funcName, xPrefix, reqFunc.args,
returnType)
if optIsExt {
g.p("body := %s(%s)\n", reqFunc.encodeFuncName, reqFunc.encodeFuncArgs)
} else {
g.p("headerData, body := %s(%s)\n", reqFunc.encodeFuncName, reqFunc.encodeFuncArgs)
}
g.p("req := &%sProtocolRequest{\n", xPrefix)
if optIsExt {
g.p("Ext: _ext,\n")
}
if reqFunc.noReply {
g.p("NoReply: true,\n")
}
g.p("Header: %sRequestHeader{\n", xPrefix)
if optIsExt {
g.p(" Data: %sOpcode,\n", reqFunc.name)
} else {
g.p(" Opcode: %sOpcode,\n", reqFunc.name)
g.p(" Data: headerData,\n")
}
g.p("},\n")
g.p("Body: body,\n")
g.p("}\n")
if returnType == "" {
g.p("conn.SendRequest(%s, req)\n", sendReqFlag)
} else {
g.p("seq := conn.SendRequest(%s, req)\n", sendReqFlag)
g.p("return %s(seq)", returnType)
}
g.p("}\n")
}
go-x11-client-1.0.2/tools/go_client.py 0000664 0000000 0000000 00000012711 14607133730 0017465 0 ustar 00root root 0000000 0000000 # SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
import sys
from common import *
from enum import *
import argparse
import subprocess
error_names = []
request_names = []
max_error_code = 0
x_prefix = ''
parser = argparse.ArgumentParser()
parser.add_argument('xml_file')
parser.add_argument('-o', '--output', dest='output', default='/dev/stdout')
parser.add_argument('-F', '--no-fmt', dest='no_fmt', action='store_true')
parser.add_argument('-p', '--package', dest='package')
parser.add_argument(
'-I', '--no-import-x', dest='no_import_x', action='store_true')
args = parser.parse_args()
def go_open(self):
set_namespace(self.namespace)
_ns = get_namespace()
global args
if args.package is not None:
pkg = args.package
else:
# pkg = _ns.header
if _ns.is_ext:
pkg = get_go_pkg_name(_ns.ext_name)
else:
pkg = 'x'
set_level(0)
l('package %s', pkg)
if pkg != 'x':
l('import x "github.com/linuxdeepin/go-x11-client"')
global x_prefix
x_prefix = 'x.'
if _ns.is_ext:
l('// _ns.ext_name: %s', _ns.ext_name)
l('const MajorVersion = %d', int(_ns.major_version))
l('const MinorVersion = %d', int(_ns.minor_version))
l('var _ext *%sExtension', x_prefix)
l('func Ext() *x.Extension {')
l(' return _ext')
l('}')
def go_close(self):
# handle errors
_ns = get_namespace()
global error_names
global request_names
global x_prefix
if len(error_names) > 0:
l("var errorCodeNameMap = map[uint8]string{")
for name in error_names:
error_code = get_type_name(name) + "ErrorCode"
error_name = get_type_name(name)
if not error_name.startswith("Bad"):
error_name = "Bad" + error_name
if error_name == "BadDeviceBusy":
error_name = "DeviceBusy"
l("%s : \"%s\",", error_code, error_name)
l("}") # end error code name map
if len(request_names) > 0:
l("var requestOpcodeNameMap = map[uint]string{")
for name in request_names:
l("%sOpcode : \"%s\",", name, name)
l("}") # end request opcode name map
if _ns.is_ext:
l("func init() {")
errMap = "nil"
if len(error_names) > 0:
errMap = "errorCodeNameMap"
reqMap = "nil"
if len(request_names) > 0:
reqMap = "requestOpcodeNameMap"
l('_ext = %sNewExtension("%s", %d, %s, %s)', x_prefix, _ns.ext_xname, max_error_code, errMap, reqMap)
l("}") # end func init
# write source file
global args
gofile = open(args.output, 'w')
if args.no_fmt:
output_lines(gofile)
else:
pipe = subprocess.Popen(
'gofmt', bufsize=4096, stdin=subprocess.PIPE, stdout=gofile)
output_lines(pipe.stdin)
pipe.wait()
if pipe.returncode != 0:
# write no formated code and raise exception.
output_lines(gofile)
raise Exception("gofmt exit with error code %d" % pipe.returncode)
def go_simple(self, name):
if self.name != name:
type_name = get_type_name(name)
source_type_name = get_type_name(self.name)
set_level(0)
l("// simple %s", name)
l("type %s %s", type_name, source_type_name)
def go_enum(self, name):
prefix = get_enum_prefix(name)
set_level(0)
l("// enum %s", prefix)
l('const (')
for (item_name, val) in self.values:
item_name = get_enum_item_name(item_name)
l("%s%s = %s", prefix, item_name, val)
# newline
l(')\n')
def go_struct(self, name):
pass
def go_union(self, name):
pass
def go_request(self, name):
global request_names
name_base = get_request_name(name)
opcode_name = name_base + "Opcode"
l("const %s = %s", opcode_name, self.opcode)
request_names.append(name_base)
if self.reply:
l("type %s %sSeqNum", name_base + "Cookie", x_prefix)
def go_event(self, name):
type_name = get_type_name(name) + "Event"
code_name = type_name + "Code"
code = self.opcodes[name]
l('const %s = %d', code_name, int(code))
define_go_event_new_func(type_name)
def define_go_event_new_func(go_type):
global x_prefix
l('\nfunc New%s(data []byte) (*%s, error) {', go_type, go_type)
l('var ev %s', go_type)
l('r := %sNewReaderFromData(data)', x_prefix)
l('err := read%s(r, &ev)', go_type)
l('if err != nil {')
l(' return nil, err')
l('}')
l('return &ev, nil')
l('}')
def go_error(self, name):
global max_error_code
global error_names
type_name = get_type_name(name) + 'Error'
code_name = type_name + "Code"
code = int(self.opcodes[name])
l('const %s = %d', code_name, code)
error_names.append(name)
if code > max_error_code:
max_error_code = code
def go_eventstruct(self, name):
pass
output = {
'open': go_open,
'close': go_close,
'simple': go_simple,
'enum': go_enum,
'struct': go_struct,
'union': go_union,
'request': go_request,
'event': go_event,
'error': go_error,
'eventstruct': go_eventstruct,
}
# Import the module class
from xcbgen.state import Module
from xcbgen.xtypes import *
# Parse the xml header
module = Module(args.xml_file, output)
# Build type-registry and resolve type dependencies
module.register()
module.resolve()
# Output the code
module.generate()
go-x11-client-1.0.2/util/ 0000775 0000000 0000000 00000000000 14607133730 0014763 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/util/atom/ 0000775 0000000 0000000 00000000000 14607133730 0015723 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/util/atom/atom.go 0000664 0000000 0000000 00000001326 14607133730 0017214 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package atom
import (
x "github.com/linuxdeepin/go-x11-client"
)
func GetVal(conn *x.Conn, name string) (x.Atom, error) {
reply, err := x.InternAtom(conn, false, name).Reply(conn)
if err != nil {
return 0, err
}
return reply.Atom, nil
}
func GetExistingVal(conn *x.Conn, name string) (x.Atom, error) {
reply, err := x.InternAtom(conn, true, name).Reply(conn)
if err != nil {
return 0, err
}
return reply.Atom, nil
}
func GetName(conn *x.Conn, val x.Atom) (string, error) {
reply, err := x.GetAtomName(conn, val).Reply(conn)
if err != nil {
return "", err
}
return reply.Name, nil
}
go-x11-client-1.0.2/util/cursor/ 0000775 0000000 0000000 00000000000 14607133730 0016300 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/util/cursor/cursor.go 0000664 0000000 0000000 00000014530 14607133730 0020147 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package cursor
import (
"errors"
"image"
"image/color"
"image/color/palette"
"image/draw"
"image/gif"
"os"
"github.com/linuxdeepin/go-x11-client"
"github.com/linuxdeepin/go-x11-client/ext/render"
"github.com/linuxdeepin/go-x11-client/ext/xfixes"
)
type Image struct {
Size uint32 // nominal size for matching
Width uint32 // actual width
Height uint32 // actual height
XHot uint32 // hot spot x
YHot uint32 // hot spot y
Delay uint32 // delay between animation frames in milliseconds
Pixels []byte
img *image.RGBA
}
func (img *Image) Img() *image.RGBA {
if img.img != nil {
return img.img
}
// parse img.pixels
pixels := img.Pixels
rgbaImg := image.NewRGBA(image.Rect(0, 0, int(img.Width), int(img.Height)))
pixIdx := 0
for y := 0; y < int(img.Height); y++ {
for X := 0; X < int(img.Width); X++ {
blue := uint8(pixels[pixIdx])
green := uint8(pixels[pixIdx+1])
red := uint8(pixels[pixIdx+2])
alpha := uint8(pixels[pixIdx+3])
rgbaImg.SetRGBA(X, y, color.RGBA{R: red, G: green, B: blue, A: alpha})
pixIdx += 4
}
}
img.img = rgbaImg
return rgbaImg
}
var errImageNotFound = errors.New("image not found")
func LoadImageFromFile(filename string, size int) (*Image, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
return loadImageFromFile(f, size)
}
func loadImageFromFile(f *os.File, size int) (*Image, error) {
d, err := newDecoder(f)
if err != nil {
return nil, err
}
defer d.close()
bestSize, _ := d.findBestSize(size)
if bestSize == 0 {
return nil, errImageNotFound
}
for _, toc := range d.tocs {
if toc.Type == typeImage && int(toc.Subtype) == bestSize {
img, err := d.readImage(toc)
if err != nil {
return nil, err
}
return img, nil
}
}
return nil, errImageNotFound
}
func dist(a, b int) int {
if a > b {
return a - b
}
return b - a
}
func (d *decoder) findBestSize(size int) (bestSize, nSizes int) {
for _, toc := range d.tocs {
if toc.Type != typeImage {
continue
}
thisSize := int(toc.Subtype)
if bestSize == 0 || dist(thisSize, size) < dist(bestSize, size) {
bestSize = thisSize
nSizes = 1
} else if thisSize == bestSize {
nSizes++
}
}
return
}
type Images []*Image
func LoadImagesFromFile(filename string, size int) (Images, error) {
f, err := os.Open(filename)
if err != nil {
return nil, err
}
return loadImagesFromFile(f, size)
}
func loadImagesFromFile(f *os.File, size int) (Images, error) {
d, err := newDecoder(f)
if err != nil {
return nil, err
}
defer d.close()
bestSize, nSizes := d.findBestSize(size)
if bestSize == 0 {
return nil, errImageNotFound
}
images := make(Images, nSizes)
var idx int
for _, toc := range d.tocs {
if toc.Type == typeImage && int(toc.Subtype) == bestSize {
img, err := d.readImage(toc)
if err != nil {
return nil, err
}
images[idx] = img
idx++
}
}
return images, nil
}
func (images Images) ToGIF() *gif.GIF {
p := append(palette.WebSafe, color.Transparent)
result := &gif.GIF{}
for _, img0 := range images {
img := img0.Img()
bounds := img.Bounds()
pImg := image.NewPaletted(bounds, p)
draw.Draw(pImg, bounds, img, image.Point{}, draw.Src)
result.Image = append(result.Image, pImg)
result.Delay = append(result.Delay, int(img0.Delay)/10)
result.Disposal = append(result.Disposal, gif.DisposalBackground)
}
return result
}
func (img *Image) LoadCursor(conn *x.Conn, name string) (x.Cursor, error) {
rootWin := conn.GetDefaultScreen().Root
depth := uint8(32)
xid, err := conn.AllocID()
if err != nil {
return 0, err
}
pixmapId := x.Pixmap(xid)
x.CreatePixmap(conn, depth, pixmapId, x.Drawable(rootWin), uint16(img.Width), uint16(img.Height))
xid, err = conn.AllocID()
if err != nil {
return 0, err
}
cid := x.GContext(xid)
x.CreateGC(conn, cid, x.Drawable(pixmapId), 0, nil)
pictFormats, err := render.QueryPictFormats(conn).Reply(conn)
if err != nil {
return 0, err
}
var formatARGB32 render.PictFormat
for _, f := range pictFormats.Formats {
if f.Depth == 32 &&
f.Type == render.PictTypeDirect &&
f.Direct.BlueMask == 255 &&
f.Direct.GreenMask == 255 &&
f.Direct.RedMask == 255 &&
f.Direct.AlphaMask == 255 &&
f.Direct.AlphaShift == 24 &&
f.Direct.RedShift == 16 &&
f.Direct.GreenShift == 8 &&
f.Direct.BlueShift == 0 {
formatARGB32 = f.Id
break
}
}
if formatARGB32 == 0 {
return 0, errors.New("not found pic format ARGB32")
}
x.PutImage(conn, x.ImageFormatZPixmap, x.Drawable(pixmapId), cid, uint16(img.Width), uint16(img.Height), 0, 0, 0, depth, img.Pixels)
x.FreeGC(conn, cid)
err = conn.FreeID(uint32(cid))
if err != nil {
return 0, err
}
xid, err = conn.AllocID()
if err != nil {
return 0, err
}
pictId := render.Picture(xid)
render.CreatePicture(conn, pictId, x.Drawable(pixmapId), formatARGB32, 0, nil)
x.FreePixmap(conn, pixmapId)
err = conn.FreeID(uint32(pixmapId))
if err != nil {
return 0, err
}
xid, err = conn.AllocID()
if err != nil {
return 0, err
}
cursorId := x.Cursor(xid)
render.CreateCursor(conn, cursorId, pictId, uint16(img.XHot), uint16(img.YHot))
render.FreePicture(conn, pictId)
err = conn.FreeID(uint32(pictId))
if err != nil {
return 0, err
}
if name != "" {
xfixes.SetCursorName(conn, cursorId, name)
}
return cursorId, nil
}
func (images Images) LoadCursor(conn *x.Conn, name string) (x.Cursor, error) {
if len(images) == 0 {
return 0, errImageNotFound
} else if len(images) == 1 {
return images[0].LoadCursor(conn, name)
}
cursors := make([]x.Cursor, 0, len(images))
defer func() {
for _, cid := range cursors {
x.FreeCursor(conn, cid)
_ = conn.FreeID(uint32(cid))
}
}()
for _, img := range images {
curId, err := img.LoadCursor(conn, "")
if err != nil {
return 0, err
}
cursors = append(cursors, curId)
}
xid, err := conn.AllocID()
if err != nil {
return 0, err
}
animCursorId := x.Cursor(xid)
animCursorEltSlice := make([]render.AnimCursorElt, len(cursors))
for idx, cursorId := range cursors {
animCursorEltSlice[idx] = render.AnimCursorElt{
Cursor: cursorId,
Delay: images[idx].Delay, // unit is milliseconds
}
}
render.CreateAnimCursor(conn, animCursorId, animCursorEltSlice)
if name != "" {
xfixes.SetCursorName(conn, animCursorId, name)
}
return animCursorId, nil
}
go-x11-client-1.0.2/util/cursor/cursor_test.go 0000664 0000000 0000000 00000004116 14607133730 0021205 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package cursor
import (
"image/gif"
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLoadImage(t *testing.T) {
_, err := os.Stat("/usr/share/icons/deepin/cursors/left_ptr")
if err == nil {
_, err = LoadImage("deepin", "left_ptr", 24)
assert.Nil(t, err)
} else {
t.Skip(err)
}
}
func TestLoadImages(t *testing.T) {
_, err := os.Stat("/usr/share/icons/deepin/cursors/watch")
if err == nil {
_, err = LoadImages("deepin", "watch", 24)
assert.Nil(t, err)
} else {
t.Skip(err)
}
}
func TestLoadImageFromFile(t *testing.T) {
img, err := LoadImageFromFile("testdata/left_ptr", 24)
if os.IsNotExist(err) {
t.Skip(err)
}
assert.Nil(t, err)
_ = img.Img()
assert.EqualValues(t, 24, img.Size)
assert.EqualValues(t, 24, img.Width)
assert.EqualValues(t, 24, img.Height)
assert.EqualValues(t, 7, img.XHot)
assert.EqualValues(t, 4, img.YHot)
assert.EqualValues(t, 50, img.Delay)
}
func TestLoadImagesFromFile(t *testing.T) {
images, err := LoadImagesFromFile("testdata/watch", 24)
if os.IsNotExist(err) {
t.Skip(err)
}
assert.Nil(t, err)
assert.Len(t, images, 16)
for _, img := range images {
_ = img.Img()
assert.EqualValues(t, 24, img.Size)
assert.EqualValues(t, 24, img.Width)
assert.EqualValues(t, 24, img.Height)
assert.EqualValues(t, 60, img.Delay)
}
}
func BenchmarkLoadImageFromFile(b *testing.B) {
for i := 0; i < b.N; i++ {
img, err := LoadImageFromFile("testdata/left_ptr", 24)
if err != nil {
b.Fatal(err)
}
_ = img.Img()
}
}
func BenchmarkLoadImagesFromFile(b *testing.B) {
for i := 0; i < b.N; i++ {
imgs, err := LoadImagesFromFile("testdata/watch", 24)
if err != nil {
b.Fatal(err)
}
for _, img := range imgs {
_ = img.Img()
}
}
}
func TestImages_ToGIF(t *testing.T) {
images, err := LoadImagesFromFile("testdata/watch", 24)
if os.IsNotExist(err) {
t.Skip(err)
}
assert.Nil(t, err)
outGif := images.ToGIF()
err = gif.EncodeAll(ioutil.Discard, outGif)
assert.Nil(t, err)
}
go-x11-client-1.0.2/util/cursor/read.go 0000664 0000000 0000000 00000006011 14607133730 0017540 0 ustar 00root root 0000000 0000000 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package cursor
import (
"bufio"
"encoding/binary"
"errors"
"io"
"os"
)
const (
typeImage = 0xfffd0002
)
type decoder struct {
f *os.File
br *bufio.Reader
version uint32
tocs []tocEntry
tmp [36]byte
}
func newDecoder(f *os.File) (*decoder, error) {
var d decoder
d.f = f
d.br = bufio.NewReader(f)
err := d.readHeader()
if err != nil {
return nil, err
}
return &d, nil
}
func (d *decoder) close() error {
return d.f.Close()
}
// table of contents entry
type tocEntry struct {
Type uint32 // entry type
Subtype uint32 //
Position uint32 // absolute byte position of table in file
}
func readFull(r io.Reader, b []byte) error {
_, err := io.ReadFull(r, b)
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return err
}
func (d *decoder) readHeader() error {
err := readFull(d.br, d.tmp[:16])
if err != nil {
return err
}
magic := string(d.tmp[:4])
if magic != "Xcur" {
return errors.New("magic not match")
}
d.version = binary.LittleEndian.Uint32(d.tmp[8:12])
nToc := binary.LittleEndian.Uint32(d.tmp[12:16])
d.tocs = make([]tocEntry, nToc)
for i := range d.tocs {
d.tocs[i], err = d.readTocEntry()
if err != nil {
return err
}
}
return nil
}
func (d *decoder) readTocEntry() (tocEntry, error) {
err := readFull(d.br, d.tmp[:12])
if err != nil {
return tocEntry{}, err
}
var e tocEntry
e.Type = binary.LittleEndian.Uint32(d.tmp[:4])
e.Subtype = binary.LittleEndian.Uint32(d.tmp[4:8])
e.Position = binary.LittleEndian.Uint32(d.tmp[8:12])
return e, nil
}
func (d *decoder) setPos(pos uint32) error {
_, err := d.f.Seek(int64(pos), io.SeekStart)
if err != nil {
return err
}
d.br.Reset(d.f)
return nil
}
func (d *decoder) readImage(toc tocEntry) (*Image, error) {
err := d.setPos(toc.Position)
if err != nil {
return nil, err
}
err = readFull(d.br, d.tmp[:36])
if err != nil {
return nil, err
}
// chuck header
headerLen := binary.LittleEndian.Uint32(d.tmp[:4])
if headerLen != 36 {
return nil, errors.New("image type chunk head len is not 36")
}
type0 := binary.LittleEndian.Uint32(d.tmp[4:8])
if type0 != typeImage {
return nil, errors.New("chunk type not match")
}
subtype := binary.LittleEndian.Uint32(d.tmp[8:12])
version := binary.LittleEndian.Uint32(d.tmp[12:16])
if version != 1 {
return nil, errors.New("version not supported")
}
var img Image
img.Size = subtype
img.Width = binary.LittleEndian.Uint32(d.tmp[16:20])
img.Height = binary.LittleEndian.Uint32(d.tmp[20:24])
img.XHot = binary.LittleEndian.Uint32(d.tmp[24:28])
if img.XHot > img.Width {
img.XHot = img.Width
}
img.YHot = binary.LittleEndian.Uint32(d.tmp[28:32])
if img.YHot > img.Height {
img.YHot = img.Height
}
img.Delay = binary.LittleEndian.Uint32(d.tmp[32:36])
// read pixels
img.Pixels = make([]byte, 4*int(img.Width)*int(img.Height))
err = readFull(d.br, img.Pixels)
if err != nil {
return nil, err
}
return &img, nil
}
go-x11-client-1.0.2/util/cursor/testdata/ 0000775 0000000 0000000 00000000000 14607133730 0020111 5 ustar 00root root 0000000 0000000 go-x11-client-1.0.2/util/cursor/testdata/left_ptr 0000664 0000000 0000000 00000036640 14607133730 0021664 0 ustar 00root root 0000000 0000000 Xcur 4 X 0 | $ 2
% * ) 444( $000000' %---------&