qdesktopwidget.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qdesktopwidget.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QDesktopScreenWidget::QDesktopScreenWidget(QScreen *screen, const QRect &geometry)-
6 : QWidget(nullptr, Qt::Desktop), m_screen(screen)-
7{-
8 setVisible(false);-
9 if (QWindow *winHandle = windowHandle()
QWindow *winHa...windowHandle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
10 winHandle->setScreen(screen);
never executed: winHandle->setScreen(screen);
0
11 setScreenGeometry(geometry);-
12}
never executed: end of block
0
13-
14void QDesktopScreenWidget::setScreenGeometry(const QRect &geometry)-
15{-
16 m_geometry = geometry;-
17 setGeometry(geometry);-
18}
never executed: end of block
0
19-
20int QDesktopScreenWidget::screenNumber() const-
21{-
22 const QDesktopWidgetPrivate *desktopWidgetP-
23 = static_cast<const QDesktopWidgetPrivate *>(qt_widget_private(QApplication::desktop()));-
24 return
never executed: return desktopWidgetP->screens.indexOf(const_cast<QDesktopScreenWidget *>(this));
desktopWidgetP->screens.indexOf(const_cast<QDesktopScreenWidget *>(this));
never executed: return desktopWidgetP->screens.indexOf(const_cast<QDesktopScreenWidget *>(this));
0
25}-
26-
27const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const-
28{-
29 if (__builtin_expect(!!(!widget), false)
__builtin_expe...idget), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
30 QMessageLogger(__FILE__, 77, __PRETTY_FUNCTION__).warning("QDesktopWidget::screenGeometry(): Attempt "-
31 "to get the screen geometry of a null widget");-
32 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
33 }-
34 QRect rect = QWidgetPrivate::screenGeometry(widget);-
35 if (rect.isNull()
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
36 return
never executed: return screenGeometry(screenNumber(widget));
screenGeometry(screenNumber(widget));
never executed: return screenGeometry(screenNumber(widget));
0
37 else return
never executed: return rect;
rect;
never executed: return rect;
0
38}-
39-
40const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const-
41{-
42 if (__builtin_expect(!!(!widget), false)
__builtin_expe...idget), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
43 QMessageLogger(__FILE__, 90, __PRETTY_FUNCTION__).warning("QDesktopWidget::availableGeometry(): Attempt "-
44 "to get the available geometry of a null widget");-
45 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
46 }-
47 QRect rect = QWidgetPrivate::screenGeometry(widget);-
48 if (rect.isNull()
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
49 return
never executed: return availableGeometry(screenNumber(widget));
availableGeometry(screenNumber(widget));
never executed: return availableGeometry(screenNumber(widget));
0
50 else-
51 return
never executed: return rect;
rect;
never executed: return rect;
0
52}-
53-
54QDesktopScreenWidget *QDesktopWidgetPrivate::widgetForScreen(QScreen *qScreen) const-
55{-
56 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(screens)>::type> _container_((screens)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QDesktopScreenWidget *widget = *_container_.i; _container_.control; _container_.control = 0) {-
57 if (widget->screen() == qScreen
widget->screen() == qScreenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
58 return
never executed: return widget;
widget;
never executed: return widget;
0
59 }
never executed: end of block
0
60 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
61}-
62-
63void QDesktopWidgetPrivate::_q_updateScreens()-
64{-
65 QDesktopWidget * const q = q_func();-
66 const QList<QScreen *> screenList = QGuiApplication::screens();-
67 const int targetLength = screenList.length();-
68 bool screenCountChanged = false;-
69-
70-
71-
72-
73-
74 QList<QDesktopScreenWidget *> newScreens;-
75 QList<int> changedScreens;-
76 QRegion virtualGeometry;-
77-
78 for (int i = 0; i < targetLength
i < targetLengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
79 QScreen *qScreen = screenList.at(i);-
80 const QRect screenGeometry = qScreen->geometry();-
81 QDesktopScreenWidget *screenWidget = widgetForScreen(qScreen);-
82 if (screenWidget
screenWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
83-
84 if (screenGeometry != screenWidget->screenGeometry()
screenGeometry...reenGeometry()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
85 screenWidget->setScreenGeometry(screenGeometry);-
86 changedScreens.push_back(i);-
87 }
never executed: end of block
0
88 }
never executed: end of block
else {
0
89-
90 screenWidget = new QDesktopScreenWidget(qScreen, screenGeometry);-
91 QObject::connect(qScreen, qFlagLocation("2""geometryChanged(QRect)" "\0" __FILE__ ":" "138"),-
92 q, qFlagLocation("1""_q_updateScreens()" "\0" __FILE__ ":" "139"), Qt::QueuedConnection);-
93 QObject::connect(qScreen, qFlagLocation("2""availableGeometryChanged(QRect)" "\0" __FILE__ ":" "140"),-
94 q, qFlagLocation("1""_q_availableGeometryChanged()" "\0" __FILE__ ":" "141"), Qt::QueuedConnection);-
95 QObject::connect(qScreen, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "142"),-
96 q, qFlagLocation("1""_q_updateScreens()" "\0" __FILE__ ":" "143"), Qt::QueuedConnection);-
97 screenCountChanged = true;-
98 }
never executed: end of block
0
99-
100 newScreens.push_back(screenWidget);-
101 virtualGeometry += screenGeometry;-
102 }
never executed: end of block
0
103-
104-
105 screens.swap(newScreens);-
106 ((!(screens.size() == targetLength)) ? qt_assert("screens.size() == targetLength",__FILE__,153) : qt_noop());-
107 q->setGeometry(virtualGeometry.boundingRect());-
108-
109-
110 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(newScreens)>::type> _container_((newScreens)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QDesktopScreenWidget *screen = *_container_.i; _container_.control; _container_.control = 0) {-
111 if (!screens.contains(screen)
!screens.contains(screen)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
112 delete screen;-
113 screenCountChanged = true;-
114 }
never executed: end of block
0
115 }
never executed: end of block
0
116-
117-
118 if (screenCountChanged
screenCountChangedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
119-
120-
121-
122 q->screenCountChanged(targetLength);-
123 }
never executed: end of block
0
124 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(changedScreens)>::type> _container_((changedScreens)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (int changedScreen = *_container_.i; _container_.control; _container_.control = 0)-
125 q->resized(changedScreen);
never executed: q->resized(changedScreen);
0
126}
never executed: end of block
0
127-
128void QDesktopWidgetPrivate::_q_availableGeometryChanged()-
129{-
130 QDesktopWidget * const q = q_func();-
131 if (QScreen *screen = qobject_cast<QScreen *>(q->sender())
QScreen *scree...>(q->sender())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
132 q->workAreaResized(QGuiApplication::screens().indexOf(screen));
never executed: q->workAreaResized(QGuiApplication::screens().indexOf(screen));
0
133}
never executed: end of block
0
134-
135QDesktopWidget::QDesktopWidget()-
136 : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)-
137{-
138 QDesktopWidgetPrivate * const d = d_func();-
139 setObjectName(QLatin1String("desktop"));-
140 d->_q_updateScreens();-
141 connect((static_cast<QApplication *>(QCoreApplication::instance())), qFlagLocation("2""screenAdded(QScreen*)" "\0" __FILE__ ":" "188"), this, qFlagLocation("1""_q_updateScreens()" "\0" __FILE__ ":" "188"));-
142 connect((static_cast<QApplication *>(QCoreApplication::instance())), qFlagLocation("2""primaryScreenChanged(QScreen*)" "\0" __FILE__ ":" "189"), this, qFlagLocation("2""primaryScreenChanged()" "\0" __FILE__ ":" "189"));-
143}
never executed: end of block
0
144-
145QDesktopWidget::~QDesktopWidget()-
146{-
147}-
148-
149bool QDesktopWidget::isVirtualDesktop() const-
150{-
151 return
never executed: return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
never executed: return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
0
152}-
153-
154int QDesktopWidget::primaryScreen() const-
155{-
156 return
never executed: return 0;
0;
never executed: return 0;
0
157}-
158-
159int QDesktopWidget::numScreens() const-
160{-
161 return
never executed: return qMax(QGuiApplication::screens().size(), 1);
qMax(QGuiApplication::screens().size(), 1);
never executed: return qMax(QGuiApplication::screens().size(), 1);
0
162}-
163-
164QWidget *QDesktopWidget::screen(int screen)-
165{-
166 QDesktopWidgetPrivate * const d = d_func();-
167 if (screen < 0
screen < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| screen >= d->screens.length()
screen >= d->screens.length()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
168 return
never executed: return d->screens.at(0);
d->screens.at(0);
never executed: return d->screens.at(0);
0
169 return
never executed: return d->screens.at(screen);
d->screens.at(screen);
never executed: return d->screens.at(screen);
0
170}-
171-
172const QRect QDesktopWidget::availableGeometry(int screenNo) const-
173{-
174 QList<QScreen *> screens = QGuiApplication::screens();-
175 if (screenNo == -1
screenNo == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
176 screenNo = 0;
never executed: screenNo = 0;
0
177 if (screenNo < 0
screenNo < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| screenNo >= screens.size()
screenNo >= screens.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
178 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
179 else-
180 return
never executed: return screens.at(screenNo)->availableGeometry();
screens.at(screenNo)->availableGeometry();
never executed: return screens.at(screenNo)->availableGeometry();
0
181}-
182-
183const QRect QDesktopWidget::screenGeometry(int screenNo) const-
184{-
185 QList<QScreen *> screens = QGuiApplication::screens();-
186 if (screenNo == -1
screenNo == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
187 screenNo = 0;
never executed: screenNo = 0;
0
188 if (screenNo < 0
screenNo < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| screenNo >= screens.size()
screenNo >= screens.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
189 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
190 else-
191 return
never executed: return screens.at(screenNo)->geometry();
screens.at(screenNo)->geometry();
never executed: return screens.at(screenNo)->geometry();
0
192}-
193-
194int QDesktopWidget::screenNumber(const QWidget *w) const-
195{-
196 if (!w
!wDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
197 return
never executed: return primaryScreen();
primaryScreen();
never executed: return primaryScreen();
0
198-
199 const QList<QScreen *> allScreens = QGuiApplication::screens();-
200 QList<QScreen *> screens = allScreens;-
201 if (screens.isEmpty()
screens.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
202 return
never executed: return primaryScreen();
primaryScreen();
never executed: return primaryScreen();
0
203-
204 const QWindow *winHandle = w->windowHandle();-
205 if (!winHandle
!winHandleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
206 if (const
const QWidget ...ParentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
QWidget *nativeParent = w->nativeParentWidget()
const QWidget ...ParentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
207 winHandle = nativeParent->windowHandle();
never executed: winHandle = nativeParent->windowHandle();
0
208 }
never executed: end of block
0
209-
210-
211 if (screens.count() != screens.constFirst()->virtualSiblings().count()
screens.count(...ings().count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
212-
213-
214 if (winHandle
winHandleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
215 if (const
const QScreen ...ndle->screen()Description
TRUEnever evaluated
FALSEnever evaluated
QScreen *winScreen = winHandle->screen()
const QScreen ...ndle->screen()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
216 screens = winScreen->virtualSiblings();
never executed: screens = winScreen->virtualSiblings();
0
217 }
never executed: end of block
0
218 }
never executed: end of block
0
219-
220-
221-
222 QRect frame = w->frameGeometry();-
223 if (!w->isWindow()
!w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
224 frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
never executed: frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
0
225 const QRect nativeFrame = QHighDpi::toNativePixels(frame, winHandle);-
226-
227 QScreen *widgetScreen = nullptr;-
228 int largestArea = 0;-
229 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(screens)>::type> _container_((screens)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QScreen *screen = *_container_.i; _container_.control; _container_.control = 0) {-
230 const QRect intersected = screen->handle()->geometry().intersected(nativeFrame);-
231 int area = intersected.width() * intersected.height();-
232 if (largestArea < area
largestArea < areaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
233 widgetScreen = screen;-
234 largestArea = area;-
235 }
never executed: end of block
0
236 }
never executed: end of block
0
237 return
never executed: return allScreens.indexOf(widgetScreen);
allScreens.indexOf(widgetScreen);
never executed: return allScreens.indexOf(widgetScreen);
0
238}-
239-
240int QDesktopWidget::screenNumber(const QPoint &p) const-
241{-
242 const QList<QScreen *> screens = QGuiApplication::screens();-
243 if (!screens.isEmpty()
!screens.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
244 const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings();-
245-
246 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(primaryScreens)>::type> _container_((primaryScreens)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QScreen *screen = *_container_.i; _container_.control; _container_.control = 0) {-
247 if (screen->geometry().contains(p)
screen->geometry().contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
248 return
never executed: return screens.indexOf(screen);
screens.indexOf(screen);
never executed: return screens.indexOf(screen);
0
249 }
never executed: end of block
0
250-
251-
252-
253-
254 if (screens.count() != primaryScreens.count()
screens.count(...creens.count()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
255 for (int i = 1; i < screens.size()
i < screens.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
256 if (screens[i]->geometry().contains(p)
screens[i]->ge...().contains(p)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
257 return
never executed: return i;
i;
never executed: return i;
0
258 }
never executed: end of block
0
259 }
never executed: end of block
0
260 }
never executed: end of block
0
261 return
never executed: return primaryScreen();
primaryScreen();
never executed: return primaryScreen();
0
262}-
263-
264void QDesktopWidget::resizeEvent(QResizeEvent *)-
265{-
266}-
267-
268-
269-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9