212
214
case mir_event_type_resize:
214
Q_ASSERT(ubuntuEvent->window->screen() == mIntegration->screen());
216
216
auto resizeEvent = mir_event_get_resize_event(nativeEvent);
218
mIntegration->screen()->handleWindowSurfaceResize(
219
mir_resize_event_get_width(resizeEvent),
220
mir_resize_event_get_height(resizeEvent));
218
// Enable workaround for Screen rotation
219
auto screen = static_cast<UbuntuScreen*>(ubuntuEvent->window->screen());
221
screen->handleWindowSurfaceResize(
222
mir_resize_event_get_width(resizeEvent),
223
mir_resize_event_get_height(resizeEvent));
222
226
ubuntuEvent->window->handleSurfaceResized(mir_resize_event_get_width(resizeEvent),
223
227
mir_resize_event_get_height(resizeEvent));
226
230
case mir_event_type_surface:
228
auto surfaceEvent = mir_event_get_surface_event(nativeEvent);
229
if (mir_surface_event_get_attribute(surfaceEvent) == mir_surface_attrib_focus) {
230
const bool focused = mir_surface_event_get_attribute_value(surfaceEvent) == mir_surface_focused;
231
// Mir may have sent a pair of focus lost/gained events, so we need to "peek" into the queue
232
// so that we don't deactivate windows prematurely.
234
mPendingFocusGainedEvents--;
235
ubuntuEvent->window->handleSurfaceFocused();
236
QWindowSystemInterface::handleWindowActivated(ubuntuEvent->window->window(), Qt::ActiveWindowFocusReason);
238
// NB: Since processing of system events is queued, never check qGuiApp->applicationState()
239
// as it might be outdated. Always call handleApplicationStateChanged() with the latest
241
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
243
} else if(!mPendingFocusGainedEvents) {
244
qCDebug(ubuntumirclient, "No windows have focus");
245
QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
246
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
231
handleSurfaceEvent(ubuntuEvent->window, mir_event_get_surface_event(nativeEvent));
233
case mir_event_type_surface_output:
234
handleSurfaceOutputEvent(ubuntuEvent->window, mir_event_get_surface_output_event(nativeEvent));
251
236
case mir_event_type_orientation:
252
237
dispatchOrientationEvent(ubuntuEvent->window->window(), mir_event_get_orientation_event(nativeEvent));
551
536
new OrientationChangeEvent(OrientationChangeEvent::mType, orientation));
539
void UbuntuInput::handleSurfaceEvent(const QPointer<UbuntuWindow> &window, const MirSurfaceEvent *event)
541
auto surfaceEventAttribute = mir_surface_event_get_attribute(event);
543
switch (surfaceEventAttribute) {
544
case mir_surface_attrib_focus: {
545
const bool focused = mir_surface_event_get_attribute_value(event) == mir_surface_focused;
546
// Mir may have sent a pair of focus lost/gained events, so we need to "peek" into the queue
547
// so that we don't deactivate windows prematurely.
549
mPendingFocusGainedEvents--;
550
window->handleSurfaceFocused();
551
QWindowSystemInterface::handleWindowActivated(window->window(), Qt::ActiveWindowFocusReason);
552
if (qGuiApp->applicationState() == Qt::ApplicationInactive) {
553
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
555
} else if(!mPendingFocusGainedEvents) {
556
qCDebug(ubuntumirclient, "No windows have focus");
557
QWindowSystemInterface::handleWindowActivated(nullptr, Qt::ActiveWindowFocusReason);
558
if (qGuiApp->applicationState() == Qt::ApplicationActive) {
559
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationInactive);
564
case mir_surface_attrib_visibility:
565
// Remaining attributes are ones client sets for server, and server should not override them
566
case mir_surface_attrib_type:
567
case mir_surface_attrib_state:
568
case mir_surface_attrib_swapinterval:
569
case mir_surface_attrib_dpi:
570
case mir_surface_attrib_preferred_orientation:
571
case mir_surface_attribs:
576
void UbuntuInput::handleSurfaceOutputEvent(const QPointer<UbuntuWindow> &window, const MirSurfaceOutputEvent *event)
578
const uint32_t outputId = mir_surface_output_event_get_output_id(event);
579
const MirFormFactor formFactor = mir_surface_output_event_get_form_factor(event);
581
const auto screenObserver = mIntegration->screenObserver();
582
UbuntuScreen *screen = screenObserver->findScreenWithId(outputId);
584
qWarning() << "Mir notified window" << window->window() << "on an unknown screen with id" << outputId;
588
screenObserver->handleScreenPropertiesChange(screen, formFactor);
589
window->handleScreenPropertiesChange(formFactor);
591
if (window->screen() != screen) {
592
QWindowSystemInterface::handleWindowScreenChanged(window->window(), screen->screen());