~alan-griffiths/miral/fix-1661256

« back to all changes in this revision

Viewing changes to include/miral/toolkit/window_spec.h

  • Committer: Alan Griffiths
  • Date: 2017-01-26 15:51:25 UTC
  • mfrom: (494.3.1 miral2)
  • Revision ID: alan@octopull.co.uk-20170126155125-nlylx1t1pfgzmlq6
[toolkit] rename the helper types to reflect new Mir terminology

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17
17
 */
18
18
 
19
 
#ifndef MIRAL_TOOLKIT_SURFACE_SPEC_H
20
 
#define MIRAL_TOOLKIT_SURFACE_SPEC_H
 
19
#ifndef MIRAL_TOOLKIT_WINDOW_SPEC_H
 
20
#define MIRAL_TOOLKIT_WINDOW_SPEC_H
21
21
 
22
 
#include <miral/toolkit/surface.h>
 
22
#include <miral/toolkit/window.h>
23
23
#include <miral/detail/mir_forward_compatibility.h>
24
24
 
25
25
#include <mir_toolkit/mir_surface.h>
33
33
namespace toolkit
34
34
{
35
35
/// Handle class for MirWindowSpec - provides automatic reference counting, method chaining.
36
 
class SurfaceSpec
 
36
class WindowSpec
37
37
{
38
38
public:
39
 
    explicit SurfaceSpec(MirWindowSpec* spec) : self{spec, deleter} {}
 
39
    explicit WindowSpec(MirWindowSpec* spec) : self{spec, deleter} {}
40
40
 
41
 
    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
42
    {
43
43
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
44
 
        return SurfaceSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
 
44
        return WindowSpec{mir_connection_create_spec_for_normal_surface(connection, width, height, format)};
45
45
#else
46
 
        auto spec = SurfaceSpec{mir_create_normal_window_spec(connection, width, height)};
 
46
        auto spec = WindowSpec{mir_create_normal_window_spec(connection, width, height)};
47
47
        mir_window_spec_set_pixel_format(spec, format);
48
48
        return spec;
49
49
#endif
55
55
                         MirPixelFormat format,
56
56
                         MirWindow* parent,
57
57
                         MirRectangle* rect,
58
 
                         MirEdgeAttachment edge) -> SurfaceSpec
 
58
                         MirEdgeAttachment edge) -> WindowSpec
59
59
    {
60
60
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
61
 
        return SurfaceSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
 
61
        return WindowSpec{mir_connection_create_spec_for_menu(connection, width, height, format, parent, rect, edge)};
62
62
#else
63
 
        auto spec = SurfaceSpec{mir_create_menu_window_spec(connection, width, height, parent, rect, edge)};
 
63
        auto spec = WindowSpec{mir_create_menu_window_spec(connection, width, height, parent, rect, edge)};
64
64
        mir_window_spec_set_pixel_format(spec, format);
65
65
        return spec;
66
66
#endif
73
73
                        MirPixelFormat format,
74
74
                        MirWindow* parent,
75
75
                        MirRectangle* rect,
76
 
                        MirEdgeAttachment edge) -> SurfaceSpec
 
76
                        MirEdgeAttachment edge) -> WindowSpec
77
77
    {
78
78
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
79
 
        return SurfaceSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
 
79
        return WindowSpec{mir_connection_create_spec_for_tip(connection, width, height, format, parent, rect, edge)};
80
80
#else
81
 
        auto spec = SurfaceSpec{mir_create_tip_window_spec(connection, width, height, parent, rect, edge)};
 
81
        auto spec = WindowSpec{mir_create_tip_window_spec(connection, width, height, parent, rect, edge)};
82
82
        mir_window_spec_set_pixel_format(spec, format);
83
83
        return spec;
84
84
#endif
88
88
    static auto for_dialog(MirConnection* connection,
89
89
                           int width,
90
90
                           int height,
91
 
                           MirPixelFormat format)-> SurfaceSpec
 
91
                           MirPixelFormat format)-> WindowSpec
92
92
    {
93
93
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
94
 
        return SurfaceSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
 
94
        return WindowSpec{mir_connection_create_spec_for_dialog(connection, width, height, format)};
95
95
#else
96
 
        auto spec = SurfaceSpec{mir_create_dialog_window_spec(connection, width, height)};
 
96
        auto spec = WindowSpec{mir_create_dialog_window_spec(connection, width, height)};
97
97
        mir_window_spec_set_pixel_format(spec, format);
98
98
        return spec;
99
99
#endif
103
103
                           int width,
104
104
                           int height,
105
105
                           MirPixelFormat format,
106
 
                           MirWindow* parent) -> SurfaceSpec
 
106
                           MirWindow* parent) -> WindowSpec
107
107
    {
108
108
        return for_dialog(connection, width, height, format).set_parent(parent);
109
109
    }
110
110
 
111
 
    static auto for_changes(MirConnection* connection) -> SurfaceSpec
 
111
    static auto for_changes(MirConnection* connection) -> WindowSpec
