diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qapplication_qpa.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_qpa.cpp | 49 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_qpa_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_qpa.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_qpa.cpp | 25 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 25 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 10 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 33 |
8 files changed, 111 insertions, 42 deletions
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index bb25075dba..94b6cd5c41 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -78,13 +78,7 @@ QString QApplicationPrivate::appName() const void QApplicationPrivate::createEventDispatcher() { - Q_Q(QApplication); -#if !defined(QT_NO_GLIB) - if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) - eventDispatcher = new QPAEventDispatcherGlib(q); - else -#endif - eventDispatcher = new QEventDispatcherQPA(q); + QGuiApplicationPrivate::createEventDispatcher(); } static bool qt_try_modal(QWidget *widget, QEvent::Type type) diff --git a/src/gui/kernel/qguiapplication_qpa.cpp b/src/gui/kernel/qguiapplication_qpa.cpp index df03c44c73..4c4f4278b9 100644 --- a/src/gui/kernel/qguiapplication_qpa.cpp +++ b/src/gui/kernel/qguiapplication_qpa.cpp @@ -45,6 +45,12 @@ #include "private/qplatformintegrationfactory_qpa_p.h" #include "private/qevent_p.h" +#if !defined(QT_NO_GLIB) +#include "qeventdispatcher_glib_qpa_p.h" +#endif +#include "qeventdispatcher_qpa_p.h" + +#include <QtCore/QAbstractEventDispatcher> #include <QtCore/private/qcoreapplication_p.h> #include <QtCore/private/qabstracteventdispatcher_p.h> #include <QtCore/qmutex.h> @@ -100,6 +106,8 @@ QGuiApplication::QGuiApplication(int &argc, char **argv, int flags) : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) { d_func()->init(); + + QCoreApplicationPrivate::eventDispatcher->startingUp(); } QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) @@ -162,6 +170,16 @@ static void init_plugins(const QList<QByteArray> pluginList) } } +void QGuiApplicationPrivate::createEventDispatcher() +{ + Q_Q(QGuiApplication); +#if !defined(QT_NO_GLIB) + if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported()) + eventDispatcher = new QPAEventDispatcherGlib(q); + else +#endif + eventDispatcher = new QEventDispatcherQPA(q); +} void QGuiApplicationPrivate::init() { @@ -213,6 +231,8 @@ void QGuiApplicationPrivate::init() init_plugins(pluginList); QFont::initialize(); + + is_app_running = true; } QGuiApplicationPrivate::~QGuiApplicationPrivate() @@ -220,6 +240,9 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() delete platform_integration; platform_integration = 0; + is_app_closing = true; + is_app_running = false; + QFont::cleanup(); } @@ -362,7 +385,9 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo stateChange = Qt::NoButton; } - QWidget * tlw = e->window.data() ? e->window.data()->widget() : 0; + QWindow *window = e->window.data(); + + QWidget * tlw = window ? window->widget() : 0; QPoint localPoint = e->localPos; QPoint globalPoint = e->globalPos; @@ -370,7 +395,6 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo Qt::MouseButton button = Qt::NoButton; - if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) { type = QEvent::MouseMove; qt_last_x = globalPoint.x(); @@ -410,6 +434,13 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo type = QEvent::MouseButtonRelease; } + + if (window && !tlw) { + QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QGuiApplication::keyboardModifiers()); + QGuiApplication::sendSpontaneousEvent(window, &ev); + return; + } + #if 0 if (self->inPopupMode()) { //popup mouse handling is magical... @@ -606,7 +637,7 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En qt_last_mouse_receiver = e->enter.data() ? e->enter.data()->widget() : 0; } -void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) +void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *) { // QGuiApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver); @@ -618,7 +649,7 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le } -void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e) +void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *) { // QGuiApplication::setActiveWindow(e->activated.data()); } @@ -628,7 +659,7 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr if (e->tlw.isNull()) return; QWidget *tlw = e->tlw.data() ? e->tlw.data()->widget() : 0; - if (!tlw->isWindow()) + if (!tlw || !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 @@ -660,12 +691,12 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl // e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent); } -void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) +void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *) { // translateRawTouchEvent(e->widget.data(), e->devType, e->points); } -void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e) +void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) @@ -677,7 +708,7 @@ void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::Sc //emit desktop->screenCountChanged(e->count); } -void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) +void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) @@ -703,7 +734,7 @@ void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate: } void QGuiApplicationPrivate::reportAvailableGeometryChange( - QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e) + QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *) { // This operation only makes sense after the QGuiApplication constructor runs if (QCoreApplication::startingUp()) diff --git a/src/gui/kernel/qguiapplication_qpa_p.h b/src/gui/kernel/qguiapplication_qpa_p.h index d1ea998768..3a01b38e25 100644 --- a/src/gui/kernel/qguiapplication_qpa_p.h +++ b/src/gui/kernel/qguiapplication_qpa_p.h @@ -67,6 +67,8 @@ public: QGuiApplicationPrivate(int &argc, char **argv, int flags); ~QGuiApplicationPrivate(); + void createEventDispatcher(); + static int keyboard_input_time; static int mouse_double_click_time; diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index d4032c49d6..75c54a2c55 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -94,6 +94,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO QWindow *win = topData()->window; win->setWindowFlags(data.window_flags); + win->setGeometry(q->geometry()); win->create(); data.window_flags = win->windowFlags(); diff --git a/src/gui/kernel/qwindow_qpa.cpp b/src/gui/kernel/qwindow_qpa.cpp index 02695ab2d1..469afaa3d2 100644 --- a/src/gui/kernel/qwindow_qpa.cpp +++ b/src/gui/kernel/qwindow_qpa.cpp @@ -410,10 +410,29 @@ void QWindow::hideEvent(QHideEvent *) qDebug() << "unimplemented:" << __FILE__ << __LINE__; } -bool QWindow::event(QEvent *) +bool QWindow::event(QEvent *event) { - qDebug() << "unimplemented:" << __FILE__ << __LINE__; - return false; + switch (event->type()) { + case QEvent::MouseMove: + mouseMoveEvent((QMouseEvent*)event); + break; + + case QEvent::MouseButtonPress: + mousePressEvent((QMouseEvent*)event); + break; + + case QEvent::MouseButtonRelease: + mouseReleaseEvent((QMouseEvent*)event); + break; + + case QEvent::MouseButtonDblClick: + mouseDoubleClickEvent((QMouseEvent*)event); + break; + + default: + return QObject::event(event); + } + return true; } void QWindow::keyPressEvent(QKeyEvent *) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index a9340ad78d..5a2a033b4c 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -143,23 +143,26 @@ QXcbConnection::~QXcbConnection() delete m_keyboard; } -QXcbWindow *platformWindowFromId(xcb_window_t id) +void QXcbConnection::addWindow(xcb_window_t id, QXcbWindow *window) { - QWidget *widget = QWidget::find(id); - if (widget) - return static_cast<QXcbWindow *>(widget->windowHandle()->handle()); - return 0; + m_mapper.insert(id, window); +} + +void QXcbConnection::removeWindow(xcb_window_t id) +{ + m_mapper.remove(id); +} + +QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id) +{ + return m_mapper.value(id, 0); } #define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \ { \ event_t *e = (event_t *)event; \ - if (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) { \ - QWindow *windowHandle = platformWindow->window(); \ - QObjectPrivate *d = QObjectPrivate::get(windowHandle->widget()); \ - if (!d->wasDeleted) \ - platformWindow->handler(e); \ - } \ + if (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) \ + platformWindow->handler(e); \ } \ break; diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 6b5f81047d..cbdfff7e15 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -44,6 +44,7 @@ #include <xcb/xcb.h> +#include <QHash> #include <QList> #include <QObject> #include <QVector> @@ -51,6 +52,9 @@ #define Q_XCB_DEBUG class QXcbScreen; +class QXcbWindow; + +typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper; namespace QXcbAtom { enum Atom { @@ -255,6 +259,9 @@ public: void sync(); void handleXcbError(xcb_generic_error_t *error); + void addWindow(xcb_window_t id, QXcbWindow *window); + void removeWindow(xcb_window_t id); + private slots: void processXcbEvents(); @@ -264,6 +271,7 @@ private: #ifdef XCB_USE_DRI2 void initializeDri2(); #endif + QXcbWindow *platformWindowFromId(xcb_window_t id); xcb_connection_t *m_connection; const xcb_setup_t *m_setup; @@ -303,6 +311,8 @@ private: template <typename cookie_t> friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); #endif + + WindowMapper m_mapper; }; #define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display())) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 81aa986c11..fa8ab0aa22 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -90,7 +90,7 @@ QXcbWindow::QXcbWindow(QWindow *window) , m_context(0) { QWidget *tlw = window->widget(); - m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw)); + m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0)); setConnection(m_screen->connection()); @@ -112,9 +112,11 @@ QXcbWindow::QXcbWindow(QWindow *window) | XCB_EVENT_MASK_FOCUS_CHANGE }; + QRect rect = window->geometry(); + #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) if (window->surfaceType() == QWindow::OpenGLSurface - && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window->requestedWindowFormat()); @@ -136,7 +138,7 @@ QXcbWindow::QXcbWindow(QWindow *window) XSetWindowAttributes a; a.colormap = cmap; - m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(), + m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), rect.x(), rect.y(), rect.width(), rect.height(), 0, visualInfo->depth, InputOutput, visualInfo->visual, CWColormap, &a); @@ -153,10 +155,10 @@ QXcbWindow::QXcbWindow(QWindow *window) XCB_COPY_FROM_PARENT, // depth -- same as root m_window, // window id m_screen->root(), // parent window id - tlw->x(), - tlw->y(), - tlw->width(), - tlw->height(), + rect.x(), + rect.y(), + rect.width(), + rect.height(), 0, // border width XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class m_screen->screen()->root_visual, // visual @@ -166,6 +168,8 @@ QXcbWindow::QXcbWindow(QWindow *window) printf("created regular window: %d\n", m_window); } + connection()->addWindow(m_window, this); + Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); xcb_atom_t properties[4]; @@ -177,7 +181,7 @@ QXcbWindow::QXcbWindow(QWindow *window) if (m_screen->syncRequestSupported()) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); - if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint) + if (window->windowFlags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); Q_XCB_CALL(xcb_change_property(xcb_connection(), @@ -205,7 +209,7 @@ QXcbWindow::QXcbWindow(QWindow *window) &m_syncCounter)); } - if (isTransient(tlw) && tlw->parentWidget()) { + if (tlw && isTransient(tlw) && tlw->parentWidget()) { // ICCCM 4.1.2.6 QWidget *p = tlw->parentWidget()->window(); xcb_window_t parentWindow = p->winId(); @@ -227,6 +231,7 @@ QXcbWindow::~QXcbWindow() delete m_context; if (m_screen->syncRequestSupported()) Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter)); + connection()->removeWindow(m_window); Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); } @@ -245,7 +250,7 @@ void QXcbWindow::setVisible(bool visible) xcb_wm_hints_t hints; if (visible) { // TODO: QWindow::isMinimized() or similar - if (window()->widget()->isMinimized()) + if (window()->windowState() & Qt::WindowMinimized) xcb_wm_hints_set_iconic(&hints); else xcb_wm_hints_set_normal(&hints); @@ -522,11 +527,15 @@ QPlatformGLContext *QXcbWindow::glContext() const void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) { - QWindowSurface *surface = window()->widget()->windowSurface(); + QWidget *widget = window()->widget(); + if (!widget) + return; + + QWindowSurface *surface = widget->windowSurface(); if (surface) { QRect rect(event->x, event->y, event->width, event->height); - surface->flush(window()->widget(), rect, QPoint()); + surface->flush(widget, rect, QPoint()); } } |