~alan-griffiths/miral/init-1.1

« back to all changes in this revision

Viewing changes to miral/window_info.cpp

  • Committer: Alan Griffiths
  • Date: 2017-01-18 15:47:16 UTC
  • mfrom: (479.3.1 miral3)
  • Revision ID: alan@octopull.co.uk-20170118154716-ijibh8bddwy0v4p2
Code compatibility with Mir 0.26

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
    Window window;
43
43
    std::string name;
44
 
    MirSurfaceType type;
45
 
    MirSurfaceState state;
 
44
    MirWindowType type;
 
45
    MirWindowState state;
46
46
    mir::geometry::Rectangle restore_rect;
47
47
    Window parent;
48
48
    std::vector <Window> children;
64
64
miral::WindowInfo::Self::Self(Window window, WindowSpecification const& params) :
65
65
    window{window},
66
66
    name{params.name().value()},
67
 
    type{optional_value_or_default(params.type(), mir_surface_type_normal)},
68
 
    state{optional_value_or_default(params.state(), mir_surface_state_restored)},
 
67
    type{optional_value_or_default(params.type(), mir_window_type_normal)},
 
68
    state{optional_value_or_default(params.state(), mir_window_state_restored)},
69
69
    restore_rect{params.top_left().value(), params.size().value()},
70
70
    min_width{optional_value_or_default(params.min_width())},
71
71
    min_height{optional_value_or_default(params.min_height())},
86
86
}
87
87
 
88
88
miral::WindowInfo::Self::Self() :
89
 
    type{mir_surface_type_normal},
90
 
    state{mir_surface_state_unknown},
 
89
    type{mir_window_type_normal},
 
90
    state{mir_window_state_unknown},
91
91
    preferred_orientation{mir_orientation_mode_any}
