/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void QtWidget::moveEvent(QMoveEvent* pEvent)
{ // already handled by QtMainWindow::moveEvent if (m_rFrame.m_pTopLevel) return;
m_rFrame.handleMoveEvent(pEvent);
}
void QtWidget::showEvent(QShowEvent*)
{
QSize aSize(size() * m_rFrame.devicePixelRatioF()); // forcing an immediate update somehow interferes with the hide + show // sequence from QtFrame::SetModal, if the frame was already set visible, // resulting in a hidden / unmapped window
SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height()); if (m_rFrame.isPopup())
GetQtInstance().setActivePopup(&m_rFrame);
m_rFrame.CallCallback(SalEvent::Paint, &aPaintEvt);
}
#if CHECK_ANY_QT_USING_X11 if (QGuiApplication::platformName() == "xcb")
{ // pressing just the ctrl key leads to a keysym of XK_Control but // the event state does not contain ControlMask. In the release // event it's the other way round: it does contain the Control mask. // The modifier mode therefore has to be adapted manually.
ModKeyFlags nExtModMask = ModKeyFlags::NONE;
sal_uInt16 nModMask = 0; switch (pEvent->nativeVirtualKey())
{ case XK_Control_L:
nExtModMask = ModKeyFlags::LeftMod1;
nModMask = KEY_MOD1; break; case XK_Control_R:
nExtModMask = ModKeyFlags::RightMod1;
nModMask = KEY_MOD1; break; case XK_Alt_L:
nExtModMask = ModKeyFlags::LeftMod2;
nModMask = KEY_MOD2; break; case XK_Alt_R:
nExtModMask = ModKeyFlags::RightMod2;
nModMask = KEY_MOD2; break; case XK_Shift_L:
nExtModMask = ModKeyFlags::LeftShift;
nModMask = KEY_SHIFT; break; case XK_Shift_R:
nExtModMask = ModKeyFlags::RightShift;
nModMask = KEY_SHIFT; break; // Map Meta/Super keys to MOD3 modifier on all Unix systems // except macOS case XK_Meta_L: case XK_Super_L:
nExtModMask = ModKeyFlags::LeftMod3;
nModMask = KEY_MOD3; break; case XK_Meta_R: case XK_Super_R:
nExtModMask = ModKeyFlags::RightMod3;
nModMask = KEY_MOD3; break;
}
if (!bIsKeyPressed)
{ // sending the old mnModKeyCode mask on release is needed to // implement the writing direction switch with Ctrl + L/R-Shift
aModEvt.mnModKeyCode = m_rFrame.m_nKeyModifiers;
nModCode &= ~nModMask;
m_rFrame.m_nKeyModifiers &= ~nExtModMask;
} else
{
nModCode |= nModMask;
m_rFrame.m_nKeyModifiers |= nExtModMask;
aModEvt.mnModKeyCode = m_rFrame.m_nKeyModifiers;
}
} #endif
aModEvt.mnCode = nModCode;
bool bStopProcessingKey; if (bIsKeyPressed)
bStopProcessingKey = m_rFrame.CallCallback(SalEvent::KeyInput, &aEvent); else
bStopProcessingKey = m_rFrame.CallCallback(SalEvent::KeyUp, &aEvent); if (bStopProcessingKey)
pEvent->accept(); return bStopProcessingKey;
}
bool QtWidget::handleEvent(QEvent* pEvent)
{ if (pEvent->type() == QEvent::Gesture)
{
QGestureEvent* pGestureEvent = static_cast<QGestureEvent*>(pEvent); return handleGestureEvent(pGestureEvent);
} elseif (pEvent->type() == QEvent::ShortcutOverride)
{ // ignore non-spontaneous QEvent::ShortcutOverride events, // since such an extra event is sent e.g. with Orca screen reader enabled, // so that two events of that kind (the "real one" and a non-spontaneous one) // would otherwise be processed, resulting in duplicate input as 'handleKeyEvent' // is called below (s. tdf#122053) if (!pEvent->spontaneous())
{ // accept event so shortcut action (from menu) isn't triggered in addition // to the processing for the spontaneous event further below
pEvent->accept(); returnfalse;
}
// Accepted event disables shortcut activation, // but enables keypress event. // If event is not accepted and shortcut is successfully activated, // KeyPress event is omitted. // // Instead of processing keyPressEvent, handle ShortcutOverride event, // and if it's handled - disable the shortcut, it should have been activated. // Don't process keyPressEvent generated after disabling shortcut since it was handled here. // If event is not handled, don't accept it and let Qt activate related shortcut. if (handleKeyEvent(static_cast<QKeyEvent*>(pEvent))) returntrue;
} elseif (pEvent->type() == QEvent::ToolTip)
{ // Qt's POV on the active popup is wrong due to our fake popup, so check LO's state. // Otherwise Qt will continue handling ToolTip events from the "parent" window. const QtFrame* pPopupFrame = GetQtInstance().activePopup(); if (!m_rFrame.m_aTooltipText.isEmpty() && (!pPopupFrame || pPopupFrame == &m_rFrame))
{ // tdf#162297 and tdf#166805: Use an html tag to ensure the tooltip is wrapped
QString sTooltipText("");
sTooltipText += toQString(m_rFrame.m_aTooltipText).toHtmlEscaped();
sTooltipText += "";
QToolTip::showText(QCursor::pos(), sTooltipText, this, m_rFrame.m_aTooltipArea);
} else
{
QToolTip::hideText();
pEvent->ignore();
} returntrue;
} returnfalse;
}
QtWidget::QtWidget(QtFrame& rFrame, Qt::WindowFlags f) // if you try to set the QWidget parent via the QtFrame, instead of using nullptr, at // least test Wayland popups; these horribly broke last time doing this (read commits)!
: QWidget(nullptr, f)
, m_rFrame(rFrame)
, m_bNonEmptyIMPreeditSeen(false)
, m_bInInputMethodQueryCursorRectangle(false)
, m_nDeltaX(0)
, m_nDeltaY(0)
{ // make floating windows translucent, needed at least by BubbleWindow // (used for update notifications) on X11 if (f & Qt::FramelessWindowHint)
{
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
}
setMouseTracking(true); if (!rFrame.isPopup())
setFocusPolicy(Qt::StrongFocus); else
setFocusPolicy(Qt::ClickFocus);
grabGesture(Qt::PinchGesture);
}
static ExtTextInputAttr lcl_MapUnderlineStyle(QTextCharFormat::UnderlineStyle us)
{ switch (us)
{ case QTextCharFormat::NoUnderline: return ExtTextInputAttr::NONE; case QTextCharFormat::DotLine: return ExtTextInputAttr::DottedUnderline; case QTextCharFormat::DashDotDotLine: case QTextCharFormat::DashDotLine: return ExtTextInputAttr::DashDotUnderline; case QTextCharFormat::WaveUnderline: return ExtTextInputAttr::GrayWaveline; default: return ExtTextInputAttr::Underline;
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.