Changeset View
Changeset View
Standalone View
Standalone View
src/client/output.cpp
Show All 34 Lines | |||||
35 | namespace { | 35 | namespace { | ||
36 | typedef QList<Output::Mode> Modes; | 36 | typedef QList<Output::Mode> Modes; | ||
37 | } | 37 | } | ||
38 | 38 | | |||
39 | class Output::Private | 39 | class Output::Private | ||
40 | { | 40 | { | ||
41 | public: | 41 | public: | ||
42 | Private(Output *q); | 42 | Private(Output *q); | ||
43 | ~Private(); | ||||
43 | void setup(wl_output *o); | 44 | void setup(wl_output *o); | ||
44 | 45 | | |||
45 | WaylandPointer<wl_output, wl_output_destroy> output; | 46 | WaylandPointer<wl_output, wl_output_destroy> output; | ||
46 | EventQueue *queue = nullptr; | 47 | EventQueue *queue = nullptr; | ||
47 | QSize physicalSize; | 48 | QSize physicalSize; | ||
48 | QPoint globalPosition; | 49 | QPoint globalPosition; | ||
49 | QString manufacturer; | 50 | QString manufacturer; | ||
50 | QString model; | 51 | QString model; | ||
51 | int scale = 1; | 52 | int scale = 1; | ||
52 | SubPixel subPixel = SubPixel::Unknown; | 53 | SubPixel subPixel = SubPixel::Unknown; | ||
53 | Transform transform = Transform::Normal; | 54 | Transform transform = Transform::Normal; | ||
54 | Modes modes; | 55 | Modes modes; | ||
55 | Modes::iterator currentMode = modes.end(); | 56 | Modes::iterator currentMode = modes.end(); | ||
56 | 57 | | |||
58 | static Output *get(wl_output *o); | ||||
59 | | ||||
57 | private: | 60 | private: | ||
58 | static void geometryCallback(void *data, wl_output *output, int32_t x, int32_t y, | 61 | static void geometryCallback(void *data, wl_output *output, int32_t x, int32_t y, | ||
59 | int32_t physicalWidth, int32_t physicalHeight, int32_t subPixel, | 62 | int32_t physicalWidth, int32_t physicalHeight, int32_t subPixel, | ||
60 | const char *make, const char *model, int32_t transform); | 63 | const char *make, const char *model, int32_t transform); | ||
61 | static void modeCallback(void *data, wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh); | 64 | static void modeCallback(void *data, wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh); | ||
62 | static void doneCallback(void *data, wl_output *output); | 65 | static void doneCallback(void *data, wl_output *output); | ||
63 | static void scaleCallback(void *data, wl_output *output, int32_t scale); | 66 | static void scaleCallback(void *data, wl_output *output, int32_t scale); | ||
64 | void setPhysicalSize(const QSize &size); | 67 | void setPhysicalSize(const QSize &size); | ||
65 | void setGlobalPosition(const QPoint &pos); | 68 | void setGlobalPosition(const QPoint &pos); | ||
66 | void setManufacturer(const QString &manufacturer); | 69 | void setManufacturer(const QString &manufacturer); | ||
67 | void setModel(const QString &model); | 70 | void setModel(const QString &model); | ||
68 | void setScale(int scale); | 71 | void setScale(int scale); | ||
69 | void setSubPixel(SubPixel subPixel); | 72 | void setSubPixel(SubPixel subPixel); | ||
70 | void setTransform(Transform transform); | 73 | void setTransform(Transform transform); | ||
71 | void addMode(uint32_t flags, int32_t width, int32_t height, int32_t refresh); | 74 | void addMode(uint32_t flags, int32_t width, int32_t height, int32_t refresh); | ||
72 | 75 | | |||
73 | Output *q; | 76 | Output *q; | ||
74 | static struct wl_output_listener s_outputListener; | 77 | static struct wl_output_listener s_outputListener; | ||
78 | | ||||
79 | static QVector<Private*> s_allOutputs; | ||||
75 | }; | 80 | }; | ||
76 | 81 | | |||
82 | QVector<Output::Private*> Output::Private::s_allOutputs; | ||||
83 | | ||||
77 | Output::Private::Private(Output *q) | 84 | Output::Private::Private(Output *q) | ||
78 | : q(q) | 85 | : q(q) | ||
79 | { | 86 | { | ||
87 | s_allOutputs << this; | ||||
88 | } | ||||
89 | | ||||
90 | Output::Private::~Private() | ||||
91 | { | ||||
92 | s_allOutputs.removeOne(this); | ||||
93 | } | ||||
94 | | ||||
95 | Output *Output::Private::get(wl_output *o) | ||||
96 | { | ||||
97 | auto it = std::find_if(s_allOutputs.constBegin(), s_allOutputs.constEnd(), | ||||
98 | [o] (Private *p) { | ||||
99 | const wl_output *reference = p->output; | ||||
100 | return reference == o; | ||||
101 | } | ||||
102 | ); | ||||
103 | if (it != s_allOutputs.constEnd()) { | ||||
104 | return (*it)->q; | ||||
105 | } | ||||
106 | return nullptr; | ||||
80 | } | 107 | } | ||
81 | 108 | | |||
82 | void Output::Private::setup(wl_output *o) | 109 | void Output::Private::setup(wl_output *o) | ||
83 | { | 110 | { | ||
84 | Q_ASSERT(o); | 111 | Q_ASSERT(o); | ||
85 | Q_ASSERT(!output); | 112 | Q_ASSERT(!output); | ||
86 | output.setup(o); | 113 | output.setup(o); | ||
87 | wl_output_add_listener(output, &s_outputListener, this); | 114 | wl_output_add_listener(output, &s_outputListener, this); | ||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Line(s) | |||||
353 | Output::operator wl_output*() { | 380 | Output::operator wl_output*() { | ||
354 | return d->output; | 381 | return d->output; | ||
355 | } | 382 | } | ||
356 | 383 | | |||
357 | Output::operator wl_output*() const { | 384 | Output::operator wl_output*() const { | ||
358 | return d->output; | 385 | return d->output; | ||
359 | } | 386 | } | ||
360 | 387 | | |||
388 | Output *Output::get(wl_output *o) | ||||
389 | { | ||||
390 | return Private::get(o); | ||||
391 | } | ||||
392 | | ||||
361 | } | 393 | } | ||
362 | } | 394 | } |