File: sync.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (522 lines) | stat: -rw-r--r-- 14,204 bytes parent folder | download | duplicates (8)
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
// 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

#ifndef UI_GFX_X_GENERATED_PROTOS_SYNC_H_
#define UI_GFX_X_GENERATED_PROTOS_SYNC_H_

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <optional>
#include <vector>

#include "base/component_export.h"
#include "base/files/scoped_file.h"
#include "base/memory/scoped_refptr.h"
#include "ui/gfx/x/error.h"
#include "ui/gfx/x/ref_counted_fd.h"
#include "ui/gfx/x/xproto_types.h"
#include "xproto.h"

namespace x11 {

class Connection;

template <typename Reply>
struct Response;

template <typename Reply>
class Future;

class COMPONENT_EXPORT(X11) Sync {
 public:
  static constexpr unsigned major_version = 3;
  static constexpr unsigned minor_version = 1;

  Sync(Connection* connection, const x11::QueryExtensionReply& info);

  uint8_t present() const { return info_.present; }
  uint8_t major_opcode() const { return info_.major_opcode; }
  uint8_t first_event() const { return info_.first_event; }
  uint8_t first_error() const { return info_.first_error; }

  Connection* connection() const { return connection_; }

  enum class Alarm : uint32_t {};

  enum class Alarmstate : int {
    Active = 0,
    Inactive = 1,
    Destroyed = 2,
  };

  enum class Counter : uint32_t {};

  enum class Fence : uint32_t {};

  enum class Testtype : int {
    PositiveTransition = 0,
    NegativeTransition = 1,
    PositiveComparison = 2,
    NegativeComparison = 3,
  };

  enum class Valuetype : int {
    Absolute = 0,
    Relative = 1,
  };

  enum class ChangeAlarmAttribute : int {
    Counter = 1 << 0,
    ValueType = 1 << 1,
    Value = 1 << 2,
    TestType = 1 << 3,
    Delta = 1 << 4,
    Events = 1 << 5,
  };

  struct Int64 {
    bool operator==(const Int64& other) const {
      return hi == other.hi && lo == other.lo;
    }

    int32_t hi{};
    uint32_t lo{};
  };

  struct SystemCounter {
    bool operator==(const SystemCounter& other) const {
      return counter == other.counter && resolution == other.resolution &&
             name == other.name;
    }

    Counter counter{};
    Int64 resolution{};
    std::string name{};
  };

  struct Trigger {
    bool operator==(const Trigger& other) const {
      return counter == other.counter && wait_type == other.wait_type &&
             wait_value == other.wait_value && test_type == other.test_type;
    }

    Counter counter{};
    Valuetype wait_type{};
    Int64 wait_value{};
    Testtype test_type{};
  };

  struct WaitCondition {
    bool operator==(const WaitCondition& other) const {
      return trigger == other.trigger &&
             event_threshold == other.event_threshold;
    }

    Trigger trigger{};
    Int64 event_threshold{};
  };

  struct CounterError : public x11::Error {
    uint16_t sequence{};
    uint32_t bad_counter{};
    uint16_t minor_opcode{};
    uint8_t major_opcode{};

    std::string ToString() const override;
  };

  struct AlarmError : public x11::Error {
    uint16_t sequence{};
    uint32_t bad_alarm{};
    uint16_t minor_opcode{};
    uint8_t major_opcode{};

    std::string ToString() const override;
  };

  struct CounterNotifyEvent {
    static constexpr uint8_t type_id = 8;
    static constexpr uint8_t opcode = 0;
    uint8_t kind{};
    uint16_t sequence{};
    Counter counter{};
    Int64 wait_value{};
    Int64 counter_value{};
    Time timestamp{};
    uint16_t count{};
    uint8_t destroyed{};
  };

  struct AlarmNotifyEvent {
    static constexpr uint8_t type_id = 9;
    static constexpr uint8_t opcode = 1;
    uint8_t kind{};
    uint16_t sequence{};
    Alarm alarm{};
    Int64 counter_value{};
    Int64 alarm_value{};
    Time timestamp{};
    Alarmstate state{};
  };

  struct InitializeRequest {
    uint8_t desired_major_version{};
    uint8_t desired_minor_version{};
  };

  struct InitializeReply {
    uint16_t sequence{};
    uint8_t major_version{};
    uint8_t minor_version{};
  };

  using InitializeResponse = Response<InitializeReply>;

  Future<InitializeReply> Initialize(const InitializeRequest& request);

  Future<InitializeReply> Initialize(const uint8_t& desired_major_version = {},
                                     const uint8_t& desired_minor_version = {});

  struct ListSystemCountersRequest {};

  struct ListSystemCountersReply {
    uint16_t sequence{};
    std::vector<SystemCounter> counters{};
  };

  using ListSystemCountersResponse = Response<ListSystemCountersReply>;

  Future<ListSystemCountersReply> ListSystemCounters(
      const ListSystemCountersRequest& request);

