QGuiApplication refactor in progress.

Things are a bit broken now... At least wiggly runs :)
(cherry picked from commit 6cdcf395ffe1e051d109a45ecd71141173a4a4c0)
This commit is contained in:
Samuel Rødal 2011-04-27 14:56:55 +02:00
parent dd34255948
commit 0d12e17d25
24 changed files with 1081 additions and 717 deletions

View File

@ -575,23 +575,6 @@ void QCoreApplication::flush()
\a argc must be greater than zero and \a argv must contain at least
one valid character string.
*/
QCoreApplication::QCoreApplication(int &argc, char **argv)
: QObject(*new QCoreApplicationPrivate(argc, argv, 0x040000))
{
init();
QCoreApplicationPrivate::eventDispatcher->startingUp();
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_LIBRARY)
// Refresh factoryloader, as text codecs are requested during lib path
// resolving process and won't be therefore properly loaded.
// Unknown if this is symbian specific issue.
QFactoryLoader::refreshAll();
#endif
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
d_func()->symbianInit();
#endif
}
QCoreApplication::QCoreApplication(int &argc, char **argv, int _internal)
: QObject(*new QCoreApplicationPrivate(argc, argv, _internal))
{

View File

@ -84,16 +84,7 @@ public:
#endif
};
#if defined(QT_BUILD_CORE_LIB) || defined(qdoc)
QCoreApplication(int &argc, char **argv); // ### Qt5 remove
#endif
#if !defined(qdoc)
QCoreApplication(int &argc, char **argv, int
#if !defined(QT_BUILD_CORE_LIB)
= ApplicationFlags
#endif
);
#endif
QCoreApplication(int &argc, char **argv, int = ApplicationFlags);
~QCoreApplication();
@ -217,6 +208,8 @@ private:
friend class QEventDispatcherUNIXPrivate;
friend class QApplication;
friend class QApplicationPrivate;
friend class QGuiApplication;
friend class QGuiApplicationPrivate;
friend class QETWidget;
friend class Q3AccelManager;
friend class QShortcutMap;

View File

