~afrantzis/mir/fix-1441620-simple-dispatch-thread-self-destruction-test

« back to all changes in this revision

Viewing changes to examples/server_example_canonical_window_manager.cpp

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2015-04-09 12:25:27 UTC
  • mfrom: (2460.1.2 mir1)
  • Revision ID: tarmac-20150409122527-zmuwqdhtd2t1xg4u
examples: Partial implementation of logic to create new surfaces on the "active display".

Approved by PS Jenkins bot, Kevin DuBois.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
{
106
106
    auto parameters = request_parameters;
107
107
 
108
 
    auto width = std::min(display_area.size.width.as_int(), parameters.size.width.as_int());
109
 
    auto height = std::min(display_area.size.height.as_int(), parameters.size.height.as_int());
 
108
    auto const active_display = tools->active_display();
 
109
 
 
110
    auto width = std::min(active_display.size.width.as_int(), parameters.size.width.as_int());
 
111
    auto height = std::min(active_display.size.height.as_int(), parameters.size.height.as_int());
110
112
    if (!width) width = 1;
111
113
    if (!height) height = 1;
112
114
    parameters.size = Size{width, height};
139
141
 
140
142
            // "If there is not room to do that, Mir should place it as if it was the app’s
141
143
            // only regular surface."
142
 
            positioned = display_area.contains(parameters.top_left + as_displacement(parameters.size));
 
144
            positioned = active_display.contains(parameters.top_left + as_displacement(parameters.size));
143
145
        }
144
146
    }
145
147
 
154
156
 
155
157
        if (edge_attachment && mir_edge_attachment_vertical)
156
158
        {
157
 
            if (display_area.contains(top_right + Displacement{width, height}))
 
159
            if (active_display.contains(top_right + Displacement{width, height}))
158
160
            {
159
161
                parameters.top_left = top_right;
160
162
                positioned = true;
161
163
            }
162
 
            else if (display_area.contains(top_left + Displacement{-width, height}))
 
164
            else if (active_display.contains(top_left + Displacement{-width, height}))
163
165
            {
164
166
                parameters.top_left = top_left + Displacement{-width, 0};
165
167
                positioned = true;
168
170
 
169
171
        if (edge_attachment && mir_edge_attachment_horizontal)
170
172
        {
171
 
            if (display_area.contains(bot_left + Displacement{width, height}))
 
173
            if (active_display.contains(bot_left + Displacement{width, height}))
172
174
            {
173
175
                parameters.top_left = bot_left;
174
176
                positioned = true;
175
177
            }
176
 
            else if (display_area.contains(top_left + Displacement{width, -height}))
 
178
            else if (active_display.contains(top_left + Displacement{width, -height}))
177
179
            {
178
180
                parameters.top_left = top_left + Displacement{0, -height};
179
181
                positioned = true;
187
189
        // opening it, Mir should position it horizontally centered, and vertically
188
190
        // such that the top margin is half the bottom margin. (Vertical centering
189
191
        // would look too low, and would allow little room for cascading.)"
190
 
        auto centred = display_area.top_left + 0.5*(
191
 
            as_displacement(display_area.size) - as_displacement(parameters.size));
 
192
        auto centred = active_display.top_left + 0.5*(
 
193
            as_displacement(active_display.size) - as_displacement(parameters.size));
192
194
 
193
 
        parameters.top_left = centred - DeltaY{(display_area.size.height.as_int()-height)/6};
 
195
        parameters.top_left = centred - DeltaY{(active_display.size.height.as_int()-height)/6};
194
196
    }
195
197
 
196
198
    return parameters;