Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
9
10#include <qpa/qwindowsysteminterface.h>
11
12#include <directfb.h>
13
15
17 : QPlatformWindow(tlw), m_inputHandler(inputhandler)
18{
19}
20
22{
23 Q_ASSERT(!m_dfbWindow.data());
24
25 DFBDisplayLayerConfig layerConfig;
26 IDirectFBDisplayLayer *layer;
27
28 layer = toDfbScreen(window())->dfbLayer();
29 layer->GetConfiguration(layer, &layerConfig);
30
31 DFBWindowDescription description;
32 memset(&description,0,sizeof(DFBWindowDescription));
33
34 description.flags = DFBWindowDescriptionFlags(DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS
35 |DWDESC_OPTIONS
36 |DWDESC_CAPS);
37 description.width = qMax(1, window()->width());
38 description.height = qMax(1, window()->height());
39 description.posx = window()->x();
40 description.posy = window()->y();
41
42 if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED)
43 description.surface_caps = DSCAPS_PREMULTIPLIED;
44 description.pixelformat = layerConfig.pixelformat;
45
46 description.options = DFBWindowOptions(DWOP_ALPHACHANNEL);
47 description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL);
48
49
50 DFBResult result = layer->CreateWindow(layer, &description, m_dfbWindow.outPtr());
51 if (result != DFB_OK)
52 DirectFBError("QDirectFbWindow: failed to create window", result);
53
54 m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
55 m_inputHandler->addWindow(m_dfbWindow.data(), window());
56}
57
59{
60 m_inputHandler->removeWindow(m_dfbWindow.data());
61 m_dfbWindow->Destroy(m_dfbWindow.data());
62}
63
64void QDirectFbWindow::setGeometry(const QRect &rect)
65{
66 QPlatformWindow::setGeometry(rect);
67 m_dfbWindow->SetBounds(m_dfbWindow.data(), rect.x(),rect.y(),
68 rect.width(), rect.height());
69}
70
71void QDirectFbWindow::setOpacity(qreal level)
72{
73 const quint8 windowOpacity = quint8(level * 0xff);
74 m_dfbWindow->SetOpacity(m_dfbWindow.data(), windowOpacity);
75}
76
77void QDirectFbWindow::setVisible(bool visible)
78{
79 if (visible) {
80 int x = geometry().x();
81 int y = geometry().y();
82 m_dfbWindow->MoveTo(m_dfbWindow.data(), x, y);
83 } else {
84 QDirectFBPointer<IDirectFBDisplayLayer> displayLayer;
85 QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(), DLID_PRIMARY, displayLayer.outPtr());
86
87 DFBDisplayLayerConfig config;
88 displayLayer->GetConfiguration(displayLayer.data(), &config);
89 m_dfbWindow->MoveTo(m_dfbWindow.data(), config. width + 1, config.height + 1);
90 }
91
92 if (window()->isTopLevel() && visible)
93 QPlatformWindow::setVisible(visible);
94}
95
96void QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags)
97{
98 switch (flags & Qt::WindowType_Mask) {
99 case Qt::ToolTip: {
100 DFBWindowOptions options;
101 m_dfbWindow->GetOptions(m_dfbWindow.data(), &options);
102 options = DFBWindowOptions(options | DWOP_GHOST);
103 m_dfbWindow->SetOptions(m_dfbWindow.data(), options);
104 break; }
105 default:
106 break;
107 }
108
109 m_dfbWindow->SetStackingClass(m_dfbWindow.data(), flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE);
110}
111
113{
114 m_dfbWindow->RaiseToTop(m_dfbWindow.data());
115}
116
118{
119 m_dfbWindow->LowerToBottom(m_dfbWindow.data());
120}
121
123{
124 DFBWindowID id;
125 m_dfbWindow->GetID(m_dfbWindow.data(), &id);
126 return WId(id);
127}
128
130{
131 DFBResult res;
132
133 if (grab)
134 res = m_dfbWindow->GrabKeyboard(m_dfbWindow.data());
135 else
136 res = m_dfbWindow->UngrabKeyboard(m_dfbWindow.data());
137
138 return res == DFB_OK;
139}
140
142{
143 DFBResult res;
144
145 if (grab)
146 res = m_dfbWindow->GrabPointer(m_dfbWindow.data());
147 else
148 res = m_dfbWindow->UngrabPointer(m_dfbWindow.data());
149
150 return res == DFB_OK;
151}
152
154{
155 return m_dfbWindow.data();
156}
157
159{
160 if (!m_dfbSurface) {
161 DFBResult res = m_dfbWindow->GetSurface(m_dfbWindow.data(), m_dfbSurface.outPtr());
162 if (res != DFB_OK)
163 DirectFBError(QDFB_PRETTY, res);
164 }
165
166 return m_dfbSurface.data();
167}
168
169QT_END_NAMESPACE
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.
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
bool setKeyboardGrabEnabled(bool grab) override
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.
\inmodule QtGui
Definition qwindow.h:63
#define QDFB_PRETTY