summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-20 19:12:23 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-20 19:12:25 +0200
commit3361fcbc28be96262d22fd2b024c85fbcbc61462 (patch)
tree48976f337b3885971dc1976b9a27cec5e7dfa2ec /src/gui/kernel
parentdc612acdc6577594c8f61345cea2de549d7aae34 (diff)
parent5e342f6f041208d142d97202f61179d7163eb773 (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qclipboard.cpp11
-rw-r--r--src/gui/kernel/qevent.cpp11
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp8
-rw-r--r--src/gui/kernel/qopenglcontext.cpp10
-rw-r--r--src/gui/kernel/qopenglcontext_p.h3
-rw-r--r--src/gui/kernel/qopenglwindow.cpp17
-rw-r--r--src/gui/kernel/qplatformmenu.h5
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp12
8 files changed, 41 insertions, 36 deletions
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index ec9a8fdcf0..5be9f19b3e 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -463,9 +463,14 @@ const QMimeData* QClipboard::mimeData(Mode mode) const
void QClipboard::setMimeData(QMimeData* src, Mode mode)
{
QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
- if (!clipboard->supportsMode(mode)) return;
-
- clipboard->setMimeData(src,mode);
+ if (!clipboard->supportsMode(mode)) {
+ if (src != 0) {
+ qWarning("Data set on unsupported clipboard mode. QMimeData object will be deleted.");
+ src->deleteLater();
+ }
+ } else {
+ clipboard->setMimeData(src,mode);
+ }
}
/*!
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index f99f28d6e0..a8539e8013 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -897,12 +897,11 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
when keys are pressed or released.
A key event contains a special accept flag that indicates whether
- the receiver will handle the key event. You should call ignore()
- if the key press or release event is not handled by your widget.
- A key event is propagated up the parent widget chain until a
- widget accepts it with accept() or an event filter consumes it.
- Key events for multimedia keys are ignored by default. You should
- call accept() if your widget handles those events.
+ the receiver will handle the key event. This flag is set by default,
+ so there is no need to call accept() when acting on a key event.
+ Calling ignore() on a key event will propagate it to the parent widget.
+ The event is propagated up the parent widget chain until a widget
+ accepts it or an event filter consumes it.
The QWidget::setEnable() function can be used to enable or disable
mouse and keyboard events for a widget.
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
index 56c4fbbf8b..5cf77de5d8 100644
--- a/src/gui/kernel/qoffscreensurface.cpp
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -64,6 +64,12 @@ QT_BEGIN_NAMESPACE
typically use a pixel buffer (pbuffer). If the platform doesn't implement or support
offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.
+ \note Due to the fact that QOffscreenSurface is backed by a QWindow on some platforms,
+ cross-platform applications must ensure that create() is only called on the main (GUI)
+ thread. The QOffscreenSurface is then safe to be used with
+ \l{QOpenGLContext::makeCurrent()}{makeCurrent()} on other threads, but the
+ initialization and destruction must always happen on the main (GUI) thread.
+
\note In order to create an offscreen surface that is guaranteed to be compatible with
a given context and window, make sure to set the format to the context's or the
window's actual format, that is, the QSurfaceFormat returned from
@@ -152,6 +158,8 @@ QOffscreenSurface::SurfaceType QOffscreenSurface::surfaceType() const
Call destroy() to free the platform resources if necessary.
+ \note Some platforms require this function to be called on the main (GUI) thread.
+
\sa destroy()
*/
void QOffscreenSurface::create()
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 51b4a6a079..07a7c601fa 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -350,16 +350,6 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context
return previous;
}
-void QOpenGLContextPrivate::setGlobalShareContext(QOpenGLContext *context)
-{
- qt_gl_set_global_share_context(context);
-}
-
-QOpenGLContext *QOpenGLContextPrivate::globalShareContext()
-{
- return qt_gl_global_share_context();
-}
-
int QOpenGLContextPrivate::maxTextureSize()
{
if (max_texture_size != -1)
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 7c45737d0a..d5a3126176 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -241,9 +241,6 @@ public:
static QOpenGLContext *setCurrentContext(QOpenGLContext *context);
- static void setGlobalShareContext(QOpenGLContext *context);
- static QOpenGLContext *globalShareContext();
-
int maxTextureSize();
static QOpenGLContextPrivate *get(QOpenGLContext *context)
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp
index 2b6692c461..158fb248dc 100644
--- a/src/gui/kernel/qopenglwindow.cpp
+++ b/src/gui/kernel/qopenglwindow.cpp
@@ -211,8 +211,11 @@ public:
context->makeCurrent(q);
}
+ const int deviceWidth = q->width() * q->devicePixelRatio();
+ const int deviceHeight = q->height() * q->devicePixelRatio();
+ const QSize deviceSize(deviceWidth, deviceHeight);
if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
- if (!fbo || fbo->size() != q->size() * q->devicePixelRatio()) {
+ if (!fbo || fbo->size() != deviceSize) {
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
if (q->requestedFormat().samples() > 0) {
@@ -221,15 +224,13 @@ public:
else
qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling");
}
- fbo.reset(new QOpenGLFramebufferObject(q->size() * q->devicePixelRatio(), fboFormat));
+ fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat));
markWindowAsDirty();
}
} else {
markWindowAsDirty();
}
- const int deviceWidth = q->width() * q->devicePixelRatio();
- const int deviceHeight = q->height() * q->devicePixelRatio();
paintDevice->setSize(QSize(deviceWidth, deviceHeight));
paintDevice->setDevicePixelRatio(q->devicePixelRatio());
context->functions()->glViewport(0, 0, deviceWidth, deviceHeight);
@@ -252,11 +253,13 @@ public:
context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject());
if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) {
+ const int deviceWidth = q->width() * q->devicePixelRatio();
+ const int deviceHeight = q->height() * q->devicePixelRatio();
QOpenGLExtensions extensions(context.data());
extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle());
extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject());
- extensions.glBlitFramebuffer(0, 0, q->width(), q->height(),
- 0, 0, q->width(), q->height(),
+ extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight,
+ 0, 0, deviceWidth, deviceHeight,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
} else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) {
if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) {
@@ -591,7 +594,7 @@ int QOpenGLWindow::metric(PaintDeviceMetric metric) const
break;
case PdmDevicePixelRatio:
if (d->paintDevice)
- return d->paintDevice->devicePixelRatio();
+ return devicePixelRatio();
break;
default:
break;
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index c832de0be6..0093ef1538 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -108,11 +108,6 @@ public:
virtual void setFont(const QFont &font) { Q_UNUSED(font); }
virtual void setMenuType(MenuType type) { Q_UNUSED(type); }
- virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item)
- {
- showPopup(parentWindow, QRect(pos, QSize()), item);
- }
-
virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item)
{
Q_UNUSED(parentWindow);
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index d03a3f7be8..bd95a8614f 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -201,9 +201,13 @@ bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, ulong timestamp,
#ifndef QT_NO_SHORTCUT
QGuiApplicationPrivate::modifier_buttons = mods;
+ QObject *focus = w->focusObject();
+ if (!focus)
+ focus = w;
+
QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, text, autorep, count);
qevent.setTimestamp(timestamp);
- return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent);
+ return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, &qevent);
#else
Q_UNUSED(w)
Q_UNUSED(timestamp)
@@ -231,9 +235,13 @@ bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, ulong ti
#ifndef QT_NO_SHORTCUT
QGuiApplicationPrivate::modifier_buttons = mods;
+ QObject *focus = w->focusObject();
+ if (!focus)
+ focus = w;
+
QKeyEvent qevent(QEvent::ShortcutOverride, k, mods, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
qevent.setTimestamp(timestamp);
- return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(w, &qevent);
+ return QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, &qevent);
#else
Q_UNUSED(w)
Q_UNUSED(timestamp)