| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #include "qwaylandoutputmode.h" |
| 31 | #include "qwaylandoutputmode_p.h" |
| 32 | |
| 33 | /*! |
| 34 | \class QWaylandOutputMode |
| 35 | \inmodule QtWaylandCompositor |
| 36 | \since 5.8 |
| 37 | \brief The QWaylandOutputMode class holds the resolution and refresh rate of an output. |
| 38 | |
| 39 | QWaylandOutputMode holds the resolution and refresh rate of an output. |
| 40 | Resolution is expressed in pixels and refresh rate is measured in mHz. |
| 41 | |
| 42 | \sa QWaylandOutput |
| 43 | */ |
| 44 | |
| 45 | QWaylandOutputMode::QWaylandOutputMode() |
| 46 | : d(new QWaylandOutputModePrivate) |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | QWaylandOutputMode::QWaylandOutputMode(const QSize &size, int refreshRate) |
| 51 | : d(new QWaylandOutputModePrivate) |
| 52 | { |
| 53 | d->size = size; |
| 54 | d->refreshRate = refreshRate; |
| 55 | } |
| 56 | |
| 57 | QWaylandOutputMode::QWaylandOutputMode(const QWaylandOutputMode &other) |
| 58 | : d(new QWaylandOutputModePrivate) |
| 59 | { |
| 60 | d->size = other.size(); |
| 61 | d->refreshRate = other.refreshRate(); |
| 62 | } |
| 63 | |
| 64 | QWaylandOutputMode::~QWaylandOutputMode() |
| 65 | { |
| 66 | delete d; |
| 67 | } |
| 68 | |
| 69 | QWaylandOutputMode &QWaylandOutputMode::operator=(const QWaylandOutputMode &other) |
| 70 | { |
| 71 | d->size = other.size(); |
| 72 | d->refreshRate = other.refreshRate(); |
| 73 | return *this; |
| 74 | } |
| 75 | |
| 76 | /*! |
| 77 | Returns \c true if this mode is equal to \a other, |
| 78 | otherwise returns \c false. |
| 79 | */ |
| 80 | bool QWaylandOutputMode::operator==(const QWaylandOutputMode &other) const |
| 81 | { |
| 82 | return size() == other.size() && refreshRate() == other.refreshRate(); |
| 83 | } |
| 84 | |
| 85 | /*! |
| 86 | Returns \c true if this mode is not equal to \a other, |
| 87 | otherwise returns \c false. |
| 88 | */ |
| 89 | bool QWaylandOutputMode::operator!=(const QWaylandOutputMode &other) const |
| 90 | { |
| 91 | return size() != other.size() || refreshRate() != other.refreshRate(); |
| 92 | } |
| 93 | |
| 94 | /*! |
| 95 | Returns whether this mode contains a valid resolution and refresh rate. |
| 96 | */ |
| 97 | bool QWaylandOutputMode::isValid() const |
| 98 | { |
| 99 | return !d->size.isEmpty() && d->refreshRate > 0; |
| 100 | } |
| 101 | |
| 102 | /*! |
| 103 | Returns the resolution in pixels. |
| 104 | */ |
| 105 | QSize QWaylandOutputMode::size() const |
| 106 | { |
| 107 | return d->size; |
| 108 | } |
| 109 | |
| 110 | /*! |
| 111 | Returns the refresh rate in mHz. |
| 112 | */ |
| 113 | int QWaylandOutputMode::refreshRate() const |
| 114 | { |
| 115 | return d->refreshRate; |
| 116 | } |
| 117 | |
| 118 | /*! |
| 119 | * \internal |
| 120 | */ |
| 121 | void QWaylandOutputMode::setSize(const QSize &size) |
| 122 | { |
| 123 | d->size = size; |
| 124 | } |
| 125 |
