Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdirectfbwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qdirectfbwindow.h"
6#include "qdirectfbinput.h"
7#include "qdirectfbscreen.h"
8
9#include <qpa/qwindowsysteminterface.h>
10
11#include <directfb.h>
12
14
16 : QPlatformWindow(tlw), m_inputHandler(inputhandler)
17{
18}
19
21{
23
24 DFBDisplayLayerConfig layerConfig;
25 IDirectFBDisplayLayer *layer;
26
28 layer->GetConfiguration(layer, &layerConfig);
29
30 DFBWindowDescription description;
31 memset(&description,0,sizeof(DFBWindowDescription));
32
33 if (window()->type() == Qt::Desktop) {
34 QRect fullscreenRect(QPoint(), screen()->availableGeometry().size());
35 window()->setGeometry(fullscreenRect);
36
37 DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
38 if (result != DFB_OK)
39 DirectFBError("QDirectFbWindow: failed to create window", result);
40
41 } else {
42 description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS
43 |DWDESC_OPTIONS
44 |DWDESC_CAPS);
45 description.width = qMax(1, window()->width());
46 description.height = qMax(1, window()->height());
47 description.posx = window()->x();
48 description.posy = window()->y();
49
50 if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED)
51 description.surface_caps = DSCAPS_PREMULTIPLIED;
52 description.pixelformat = layerConfig.pixelformat;
53
54 description.options = DFBWindowOptions(DWOP_ALPHACHANNEL);
55 description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL);
56
57
58 DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
59 if (result != DFB_OK)
60 DirectFBError("QDirectFbWindow: failed to create window", result);
61
62 m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
64 }
65}
66
72
74{
76 m_dfbWindow->SetBounds(m_dfbWindow.data(), rect.x(),rect.y(),
77 rect.width(), rect.height());
78}
79
81{
82 const quint8 windowOpacity = quint8(level * 0xff);
83 m_dfbWindow->SetOpacity(m_dfbWindow.data(), windowOpacity);
84}
85
87{
88 if (window()->type() != Qt::Desktop) {
89 if (visible) {
90 int x = geometry().x();
91 int y = geometry().y();
92 m_dfbWindow->MoveTo(m_dfbWindow.data(), x, y);
93 } else {
94 QDirectFBPointer<IDirectFBDisplayLayer> displayLayer;
95 QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(), DLID_PRIMARY, displayLayer.outPtr());
96
97 DFBDisplayLayerConfig config;
98 displayLayer->GetConfiguration(displayLayer.data(), &config);
99 m_dfbWindow->MoveTo(m_dfbWindow.data(), config. width + 1, config.height + 1);
100 }
101
102 if (window()->isTopLevel() && visible)
104 }
105}
106
108{
109 switch (flags & Qt::WindowType_Mask) {
110 case Qt::ToolTip: {
111 DFBWindowOptions options;
112 m_dfbWindow->GetOptions(m_dfbWindow.data(), &options);
113 options = DFBWindowOptions(options | DWOP_GHOST);
114 m_dfbWindow->SetOptions(m_dfbWindow.data(), options);
115 break; }
116 default:
117 break;
118 }
119
120 m_dfbWindow->SetStackingClass(m_dfbWindow.data(), flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE);
121}
122
124{
125 if (window()->type() != Qt::Desktop)
126 m_dfbWindow->RaiseToTop(m_dfbWindow.data());
127}
128
130{
131 if (window()->type() != Qt::Desktop)
132 m_dfbWindow->LowerToBottom(m_dfbWindow.data());
133}
134
136{
137 DFBWindowID id;
138 m_dfbWindow->GetID(m_dfbWindow.data(), &id);
139 return WId(id);
140}
141
143{
144 DFBResult res;
145
146 if (grab)
147 res = m_dfbWindow->GrabKeyboard(m_dfbWindow.data());
148 else
149 res = m_dfbWindow->UngrabKeyboard(m_dfbWindow.data());
150
151 return res == DFB_OK;
152}
153
155{
156 DFBResult res;
157
158 if (grab)
159 res = m_dfbWindow->GrabPointer(m_dfbWindow.data());
160 else
161 res = m_dfbWindow->UngrabPointer(m_dfbWindow.data());
162
163 return res == DFB_OK;
164}
165
166IDirectFBWindow *QDirectFbWindow::dfbWindow() const
167{
168 return m_dfbWindow.data();
169}
170
172{
173 if (!m_dfbSurface) {
174 DFBResult res = m_dfbWindow->GetSurface(m_dfbWindow.data(), m_dfbSurface.outPtr());
175 if (res != DFB_OK)
176 DirectFBError(QDFB_PRETTY, res);
177 }
178
179 return m_dfbSurface.data();
180}
181
static IDirectFB * dfbInterface()
void removeWindow(IDirectFBWindow *window)
void addWindow(IDirectFBWindow *window, QWindow *platformWindow)
IDirectFBDisplayLayer * dfbLayer() const
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
QDirectFbInput * m_inputHandler
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
~QDirectFbWindow() override
QDirectFBPointer< IDirectFBSurface > m_dfbSurface
QDirectFbWindow(QWindow *tlw, QDirectFbInput *inputhandler)
bool setKeyboardGrabEnabled(bool grab) override
QDirectFBPointer< IDirectFBWindow > m_dfbWindow
void setOpacity(qreal level) override
Reimplement to be able to let Qt set the opacity level of a window.
bool setMouseGrabEnabled(bool grab) override
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
IDirectFBWindow * dfbWindow() const
virtual void createDirectFBWindow()
IDirectFBSurface * dfbSurface()
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
The QPlatformWindow class provides an abstraction for top-level windows.
virtual void setVisible(bool visible)
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
QPlatformScreen * screen() const override
Returns the platform screen handle corresponding to this platform window, or null if the window is no...
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or resized using the QWindow API.
virtual QRect geometry() const
Returns the current geometry of a window.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
T * data() const noexcept
Returns the value of the pointer referenced by this object.
\inmodule QtGui
Definition qwindow.h:63
int x
the x position of the window's geometry
Definition qwindow.h:80
int y
the y position of the window's geometry
Definition qwindow.h:81
void setGeometry(int posx, int posy, int w, int h)
Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx,...
Definition qwindow.cpp:1802
rect
[4]
Combined button and popup list for selecting options.
@ Desktop
Definition qnamespace.h:215
@ ToolTip
Definition qnamespace.h:213
@ WindowType_Mask
Definition qnamespace.h:220
@ WindowStaysOnTopHint
Definition qnamespace.h:233
QDirectFbScreen * toDfbScreen(QWindow *window)
#define QDFB_PRETTY
EGLConfig config
EGLOutputLayerEXT layer
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLint level
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint id
[7]
GLint GLsizei width
GLenum type
GLbitfield flags
GLint y
GLuint res
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
double qreal
Definition qtypes.h:187
unsigned char quint8
Definition qtypes.h:46