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;
25 for (
auto screen : m_integration->screens()) {
26 platformScreens.append(screen);
28 return platformScreens;
37 void setPos(
const QPoint &pos)
override
40 const QWindowList wl = QGuiApplication::topLevelWindows();
41 QWindow *containing =
nullptr;
42 for (QWindow *w : wl) {
43 if (w->isExposed() && w->geometry().contains(pos)) {
51 local -= containing->position();
53 QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() :
nullptr;
55 if (containing != previous)
56 QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos);
58 QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton,
59 QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt);
61 QOffscreenScreen::windowContainingCursor = containing ? containing->handle() :
nullptr;
66 Q_UNUSED(windowCursor);
83 QRect rect(x, y, width, height);
88 rect.setWidth(m_geometry.width());
90 rect.setHeight(m_geometry.height());
91 QPixmap screenImage(rect.size());
92 QPainter painter(&screenImage);
93 painter.translate(-x, -y);
94 const QWindowList wl = QGuiApplication::topLevelWindows();
95 for (QWindow *w : wl) {
96 if (w->isExposed() && w->geometry().intersects(rect)) {
97 QOffscreenBackingStore *store = QOffscreenBackingStore::backingStoreForWinId(w->winId());
98 const QImage windowImage = store ? store->toImage() : QImage();
99 if (!windowImage.isNull())
100 painter.drawImage(w->position(), windowImage);
108 return store->grabWindow(id, rect);
131 if (m_image.size().isEmpty())
134 QSize imageSize = m_image.size();
136 QRegion clipped = QRect(0, 0, window->width(), window->height());
137 clipped &= QRect(0, 0, imageSize.width(), imageSize.height()).translated(-offset);
139 QRect bounds = clipped.boundingRect().translated(offset);
144 WId id = window->winId();
146 m_windowAreaHash[id] = bounds;
147 m_backingStoreForWinIdHash[id] =
this;
152 QImage::Format format = window()->format().hasAlpha()
153 ? QImage::Format_ARGB32_Premultiplied
154 : QGuiApplication::primaryScreen()->handle()->format();
155 if (m_image.size() != size)
156 m_image = QImage(size, format);
164 if (m_image.isNull())
167 const QRect rect = area.boundingRect();
175 if (QImage::toPixelFormat(m_image.format()).alphaUsage() == QPixelFormat::UsesAlpha) {
176 QPainter p(&m_image);
177 p.setCompositionMode(QPainter::CompositionMode_Source);
178 const QColor blank = Qt::transparent;
179 for (
const QRect &r : region)
180 p.fillRect(r, blank);
186 QRect area = m_windowAreaHash.value(window, QRect());
190 QRect adjusted = rect;
191 if (adjusted.width() <= 0)
192 adjusted.setWidth(area.width());
193 if (adjusted.height() <= 0)
194 adjusted.setHeight(area.height());
196 adjusted = adjusted.translated(area.topLeft()) & area;
198 if (adjusted.isEmpty())
201 return QPixmap::fromImage(m_image.copy(adjusted));
206 return m_backingStoreForWinIdHash.value(id,
nullptr);
211 for (
auto it = m_windowAreaHash.cbegin(), end = m_windowAreaHash.cend(); it != end; ++it) {
212 const auto it2 = std::as_const(m_backingStoreForWinIdHash).find(it.key());
213 if (it2.value() ==
this)
214 m_backingStoreForWinIdHash.erase(it2);
216 m_windowAreaHash.clear();
222 : m_integration(integration)
230
231
234 iface->m_integration->setConfiguration(configuration);
238
239
242 return iface->m_integration->configuration();
247 if (resource ==
"setConfiguration")
248 return reinterpret_cast<
void*>(&QOffscreenPlatformNativeInterface::setConfiguration);
249 else if (resource ==
"configuration")
250 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)