KWin
Loading...
Searching...
No Matches
expoarea.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "expoarea.h"
8#include "virtualdesktops.h"
9#include "workspace.h"
10
11namespace KWin
12{
13
14ExpoArea::ExpoArea(QObject *parent)
15 : QObject(parent)
16{
17}
18
19qreal ExpoArea::x() const
20{
21 return m_rect.x();
22}
23
24qreal ExpoArea::y() const
25{
26 return m_rect.y();
27}
28
29qreal ExpoArea::width() const
30{
31 return m_rect.width();
32}
33
34qreal ExpoArea::height() const
35{
36 return m_rect.height();
37}
38
40{
41 return m_screen;
42}
43
45{
46 if (m_screen != screen) {
47 if (m_screen) {
48 disconnect(m_screen, &Output::geometryChanged, this, &ExpoArea::update);
49 }
50 m_screen = screen;
51 if (m_screen) {
52 connect(m_screen, &Output::geometryChanged, this, &ExpoArea::update);
53 }
54 update();
55 Q_EMIT screenChanged();
56 }
57}
58
59void ExpoArea::update()
60{
61 if (!m_screen) {
62 return;
63 }
64 const QRectF oldRect = m_rect;
65
66 m_rect = workspace()->clientArea(MaximizeArea, m_screen, VirtualDesktopManager::self()->currentDesktop());
67
68 // Map the area to the output local coordinates.
69 m_rect.translate(-m_screen->geometry().topLeft());
70
71 if (oldRect.x() != m_rect.x()) {
72 Q_EMIT xChanged();
73 }
74 if (oldRect.y() != m_rect.y()) {
75 Q_EMIT yChanged();
76 }
77 if (oldRect.width() != m_rect.width()) {
78 Q_EMIT widthChanged();
79 }
80 if (oldRect.height() != m_rect.height()) {
81 Q_EMIT heightChanged();
82 }
83}
84
85} // namespace KWin
86
87#include "moc_expoarea.cpp"
KWin::Output * screen
Definition expoarea.h:17
ExpoArea(QObject *parent=nullptr)
Definition expoarea.cpp:14
void widthChanged()
void heightChanged()
void setScreen(Output *screen)
Definition expoarea.cpp:44
void screenChanged()
void geometryChanged()
QRect geometry
Definition output.h:134
QRectF clientArea(clientAreaOption, const Output *output, const VirtualDesktop *desktop) const
@ MaximizeArea
Definition globals.h:51
Workspace * workspace()
Definition workspace.h:830