112
112
    {
113
113
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
114
 
        return SurfaceSpec{mir_connection_create_spec_for_changes(connection)};
 
114
        return WindowSpec{mir_connection_create_spec_for_changes(connection)};
115
115
#else
116
 
        return SurfaceSpec{mir_create_window_spec(connection)};
 
116
        return WindowSpec{mir_create_window_spec(connection)};
117
117
#endif
118
118
    }
119
119
 
120
 
    auto set_buffer_usage(MirBufferUsage usage) -> SurfaceSpec&
 
120
    auto set_buffer_usage(MirBufferUsage usage) -> WindowSpec&
121
121
    {
122
122
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
123
123
        mir_surface_spec_set_buffer_usage(*this, usage);
127
127
        return *this;
128
128
    }
129
129
 
130
 
    auto set_type(MirWindowType type) -> SurfaceSpec&
 
130
    auto set_type(MirWindowType type) -> WindowSpec&
131
131
    {
132
132
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
133
133
        mir_surface_spec_set_type(*this, type);
137
137
        return *this;
138
138
    }
139
139
 
140
 
    auto set_min_size(int min_width, int min_height) -> SurfaceSpec&
 
140
    auto set_min_size(int min_width, int min_height) -> WindowSpec&
141
141
    {
142
142
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
143
143
        mir_surface_spec_set_min_width(*this, min_width);
149
149
        return *this;
150
150
    }
151
151
 
152
 
    auto set_max_size(int max_width, int max_height) -> SurfaceSpec&
 
152
    auto set_max_size(int max_width, int max_height) -> WindowSpec&
153
153
    {
154
154
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
155
155
        mir_surface_spec_set_max_width(*this, max_width);
161
161
        return *this;
162
162
    }
163
163
 
164
 
    auto set_size_inc(int width_inc, int height_inc) -> SurfaceSpec&
 
164
    auto set_size_inc(int width_inc, int height_inc) -> WindowSpec&
165
165
    {
166
166
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
167
167
        mir_surface_spec_set_width_increment(*this, width_inc);
173
173
        return *this;
174
174
    }
175
175
 
176
 
    auto set_size(int width, int height) -> SurfaceSpec&
 
176
    auto set_size(int width, int height) -> WindowSpec&
177
177
    {
178
178
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
179
179
        mir_surface_spec_set_width(*this, width);
185
185
        return *this;
186
186
    }
187
187
 
188
 
    auto set_name(char const* name) -> SurfaceSpec&
 
188
    auto set_name(char const* name) -> WindowSpec&
189
189
    {
190
190
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
191
191
        mir_surface_spec_set_name(*this, name);
196
196
    }
197
197
 
198
198
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
199
 
    auto set_event_handler(mir_surface_event_callback callback, void* context) -> SurfaceSpec&
 
199
    auto set_event_handler(mir_surface_event_callback callback, void* context) -> WindowSpec&
200
200
    {
201
201
        mir_surface_spec_set_event_handler(*this, callback, context);
202
202
        return *this;
203
203
    }
204
204
#else
205
 
    auto set_event_handler(MirWindowEventCallback callback, void* context) -> SurfaceSpec&
 
205
    auto set_event_handler(MirWindowEventCallback callback, void* context) -> WindowSpec&
206
206
    {
207
207
        mir_window_spec_set_event_handler(*this, callback, context);
208
208
        return *this;
215
215
                       MirPlacementGravity surface_gravity,
216
216
                       MirPlacementHints   placement_hints,
217
217
                       int                 offset_dx,
218
 
                       int                 offset_dy) -> SurfaceSpec&
 
218
                       int                 offset_dy) -> WindowSpec&
219
219
    {
220
220
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
221
221
        mir_surface_spec_set_placement(*this, rect, rect_gravity, surface_gravity, placement_hints, offset_dx, offset_dy);
226
226
    }
227
227
#endif
228
228
 
229
 
    auto set_parent(MirWindow* parent) -> SurfaceSpec&
 
229
    auto set_parent(MirWindow* parent) -> WindowSpec&
230
230
    {
231
231
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
232
232
        mir_surface_spec_set_parent(*this, parent);
246
246
#endif
247
247
    }
248
248
 
249
 
    auto create_surface() const -> Surface
 
249
    auto create_surface() const -> Window
250
250
    {
251
251
#if MIR_CLIENT_VERSION <= MIR_VERSION_NUMBER(3, 4, 0)
252
 
        return Surface{mir_surface_create_sync(*this)};
 
252
        return Window{mir_surface_create_sync(*this)};
253
253
#else
254
 
        return Surface{mir_create_window_sync(*this)};
 
254
        return Window{mir_create_window_sync(*this)};
255
255
#endif
256
256
    }
257
257
 
277
277
}
278
278
}
279
279
 
280
 
#endif //MIRAL_TOOLKIT_SURFACE_SPEC_H_H
 
280
#endif //MIRAL_TOOLKIT_WINDOW_SPEC_H_H