summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-15 01:00:11 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-15 01:00:11 +0100
commit8264e495fa9220c101a8a913701a0b8834a6d58b (patch)
tree069aa1d3efab926991c1edfc5b69a3d9e58dcfba /src/plugins
parent80f52812f2651e6d427bb3dd2e338b60fb25d48b (diff)
parent8eb3944dac81b8c51d7bac7784204d457551b50c (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp21
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp118
-rw-r--r--src/plugins/platformthemes/flatpak/qflatpaktheme.cpp88
5 files changed, 121 insertions, 114 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 3d0dbd7b1a..20d6e6e8d4 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -1364,9 +1364,10 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPAR
const bool handled = QWindowsContext::instance()->windowsProc(hwnd, message, et, wParam, lParam, &result, &platformWindow);
if (QWindowsContext::verbose > 1 && lcQpaEvents().isDebugEnabled()) {
if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message)) {
- qCDebug(lcQpaEvents) << "EVENT: hwd=" << hwnd << eventName << hex << "msg=0x" << message
- << "et=0x" << et << dec << "wp=" << int(wParam) << "at"
- << GET_X_LPARAM(lParam) << GET_Y_LPARAM(lParam) << "handled=" << handled;
+ qCDebug(lcQpaEvents).nospace() << "EVENT: hwd=" << hwnd << ' ' << eventName
+ << " msg=0x" << hex << message << " et=0x" << et << dec << " wp="
+ << int(wParam) << " at " << GET_X_LPARAM(lParam) << ','
+ << GET_Y_LPARAM(lParam) << " handled=" << handled;
}
}
if (!handled)
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 159e1250d0..9fff4b5e42 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1077,6 +1077,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
*/
const char *QWindowsWindow::embeddedNativeParentHandleProperty = "_q_embedded_native_parent_handle";
+const char *QWindowsWindow::hasBorderInFullScreenProperty = "_q_has_border_in_fullscreen";
QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) :
QWindowsBaseWindow(aWindow),
@@ -1106,7 +1107,6 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
updateDropSite(window()->isTopLevel());
registerTouchWindow();
- setWindowState(aWindow->windowStates());
const qreal opacity = qt_window_private(aWindow)->opacity;
if (!qFuzzyCompare(opacity, qreal(1.0)))
setOpacity(opacity);
@@ -1115,6 +1115,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
if (aWindow->isTopLevel())
setWindowIcon(aWindow->icon());
+ if (aWindow->property(hasBorderInFullScreenProperty).toBool())
+ setFlag(HasBorderInFullScreen);
clearFlag(WithinCreate);
}
@@ -1133,9 +1135,11 @@ void QWindowsWindow::initialize()
QWindowCreationContextPtr creationContext =
QWindowsContext::instance()->setWindowCreationContext(QWindowCreationContextPtr());
+ QWindow *w = window();
+ setWindowState(w->windowStates());
+
// Trigger geometry change (unless it has a special state in which case setWindowState()
// will send the message) and screen change signals of QWindow.
- QWindow *w = window();
if (w->type() != Qt::Desktop) {
const Qt::WindowState state = w->windowState();
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
@@ -2662,15 +2666,26 @@ void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border
if (QPlatformWindow *handle = window->handle())
static_cast<QWindowsWindow *>(handle)->setHasBorderInFullScreen(border);
else
- qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO);
+ window->setProperty(hasBorderInFullScreenProperty, QVariant(border));
}
void QWindowsWindow::setHasBorderInFullScreen(bool border)
{
+ if (testFlag(HasBorderInFullScreen) == border)
+ return;
if (border)
setFlag(HasBorderInFullScreen);
else
clearFlag(HasBorderInFullScreen);
+ // Directly apply the flag in case we are fullscreen.
+ if (m_windowState == Qt::WindowFullScreen) {
+ LONG_PTR style = GetWindowLongPtr(handle(), GWL_STYLE);
+ if (border)
+ style |= WS_BORDER;
+ else
+ style &= ~WS_BORDER;
+ SetWindowLongPtr(handle(), GWL_STYLE, style);
+ }
}
QString QWindowsWindow::formatWindowTitle(const QString &title)
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index 8d29b871bf..fe2518e329 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -340,6 +340,7 @@ public:
static QString formatWindowTitle(const QString &title);
static const char *embeddedNativeParentHandleProperty;
+ static const char *hasBorderInFullScreenProperty;
private:
inline void show_sys() const;
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 6ae52d9fd3..70d1757af4 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -74,7 +74,9 @@ class QXcbShmImage : public QXcbObject
{
public:
QXcbShmImage(QXcbScreen *connection, const QSize &size, uint depth, QImage::Format format);
- ~QXcbShmImage() { destroy(); }
+ ~QXcbShmImage() { destroy(true); }
+
+ void resize(const QSize &size);
void flushScrolledRegion(bool clientSideScroll);
@@ -95,14 +97,18 @@ private:
void createShmSegment(size_t segmentSize);
void destroyShmSegment(size_t segmentSize);
- void destroy();
+ void create(const QSize &size, const xcb_format_t *fmt, QImage::Format format);
+ void destroy(bool destroyShm);
void ensureGC(xcb_drawable_t dst);
void shmPutImage(xcb_drawable_t drawable, const QRegion &region, const QPoint &offset = QPoint());
void flushPixmap(const QRegion &region, bool fullRegion = false);
void setClip(const QRegion &region);
+ xcb_window_t m_screen_root;
+
xcb_shm_segment_info_t m_shm_info;
+ size_t m_segmentSize;
xcb_image_t *m_xcb_image;
@@ -171,6 +177,8 @@ static inline size_t imageDataSize(const xcb_image_t *image)
QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QImage::Format format)
: QXcbObject(screen->connection())
+ , m_screen_root(screen->screen()->root)
+ , m_segmentSize(0)
, m_graphics_buffer(nullptr)
, m_gc(0)
, m_gc_drawable(0)
@@ -180,6 +188,27 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
const xcb_format_t *fmt = connection()->formatForDepth(depth);
Q_ASSERT(fmt);
+ m_hasAlpha = QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha;
+ if (!m_hasAlpha)
+ format = qt_maybeAlphaVersionWithSameDepth(format);
+
+ memset(&m_shm_info, 0, sizeof m_shm_info);
+ create(size, fmt, format);
+}
+
+void QXcbShmImage::resize(const QSize &size)
+{
+ xcb_format_t fmt;
+ fmt.depth = m_xcb_image->depth;
+ fmt.bits_per_pixel = m_xcb_image->bpp;
+ fmt.scanline_pad = m_xcb_image->scanline_pad;
+ memset(fmt.pad0, 0, sizeof(fmt.pad0));
+ destroy(false);
+ create(size, &fmt, m_qimage.format());
+}
+
+void QXcbShmImage::create(const QSize &size, const xcb_format_t *fmt, QImage::Format format)
+{
m_xcb_image = xcb_image_create(size.width(), size.height(),
XCB_IMAGE_FORMAT_Z_PIXMAP,
fmt->scanline_pad,
@@ -192,14 +221,16 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
if (!segmentSize)
return;
- createShmSegment(segmentSize);
+ if (hasShm() && m_segmentSize > 0 && (m_segmentSize < segmentSize || m_segmentSize / 2 >= segmentSize))
+ destroyShmSegment(m_segmentSize);
+ if (!hasShm() && connection()->hasShm())
+ {
+ qCDebug(lcQpaXcb) << "creating shared memory" << segmentSize << "for" << size << "depth" << fmt->depth << "bits" << fmt->bits_per_pixel;
+ createShmSegment(segmentSize);
+ }
m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize);
- m_hasAlpha = QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha;
- if (!m_hasAlpha)
- format = qt_maybeAlphaVersionWithSameDepth(format);
-
m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format);
m_graphics_buffer = new QXcbShmGraphicsBuffer(&m_qimage);
@@ -207,10 +238,36 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
xcb_create_pixmap(xcb_connection(),
m_xcb_image->depth,
m_xcb_pixmap,
- screen->screen()->root,
+ m_screen_root,
m_xcb_image->width, m_xcb_image->height);
}
+void QXcbShmImage::destroy(bool destroyShm)
+{
+ if (m_xcb_image->data) {
+ if (m_shm_info.shmaddr) {
+ if (destroyShm)
+ destroyShmSegment(m_segmentSize);
+ } else {
+ free(m_xcb_image->data);
+ }
+ }
+
+ xcb_image_destroy(m_xcb_image);
+
+ if (m_gc) {
+ xcb_free_gc(xcb_connection(), m_gc);
+ m_gc = 0;
+ }
+ m_gc_drawable = 0;
+
+ delete m_graphics_buffer;
+ m_graphics_buffer = nullptr;
+
+ xcb_free_pixmap(xcb_connection(), m_xcb_pixmap);
+ m_xcb_pixmap = 0;
+}
+
void QXcbShmImage::flushScrolledRegion(bool clientSideScroll)
{
if (m_clientSideScroll == clientSideScroll)
@@ -261,10 +318,8 @@ void QXcbShmImage::flushScrolledRegion(bool clientSideScroll)
void QXcbShmImage::createShmSegment(size_t segmentSize)
{
- m_shm_info.shmaddr = nullptr;
-
- if (!connection()->hasShm())
- return;
+ Q_ASSERT(connection()->hasShm());
+ Q_ASSERT(m_segmentSize == 0);
#ifdef XCB_USE_SHM_FD
if (connection()->hasShmFd()) {
@@ -302,6 +357,8 @@ void QXcbShmImage::createShmSegment(size_t segmentSize)
close(fds[0]);
m_shm_info.shmseg = seg;
m_shm_info.shmaddr = static_cast<quint8 *>(addr);
+
+ m_segmentSize = segmentSize;
} else
#endif
{
@@ -338,6 +395,8 @@ void QXcbShmImage::createShmSegment(size_t segmentSize)
m_shm_info.shmseg = seg;
m_shm_info.shmid = id; // unused
m_shm_info.shmaddr = static_cast<quint8 *>(addr);
+
+ m_segmentSize = segmentSize;
}
}
@@ -350,6 +409,7 @@ void QXcbShmImage::destroyShmSegment(size_t segmentSize)
xcb_generic_error_t *error = xcb_request_check(xcb_connection(), cookie);
if (error)
connection()->printXcbError("QXcbShmImage: xcb_shm_detach() failed with error", error);
+ m_shm_info.shmseg = 0;
#ifdef XCB_USE_SHM_FD
if (connection()->hasShmFd()) {
@@ -364,7 +424,11 @@ void QXcbShmImage::destroyShmSegment(size_t segmentSize)
qWarning("QXcbShmImage: shmdt() failed (%d: %s) for %p",
errno, strerror(errno), m_shm_info.shmaddr);
}
+ m_shm_info.shmid = 0; // unused
}
+ m_shm_info.shmaddr = nullptr;
+
+ m_segmentSize = 0;
}
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
@@ -413,26 +477,6 @@ bool QXcbShmImage::scroll(const QRegion &area, int dx, int dy)
return true;
}
-void QXcbShmImage::destroy()
-{
- if (m_xcb_image->data) {
- if (m_shm_info.shmaddr)
- destroyShmSegment(imageDataSize(m_xcb_image));
- else
- free(m_xcb_image->data);
- }
-
- xcb_image_destroy(m_xcb_image);
-
- if (m_gc)
- xcb_free_gc(xcb_connection(), m_gc);
- delete m_graphics_buffer;
- m_graphics_buffer = nullptr;
-
- xcb_free_pixmap(xcb_connection(), m_xcb_pixmap);
- m_xcb_pixmap = 0;
-}
-
void QXcbShmImage::ensureGC(xcb_drawable_t dst)
{
if (m_gc_drawable != dst) {
@@ -805,7 +849,6 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &)
if (m_image && size == m_image->size())
return;
- QXcbScreen *screen = static_cast<QXcbScreen *>(window()->screen()->handle());
QPlatformWindow *pw = window()->handle();
if (!pw) {
window()->create();
@@ -813,8 +856,13 @@ void QXcbBackingStore::resize(const QSize &size, const QRegion &)
}
QXcbWindow* win = static_cast<QXcbWindow *>(pw);
- delete m_image;
- m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat());
+ if (m_image) {
+ m_image->resize(size);
+ } else {
+ QXcbScreen *screen = static_cast<QXcbScreen *>(window()->screen()->handle());
+ m_image = new QXcbShmImage(screen, size, win->depth(), win->imageFormat());
+ }
+
// Slow path for bgr888 VNC: Create an additional image, paint into that and
// swap R and B while copying to m_image after each paint.
if (win->imageNeedsRgbSwap()) {
diff --git a/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp b/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp
index 04abd707e1..6c5e1389cf 100644
--- a/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp
+++ b/src/plugins/platformthemes/flatpak/qflatpaktheme.cpp
@@ -95,41 +95,25 @@ QFlatpakTheme::QFlatpakTheme()
QPlatformMenuItem* QFlatpakTheme::createPlatformMenuItem() const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->createPlatformMenuItem();
-
- return QPlatformTheme::createPlatformMenuItem();
+ return d->baseTheme->createPlatformMenuItem();
}
QPlatformMenu* QFlatpakTheme::createPlatformMenu() const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->createPlatformMenu();
-
- return QPlatformTheme::createPlatformMenu();
+ return d->baseTheme->createPlatformMenu();
}
QPlatformMenuBar* QFlatpakTheme::createPlatformMenuBar() const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->createPlatformMenuBar();
-
- return QFlatpakTheme::createPlatformMenuBar();
+ return d->baseTheme->createPlatformMenuBar();
}
void QFlatpakTheme::showPlatformMenuBar()
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->showPlatformMenuBar();
-
- return QFlatpakTheme::showPlatformMenuBar();
+ return d->baseTheme->showPlatformMenuBar();
}
bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
@@ -139,10 +123,7 @@ bool QFlatpakTheme::usePlatformNativeDialog(DialogType type) const
if (type == FileDialog)
return true;
- if (d->baseTheme)
- return d->baseTheme->usePlatformNativeDialog(type);
-
- return QFlatpakTheme::usePlatformNativeDialog(type);
+ return d->baseTheme->usePlatformNativeDialog(type);
}
QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type) const
@@ -152,103 +133,64 @@ QPlatformDialogHelper* QFlatpakTheme::createPlatformDialogHelper(DialogType type
if (type == FileDialog)
return new QFlatpakFileDialog;
- if (d->baseTheme)
- return d->baseTheme->createPlatformDialogHelper(type);
-
- return QFlatpakTheme::createPlatformDialogHelper(type);
+ return d->baseTheme->createPlatformDialogHelper(type);
}
#ifndef QT_NO_SYSTEMTRAYICON
QPlatformSystemTrayIcon* QFlatpakTheme::createPlatformSystemTrayIcon() const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->createPlatformSystemTrayIcon();
-
- return QPlatformTheme::createPlatformSystemTrayIcon();
+ return d->baseTheme->createPlatformSystemTrayIcon();
}
#endif
const QPalette *QFlatpakTheme::palette(Palette type) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->palette(type);
-
- return QPlatformTheme::palette(type);
+ return d->baseTheme->palette(type);
}
const QFont* QFlatpakTheme::font(Font type) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->font(type);
-
- return QPlatformTheme::font(type);
+ return d->baseTheme->font(type);
}
QVariant QFlatpakTheme::themeHint(ThemeHint hint) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->themeHint(hint);
-
- return QPlatformTheme::themeHint(hint);
+ return d->baseTheme->themeHint(hint);
}
QPixmap QFlatpakTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->standardPixmap(sp, size);
-
- return QPlatformTheme::standardPixmap(sp, size);
+ return d->baseTheme->standardPixmap(sp, size);
}
QIcon QFlatpakTheme::fileIcon(const QFileInfo &fileInfo,
QPlatformTheme::IconOptions iconOptions) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->fileIcon(fileInfo, iconOptions);
-
- return QPlatformTheme::fileIcon(fileInfo, iconOptions);
+ return d->baseTheme->fileIcon(fileInfo, iconOptions);
}
QIconEngine * QFlatpakTheme::createIconEngine(const QString &iconName) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->createIconEngine(iconName);
-
- return QPlatformTheme::createIconEngine(iconName);
+ return d->baseTheme->createIconEngine(iconName);
}
QList<QKeySequence> QFlatpakTheme::keyBindings(QKeySequence::StandardKey key) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->keyBindings(key);
-
- return QPlatformTheme::keyBindings(key);
+ return d->baseTheme->keyBindings(key);
}
QString QFlatpakTheme::standardButtonText(int button) const
{
Q_D(const QFlatpakTheme);
-
- if (d->baseTheme)
- return d->baseTheme->standardButtonText(button);
-
- return QPlatformTheme::standardButtonText(button);
+ return d->baseTheme->standardButtonText(button);
}
QT_END_NAMESPACE