19 #ifndef MIR_CLIENT_WINDOW_SPEC_H 20 #define MIR_CLIENT_WINDOW_SPEC_H 25 #include <mir_toolkit/mir_connection.h> 27 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) 28 #include <mir_toolkit/mir_surface.h> 30 #include <mir_toolkit/mir_window.h> 36 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) 37 using MirWindowCallback = mir_surface_callback;
38 using MirWindowEventCallback = mir_surface_event_callback;
39 auto const mir_create_window_spec = mir_connection_create_spec_for_changes;
40 auto const mir_window_spec_set_event_handler = mir_surface_spec_set_event_handler;
41 auto const mir_window_spec_set_name = mir_surface_spec_set_name;
42 auto const mir_window_spec_set_width = mir_surface_spec_set_width;
43 auto const mir_window_spec_set_height = mir_surface_spec_set_height;
44 auto const mir_window_spec_set_width_increment = mir_surface_spec_set_width_increment;
45 auto const mir_window_spec_set_height_increment = mir_surface_spec_set_height_increment;
46 auto const mir_window_spec_set_buffer_usage = mir_surface_spec_set_buffer_usage;
47 auto const mir_window_spec_set_pixel_format = mir_surface_spec_set_pixel_format;
48 auto const mir_window_spec_set_type = mir_surface_spec_set_type;
49 auto const mir_window_spec_set_shell_chrome = mir_surface_spec_set_shell_chrome;
50 auto const mir_window_spec_set_min_width = mir_surface_spec_set_min_width;
51 auto const mir_window_spec_set_min_height = mir_surface_spec_set_min_height;
52 auto const mir_window_spec_set_max_width = mir_surface_spec_set_max_width;
53 auto const mir_window_spec_set_max_height = mir_surface_spec_set_max_height;
54 auto const mir_window_spec_set_parent = mir_surface_spec_set_parent;
55 auto const mir_window_spec_set_state = mir_surface_spec_set_state;
56 auto const mir_window_spec_set_fullscreen_on_output = mir_surface_spec_set_fullscreen_on_output;
57 auto const mir_create_window = mir_surface_create;
58 auto const mir_create_window_sync = mir_surface_create_sync;
59 auto const mir_window_apply_spec = mir_surface_apply_spec;
60 auto const mir_window_spec_release = mir_surface_spec_release;
62 #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) 63 auto const mir_window_spec_set_placement = mir_surface_spec_set_placement;
75 explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {}
77 static auto for_normal_window(MirConnection* connection,
int width,
int height, MirPixelFormat format) -> WindowSpec
79 #if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0) 80 return WindowSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
82 auto spec = WindowSpec{mir_create_normal_window_spec(connection, width, height)};
83 mir_window_spec_set_pixel_format(spec, format);
88 #if MIR_CLIENT_VERSION > MIR_VERSION_NUMBER(3, 4, 0) 89 static auto for_normal_window(MirConnection* connection,
int width,
int height) -> WindowSpec
91 return WindowSpec{mir_create_normal_window_spec(connection, width, height)};
95 static auto for_menu(MirConnection* connection,
98 MirPixelFormat format,
101 MirEdgeAttachment edge) -> WindowSpec
103 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) 104 return WindowSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
106 auto spec = WindowSpec{mir_create_menu_window_spec(connection, width, height, parent, rect, edge)};
107 mir_window_spec_set_pixel_format(spec, format);
112 #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) 113 static auto for_tip(MirConnection* connection,
116 MirPixelFormat format,
119 MirEdgeAttachment edge) -> WindowSpec
121 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) 122 return WindowSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
124 auto spec = WindowSpec{mir_create_tip_window_spec(connection, width, height, parent, rect, edge)};
125 mir_window_spec_set_pixel_format(spec, format);
131 static auto for_dialog(MirConnection* connection,
134 MirPixelFormat format)-> WindowSpec
136 #if MIR_CLIENT_VERSION < MIR_VERSION_NUMBER(3, 5, 0) 137 return WindowSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
139 auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)};
140 mir_window_spec_set_pixel_format(spec, format);
145 static auto for_dialog(MirConnection* connection,
148 MirPixelFormat format,
149 MirWindow* parent) -> WindowSpec
151 return for_dialog(connection, width, height, format).set_parent(parent);
154 static auto for_input_method(MirConnection* connection,
int width,
int height, MirWindow* parent)
156 #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 5, 0) 157 auto spec = WindowSpec{mir_create_input_method_window_spec(connection, width, height)}
159 auto spec = WindowSpec{mir_create_surface_spec(connection)}
160 .set_buffer_usage(mir_buffer_usage_hardware)
161 .set_pixel_format(mir_pixel_format_invalid)
162 .set_size(width, height)
163 .set_type(mir_window_type_inputmethod)
169 static auto for_satellite(MirConnection* connection,
int width,
int height, MirWindow* parent)
172 return WindowSpec{mir_create_window_spec(connection)}
173 .set_buffer_usage(mir_buffer_usage_hardware)
174 .set_pixel_format(mir_pixel_format_invalid)
175 .set_size(width, height)
176 .set_type(mir_window_type_satellite)
180 static auto for_gloss(MirConnection* connection,
int width,
int height)
183 return WindowSpec{mir_create_window_spec(connection)}
184 .set_buffer_usage(mir_buffer_usage_hardware)
185 .set_pixel_format(mir_pixel_format_invalid)
186 .set_size(width, height)
187 .set_type(mir_window_type_gloss);
190 static auto for_changes(MirConnection* connection) -> WindowSpec
192 return WindowSpec{mir_create_window_spec(connection)};
195 auto set_buffer_usage(MirBufferUsage usage) -> WindowSpec&
197 mir_window_spec_set_buffer_usage(*
this, usage);
201 auto set_pixel_format(MirPixelFormat format) -> WindowSpec&
203 mir_window_spec_set_pixel_format(*
this, format);
207 auto set_type(MirWindowType type) -> WindowSpec&
209 mir_window_spec_set_type(*
this, type);
213 auto set_shell_chrome(MirShellChrome chrome) -> WindowSpec&
215 mir_window_spec_set_shell_chrome(*
this, chrome);
219 auto set_min_size(
int min_width,
int min_height) -> WindowSpec&
221 mir_window_spec_set_min_width(*
this, min_width);
222 mir_window_spec_set_min_height(*
this, min_height);
226 auto set_max_size(
int max_width,
int max_height) -> WindowSpec&
228 mir_window_spec_set_max_width(*
this, max_width);
229 mir_window_spec_set_max_height(*
this, max_height);
233 auto set_size_inc(
int width_inc,
int height_inc) -> WindowSpec&
235 mir_window_spec_set_width_increment(*
this, width_inc);
236 mir_window_spec_set_height_increment(*
this, height_inc);
240 auto set_size(
int width,
int height) -> WindowSpec&
242 mir_window_spec_set_width(*
this, width);
243 mir_window_spec_set_height(*
this, height);
247 auto set_name(
char const* name) -> WindowSpec&
249 mir_window_spec_set_name(*
this, name);
253 auto set_event_handler(MirWindowEventCallback callback,
void* context) -> WindowSpec&
255 mir_window_spec_set_event_handler(*
this, callback, context);
259 auto set_fullscreen_on_output(uint32_t output_id) -> WindowSpec&
261 mir_window_spec_set_fullscreen_on_output(*
this, output_id);
265 #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) 266 auto set_placement(
const MirRectangle* rect,
267 MirPlacementGravity rect_gravity,
268 MirPlacementGravity surface_gravity,
269 MirPlacementHints placement_hints,
271 int offset_dy) -> WindowSpec&
273 mir_window_spec_set_placement(*
this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy);
277 auto set_placement(
const MirRectangle* ,
278 MirPlacementGravity ,
279 MirPlacementGravity ,
288 auto set_parent(MirWindow* parent) -> WindowSpec&
290 mir_window_spec_set_parent(*
this, parent);
294 auto set_state(MirWindowState state) -> WindowSpec&
296 mir_window_spec_set_state(*
this, state);
300 template<
typename Context>
301 void create_window(
void (* callback)(MirWindow*, Context*), Context* context)
const 303 mir_create_window(*
this, reinterpret_cast<MirWindowCallback>(callback), context);
306 auto create_window() const -> Window
308 return Window{mir_create_window_sync(*
this)};
311 void apply_to(MirWindow* window)
const 313 mir_window_apply_spec(window, *
this);
316 operator MirWindowSpec*()
const {
return self.get(); }
319 static void deleter(MirWindowSpec* spec) { mir_window_spec_release(spec); }
320 std::shared_ptr<MirWindowSpec>
self;
324 void mir_window_spec_release(WindowSpec
const& spec) =
delete;
325 void mir_surface_spec_release(WindowSpec
const& spec) =
delete;
329 #endif //MIRAL_TOOLKIT_WINDOW_SPEC_H_H Definition: connection.h:26