YSTest: XCB.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

XCB.h
浏览该文件的文档.
1 /*
2 © 2014-2015 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
29 #ifndef YCL_INC_XCB_h_
30 #define YCL_INC_XCB_h_ 1
31
32 #include "YCLib/YModules.h"
33 #include YFM_YCLib_Platform
34 #if YF_Use_XCB
35 // #include <xcb/xcb.h>
36 # include YFM_YCLib_Host // for platform::string, platform::string_view,
37 // platform_ex::Exception;
38 # include YFM_YCLib_Debug // for platform::Deref;
39 # include <ystdex/pointer.hpp> // for ystdex::nptr;
40 # include YFM_YSLib_Core_YGraphics
41 # include YFM_YSLib_Core_YEvent
42 # include <atomic>
43
45
46 struct xcb_connection_t;
47 struct xcb_auth_info_t;
48 struct xcb_setup_t;
50 struct xcb_screen_t;
52
53 namespace platform_ex
54 {
55
57 namespace XCB
58 {
59
61 using platform::string_view;
62
64 class YF_API XCBException : public Exception
65 {
66 private:
68
69 std::uint8_t error_code;
70 std::uint16_t sequence;
71 std::uint32_t resource_id;
72 std::uint16_t minor_code;
73 std::uint8_t major_code;
74 std::uint32_t full_sequence;
76
77 public:
83 YB_NONNULL(2)
84 XCBException(const char*, std::uint8_t, std::uint8_t, std::uint16_t,
85 std::uint32_t, std::uint16_t, std::uint8_t, std::uint32_t,
86 YSLib::RecordLevel = YSLib::Emergent);
87 XCBException(string_view, std::uint8_t, std::uint8_t, std::uint16_t,
88 std::uint32_t, std::uint16_t, std::uint8_t, std::uint32_t,
89 YSLib::RecordLevel = YSLib::Emergent);
91
93
94 DefGetter(const ynothrow, std::uint8_t, ErrorCode, error_code)
95 DefGetter(const ynothrow, std::uint8_t, FullSequence, full_sequence)
96 DefGetter(const ynothrow, std::uint8_t, MajorCode, major_code)
97 DefGetter(const ynothrow, std::uint16_t, MinorCode, minor_code)
98 DefGetter(const ynothrow, std::uint8_t, ResponseType,
99 std::uint8_t(code().value()))
100 DefGetter(const ynothrow, std::uint32_t, ResourceID, resource_id)
101 DefGetter(const ynothrow, std::uint16_t, Sequence, sequence)
103 };
104
105
110 class YF_API ConnectionReference
111 : private ystdex::nptr<::xcb_connection_t*>
112 {
113 public:
114 using NativeHandle = ::xcb_connection_t*;
115
116 using nptr::nptr;
117 DefDeCopyMoveCtorAssignment(ConnectionReference)
118
119
120
121 DefPred(const ynothrow, OnError, GetError() != 0)
123
128 int
129 GetError() const ynothrow;
131 int
132 GetFileDescriptor() const ynothrow;
139 const ::xcb_setup_t&
140 GetSetup() const;
141
147 void
148 Check() const;
150 std::uint32_t
151 GenerateID() const ynothrow;
153
155 using nptr::get;
156 };
157
158
163 class YF_API Connection final : private ConnectionReference,
164 private YSLib::noncopyable, private YSLib::nonmovable
165 {
166 private:
168 shared_ptr<void> p_shared;
169
170 public:
172
173
178 Connection(const char* = {}, int* = {});
184 Connection(::xcb_auth_info_t*, const char* = {}, int* = {});
189 explicit
190 Connection(ConnectionReference);
192 ~Connection();
194
195 DefBoolNeg(explicit, !IsOnError())
196
197 using ConnectionReference::IsOnError;
198
200 using ConnectionReference::GetError;
201 using ConnectionReference::GetFileDescriptor;
202 using ConnectionReference::GetSetup;
203
205 using ConnectionReference::Check;
206 using ConnectionReference::GenerateID;
207
209 using ConnectionReference::get;
210 };
211
212
214 class YF_API Atom final
215 {
216 public:
218 using NativeType = std::uint32_t;
219
220 private:
221 std::uint32_t atom;
222
223 public:
228 explicit
229 Atom(::xcb_connection_t&, string_view, bool = {}) ynothrowv;
230
231 DefCvt(const ynothrow, NativeType, atom)
232 };
233
234
240 YF_API Atom::NativeType
241 LookupAtom(::xcb_connection_t&, const YSLib::string&);
242
243
248 class YF_API Drawable
249 {
250 public:
255 using ID = std::uint32_t;
256
257 private:
258 ConnectionReference conn_ref;
259 ID id;
260
261 protected:
262 Drawable(::xcb_connection_t& c_ref) ynothrow
263 : conn_ref(&c_ref), id(conn_ref.GenerateID())
264 {}
265 DefDeDtor(Drawable)
266
267 public:
268 DefGetter(const ynothrow, ConnectionReference, ConnectionRef, conn_ref)
269 DefGetter(const ynothrow, ID, ID, id)
270
271 PDefH(::xcb_connection_t&, DerefConn, ) const ynothrow
272 ImplRet(platform::Deref(conn_ref.get()))
273 };
274
275
277 class YF_API WindowData final : public Drawable
278 {
279 public:
290 WindowData(::xcb_connection_t&, const YSLib::Drawing::Rect&);
292 WindowData(::xcb_connection_t&, const YSLib::Drawing::Rect&,
293 const ::xcb_screen_t&);
295 WindowData(::xcb_connection_t&, const YSLib::Drawing::Rect&, ID);
297
299
300 YSLib::Drawing::Rect
301 GetBounds() const;
302 DefGetter(const, YSLib::Drawing::Point, Location, GetBounds().GetPoint())
303 DefGetter(const, YSLib::Drawing::Size, Size, GetSize())
304
305 void
306 SetBounds(const YSLib::Drawing::Rect&);
308
310 void
311 Close();
312
313 void
314 Hide();
315
317
318 PDefH(void, Invalidate, )
319 ImplExpr(Invalidate(GetBounds()))
320 void
321 Invalidate(const YSLib::Drawing::Rect&);
322
324 PDefH(Atom::NativeType, LookupAtom, const YSLib::string& name)
325 ImplRet(XCB::LookupAtom(DerefConn(), name))
326
327 void
328 Move(const YSLib::Drawing::Point&);
329
330 void
331 Resize(const YSLib::Drawing::Size&);
332
333 void
334 Show();
336 };
337
338
343 class YF_API GContext final : public Drawable, private YSLib::noncopyable
344 {
345 public:
346 GContext(::xcb_connection_t& c_ref) ynothrow
347 : Drawable(c_ref)
348 {}
349 ~GContext();
350 };
351
352
354 YF_API void
355 UpdatePixmapBuffer(WindowData&, const YSLib::Drawing::Rect&,
356 const YSLib::Drawing::ConstGraphics&);
357
358 } // namespace XCB;
359
360 } // namespace platform_ex;
361
362 #endif
363
364 #endif
365
YSLib::UI::Move
移动：位置调整。
Definition: YWidgetEvent.h:382
platform::ID
std::uintmax_t ID
YF_Platform_* 宏替换值的公共类型。
Definition: YCommon.h:52
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:232
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
YSLib::Drawing::GGraphics
二维图形接口上下文模板。
Definition: YGraphics.h:62
platform
默认平台命名空间。
Definition: Container.h:47
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:451
platform::Descriptions::Emergent
Definition: YCommon.h:163
YSLib::UI::Close
void Close(IWidget &wgt)
Definition: YWidget.cpp:92
DefDeCopyMoveCtorAssignment
#define DefDeCopyMoveCtorAssignment(_t)
Definition: YBaseMacro.h:202
platform::containers::string
basic_string< char > string
Definition: Container.h:101
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.cpp:108
platform::Descriptions::RecordLevel
RecordLevel
记录等级。
Definition: YCommon.h:161
YSLib::UI::Resize
大小调整。
Definition: YWidgetEvent.h:383
platform_ex::ImplRet
const char16_t *s ImplRet(platform::Nonnull(s)) inline PDefH(const u16string &
ystdex::nptr::nptr
nptr()=default
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
ystdex
特性测试宏。
Definition: ydef.h:822
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
YF_API
#define YF_API
Definition: Platform.h:56
Drawing
YModules.h
pointer.hpp
通用指针。
YSLib::Drawing::GBinaryGroup< SPos >
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:786
YSLib::UI::Show
YF_API void Show(IWidget &)
显示部件。
Definition: YWidget.cpp:202
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
platform_ex::YB_NONNULL
YB_NONNULL(1) PDefH(u16string
构造适合表示路径的 char16_t 字符串。
std
Definition: memory.hpp:1183
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
YSLib::UI::Hide
YF_API void Hide(IWidget &)
隐藏部件。
Definition: YWidget.cpp:100
platform_ex
平台扩展命名空间。
Definition: Android.h:45
YSLib::UI::name
yconstfn const string & name
Definition: Loader.h:130
platform_ex::Windows::ErrorCode
unsigned long ErrorCode
Definition: MinGW32.h:57
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
ystdex::details::get
get())
Definition: cast.hpp:102