1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file was automatically generated with:
// ../../ui/gfx/x/gen_xproto.py \
// ../../third_party/xcbproto/src \
// gen/ui/gfx/x \
// bigreq \
// dri3 \
// glx \
// randr \
// render \
// screensaver \
// shape \
// shm \
// sync \
// xfixes \
// xinput \
// xkb \
// xproto \
// xtest
#include "xtest.h"
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xcbext.h>
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/xproto_internal.h"
namespace x11 {
Test::Test(Connection* connection, const x11::QueryExtensionReply& info)
: connection_(connection), info_(info) {}
Future<Test::GetVersionReply> Test::GetVersion(
const Test::GetVersionRequest& request) {
if (!connection_->Ready() || !present())
return {};
WriteBuffer buf;
auto& major_version = request.major_version;
auto& minor_version = request.minor_version;
// major_opcode
uint8_t major_opcode = info_.major_opcode;
buf.Write(&major_opcode);
// minor_opcode
uint8_t minor_opcode = 0;
buf.Write(&minor_opcode);
// length
// Caller fills in length for writes.
Pad(&buf, sizeof(uint16_t));
// major_version
buf.Write(&major_version);
// pad0
Pad(&buf, 1);
// minor_version
buf.Write(&minor_version);
Align(&buf, 4);
return connection_->SendRequest<Test::GetVersionReply>(
&buf, "Test::GetVersion", false);
}
Future<Test::GetVersionReply> Test::GetVersion(const uint8_t& major_version,
const uint16_t& minor_version) {
return Test::GetVersion(
Test::GetVersionRequest{major_version, minor_version});
}
template <>
COMPONENT_EXPORT(X11)
std::unique_ptr<Test::GetVersionReply> detail::ReadReply<Test::GetVersionReply>(
ReadBuffer* buffer) {
auto& buf = *buffer;
auto reply = std::make_unique<Test::GetVersionReply>();
auto& major_version = (*reply).major_version;
auto& sequence = (*reply).sequence;
auto& minor_version = (*reply).minor_version;
// response_type
uint8_t response_type;
Read(&response_type, &buf);
// major_version
Read(&major_version, &buf);
// sequence
Read(&sequence, &buf);
// length
uint32_t length;
Read(&length, &buf);
// minor_version
Read(&minor_version, &buf);
Align(&buf, 4);
CHECK_EQ(buf.offset < 32 ? 0 : buf.offset - 32, 4 * length);
return reply;
}
Future<Test::CompareCursorReply> Test::CompareCursor(
const Test::CompareCursorRequest& request) {
if (!connection_->Ready() || !present())
return {};
WriteBuffer buf;
auto& window = request.window;
auto& cursor = request.cursor;
// major_opcode
uint8_t major_opcode = info_.major_opcode;
buf.Write(&major_opcode);
// minor_opcode
uint8_t minor_opcode = 1;
buf.Write(&minor_opcode);
// length
// Caller fills in length for writes.
Pad(&buf, sizeof(uint16_t));
// window
buf.Write(&window);
// cursor
buf.Write(&cursor);
Align(&buf, 4);
return connection_->SendRequest<Test::CompareCursorReply>(
&buf, "Test::CompareCursor", false);
}
Future<Test::CompareCursorReply> Test::CompareCursor(
const Window& window,
const x11::Cursor& cursor) {
return Test::CompareCursor(Test::CompareCursorRequest{window, cursor});
}
template <>
COMPONENT_EXPORT(X11)
std::unique_ptr<Test::CompareCursorReply> detail::ReadReply<
Test::CompareCursorReply>(ReadBuffer* buffer) {
auto& buf = *buffer;
auto reply = std::make_unique<Test::CompareCursorReply>();
auto& same = (*reply).same;
auto& sequence = (*reply).sequence;
// response_type
uint8_t response_type;
Read(&response_type, &buf);
// same
Read(&same, &buf);
// sequence
Read(&sequence, &buf);
// length
uint32_t length;
Read(&length, &buf);
Align(&buf, 4);
CHECK_EQ(buf.offset < 32 ? 0 : buf.offset - 32, 4 * length);
return reply;
}
Future<void> Test::FakeInput(const Test::FakeInputRequest& request) {
if (!connection_->Ready() || !present())
return {};
WriteBuffer buf;
auto& type = request.type;
auto& detail = request.detail;
auto& time = request.time;
auto& root = request.root;
auto& rootX = request.rootX;
auto& rootY = request.rootY;
auto& deviceid = request.deviceid;
// major_opcode
uint8_t major_opcode = info_.major_opcode;
buf.Write(&major_opcode);
// minor_opcode
uint8_t minor_opcode = 2;
buf.Write(&minor_opcode);
// length
// Caller fills in length for writes.
Pad(&buf, sizeof(uint16_t));
// type
buf.Write(&type);
// detail
buf.Write(&detail);
// pad0
Pad(&buf, 2);
// time
buf.Write(&time);
// root
buf.Write(&root);
// pad1
Pad(&buf, 8);
// rootX
buf.Write(&rootX);
// rootY
buf.Write(&rootY);
// pad2
Pad(&buf, 7);
// deviceid
buf.Write(&deviceid);
Align(&buf, 4);
return connection_->SendRequest<void>(&buf, "Test::FakeInput", false);
}
Future<void> Test::FakeInput(const uint8_t& type,
const uint8_t& detail,
const uint32_t& time,
const Window& root,
const int16_t& rootX,
const int16_t& rootY,
const uint8_t& deviceid) {
return Test::FakeInput(
Test::FakeInputRequest{type, detail, time, root, rootX, rootY, deviceid});
}
Future<void> Test::GrabControl(const Test::GrabControlRequest& request) {
if (!connection_->Ready() || !present())
return {};
WriteBuffer buf;
auto& impervious = request.impervious;
// major_opcode
uint8_t major_opcode = info_.major_opcode;
buf.Write(&major_opcode);
// minor_opcode
uint8_t minor_opcode = 3;
buf.Write(&minor_opcode);
// length
// Caller fills in length for writes.
Pad(&buf, sizeof(uint16_t));
// impervious
buf.Write(&impervious);
// pad0
Pad(&buf, 3);
Align(&buf, 4);
return connection_->SendRequest<void>(&buf, "Test::GrabControl", false);
}
Future<void> Test::GrabControl(const uint8_t& impervious) {
return Test::GrabControl(Test::GrabControlRequest{impervious});
}
} // namespace x11
|