@ -228,6 +228,8 @@ qpa {
kernel/qplatformclipboard_qpa.h \
kernel/qplatformnativeinterface_qpa.h \
kernel/qwindowformat_qpa.h \
kernel/qguiapplication_qpa.h \
kernel/qguiapplication_qpa_p.h \
kernel/qwindow_qpa.h
SOURCES += \
@ -255,6 +257,7 @@ qpa {
kernel/qplatformnativeinterface_qpa.cpp \
kernel/qsessionmanager_qpa.cpp \
kernel/qwindowformat_qpa.cpp \
kernel/qguiapplication_qpa.cpp \
kernel/qwindow_qpa.cpp
contains(QT_CONFIG, glib) {

View File

@ -172,7 +172,7 @@ bool QApplicationPrivate::autoSipEnabled = true;
#endif
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags)
: QCoreApplicationPrivate(argc, argv, flags)
: QGuiApplicationPrivate(argc, argv, flags)
{
application_type = type;
qt_appType = type;
@ -454,9 +454,6 @@ QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system
#if defined(Q_WS_QPA)
QPlatformIntegration *QApplicationPrivate::platform_integration = 0;
#endif
QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
bool QApplicationPrivate::runtime_graphics_system = false;
@ -729,11 +726,11 @@ void QApplicationPrivate::process_cmdline()
*/
QApplication::QApplication(int &argc, char **argv)
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
: QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
{ Q_D(QApplication); d->construct(); }
QApplication::QApplication(int &argc, char **argv, int _internal)
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
: QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
{ Q_D(QApplication); d->construct(); }
@ -763,11 +760,11 @@ QApplication::QApplication(int &argc, char **argv, int _internal)
*/
QApplication::QApplication(int &argc, char **argv, bool GUIenabled )
: QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
: QGuiApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
{ Q_D(QApplication); d->construct(); }
QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal)
: QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal))
: QGuiApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal))
{ Q_D(QApplication); d->construct();}
@ -786,11 +783,11 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern
\c -qws option).
*/
QApplication::QApplication(int &argc, char **argv, Type type)
: QCoreApplication(*new QApplicationPrivate(argc, argv, type, 0x040000))
: QGuiApplication(*new QApplicationPrivate(argc, argv, type, 0x040000))
{ Q_D(QApplication); d->construct(); }
QApplication::QApplication(int &argc, char **argv, Type type , int _internal)
: QCoreApplication(*new QApplicationPrivate(argc, argv, type, _internal))
: QGuiApplication(*new QApplicationPrivate(argc, argv, type, _internal))
{ Q_D(QApplication); d->construct(); }
#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
@ -897,7 +894,7 @@ static char *aargv[] = { (char*)"unknown", 0 };
This function is only available on X11.
*/
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
: QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000))
: QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@ -906,7 +903,7 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
}
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
: QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal))
: QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@ -931,7 +928,7 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap,
*/
QApplication::QApplication(Display *dpy, int &argc, char **argv,
Qt::HANDLE visual, Qt::HANDLE colormap)
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
: QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@ -941,7 +938,7 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv,
QApplication::QApplication(Display *dpy, int &argc, char **argv,
Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
: QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
{
if (! dpy)
qWarning("QApplication: Invalid Display* argument");
@ -1316,7 +1313,7 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
}
return false;
}
return QCoreApplication::compressEvent(event, receiver, postedEvents);
return QApplicationBase::compressEvent(event, receiver, postedEvents);
}
/*!
@ -2521,7 +2518,7 @@ bool QApplication::event(QEvent *e)
d->toolTipFallAsleep.stop();
}
}
return QCoreApplication::event(e);
return QApplicationBase::event(e);
}
#if !defined(Q_WS_X11)
@ -2898,6 +2895,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget)
if (QApplication::activePopupWidget() == widget)
return false;
#if 0
for (int i = 0; i < qt_modal_stack->size(); ++i) {
QWidget *modalWidget = qt_modal_stack->at(i);
@ -2976,6 +2974,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget)
break;
}
}
#endif
return false;
}
@ -3753,7 +3752,7 @@ int QApplication::exec()
#ifndef QT_NO_ACCESSIBILITY
QAccessible::setRootObject(qApp);
#endif
return QCoreApplication::exec();
return QApplicationBase::exec();
}
/*! \reimp
@ -5486,7 +5485,7 @@ uint QApplicationPrivate::currentPlatform(){
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
{
return QCoreApplication::sendSpontaneousEvent(receiver, event);
return QApplicationBase::sendSpontaneousEvent(receiver, event);
}

View File

@ -58,6 +58,9 @@
# include <QtGui/qrgb.h>
# include <QtGui/qtransportauth_qws.h>
#endif
#ifdef Q_WS_QPA
# include <QtGui/qguiapplication_qpa.h>
#endif
QT_BEGIN_HEADER
@ -93,8 +96,13 @@ class QApplicationPrivate;
#endif
#define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
#ifdef Q_WS_QPA
#define QApplicationBase QGuiApplication
#else
#define QApplicationBase QCoreApplication
#endif
class Q_GUI_EXPORT QApplication : public QCoreApplication
class Q_GUI_EXPORT QApplication : public QApplicationBase
{
Q_OBJECT
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)

View File

@ -80,6 +80,7 @@
#include <QWindowSystemInterface>
#include "qwindowsysteminterface_qpa_p.h"
#include "QtGui/qplatformintegration_qpa.h"
#include "QtGui/private/qguiapplication_qpa_p.h"
#endif
QT_BEGIN_NAMESPACE
@ -294,7 +295,11 @@ FontHash *qt_app_fonts_hash();
typedef QHash<QByteArray, QPalette> PaletteHash;
PaletteHash *qt_app_palettes_hash();
#ifdef Q_WS_QPA
class Q_GUI_EXPORT QApplicationPrivate : public QGuiApplicationPrivate
#else
class Q_GUI_EXPORT QApplicationPrivate : public QCoreApplicationPrivate
#endif
{
Q_DECLARE_PUBLIC(QApplication)
public:
@ -325,14 +330,6 @@ public:
{ return graphics_system; }
#endif
#if defined(Q_WS_QPA)
static QPlatformIntegration *platformIntegration()
{ return platform_integration; }
static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
{ return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
#endif
void createEventDispatcher();
QString appName() const;
static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
@ -433,9 +430,6 @@ public:
static QGraphicsSystem *graphics_system;
static QString graphics_system_name;
static bool runtime_graphics_system;
#ifdef Q_WS_QPA
static QPlatformIntegration *platform_integration;
#endif
private:
static QFont *app_font; // private for a reason! Always use QApplication::font() instead!
@ -493,32 +487,6 @@ public:
static bool qt_mac_apply_settings();
#endif
#ifdef Q_WS_QPA
static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
// static void reportScreenCount(int count);
static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
// static void reportGeometryChange(int screenIndex);
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
// static void reportAvailableGeometryChange(int screenIndex);
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
#endif
#ifdef Q_WS_QWS
QPointer<QWSManager> last_manager;
QWSServerCleaner qwsServerCleaner;

View File

@ -71,71 +71,6 @@ QT_BEGIN_NAMESPACE
static QString appName;
static QString appFont;
QWidget *qt_button_down = 0; // widget got last button-down
static bool app_do_modal = false;
extern QWidgetList *qt_modal_stack; // stack of modal widgets
int qt_last_x = 0;
int qt_last_y = 0;
QPointer<QWidget> qt_last_mouse_receiver = 0;
static Qt::MouseButtons buttons = Qt::NoButton;
static ulong mousePressTime;
static Qt::MouseButton mousePressButton = Qt::NoButton;
static int mousePressX;
static int mousePressY;
static int mouse_double_click_distance = 5;
void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
{
switch(e->type) {
case QWindowSystemInterfacePrivate::Mouse:
QApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Wheel:
QApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Key:
QApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Touch:
QApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
break;
case QWindowSystemInterfacePrivate::GeometryChange:
QApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
break;
case QWindowSystemInterfacePrivate::Enter:
QApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Leave:
QApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ActivatedWindow:
QApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Close:
QApplicationPrivate::processCloseEvent(
static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenCountChange:
QApplicationPrivate::reportScreenCount(
static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenGeometry:
QApplicationPrivate::reportGeometryChange(
static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenAvailableGeometry:
QApplicationPrivate::reportAvailableGeometryChange(
static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
break;
default:
qWarning() << "Unknown user input event type:" << e->type;
break;
}
}
QString QApplicationPrivate::appName() const
{
return QT_PREPEND_NAMESPACE(appName);
@ -190,14 +125,17 @@ static bool qt_try_modal(QWidget *widget, QEvent::Type type)
void QApplicationPrivate::enterModal_sys(QWidget *widget)
{
#if 0
if (!qt_modal_stack)
qt_modal_stack = new QWidgetList;
qt_modal_stack->insert(0, widget);
app_do_modal = true;
#endif
}
void QApplicationPrivate::leaveModal_sys(QWidget *widget )
{
#if 0
if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
if (qt_modal_stack->isEmpty()) {
delete qt_modal_stack;
@ -205,11 +143,15 @@ void QApplicationPrivate::leaveModal_sys(QWidget *widget )
}
}
app_do_modal = qt_modal_stack != 0;
#endif
}
bool QApplicationPrivate::modalState()
{
return false;
#if 0
return app_do_modal;
#endif
}
void QApplicationPrivate::closePopup(QWidget *popup)
@ -450,45 +392,6 @@ QPlatformNativeInterface *QApplication::platformNativeInterface()
return pi->nativeInterface();
}
static void init_platform(const QString &name, const QString &platformPluginPath)
{
QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
if (!QApplicationPrivate::platform_integration) {
QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
QString fatalMessage =
QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
foreach(QString key, keys) {
fatalMessage.append(key + QString::fromLatin1("\n"));
}
qFatal("%s", fatalMessage.toLocal8Bit().constData());
}
}
static void cleanup_platform()
{
delete QApplicationPrivate::platform_integration;
QApplicationPrivate::platform_integration = 0;
}
static void init_plugins(const QList<QByteArray> pluginList)
{
for (int i = 0; i < pluginList.count(); ++i) {
QByteArray pluginSpec = pluginList.at(i);
qDebug() << "init_plugins" << i << pluginSpec;
int colonPos = pluginSpec.indexOf(':');
QObject *plugin;
if (colonPos < 0)
plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
else
plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
QLatin1String(pluginSpec.mid(colonPos+1)));
qDebug() << " created" << plugin;
}
}
#ifndef QT_NO_QWS_INPUTMETHODS
class QDummyInputContext : public QInputContext
{
@ -504,74 +407,12 @@ public:
};
#endif // QT_NO_QWS_INPUTMETHODS
void qt_init(QApplicationPrivate *priv, int type)
void qt_init(QApplicationPrivate *, int type)
{
Q_UNUSED(type);
qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
char *p;
char **argv = priv->argv;
int argc = priv->argc;
if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
p = strrchr(argv[0], '/');
appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
}
QList<QByteArray> pluginList;
QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
QByteArray platformName;
#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
#endif
QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
if (!platformNameEnv.isEmpty()) {
platformName = platformNameEnv;
}
// Get command line params
int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') {
argv[j++] = argv[i];
continue;
}
QByteArray arg = argv[i];
if (arg == "-fn" || arg == "-font") {
if (++i < argc)
appFont = QString::fromLocal8Bit(argv[i]);
} else if (arg == "-platformpluginpath") {
if (++i < argc)
platformPluginPath = QLatin1String(argv[i]);
} else if (arg == "-platform") {
if (++i < argc)
platformName = argv[i];
} else if (arg == "-plugin") {
if (++i < argc)
pluginList << argv[i];
} else {
argv[j++] = argv[i];
}
}
if (j < priv->argc) {
priv->argv[j] = 0;
priv->argc = j;
}
#if 0
QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
if (!pluginEnv.isEmpty()) {
pluginList.append(pluginEnv.split(';'));
}
#endif
init_platform(QLatin1String(platformName), platformPluginPath);
init_plugins(pluginList);
QColormap::initialize();
QFont::initialize();
#ifndef QT_NO_CURSOR
// QCursorData::initialize();
#endif
@ -585,13 +426,10 @@ void qt_init(QApplicationPrivate *priv, int type)
void qt_cleanup()
{
cleanup_platform();
QPixmapCache::clear();
#ifndef QT_NO_CURSOR
QCursorData::cleanup();
#endif
QFont::cleanup();
QColormap::cleanup();
delete QApplicationPrivate::inputContext;
QApplicationPrivate::inputContext = 0;
@ -610,356 +448,4 @@ void QApplication::setMainWidget(QWidget *mainWidget)
}
#endif
void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
{
// qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons();
static QWeakPointer<QWidget> implicit_mouse_grabber;
QEvent::Type type;
// move first
Qt::MouseButtons stateChange = e->buttons ^ buttons;
if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
new QWindowSystemInterfacePrivate::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
stateChange = Qt::NoButton;
}
QWidget * tlw = e->widget.data();
QPoint localPoint = e->localPos;
QPoint globalPoint = e->globalPos;
QWidget *mouseWindow = tlw;
Qt::MouseButton button = Qt::NoButton;
if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
type = QEvent::MouseMove;
qt_last_x = globalPoint.x();
qt_last_y = globalPoint.y();
if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
mousePressButton = Qt::NoButton;
}
else { // check to see if a new button has been pressed/released
for (int check = Qt::LeftButton;
check <= Qt::XButton2;
check = check << 1) {
if (check & stateChange) {
button = Qt::MouseButton(check);
break;
}
}
if (button == Qt::NoButton) {
// Ignore mouse events that don't change the current state
return;
}
buttons = e->buttons;
if (button & e->buttons) {
if ((e->timestamp - mousePressTime) < static_cast<ulong>(QApplication::doubleClickInterval()) && button == mousePressButton) {
type = QEvent::MouseButtonDblClick;
mousePressButton = Qt::NoButton;
}
else {
type = QEvent::MouseButtonPress;
mousePressTime = e->timestamp;
mousePressButton = button;
mousePressX = qt_last_x;
mousePressY = qt_last_y;
}
}
else
type = QEvent::MouseButtonRelease;
}
if (self->inPopupMode()) {
//popup mouse handling is magical...
mouseWindow = qApp->activePopupWidget();
implicit_mouse_grabber.clear();
//### how should popup mode and implicit mouse grab interact?
} else if (tlw && app_do_modal && !qt_try_modal(tlw, QEvent::MouseButtonRelease) ) {
//even if we're blocked by modality, we should deliver the mouse release event..
//### this code is not completely correct: multiple buttons can be pressed simultaneously
if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) {
//qDebug() << "modal blocked mouse event to" << tlw;
return;
}
}
// find the tlw if we didn't get it from the plugin
if (!mouseWindow) {
mouseWindow = QApplication::topLevelAt(globalPoint);
}
if (!mouseWindow && !implicit_mouse_grabber)
mouseWindow = QApplication::desktop();
if (mouseWindow && mouseWindow != tlw) {
//we did not get a sensible localPoint from the window system, so let's calculate it
localPoint = mouseWindow->mapFromGlobal(globalPoint);
}
// which child should have it?
QWidget *mouseWidget = mouseWindow;
if (mouseWindow) {
QWidget *w = mouseWindow->childAt(localPoint);
if (w) {
mouseWidget = w;
}
}
//handle implicit mouse grab
if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) {
implicit_mouse_grabber = mouseWidget;
Q_ASSERT(mouseWindow);
mouseWindow->activateWindow(); //focus
} else if (implicit_mouse_grabber) {
mouseWidget = implicit_mouse_grabber.data();
mouseWindow = mouseWidget->window();
if (mouseWindow != tlw)
localPoint = mouseWindow->mapFromGlobal(globalPoint);
}
Q_ASSERT(mouseWidget);
//localPoint is local to mouseWindow, but it needs to be local to mouseWidget
localPoint = mouseWidget->mapFrom(mouseWindow, localPoint);
if (buttons == Qt::NoButton) {
//qDebug() << "resetting mouse grabber";
implicit_mouse_grabber.clear();
}
if (mouseWidget != qt_last_mouse_receiver) {
dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver);
qt_last_mouse_receiver = mouseWidget;
}
// Remember, we might enter a modal event loop when sending the event,
// so think carefully before adding code below this point.
// qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber;
QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QApplication::keyboardModifiers());
QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances();
foreach (QWeakPointer<QPlatformCursor> cursor, cursors) {
if (cursor)
cursor.data()->pointerEvent(ev);
}
int oldOpenPopupCount = openPopupCount;
QApplication::sendSpontaneousEvent(mouseWidget, &ev);
#ifndef QT_NO_CONTEXTMENU
if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint, globalPoint, QApplication::keyboardModifiers());
QApplication::sendSpontaneousEvent(mouseWidget, &e);
}
#endif // QT_NO_CONTEXTMENU
}
//### there's a lot of duplicated logic here -- refactoring required!
void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
{
// QPoint localPoint = ev.pos();
QPoint globalPoint = e->globalPos;
// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
QWidget *mouseWidget;
qt_last_x = globalPoint.x();
qt_last_y = globalPoint.y();
QWidget *mouseWindow = e->widget.data();
// find the tlw if we didn't get it from the plugin
if (!mouseWindow) {
mouseWindow = QApplication::topLevelAt(globalPoint);
}
if (!mouseWindow)
return;
mouseWidget = mouseWindow;
if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
qDebug() << "modal blocked wheel event" << mouseWindow;
return;
}
QPoint p = mouseWindow->mapFromGlobal(globalPoint);
QWidget *w = mouseWindow->childAt(p);
if (w) {
mouseWidget = w;
p = mouseWidget->mapFromGlobal(globalPoint);
}
QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
e->orient);
QApplication::sendSpontaneousEvent(mouseWidget, &ev);
}
// Remember, Qt convention is: keyboard state is state *before*
void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
{
QWidget *focusW = 0;
if (self->inPopupMode()) {
QWidget *popupW = qApp->activePopupWidget();
focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
}
if (!focusW)
focusW = QApplication::focusWidget();
if (!focusW) {
focusW = e->widget.data();
}
if (!focusW)
focusW = QApplication::activeWindow();
//qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
if (!focusW)
return;
if (app_do_modal && !qt_try_modal(focusW, e->keyType))
return;
if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
QApplication::sendSpontaneousEvent(focusW, &ev);
} else {
QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
QApplication::sendSpontaneousEvent(focusW, &ev);
}
}
void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
{
QApplicationPrivate::dispatchEnterLeave(e->enter.data(),0);
qt_last_mouse_receiver = e->enter.data();
}
void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
{
QApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver);
if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
QApplicationPrivate::dispatchEnterLeave(0, e->leave.data());
qt_last_mouse_receiver = 0;
}
void QApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
{
QApplication::setActiveWindow(e->activated.data());
}
void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
{
if (e->tlw.isNull())
return;
QWidget *tlw = e->tlw.data();
if (!tlw->isWindow())
return; //geo of native child widgets is controlled by lighthouse
//so we already have sent the events; besides this new rect
//is not mapped to parent
QRect newRect = e->newGeometry;
QRect cr(tlw->geometry());
bool isResize = cr.size() != newRect.size();
bool isMove = cr.topLeft() != newRect.topLeft();
tlw->data->crect = newRect;
if (isResize) {
QResizeEvent e(tlw->data->crect.size(), cr.size());
QApplication::sendSpontaneousEvent(tlw, &e);
tlw->update();
}
if (isMove) {
//### frame geometry
QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft());
QApplication::sendSpontaneousEvent(tlw, &e);
}
}
void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
{
if (e->topLevel.isNull()) {
//qDebug() << "QApplicationPrivate::processCloseEvent NULL";
return;
}
e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
void QApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
{
translateRawTouchEvent(e->widget.data(), e->devType, e->points);
}
void QApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e)
{
// This operation only makes sense after the QApplication constructor runs
if (QCoreApplication::startingUp())
return;
QApplication::desktop()->d_func()->updateScreenList();
// signal anything listening for creation or deletion of screens
QDesktopWidget *desktop = QApplication::desktop();
emit desktop->screenCountChanged(e->count);
}
void QApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e)
{
// This operation only makes sense after the QApplication constructor runs
if (QCoreApplication::startingUp())
return;
QApplication::desktop()->d_func()->updateScreenList();
// signal anything listening for screen geometry changes
QDesktopWidget *desktop = QApplication::desktop();
emit desktop->resized(e->index);
// make sure maximized and fullscreen windows are updated
QWidgetList list = QApplication::topLevelWidgets();
for (int i = list.size() - 1; i >= 0; --i) {
QWidget *w = list.at(i);
if (w->isFullScreen())
w->d_func()->setFullScreenSize_helper();
else if (w->isMaximized())
w->d_func()->setMaxWindowState_helper();
}
}
void QApplicationPrivate::reportAvailableGeometryChange(
QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e)
{
// This operation only makes sense after the QApplication constructor runs
if (QCoreApplication::startingUp())
return;
QApplication::desktop()->d_func()->updateScreenList();
// signal anything listening for screen geometry changes
QDesktopWidget *desktop = QApplication::desktop();
emit desktop->workAreaResized(e->index);
// make sure maximized and fullscreen windows are updated
QWidgetList list = QApplication::topLevelWidgets();
for (int i = list.size() - 1; i >= 0; --i) {
QWidget *w = list.at(i);
if (w->isFullScreen())
w->d_func()->setFullScreenSize_helper();
else if (w->isMaximized())
w->d_func()->setMaxWindowState_helper();
}
}
QT_END_NAMESPACE

View File

@ -87,7 +87,7 @@ static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
delete event;
continue;
}
QApplicationPrivate::processWindowSystemEvent(event);
QGuiApplicationPrivate::processWindowSystemEvent(event);
delete event;
}

View File

@ -236,7 +236,7 @@ bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
}
nevents++;
QApplicationPrivate::processWindowSystemEvent(event);
QGuiApplicationPrivate::processWindowSystemEvent(event);
delete event;
}

View File

@ -0,0 +1,707 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qguiapplication_qpa.h"
#include "private/qguiapplication_qpa_p.h"
#include "private/qplatformintegrationfactory_qpa_p.h"
#include "private/qevent_p.h"
#include <QtCore/private/qcoreapplication_p.h>
#include <QtDebug>
#include <QtGui/QPlatformIntegration>
#include <QtGui/QGenericPluginFactory>
#include <QWindowSystemInterface>
#include "private/qwindowsysteminterface_qpa_p.h"
QT_BEGIN_NAMESPACE
Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
int QGuiApplicationPrivate::keyboard_input_time = 0;
int QGuiApplicationPrivate::mouse_double_click_time = 0;
QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0;
QWidget *qt_button_down = 0; // widget got last button-down
bool QGuiApplicationPrivate::app_do_modal = false;
int qt_last_x = 0;
int qt_last_y = 0;
QPointer<QWidget> QGuiApplicationPrivate::qt_last_mouse_receiver = 0;
QWidgetList QGuiApplicationPrivate::qt_modal_stack;
Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton;
ulong QGuiApplicationPrivate::mousePressTime = 0;
Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton;
int QGuiApplicationPrivate::mousePressX = 0;
int QGuiApplicationPrivate::mousePressY = 0;
int QGuiApplicationPrivate::mouse_double_click_distance = 5;
QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
: QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
{
d_func()->init();
}
QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p)
: QCoreApplication(p)
{
d_func()->init();
}
QGuiApplication::~QGuiApplication()
{
}
QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
: QCoreApplicationPrivate(argc, argv, flags)
{
self = this;
}
static void init_platform(const QString &name, const QString &platformPluginPath)
{
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
if (!QGuiApplicationPrivate::platform_integration) {
QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
QString fatalMessage =
QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
foreach(QString key, keys) {
fatalMessage.append(key + QString::fromLatin1("\n"));
}
qFatal("%s", fatalMessage.toLocal8Bit().constData());
}
}
static void init_plugins(const QList<QByteArray> pluginList)
{
for (int i = 0; i < pluginList.count(); ++i) {
QByteArray pluginSpec = pluginList.at(i);
qDebug() << "init_plugins" << i << pluginSpec;
int colonPos = pluginSpec.indexOf(':');
QObject *plugin;
if (colonPos < 0)
plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
else
plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
QLatin1String(pluginSpec.mid(colonPos+1)));
qDebug() << " created" << plugin;
}
}
void QGuiApplicationPrivate::init()
{
QList<QByteArray> pluginList;
QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
QByteArray platformName;
#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
#endif
QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
if (!platformNameEnv.isEmpty()) {
platformName = platformNameEnv;
}
// Get command line params
int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') {
argv[j++] = argv[i];
continue;
}
QByteArray arg = argv[i];
if (arg == "-platformpluginpath") {
if (++i < argc)
platformPluginPath = QLatin1String(argv[i]);
} else if (arg == "-platform") {
if (++i < argc)
platformName = argv[i];
} else if (arg == "-plugin") {
if (++i < argc)
pluginList << argv[i];
} else {
argv[j++] = argv[i];
}
}
argv[j] = 0;
argc = j;
#if 0
QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
if (!pluginEnv.isEmpty()) {
pluginList.append(pluginEnv.split(';'));
}
#endif
init_platform(QLatin1String(platformName), platformPluginPath);
init_plugins(pluginList);
QFont::initialize();
}
QGuiApplicationPrivate::~QGuiApplicationPrivate()
{
delete platform_integration;
platform_integration = 0;
QFont::cleanup();
}
#if 0
#ifndef QT_NO_CURSOR
QCursor *overrideCursor();
void setOverrideCursor(const QCursor &);
void changeOverrideCursor(const QCursor &);
void restoreOverrideCursor();
#endif
static QFont font();
static QFont font(const QWidget*);
static QFont font(const char *className);
static void setFont(const QFont &, const char* className = 0);
static QFontMetrics fontMetrics();
#ifndef QT_NO_CLIPBOARD
static QClipboard *clipboard();
#endif
#endif
Qt::KeyboardModifiers QGuiApplication::keyboardModifiers()
{
return QGuiApplicationPrivate::modifier_buttons;
}
Qt::MouseButtons QGuiApplication::mouseButtons()
{
return QGuiApplicationPrivate::mouse_buttons;
}
void QGuiApplication::setDoubleClickInterval(int ms)
{
QGuiApplicationPrivate::mouse_double_click_time = ms;
}
int QGuiApplication::doubleClickInterval()
{
return QGuiApplicationPrivate::mouse_double_click_time;
}
void QGuiApplication::setKeyboardInputInterval(int ms)
{
QGuiApplicationPrivate::keyboard_input_time = ms;
}
int QGuiApplication::keyboardInputInterval()
{
return QGuiApplicationPrivate::keyboard_input_time;
}
QPlatformNativeInterface *QGuiApplication::platformNativeInterface()
{
QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
return pi->nativeInterface();
}
int QGuiApplication::exec()
{
return QCoreApplication::exec();
}
bool QGuiApplication::notify(QObject *object, QEvent *event)
{
return QCoreApplication::notify(object, event);
}
bool QGuiApplication::event(QEvent *e)
{
return QCoreApplication::event(e);
}
bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
{
return QCoreApplication::compressEvent(event, receiver, postedEvents);
}
void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
{
switch(e->type) {
case QWindowSystemInterfacePrivate::Mouse:
QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Wheel:
QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Key:
QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Touch:
QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
break;
case QWindowSystemInterfacePrivate::GeometryChange:
QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
break;
case QWindowSystemInterfacePrivate::Enter:
QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Leave:
QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ActivatedWindow:
QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Close:
QGuiApplicationPrivate::processCloseEvent(
static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenCountChange:
QGuiApplicationPrivate::reportScreenCount(
static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenGeometry:
QGuiApplicationPrivate::reportGeometryChange(
static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenAvailableGeometry:
QGuiApplicationPrivate::reportAvailableGeometryChange(
static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
break;
default:
qWarning() << "Unknown user input event type:" << e->type;
break;
}
}
void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
{
// qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons();
static QWeakPointer<QWidget> implicit_mouse_grabber;
QEvent::Type type;
// move first
Qt::MouseButtons stateChange = e->buttons ^ buttons;
if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
stateChange = Qt::NoButton;
}
QWidget * tlw = e->window.data() ? e->window.data()->widget() : 0;
QPoint localPoint = e->localPos;
QPoint globalPoint = e->globalPos;
QWidget *mouseWindow = tlw;
Qt::MouseButton button = Qt::NoButton;
if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
type = QEvent::MouseMove;
qt_last_x = globalPoint.x();
qt_last_y = globalPoint.y();
if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
mousePressButton = Qt::NoButton;
}
else { // check to see if a new button has been pressed/released
for (int check = Qt::LeftButton;
check <= Qt::XButton2;
check = check << 1) {
if (check & stateChange) {
button = Qt::MouseButton(check);
break;
}
}
if (button == Qt::NoButton) {
// Ignore mouse events that don't change the current state
return;
}
buttons = e->buttons;
if (button & e->buttons) {
if ((e->timestamp - mousePressTime) < static_cast<ulong>(QGuiApplication::doubleClickInterval()) && button == mousePressButton) {
type = QEvent::MouseButtonDblClick;
mousePressButton = Qt::NoButton;
}
else {
type = QEvent::MouseButtonPress;
mousePressTime = e->timestamp;
mousePressButton = button;
mousePressX = qt_last_x;
mousePressY = qt_last_y;
}
}
else
type = QEvent::MouseButtonRelease;
}
#if 0
if (self->inPopupMode()) {
//popup mouse handling is magical...
mouseWindow = qApp->activePopupWidget();
implicit_mouse_grabber.clear();
//### how should popup mode and implicit mouse grab interact?
} else if (tlw && app_do_modal && !qt_try_modal(tlw, QEvent::MouseButtonRelease) ) {
//even if we're blocked by modality, we should deliver the mouse release event..
//### this code is not completely correct: multiple buttons can be pressed simultaneously
if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) {
//qDebug() << "modal blocked mouse event to" << tlw;
return;
}
}
#endif
#if 0
// find the tlw if we didn't get it from the plugin
if (!mouseWindow) {
mouseWindow = QGuiApplication::topLevelAt(globalPoint);
}
if (!mouseWindow && !implicit_mouse_grabber)
mouseWindow = QGuiApplication::desktop();
if (mouseWindow && mouseWindow != tlw) {
//we did not get a sensible localPoint from the window system, so let's calculate it
localPoint = mouseWindow->mapFromGlobal(globalPoint);
}
#endif
// which child should have it?
QWidget *mouseWidget = mouseWindow;
if (mouseWindow) {
QWidget *w = mouseWindow->childAt(localPoint);
if (w) {
mouseWidget = w;
}
}
//handle implicit mouse grab
if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) {
implicit_mouse_grabber = mouseWidget;
Q_ASSERT(mouseWindow);
mouseWindow->activateWindow(); //focus
} else if (implicit_mouse_grabber) {
mouseWidget = implicit_mouse_grabber.data();
mouseWindow = mouseWidget->window();
#if 0
if (mouseWindow != tlw)
localPoint = mouseWindow->mapFromGlobal(globalPoint);
#endif
}
if (!mouseWidget)
return;
Q_ASSERT(mouseWidget);
//localPoint is local to mouseWindow, but it needs to be local to mouseWidget
localPoint = mouseWidget->mapFrom(mouseWindow, localPoint);
if (buttons == Qt::NoButton) {
//qDebug() << "resetting mouse grabber";
implicit_mouse_grabber.clear();
}
if (mouseWidget != qt_last_mouse_receiver) {
// dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver);
qt_last_mouse_receiver = mouseWidget;
}
// Remember, we might enter a modal event loop when sending the event,
// so think carefully before adding code below this point.
// qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber;
QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QGuiApplication::keyboardModifiers());
#if 0
QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances();
foreach (QWeakPointer<QPlatformCursor> cursor, cursors) {
if (cursor)
cursor.data()->pointerEvent(ev);
}
#endif
// int oldOpenPopupCount = openPopupCount;
QGuiApplication::sendSpontaneousEvent(mouseWidget, &ev);
#if 0
#ifndef QT_NO_CONTEXTMENU
if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint, globalPoint, QGuiApplication::keyboardModifiers());
QGuiApplication::sendSpontaneousEvent(mouseWidget, &e);
}
#endif // QT_NO_CONTEXTMENU
#endif
}
//### there's a lot of duplicated logic here -- refactoring required!
void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
{
// QPoint localPoint = ev.pos();
QPoint globalPoint = e->globalPos;
// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
QWidget *mouseWidget;
qt_last_x = globalPoint.x();
qt_last_y = globalPoint.y();
QWidget *mouseWindow = e->window.data() ? e->window.data()->widget() : 0;
// find the tlw if we didn't get it from the plugin
#if 0
if (!mouseWindow) {
mouseWindow = QGuiApplication::topLevelAt(globalPoint);
}
#endif
if (!mouseWindow)
return;
mouseWidget = mouseWindow;
#if 0
if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
qDebug() << "modal blocked wheel event" << mouseWindow;
return;
}
QPoint p = mouseWindow->mapFromGlobal(globalPoint);
QWidget *w = mouseWindow->childAt(p);
if (w) {
mouseWidget = w;
p = mouseWidget->mapFromGlobal(globalPoint);
}
QWheelEvent ev(p, globalPoint, e->delta, buttons, QGuiApplication::keyboardModifiers(),
e->orient);
QGuiApplication::sendSpontaneousEvent(mouseWidget, &ev);
#endif
}
// Remember, Qt convention is: keyboard state is state *before*
void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
{
QWidget *focusW = 0;
#if 0
if (self->inPopupMode()) {
QWidget *popupW = qApp->activePopupWidget();
focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
}
if (!focusW)
focusW = QGuiApplication::focusWidget();
#endif
if (!focusW) {
focusW = e->window.data() ? e->window.data()->widget() : 0;
}
#if 0
if (!focusW)
focusW = QGuiApplication::activeWindow();
#endif
//qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
if (!focusW)
return;
#if 0
if (app_do_modal && !qt_try_modal(focusW, e->keyType))
return;
#endif
if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
QGuiApplication::sendSpontaneousEvent(focusW, &ev);
} else {
QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
QGuiApplication::sendSpontaneousEvent(focusW, &ev);
}
}
void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
{
// QGuiApplicationPrivate::dispatchEnterLeave(e->enter.data(),0);
qt_last_mouse_receiver = e->enter.data() ? e->enter.data()->widget() : 0;
}
void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
{
// QGuiApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver);
#if 0
if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
QGuiApplicationPrivate::dispatchEnterLeave(0, e->leave.data());
#endif
qt_last_mouse_receiver = 0;
}
void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
{
// QGuiApplication::setActiveWindow(e->activated.data());
}
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
{
if (e->tlw.isNull())
return;
QWidget *tlw = e->tlw.data() ? e->tlw.data()->widget() : 0;
if (!tlw->isWindow())
return; //geo of native child widgets is controlled by lighthouse
//so we already have sent the events; besides this new rect
//is not mapped to parent
QRect newRect = e->newGeometry;
QRect cr(tlw->geometry());
bool isResize = cr.size() != newRect.size();
bool isMove = cr.topLeft() != newRect.topLeft();
tlw->data->crect = newRect;
if (isResize) {
QResizeEvent e(tlw->data->crect.size(), cr.size());
QGuiApplication::sendSpontaneousEvent(tlw, &e);
tlw->update();
}
if (isMove) {
//### frame geometry
QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft());
QGuiApplication::sendSpontaneousEvent(tlw, &e);
}
}
void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
{
if (e->topLevel.isNull()) {
//qDebug() << "QGuiApplicationPrivate::processCloseEvent NULL";
return;
}
// e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
{
// translateRawTouchEvent(e->widget.data(), e->devType, e->points);
}
void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e)
{
// This operation only makes sense after the QGuiApplication constructor runs
if (QCoreApplication::startingUp())
return;
//QGuiApplication::desktop()->d_func()->updateScreenList();
// signal anything listening for creation or deletion of screens
//QDesktopWidget *desktop = QGuiApplication::desktop();
//emit desktop->screenCountChanged(e->count);
}
void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e)
{
// This operation only makes sense after the QGuiApplication constructor runs
if (QCoreApplication::startingUp())
return;
#if 0
QGuiApplication::desktop()->d_func()->updateScreenList();
// signal anything listening for screen geometry changes
QDesktopWidget *desktop = QGuiApplication::desktop();
emit desktop->resized(e->index);
// make sure maximized and fullscreen windows are updated
QWidgetList list = QGuiApplication::topLevelWidgets();
for (int i = list.size() - 1; i >= 0; --i) {
QWidget *w = list.at(i);
if (w->isFullScreen())
w->d_func()->setFullScreenSize_helper();
else if (w->isMaximized())
w->d_func()->setMaxWindowState_helper();
}
#endif
}
void QGuiApplicationPrivate::reportAvailableGeometryChange(
QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e)
{
// This operation only makes sense after the QGuiApplication constructor runs
if (QCoreApplication::startingUp())
return;
#if 0
QGuiApplication::desktop()->d_func()->updateScreenList();
// signal anything listening for screen geometry changes
QDesktopWidget *desktop = QGuiApplication::desktop();
emit desktop->workAreaResized(e->index);
// make sure maximized and fullscreen windows are updated
QWidgetList list = QGuiApplication::topLevelWidgets();
for (int i = list.size() - 1; i >= 0; --i) {
QWidget *w = list.at(i);
if (w->isFullScreen())
w->d_func()->setFullScreenSize_helper();
else if (w->isMaximized())
w->d_func()->setMaxWindowState_helper();
}
#endif
}
QT_END_NAMESPACE

View File

@ -0,0 +1,121 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGUIAPPLICATION_QPA_H
#define QGUIAPPLICATION_QPA_H
#include <QtCore/qcoreapplication.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qpoint.h>
#include <QtCore/qsize.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QGuiApplicationPrivate;
class QPlatformNativeInterface;
class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
{
Q_OBJECT
Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
public:
QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
virtual ~QGuiApplication();
#if 0
#ifndef QT_NO_CURSOR
static QCursor *overrideCursor();
static void setOverrideCursor(const QCursor &);
static void changeOverrideCursor(const QCursor &);
static void restoreOverrideCursor();
#endif
static QFont font();
static QFont font(const QWidget*);
static QFont font(const char *className);
static void setFont(const QFont &, const char* className = 0);
static QFontMetrics fontMetrics();
#ifndef QT_NO_CLIPBOARD
static QClipboard *clipboard();
#endif
#endif
static Qt::KeyboardModifiers keyboardModifiers();
static Qt::MouseButtons mouseButtons();
static void setDoubleClickInterval(int);
static int doubleClickInterval();
static void setKeyboardInputInterval(int);
static int keyboardInputInterval();
static QPlatformNativeInterface *platformNativeInterface();
static int exec();
bool notify(QObject *, QEvent *);
protected:
bool event(QEvent *);
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
QGuiApplication(QGuiApplicationPrivate &p);
private:
Q_DISABLE_COPY(QGuiApplication)
Q_DECLARE_PRIVATE(QGuiApplication)
#ifndef QT_NO_GESTURES
friend class QGestureManager;
#endif
};
QT_END_NAMESPACE
QT_END_HEADER
#endif // QGUIAPPLICATION_QPA_H

View File

@ -0,0 +1,127 @@
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGUIAPPLICATION_QPA_P_H
#define QGUIAPPLICATION_QPA_P_H
#include <QtGui/qguiapplication_qpa.h>
#include <QtCore/private/qcoreapplication_p.h>
#include <QtCore/private/qthread_p.h>
#include <QWindowSystemInterface>
#include "private/qwindowsysteminterface_qpa_p.h"
#include "QtGui/qplatformintegration_qpa.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QPlatformIntegration;
class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
{
Q_DECLARE_PUBLIC(QGuiApplication)
public:
QGuiApplicationPrivate(int &argc, char **argv, int flags);
~QGuiApplicationPrivate();
static int keyboard_input_time;
static int mouse_double_click_time;
static Qt::KeyboardModifiers modifier_buttons;
static Qt::MouseButtons mouse_buttons;
static QPlatformIntegration *platform_integration;
static QPlatformIntegration *platformIntegration()
{ return platform_integration; }
static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
{ return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
static bool app_do_modal;
static QPointer<QWidget> qt_last_mouse_receiver;
static QWidgetList qt_modal_stack;
static Qt::MouseButtons buttons;
static ulong mousePressTime;
static Qt::MouseButton mousePressButton;
static int mousePressX;
static int mousePressY;
static int mouse_double_click_distance;
private:
void init();
static QGuiApplicationPrivate *self;
};
QT_END_NAMESPACE
QT_END_HEADER
#endif // QGUIAPPLICATION_QPA_P_H

View File

@ -43,10 +43,10 @@
QT_BEGIN_NAMESPACE
void *QPlatformNativeInterface::nativeResourceForWidget(const QByteArray &resource, QWidget *widget)
void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
{
Q_UNUSED(resource);
Q_UNUSED(widget);
Q_UNUSED(window);
return 0;
}

View File

@ -50,12 +50,12 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
class QWidget;
class QWindow;
class Q_GUI_EXPORT QPlatformNativeInterface
{
public:
virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget);
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
};
QT_END_NAMESPACE

View File

@ -113,7 +113,6 @@ void QPlatformWindow::setVisible(bool visible)
*/
Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
{
Q_D(QPlatformWindow);
return flags;
}
@ -174,7 +173,7 @@ void QPlatformWindow::setOpacity(qreal level)
*/
void QPlatformWindow::requestActivateWindow()
{
QWindowSystemInterface::handleWindowActivated(window()->widget());
QWindowSystemInterface::handleWindowActivated(window());
}
/*!

View File

@ -737,6 +737,8 @@ private:
friend class QWidgetBackingStore;
friend class QApplication;
friend class QApplicationPrivate;
friend class QGuiApplication;
friend class QGuiApplicationPrivate;
friend class QBaseApplication;
friend class QPainter;
friend class QPainterPrivate;

View File

@ -172,6 +172,9 @@ protected:
private:
Q_DISABLE_COPY(QWindow)
friend class QGuiApplication;
friend class QGuiApplicationPrivate;
};
QT_END_NAMESPACE

View File

@ -56,51 +56,37 @@ QTime QWindowSystemInterfacePrivate::eventTime;
QList<QWindowSystemInterfacePrivate::WindowSystemEvent *> QWindowSystemInterfacePrivate::windowSystemEventQueue;
QMutex QWindowSystemInterfacePrivate::queueMutex;
extern QPointer<QWidget> qt_last_mouse_receiver;
extern QPointer<QWindow> qt_last_mouse_receiver;
void QWindowSystemInterface::handleEnterEvent(QWidget *tlw)
void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
return;
QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
}
void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw)
void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
return;
}
QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleWindowActivated(QWidget *tlw)
void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
{
QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect)
void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
return;
}
QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleCloseEvent(QWidget *tlw)
void QWindowSystemInterface::handleCloseEvent(QWindow *tlw)
{
if (tlw) {
QWindowSystemInterfacePrivate::CloseEvent *e =
@ -115,42 +101,31 @@ void QWindowSystemInterface::handleCloseEvent(QWidget *tlw)
*/
void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
void QWindowSystemInterface::handleMouseEvent(QWindow *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
handleMouseEvent(w, time, local, global, b);
}
void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
void QWindowSystemInterface::handleMouseEvent(QWindow *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
tlw = 0;
}
QWindowSystemInterfacePrivate::MouseEvent * e =
new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
void QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
handleKeyEvent(w, time, t, k, mods, text, autorep, count);
}
void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
tlw = 0;
}
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text, bool autorep,
@ -161,38 +136,26 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *w, QEvent::Type typ
text, autorep, count);
}
void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, int key,
void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,
Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text, bool autorep,
ushort count)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
tlw = 0;
}
QWindowSystemInterfacePrivate::KeyEvent * e =
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
handleWheelEvent(w, time, local, global, d, o);
}
void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
{
if (tlw) {
QWidgetData *data = qt_qwidget_data(tlw);
if (data->in_destructor)
tlw = 0;
}
QWindowSystemInterfacePrivate::WheelEvent *e =
new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
@ -229,12 +192,12 @@ void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfac
dispatcher->wakeUp();
}
void QWindowSystemInterface::handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) {
void QWindowSystemInterface::handleTouchEvent(QWindow *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) {
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
handleTouchEvent(w, time, type, devType, points);
}
void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points)
void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points)
{
if (!points.size()) // Touch events must have at least one point
return;

View File

@ -44,7 +44,7 @@
#include <QtCore/QTime>
#include <QtGui/qwindowdefs.h>
#include <QtCore/QEvent>
#include <QtGui/QWidget>
#include <QtGui/QWindow>
#include <QtCore/QWeakPointer>
#include <QtCore/QMutex>
#include <QtGui/QTouchEvent>
@ -58,25 +58,25 @@ QT_MODULE(Gui)
class Q_GUI_EXPORT QWindowSystemInterface
{
public:
static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
static void handleMouseEvent(QWindow *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
static void handleMouseEvent(QWindow *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
static void handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
static void handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
static void handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
static void handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
ushort count = 1);
static void handleExtendedKeyEvent(QWidget *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
static void handleExtendedKeyEvent(QWindow *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
ushort count = 1);
static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
static void handleWheelEvent(QWindow *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
static void handleWheelEvent(QWindow *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
struct TouchPoint {
int id; // for application use
@ -87,14 +87,14 @@ public:
Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released}
};
static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
static void handleTouchEvent(QWindow *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
static void handleTouchEvent(QWindow *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
static void handleGeometryChange(QWidget *w, const QRect &newRect);
static void handleCloseEvent(QWidget *w);
static void handleEnterEvent(QWidget *w);
static void handleLeaveEvent(QWidget *w);
static void handleWindowActivated(QWidget *w);
static void handleGeometryChange(QWindow *w, const QRect &newRect);
static void handleCloseEvent(QWindow *w);
static void handleEnterEvent(QWindow *w);
static void handleLeaveEvent(QWindow *w);
static void handleWindowActivated(QWindow *w);
// Changes to the screen
static void handleScreenGeometryChange(int screenIndex);

View File

@ -73,55 +73,55 @@ public:
class CloseEvent : public WindowSystemEvent {
public:
CloseEvent(QWidget *tlw)
CloseEvent(QWindow *tlw)
: WindowSystemEvent(Close), topLevel(tlw) { }
QWeakPointer<QWidget> topLevel;
QWeakPointer<QWindow> topLevel;
};
class GeometryChangeEvent : public WindowSystemEvent {
public:
GeometryChangeEvent(QWidget *tlw, const QRect &newGeometry)
GeometryChangeEvent(QWindow *tlw, const QRect &newGeometry)
: WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry)
{ }
QWeakPointer<QWidget> tlw;
QWeakPointer<QWindow> tlw;
QRect newGeometry;
};
class EnterEvent : public WindowSystemEvent {
public:
EnterEvent(QWidget *enter)
EnterEvent(QWindow *enter)
: WindowSystemEvent(Enter), enter(enter)
{ }
QWeakPointer<QWidget> enter;
QWeakPointer<QWindow> enter;
};
class LeaveEvent : public WindowSystemEvent {
public:
LeaveEvent(QWidget *leave)
LeaveEvent(QWindow *leave)
: WindowSystemEvent(Leave), leave(leave)
{ }
QWeakPointer<QWidget> leave;
QWeakPointer<QWindow> leave;
};
class ActivatedWindowEvent : public WindowSystemEvent {
public:
ActivatedWindowEvent(QWidget *activatedWindow)
ActivatedWindowEvent(QWindow *activatedWindow)
: WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
{ }
QWeakPointer<QWidget> activated;
QWeakPointer<QWindow> activated;
};
class UserEvent : public WindowSystemEvent {
public:
UserEvent(QWidget * w, ulong time, EventType t)
: WindowSystemEvent(t), widget(w), timestamp(time) { }
QWeakPointer<QWidget> widget;
UserEvent(QWindow * w, ulong time, EventType t)
: WindowSystemEvent(t), window(w), timestamp(time) { }
QWeakPointer<QWindow> window;
unsigned long timestamp;
};
class MouseEvent : public UserEvent {
public:
MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
MouseEvent(QWindow * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
: UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { }
QPoint localPos;
QPoint globalPos;
@ -130,7 +130,7 @@ public:
class WheelEvent : public UserEvent {
public:
WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
WheelEvent(QWindow *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
: UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { }
int delta;
QPoint localPos;
@ -140,11 +140,11 @@ public:
class KeyEvent : public UserEvent {
public:
KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
:UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
repeatCount(count), modifiers(mods), keyType(t),
nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { }
KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
quint32 nativeSC, quint32 nativeVK, quint32 nativeMods,
const QString & text = QString(), bool autorep = false, ushort count = 1)
:UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
@ -163,7 +163,7 @@ public:
class TouchEvent : public UserEvent {
public:
TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList<QTouchEvent::TouchPoint> &p)
TouchEvent(QWindow *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList<QTouchEvent::TouchPoint> &p)
:UserEvent(w, time, Touch), devType(d), points(p), touchType(t) { }
QTouchEvent::DeviceType devType;
QList<QTouchEvent::TouchPoint> points;

View File

@ -167,7 +167,7 @@ break;
{ \
event_t *e = (event_t *)event; \
if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \
m_keyboard->handler(platformWindow->window()->widget(), e); \
m_keyboard->handler(platformWindow->window(), e); \
} \
break;

View File

@ -913,7 +913,7 @@ QXcbKeyboard::~QXcbKeyboard()
// #define XCB_KEYBOARD_DEBUG
void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
{
int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0;
@ -954,17 +954,17 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod
QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
QWindowSystemInterface::handleExtendedKeyEvent(widget, time, type, qtcode, modifiers, code, 0, state, string.left(count));
QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, code, 0, state, string.left(count));
}
void QXcbKeyboard::handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event)
void QXcbKeyboard::handleKeyPressEvent(QWindow *window, const xcb_key_press_event_t *event)
{
handleKeyEvent(widget, QEvent::KeyPress, event->detail, event->state, event->time);
handleKeyEvent(window, QEvent::KeyPress, event->detail, event->state, event->time);
}
void QXcbKeyboard::handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event)
void QXcbKeyboard::handleKeyReleaseEvent(QWindow *window, const xcb_key_release_event_t *event)
{
handleKeyEvent(widget, QEvent::KeyRelease, event->detail, event->state, event->time);
handleKeyEvent(window, QEvent::KeyRelease, event->detail, event->state, event->time);
}
void QXcbKeyboard::handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event)

View File

@ -48,21 +48,23 @@
#include <QEvent>
class QWindow;
class QXcbKeyboard : public QXcbObject
{
public:
QXcbKeyboard(QXcbConnection *connection);
~QXcbKeyboard();
void handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event);
void handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event);
void handleKeyPressEvent(QWindow *window, const xcb_key_press_event_t *event);
void handleKeyReleaseEvent(QWindow *window, const xcb_key_release_event_t *event);
void handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event);
Qt::KeyboardModifiers translateModifiers(int s);
private:
void handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
int translateKeySym(uint key) const;
QString translateKeySym(xcb_keysym_t keysym, uint xmodifiers,

View File

@ -534,7 +534,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
{
if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) {
if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) {
QWindowSystemInterface::handleCloseEvent(window()->widget());
QWindowSystemInterface::handleCloseEvent(window());
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) {
xcb_client_message_event_t reply = *event;
@ -570,7 +570,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
return;
QPlatformWindow::setGeometry(rect);
QWindowSystemInterface::handleGeometryChange(window()->widget(), rect);
QWindowSystemInterface::handleGeometryChange(window(), rect);
#if XCB_USE_DRI2
if (m_context)
@ -618,7 +618,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
&& (modifiers & Qt::AltModifier))
|| (event->detail == 6 || event->detail == 7));
QWindowSystemInterface::handleWheelEvent(window()->widget(), event->time,
QWindowSystemInterface::handleWheelEvent(window(), event->time,
local, global, delta, hor ? Qt::Horizontal : Qt::Vertical);
return;
}
@ -649,22 +649,22 @@ void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_times
buttons ^= button; // X event uses state *before*, Qt uses state *after*
QWindowSystemInterface::handleMouseEvent(window()->widget(), time, local, global, buttons);
QWindowSystemInterface::handleMouseEvent(window(), time, local, global, buttons);
}
void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
{
QWindowSystemInterface::handleEnterEvent(window()->widget());
QWindowSystemInterface::handleEnterEvent(window());
}
void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
{
QWindowSystemInterface::handleLeaveEvent(window()->widget());
QWindowSystemInterface::handleLeaveEvent(window());
}
void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *)
{
QWindowSystemInterface::handleWindowActivated(window()->widget());
QWindowSystemInterface::handleWindowActivated(window());
}
void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *)