~ci-train-bot/miral/miral-ubuntu-zesty-2476

« back to all changes in this revision

Viewing changes to miral/window_info.cpp

  • Committer: Bileto Bot
  • Date: 2017-01-27 03:02:13 UTC
  • mfrom: (330.2.167 miral0)
  • Revision ID: ci-train-bot@canonical.com-20170127030213-q62prxw1xh7kasbu
* New upstream release 1.1.0 (https://launchpad.net/miral/+milestone/1.1)
  - ABI summary:
    . miral ABI unchanged at 2
  - Enhancements:
    . Compatibility with Mir 0.26 and update API to use the new Mir types and
      enums.
    . Logging of exceptions added to --window-management-trace
    . Rename WindowManagementPolicy::place_new_surface => place_new_window"
  - Bugs fixed:
    . top-level window is not raised along with its child (LP: #1658085)
    . miral-shell depends on default cursor theme being installed
      (LP: #1658159)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "miral/window_info.h"
20
20
 
 
21
#include "both_versions.h"
 
22
 
21
23
#include <mir/scene/surface.h>
 
24
#include <mir/version.h>
22
25
 
23
26
#include <limits>
24
27
 
41
44
 
42
45
    Window window;
43
46
    std::string name;
44
 
    MirSurfaceType type;
45
 
    MirSurfaceState state;
 
47
    MirWindowType type;
 
48
    MirWindowState state;
46
49
    mir::geometry::Rectangle restore_rect;
47
50
    Window parent;
48
51
    std::vector <Window> children;
64
67
miral::WindowInfo::Self::Self(Window window, WindowSpecification const& params) :
65
68
    window{window},
66
69
    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)},
 
70
    type{optional_value_or_default(params.type(), mir_window_type_normal)},
 
71
    state{optional_value_or_default(params.state(), mir_window_state_restored)},
69
72
    restore_rect{params.top_left().value(), params.size().value()},
70
73
    min_width{optional_value_or_default(params.min_width())},
71
74
    min_height{optional_value_or_default(params.min_height())},
86
89
}
87
90
 
88
91
miral::WindowInfo::Self::Self() :
89
 
    type{mir_surface_type_normal},
90
 
    state{mir_surface_state_unknown},
 
92
    type{mir_window_type_normal},
 
93
    state{mir_window_state_unknown},
91
94
    preferred_orientation{mir_orientation_mode_any}
92
95
{
93
96
}
123
126
{
124
127
    switch (type())
125
128
    {
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.       */
 
129
    case mir_window_type_normal:       /**< AKA "regular"                       */
 
130
    case mir_window_type_utility:      /**< AKA "floating"                      */
 
131
    case mir_window_type_dialog:
 
132
    case mir_window_type_satellite:    /**< AKA "toolbox"/"toolbar"             */
 
133
    case mir_window_type_freestyle:
 
134
    case mir_window_type_menu:
 
135
    case mir_window_type_inputmethod:  /**< AKA "OSK" or handwriting etc.       */
133
136
        return true;
134
137
 
135
 
    case mir_surface_type_gloss:
136
 
    case mir_surface_type_tip:          /**< AKA "tooltip"                       */
 
138
    case mir_window_type_gloss:
 
139
    case mir_window_type_tip:          /**< AKA "tooltip"                       */
137
140
    default:
138
141
        // Cannot have input focus
139
142
        return false;
144
147
{
145
148
    switch (type())
146
149
    {
147
 
    case mir_surface_type_overlay:;
148
 
    case mir_surface_type_inputmethod:
149
 
    case mir_surface_type_satellite:
150
 
    case mir_surface_type_tip:
 
150
    case mir_window_type_gloss:;
 
151
    case mir_window_type_inputmethod:
 
152
    case mir_window_type_satellite:
 
153
    case mir_window_type_tip:
151
154
        return true;
152
155
 
153
156
    default:
155
158
    }
156
159
}
157
160
 
158
 
bool miral::WindowInfo::can_morph_to(MirSurfaceType new_type) const
 
161
MIRAL_BOTH_VERSIONS(
 
162
    _ZNK5miral10WindowInfo12can_morph_toE14MirSurfaceType, MIRAL_1.0,
 
163
    _ZNK5miral10WindowInfo12can_morph_toE13MirWindowType,  MIRAL_1.1)
 
164
bool miral::WindowInfo::can_morph_to(MirWindowType new_type) const
159
165
{
160
166
    switch (new_type)
161
167
    {
162
 
    case mir_surface_type_normal:
163
 
    case mir_surface_type_utility:
164
 
    case mir_surface_type_satellite:
 
168
    case mir_window_type_normal:
 
169
    case mir_window_type_utility:
 
170
    case mir_window_type_satellite:
165
171
        switch (type())
166
172
        {
167
 
        case mir_surface_type_normal:
168
 
        case mir_surface_type_utility:
169
 
        case mir_surface_type_dialog:
170
 
        case mir_surface_type_satellite:
 
173
        case mir_window_type_normal:
 
174
        case mir_window_type_utility:
 
175
        case mir_window_type_dialog:
 
176
        case mir_window_type_satellite:
171
177
            return true;
172
178
 
173
179
        default:
175
181
        }
176
182
        break;
177
183
 
178
 
    case mir_surface_type_dialog:
 
184
    case mir_window_type_dialog:
179
185
        switch (type())
180
186
        {
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:
 
187
        case mir_window_type_normal:
 
188
        case mir_window_type_utility:
 
189
        case mir_window_type_dialog:
 
190
        case mir_window_type_menu:
 
191
        case mir_window_type_satellite:
186
192
            return true;
187
193
 
188
194
        default:
201
207
{
202
208
    switch (type())
203
209
    {
204
 
    case mir_surface_type_normal:
205
 
    case mir_surface_type_utility:
 
210
    case mir_window_type_normal:
 
211
    case mir_window_type_utility:
206
212
        return true;
207
213
 
208
214
    default:
214
220
{
215
221
    switch (state())
216
222
    {
217
 
    case mir_surface_state_hidden:
218
 
    case mir_surface_state_minimized:
 
223
    case mir_window_state_hidden:
 
224
    case mir_window_state_minimized:
219
225
        return false;
220
226
    default:
221
227
        if (std::shared_ptr<mir::scene::Surface> surface = window())
312
318
 
313
319
    switch (state())
314
320
    {
315
 
    case mir_surface_state_restored:
 
321
    case mir_window_state_restored:
316
322
        break;
317
323
 
318
324
        // "A vertically maximised window is anchored to the top and bottom of
319
325
        // the available workspace and can have any width."
320
 
    case mir_surface_state_vertmaximized:
 
326
    case mir_window_state_vertmaximized:
321
327
        new_pos.y = self->window.top_left().y;
322
328
        new_size.height = self->window.size().height;
323
329
        break;
324
330
 
325
331
        // "A horizontally maximised window is anchored to the left and right of
326
332
        // the available workspace and can have any height"
327
 
    case mir_surface_state_horizmaximized:
 
333
    case mir_window_state_horizmaximized:
328
334
        new_pos.x = self->window.top_left().x;
329
335
        new_size.width = self->window.size().width;
330
336
        break;
332
338
        // "A maximised window is anchored to the top, bottom, left and right of the
333
339
        // available workspace. For example, if the launcher is always-visible then
334
340
        // the left-edge of the window is anchored to the right-edge of the launcher."
335
 
    case mir_surface_state_maximized:
 
341
    case mir_window_state_maximized:
336
342
    default:
337
343
        new_pos.x = self->window.top_left().x;
338
344
        new_pos.y = self->window.top_left().y;
345
351
    requested_size = new_size;
346
352
}
347
353
 
348
 
bool miral::WindowInfo::needs_titlebar(MirSurfaceType type)
 
354
MIRAL_BOTH_VERSIONS(
 
355
    _ZN5miral10WindowInfo14needs_titlebarE14MirSurfaceType, MIRAL_1.0,
 
356
    _ZN5miral10WindowInfo14needs_titlebarE13MirWindowType,  MIRAL_1.1)
 
357
bool miral::WindowInfo::needs_titlebar(MirWindowType type)
349
358
{
350
359
    switch (type)
351
360
    {
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:
 
361
    case mir_window_type_freestyle:
 
362
    case mir_window_type_menu:
 
363
    case mir_window_type_inputmethod:
 
364
    case mir_window_type_gloss:
 
365
    case mir_window_type_tip:
357
366
        // No decorations for these surface types
358
367
        return false;
359
368
    default:
361
370
    }
362
371
}
363
372
 
364
 
auto miral::WindowInfo::type() const -> MirSurfaceType
 
373
auto miral::WindowInfo::type() const -> MirWindowType
365
374
{
366
375
    return self->type;
367
376
}
368
377
 
369
 
void miral::WindowInfo::type(MirSurfaceType type)
 
378
MIRAL_BOTH_VERSIONS(
 
379
    _ZN5miral10WindowInfo4typeE14MirSurfaceType, MIRAL_1.0,
 
380
    _ZN5miral10WindowInfo4typeE13MirWindowType,  MIRAL_1.1)
 
381
void miral::WindowInfo::type(MirWindowType type)
370
382
{
371
383
    self->type = type;
372
384
}
373
385
 
374
 
auto miral::WindowInfo::state() const -> MirSurfaceState
 
386
auto miral::WindowInfo::state() const -> MirWindowState
375
387
{
376
388
    return self->state;
377
389
}
378
390
 
379
 
void miral::WindowInfo::state(MirSurfaceState state)
 
391
MIRAL_BOTH_VERSIONS(
 
392
    _ZN5miral10WindowInfo5stateE15MirSurfaceState, MIRAL_1.0,
 
393
    _ZN5miral10WindowInfo5stateE14MirWindowState,  MIRAL_1.1)
 
394
void miral::WindowInfo::state(MirWindowState state)
380
395
{
381
396
    self->state = state;
382
397
}