10#include <QtGui/QPainter>
11#include <QtGui/private/qpixmap_raster_p.h>
12#include <QtGui/private/qguiapplication_p.h>
14#include <qpa/qplatformcursor.h>
15#include <qpa/qplatformwindow.h>
19QPlatformWindow *QOffscreenScreen::windowContainingCursor =
nullptr;
24 QList<QPlatformScreen *> platformScreens;
26 for (
auto screen : screens) {
27 platformScreens.append(screen);
29 return platformScreens;
38 void setPos(
const QPoint &pos)
override
41 const QWindowList wl = QGuiApplication::topLevelWindows();
42 QWindow *containing =
nullptr;
43 for (QWindow *w : wl) {
44 if (w->isExposed() && w->geometry().contains(pos)) {
52 local -= containing->position();
54 QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() :
nullptr;
56 if (containing != previous)
57 QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos);
59 QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton,
60 QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt);
62 QOffscreenScreen::windowContainingCursor = containing ? containing->handle() :
nullptr;
67 Q_UNUSED(windowCursor);
84 QRect rect(x, y, width, height);
89 rect.setWidth(m_geometry.width());
91 rect.setHeight(m_geometry.height());
92 QPixmap screenImage(rect.size());
93 QPainter painter(&screenImage);
94 painter.translate(-x, -y);
95 const QWindowList wl = QGuiApplication::topLevelWindows();
96 for (QWindow *w : wl) {
97 if (w->isExposed() && w->geometry().intersects(rect)) {
98 QOffscreenBackingStore *store = QOffscreenBackingStore::backingStoreForWinId(w->winId());
99 const QImage windowImage = store ? store->toImage() : QImage();
100 if (!windowImage.isNull())
101 painter.drawImage(w->position(), windowImage);
109 return store->grabWindow(id, rect);
132 if (m_image.size().isEmpty())
135 QSize imageSize = m_image.size();
137 QRegion clipped = QRect(0, 0, window->width(), window->height());
138 clipped &= QRect(0, 0, imageSize.width(), imageSize.height()).translated(-offset);
140 QRect bounds = clipped.boundingRect().translated(offset);
145 WId id = window->winId();
147 m_windowAreaHash[id] = bounds;
148 m_backingStoreForWinIdHash[id] =
this;
153 QImage::Format format = window()->format().hasAlpha()
154 ? QImage::Format_ARGB32_Premultiplied
155 : QGuiApplication::primaryScreen()->handle()->format();
156 if (m_image.size() != size)
157 m_image = QImage(size, format);
165 if (m_image.isNull())
168 const QRect rect = area.boundingRect();
176 if (QImage::toPixelFormat(m_image.format()).alphaUsage() == QPixelFormat::UsesAlpha) {
177 QPainter p(&m_image);
178 p.setCompositionMode(QPainter::CompositionMode_Source);
179 const QColor blank = Qt::transparent;
180 for (
const QRect &r : region)
181 p.fillRect(r, blank);
187 QRect area = m_windowAreaHash.value(window, QRect());
191 QRect adjusted = rect;
192 if (adjusted.width() <= 0)
193 adjusted.setWidth(area.width());
194 if (adjusted.height() <= 0)
195 adjusted.setHeight(area.height());
197 adjusted = adjusted.translated(area.topLeft()) & area;
199 if (adjusted.isEmpty())
202 return QPixmap::fromImage(m_image.copy(adjusted));
207 return m_backingStoreForWinIdHash.value(id,
nullptr);
212 for (
auto it = m_windowAreaHash.cbegin(), end = m_windowAreaHash.cend(); it != end; ++it) {
213 const auto it2 = std::as_const(m_backingStoreForWinIdHash).find(it.key());
214 if (it2.value() ==
this)
215 m_backingStoreForWinIdHash.erase(it2);
217 m_windowAreaHash.clear();
223 : m_integration(integration)
231
232
235 iface->m_integration->setConfiguration(configuration);
239
240
243 return iface->m_integration->configuration();
248 if (resource ==
"setConfiguration")
249 return reinterpret_cast<
void*>(&QOffscreenPlatformNativeInterface::setConfiguration);
250 else if (resource ==
"configuration")
251 return reinterpret_cast<
void*>(&QOffscreenPlatformNativeInterface::configuration);
bool scroll(const QRegion &area, int dx, int dy) override
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.
void beginPaint(const QRegion &) override
This function is called before painting onto the surface begins, with the region in which the paintin...
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override
Flushes the given region from the specified window.
~QOffscreenBackingStore()
void resize(const QSize &size, const QRegion &staticContents) override
QOffscreenBackingStore(QWindow *window)
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
QPixmap grabWindow(WId window, const QRect &rect) const
void setPos(const QPoint &pos) override
QPoint pos() const override
void changeCursor(QCursor *windowCursor, QWindow *window) override
This method is called by Qt whenever the cursor graphic should be changed.
QOffscreenScreen(const QOffscreenIntegration *integration)
QPixmap grabWindow(WId window, int x, int y, int width, int height) const override
This function is called when Qt needs to be able to grab the content of a window.
const QOffscreenIntegration * m_integration
Combined button and popup list for selecting options.
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)