Changeset View
Changeset View
Standalone View
Standalone View
src/output.cpp
Show All 34 Lines | |||||
35 | { | 35 | { | ||
36 | public: | 36 | public: | ||
37 | Private(): | 37 | Private(): | ||
38 | id(0), | 38 | id(0), | ||
39 | type(Unknown), | 39 | type(Unknown), | ||
40 | replicationSource(0), | 40 | replicationSource(0), | ||
41 | rotation(None), | 41 | rotation(None), | ||
42 | scale(1.0), | 42 | scale(1.0), | ||
43 | logicalSize(QSizeF()), | ||||
43 | connected(false), | 44 | connected(false), | ||
44 | enabled(false), | 45 | enabled(false), | ||
45 | primary(false), | 46 | primary(false), | ||
46 | edid(nullptr) | 47 | edid(nullptr) | ||
47 | {} | 48 | {} | ||
48 | 49 | | |||
49 | Private(const Private &other): | 50 | Private(const Private &other): | ||
50 | id(other.id), | 51 | id(other.id), | ||
Show All 36 Lines | |||||
87 | QString currentMode; | 88 | QString currentMode; | ||
88 | QString preferredMode; | 89 | QString preferredMode; | ||
89 | QStringList preferredModes; | 90 | QStringList preferredModes; | ||
90 | QSize sizeMm; | 91 | QSize sizeMm; | ||
91 | QPoint pos; | 92 | QPoint pos; | ||
92 | QSize size; | 93 | QSize size; | ||
93 | Rotation rotation; | 94 | Rotation rotation; | ||
94 | qreal scale; | 95 | qreal scale; | ||
96 | QSizeF logicalSize; | ||||
95 | bool connected; | 97 | bool connected; | ||
96 | bool enabled; | 98 | bool enabled; | ||
97 | bool primary; | 99 | bool primary; | ||
98 | bool followPreferredMode = false; | 100 | bool followPreferredMode = false; | ||
99 | 101 | | |||
100 | QScopedPointer<Edid> edid; | 102 | QScopedPointer<Edid> edid; | ||
101 | }; | 103 | }; | ||
102 | 104 | | |||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | |||||
420 | { | 422 | { | ||
421 | if (qFuzzyCompare(d->scale, factor)) { | 423 | if (qFuzzyCompare(d->scale, factor)) { | ||
422 | return; | 424 | return; | ||
423 | } | 425 | } | ||
424 | d->scale = factor; | 426 | d->scale = factor; | ||
425 | emit scaleChanged(); | 427 | emit scaleChanged(); | ||
426 | } | 428 | } | ||
427 | 429 | | |||
430 | QSizeF Output::logicalSize() const | ||||
431 | { | ||||
432 | if (d->logicalSize.isValid()) { | ||||
433 | return d->logicalSize; | ||||
434 | } | ||||
435 | | ||||
436 | QSizeF size = enforcedModeSize(); | ||||
437 | if (!size.isValid()) { | ||||
438 | return QSizeF(); | ||||
439 | } | ||||
440 | size = size / d->scale; | ||||
441 | | ||||
442 | // We can't use d->size, because d->size does not reflect the actual rotation() set by caller. | ||||
443 | // It is only updated when we get update from KScreen, but not when user changes mode or | ||||
444 | // rotation manually. | ||||
445 | | ||||
446 | if (!isHorizontal()) { | ||||
447 | size = size.transposed(); | ||||
448 | } | ||||
449 | return size; | ||||
450 | } | ||||
451 | | ||||
452 | QSizeF Output::explicitLogicalSize() const | ||||
453 | { | ||||
454 | return d->logicalSize; | ||||
455 | } | ||||
456 | | ||||
457 | void Output::setLogicalSize(const QSizeF &size) | ||||
458 | { | ||||
459 | if (qFuzzyCompare(d->logicalSize.width(), size.width()) | ||||
460 | && qFuzzyCompare(d->logicalSize.height(), size.height())) { | ||||
461 | return; | ||||
462 | } | ||||
463 | d->logicalSize = size; | ||||
464 | Q_EMIT logicalSizeChanged(); | ||||
465 | } | ||||
466 | | ||||
428 | bool Output::isConnected() const | 467 | bool Output::isConnected() const | ||
429 | { | 468 | { | ||
430 | return d->connected; | 469 | return d->connected; | ||
431 | } | 470 | } | ||
432 | 471 | | |||
433 | void Output::setConnected(bool connected) | 472 | void Output::setConnected(bool connected) | ||
434 | { | 473 | { | ||
435 | if (d->connected == connected) { | 474 | if (d->connected == connected) { | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 587 | { | |||
553 | } else if (d->modeList.count() > 0) { | 592 | } else if (d->modeList.count() > 0) { | ||
554 | return d->modeList.first()->size(); | 593 | return d->modeList.first()->size(); | ||
555 | } | 594 | } | ||
556 | return QSize(); | 595 | return QSize(); | ||
557 | } | 596 | } | ||
558 | 597 | | |||
559 | QRect Output::geometry() const | 598 | QRect Output::geometry() const | ||
560 | { | 599 | { | ||
561 | QSize size = enforcedModeSize(); | 600 | QSize size = logicalSize().toSize(); | ||
562 | if (!size.isValid()) { | 601 | if (!size.isValid()) { | ||
563 | return QRect(); | 602 | return QRect(); | ||
564 | } | 603 | } | ||
565 | size = size / d->scale; | | |||
566 | | ||||
567 | // We can't use QRect(d->pos, d->size), because d->size does not reflect the | | |||
568 | // actual rotation() set by caller, it's only updated when we get update from | | |||
569 | // KScreen, but not when user changes mode or rotation manually | | |||
570 | | ||||
571 | if (!isHorizontal()) { | | |||
572 | size = size.transposed(); | | |||
573 | } | | |||
574 | 604 | | |||
575 | return QRect(d->pos, size); | 605 | return QRect(d->pos, size); | ||
576 | } | 606 | } | ||
577 | 607 | | |||
578 | void Output::apply(const OutputPtr& other) | 608 | void Output::apply(const OutputPtr& other) | ||
579 | { | 609 | { | ||
580 | typedef void (KScreen::Output::*ChangeSignal)(); | 610 | typedef void (KScreen::Output::*ChangeSignal)(); | ||
581 | QList<ChangeSignal> changes; | 611 | QList<ChangeSignal> changes; | ||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |