19 #ifndef MIRAL_TOOLKIT_SURFACE_SPEC_H 20 #define MIRAL_TOOLKIT_SURFACE_SPEC_H 24 #include <mir_toolkit/mir_surface.h> 25 #include <mir_toolkit/mir_connection.h> 26 #include <mir_toolkit/version.h> 38 explicit SurfaceSpec(MirSurfaceSpec* spec) : self{spec, deleter} {}
42 return SurfaceSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
45 static auto for_menu(MirConnection* connection,
48 MirPixelFormat format,
53 return SurfaceSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
56 #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) 57 static auto for_tip(MirConnection* connection,
60 MirPixelFormat format,
65 return SurfaceSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
74 return SurfaceSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
80 MirPixelFormat format,
83 return for_dialog(connection, width, height, format).set_parent(parent);
88 return SurfaceSpec{mir_connection_create_spec_for_changes(connection)};
93 mir_surface_spec_set_buffer_usage(*
this, usage);
99 mir_surface_spec_set_type(*
this, type);
105 mir_surface_spec_set_min_width(*
this, min_width);
106 mir_surface_spec_set_min_height(*
this, min_height);
112 mir_surface_spec_set_max_width(*
this, max_width);
113 mir_surface_spec_set_max_height(*
this, max_height);
119 mir_surface_spec_set_width_increment(*
this, width_inc);
120 mir_surface_spec_set_height_increment(*
this, height_inc);
126 mir_surface_spec_set_width(*
this, width);
127 mir_surface_spec_set_height(*
this, height);
133 mir_surface_spec_set_name(*
this, name);
139 mir_surface_spec_set_event_handler(*
this, callback, context);
143 #if MIR_CLIENT_VERSION >= MIR_VERSION_NUMBER(3, 4, 0) 145 MirPlacementGravity rect_gravity,
146 MirPlacementGravity surface_gravity,
147 MirPlacementHints placement_hints,
151 mir_surface_spec_set_placement(*
this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy);
158 mir_surface_spec_set_parent(*
this, parent);
162 template<
typename Context>
163 void create_surface(
void (*callback)(MirSurface*, Context*), Context* context)
const 165 mir_surface_create(*
this, reinterpret_cast<mir_surface_callback>(callback), context);
170 return Surface{mir_surface_create_sync(*
this)};
175 mir_surface_apply_spec(surface, *
this);
178 operator MirSurfaceSpec*()
const {
return self.get(); }
181 static void deleter(MirSurfaceSpec* spec) { mir_surface_spec_release(spec); }
182 std::shared_ptr<MirSurfaceSpec>
self;
187 #endif //MIRAL_TOOLKIT_SURFACE_SPEC_H_H
Mir Abstraction Layer.
Definition: active_outputs.h:27