Changeset View
Changeset View
Standalone View
Standalone View
src/server/output_interface.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 56 | struct { | |||
---|---|---|---|---|---|
57 | DpmsMode mode = DpmsMode::On; | 57 | DpmsMode mode = DpmsMode::On; | ||
58 | bool supported = false; | 58 | bool supported = false; | ||
59 | } dpms; | 59 | } dpms; | ||
60 | 60 | | |||
61 | static OutputInterface *get(wl_resource *native); | 61 | static OutputInterface *get(wl_resource *native); | ||
62 | 62 | | |||
63 | private: | 63 | private: | ||
64 | static Private *cast(wl_resource *native); | 64 | static Private *cast(wl_resource *native); | ||
65 | static void releaseCallback(wl_client *client, wl_resource *resource); | ||||
65 | static void unbind(wl_resource *resource); | 66 | static void unbind(wl_resource *resource); | ||
66 | void bind(wl_client *client, uint32_t version, uint32_t id) override; | 67 | void bind(wl_client *client, uint32_t version, uint32_t id) override; | ||
67 | int32_t toTransform() const; | 68 | int32_t toTransform() const; | ||
68 | int32_t toSubPixel() const; | 69 | int32_t toSubPixel() const; | ||
69 | void sendGeometry(wl_resource *resource); | 70 | void sendGeometry(wl_resource *resource); | ||
70 | void sendScale(const ResourceData &data); | 71 | void sendScale(const ResourceData &data); | ||
71 | 72 | | |||
72 | OutputInterface *q; | 73 | OutputInterface *q; | ||
73 | static QVector<Private*> s_privates; | 74 | static QVector<Private*> s_privates; | ||
75 | static const struct wl_output_interface s_interface; | ||||
74 | static const quint32 s_version; | 76 | static const quint32 s_version; | ||
75 | }; | 77 | }; | ||
76 | 78 | | |||
77 | QVector<OutputInterface::Private*> OutputInterface::Private::s_privates; | 79 | QVector<OutputInterface::Private*> OutputInterface::Private::s_privates; | ||
78 | const quint32 OutputInterface::Private::s_version = 2; | 80 | const quint32 OutputInterface::Private::s_version = 3; | ||
79 | 81 | | |||
80 | OutputInterface::Private::Private(OutputInterface *q, Display *d) | 82 | OutputInterface::Private::Private(OutputInterface *q, Display *d) | ||
81 | : Global::Private(d, &wl_output_interface, s_version) | 83 | : Global::Private(d, &wl_output_interface, s_version) | ||
82 | , q(q) | 84 | , q(q) | ||
83 | { | 85 | { | ||
84 | s_privates << this; | 86 | s_privates << this; | ||
85 | } | 87 | } | ||
86 | 88 | | |||
87 | OutputInterface::Private::~Private() | 89 | OutputInterface::Private::~Private() | ||
88 | { | 90 | { | ||
89 | s_privates.removeAll(this); | 91 | s_privates.removeAll(this); | ||
90 | } | 92 | } | ||
91 | 93 | | |||
94 | #ifndef DOXYGEN_SHOULD_SKIP_THIS | ||||
95 | const struct wl_output_interface OutputInterface::Private::s_interface = { | ||||
96 | releaseCallback | ||||
97 | }; | ||||
98 | #endif | ||||
99 | | ||||
100 | void OutputInterface::Private::releaseCallback(wl_client *client, wl_resource *resource) | ||||
101 | { | ||||
102 | Q_UNUSED(client); | ||||
103 | unbind(resource); | ||||
104 | } | ||||
105 | | ||||
92 | OutputInterface *OutputInterface::Private::get(wl_resource *native) | 106 | OutputInterface *OutputInterface::Private::get(wl_resource *native) | ||
93 | { | 107 | { | ||
94 | if (Private *p = cast(native)) { | 108 | if (Private *p = cast(native)) { | ||
95 | return p->q; | 109 | return p->q; | ||
96 | } | 110 | } | ||
97 | return nullptr; | 111 | return nullptr; | ||
98 | } | 112 | } | ||
99 | 113 | | |||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | |||||
298 | { | 312 | { | ||
299 | auto c = display->getConnection(client); | 313 | auto c = display->getConnection(client); | ||
300 | wl_resource *resource = c->createResource(&wl_output_interface, qMin(version, s_version), id); | 314 | wl_resource *resource = c->createResource(&wl_output_interface, qMin(version, s_version), id); | ||
301 | if (!resource) { | 315 | if (!resource) { | ||
302 | wl_client_post_no_memory(client); | 316 | wl_client_post_no_memory(client); | ||
303 | return; | 317 | return; | ||
304 | } | 318 | } | ||
305 | wl_resource_set_user_data(resource, this); | 319 | wl_resource_set_user_data(resource, this); | ||
306 | wl_resource_set_destructor(resource, unbind); | 320 | wl_resource_set_implementation(resource, &s_interface, this, unbind); | ||
307 | ResourceData r; | 321 | ResourceData r; | ||
308 | r.resource = resource; | 322 | r.resource = resource; | ||
309 | r.version = version; | 323 | r.version = version; | ||
310 | resources << r; | 324 | resources << r; | ||
311 | 325 | | |||
312 | sendGeometry(resource); | 326 | sendGeometry(resource); | ||
313 | sendScale(r); | 327 | sendScale(r); | ||
314 | 328 | | |||
▲ Show 20 Lines • Show All 218 Lines • Show Last 20 Lines |