Changeset View
Changeset View
Standalone View
Standalone View
screens.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | 51 | | |||
52 | Screens::Screens(QObject *parent) | 52 | Screens::Screens(QObject *parent) | ||
53 | : QObject(parent) | 53 | : QObject(parent) | ||
54 | , m_count(0) | 54 | , m_count(0) | ||
55 | , m_current(0) | 55 | , m_current(0) | ||
56 | , m_currentFollowsMouse(false) | 56 | , m_currentFollowsMouse(false) | ||
57 | , m_changedTimer(new QTimer(this)) | 57 | , m_changedTimer(new QTimer(this)) | ||
58 | , m_orientationSensor(new OrientationSensor(this)) | 58 | , m_orientationSensor(new OrientationSensor(this)) | ||
59 | , m_maxScale(1.0) | ||||
59 | { | 60 | { | ||
60 | connect(this, &Screens::changed, this, | 61 | connect(this, &Screens::changed, this, | ||
61 | [this] { | 62 | [this] { | ||
62 | int internalIndex = -1; | 63 | int internalIndex = -1; | ||
63 | for (int i = 0; i < m_count; i++) { | 64 | for (int i = 0; i < m_count; i++) { | ||
64 | if (isInternal(i)) { | 65 | if (isInternal(i)) { | ||
65 | internalIndex = i; | 66 | internalIndex = i; | ||
66 | break; | 67 | break; | ||
Show All 33 Lines | |||||
100 | 101 | | |||
101 | float Screens::refreshRate(int screen) const | 102 | float Screens::refreshRate(int screen) const | ||
102 | { | 103 | { | ||
103 | Q_UNUSED(screen) | 104 | Q_UNUSED(screen) | ||
104 | qCWarning(KWIN_CORE, "%s::refreshRate(int screen) is a stub, please reimplement it!", metaObject()->className()); | 105 | qCWarning(KWIN_CORE, "%s::refreshRate(int screen) is a stub, please reimplement it!", metaObject()->className()); | ||
105 | return 60.0f; | 106 | return 60.0f; | ||
106 | } | 107 | } | ||
107 | 108 | | |||
109 | qreal Screens::maxScale() const | ||||
110 | { | ||||
111 | return m_maxScale; | ||||
112 | } | ||||
113 | | ||||
108 | qreal Screens::scale(int screen) const | 114 | qreal Screens::scale(int screen) const | ||
109 | { | 115 | { | ||
110 | Q_UNUSED(screen) | 116 | Q_UNUSED(screen) | ||
111 | return 1; | 117 | return 1; | ||
112 | } | 118 | } | ||
113 | 119 | | |||
114 | void Screens::reconfigure() | 120 | void Screens::reconfigure() | ||
115 | { | 121 | { | ||
116 | if (!m_config) { | 122 | if (!m_config) { | ||
117 | return; | 123 | return; | ||
118 | } | 124 | } | ||
119 | Settings settings(m_config); | 125 | Settings settings(m_config); | ||
120 | settings.read(); | 126 | settings.read(); | ||
121 | setCurrentFollowsMouse(settings.activeMouseScreen()); | 127 | setCurrentFollowsMouse(settings.activeMouseScreen()); | ||
122 | } | 128 | } | ||
123 | 129 | | |||
124 | void Screens::updateSize() | 130 | void Screens::updateSize() | ||
125 | { | 131 | { | ||
126 | QRect bounding; | 132 | QRect bounding; | ||
133 | qreal maxScale = 1.0; | ||||
127 | for (int i = 0; i < count(); ++i) { | 134 | for (int i = 0; i < count(); ++i) { | ||
128 | bounding = bounding.united(geometry(i)); | 135 | bounding = bounding.united(geometry(i)); | ||
136 | maxScale = qMax(maxScale, scale(i)); | ||||
129 | } | 137 | } | ||
130 | if (m_boundingSize != bounding.size()) { | 138 | if (m_boundingSize != bounding.size()) { | ||
131 | m_boundingSize = bounding.size(); | 139 | m_boundingSize = bounding.size(); | ||
132 | emit sizeChanged(); | 140 | emit sizeChanged(); | ||
133 | } | 141 | } | ||
142 | if (!qFuzzyCompare(m_maxScale, maxScale)) { | ||||
graesslin: qFuzzyCompare | |||||
I'm not 100% sure about this particular case. I'm comparing a cache of a previous copied float value. So arguably in the case that an output did go from 2.0000001 to 1.9999999 it would hypothetically cause more problems for us to not update the cache and emit that we changed. But also I don't intend to ever be in this case, so maybe it's best to just be consistent. Updated. davidedmundson: I'm not 100% sure about this particular case.
I'm comparing a cache of a previous copied float… | |||||
143 | m_maxScale = maxScale; | ||||
144 | emit maxScaleChanged(); | ||||
145 | } | ||||
134 | } | 146 | } | ||
135 | 147 | | |||
136 | void Screens::setCount(int count) | 148 | void Screens::setCount(int count) | ||
137 | { | 149 | { | ||
138 | if (m_count == count) { | 150 | if (m_count == count) { | ||
139 | return; | 151 | return; | ||
140 | } | 152 | } | ||
141 | const int previous = m_count; | 153 | const int previous = m_count; | ||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |
qFuzzyCompare