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>
25namespace unityapi = unity::shell::application;
27Q_LOGGING_CATEGORY(UNITY_WINDOW, "unity.window", QtWarningMsg)
29#define DEBUG_MSG qCDebug(UNITY_WINDOW).nospace() << qPrintable(toString()) << "::" << __func__
31Window::Window(int id, QObject *parent)
36 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
44QPoint Window::position() const
49QPoint Window::requestedPosition() const
51 return m_requestedPosition;
54void Window::setRequestedPosition(const QPoint &value)
56 m_positionRequested = true;
57 if (value != m_requestedPosition) {
58 m_requestedPosition = value;
59 Q_EMIT requestedPositionChanged(m_requestedPosition);
61 m_surface->setRequestedPosition(value);
63 // fake-miral: always comply
64 m_position = m_requestedPosition;
65 Q_EMIT positionChanged(m_position);
70Mir::State Window::state() const
75bool Window::focused() const
80bool Window::confinesMousePointer() const
83 return m_surface->confinesMousePointer();
94unityapi::MirSurfaceInterface* Window::surface() const
99void Window::requestState(Mir::State state)
101 m_stateRequested = true;
103 m_surface->requestState(state);
104 } else if (m_state != state) {
106 Q_EMIT stateChanged(m_state);
115 Q_EMIT closeRequested();
119void Window::activate()
123 m_surface->activate();
125 Q_EMIT emptyWindowActivated();
129void Window::setSurface(unityapi::MirSurfaceInterface *surface)
131 DEBUG_MSG << "(" << surface << ")";
133 disconnect(m_surface, 0, this, 0);
139 connect(surface, &unityapi::MirSurfaceInterface::focusRequested, this, [this]() {
140 Q_EMIT focusRequested();
143 connect(surface, &unityapi::MirSurfaceInterface::closeRequested, this, &Window::closeRequested);
145 connect(surface, &unityapi::MirSurfaceInterface::positionChanged, this, [this]() {
149 connect(surface, &unityapi::MirSurfaceInterface::stateChanged, this, [this]() {
153 connect(surface, &unityapi::MirSurfaceInterface::focusedChanged, this, [this]() {
157 // bring it up to speed
158 if (m_positionRequested) {
159 m_surface->setRequestedPosition(m_requestedPosition);
161 if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
162 m_surface->requestState(m_state);
165 // and sync with surface
171 Q_EMIT surfaceChanged(surface);
174void Window::updatePosition()
176 if (m_surface->position() != m_position) {
177 m_position = m_surface->position();
178 Q_EMIT positionChanged(m_position);
182void Window::updateState()
184 if (m_surface->state() != m_state) {
185 m_state = m_surface->state();
186 Q_EMIT stateChanged(m_state);
190void Window::updateFocused()
192 if (m_surface->focused() != m_focused) {
193 m_focused = m_surface->focused();
194 Q_EMIT focusedChanged(m_focused);
198void Window::setFocused(bool value)
200 if (value != m_focused) {
201 DEBUG_MSG << "(" << value << ")";
203 Q_EMIT focusedChanged(m_focused);
204 // when we have a surface we get focus changes from updateFocused() instead
205 Q_ASSERT(!m_surface);
209QString Window::toString() const
213 QTextStream stream(&result);
214 stream << "Window["<<(void*)this<<", id="<<id()<<", ";
216 stream << "MirSurface["<<(void*)surface()<<",\""<<surface()->name()<<"\"]";
225QDebug operator<<(QDebug dbg, const Window *window)
227 QDebugStateSaver saver(dbg);
231 dbg << qPrintable(window->toString());
233 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