12#include <QtCore/QThread>
13#include <QtCore/QDebug>
14#include <qpa/qwindowsysteminterface.h>
18#if defined(QQNX_PHYSICAL_SCREEN_WIDTH) && QQNX_PHYSICAL_SCREEN_WIDTH > 0 \
19 && defined(QQNX_PHYSICAL_SCREEN_HEIGHT) && QQNX_PHYSICAL_SCREEN_HEIGHT > 0
20#define QQNX_PHYSICAL_SCREEN_SIZE_DEFINED
21#elif defined(QQNX_PHYSICAL_SCREEN_WIDTH) || defined(QQNX_PHYSICAL_SCREEN_HEIGHT)
22#error Please define QQNX_PHYSICAL_SCREEN_WIDTH and QQNX_PHYSICAL_SCREEN_HEIGHT to values greater than zero
36 const int result = screen_get_display_property_iv(
display, SCREEN_PROPERTY_PHYSICAL_SIZE,
val);
39 return QSize(150, 90);
42 if (
val[0] > 0 &&
val[1] > 0)
45 qCDebug(lcQpaScreen,
"QQnxScreen: screen_get_display_property_iv() reported an invalid "
46 "physical screen size (%dx%d). Falling back to QQNX_PHYSICAL_SCREEN_SIZE "
47 "environment variable.",
val[0],
val[1]);
49 const QString envPhySizeStr =
qgetenv(
"QQNX_PHYSICAL_SCREEN_SIZE");
50 if (!envPhySizeStr.isEmpty()) {
52 const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
53 const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;
55 if (envWidth <= 0 || envHeight <= 0) {
56 qWarning(
"QQnxScreen: The value of QQNX_PHYSICAL_SCREEN_SIZE must be in the format "
57 "\"width,height\" in mm, with width, height > 0. Defaulting to 150x90. "
58 "Example: QQNX_PHYSICAL_SCREEN_SIZE=150,90");
59 return QSize(150, 90);
62 return QSize(envWidth, envHeight);
65#if defined(QQNX_PHYSICAL_SCREEN_SIZE_DEFINED)
66 const QSize defSize(QQNX_PHYSICAL_SCREEN_WIDTH, QQNX_PHYSICAL_SCREEN_HEIGHT);
67 qWarning(
"QQnxScreen: QQNX_PHYSICAL_SCREEN_SIZE variable not set. Falling back to defines "
68 "QQNX_PHYSICAL_SCREEN_WIDTH/QQNX_PHYSICAL_SCREEN_HEIGHT (%dx%d)",
69 defSize.width(), defSize.height());
73 qWarning(
"QQnxScreen: QQNX_PHYSICAL_SCREEN_SIZE variable not set. "
74 "Could not determine physical screen size. Defaulting to 150x90.");
75 return QSize(150, 90);
80 : m_screenContext(screenContext),
83 m_primaryScreen(primaryScreen),
85 m_nativeOrientation(
Qt::PrimaryOrientation),
91 int result = screen_get_display_property_iv(m_display, SCREEN_PROPERTY_ROTATION,
95 m_currentRotation = m_initialRotation;
100 "Failed to query display size");
102 m_currentGeometry = m_initialGeometry =
QRect(0, 0,
val[0],
val[1]);
105 Q_SCREEN_CHECKERROR(screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, 100,
106 name),
"Failed to query display name");
119 m_currentPhysicalSize = m_initialPhysicalSize = screenSize;
121 m_currentPhysicalSize = m_initialPhysicalSize = screenSize.
transposed();
128 childWindow->setScreen(0);
140 qWarning(
"grabWindow: unknown window");
144 QRect bound = qnxWin->geometry();
154 qWarning(
"grabWindow: size is null");
160 if (screen_create_context(&
context, SCREEN_DISPLAY_MANAGER_CONTEXT)) {
162 qWarning(
"grabWindow: root privileges required");
164 qWarning(
"grabWindow: cannot create context");
171 screen_get_context_property_iv(
context, SCREEN_PROPERTY_DISPLAY_COUNT, &
count);
173 const size_t idLen = 30;
178 screen_display_t *displays =
static_cast<screen_display_t*
>
179 (calloc(
count,
sizeof(screen_display_t)));
180 screen_get_context_property_pv(
context, SCREEN_PROPERTY_DISPLAYS, (
void **)displays);
181 screen_get_display_property_cv(m_display, SCREEN_PROPERTY_ID_STRING, idLen, matchId);
183 while (
count && !found) {
185 screen_get_display_property_cv(displays[
count], SCREEN_PROPERTY_ID_STRING, idLen,
id);
186 found = !strncmp(
id, matchId, idLen);
204 int val = SCREEN_USAGE_READ | SCREEN_USAGE_NATIVE;
205 screen_set_pixmap_property_iv(
pixmap, SCREEN_PROPERTY_USAGE, &
val);
206 val = SCREEN_FORMAT_RGBA8888;
207 screen_set_pixmap_property_iv(
pixmap, SCREEN_PROPERTY_FORMAT, &
val);
209 int err = screen_set_pixmap_property_iv(
pixmap, SCREEN_PROPERTY_BUFFER_SIZE,
rect+2);
210 err = err || screen_create_pixmap_buffer(
pixmap);
211 err = err || screen_get_pixmap_property_pv(
pixmap, SCREEN_PROPERTY_RENDER_BUFFERS,
212 reinterpret_cast<void**
>(&
buffer));
213 err = err || screen_get_buffer_property_pv(
buffer, SCREEN_PROPERTY_POINTER, &
pointer);
214 err = err || screen_get_buffer_property_iv(
buffer, SCREEN_PROPERTY_STRIDE, &
stride);
222 qWarning(
"grabWindow: capture error");
224 screen_destroy_pixmap(
pixmap);
226 qWarning(
"grabWindow: display/pixmap error ");
228 screen_destroy_context(
context);
251 return QRect(m_currentGeometry.
x(), m_currentGeometry.
y(),
252 m_currentGeometry.
width(), m_currentGeometry.
height() - m_keyboardHeight);
262 screen_display_mode_t displayMode;
263 int result = screen_get_display_property_pv(m_display, SCREEN_PROPERTY_MODE,
reinterpret_cast<void **
>(&displayMode));
265 if (
result != 0 || displayMode.refresh == 0) {
266 qWarning(
"QQnxScreen: Failed to query screen mode. Using default value of 60Hz");
269 qCDebug(lcQpaScreen,
"screen mode:\n"
274 uint(displayMode.width),
uint(displayMode.height),
uint(displayMode.refresh),
uint(displayMode.interlaced));
275 return static_cast<qreal>(displayMode.refresh);
280 return m_nativeOrientation;
288 if (m_currentRotation == 0)
290 else if (m_currentRotation == 90)
292 else if (m_currentRotation == 180)
299 if (m_currentRotation == 0)
301 else if (m_currentRotation == 90)
303 else if (m_currentRotation == 180)
327 return ((angle1 - angle2) % 180) != 0;
344 m_currentGeometry =
QRect(0, 0, m_initialGeometry.
height(), m_initialGeometry.
width());
345 m_currentPhysicalSize =
QSize(m_initialPhysicalSize.
height(), m_initialPhysicalSize.
width());
347 m_currentGeometry =
QRect(0, 0, m_initialGeometry.
width(), m_initialGeometry.
height());
348 m_currentPhysicalSize = m_initialPhysicalSize;
357 resizeWindows(previousScreenGeometry);
370 if (m_primaryScreen) {
377 screen_flush_context( m_screenContext, 0 );
384void QQnxScreen::resizeNativeWidgetWindow(
QQnxWindow *
w,
const QRect &previousScreenGeometry)
const
386 const qreal relativeX =
static_cast<qreal>(
w->geometry().topLeft().x()) / previousScreenGeometry.width();
387 const qreal relativeY =
static_cast<qreal>(
w->geometry().topLeft().y()) / previousScreenGeometry.height();
388 const qreal relativeWidth =
static_cast<qreal>(
w->geometry().width()) / previousScreenGeometry.width();
389 const qreal relativeHeight =
static_cast<qreal>(
w->geometry().height()) / previousScreenGeometry.height();
394 w->setGeometry(windowGeometry);
400void QQnxScreen::resizeTopLevelWindow(
QQnxWindow *
w,
const QRect &previousScreenGeometry)
const
402 QRect windowGeometry =
w->geometry();
404 const qreal relativeCenterX =
static_cast<qreal>(
w->geometry().center().x()) / previousScreenGeometry.
width();
405 const qreal relativeCenterY =
static_cast<qreal>(
w->geometry().center().y()) / previousScreenGeometry.height();
413 const int x1 = windowGeometry.
x();
414 const int y1 = windowGeometry.
y();
415 const int x2 =
x1 + windowGeometry.
width();
453 windowGeometry.
setSize(newSize);
455 if (windowGeometry.
x() < 0)
458 if (windowGeometry.
y() < 0)
462 w->setGeometry(windowGeometry);
468void QQnxScreen::resizeWindows(
const QRect &previousScreenGeometry)
479 resizeNativeWidgetWindow(
w, previousScreenGeometry);
482 resizeTopLevelWindow(
w, previousScreenGeometry);
525 if (
window != m_coverWindow) {
527 if (
window == m_rootWindow)
529 if (numWindowsRemoved > 0)
540 if (
window != m_coverWindow) {
550 if (
window != m_coverWindow) {
566 result = screen_get_window_property_iv(
rootWindow()->nativeHandle(), SCREEN_PROPERTY_ZORDER, &topZorder);
569 qWarning(
"QQnxScreen: failed to query root window z-order, errno=%d", errno);
578 int underlayZorder = -1;
580 Q_FOREACH (screen_window_t underlay, m_underlays) {
584 screen_set_window_property_iv(underlay, SCREEN_PROPERTY_ZORDER, &underlayZorder);
590 (*it)->updateZorder(topZorder);
593 Q_FOREACH (screen_window_t overlay, m_overlays) {
595 screen_set_window_property_iv(overlay, SCREEN_PROPERTY_ZORDER, &topZorder);
601 screen_flush_context(m_screenContext, 0);
606 if (!m_primaryScreen)
621void QQnxScreen::keyboardHeightChanged(
int height)
623 if (
height == m_keyboardHeight)
626 m_keyboardHeight =
height;
631void QQnxScreen::addOverlayWindow(screen_window_t
window)
637void QQnxScreen::addUnderlayWindow(screen_window_t
window)
643void QQnxScreen::removeOverlayOrUnderlayWindow(screen_window_t
window)
646 if (numRemoved > 0) {
655 const screen_window_t windowHandle =
reinterpret_cast<screen_window_t
>(
window);
657 if (screen_get_window_property_pv(windowHandle, SCREEN_PROPERTY_DISPLAY, (
void**)&
display) != 0) {
658 qWarning(
"QQnx: Failed to get screen for window, errno=%d", errno);
663 if (screen_get_window_property_iv(windowHandle, SCREEN_PROPERTY_ZORDER, &zorder) != 0) {
664 qWarning(
"QQnx: Failed to get z-order for window, errno=%d", errno);
668 char windowNameBuffer[256] = { 0 };
671 if (screen_get_window_property_cv(windowHandle, SCREEN_PROPERTY_ID_STRING,
672 sizeof(windowNameBuffer) - 1, windowNameBuffer) != 0) {
673 qWarning(
"QQnx: Failed to get id for window, errno=%d", errno);
691 addUnderlayWindow(windowHandle);
693 addOverlayWindow(windowHandle);
701 const screen_window_t windowHandle =
reinterpret_cast<screen_window_t
>(
window);
703 removeOverlayOrUnderlayWindow(windowHandle);
734 childWindow->setExposed(
true);
751 childWindow->setExposed(
false);
764 if (
ok && disablePowerSave) {
765 const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
766 int result = screen_set_window_property_iv(
window->nativeHandle(), SCREEN_PROPERTY_IDLE_MODE, &
mode);
768 qWarning(
"QQnxRootWindow: failed to disable power saving mode");
void push_front(rvalue_ref t)
void push_back(parameter_type t)
const_iterator constBegin() const noexcept
qsizetype removeAll(const AT &t)
reverse_iterator rbegin()
void append(parameter_type t)
const_iterator constEnd() const noexcept
QThread * thread() const
Returns the thread in which the object lives.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
\inmodule QtCore\reentrant
void windowClosed(void *window)
QQnxScreen(screen_context_t context, screen_display_t display, bool primaryScreen)
Qt::ScreenOrientation nativeOrientation() const override
Reimplement this function in subclass to return the native orientation of the screen,...
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
QWindow * topLevelAt(const QPoint &point) const override
Return the given top level window for a given position.
void lowerWindow(QQnxWindow *window)
bool isPrimaryScreen() const
void raiseWindow(QQnxWindow *window)
void activateWindowGroup(const QByteArray &id)
void foreignWindowClosed(void *window)
void removeWindow(QQnxWindow *child)
void addWindow(QQnxWindow *child)
QRect availableGeometry() const override
Reimplement in subclass to return the pixel geometry of the available space This normally is the desk...
screen_context_t nativeContext() const
void deactivateWindowGroup(const QByteArray &id)
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.
QQnxWindow * findWindow(screen_window_t windowHandle) const
void foreignWindowCreated(void *window)
void setRootWindow(QQnxWindow *)
int depth() const override
Reimplement in subclass to return current depth of the screen.
screen_display_t nativeDisplay() const
void setRotation(int rotation)
QQnxWindow * rootWindow() const
void newWindowCreated(void *window)
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
void windowGroupStateChanged(const QByteArray &id, Qt::WindowState state)
The QQnxWindow is the base class of the various classes used as instances of QPlatformWindow in the Q...
void setExposed(bool exposed)
void setScreen(QQnxScreen *platformScreen)
void setRotation(int rotation)
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
\inmodule QtCore\reentrant
constexpr void moveCenter(const QPoint &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
int angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) const
Convenience function to compute the angle of rotation to get from rotation a to rotation b.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
void scale(int w, int h, Qt::AspectRatioMode mode) noexcept
Scales the size to a rectangle with the given width and height, according to the specified mode:
constexpr QSize transposed() const noexcept
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QThread * currentThread()
static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry, const QRect &newAvailableGeometry)
static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation)
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState=-1)
QSet< QString >::iterator it
struct wl_display * display
Combined button and popup list for selecting options.
@ InvertedLandscapeOrientation
@ InvertedPortraitOrientation
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
#define Q_FOREACH(variable, container)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat x1
GLenum GLenum GLsizei count
const void GLsizei GLsizei stride
GLfixed GLfixed GLfixed y2
GLsizei const void * pointer
#define Q_SCREEN_CRITICALERROR(x, message)
#define Q_SCREEN_CHECKERROR(x, message)
static const int MAX_UNDERLAY_ZORDER
static bool isOrthogonal(int angle1, int angle2)
Check if the supplied angles are perpendicular to each other.
static int defaultDepth()
static QSize determineScreenSize(screen_display_t display, bool primaryScreen)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
bool contains(const AT &t) const noexcept