2015-03-04 08:21:10 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#include "shell_client.h"
|
2015-05-27 08:16:46 +00:00
|
|
|
#include "composite.h"
|
2015-03-04 08:21:10 +00:00
|
|
|
#include "deleted.h"
|
2015-05-27 08:16:46 +00:00
|
|
|
#include "screens.h"
|
2015-03-04 08:21:10 +00:00
|
|
|
#include "wayland_server.h"
|
2015-05-27 08:16:46 +00:00
|
|
|
#include "workspace.h"
|
2015-03-16 08:14:04 +00:00
|
|
|
#include "virtualdesktops.h"
|
2015-05-19 10:03:53 +00:00
|
|
|
#include "workspace.h"
|
2015-03-04 08:21:10 +00:00
|
|
|
|
2015-05-18 12:51:40 +00:00
|
|
|
#include <KWayland/Client/surface.h>
|
2015-03-04 08:21:10 +00:00
|
|
|
#include <KWayland/Server/shell_interface.h>
|
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
#include <KWayland/Server/buffer_interface.h>
|
2015-06-09 17:10:56 +00:00
|
|
|
#include <KWayland/Server/plasmashell_interface.h>
|
2015-07-15 09:24:19 +00:00
|
|
|
#include <KWayland/Server/shadow_interface.h>
|
2015-06-09 22:59:53 +00:00
|
|
|
#include <KWayland/Server/qtsurfaceextension_interface.h>
|
2015-03-04 08:21:10 +00:00
|
|
|
|
2015-06-19 23:11:42 +00:00
|
|
|
#include <KDesktopFile>
|
|
|
|
|
2015-08-18 12:40:26 +00:00
|
|
|
#include <QOpenGLFramebufferObject>
|
2015-05-18 12:51:40 +00:00
|
|
|
#include <QWindow>
|
|
|
|
|
2015-03-04 08:21:10 +00:00
|
|
|
using namespace KWayland::Server;
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
ShellClient::ShellClient(ShellSurfaceInterface *surface)
|
2015-03-16 08:14:04 +00:00
|
|
|
: AbstractClient()
|
2015-03-04 08:21:10 +00:00
|
|
|
, m_shellSurface(surface)
|
|
|
|
{
|
|
|
|
setSurface(surface->surface());
|
2015-05-18 12:51:40 +00:00
|
|
|
findInternalWindow();
|
|
|
|
createWindowId();
|
2015-03-04 08:21:10 +00:00
|
|
|
setupCompositing();
|
|
|
|
if (surface->surface()->buffer()) {
|
|
|
|
setReadyForPainting();
|
2015-07-09 07:10:33 +00:00
|
|
|
setupWindowManagementInterface();
|
2015-06-03 19:19:00 +00:00
|
|
|
m_unmapped = false;
|
2015-03-04 08:21:10 +00:00
|
|
|
m_clientSize = surface->surface()->buffer()->size();
|
|
|
|
} else {
|
|
|
|
ready_for_painting = false;
|
|
|
|
}
|
2015-05-18 12:51:40 +00:00
|
|
|
if (m_internalWindow) {
|
2015-05-20 06:27:48 +00:00
|
|
|
updateInternalWindowGeometry();
|
2015-06-08 18:18:40 +00:00
|
|
|
setOnAllDesktops(true);
|
2015-05-18 12:51:40 +00:00
|
|
|
} else {
|
|
|
|
setGeometry(QRect(QPoint(0, 0), m_clientSize));
|
2015-06-08 18:18:40 +00:00
|
|
|
setDesktop(VirtualDesktopManager::self()->current());
|
2015-05-18 12:51:40 +00:00
|
|
|
}
|
2015-06-13 02:06:12 +00:00
|
|
|
if (waylandServer()->inputMethodConnection() == m_shellSurface->client()) {
|
|
|
|
m_windowType = NET::OnScreenDisplay;
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
|
|
|
|
connect(surface->surface(), &SurfaceInterface::sizeChanged, this,
|
|
|
|
[this] {
|
|
|
|
m_clientSize = m_shellSurface->surface()->buffer()->size();
|
2015-05-18 12:50:10 +00:00
|
|
|
setGeometry(QRect(geom.topLeft(), m_clientSize));
|
2015-05-21 11:30:55 +00:00
|
|
|
discardWindowPixmap();
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(surface, &ShellSurfaceInterface::destroyed, this, &ShellClient::destroyClient);
|
2015-06-03 19:19:00 +00:00
|
|
|
connect(surface->surface(), &SurfaceInterface::unmapped, this, &ShellClient::unmap);
|
2015-05-20 12:40:32 +00:00
|
|
|
connect(surface, &ShellSurfaceInterface::titleChanged, this, &ShellClient::captionChanged);
|
2015-05-19 10:03:53 +00:00
|
|
|
|
|
|
|
connect(surface, &ShellSurfaceInterface::fullscreenChanged, this, &ShellClient::clientFullScreenChanged);
|
2015-06-07 01:28:38 +00:00
|
|
|
connect(surface, &ShellSurfaceInterface::maximizedChanged, this,
|
|
|
|
[this] (bool maximized) {
|
|
|
|
maximize(maximized ? MaximizeFull : MaximizeRestore);
|
|
|
|
}
|
|
|
|
);
|
2015-06-19 23:11:42 +00:00
|
|
|
connect(surface, &ShellSurfaceInterface::windowClassChanged, this, &ShellClient::updateIcon);
|
|
|
|
updateIcon();
|
2015-07-15 09:24:19 +00:00
|
|
|
|
|
|
|
// setup shadow integration
|
|
|
|
getShadow();
|
|
|
|
connect(surface->surface(), &SurfaceInterface::shadowChanged, this, &Toplevel::getShadow);
|
2015-07-20 07:37:36 +00:00
|
|
|
|
|
|
|
setResourceClass(surface->windowClass());
|
|
|
|
connect(surface, &ShellSurfaceInterface::windowClassChanged, this,
|
|
|
|
[this] {
|
|
|
|
setResourceClass(m_shellSurface->windowClass());
|
|
|
|
}
|
|
|
|
);
|
2015-09-11 10:11:01 +00:00
|
|
|
|
|
|
|
setTransient();
|
|
|
|
connect(surface, &ShellSurfaceInterface::transientForChanged, this, &ShellClient::setTransient);
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ShellClient::~ShellClient() = default;
|
|
|
|
|
|
|
|
void ShellClient::destroyClient()
|
|
|
|
{
|
2015-04-30 11:48:59 +00:00
|
|
|
m_closing = true;
|
2015-03-04 08:21:10 +00:00
|
|
|
Deleted *del = Deleted::create(this);
|
|
|
|
emit windowClosed(this, del);
|
2015-10-01 12:12:46 +00:00
|
|
|
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
|
|
|
if (transientFor()) {
|
|
|
|
transientFor()->removeTransient(this);
|
|
|
|
}
|
|
|
|
for (auto it = transients().constBegin(); it != transients().constEnd();) {
|
|
|
|
if ((*it)->transientFor() == this) {
|
|
|
|
removeTransient(*it);
|
|
|
|
it = transients().constBegin(); // restart, just in case something more has changed with the list
|
|
|
|
} else {
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
waylandServer()->removeClient(this);
|
|
|
|
|
|
|
|
del->unrefWindow();
|
|
|
|
m_shellSurface = nullptr;
|
|
|
|
deleteClient(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::deleteClient(ShellClient *c)
|
|
|
|
{
|
|
|
|
delete c;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList ShellClient::activities() const
|
|
|
|
{
|
|
|
|
// TODO: implement
|
|
|
|
return QStringList();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint ShellClient::clientPos() const
|
|
|
|
{
|
|
|
|
return QPoint(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize ShellClient::clientSize() const
|
|
|
|
{
|
|
|
|
// TODO: connect for changes
|
|
|
|
return m_clientSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::debug(QDebug &stream) const
|
|
|
|
{
|
|
|
|
// TODO: implement
|
|
|
|
Q_UNUSED(stream)
|
|
|
|
}
|
|
|
|
|
2015-09-17 09:06:59 +00:00
|
|
|
Layer ShellClient::layerForDock() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2015-09-17 09:06:59 +00:00
|
|
|
if (m_plasmaShellSurface) {
|
|
|
|
switch (m_plasmaShellSurface->panelBehavior()) {
|
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::WindowsCanCover:
|
2015-06-09 17:10:56 +00:00
|
|
|
return NormalLayer;
|
2015-09-17 09:06:59 +00:00
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::AutoHide:
|
2015-06-09 17:10:56 +00:00
|
|
|
return AboveLayer;
|
2015-09-17 09:06:59 +00:00
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::WindowsGoBelow:
|
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::AlwaysVisible:
|
|
|
|
return DockLayer;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
2015-09-17 09:06:59 +00:00
|
|
|
return AbstractClient::layerForDock();
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::shouldUnredirect() const
|
|
|
|
{
|
|
|
|
// TODO: unredirect for fullscreen
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect ShellClient::transparentRect() const
|
|
|
|
{
|
|
|
|
// TODO: implement
|
|
|
|
return QRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
NET::WindowType ShellClient::windowType(bool direct, int supported_types) const
|
|
|
|
{
|
|
|
|
// TODO: implement
|
|
|
|
Q_UNUSED(direct)
|
|
|
|
Q_UNUSED(supported_types)
|
2015-06-08 19:27:55 +00:00
|
|
|
return m_windowType;
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double ShellClient::opacity() const
|
|
|
|
{
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
2015-03-16 08:13:19 +00:00
|
|
|
void ShellClient::setOpacity(double opacity)
|
|
|
|
{
|
|
|
|
Q_UNUSED(opacity)
|
|
|
|
}
|
|
|
|
|
2015-03-04 08:21:10 +00:00
|
|
|
void ShellClient::addDamage(const QRegion &damage)
|
|
|
|
{
|
|
|
|
if (m_shellSurface->surface()->buffer()->size().isValid()) {
|
|
|
|
m_clientSize = m_shellSurface->surface()->buffer()->size();
|
2015-05-19 10:03:53 +00:00
|
|
|
QPoint position = geom.topLeft();
|
|
|
|
if (m_positionAfterResize.isValid()) {
|
2015-06-07 00:38:53 +00:00
|
|
|
addLayerRepaint(geometry());
|
2015-05-19 10:03:53 +00:00
|
|
|
position = m_positionAfterResize.point();
|
|
|
|
m_positionAfterResize.clear();
|
|
|
|
}
|
|
|
|
setGeometry(QRect(position, m_clientSize));
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
2015-07-22 06:38:00 +00:00
|
|
|
markAsMapped();
|
2015-06-01 14:25:21 +00:00
|
|
|
setDepth(m_shellSurface->surface()->buffer()->hasAlphaChannel() ? 32 : 24);
|
2015-03-04 08:21:10 +00:00
|
|
|
Toplevel::addDamage(damage);
|
|
|
|
}
|
|
|
|
|
2015-08-18 12:40:26 +00:00
|
|
|
void ShellClient::setInternalFramebufferObject(const QSharedPointer<QOpenGLFramebufferObject> &fbo)
|
|
|
|
{
|
|
|
|
if (fbo.isNull()) {
|
|
|
|
unmap();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
markAsMapped();
|
|
|
|
m_clientSize = fbo->size();
|
|
|
|
setGeometry(QRect(geom.topLeft(), m_clientSize));
|
|
|
|
Toplevel::setInternalFramebufferObject(fbo);
|
|
|
|
Toplevel::addDamage(QRegion(0, 0, width(), height()));
|
|
|
|
}
|
|
|
|
|
2015-07-22 06:38:00 +00:00
|
|
|
void ShellClient::markAsMapped()
|
2015-07-09 07:10:33 +00:00
|
|
|
{
|
|
|
|
if (!m_unmapped) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_unmapped = false;
|
|
|
|
setReadyForPainting();
|
|
|
|
setupWindowManagementInterface();
|
|
|
|
}
|
|
|
|
|
2015-03-04 08:21:10 +00:00
|
|
|
void ShellClient::setGeometry(const QRect &rect)
|
|
|
|
{
|
|
|
|
if (geom == rect) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-20 07:38:19 +00:00
|
|
|
if (!m_unmapped) {
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
const QRect old = geom;
|
|
|
|
geom = rect;
|
2015-08-20 07:38:19 +00:00
|
|
|
if (!m_unmapped) {
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
emit geometryChanged();
|
|
|
|
emit geometryShapeChanged(this, old);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray ShellClient::windowRole() const
|
|
|
|
{
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
|
2015-03-16 08:14:04 +00:00
|
|
|
bool ShellClient::belongsToSameApplication(const AbstractClient *other, bool active_hack) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(active_hack)
|
|
|
|
if (auto s = other->surface()) {
|
|
|
|
return s->client() == surface()->client();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::blockActivityUpdates(bool b)
|
|
|
|
{
|
|
|
|
Q_UNUSED(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ShellClient::caption(bool full, bool stripped) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(full)
|
|
|
|
Q_UNUSED(stripped)
|
2015-05-20 12:40:32 +00:00
|
|
|
return m_shellSurface->title();
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
fix sendToScreen/checkWorkspaceGeometry
Prime target is to preserve the in-screen
condition of client AND window.i[1]
Atm. when the client is fully in sight
(but the window is not) - regardless of snapping
or screen change - a workspace update (screen change,
resolution change, adding/removing a strutting panel)
would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen smaller
than the window, the window is shrinked to the dimensions of that
screen and now randomly touches eg. left AND right edge. When
moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 122517
FIXED-IN: 5.4
Prime target is to preserve the in-screen condition
of client AND window.[1]
Atm. when the client is fully in sight (but the window is not) -
regardless of snapping or screen change - a workspace update
(screen change, resolution change, adding/removing a strutting
panel) would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen
smaller than the window, the window is shrinked to the dimensions
of that screen and now randomly touches eg. left AND right edge.
When moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 116029
FIXED-IN: 5.3
2015-02-06 21:48:12 +00:00
|
|
|
void ShellClient::checkWorkspacePosition(QRect oldGeometry, int oldDesktop, QRect oldClientGeometry)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(oldGeometry)
|
|
|
|
Q_UNUSED(oldDesktop)
|
fix sendToScreen/checkWorkspaceGeometry
Prime target is to preserve the in-screen
condition of client AND window.i[1]
Atm. when the client is fully in sight
(but the window is not) - regardless of snapping
or screen change - a workspace update (screen change,
resolution change, adding/removing a strutting panel)
would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen smaller
than the window, the window is shrinked to the dimensions of that
screen and now randomly touches eg. left AND right edge. When
moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 122517
FIXED-IN: 5.4
Prime target is to preserve the in-screen condition
of client AND window.[1]
Atm. when the client is fully in sight (but the window is not) -
regardless of snapping or screen change - a workspace update
(screen change, resolution change, adding/removing a strutting
panel) would allow the client to partiall escape screen bounds.
This is changed so that if the client is fully in sight,
it's kept fully in sight (but not the decoration)
If the entire window was fully in sight, it's also kept
(as is right now)
The code handles inner screen edges (if the client was in sight,
the entire window will be if we'd bleed to the other screen)
[1] I'd say that handling the client is more relevant,
but foresee more complaints if the window wasn't handled anymore ;-)
During that, i stumbled across some other issues.
- when a window centered on one screen is moved to a screen
smaller than the window, the window is shrinked to the dimensions
of that screen and now randomly touches eg. left AND right edge.
When moved back, the right and bottom edge were preferred
(to the window was "moved" into the lower right corner).
It's now kept centered.
- geom_restore was saved before keeping the window in the new
screen area (causing accidental drops on screen changes)
BUG: 330968
REVIEW: 116029
FIXED-IN: 5.3
2015-02-06 21:48:12 +00:00
|
|
|
Q_UNUSED(oldClientGeometry)
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::closeWindow()
|
|
|
|
{
|
2015-06-11 23:20:31 +00:00
|
|
|
if (m_qtExtendedSurface && isCloseable()) {
|
2015-06-09 22:59:53 +00:00
|
|
|
m_qtExtendedSurface->close();
|
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AbstractClient *ShellClient::findModal(bool allow_itself)
|
|
|
|
{
|
|
|
|
Q_UNUSED(allow_itself)
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isCloseable() const
|
|
|
|
{
|
2015-06-11 23:20:31 +00:00
|
|
|
if (m_windowType == NET::Desktop || m_windowType == NET::Dock) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-09 22:59:53 +00:00
|
|
|
return m_qtExtendedSurface ? true : false;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 13:59:27 +00:00
|
|
|
bool ShellClient::isFullScreenable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-16 08:14:04 +00:00
|
|
|
bool ShellClient::isFullScreen() const
|
|
|
|
{
|
2015-05-19 10:03:53 +00:00
|
|
|
return m_shellSurface->isFullscreen();
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isMaximizable() const
|
|
|
|
{
|
2015-06-07 01:28:38 +00:00
|
|
|
return true;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isMinimizable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isMovable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isMovableAcrossScreens() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isResizable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isShown(bool shaded_is_shown) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(shaded_is_shown)
|
2015-06-03 19:19:00 +00:00
|
|
|
return !m_closing && !m_unmapped;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2015-05-23 07:02:11 +00:00
|
|
|
void ShellClient::hideClient(bool hide)
|
|
|
|
{
|
2015-06-12 01:09:44 +00:00
|
|
|
Q_UNUSED(hide)
|
2015-05-23 07:02:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-07 01:28:38 +00:00
|
|
|
void ShellClient::maximize(MaximizeMode mode)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2015-06-07 01:28:38 +00:00
|
|
|
if (m_maximizeMode == mode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// TODO: check rules
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
|
|
|
const MaximizeMode oldMode = m_maximizeMode;
|
|
|
|
m_maximizeMode = mode;
|
|
|
|
|
|
|
|
if (m_maximizeMode == MaximizeFull) {
|
|
|
|
m_geomMaximizeRestore = geometry();
|
|
|
|
requestGeometry(workspace()->clientArea(MaximizeArea, this));
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
} else {
|
|
|
|
if (m_geomMaximizeRestore.isValid()) {
|
|
|
|
requestGeometry(m_geomMaximizeRestore);
|
|
|
|
} else {
|
|
|
|
requestGeometry(workspace()->clientArea(PlacementArea, this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (oldMode != maximizeMode()) {
|
|
|
|
emit clientMaximizedStateChanged(this, m_maximizeMode);
|
|
|
|
const bool set = m_maximizeMode == MaximizeFull;
|
|
|
|
emit clientMaximizedStateChanged(this, set, set);
|
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MaximizeMode ShellClient::maximizeMode() const
|
|
|
|
{
|
2015-06-07 01:28:38 +00:00
|
|
|
return m_maximizeMode;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::noBorder() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const WindowRules *ShellClient::rules() const
|
|
|
|
{
|
|
|
|
static WindowRules s_rules;
|
|
|
|
return &s_rules;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::sendToScreen(int screen)
|
|
|
|
{
|
|
|
|
Q_UNUSED(screen)
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::setFullScreen(bool set, bool user)
|
|
|
|
{
|
|
|
|
Q_UNUSED(set)
|
|
|
|
Q_UNUSED(user)
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::setNoBorder(bool set)
|
|
|
|
{
|
|
|
|
Q_UNUSED(set)
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::setOnAllActivities(bool set)
|
|
|
|
{
|
|
|
|
Q_UNUSED(set)
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::setQuickTileMode(AbstractClient::QuickTileMode mode, bool keyboard)
|
|
|
|
{
|
|
|
|
Q_UNUSED(mode)
|
|
|
|
Q_UNUSED(keyboard)
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::setShortcut(const QString &cut)
|
|
|
|
{
|
|
|
|
Q_UNUSED(cut)
|
|
|
|
}
|
|
|
|
|
|
|
|
const QKeySequence &ShellClient::shortcut() const
|
|
|
|
{
|
|
|
|
static QKeySequence seq;
|
|
|
|
return seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::takeFocus()
|
|
|
|
{
|
2015-07-09 18:43:41 +00:00
|
|
|
if (rules()->checkAcceptFocus(wantsInput())) {
|
|
|
|
setActive(true);
|
|
|
|
}
|
2015-06-23 09:08:28 +00:00
|
|
|
|
|
|
|
bool breakShowingDesktop = !keepAbove() && !isOnScreenDisplay();
|
|
|
|
if (breakShowingDesktop) {
|
|
|
|
// check that it doesn't belong to the desktop
|
|
|
|
const auto &clients = waylandServer()->clients();
|
|
|
|
for (auto c: clients) {
|
|
|
|
if (!belongsToSameApplication(c, false)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (c->isDesktop()) {
|
|
|
|
breakShowingDesktop = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (breakShowingDesktop)
|
|
|
|
workspace()->setShowingDesktop(false);
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 14:15:58 +00:00
|
|
|
void ShellClient::doSetActive()
|
|
|
|
{
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
|
|
|
workspace()->focusToNull();
|
|
|
|
}
|
|
|
|
|
2015-03-16 08:14:04 +00:00
|
|
|
void ShellClient::updateWindowRules(Rules::Types selection)
|
|
|
|
{
|
|
|
|
Q_UNUSED(selection)
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::userCanSetFullScreen() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::userCanSetNoBorder() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::wantsInput() const
|
|
|
|
{
|
2015-05-21 08:39:10 +00:00
|
|
|
if (isInternal()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-13 02:06:12 +00:00
|
|
|
if (waylandServer()->inputMethodConnection() == m_shellSurface->client()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-11 11:33:57 +00:00
|
|
|
if (m_shellSurface->isPopup()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-10 15:46:55 +00:00
|
|
|
// if the window is not visible it doesn't get input
|
|
|
|
return isShown(true);
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 12:51:40 +00:00
|
|
|
void ShellClient::createWindowId()
|
|
|
|
{
|
|
|
|
if (m_internalWindow) {
|
|
|
|
m_windowId = m_internalWindow->winId();
|
2015-05-21 07:59:45 +00:00
|
|
|
} else {
|
|
|
|
m_windowId = waylandServer()->createWindowId(m_shellSurface->surface());
|
2015-05-18 12:51:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::findInternalWindow()
|
|
|
|
{
|
2015-08-18 06:15:00 +00:00
|
|
|
if (m_shellSurface->client() != waylandServer()->internalConnection()) {
|
2015-05-18 12:51:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QWindowList windows = kwinApp()->topLevelWindows();
|
|
|
|
for (QWindow *w: windows) {
|
2015-09-15 10:18:36 +00:00
|
|
|
auto s = KWayland::Client::Surface::fromWindow(w);
|
2015-05-18 12:51:40 +00:00
|
|
|
if (!s) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (s->id() != surface()->id()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
m_internalWindow = w;
|
2015-05-20 06:27:48 +00:00
|
|
|
connect(m_internalWindow, &QWindow::xChanged, this, &ShellClient::updateInternalWindowGeometry);
|
2015-05-20 06:57:51 +00:00
|
|
|
connect(m_internalWindow, &QWindow::yChanged, this, &ShellClient::updateInternalWindowGeometry);
|
2015-06-08 19:27:55 +00:00
|
|
|
|
|
|
|
// Try reading the window type from the QWindow. PlasmaCore.Dialog provides a dynamic type property
|
|
|
|
// let's check whether it exists, if it does it's our window type
|
|
|
|
const QVariant windowType = m_internalWindow->property("type");
|
|
|
|
if (!windowType.isNull()) {
|
|
|
|
m_windowType = static_cast<NET::WindowType>(windowType.toInt());
|
|
|
|
}
|
2015-05-18 12:51:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 06:27:48 +00:00
|
|
|
void ShellClient::updateInternalWindowGeometry()
|
|
|
|
{
|
|
|
|
if (!m_internalWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setGeometry(m_internalWindow->geometry());
|
|
|
|
}
|
|
|
|
|
2015-05-21 08:31:19 +00:00
|
|
|
bool ShellClient::isInternal() const
|
|
|
|
{
|
2015-08-18 06:15:00 +00:00
|
|
|
return m_shellSurface->client() == waylandServer()->internalConnection();
|
2015-05-21 08:31:19 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 08:46:12 +00:00
|
|
|
xcb_window_t ShellClient::window() const
|
|
|
|
{
|
|
|
|
return windowId();
|
|
|
|
}
|
|
|
|
|
2015-05-19 10:03:53 +00:00
|
|
|
void ShellClient::requestGeometry(const QRect &rect)
|
|
|
|
{
|
|
|
|
m_positionAfterResize.setPoint(rect.topLeft());
|
|
|
|
m_shellSurface->requestSize(rect.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::clientFullScreenChanged(bool fullScreen)
|
|
|
|
{
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
|
|
|
workspace()->updateClientLayer(this); // active fullscreens get different layer
|
|
|
|
|
2015-10-01 14:03:02 +00:00
|
|
|
if (fullScreen) {
|
2015-05-19 10:03:53 +00:00
|
|
|
m_geomFsRestore = geometry();
|
|
|
|
requestGeometry(workspace()->clientArea(FullScreenArea, this));
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
} else {
|
|
|
|
if (m_geomFsRestore.isValid()) {
|
|
|
|
requestGeometry(m_geomFsRestore);
|
|
|
|
} else {
|
|
|
|
requestGeometry(workspace()->clientArea(MaximizeArea, this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-27 08:16:46 +00:00
|
|
|
void ShellClient::move(int x, int y, ForceGeometry_t force)
|
|
|
|
{
|
|
|
|
QPoint p(x, y);
|
|
|
|
if (force == NormalGeometrySet && geom.topLeft() == p) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QRect oldGeom = visibleRect();
|
|
|
|
geom.moveTopLeft(p);
|
|
|
|
updateWindowRules(Rules::Position);
|
|
|
|
screens()->setCurrent(this);
|
|
|
|
workspace()->updateStackingOrder();
|
|
|
|
if (Compositor::isCreated()) {
|
|
|
|
// TODO: is this really needed here?
|
|
|
|
Compositor::self()->checkUnredirect();
|
|
|
|
}
|
|
|
|
|
|
|
|
addLayerRepaint(oldGeom);
|
|
|
|
addLayerRepaint(visibleRect());
|
|
|
|
emit geometryChanged();
|
|
|
|
}
|
|
|
|
|
2015-05-27 09:48:33 +00:00
|
|
|
void ShellClient::resizeWithChecks(int w, int h, ForceGeometry_t force)
|
|
|
|
{
|
|
|
|
Q_UNUSED(force)
|
|
|
|
QRect area = workspace()->clientArea(WorkArea, this);
|
|
|
|
// don't allow growing larger than workarea
|
|
|
|
if (w > area.width()) {
|
|
|
|
w = area.width();
|
|
|
|
}
|
|
|
|
if (h > area.height()) {
|
|
|
|
h = area.height();
|
|
|
|
}
|
|
|
|
m_shellSurface->requestSize(QSize(w, h));
|
|
|
|
}
|
|
|
|
|
2015-06-03 19:19:00 +00:00
|
|
|
void ShellClient::unmap()
|
|
|
|
{
|
|
|
|
m_unmapped = true;
|
|
|
|
ready_for_painting = false;
|
2015-07-09 07:10:33 +00:00
|
|
|
destroyWindowManagementInterface();
|
2015-06-03 19:19:00 +00:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
workspace()->clientHidden(this);
|
2015-06-10 15:45:59 +00:00
|
|
|
emit windowHidden(this);
|
2015-06-03 19:19:00 +00:00
|
|
|
}
|
|
|
|
|
2015-06-09 17:10:56 +00:00
|
|
|
void ShellClient::installPlasmaShellSurface(PlasmaShellSurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
m_plasmaShellSurface = surface;
|
|
|
|
auto updatePosition = [this, surface] {
|
|
|
|
setGeometry(QRect(surface->position(), m_clientSize));
|
|
|
|
};
|
|
|
|
auto updateRole = [this, surface] {
|
|
|
|
NET::WindowType type = NET::Unknown;
|
|
|
|
switch (surface->role()) {
|
|
|
|
case PlasmaShellSurfaceInterface::Role::Desktop:
|
|
|
|
type = NET::Desktop;
|
|
|
|
break;
|
|
|
|
case PlasmaShellSurfaceInterface::Role::Panel:
|
|
|
|
type = NET::Dock;
|
|
|
|
break;
|
2015-09-03 16:19:38 +00:00
|
|
|
case PlasmaShellSurfaceInterface::Role::OnScreenDisplay:
|
|
|
|
type = NET::OnScreenDisplay;
|
|
|
|
break;
|
2015-06-09 17:10:56 +00:00
|
|
|
case PlasmaShellSurfaceInterface::Role::Normal:
|
|
|
|
default:
|
|
|
|
type = NET::Normal;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (type != m_windowType) {
|
|
|
|
m_windowType = type;
|
|
|
|
workspace()->updateClientArea();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
connect(surface, &PlasmaShellSurfaceInterface::positionChanged, this, updatePosition);
|
|
|
|
connect(surface, &PlasmaShellSurfaceInterface::roleChanged, this, updateRole);
|
2015-06-25 07:04:51 +00:00
|
|
|
connect(surface, &PlasmaShellSurfaceInterface::panelBehaviorChanged, this,
|
|
|
|
[] {
|
|
|
|
workspace()->updateClientArea();
|
|
|
|
}
|
|
|
|
);
|
2015-06-09 17:10:56 +00:00
|
|
|
updatePosition();
|
|
|
|
updateRole();
|
2015-09-29 18:25:04 +00:00
|
|
|
|
|
|
|
setSkipTaskbar(surface->skipTaskbar());
|
|
|
|
connect(surface, &PlasmaShellSurfaceInterface::skipTaskbarChanged, this, [this] {
|
|
|
|
setSkipTaskbar(m_plasmaShellSurface->skipTaskbar());
|
|
|
|
});
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShellClient::isInitialPositionSet() const
|
|
|
|
{
|
|
|
|
if (m_plasmaShellSurface) {
|
|
|
|
return m_plasmaShellSurface->isPositionSet();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-09 22:59:53 +00:00
|
|
|
void ShellClient::installQtExtendedSurface(QtExtendedSurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
m_qtExtendedSurface = surface;
|
2015-09-16 14:36:26 +00:00
|
|
|
|
2015-09-28 12:09:10 +00:00
|
|
|
connect(m_qtExtendedSurface.data(), &QtExtendedSurfaceInterface::raiseRequested, this, [this]() {
|
2015-09-16 14:36:26 +00:00
|
|
|
workspace()->raiseClientRequest(this);
|
|
|
|
});
|
2015-09-28 12:09:10 +00:00
|
|
|
connect(m_qtExtendedSurface.data(), &QtExtendedSurfaceInterface::lowerRequested, this, [this]() {
|
2015-09-16 14:36:26 +00:00
|
|
|
workspace()->lowerClientRequest(this);
|
|
|
|
});
|
2015-06-09 22:59:53 +00:00
|
|
|
}
|
|
|
|
|
2015-06-19 22:14:49 +00:00
|
|
|
bool ShellClient::hasStrut() const
|
|
|
|
{
|
|
|
|
if (!isShown(true)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!m_plasmaShellSurface) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_plasmaShellSurface->role() != PlasmaShellSurfaceInterface::Role::Panel) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return m_plasmaShellSurface->panelBehavior() != PlasmaShellSurfaceInterface::PanelBehavior::WindowsGoBelow;
|
|
|
|
}
|
|
|
|
|
2015-06-19 23:11:42 +00:00
|
|
|
void ShellClient::updateIcon()
|
|
|
|
{
|
2015-07-15 15:18:39 +00:00
|
|
|
QString desktopFile = QString::fromUtf8(m_shellSurface->windowClass());
|
|
|
|
if (desktopFile.isEmpty()) {
|
2015-06-19 23:11:42 +00:00
|
|
|
setIcon(QIcon());
|
|
|
|
}
|
2015-07-15 15:18:39 +00:00
|
|
|
if (!desktopFile.endsWith(QLatin1String(".desktop"))) {
|
|
|
|
desktopFile.append(QLatin1String(".desktop"));
|
|
|
|
}
|
|
|
|
KDesktopFile df(desktopFile);
|
2015-06-19 23:11:42 +00:00
|
|
|
setIcon(QIcon::fromTheme(df.readIcon()));
|
|
|
|
}
|
|
|
|
|
2015-09-11 10:11:01 +00:00
|
|
|
bool ShellClient::isTransient() const
|
|
|
|
{
|
|
|
|
return m_shellSurface->isTransient();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShellClient::setTransient()
|
|
|
|
{
|
|
|
|
const auto s = m_shellSurface->transientFor();
|
2015-10-01 12:12:46 +00:00
|
|
|
auto t = waylandServer()->findClient(s.data());
|
|
|
|
if (t != transientFor()) {
|
|
|
|
// remove from main client
|
|
|
|
if (transientFor())
|
|
|
|
transientFor()->removeTransient(this);
|
|
|
|
setTransientFor(t);
|
|
|
|
if (t) {
|
|
|
|
t->addTransient(this);
|
|
|
|
}
|
|
|
|
}
|
2015-09-11 10:11:01 +00:00
|
|
|
}
|
|
|
|
|
2015-09-11 11:31:41 +00:00
|
|
|
bool ShellClient::hasTransientPlacementHint() const
|
|
|
|
{
|
|
|
|
return isTransient() && transientFor() != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint ShellClient::transientPlacementHint() const
|
|
|
|
{
|
|
|
|
return m_shellSurface->transientOffset();
|
|
|
|
}
|
|
|
|
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|