34
/// Handle class for MirSurfaceSpec - provides automatic reference counting, method chaining.
35
/// Handle class for MirWindowSpec - provides automatic reference counting, method chaining.
38
explicit SurfaceSpec(MirSurfaceSpec* spec) : self{spec, deleter} {}
39
explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {}
40
static auto for_normal_surface(MirConnection* connection, int width, int height, MirPixelFormat format) -> SurfaceSpec
41
static auto for_normal_surface(MirConnection* connection, int width, int height, MirPixelFormat format) -> WindowSpec
42
return SurfaceSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
43
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
44
return WindowSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
46
auto spec = WindowSpec{mir_create_normal_window_spec(connection, width, height)};
47
mir_window_spec_set_pixel_format(spec, format);
45
52
static auto for_menu(MirConnection* connection,
48
55
MirPixelFormat format,
50
57
MirRectangle* rect,
51
MirEdgeAttachment edge) -> SurfaceSpec
58
MirEdgeAttachment edge) -> WindowSpec
53
return SurfaceSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
60
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
61
return WindowSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
63
auto spec = WindowSpec{mir_create_menu_window_spec(connection, width, height, parent, rect, edge)};
64
mir_window_spec_set_pixel_format(spec, format);
56
69
#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0)
60
73
MirPixelFormat format,
62
75
MirRectangle* rect,
63
MirEdgeAttachment edge) -> SurfaceSpec
76
MirEdgeAttachment edge) -> WindowSpec
65
return SurfaceSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
78
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
79
return WindowSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
81
auto spec = WindowSpec{mir_create_tip_window_spec(connection, width, height, parent, rect, edge)};
82
mir_window_spec_set_pixel_format(spec, format);
69
88
static auto for_dialog(MirConnection* connection,
72
MirPixelFormat format)-> SurfaceSpec
91
MirPixelFormat format)-> WindowSpec
74
return SurfaceSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
93
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
94
return WindowSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
96
auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)};
97
mir_window_spec_set_pixel_format(spec, format);
77
102
static auto for_dialog(MirConnection* connection,
80
105
MirPixelFormat format,
81
MirSurface* parent) -> SurfaceSpec
106
MirWindow* parent) -> WindowSpec
83
108
return for_dialog(connection, width, height, format).set_parent(parent);
86
static auto for_changes(MirConnection* connection) -> SurfaceSpec
111
static auto for_changes(MirConnection* connection) -> WindowSpec
88
return SurfaceSpec{mir_connection_create_spec_for_changes(connection)};
113
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
114
return WindowSpec{mir_connection_create_spec_for_changes(connection)};
116
return WindowSpec{mir_create_window_spec(connection)};
91
auto set_buffer_usage(MirBufferUsage usage) -> SurfaceSpec&
120
auto set_buffer_usage(MirBufferUsage usage) -> WindowSpec&
122
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
93
123
mir_surface_spec_set_buffer_usage(*this, usage);
125
mir_window_spec_set_buffer_usage(*this, usage);
97
auto set_type(MirSurfaceType type) -> SurfaceSpec&
130
auto set_type(MirWindowType type) -> WindowSpec&
132
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
99
133
mir_surface_spec_set_type(*this, type);
135
mir_window_spec_set_type(*this, type);
103
auto set_min_size(int min_width, int min_height) -> SurfaceSpec&
140
auto set_min_size(int min_width, int min_height) -> WindowSpec&
142
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
105
143
mir_surface_spec_set_min_width(*this, min_width);
106
144
mir_surface_spec_set_min_height(*this, min_height);
146
mir_window_spec_set_min_width(*this, min_width);
147
mir_window_spec_set_min_height(*this, min_height);
110
auto set_max_size(int max_width, int max_height) -> SurfaceSpec&
152
auto set_max_size(int max_width, int max_height) -> WindowSpec&
154
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
112
155
mir_surface_spec_set_max_width(*this, max_width);
113
156
mir_surface_spec_set_max_height(*this, max_height);
158
mir_window_spec_set_max_width(*this, max_width);
159
mir_window_spec_set_max_height(*this, max_height);
117
auto set_size_inc(int width_inc, int height_inc) -> SurfaceSpec&
164
auto set_size_inc(int width_inc, int height_inc) -> WindowSpec&
166
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
119
167
mir_surface_spec_set_width_increment(*this, width_inc);
120
168
mir_surface_spec_set_height_increment(*this, height_inc);
170
mir_window_spec_set_width_increment(*this, width_inc);
171
mir_window_spec_set_height_increment(*this, height_inc);
124
auto set_size(int width, int height) -> SurfaceSpec&
176
auto set_size(int width, int height) -> WindowSpec&
178
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
126
179
mir_surface_spec_set_width(*this, width);
127
180
mir_surface_spec_set_height(*this, height);
182
mir_window_spec_set_width(*this, width);
183
mir_window_spec_set_height(*this, height);
131
auto set_name(char const* name) -> SurfaceSpec&
188
auto set_name(char const* name) -> WindowSpec&
190
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
133
191
mir_surface_spec_set_name(*this, name);
193
mir_window_spec_set_name(*this, name);
137
auto set_event_handler(mir_surface_event_callback callback, void* context) -> SurfaceSpec&
198
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
199
auto set_event_handler(mir_surface_event_callback callback, void* context) -> WindowSpec&
139
201
mir_surface_spec_set_event_handler(*this, callback, context);
205
auto set_event_handler(MirWindowEventCallback callback, void* context) -> WindowSpec&
207
mir_window_spec_set_event_handler(*this, callback, context);
143
212
#if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0)
144
213
auto set_placement(const MirRectangle* rect,
146
215
MirPlacementGravity surface_gravity,
147
216
MirPlacementHints placement_hints,
149
int offset_dy) -> SurfaceSpec&
218
int offset_dy) -> WindowSpec&
220
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
151
221
mir_surface_spec_set_placement(*this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy);
223
mir_window_spec_set_placement(*this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy);
156
auto set_parent(MirSurface* parent) -> SurfaceSpec&
229
auto set_parent(MirWindow* parent) -> WindowSpec&
231
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
158
232
mir_surface_spec_set_parent(*this, parent);
234
mir_window_spec_set_parent(*this, parent);
162
239
template<typename Context>
163
void create_surface(void (*callback)(MirSurface*, Context*), Context* context) const
240
void create_surface(void (*callback)(MirWindow*, Context*), Context* context) const
242
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
165
243
mir_surface_create(*this, reinterpret_cast<mir_surface_callback>(callback), context);
168
auto create_surface() const -> Surface
170
return Surface{mir_surface_create_sync(*this)};
173
void apply_to(MirSurface* surface) const
245
mir_create_window(*this, reinterpret_cast<MirWindowCallback>(callback), context);
249
auto create_surface() const -> Window
251
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
252
return Window{mir_surface_create_sync(*this)};
254
return Window{mir_create_window_sync(*this)};
258
void apply_to(MirWindow* surface) const
260
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
175
261
mir_surface_apply_spec(surface, *this);
263
mir_window_apply_spec(surface, *this);
178
operator MirSurfaceSpec*() const { return self.get(); }
267
operator MirWindowSpec*() const { return self.get(); }
181
static void deleter(MirSurfaceSpec* spec) { mir_surface_spec_release(spec); }
182
std::shared_ptr<MirSurfaceSpec> self;
270
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
271
static void deleter(MirWindowSpec* spec) { mir_surface_spec_release(spec); }
273
static void deleter(MirWindowSpec* spec) { mir_window_spec_release(spec); }
275
std::shared_ptr<MirWindowSpec> self;
187
#endif //MIRAL_TOOLKIT_SURFACE_SPEC_H_H
280
#endif //MIRAL_TOOLKIT_WINDOW_SPEC_H_H