Key and wheel events.
This commit is contained in:
parent
b68d0688fe
commit
7dda80e1d0
@ -553,12 +553,15 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
|
|||||||
// QPoint localPoint = ev.pos();
|
// QPoint localPoint = ev.pos();
|
||||||
QPoint globalPoint = e->globalPos;
|
QPoint globalPoint = e->globalPos;
|
||||||
// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
|
// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
|
||||||
QWidget *mouseWidget;
|
|
||||||
|
|
||||||
qt_last_x = globalPoint.x();
|
qt_last_x = globalPoint.x();
|
||||||
qt_last_y = globalPoint.y();
|
qt_last_y = globalPoint.y();
|
||||||
|
|
||||||
QWidget *mouseWindow = e->window.data() ? e->window.data()->widget() : 0;
|
QWindow *window = e->window.data();
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QWidget *mouseWidget = window ? window->widget() : 0;
|
||||||
|
|
||||||
// find the tlw if we didn't get it from the plugin
|
// find the tlw if we didn't get it from the plugin
|
||||||
#if 0
|
#if 0
|
||||||
@ -567,10 +570,12 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!mouseWindow)
|
if (!mouseWidget) {
|
||||||
|
QWheelEvent ev(e->localPos, e->globalPos, e->delta, buttons, QGuiApplication::keyboardModifiers(),
|
||||||
|
e->orient);
|
||||||
|
QGuiApplication::sendSpontaneousEvent(window, &ev);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
mouseWidget = mouseWindow;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
|
if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
|
||||||
@ -583,11 +588,11 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
|
|||||||
mouseWidget = w;
|
mouseWidget = w;
|
||||||
p = mouseWidget->mapFromGlobal(globalPoint);
|
p = mouseWidget->mapFromGlobal(globalPoint);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QWheelEvent ev(p, globalPoint, e->delta, buttons, QGuiApplication::keyboardModifiers(),
|
QWheelEvent ev(e->localPos, e->globalPos, e->delta, buttons, QGuiApplication::keyboardModifiers(),
|
||||||
e->orient);
|
e->orient);
|
||||||
QGuiApplication::sendSpontaneousEvent(mouseWidget, &ev);
|
QGuiApplication::sendSpontaneousEvent(mouseWidget, &ev);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -596,28 +601,31 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
|
|||||||
|
|
||||||
void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
|
void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
|
||||||
{
|
{
|
||||||
QWidget *focusW = 0;
|
QWindow *window = e->window.data();
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QObject *target = window->widget() ? static_cast<QObject *>(window->widget()) : static_cast<QObject *>(window);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
QWidget *focusW = 0;
|
||||||
if (self->inPopupMode()) {
|
if (self->inPopupMode()) {
|
||||||
QWidget *popupW = qApp->activePopupWidget();
|
QWidget *popupW = qApp->activePopupWidget();
|
||||||
focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
|
focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
|
||||||
}
|
}
|
||||||
if (!focusW)
|
if (!focusW)
|
||||||
focusW = QGuiApplication::focusWidget();
|
focusW = QGuiApplication::focusWidget();
|
||||||
#endif
|
if (!focusW)
|
||||||
if (!focusW) {
|
focusW = window->widget();
|
||||||
focusW = e->window.data() ? e->window.data()->widget() : 0;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
if (!focusW)
|
if (!focusW)
|
||||||
focusW = QGuiApplication::activeWindow();
|
focusW = QGuiApplication::activeWindow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
|
//qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (!focusW)
|
if (!focusW)
|
||||||
return;
|
return;
|
||||||
#if 0
|
|
||||||
if (app_do_modal && !qt_try_modal(focusW, e->keyType))
|
if (app_do_modal && !qt_try_modal(focusW, e->keyType))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
@ -625,10 +633,10 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
|
|||||||
if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
|
if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
|
||||||
QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
|
QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
|
||||||
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
|
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
|
||||||
QGuiApplication::sendSpontaneousEvent(focusW, &ev);
|
QGuiApplication::sendSpontaneousEvent(target, &ev);
|
||||||
} else {
|
} else {
|
||||||
QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
|
QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
|
||||||
QGuiApplication::sendSpontaneousEvent(focusW, &ev);
|
QGuiApplication::sendSpontaneousEvent(target, &ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,49 +669,40 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QWindow *window = e->tlw.data();
|
QWindow *window = e->tlw.data();
|
||||||
QWidget *tlw = window ? window->widget() : 0;
|
if (!window)
|
||||||
if (!tlw) {
|
|
||||||
if (window) {
|
|
||||||
QRect newRect = e->newGeometry;
|
|
||||||
QRect cr = window->geometry();
|
|
||||||
|
|
||||||
bool isResize = cr.size() != newRect.size();
|
|
||||||
bool isMove = cr.topLeft() != newRect.topLeft();
|
|
||||||
window->d_func()->geometry = newRect;
|
|
||||||
if (isResize) {
|
|
||||||
QResizeEvent e(newRect.size(), cr.size());
|
|
||||||
QGuiApplication::sendSpontaneousEvent(window, &e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMove) {
|
|
||||||
//### frame geometry
|
|
||||||
QMoveEvent e(newRect.topLeft(), cr.topLeft());
|
|
||||||
QGuiApplication::sendSpontaneousEvent(window, &e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!tlw->isWindow())
|
QWidget *tlw = window->widget();
|
||||||
|
QObject *target = tlw ? static_cast<QObject *>(tlw) : static_cast<QObject *>(window);
|
||||||
|
|
||||||
|
QRect newRect = e->newGeometry;
|
||||||
|
QRect cr = tlw ? tlw->geometry() : window->geometry();
|
||||||
|
|
||||||
|
bool isResize = cr.size() != newRect.size();
|
||||||
|
bool isMove = cr.topLeft() != newRect.topLeft();
|
||||||
|
|
||||||
|
if (tlw && !tlw->isWindow())
|
||||||
return; //geo of native child widgets is controlled by lighthouse
|
return; //geo of native child widgets is controlled by lighthouse
|
||||||
//so we already have sent the events; besides this new rect
|
//so we already have sent the events; besides this new rect
|
||||||
//is not mapped to parent
|
//is not mapped to parent
|
||||||
|
|
||||||
QRect newRect = e->newGeometry;
|
|
||||||
QRect cr(tlw->geometry());
|
if (tlw)
|
||||||
bool isResize = cr.size() != newRect.size();
|
tlw->data->crect = newRect;
|
||||||
bool isMove = cr.topLeft() != newRect.topLeft();
|
else
|
||||||
tlw->data->crect = newRect;
|
window->d_func()->geometry = newRect;
|
||||||
|
|
||||||
if (isResize) {
|
if (isResize) {
|
||||||
QResizeEvent e(tlw->data->crect.size(), cr.size());
|
QResizeEvent e(newRect.size(), cr.size());
|
||||||
QGuiApplication::sendSpontaneousEvent(tlw, &e);
|
QGuiApplication::sendSpontaneousEvent(target, &e);
|
||||||
tlw->update();
|
if (tlw)
|
||||||
|
tlw->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMove) {
|
if (isMove) {
|
||||||
//### frame geometry
|
//### frame geometry
|
||||||
QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft());
|
QMoveEvent e(newRect.topLeft(), cr.topLeft());
|
||||||
QGuiApplication::sendSpontaneousEvent(tlw, &e);
|
QGuiApplication::sendSpontaneousEvent(target, &e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,6 +401,20 @@ bool QWindow::event(QEvent *event)
|
|||||||
resizeEvent(static_cast<QResizeEvent*>(event));
|
resizeEvent(static_cast<QResizeEvent*>(event));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QEvent::KeyPress:
|
||||||
|
keyPressEvent(static_cast<QKeyEvent *>(event));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QEvent::KeyRelease:
|
||||||
|
keyReleaseEvent(static_cast<QKeyEvent *>(event));
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifndef QT_NO_WHEELEVENT
|
||||||
|
case QEvent::Wheel:
|
||||||
|
wheelEvent(static_cast<QWheelEvent*>(event));
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QObject::event(event);
|
return QObject::event(event);
|
||||||
}
|
}
|
||||||
@ -409,7 +423,6 @@ bool QWindow::event(QEvent *event)
|
|||||||
|
|
||||||
void QWindow::keyPressEvent(QKeyEvent *)
|
void QWindow::keyPressEvent(QKeyEvent *)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWindow::keyReleaseEvent(QKeyEvent *)
|
void QWindow::keyReleaseEvent(QKeyEvent *)
|
||||||
|
Loading…
Reference in New Issue
Block a user