  Future<ListSystemCountersReply> ListSystemCounters();

  struct CreateCounterRequest {
    Counter id{};
    Int64 initial_value{};
  };

  using CreateCounterResponse = Response<void>;

  Future<void> CreateCounter(const CreateCounterRequest& request);

  Future<void> CreateCounter(const Counter& id = {},
                             const Int64& initial_value = {{}, {}});

  struct DestroyCounterRequest {
    Counter counter{};
  };

  using DestroyCounterResponse = Response<void>;

  Future<void> DestroyCounter(const DestroyCounterRequest& request);

  Future<void> DestroyCounter(const Counter& counter = {});

  struct QueryCounterRequest {
    Counter counter{};
  };

  struct QueryCounterReply {
    uint16_t sequence{};
    Int64 counter_value{};
  };

  using QueryCounterResponse = Response<QueryCounterReply>;

  Future<QueryCounterReply> QueryCounter(const QueryCounterRequest& request);

  Future<QueryCounterReply> QueryCounter(const Counter& counter = {});

  struct AwaitRequest {
    std::vector<WaitCondition> wait_list{};
  };

  using AwaitResponse = Response<void>;

  Future<void> Await(const AwaitRequest& request);

  Future<void> Await(const std::vector<WaitCondition>& wait_list = {});

  struct ChangeCounterRequest {
    Counter counter{};
    Int64 amount{};
  };

  using ChangeCounterResponse = Response<void>;

  Future<void> ChangeCounter(const ChangeCounterRequest& request);

  Future<void> ChangeCounter(const Counter& counter = {},
                             const Int64& amount = {{}, {}});

  struct SetCounterRequest {
    Counter counter{};
    Int64 value{};
  };

  using SetCounterResponse = Response<void>;

  Future<void> SetCounter(const SetCounterRequest& request);

  Future<void> SetCounter(const Counter& counter = {},
                          const Int64& value = {{}, {}});

  struct CreateAlarmRequest {
    Alarm id{};
    std::optional<Counter> counter{};
    std::optional<Valuetype> valueType{};
    std::optional<Int64> value{};
    std::optional<Testtype> testType{};
    std::optional<Int64> delta{};
    std::optional<uint32_t> events{};
  };

  using CreateAlarmResponse = Response<void>;

  Future<void> CreateAlarm(const CreateAlarmRequest& request);

  Future<void> CreateAlarm(
      const Alarm& id = {},
      const std::optional<Counter>& counter = std::nullopt,
      const std::optional<Valuetype>& valueType = std::nullopt,
      const std::optional<Int64>& value = std::nullopt,
      const std::optional<Testtype>& testType = std::nullopt,
      const std::optional<Int64>& delta = std::nullopt,
      const std::optional<uint32_t>& events = std::nullopt);

  struct ChangeAlarmRequest {
    Alarm id{};
    std::optional<Counter> counter{};
    std::optional<Valuetype> valueType{};
    std::optional<Int64> value{};
    std::optional<Testtype> testType{};
    std::optional<Int64> delta{};
    std::optional<uint32_t> events{};
  };

  using ChangeAlarmResponse = Response<void>;

  Future<void> ChangeAlarm(const ChangeAlarmRequest& request);

  Future<void> ChangeAlarm(
      const Alarm& id = {},
      const std::optional<Counter>& counter = std::nullopt,
      const std::optional<Valuetype>& valueType = std::nullopt,
      const std::optional<Int64>& value = std::nullopt,
      const std::optional<Testtype>& testType = std::nullopt,
      const std::optional<Int64>& delta = std::nullopt,
      const std::optional<uint32_t>& events = std::nullopt);

  struct DestroyAlarmRequest {
    Alarm alarm{};
  };

  using DestroyAlarmResponse = Response<void>;

  Future<void> DestroyAlarm(const DestroyAlarmRequest& request);

  Future<void> DestroyAlarm(const Alarm& alarm = {});

  struct QueryAlarmRequest {
    Alarm alarm{};
  };

  struct QueryAlarmReply {
    uint16_t sequence{};
    Trigger trigger{};
    Int64 delta{};
    uint8_t events{};
    Alarmstate state{};
  };

  using QueryAlarmResponse = Response<QueryAlarmReply>;

  Future<QueryAlarmReply> QueryAlarm(const QueryAlarmRequest& request);

  Future<QueryAlarmReply> QueryAlarm(const Alarm& alarm = {});

  struct SetPriorityRequest {
    uint32_t id{};
    int32_t priority{};
  };

  using SetPriorityResponse = Response<void>;

  Future<void> SetPriority(const SetPriorityRequest& request);

  Future<void> SetPriority(const uint32_t& id = {},
                           const int32_t& priority = {});

  struct GetPriorityRequest {
    uint32_t id{};
  };

  struct GetPriorityReply {
    uint16_t sequence{};
    int32_t priority{};
  };

