8#include <qpa/qplatformscreen.h>
9#include <qpa/qwindowsysteminterface.h>
11#include <private/qwindow_p.h>
12#include <private/qguiapplication_p.h>
17 : QPlatformWindow(window)
18 , m_positionIncludesFrame(
false)
20 , m_pendingGeometryChangeOnShow(
true)
21 , m_frameMarginsRequested(frameMarginsEnabled)
23 if (window->windowState() == Qt::WindowNoState) {
24 setGeometry(windowGeometry());
26 setWindowState(window->windowStates());
29 static WId counter = 0;
32 m_windowForWinIdHash[m_winId] =
this;
37 if (QOffscreenScreen::windowContainingCursor ==
this)
38 QOffscreenScreen::windowContainingCursor =
nullptr;
39 m_windowForWinIdHash.remove(m_winId);
44 if (window()->windowState() != Qt::WindowNoState)
47 m_positionIncludesFrame = qt_window_private(window())->positionPolicy == QWindowPrivate::WindowFrameInclusive;
49 setFrameMarginsEnabled(m_frameMarginsRequested);
50 setGeometryImpl(rect);
52 m_normalGeometry = geometry();
57 QRect adjusted = rect;
58 if (adjusted.width() <= 0)
60 if (adjusted.height() <= 0)
61 adjusted.setHeight(1);
63 if (m_positionIncludesFrame) {
64 adjusted.translate(m_margins.left(), m_margins.top());
67 if (adjusted.left() < m_margins.left())
68 adjusted.translate(m_margins.left(), 0);
69 if (adjusted.top() < m_margins.top())
70 adjusted.translate(0, m_margins.top());
73 QPlatformWindow::setGeometry(adjusted);
76 QWindowSystemInterface::handleGeometryChange(window(), adjusted);
77 QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), adjusted.size()));
79 m_pendingGeometryChangeOnShow =
true;
85 if (visible == m_visible)
89 if (window()->type() != Qt::ToolTip)
90 QWindowSystemInterface::handleFocusWindowChanged(window(), Qt::ActiveWindowFocusReason);
92 if (m_pendingGeometryChangeOnShow) {
93 m_pendingGeometryChangeOnShow =
false;
94 QWindowSystemInterface::handleGeometryChange(window(), geometry());
98 const QPoint cursorPos = QCursor::pos();
100 QRect rect(QPoint(), geometry().size());
101 QWindowSystemInterface::handleExposeEvent(window(), rect);
102 if (QWindowPrivate::get(window())->isPopup() && QGuiApplicationPrivate::currentMouseWindow) {
103 QWindowSystemInterface::handleLeaveEvent<QWindowSystemInterface::SynchronousDelivery>
104 (QGuiApplicationPrivate::currentMouseWindow);
106 if (geometry().contains(cursorPos))
107 QWindowSystemInterface::handleEnterEvent(window(),
108 window()->mapFromGlobal(cursorPos), cursorPos);
110 QWindowSystemInterface::handleExposeEvent(window(), QRegion());
111 if (window()->type() & Qt::Window) {
112 if (QWindow *windowUnderMouse = QGuiApplication::topLevelAt(cursorPos)) {
113 QWindowSystemInterface::handleEnterEvent(windowUnderMouse,
114 windowUnderMouse->mapFromGlobal(cursorPos),
126 QWindowSystemInterface::handleFocusWindowChanged(window(), Qt::ActiveWindowFocusReason);
136 return window()->requestedFormat();
147 && !(window()->flags() & Qt::FramelessWindowHint)
148 && (parent() ==
nullptr)) {
149 m_margins = QMargins(2, 2, 2, 2);
151 m_margins = QMargins(0, 0, 0, 0);
157 setFrameMarginsEnabled(m_frameMarginsRequested && !(state & Qt::WindowFullScreen));
158 m_positionIncludesFrame =
false;
160 if (state & Qt::WindowMinimized)
162 else if (state & Qt::WindowFullScreen)
163 setGeometryImpl(screen()->geometry());
164 else if (state & Qt::WindowMaximized)
165 setGeometryImpl(screen()->availableGeometry().adjusted(m_margins.left(), m_margins.top(), -m_margins.right(), -m_margins.bottom()));
167 setGeometryImpl(m_normalGeometry);
169 QWindowSystemInterface::handleWindowStateChanged(window(), state);
174 return m_windowForWinIdHash.value(id,
nullptr);
177Q_CONSTINIT QHash<WId, QOffscreenWindow *> QOffscreenWindow::m_windowForWinIdHash;
QSurfaceFormat format() const override
Returns the actual surface format of the window.
void setWindowState(Qt::WindowStates states) override
Requests setting the window state of this surface to type.
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QMargins frameMargins() const override
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
Combined button and popup list for selecting options.