~lukas-kde/qtmir/betterSessionManagement

« back to all changes in this revision

Viewing changes to src/platforms/mirserver/windowmanagementpolicy.cpp

  • Committer: Lukáš Tinkl
  • Date: 2017-03-24 11:51:00 UTC
  • mfrom: (590.1.35 qtmir)
  • Revision ID: lukas.tinkl@canonical.com-20170324115100-n0itqdupc26qe6g6
merge trunk, resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include "windowmanagementpolicy.h"
18
18
 
 
19
#include "eventdispatch.h"
19
20
#include "initialsurfacesizes.h"
20
21
#include "screensmodel.h"
21
22
#include "surfaceobserver.h"
24
25
#include "miral/window_specification.h"
25
26
 
26
27
#include "mirqtconversion.h"
 
28
#include "tracepoints.h"
27
29
 
28
 
#include <mir/scene/surface.h>
29
30
#include <QDebug>
30
31
 
31
32
namespace qtmir {
89
90
 
90
91
void WindowManagementPolicy::handle_modify_window(
91
92
    miral::WindowInfo &windowInfo,
92
 
    const miral::WindowSpecification &modifications)
 
93
    const miral::WindowSpecification &modificationsClient)
93
94
{
94
 
    // TODO this applies the default policy. Qt needs to process the request instead
 
95
    miral::WindowSpecification modifications(modificationsClient);
 
96
 
 
97
    if (modifications.size().is_set()) {
 
98
        auto extraWindowInfo = getExtraInfo(windowInfo);
 
99
        QMutexLocker locker(&extraWindowInfo->mutex);
 
100
        if (!extraWindowInfo->allowClientResize) {
 
101
            modifications.size().consume();
 
102
        }
 
103
    }
 
104
 
95
105
    CanonicalWindowManagerPolicy::handle_modify_window(windowInfo, modifications);
96
106
 
97
107
    // TODO Once Qt processes the request we probably don't want to notify from here
149
159
 
150
160
void WindowManagementPolicy::advise_new_app(miral::ApplicationInfo &application)
151
161
{
 
162
    tracepoint(qtmirserver, starting);
152
163
    Q_EMIT m_appNotifier.appAdded(application);
153
164
}
154
165
 
155
166
void WindowManagementPolicy::advise_delete_app(const miral::ApplicationInfo &application)
156
167
{
 
168
    tracepoint(qtmirserver, stopping);
157
169
    Q_EMIT m_appNotifier.appRemoved(application);
158
170
}
159
171
 
223
235
        ensureWindowIsActive(window);
224
236
    }
225
237
 
226
 
    auto e = reinterpret_cast<MirEvent const*>(event); // naughty
227
 
 
228
 
    if (auto surface = std::weak_ptr<mir::scene::Surface>(window).lock()) {
229
 
        surface->consume(e);
230
 
    }
 
238
    dispatchInputEvent(window, mir_keyboard_event_input_event(event));
231
239
}
232
240
 
233
241
void WindowManagementPolicy::deliver_touch_event(const MirTouchEvent *event,
235
243
{
236
244
    ensureWindowIsActive(window);
237
245
 
238
 
    auto e = reinterpret_cast<MirEvent const*>(event); // naughty
239
 
 
240
 
    if (auto surface = std::weak_ptr<mir::scene::Surface>(window).lock()) {
241
 
        surface->consume(e);
242
 
    }
 
246
    dispatchInputEvent(window, mir_touch_event_input_event(event));
243
247
}
244
248
 
245
249
void WindowManagementPolicy::deliver_pointer_event(const MirPointerEvent *event,
249
253
    if (mir_pointer_event_action(event) == mir_pointer_action_button_down) {
250
254
        ensureWindowIsActive(window);
251
255
    }
252
 
    auto e = reinterpret_cast<MirEvent const*>(event); // naughty
253
256
 
254
 
    if (auto surface = std::weak_ptr<mir::scene::Surface>(window).lock()) {
255
 
        surface->consume(e);
256
 
    }
 
257
    dispatchInputEvent(window, mir_pointer_event_input_event(event));
257
258
}
258
259
 
259
260
/* Methods to allow Shell to request changes to the window stack. Called from the Qt GUI thread */