Changeset View
Changeset View
Standalone View
Standalone View
kded/osdmanager.cpp
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 120 | Q_FOREACH (const KScreen::OutputPtr &output, config->outputs()) { | |||
---|---|---|---|---|---|
128 | } | 128 | } | ||
129 | osd->showGenericOsd(icon, text); | 129 | osd->showGenericOsd(icon, text); | ||
130 | } | 130 | } | ||
131 | m_cleanupTimer->start(); | 131 | m_cleanupTimer->start(); | ||
132 | } | 132 | } | ||
133 | ); | 133 | ); | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | OsdAction *OsdManager::showActionSelector() | 136 | OsdAction *OsdManager::showActionSelector(bool lidIsOpen) | ||
137 | { | 137 | { | ||
138 | hideOsd(); | 138 | hideOsd(); | ||
139 | 139 | | |||
140 | OsdActionImpl *action = new OsdActionImpl(this); | 140 | OsdActionImpl *action = new OsdActionImpl(this); | ||
141 | connect(action, &OsdActionImpl::selected, | 141 | connect(action, &OsdActionImpl::selected, | ||
142 | this, [this]() { | 142 | this, [this]() { | ||
143 | for (auto osd : qAsConst(m_osds)) { | 143 | for (auto osd : qAsConst(m_osds)) { | ||
144 | osd->hideOsd(); | 144 | osd->hideOsd(); | ||
145 | } | 145 | } | ||
146 | }); | 146 | }); | ||
147 | connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, | 147 | connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, | ||
148 | this, [this, action](const KScreen::ConfigOperation *op) { | 148 | this, [this, action, lidIsOpen](const KScreen::ConfigOperation *op) { | ||
149 | if (op->hasError()) { | 149 | if (op->hasError()) { | ||
150 | qCWarning(KSCREEN_KDED) << op->errorString(); | 150 | qCWarning(KSCREEN_KDED) << op->errorString(); | ||
151 | return; | 151 | return; | ||
152 | } | 152 | } | ||
153 | 153 | | |||
154 | // Show selector on alll enabled screens | 154 | // Show selector on alll enabled screens | ||
155 | const auto outputs = op->config()->outputs(); | 155 | const auto outputs = op->config()->outputs(); | ||
156 | KScreen::OutputPtr osdOutput; | 156 | KScreen::OutputPtr osdOutput; | ||
157 | for (const auto &output : outputs) { | 157 | for (const auto &output : outputs) { | ||
158 | if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) { | 158 | if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) { | ||
159 | continue; | 159 | continue; | ||
160 | } | 160 | } | ||
161 | 161 | | |||
162 | // Prefer laptop screen | 162 | // Prefer laptop screen | ||
163 | if (output->type() == KScreen::Output::Panel) { | 163 | if ((output->type() == KScreen::Output::Panel) && lidIsOpen) { | ||
164 | osdOutput = output; | 164 | osdOutput = output; | ||
165 | break; | 165 | break; | ||
166 | } | 166 | } | ||
167 | 167 | | |||
168 | // Fallback to primary | 168 | // Fallback to primary | ||
169 | if (output->isPrimary()) { | 169 | if (output->isPrimary() && lidIsOpen) { | ||
170 | osdOutput = output; | 170 | osdOutput = output; | ||
171 | break; | 171 | break; | ||
172 | } | 172 | } | ||
173 | } | 173 | } | ||
174 | // no laptop or primary screen, just take the first usable one | 174 | | ||
175 | // no laptop (with open lid) or primary screen (with open lid), just take the first usable one (with open lid) | ||||
176 | if (!osdOutput) { | ||||
177 | for (const auto &output : outputs) { | ||||
178 | if ( (output->isConnected() && output->isEnabled() && output->currentMode()) | ||||
179 | && ( ( (output->type() == KScreen::Output::Panel) && lidIsOpen) | ||||
180 | || (output->type() != KScreen::Output::Panel) | ||||
181 | ) | ||||
182 | ) { | ||||
183 | osdOutput = output; | ||||
184 | break; | ||||
185 | } | ||||
186 | } | ||||
187 | } | ||||
188 | | ||||
189 | // nothing up to now, just take the first usable one, even with closed lid | ||||
175 | if (!osdOutput) { | 190 | if (!osdOutput) { | ||
176 | for (const auto &output : outputs) { | 191 | for (const auto &output : outputs) { | ||
177 | if (output->isConnected() && output->isEnabled() && output->currentMode()) { | 192 | if (output->isConnected() && output->isEnabled() && output->currentMode()) { | ||
178 | osdOutput = output; | 193 | osdOutput = output; | ||
179 | break; | 194 | break; | ||
180 | } | 195 | } | ||
181 | } | 196 | } | ||
182 | } | 197 | } | ||
Show All 26 Lines |