92
92
{
93
93
}
123
123
{
124
124
    switch (type())
125
125
    {
126
 
    case mir_surface_type_normal:       /**< AKA "regular"                       */
127
 
    case mir_surface_type_utility:      /**< AKA "floating"                      */
128
 
    case mir_surface_type_dialog:
129
 
    case mir_surface_type_satellite:    /**< AKA "toolbox"/"toolbar"             */
130
 
    case mir_surface_type_freestyle:
131
 
    case mir_surface_type_menu:
132
 
    case mir_surface_type_inputmethod:  /**< AKA "OSK" or handwriting etc.       */
 
126
    case mir_window_type_normal:       /**< AKA "regular"                       */
 
127
    case mir_window_type_utility:      /**< AKA "floating"                      */
 
128
    case mir_window_type_dialog:
 
129
    case mir_window_type_satellite:    /**< AKA "toolbox"/"toolbar"             */
 
130
    case mir_window_type_freestyle:
 
131
    case mir_window_type_menu:
 
132
    case mir_window_type_inputmethod:  /**< AKA "OSK" or handwriting etc.       */
133
133
        return true;
134
134
 
135
 
    case mir_surface_type_gloss:
136
 
    case mir_surface_type_tip:          /**< AKA "tooltip"                       */
 
135
    case mir_window_type_gloss:
 
136
    case mir_window_type_tip:          /**< AKA "tooltip"                       */
137
137
    default:
138
138
        // Cannot have input focus
139
139
        return false;
144
144
{
145
145
    switch (type())
146
146
    {
147
 
    case mir_surface_type_overlay:;
148
 
    case mir_surface_type_inputmethod:
149
 
    case mir_surface_type_satellite:
150
 
    case mir_surface_type_tip:
 
147
    case mir_window_type_gloss:;
 
148
    case mir_window_type_inputmethod:
 
149
    case mir_window_type_satellite:
 
150
    case mir_window_type_tip:
151
151
        return true;
152
152
 
153
153
    default:
155
155
    }
156
156
}
157
157
 
158
 
bool miral::WindowInfo::can_morph_to(MirSurfaceType new_type) const
 
158
bool miral::WindowInfo::can_morph_to(MirWindowType new_type) const
159
159
{
160
160
    switch (new_type)
161
161
    {
162
 
    case mir_surface_type_normal:
163
 
    case mir_surface_type_utility:
164
 
    case mir_surface_type_satellite:
 
162
    case mir_window_type_normal:
 
163
    case mir_window_type_utility:
 
164
    case mir_window_type_satellite:
165
165
        switch (type())
166
166
        {
167
 
        case mir_surface_type_normal:
168
 
        case mir_surface_type_utility:
169
 
        case mir_surface_type_dialog:
170
 
        case mir_surface_type_satellite:
 
167
        case mir_window_type_normal:
 
168
        case mir_window_type_utility:
 
169
        case mir_window_type_dialog:
 
170
        case mir_window_type_satellite:
171
171
            return true;
172
172
 
173
173
        default:
175
175
        }
176
176
        break;
177
177
 
178
 
    case mir_surface_type_dialog:
 
178
    case mir_window_type_dialog:
179
179
        switch (type())
180
180
        {
181
 
        case mir_surface_type_normal:
182
 
        case mir_surface_type_utility:
183
 
        case mir_surface_type_dialog:
184
 
        case mir_surface_type_popover:
185
 
        case mir_surface_type_satellite:
 
181
        case mir_window_type_normal:
 
182
        case mir_window_type_utility:
 
183
        case mir_window_type_dialog:
 
184
        case mir_window_type_menu:
 
185
        case mir_window_type_satellite:
186
186
            return true;
187
187
 
188
188
        default:
201
201
{
202
202
    switch (type())
203
203
    {
204
 
    case mir_surface_type_normal:
205
 
    case mir_surface_type_utility:
 
204
    case mir_window_type_normal:
 
205
    case mir_window_type_utility:
206
206
        return true;
207
207
 
208
208
    default:
214
214
{
215
215
    switch (state())
216
216
    {
217
 
    case mir_surface_state_hidden:
218
 
    case mir_surface_state_minimized:
 
217
    case mir_window_state_hidden:
 
218
    case mir_window_state_minimized:
219
219
        return false;
220
220
    default:
221
221
        if (std::shared_ptr<mir::scene::Surface> surface = window())
312
312
 
313
313
    switch (state())
314
314
    {
315
 
    case mir_surface_state_restored:
 
315
    case mir_window_state_restored:
316
316
        break;
317
317
 
318
318
        // "A vertically maximised window is anchored to the top and bottom of
319
319
        // the available workspace and can have any width."
320
 
    case mir_surface_state_vertmaximized:
 
320
    case mir_window_state_vertmaximized:
321
321
        new_pos.y = self->window.top_left().y;
322
322
        new_size.height = self->window.size().height;
323
323
        break;
324
324
 
325
325
        // "A horizontally maximised window is anchored to the left and right of
326
326
        // the available workspace and can have any height"
327
 
    case mir_surface_state_horizmaximized:
 
327
    case mir_window_state_horizmaximized:
328
328
        new_pos.x = self->window.top_left().x;
329
329
        new_size.width = self->window.size().width;
330
330
        break;
332
332
        // "A maximised window is anchored to the top, bottom, left and right of the
333
333
        // available workspace. For example, if the launcher is always-visible then
334
334
        // the left-edge of the window is anchored to the right-edge of the launcher."
335
 
    case mir_surface_state_maximized:
 
335
    case mir_window_state_maximized:
336
336
    default:
337
337
        new_pos.x = self->window.top_left().x;
338
338
        new_pos.y = self->window.top_left().y;
345
345
    requested_size = new_size;
346
346
}
347
347
 
348
 
bool miral::WindowInfo::needs_titlebar(MirSurfaceType type)
 
348
bool miral::WindowInfo::needs_titlebar(MirWindowType type)
349
349
{
350
350
    switch (type)
351
351
    {
352
 
    case mir_surface_type_freestyle:
353
 
    case mir_surface_type_menu:
354
 
    case mir_surface_type_inputmethod:
355
 
    case mir_surface_type_gloss:
356
 
    case mir_surface_type_tip:
 
352
    case mir_window_type_freestyle:
 
353
    case mir_window_type_menu:
 
354
    case mir_window_type_inputmethod:
 
355
    case mir_window_type_gloss:
 
356
    case mir_window_type_tip:
357
357
        // No decorations for these surface types
358
358
        return false;
359
359
    default:
361
361
    }
362
362
}
363
363
 
364
 
auto miral::WindowInfo::type() const -> MirSurfaceType
 
364
auto miral::WindowInfo::type() const -> MirWindowType
365
365
{
366
366
    return self->type;
367
367
}
368
368
 
369
 
void miral::WindowInfo::type(MirSurfaceType type)
 
369
void miral::WindowInfo::type(MirWindowType type)
370
370
{
371
371
    self->type = type;
372
372
}
373
373
 
374
 
auto miral::WindowInfo::state() const -> MirSurfaceState
 
374
auto miral::WindowInfo::state() const -> MirWindowState
375
375
{
376
376
    return self->state;
377
377
}
378
378
 
379
 
void miral::WindowInfo::state(MirSurfaceState state)
 
379
void miral::WindowInfo::state(MirWindowState state)
380
380
{
381
381
    self->state = state;
382
382
}