File indexing completed on 2024-07-14 05:21:36

0001 /*
0002     SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "trackedviewinfo.h"
0007 
0008 //local
0009 #include "windowstracker.h"
0010 #include "../schemecolors.h"
0011 #include "../../view/view.h"
0012 
0013 
0014 namespace Latte {
0015 namespace WindowSystem {
0016 namespace Tracker {
0017 
0018 
0019 TrackedViewInfo::TrackedViewInfo(Tracker::Windows *tracker, Latte::View *view)
0020     : TrackedGeneralInfo(tracker) ,
0021       m_view(view)
0022 {
0023     m_activities = m_view->activities();
0024 
0025     connect(m_view, &Latte::View::activitiesChanged, this, [&]() {
0026         m_activities = m_view->activities();
0027         updateTrackingCurrentActivity();
0028     });
0029 }
0030 
0031 TrackedViewInfo::~TrackedViewInfo()
0032 {
0033 }
0034 
0035 bool TrackedViewInfo::activeWindowTouching() const
0036 {
0037     return m_activeWindowTouching;
0038 }
0039 
0040 void TrackedViewInfo::setActiveWindowTouching(bool touching)
0041 {
0042     if (m_activeWindowTouching == touching) {
0043         return;
0044     }
0045 
0046     m_activeWindowTouching = touching;
0047 }
0048 
0049 bool TrackedViewInfo::existsWindowTouching() const
0050 {
0051     return m_existsWindowTouching;
0052 }
0053 
0054 void TrackedViewInfo::setExistsWindowTouching(bool touching)
0055 {
0056     if (m_existsWindowTouching == touching) {
0057         return;
0058     }
0059 
0060     m_existsWindowTouching = touching;
0061 }
0062 
0063 bool TrackedViewInfo::activeWindowTouchingEdge() const
0064 {
0065     return m_activeWindowTouchingEdge;
0066 }
0067 
0068 void TrackedViewInfo::setActiveWindowTouchingEdge(bool touching)
0069 {
0070     if (m_activeWindowTouchingEdge == touching) {
0071         return;
0072     }
0073 
0074     m_activeWindowTouchingEdge = touching;
0075 }
0076 
0077 bool TrackedViewInfo::existsWindowTouchingEdge() const
0078 {
0079     return m_existsWindowTouchingEdge;
0080 }
0081 
0082 void TrackedViewInfo::setExistsWindowTouchingEdge(bool touching)
0083 {
0084     if (m_existsWindowTouchingEdge == touching) {
0085         return;
0086     }
0087 
0088     m_existsWindowTouchingEdge = touching;
0089 }
0090 
0091 bool TrackedViewInfo::isTouchingBusyVerticalView() const
0092 {
0093     return m_isTouchingBusyVerticalView;
0094 }
0095 
0096 void TrackedViewInfo::setIsTouchingBusyVerticalView(bool touching)
0097 {
0098     if (m_isTouchingBusyVerticalView == touching) {
0099         return;
0100     }
0101 
0102     m_isTouchingBusyVerticalView = touching;
0103 }
0104 
0105 QRect TrackedViewInfo::screenGeometry() const
0106 {
0107     return m_screenGeometry;
0108 }
0109 
0110 void TrackedViewInfo::setScreenGeometry(QRect geometry)
0111 {
0112     if (m_screenGeometry == geometry) {
0113         return;
0114     }
0115 
0116     m_screenGeometry = geometry;
0117 }
0118 
0119 SchemeColors *TrackedViewInfo::touchingWindowScheme() const
0120 {
0121     return m_touchingWindowScheme;
0122 }
0123 
0124 void TrackedViewInfo::setTouchingWindowScheme(SchemeColors *scheme)
0125 {
0126     if (m_touchingWindowScheme == scheme) {
0127         return;
0128     }
0129 
0130     m_touchingWindowScheme = scheme;
0131 }
0132 
0133 Latte::View *TrackedViewInfo::view() const
0134 {
0135     return m_view;
0136 }
0137 
0138 bool TrackedViewInfo::isTracking(const WindowInfoWrap &winfo) const
0139 {   
0140     return  TrackedGeneralInfo::isTracking(winfo)
0141             && m_screenGeometry.intersects(winfo.geometry());
0142 }
0143 
0144 }
0145 }
0146 }