2 * Copyright (C) 2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include <unity/shell/application/MirSurfaceInterface.h>
24namespace unityapi = unity::shell::application;
26Q_LOGGING_CATEGORY(UNITY_WINDOW, "unity.window", QtWarningMsg)
28#define DEBUG_MSG qCDebug(UNITY_WINDOW).nospace() << qPrintable(toString()) << "::" << __func__
30Window::Window(int id, QObject *parent)
35 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
43QPoint Window::position() const
48QPoint Window::requestedPosition() const
50 return m_requestedPosition;
53void Window::setRequestedPosition(const QPoint &value)
55 m_positionRequested = true;
56 if (value != m_requestedPosition) {
57 m_requestedPosition = value;
58 Q_EMIT requestedPositionChanged(m_requestedPosition);
60 m_surface->setRequestedPosition(value);
62 // fake-miral: always comply
63 m_position = m_requestedPosition;
64 Q_EMIT positionChanged(m_position);
69Mir::State Window::state() const
74bool Window::focused() const
79bool Window::confinesMousePointer() const
82 return m_surface->confinesMousePointer();
93unityapi::MirSurfaceInterface* Window::surface() const
98void Window::requestState(Mir::State state)
100 m_stateRequested = true;
102 m_surface->requestState(state);
103 } else if (m_state != state) {
105 Q_EMIT stateChanged(m_state);
114 Q_EMIT closeRequested();
118void Window::activate()
121 m_surface->activate();
123 Q_EMIT emptyWindowActivated();
127void Window::setSurface(unityapi::MirSurfaceInterface *surface)
129 DEBUG_MSG << "(" << surface << ")";
131 disconnect(m_surface, 0, this, 0);
137 connect(surface, &unityapi::MirSurfaceInterface::focusRequested, this, [this]() {
138 Q_EMIT focusRequested();
141 connect(surface, &unityapi::MirSurfaceInterface::closeRequested, this, &Window::closeRequested);
143 connect(surface, &unityapi::MirSurfaceInterface::positionChanged, this, [this]() {
147 connect(surface, &unityapi::MirSurfaceInterface::stateChanged, this, [this]() {
151 connect(surface, &unityapi::MirSurfaceInterface::focusedChanged, this, [this]() {
155 // bring it up to speed
156 if (m_positionRequested) {
157 m_surface->setRequestedPosition(m_requestedPosition);
159 if (m_stateRequested) {
160 m_surface->requestState(m_state);
163 // and sync with surface
169 Q_EMIT surfaceChanged(surface);
172void Window::updatePosition()
174 if (m_surface->position() != m_position) {
175 m_position = m_surface->position();
176 Q_EMIT positionChanged(m_position);
180void Window::updateState()
182 if (m_surface->state() != m_state) {
183 m_state = m_surface->state();
184 Q_EMIT stateChanged(m_state);
188void Window::updateFocused()
190 if (m_surface->focused() != m_focused) {
191 m_focused = m_surface->focused();
192 Q_EMIT focusedChanged(m_focused);
196void Window::setFocused(bool value)
198 if (value != m_focused) {
199 DEBUG_MSG << "(" << value << ")";
201 Q_EMIT focusedChanged(m_focused);
202 // when we have a surface we get focus changes from updateFocused() instead
203 Q_ASSERT(!m_surface);
207QString Window::toString() const
210 return QString("Window[0x%1, id=%2, MirSurface[0x%3,\"%4\"]]").arg(
211 QString::number((quintptr)this, 16),
212 QString::number(id()),
213 QString::number((quintptr)surface(), 16),
216 return QString("Window[0x%1, id=%2, null]").arg(
217 QString::number((quintptr)this, 0, 16),
218 QString::number(id()));
222QDebug operator<<(QDebug dbg, const Window *window)
224 QDebugStateSaver saver(dbg);
228 dbg << qPrintable(window->toString());
230 dbg << (void*)(window);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list