  using GetPriorityResponse = Response<GetPriorityReply>;

  Future<GetPriorityReply> GetPriority(const GetPriorityRequest& request);

  Future<GetPriorityReply> GetPriority(const uint32_t& id = {});

  struct CreateFenceRequest {
    Drawable drawable{};
    Fence fence{};
    uint8_t initially_triggered{};
  };

  using CreateFenceResponse = Response<void>;

  Future<void> CreateFence(const CreateFenceRequest& request);

  Future<void> CreateFence(const Drawable& drawable = {},
                           const Fence& fence = {},
                           const uint8_t& initially_triggered = {});

  struct TriggerFenceRequest {
    Fence fence{};
  };

  using TriggerFenceResponse = Response<void>;

  Future<void> TriggerFence(const TriggerFenceRequest& request);

  Future<void> TriggerFence(const Fence& fence = {});

  struct ResetFenceRequest {
    Fence fence{};
  };

  using ResetFenceResponse = Response<void>;

  Future<void> ResetFence(const ResetFenceRequest& request);

  Future<void> ResetFence(const Fence& fence = {});

  struct DestroyFenceRequest {
    Fence fence{};
  };

  using DestroyFenceResponse = Response<void>;

  Future<void> DestroyFence(const DestroyFenceRequest& request);

  Future<void> DestroyFence(const Fence& fence = {});

  struct QueryFenceRequest {
    Fence fence{};
  };

  struct QueryFenceReply {
    uint16_t sequence{};
    uint8_t triggered{};
  };

  using QueryFenceResponse = Response<QueryFenceReply>;

  Future<QueryFenceReply> QueryFence(const QueryFenceRequest& request);

  Future<QueryFenceReply> QueryFence(const Fence& fence = {});

  struct AwaitFenceRequest {
    std::vector<Fence> fence_list{};
  };

  using AwaitFenceResponse = Response<void>;

  Future<void> AwaitFence(const AwaitFenceRequest& request);

  Future<void> AwaitFence(const std::vector<Fence>& fence_list = {});

 private:
  Connection* const connection_;
  x11::QueryExtensionReply info_{};
};

}  // namespace x11

inline constexpr x11::Sync::Alarmstate operator|(x11::Sync::Alarmstate l,
                                                 x11::Sync::Alarmstate r) {
  using T = std::underlying_type_t<x11::Sync::Alarmstate>;
  return static_cast<x11::Sync::Alarmstate>(static_cast<T>(l) |
                                            static_cast<T>(r));
}

inline constexpr x11::Sync::Alarmstate operator&(x11::Sync::Alarmstate l,
                                                 x11::Sync::Alarmstate r) {
  using T = std::underlying_type_t<x11::Sync::Alarmstate>;
  return static_cast<x11::Sync::Alarmstate>(static_cast<T>(l) &
                                            static_cast<T>(r));
}

inline constexpr x11::Sync::Testtype operator|(x11::Sync::Testtype l,
                                               x11::Sync::Testtype r) {
  using T = std::underlying_type_t<x11::Sync::Testtype>;
  return static_cast<x11::Sync::Testtype>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Sync::Testtype operator&(x11::Sync::Testtype l,
                                               x11::Sync::Testtype r) {
  using T = std::underlying_type_t<x11::Sync::Testtype>;
  return static_cast<x11::Sync::Testtype>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Sync::Valuetype operator|(x11::Sync::Valuetype l,
                                                x11::Sync::Valuetype r) {
  using T = std::underlying_type_t<x11::Sync::Valuetype>;
  return static_cast<x11::Sync::Valuetype>(static_cast<T>(l) |
                                           static_cast<T>(r));
}

inline constexpr x11::Sync::Valuetype operator&(x11::Sync::Valuetype l,
                                                x11::Sync::Valuetype r) {
  using T = std::underlying_type_t<x11::Sync::Valuetype>;
  return static_cast<x11::Sync::Valuetype>(static_cast<T>(l) &
                                           static_cast<T>(r));
}

inline constexpr x11::Sync::ChangeAlarmAttribute operator|(
    x11::Sync::ChangeAlarmAttribute l,
    x11::Sync::ChangeAlarmAttribute r) {
  using T = std::underlying_type_t<x11::Sync::ChangeAlarmAttribute>;
  return static_cast<x11::Sync::ChangeAlarmAttribute>(static_cast<T>(l) |
                                                      static_cast<T>(r));
}

inline constexpr x11::Sync::ChangeAlarmAttribute operator&(
    x11::Sync::ChangeAlarmAttribute l,
    x11::Sync::ChangeAlarmAttribute r) {
  using T = std::underlying_type_t<x11::Sync::ChangeAlarmAttribute>;
  return static_cast<x11::Sync::ChangeAlarmAttribute>(static_cast<T>(l) &
                                                      static_cast<T>(r));
}

#endif  // UI_GFX_X_GENERATED_PROTOS_SYNC_H_