summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2017-05-02 18:07:08 +0100
committerDavid Edmundson <[email protected]>2017-05-02 18:07:08 +0100
commit1ac226792ae26e78b01b5790fecd2148188c35d3 (patch)
tree21cfbb7dc294ba8b18d05ccb502a367db5210406
parenta76dcadb03813a19792add450faadfc10f6c1c97 (diff)
Get output size with output-geometry() rather than mode size directly
Summary: We can use output->geometry to get the current mode size with transform applied simplifying a bunch of code, whilst being currently exactly the same code. This also applies the is->horizontal ? width : height to the displaySwitch button. Fixing a bug if you had a rotated laptop monitor then pressed the display switch button then it would be using the wrong geometry. ---- Real reason for this patch is that if I make geometry() the definitive call for getting output size with transformations I can then do all the scaling support in a simple tidy one-line edit. Reviewers: #plasma, sebas Reviewed By: #plasma, sebas Subscribers: sebas, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D5659
-rw-r--r--kded/generator.cpp36
1 files changed, 7 insertions, 29 deletions
diff --git a/kded/generator.cpp b/kded/generator.cpp
index b00fc43..45710ff 100644
--- a/kded/generator.cpp
+++ b/kded/generator.cpp
@@ -202,7 +202,7 @@ KScreen::ConfigPtr Generator::displaySwitch(DisplaySwitchAction action)
external->setCurrentModeId(extMode->id());
Q_ASSERT(external->currentMode()); // we must have a mode now
- const QSize size = external->currentMode()->size();
+ const QSize size = external->geometry().size();
embedded->setPos(QPoint(size.width(), 0));
embedded->setEnabled(true);
embedded->setPrimary(true);
@@ -248,7 +248,7 @@ KScreen::ConfigPtr Generator::displaySwitch(DisplaySwitchAction action)
Q_ASSERT(embedded->currentMode()); // we must have a mode now
- const QSize size = embedded->currentMode()->size();
+ const QSize size = embedded->geometry().size();
external->setPos(QPoint(size.width(), 0));
external->setEnabled(true);
external->setPrimary(false);
@@ -424,12 +424,7 @@ void Generator::laptop(KScreen::OutputList &connectedOutputs)
Q_ASSERT(embeddedMode);
embedded->setCurrentModeId(embeddedMode->id());
- int globalWidth;
- if (embedded->isHorizontal()) {
- globalWidth = embedded->currentMode()->size().width();
- } else {
- globalWidth = embedded->currentMode()->size().height();
- }
+ int globalWidth = embedded->geometry().width();
KScreen::OutputPtr biggest = biggestOutput(connectedOutputs);
Q_ASSERT(biggest);
connectedOutputs.remove(biggest->id());
@@ -440,11 +435,7 @@ void Generator::laptop(KScreen::OutputList &connectedOutputs)
const KScreen::ModePtr mode = bestModeForOutput(biggest);
biggest->setCurrentModeId(mode->id());
- if (biggest->isHorizontal()) {
- globalWidth += biggest->currentMode()->size().width();
- } else {
- globalWidth += biggest->currentMode()->size().height();
- }
+ globalWidth += biggest->geometry().width();
Q_FOREACH(KScreen::OutputPtr output, connectedOutputs) {
output->setEnabled(true);
output->setPrimary(false);
@@ -453,11 +444,7 @@ void Generator::laptop(KScreen::OutputList &connectedOutputs)
Q_ASSERT(mode);
output->setCurrentModeId(mode->id());
- if (output->isHorizontal()) {
- globalWidth += output->currentMode()->size().width();
- } else {
- globalWidth += output->currentMode()->size().height();
- }
+ globalWidth += output->geometry().width();
}
if (isDocked()) {
@@ -487,12 +474,7 @@ void Generator::extendToRight(KScreen::OutputList &connectedOutputs)
Q_ASSERT(mode);
biggest->setCurrentModeId(mode->id());
- int globalWidth;
- if (biggest->isHorizontal()) {
- globalWidth = biggest->currentMode()->size().width();
- } else {
- globalWidth = biggest->currentMode()->size().height();
- }
+ int globalWidth = biggest->geometry().width();
Q_FOREACH(KScreen::OutputPtr output, connectedOutputs) {
output->setEnabled(true);
@@ -502,11 +484,7 @@ void Generator::extendToRight(KScreen::OutputList &connectedOutputs)
Q_ASSERT(mode);
output->setCurrentModeId(mode->id());
- if (output->isHorizontal()) {
- globalWidth += output->currentMode()->size().width();
- } else {
- globalWidth += output->currentMode()->size().height();
- }
+ globalWidth += output->geometry().width();
}
}