Commit 92a512f0 authored by Carlos De Maine's avatar Carlos De Maine 🎱
Browse files

Add an option to position a secondary display above primary display.

A common setup is to have a diplay/projector directly above a laptop.  This adds an option to the OSD for this.

BUG: 439410
parent fff84af3
Pipeline #161849 passed with stage
in 1 minute and 53 seconds
......@@ -299,6 +299,11 @@ void KScreenDaemon::applyOsdAction(KScreen::OsdAction::Action action)
qCDebug(KSCREEN_KDED) << "OSD: extend right";
doApplyConfig(Generator::self()->displaySwitch(Generator::ExtendToRight));
return;
case KScreen::OsdAction::ExtendAbove:
qCDebug(KSCREEN_KDED) << "OSD: extend above";
doApplyConfig(Generator::self()->displaySwitch(Generator::ExtendAbove));
return;
case KScreen::OsdAction::Clone:
qCDebug(KSCREEN_KDED) << "OSD: clone";
doApplyConfig(Generator::self()->displaySwitch(Generator::Clone));
......
......@@ -237,6 +237,20 @@ KScreen::ConfigPtr Generator::displaySwitch(DisplaySwitchAction action)
return config;
}
case Generator::ExtendAbove: {
qCDebug(KSCREEN_KDED) << "Extend above";
const QSize size = embedded->geometry().size();
embedded->setPos(QPoint(0, size.height()));
embedded->setEnabled(true);
embedded->setPrimary(true);
Q_ASSERT(embedded->currentMode()); // we must have a mode now
external->setPos(QPoint(1, 0));
external->setEnabled(true);
external->setPrimary(false);
return config;
}
case Generator::None: // just return config
case Generator::Clone: // handled above
break;
......@@ -451,6 +465,34 @@ void Generator::extendToRight(KScreen::OutputList &connectedOutputs)
}
}
void Generator::extendAbove(KScreen::OutputList &connectedOutputs)
{
ASSERT_OUTPUTS(connectedOutputs);
if (connectedOutputs.isEmpty()) {
return;
}
qCDebug(KSCREEN_KDED) << "Extending above";
KScreen::OutputPtr biggest = biggestOutput(connectedOutputs);
Q_ASSERT(biggest);
connectedOutputs.remove(biggest->id());
biggest->setEnabled(true);
biggest->setPrimary(true);
biggest->setPos(QPoint(0, 0));
int globalWidth = biggest->geometry().width();
for (KScreen::OutputPtr output : qAsConst(connectedOutputs)) {
output->setEnabled(true);
output->setPrimary(false);
output->setPos(QPoint(globalWidth, 0));
globalWidth += output->geometry().width();
}
}
void Generator::initializeOutput(const KScreen::OutputPtr &output, KScreen::Config::Features features)
{
Output::GlobalConfig config = Output::readGlobal(output);
......
......@@ -28,6 +28,7 @@ public:
TurnOffEmbedded = 3,
TurnOffExternal = 4,
ExtendToRight = 5,
ExtendAbove = 6,
};
static Generator *self();
......@@ -58,6 +59,7 @@ private:
void laptop(KScreen::OutputList &connectedOutputs);
void singleOutput(KScreen::OutputList &connectedOutputs);
void extendToRight(KScreen::OutputList &connectedOutputs);
void extendAbove(KScreen::OutputList &connectedOutputs);
void initializeOutput(const KScreen::OutputPtr &output, KScreen::Config::Features features);
KScreen::ModePtr bestModeForSize(const KScreen::ModeList &modes, const QSize &size);
......
......@@ -20,7 +20,7 @@ OsdAction::OsdAction(QObject *parent)
QVector<int> OsdAction::actionOrder() const
{
return {SwitchToExternal, SwitchToInternal, Clone, ExtendLeft, ExtendRight, NoAction};
return {SwitchToExternal, SwitchToInternal, Clone, ExtendLeft, ExtendRight, ExtendAbove, NoAction};
}
QString OsdAction::actionLabel(OsdAction::Action action) const
......@@ -37,6 +37,8 @@ QString OsdAction::actionLabel(OsdAction::Action action) const
return i18nd("kscreen", "Extend to left");
case ExtendRight:
return i18nd("kscreen", "Extend to right");
case ExtendAbove:
return i18nd("kscreen", "Extend above");
case NoAction:
return i18nd("kscreen", "Leave unchanged");
}
......@@ -58,6 +60,8 @@ QString OsdAction::actionIconName(OsdAction::Action action) const
return QStringLiteral("osd-sbs-left");
case ExtendRight:
return QStringLiteral("osd-sbs-sright");
case ExtendAbove:
return QStringLiteral("osd-sbs-above");
case NoAction:
return QStringLiteral("dialog-cancel");
}
......
......@@ -26,6 +26,7 @@ public:
Clone,
ExtendLeft,
ExtendRight,
ExtendAbove,
};
Q_ENUM(Action)
......
......@@ -30,6 +30,7 @@ public:
Clone,
ExtendLeft,
ExtendRight,
ExtendAbove,
};
Q_ENUM(Action)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment