File indexing completed on 2024-11-10 04:57:05

0001 /*
0002     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "expoarea.h"
0008 #include "virtualdesktops.h"
0009 #include "workspace.h"
0010 
0011 namespace KWin
0012 {
0013 
0014 ExpoArea::ExpoArea(QObject *parent)
0015     : QObject(parent)
0016 {
0017 }
0018 
0019 qreal ExpoArea::x() const
0020 {
0021     return m_rect.x();
0022 }
0023 
0024 qreal ExpoArea::y() const
0025 {
0026     return m_rect.y();
0027 }
0028 
0029 qreal ExpoArea::width() const
0030 {
0031     return m_rect.width();
0032 }
0033 
0034 qreal ExpoArea::height() const
0035 {
0036     return m_rect.height();
0037 }
0038 
0039 Output *ExpoArea::screen() const
0040 {
0041     return m_screen;
0042 }
0043 
0044 void ExpoArea::setScreen(Output *screen)
0045 {
0046     if (m_screen != screen) {
0047         if (m_screen) {
0048             disconnect(m_screen, &Output::geometryChanged, this, &ExpoArea::update);
0049         }
0050         m_screen = screen;
0051         if (m_screen) {
0052             connect(m_screen, &Output::geometryChanged, this, &ExpoArea::update);
0053         }
0054         update();
0055         Q_EMIT screenChanged();
0056     }
0057 }
0058 
0059 void ExpoArea::update()
0060 {
0061     if (!m_screen) {
0062         return;
0063     }
0064     const QRectF oldRect = m_rect;
0065 
0066     m_rect = workspace()->clientArea(MaximizeArea, m_screen, VirtualDesktopManager::self()->currentDesktop());
0067 
0068     // Map the area to the output local coordinates.
0069     m_rect.translate(-m_screen->geometry().topLeft());
0070 
0071     if (oldRect.x() != m_rect.x()) {
0072         Q_EMIT xChanged();
0073     }
0074     if (oldRect.y() != m_rect.y()) {
0075         Q_EMIT yChanged();
0076     }
0077     if (oldRect.width() != m_rect.width()) {
0078         Q_EMIT widthChanged();
0079     }
0080     if (oldRect.height() != m_rect.height()) {
0081         Q_EMIT heightChanged();
0082     }
0083 }
0084 
0085 } // namespace KWin
0086 
0087 #include "moc_expoarea.cpp"