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>
|
[wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.
This patch splits the requested, pending and current state, updating as
appropriate.
Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.
X code is untouched.
This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.
Test Plan:
Maximised a window with the button and double clicking title bar.
I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true
19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false
BUG: 382698
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 14:36:02 +00:00
|
|
|
Copyright (C) 2018 David Edmundson <davidedmundson@kde.org>
|
2020-01-14 16:17:18 +00:00
|
|
|
Copyright (C) 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2015-03-04 08:21:10 +00:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
2019-08-30 21:36:58 +00:00
|
|
|
#include "xdgshellclient.h"
|
2015-03-04 08:21:10 +00:00
|
|
|
#include "deleted.h"
|
2016-09-15 19:03:40 +00:00
|
|
|
#include "screenedge.h"
|
2015-05-27 08:16:46 +00:00
|
|
|
#include "screens.h"
|
2020-02-17 18:39:17 +00:00
|
|
|
#include "subsurfacemonitor.h"
|
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
2019-07-29 18:24:09 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
|
|
|
#include "tabbox.h"
|
|
|
|
#endif
|
2019-09-15 11:48:14 +00:00
|
|
|
|
2015-12-17 14:47:36 +00:00
|
|
|
#include <KDecoration2/DecoratedClient>
|
2019-09-26 16:49:04 +00:00
|
|
|
#include <KDecoration2/Decoration>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/appmenu_interface.h>
|
|
|
|
#include <KWaylandServer/buffer_interface.h>
|
2020-02-17 18:39:17 +00:00
|
|
|
#include <KWaylandServer/output_interface.h>
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/plasmashell_interface.h>
|
|
|
|
#include <KWaylandServer/seat_interface.h>
|
|
|
|
#include <KWaylandServer/server_decoration_interface.h>
|
|
|
|
#include <KWaylandServer/server_decoration_palette_interface.h>
|
|
|
|
#include <KWaylandServer/surface_interface.h>
|
2020-02-17 18:39:17 +00:00
|
|
|
#include <KWaylandServer/xdgdecoration_v1_interface.h>
|
|
|
|
#include <KWaylandServer/xdgshell_interface.h>
|
2019-01-13 16:50:32 +00:00
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
using namespace KWaylandServer;
|
2015-03-04 08:21:10 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2020-06-01 10:43:49 +00:00
|
|
|
enum XdgSurfaceGeometryType {
|
|
|
|
XdgSurfaceGeometryClient = 0x1,
|
|
|
|
XdgSurfaceGeometryFrame = 0x2,
|
|
|
|
XdgSurfaceGeometryBuffer = 0x4,
|
|
|
|
};
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceClient::XdgSurfaceClient(XdgSurfaceInterface *shellSurface)
|
|
|
|
: WaylandClient(shellSurface->surface())
|
|
|
|
, m_shellSurface(shellSurface)
|
|
|
|
, m_configureTimer(new QTimer(this))
|
2016-04-18 09:55:40 +00:00
|
|
|
{
|
2015-03-04 08:21:10 +00:00
|
|
|
setupCompositing();
|
2019-09-15 09:54:50 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(shellSurface, &XdgSurfaceInterface::configureAcknowledged,
|
|
|
|
this, &XdgSurfaceClient::handleConfigureAcknowledged);
|
2020-05-07 14:29:41 +00:00
|
|
|
connect(shellSurface, &XdgSurfaceInterface::resetOccurred,
|
|
|
|
this, &XdgSurfaceClient::destroyClient);
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::committed,
|
|
|
|
this, &XdgSurfaceClient::handleCommit);
|
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::shadowChanged,
|
|
|
|
this, &XdgSurfaceClient::updateShadow);
|
2020-05-07 14:29:41 +00:00
|
|
|
#if 0 // TODO: Refactor kwin core in order to uncomment this code.
|
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::mapped,
|
|
|
|
this, &XdgSurfaceClient::setReadyForPainting);
|
|
|
|
#endif
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::unbound,
|
|
|
|
this, &XdgSurfaceClient::destroyClient);
|
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::destroyed,
|
|
|
|
this, &XdgSurfaceClient::destroyClient);
|
2019-09-15 09:54:50 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
// The effective window geometry is determined by two things: (a) the rectangle that bounds
|
|
|
|
// the main surface and all of its sub-surfaces, (b) the client-specified window geometry, if
|
|
|
|
// any. If the client hasn't provided the window geometry, we fallback to the bounding sub-
|
|
|
|
// surface rectangle. If the client has provided the window geometry, we intersect it with
|
|
|
|
// the bounding rectangle and that will be the effective window geometry. It's worth to point
|
|
|
|
// out that geometry updates do not occur that frequently, so we don't need to recompute the
|
|
|
|
// bounding geometry every time the client commits the surface.
|
2018-10-05 14:27:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
SubSurfaceMonitor *treeMonitor = new SubSurfaceMonitor(surface(), this);
|
2015-07-15 09:24:19 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(treeMonitor, &SubSurfaceMonitor::subSurfaceAdded,
|
|
|
|
this, &XdgSurfaceClient::setHaveNextWindowGeometry);
|
|
|
|
connect(treeMonitor, &SubSurfaceMonitor::subSurfaceRemoved,
|
|
|
|
this, &XdgSurfaceClient::setHaveNextWindowGeometry);
|
|
|
|
connect(treeMonitor, &SubSurfaceMonitor::subSurfaceMoved,
|
|
|
|
this, &XdgSurfaceClient::setHaveNextWindowGeometry);
|
|
|
|
connect(treeMonitor, &SubSurfaceMonitor::subSurfaceResized,
|
|
|
|
this, &XdgSurfaceClient::setHaveNextWindowGeometry);
|
|
|
|
connect(shellSurface, &XdgSurfaceInterface::windowGeometryChanged,
|
|
|
|
this, &XdgSurfaceClient::setHaveNextWindowGeometry);
|
|
|
|
connect(surface(), &SurfaceInterface::sizeChanged,
|
|
|
|
this, &XdgSurfaceClient::setHaveNextWindowGeometry);
|
2017-10-07 12:09:07 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
// Configure events are not sent immediately, but rather scheduled to be sent when the event
|
|
|
|
// loop is about to be idle. By doing this, we can avoid sending configure events that do
|
|
|
|
// nothing, and implementation-wise, it's simpler.
|
2015-09-11 10:11:01 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
m_configureTimer->setSingleShot(true);
|
|
|
|
connect(m_configureTimer, &QTimer::timeout, this, &XdgSurfaceClient::sendConfigure);
|
2015-12-17 14:47:36 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
// Unfortunately, AbstractClient::checkWorkspacePosition() operates on the geometry restore
|
|
|
|
// so we need to initialize it with some reasonable value; otherwise bad things will happen
|
|
|
|
// when we want to decorate the client or move the client to another screen. This is a hack.
|
2019-09-26 15:20:36 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(this, &XdgSurfaceClient::frameGeometryChanged,
|
|
|
|
this, &XdgSurfaceClient::updateGeometryRestoreHack);
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceClient::~XdgSurfaceClient()
|
2019-09-15 11:26:33 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
qDeleteAll(m_configureEvents);
|
2019-02-26 13:41:07 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::requestedFrameGeometry() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_requestedFrameGeometry;
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QPoint XdgSurfaceClient::requestedPos() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_requestedFrameGeometry.topLeft();
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QSize XdgSurfaceClient::requestedSize() const
|
2020-01-16 20:15:24 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_requestedFrameGeometry.size();
|
2020-01-16 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::requestedClientGeometry() const
|
2019-05-17 14:13:54 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_requestedClientGeometry;
|
2019-05-17 14:13:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::inputGeometry() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return isDecorated() ? AbstractClient::inputGeometry() : bufferGeometry();
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::bufferGeometry() const
|
2015-12-08 09:11:26 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_bufferGeometry;
|
2015-12-08 09:11:26 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QSize XdgSurfaceClient::requestedClientSize() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return requestedClientGeometry().size();
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::clientGeometry() const
|
2020-02-12 10:43:30 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_clientGeometry;
|
2020-02-12 10:43:30 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QMatrix4x4 XdgSurfaceClient::inputTransformation() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
QMatrix4x4 transformation;
|
|
|
|
transformation.translate(-m_bufferGeometry.x(), -m_bufferGeometry.y());
|
|
|
|
return transformation;
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceConfigure *XdgSurfaceClient::lastAcknowledgedConfigure() const
|
2019-02-27 10:52:44 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_lastAcknowledgedConfigure.data();
|
2019-02-27 10:52:44 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgSurfaceClient::stateCompare() const
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_requestedFrameGeometry != m_frameGeometry) {
|
|
|
|
return true;
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_requestedClientGeometry != m_clientGeometry) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (m_requestedClientGeometry.isEmpty()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::scheduleConfigure()
|
2015-03-16 08:13:19 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isClosing()) {
|
2016-02-18 07:27:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-09-29 08:44:47 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (stateCompare()) {
|
|
|
|
m_configureTimer->start();
|
|
|
|
} else {
|
|
|
|
m_configureTimer->stop();
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::sendConfigure()
|
2015-07-09 07:10:33 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceConfigure *configureEvent = sendRoleConfigure();
|
2015-12-17 14:47:36 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (configureEvent->position != pos()) {
|
|
|
|
configureEvent->presentFields |= XdgSurfaceConfigure::PositionField;
|
2016-07-04 13:06:20 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (configureEvent->size != size()) {
|
|
|
|
configureEvent->presentFields |= XdgSurfaceConfigure::SizeField;
|
2016-06-03 11:37:24 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
m_configureEvents.append(configureEvent);
|
2015-07-09 07:10:33 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::handleConfigureAcknowledged(quint32 serial)
|
2015-12-17 14:47:36 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
while (!m_configureEvents.isEmpty()) {
|
|
|
|
if (serial < m_configureEvents.first()->serial) {
|
|
|
|
break;
|
2019-06-22 15:13:43 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
m_lastAcknowledgedConfigure.reset(m_configureEvents.takeFirst());
|
2019-01-01 17:37:18 +00:00
|
|
|
}
|
2015-12-17 14:47:36 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::handleCommit()
|
2015-10-13 08:52:01 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (!surface()->buffer()) {
|
2017-11-22 16:33:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-09-26 15:14:42 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (haveNextWindowGeometry()) {
|
|
|
|
handleNextWindowGeometry();
|
|
|
|
resetHaveNextWindowGeometry();
|
2017-11-22 16:33:21 +00:00
|
|
|
}
|
2019-09-26 15:14:42 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
handleRoleCommit();
|
|
|
|
m_lastAcknowledgedConfigure.reset();
|
2019-04-09 10:13:38 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
setReadyForPainting();
|
2020-02-17 18:39:17 +00:00
|
|
|
updateDepth();
|
2015-10-13 08:52:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::handleRoleCommit()
|
2019-10-03 19:43:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::handleNextWindowGeometry()
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
const QRect boundingGeometry = surface()->boundingRect();
|
2019-10-03 19:43:28 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
// The effective window geometry is defined as the intersection of the window geometry
|
|
|
|
// and the rectangle that bounds the main surface and all of its sub-surfaces. If the
|
|
|
|
// client hasn't specified the window geometry, we must fallback to the bounding geometry.
|
|
|
|
// Note that the xdg-shell spec is not clear about when exactly we have to clamp the
|
|
|
|
// window geometry.
|
2019-10-03 19:43:28 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
m_windowGeometry = m_shellSurface->windowGeometry();
|
|
|
|
if (m_windowGeometry.isValid()) {
|
|
|
|
m_windowGeometry &= boundingGeometry;
|
|
|
|
} else {
|
|
|
|
m_windowGeometry = boundingGeometry;
|
2015-08-20 07:38:19 +00:00
|
|
|
}
|
2019-07-09 17:28:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_windowGeometry.isEmpty()) {
|
|
|
|
qCWarning(KWIN_CORE) << "Committed empty window geometry, dealing with a buggy client!";
|
2019-10-03 19:43:28 +00:00
|
|
|
}
|
2015-10-14 10:11:56 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect frameGeometry(pos(), clientSizeToFrameSize(m_windowGeometry.size()));
|
2015-10-14 10:11:56 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
// We're not done yet. The xdg-shell spec allows clients to attach buffers smaller than
|
|
|
|
// we asked. Normally, this is not a big deal, but when the client is being interactively
|
|
|
|
// resized, it may cause the window contents to bounce. In order to counter this, we have
|
|
|
|
// to "gravitate" the new geometry according to the current move-resize pointer mode so
|
|
|
|
// the opposite window corner stays still.
|
|
|
|
|
|
|
|
if (isMoveResize()) {
|
|
|
|
frameGeometry = adjustMoveResizeGeometry(frameGeometry);
|
|
|
|
} else if (lastAcknowledgedConfigure()) {
|
|
|
|
XdgSurfaceConfigure *configureEvent = lastAcknowledgedConfigure();
|
|
|
|
|
|
|
|
if (configureEvent->presentFields & XdgSurfaceConfigure::PositionField) {
|
|
|
|
frameGeometry.moveTopLeft(configureEvent->position);
|
2019-10-03 19:43:28 +00:00
|
|
|
}
|
2016-06-10 08:50:02 +00:00
|
|
|
}
|
2019-10-03 19:43:28 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
updateGeometry(frameGeometry);
|
2017-01-29 13:30:43 +00:00
|
|
|
|
|
|
|
if (isResize()) {
|
|
|
|
performMoveResize();
|
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgSurfaceClient::haveNextWindowGeometry() const
|
2019-10-03 19:43:28 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_haveNextWindowGeometry || m_lastAcknowledgedConfigure;
|
2019-10-03 19:43:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::setHaveNextWindowGeometry()
|
2015-03-04 08:21:10 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_haveNextWindowGeometry = true;
|
2015-03-04 08:21:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::resetHaveNextWindowGeometry()
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_haveNextWindowGeometry = false;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::adjustMoveResizeGeometry(const QRect &rect) const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect geometry = rect;
|
2015-03-16 08:14:04 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
switch (moveResizePointerMode()) {
|
|
|
|
case PositionTopLeft:
|
|
|
|
geometry.moveRight(moveResizeGeometry().right());
|
|
|
|
geometry.moveBottom(moveResizeGeometry().bottom());
|
|
|
|
break;
|
|
|
|
case PositionTop:
|
|
|
|
case PositionTopRight:
|
|
|
|
geometry.moveLeft(moveResizeGeometry().left());
|
|
|
|
geometry.moveBottom(moveResizeGeometry().bottom());
|
|
|
|
break;
|
|
|
|
case PositionRight:
|
|
|
|
case PositionBottomRight:
|
|
|
|
case PositionBottom:
|
|
|
|
case PositionCenter:
|
|
|
|
geometry.moveLeft(moveResizeGeometry().left());
|
|
|
|
geometry.moveTop(moveResizeGeometry().top());
|
|
|
|
break;
|
|
|
|
case PositionBottomLeft:
|
|
|
|
case PositionLeft:
|
|
|
|
geometry.moveRight(moveResizeGeometry().right());
|
|
|
|
geometry.moveTop(moveResizeGeometry().top());
|
|
|
|
break;
|
|
|
|
}
|
2019-09-15 09:41:21 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
return geometry;
|
2019-09-15 09:41:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
/**
|
|
|
|
* Sets the frame geometry of the XdgSurfaceClient to \a rect.
|
|
|
|
*
|
|
|
|
* Because geometry updates are asynchronous on Wayland, there are no any guarantees that
|
|
|
|
* the frame geometry will be changed immediately. We may need to send a configure event to
|
|
|
|
* the client if the current window geometry size and the requested window geometry size
|
|
|
|
* don't match. frameGeometryChanged() will be emitted when the requested frame geometry
|
|
|
|
* has been applied.
|
|
|
|
*
|
|
|
|
* Notice that the client may attach a buffer smaller than the one in the configure event.
|
|
|
|
*/
|
|
|
|
void XdgSurfaceClient::setFrameGeometry(const QRect &rect, ForceGeometry_t force)
|
|
|
|
{
|
|
|
|
m_requestedFrameGeometry = rect;
|
|
|
|
|
|
|
|
// XdgToplevelClient currently doesn't support shaded clients, but let's stick with
|
|
|
|
// what X11Client does. Hopefully, one day we will be able to unify setFrameGeometry()
|
|
|
|
// for all AbstractClient subclasses. It's going to be great!
|
|
|
|
|
|
|
|
if (isShade()) {
|
|
|
|
if (m_requestedFrameGeometry.height() == borderTop() + borderBottom()) {
|
|
|
|
qCDebug(KWIN_CORE) << "Passed shaded frame geometry to setFrameGeometry()";
|
|
|
|
} else {
|
|
|
|
m_requestedClientGeometry = frameRectToClientRect(m_requestedFrameGeometry);
|
|
|
|
m_requestedFrameGeometry.setHeight(borderTop() + borderBottom());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m_requestedClientGeometry = frameRectToClientRect(m_requestedFrameGeometry);
|
2017-08-20 06:56:13 +00:00
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (areGeometryUpdatesBlocked()) {
|
|
|
|
m_frameGeometry = m_requestedFrameGeometry;
|
|
|
|
if (pendingGeometryUpdate() == PendingGeometryForced) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (force == ForceGeometrySet) {
|
|
|
|
setPendingGeometryUpdate(PendingGeometryForced);
|
|
|
|
} else {
|
|
|
|
setPendingGeometryUpdate(PendingGeometryNormal);
|
|
|
|
}
|
|
|
|
return;
|
2016-05-09 12:48:10 +00:00
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
m_frameGeometry = frameGeometryBeforeUpdateBlocking();
|
|
|
|
|
|
|
|
// Notice that the window geometry size of (0, 0) has special meaning to xdg shell clients.
|
|
|
|
// It basically says "pick whatever size you think is the best, dawg."
|
|
|
|
|
|
|
|
if (requestedClientSize() != clientSize()) {
|
|
|
|
requestGeometry(requestedFrameGeometry());
|
|
|
|
} else {
|
|
|
|
updateGeometry(requestedFrameGeometry());
|
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::move(int x, int y, ForceGeometry_t force)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
Q_ASSERT(pendingGeometryUpdate() == PendingGeometryNone || areGeometryUpdatesBlocked());
|
|
|
|
QPoint p(x, y);
|
|
|
|
if (!areGeometryUpdatesBlocked() && p != rules()->checkPosition(p)) {
|
|
|
|
qCDebug(KWIN_CORE) << "forced position fail:" << p << ":" << rules()->checkPosition(p);
|
2015-06-11 23:20:31 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
m_requestedFrameGeometry.moveTopLeft(p);
|
|
|
|
m_requestedClientGeometry.moveTopLeft(framePosToClientPos(p));
|
|
|
|
if (force == NormalGeometrySet && m_frameGeometry.topLeft() == p) {
|
|
|
|
return;
|
2016-04-22 12:13:37 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
m_frameGeometry.moveTopLeft(m_requestedFrameGeometry.topLeft());
|
|
|
|
if (areGeometryUpdatesBlocked()) {
|
|
|
|
if (pendingGeometryUpdate() == PendingGeometryForced) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (force == ForceGeometrySet) {
|
|
|
|
setPendingGeometryUpdate(PendingGeometryForced);
|
|
|
|
} else {
|
|
|
|
setPendingGeometryUpdate(PendingGeometryNormal);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_clientGeometry.moveTopLeft(m_requestedClientGeometry.topLeft());
|
|
|
|
m_bufferGeometry = frameRectToBufferRect(m_frameGeometry);
|
|
|
|
updateWindowRules(Rules::Position);
|
|
|
|
screens()->setCurrent(this);
|
|
|
|
workspace()->updateStackingOrder();
|
|
|
|
emit frameGeometryChanged(this, frameGeometryBeforeUpdateBlocking());
|
|
|
|
addRepaintDuringGeometryUpdates();
|
|
|
|
updateGeometryBeforeUpdateBlocking();
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::requestGeometry(const QRect &rect)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_requestedFrameGeometry = rect;
|
|
|
|
m_requestedClientGeometry = frameRectToClientRect(rect);
|
|
|
|
|
|
|
|
scheduleConfigure(); // Send the configure event later.
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::updateGeometry(const QRect &rect)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-06-01 10:43:49 +00:00
|
|
|
const QRect oldClientGeometry = m_clientGeometry;
|
2020-02-17 18:39:17 +00:00
|
|
|
const QRect oldFrameGeometry = m_frameGeometry;
|
2020-06-01 10:43:49 +00:00
|
|
|
const QRect oldBufferGeometry = m_bufferGeometry;
|
2020-02-17 18:39:17 +00:00
|
|
|
|
2020-06-01 10:43:49 +00:00
|
|
|
m_clientGeometry = frameRectToClientRect(rect);
|
2020-02-17 18:39:17 +00:00
|
|
|
m_frameGeometry = rect;
|
|
|
|
m_bufferGeometry = frameRectToBufferRect(rect);
|
|
|
|
|
2020-06-01 10:43:49 +00:00
|
|
|
uint changedGeometries = 0;
|
|
|
|
|
|
|
|
if (m_clientGeometry != oldClientGeometry) {
|
|
|
|
changedGeometries |= XdgSurfaceGeometryClient;
|
|
|
|
}
|
|
|
|
if (m_frameGeometry != oldFrameGeometry) {
|
|
|
|
changedGeometries |= XdgSurfaceGeometryFrame;
|
|
|
|
}
|
|
|
|
if (m_bufferGeometry != oldBufferGeometry) {
|
|
|
|
changedGeometries |= XdgSurfaceGeometryBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!changedGeometries) {
|
2020-02-17 18:39:17 +00:00
|
|
|
return;
|
2019-07-09 18:07:21 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
updateWindowRules(Rules::Position | Rules::Size);
|
|
|
|
updateGeometryBeforeUpdateBlocking();
|
|
|
|
|
2020-06-01 10:43:49 +00:00
|
|
|
if (changedGeometries & XdgSurfaceGeometryClient) {
|
|
|
|
emit clientGeometryChanged(this, oldClientGeometry);
|
|
|
|
}
|
|
|
|
if (changedGeometries & XdgSurfaceGeometryFrame) {
|
|
|
|
emit frameGeometryChanged(this, oldFrameGeometry);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
emit geometryShapeChanged(this, oldFrameGeometry);
|
|
|
|
|
|
|
|
addRepaintDuringGeometryUpdates();
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
* \todo We have to check the current frame geometry in checkWorskpacePosition().
|
|
|
|
*
|
|
|
|
* Sets the geometry restore to the first valid frame geometry. This is a HACK!
|
|
|
|
*
|
|
|
|
* Unfortunately, AbstractClient::checkWorkspacePosition() operates on the geometry restore
|
|
|
|
* rather than the current frame geometry, so we have to ensure that it's initialized with
|
|
|
|
* some reasonable value even if the client is not maximized or quick tiled.
|
|
|
|
*/
|
|
|
|
void XdgSurfaceClient::updateGeometryRestoreHack()
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-05-07 14:29:41 +00:00
|
|
|
if (geometryRestore().isEmpty() && !frameGeometry().isEmpty()) {
|
2020-02-17 18:39:17 +00:00
|
|
|
setGeometryRestore(frameGeometry());
|
2019-07-09 12:05:32 +00:00
|
|
|
}
|
2015-11-05 10:30:02 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::updateDepth()
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (surface()->buffer()->hasAlphaChannel() && !isDesktop()) {
|
|
|
|
setDepth(32);
|
|
|
|
} else {
|
|
|
|
setDepth(24);
|
2016-04-22 12:13:37 +00:00
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgSurfaceClient::frameRectToBufferRect(const QRect &rect) const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
const int left = rect.left() + borderLeft() - m_windowGeometry.left();
|
|
|
|
const int top = rect.top() + borderTop() - m_windowGeometry.top();
|
|
|
|
return QRect(QPoint(left, top), surface()->size());
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::addDamage(const QRegion &damage)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
const int offsetX = m_bufferGeometry.x() - m_frameGeometry.x();
|
|
|
|
const int offsetY = m_bufferGeometry.y() - m_frameGeometry.y();
|
|
|
|
repaints_region += damage.translated(offsetX, offsetY);
|
|
|
|
Toplevel::addDamage(damage);
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgSurfaceClient::isShown(bool shaded_is_shown) const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(shaded_is_shown)
|
2020-05-07 14:29:41 +00:00
|
|
|
return !isClosing() && !isHidden() && !isMinimized();
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgSurfaceClient::isHiddenInternal() const
|
2019-09-15 09:41:21 +00:00
|
|
|
{
|
2020-05-07 14:29:41 +00:00
|
|
|
return isHidden();
|
2019-09-15 09:41:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::hideClient(bool hide)
|
2015-05-23 07:02:11 +00:00
|
|
|
{
|
2016-10-11 14:24:10 +00:00
|
|
|
if (hide) {
|
2020-02-17 18:39:17 +00:00
|
|
|
internalHide();
|
2016-10-11 14:24:10 +00:00
|
|
|
} else {
|
2020-02-17 18:39:17 +00:00
|
|
|
internalShow();
|
2016-10-11 14:24:10 +00:00
|
|
|
}
|
2015-05-23 07:02:11 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgSurfaceClient::isHidden() const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_isHidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgSurfaceClient::internalShow()
|
|
|
|
{
|
|
|
|
if (!isHidden()) {
|
2016-06-09 12:37:32 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
m_isHidden = false;
|
|
|
|
addRepaintFull();
|
|
|
|
emit windowShown(this);
|
|
|
|
}
|
2016-09-16 12:27:50 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::internalHide()
|
|
|
|
{
|
|
|
|
if (isHidden()) {
|
2016-09-16 12:27:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isMoveResize()) {
|
|
|
|
leaveMoveResize();
|
|
|
|
}
|
|
|
|
m_isHidden = true;
|
|
|
|
addWorkspaceRepaint(visibleRect());
|
|
|
|
workspace()->clientHidden(this);
|
|
|
|
emit windowHidden(this);
|
|
|
|
}
|
2016-09-16 12:27:50 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgSurfaceClient::isClosing() const
|
|
|
|
{
|
|
|
|
return m_isClosing;
|
|
|
|
}
|
2019-07-08 09:44:26 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::destroyClient()
|
|
|
|
{
|
|
|
|
m_isClosing = true;
|
|
|
|
m_configureTimer->stop();
|
|
|
|
if (isMoveResize()) {
|
|
|
|
leaveMoveResize();
|
|
|
|
}
|
|
|
|
cleanTabBox();
|
|
|
|
Deleted *deleted = Deleted::create(this);
|
|
|
|
emit windowClosed(this, deleted);
|
2019-07-09 17:28:05 +00:00
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
2020-02-17 18:39:17 +00:00
|
|
|
RuleBook::self()->discardUsed(this, true);
|
|
|
|
destroyWindowManagementInterface();
|
|
|
|
destroyDecoration();
|
|
|
|
cleanGrouping();
|
|
|
|
waylandServer()->removeClient(this);
|
|
|
|
deleted->unrefWindow();
|
|
|
|
delete this;
|
|
|
|
}
|
2019-07-09 17:28:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::cleanGrouping()
|
|
|
|
{
|
|
|
|
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;
|
2016-06-09 12:37:32 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
2016-06-09 14:50:48 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgSurfaceClient::cleanTabBox()
|
|
|
|
{
|
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
|
|
|
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
|
|
|
if (tabBox->isDisplayed() && tabBox->currentClient() == this) {
|
|
|
|
tabBox->nextPrev(true);
|
2016-11-25 15:45:40 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
#endif
|
|
|
|
}
|
2016-09-16 12:27:50 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgToplevelClient::XdgToplevelClient(XdgToplevelInterface *shellSurface)
|
|
|
|
: XdgSurfaceClient(shellSurface->xdgSurface())
|
|
|
|
, m_shellSurface(shellSurface)
|
|
|
|
{
|
|
|
|
setupWindowManagementIntegration();
|
|
|
|
setupPlasmaShellIntegration();
|
|
|
|
setDesktop(VirtualDesktopManager::self()->current());
|
|
|
|
|
|
|
|
if (waylandServer()->inputMethodConnection() == surface()->client()) {
|
|
|
|
m_windowType = NET::OnScreenDisplay;
|
2016-09-16 12:27:50 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(shellSurface, &XdgToplevelInterface::windowTitleChanged,
|
|
|
|
this, &XdgToplevelClient::handleWindowTitleChanged);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::windowClassChanged,
|
|
|
|
this, &XdgToplevelClient::handleWindowClassChanged);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::windowMenuRequested,
|
|
|
|
this, &XdgToplevelClient::handleWindowMenuRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::moveRequested,
|
|
|
|
this, &XdgToplevelClient::handleMoveRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::resizeRequested,
|
|
|
|
this, &XdgToplevelClient::handleResizeRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::maximizeRequested,
|
|
|
|
this, &XdgToplevelClient::handleMaximizeRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::unmaximizeRequested,
|
|
|
|
this, &XdgToplevelClient::handleUnmaximizeRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::fullscreenRequested,
|
|
|
|
this, &XdgToplevelClient::handleFullscreenRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::unfullscreenRequested,
|
|
|
|
this, &XdgToplevelClient::handleUnfullscreenRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::minimizeRequested,
|
|
|
|
this, &XdgToplevelClient::handleMinimizeRequested);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::parentXdgToplevelChanged,
|
|
|
|
this, &XdgToplevelClient::handleTransientForChanged);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::initializeRequested,
|
|
|
|
this, &XdgToplevelClient::initialize);
|
|
|
|
connect(shellSurface, &XdgToplevelInterface::destroyed,
|
|
|
|
this, &XdgToplevelClient::destroyClient);
|
|
|
|
connect(shellSurface->shell(), &XdgShellInterface::pingTimeout,
|
|
|
|
this, &XdgToplevelClient::handlePingTimeout);
|
|
|
|
connect(shellSurface->shell(), &XdgShellInterface::pingDelayed,
|
|
|
|
this, &XdgToplevelClient::handlePingDelayed);
|
|
|
|
connect(shellSurface->shell(), &XdgShellInterface::pongReceived,
|
|
|
|
this, &XdgToplevelClient::handlePongReceived);
|
2016-09-16 12:27:50 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(waylandServer(), &WaylandServer::foreignTransientChanged,
|
|
|
|
this, &XdgToplevelClient::handleForeignTransientForChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
XdgToplevelClient::~XdgToplevelClient()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
XdgToplevelInterface *XdgToplevelClient::shellSurface() const
|
|
|
|
{
|
|
|
|
return m_shellSurface;
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::debug(QDebug &stream) const
|
|
|
|
{
|
2020-06-19 08:32:15 +00:00
|
|
|
stream << "XdgToplevelClient:" << resourceClass() << caption();
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
NET::WindowType XdgToplevelClient::windowType(bool direct, int supported_types) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(direct)
|
|
|
|
Q_UNUSED(supported_types)
|
|
|
|
return m_windowType;
|
|
|
|
}
|
|
|
|
|
|
|
|
MaximizeMode XdgToplevelClient::maximizeMode() const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2015-06-07 01:28:38 +00:00
|
|
|
return m_maximizeMode;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
MaximizeMode XdgToplevelClient::requestedMaximizeMode() const
|
2018-10-07 16:51:42 +00:00
|
|
|
{
|
|
|
|
return m_requestedMaximizeMode;
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QSize XdgToplevelClient::minSize() const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return rules()->checkMinSize(m_shellSurface->minimumSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize XdgToplevelClient::maxSize() const
|
|
|
|
{
|
|
|
|
return rules()->checkMaxSize(m_shellSurface->maximumSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::isFullScreen() const
|
|
|
|
{
|
|
|
|
return m_isFullScreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::isMovable() const
|
|
|
|
{
|
|
|
|
if (isFullScreen()) {
|
|
|
|
return false;
|
2015-12-17 14:47:36 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isSpecialWindow() && !isSplash() && !isToolbar()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (rules()->checkPosition(invalidPoint) != invalidPoint) {
|
|
|
|
return false;
|
2019-01-01 17:37:18 +00:00
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isMovableAcrossScreens() const
|
2019-01-09 14:20:19 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isSpecialWindow() && !isSplash() && !isToolbar()) {
|
2019-01-09 14:20:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (rules()->checkPosition(invalidPoint) != invalidPoint) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2019-01-09 14:20:19 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isResizable() const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isFullScreen()) {
|
|
|
|
return false;
|
2019-01-09 19:49:10 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isSpecialWindow() || isSplash() || isToolbar()) {
|
|
|
|
return false;
|
2019-01-09 19:49:10 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (rules()->checkSize(QSize()).isValid()) {
|
|
|
|
return false;
|
2019-01-09 19:49:10 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
const QSize min = minSize();
|
|
|
|
const QSize max = maxSize();
|
|
|
|
return min.width() < max.width() || min.height() < max.height();
|
|
|
|
}
|
2019-01-09 19:49:10 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isCloseable() const
|
|
|
|
{
|
|
|
|
return !isDesktop() && !isDock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::isFullScreenable() const
|
|
|
|
{
|
|
|
|
if (!rules()->checkFullScreen(true)) {
|
|
|
|
return false;
|
2018-11-16 11:59:33 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
return !isSpecialWindow();
|
|
|
|
}
|
2019-01-09 19:49:10 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isMaximizable() const
|
|
|
|
{
|
|
|
|
if (!isResizable()) {
|
|
|
|
return false;
|
2017-10-07 09:41:17 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (rules()->checkMaximize(MaximizeRestore) != MaximizeRestore ||
|
|
|
|
rules()->checkMaximize(MaximizeFull) != MaximizeFull) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2019-01-09 19:49:10 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isMinimizable() const
|
|
|
|
{
|
|
|
|
if (isSpecialWindow() && !isTransient()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!rules()->checkMinimize(true)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2019-01-09 19:49:10 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isTransient() const
|
|
|
|
{
|
|
|
|
return m_isTransient;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::userCanSetFullScreen() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::userCanSetNoBorder() const
|
|
|
|
{
|
|
|
|
if (m_serverDecoration) {
|
|
|
|
switch (m_serverDecoration->mode()) {
|
|
|
|
case ServerSideDecorationManagerInterface::Mode::Server:
|
|
|
|
return !isFullScreen() && !isShade();
|
|
|
|
case ServerSideDecorationManagerInterface::Mode::Client:
|
|
|
|
case ServerSideDecorationManagerInterface::Mode::None:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_xdgDecoration) {
|
|
|
|
switch (m_xdgDecoration->preferredMode()) {
|
|
|
|
case XdgToplevelDecorationV1Interface::Mode::Server:
|
|
|
|
case XdgToplevelDecorationV1Interface::Mode::Undefined:
|
|
|
|
return !isFullScreen() && !isShade();
|
|
|
|
case XdgToplevelDecorationV1Interface::Mode::Client:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::noBorder() const
|
|
|
|
{
|
|
|
|
if (m_serverDecoration) {
|
|
|
|
switch (m_serverDecoration->mode()) {
|
|
|
|
case ServerSideDecorationManagerInterface::Mode::Server:
|
|
|
|
return m_userNoBorder || isFullScreen();
|
|
|
|
case ServerSideDecorationManagerInterface::Mode::Client:
|
|
|
|
case ServerSideDecorationManagerInterface::Mode::None:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_xdgDecoration) {
|
|
|
|
switch (m_xdgDecoration->preferredMode()) {
|
|
|
|
case XdgToplevelDecorationV1Interface::Mode::Server:
|
|
|
|
case XdgToplevelDecorationV1Interface::Mode::Undefined:
|
|
|
|
return m_userNoBorder || isFullScreen();
|
|
|
|
case XdgToplevelDecorationV1Interface::Mode::Client:
|
|
|
|
return true;
|
2017-10-07 09:41:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
return true;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::setNoBorder(bool set)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2015-12-17 14:47:36 +00:00
|
|
|
if (!userCanSetNoBorder()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
set = rules()->checkNoBorder(set);
|
|
|
|
if (m_userNoBorder == set) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_userNoBorder = set;
|
|
|
|
updateDecoration(true, false);
|
|
|
|
updateWindowRules(Rules::NoBorder);
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::updateDecoration(bool check_workspace_pos, bool force)
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (!force && ((!isDecorated() && noBorder()) || (isDecorated() && !noBorder()))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QRect oldFrameGeometry = frameGeometry();
|
|
|
|
const QRect oldClientGeometry = clientGeometry();
|
|
|
|
blockGeometryUpdates(true);
|
|
|
|
if (force) {
|
|
|
|
destroyDecoration();
|
|
|
|
}
|
|
|
|
if (!noBorder()) {
|
|
|
|
createDecoration(oldFrameGeometry);
|
|
|
|
} else {
|
|
|
|
destroyDecoration();
|
|
|
|
}
|
|
|
|
if (m_serverDecoration && isDecorated()) {
|
|
|
|
m_serverDecoration->setMode(ServerSideDecorationManagerInterface::Mode::Server);
|
|
|
|
}
|
|
|
|
if (m_xdgDecoration) {
|
|
|
|
if (isDecorated() || m_userNoBorder) {
|
|
|
|
m_xdgDecoration->sendConfigure(XdgToplevelDecorationV1Interface::Mode::Server);
|
|
|
|
} else {
|
|
|
|
m_xdgDecoration->sendConfigure(XdgToplevelDecorationV1Interface::Mode::Client);
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
scheduleConfigure();
|
2015-07-09 18:43:41 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
updateShadow();
|
|
|
|
if (check_workspace_pos) {
|
|
|
|
checkWorkspacePosition(oldFrameGeometry, -2, oldClientGeometry);
|
2019-02-27 10:52:44 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
blockGeometryUpdates(false);
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::supportsWindowRules() const
|
2015-07-07 14:15:58 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return !m_plasmaShellSurface;
|
2015-07-07 14:15:58 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::hasStrut() const
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (!isShown(true)) {
|
|
|
|
return false;
|
2017-10-07 09:41:17 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (!m_plasmaShellSurface) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_plasmaShellSurface->role() != PlasmaShellSurfaceInterface::Role::Panel) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AlwaysVisible;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::showOnScreenEdge()
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-05-07 14:29:41 +00:00
|
|
|
if (!m_plasmaShellSurface) {
|
2020-02-17 18:39:17 +00:00
|
|
|
return;
|
2015-12-17 15:11:15 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
hideClient(false);
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
if (m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide) {
|
|
|
|
m_plasmaShellSurface->showAutoHidingPanel();
|
2019-01-01 17:37:18 +00:00
|
|
|
}
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::isInitialPositionSet() const
|
2015-12-07 15:18:30 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return m_plasmaShellSurface ? m_plasmaShellSurface->isPositionSet() : false;
|
2015-12-07 15:18:30 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::closeWindow()
|
2015-03-16 08:14:04 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isCloseable()) {
|
|
|
|
sendPing(PingReason::CloseWindow);
|
|
|
|
m_shellSurface->sendClose();
|
2015-06-13 02:06:12 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
2019-12-23 12:04:59 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceConfigure *XdgToplevelClient::sendRoleConfigure() const
|
|
|
|
{
|
|
|
|
const quint32 serial = m_shellSurface->sendConfigure(requestedClientSize(), m_requestedStates);
|
|
|
|
|
|
|
|
XdgToplevelConfigure *configureEvent = new XdgToplevelConfigure();
|
|
|
|
configureEvent->position = requestedPos();
|
|
|
|
configureEvent->size = requestedSize();
|
|
|
|
configureEvent->states = m_requestedStates;
|
|
|
|
configureEvent->serial = serial;
|
|
|
|
|
|
|
|
return configureEvent;
|
2015-03-16 08:14:04 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::stateCompare() const
|
2015-05-18 12:51:40 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_requestedStates != m_acknowledgedStates) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return XdgSurfaceClient::stateCompare();
|
2015-05-18 12:51:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleRoleCommit()
|
2017-05-13 15:02:30 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
auto configureEvent = static_cast<XdgToplevelConfigure *>(lastAcknowledgedConfigure());
|
|
|
|
if (configureEvent) {
|
|
|
|
handleStatesAcknowledged(configureEvent->states);
|
|
|
|
}
|
2017-05-13 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::doMinimize()
|
2015-11-06 14:08:13 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isMinimized()) {
|
|
|
|
workspace()->clientHidden(this);
|
|
|
|
} else {
|
|
|
|
emit windowShown(this);
|
|
|
|
}
|
|
|
|
workspace()->updateMinimizedOfTransients(this);
|
2015-11-06 14:08:13 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::doResizeSync()
|
2015-11-06 14:08:13 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
requestGeometry(moveResizeGeometry());
|
2015-11-06 14:08:13 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::doSetActive()
|
2015-05-19 10:03:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
WaylandClient::doSetActive();
|
|
|
|
|
|
|
|
if (isActive()) {
|
|
|
|
m_requestedStates |= XdgToplevelInterface::State::Activated;
|
|
|
|
} else {
|
|
|
|
m_requestedStates &= ~XdgToplevelInterface::State::Activated;
|
2016-06-09 14:54:06 +00:00
|
|
|
}
|
2018-10-05 14:27:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
scheduleConfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::doSetFullScreen()
|
|
|
|
{
|
|
|
|
if (isFullScreen()) {
|
|
|
|
m_requestedStates |= XdgToplevelInterface::State::FullScreen;
|
2019-02-26 13:40:54 +00:00
|
|
|
} else {
|
2020-02-17 18:39:17 +00:00
|
|
|
m_requestedStates &= ~XdgToplevelInterface::State::FullScreen;
|
2019-02-26 13:40:54 +00:00
|
|
|
}
|
2018-10-10 11:03:22 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
scheduleConfigure();
|
|
|
|
}
|
2019-02-26 13:40:54 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::doSetMaximized()
|
|
|
|
{
|
|
|
|
if (requestedMaximizeMode() & MaximizeHorizontal) {
|
|
|
|
m_requestedStates |= XdgToplevelInterface::State::MaximizedHorizontal;
|
|
|
|
} else {
|
|
|
|
m_requestedStates &= ~XdgToplevelInterface::State::MaximizedHorizontal;
|
2016-04-18 11:33:23 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
if (requestedMaximizeMode() & MaximizeVertical) {
|
|
|
|
m_requestedStates |= XdgToplevelInterface::State::MaximizedVertical;
|
|
|
|
} else {
|
|
|
|
m_requestedStates &= ~XdgToplevelInterface::State::MaximizedVertical;
|
XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.
Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.
But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.
Also integrate pinging clients
Test Plan: gtk3-demo works nicely.
Reviewers: #plasma, graesslin, mart
Reviewed By: #plasma, graesslin
Subscribers: mart, graesslin, kwin, plasma-devel, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 15:37:59 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
scheduleConfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::doStartMoveResize()
|
|
|
|
{
|
|
|
|
if (moveResizePointerMode() != PositionCenter) {
|
|
|
|
m_requestedStates |= XdgToplevelInterface::State::Resizing;
|
2019-02-26 13:40:54 +00:00
|
|
|
}
|
2018-10-05 14:27:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
scheduleConfigure();
|
|
|
|
return true;
|
2015-05-19 10:03:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::doFinishMoveResize()
|
2018-10-05 14:27:05 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_requestedStates &= ~XdgToplevelInterface::State::Resizing;
|
|
|
|
scheduleConfigure();
|
|
|
|
}
|
2018-10-05 14:27:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::takeFocus()
|
|
|
|
{
|
|
|
|
if (wantsInput()) {
|
|
|
|
sendPing(PingReason::FocusWindow);
|
|
|
|
setActive(true);
|
2020-01-23 21:40:34 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (!keepAbove() && !isOnScreenDisplay() && !belongsToDesktop()) {
|
|
|
|
workspace()->setShowingDesktop(false);
|
2020-01-23 21:40:34 +00:00
|
|
|
}
|
2018-10-05 14:27:05 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::wantsInput() const
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return rules()->checkAcceptFocus(acceptsFocus());
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgToplevelClient::dockWantsInput() const
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_plasmaShellSurface) {
|
|
|
|
if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Panel) {
|
|
|
|
return m_plasmaShellSurface->panelTakesFocus();
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::acceptsFocus() const
|
|
|
|
{
|
|
|
|
if (isInputMethod()) {
|
|
|
|
return false;
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_plasmaShellSurface) {
|
|
|
|
if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::OnScreenDisplay ||
|
|
|
|
m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::ToolTip) {
|
|
|
|
return false;
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Notification ||
|
|
|
|
m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::CriticalNotification) {
|
|
|
|
return m_plasmaShellSurface->panelTakesFocus();
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-07 14:29:41 +00:00
|
|
|
return !isClosing() && readyForPainting();
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
Layer XdgToplevelClient::layerForDock() const
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_plasmaShellSurface) {
|
|
|
|
switch (m_plasmaShellSurface->panelBehavior()) {
|
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::WindowsCanCover:
|
|
|
|
return NormalLayer;
|
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::AutoHide:
|
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::WindowsGoBelow:
|
2020-06-02 13:51:05 +00:00
|
|
|
return AboveLayer;
|
2020-02-17 18:39:17 +00:00
|
|
|
case PlasmaShellSurfaceInterface::PanelBehavior::AlwaysVisible:
|
|
|
|
return DockLayer;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
return AbstractClient::layerForDock();
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleWindowTitleChanged()
|
2019-10-03 19:43:28 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
setCaption(m_shellSurface->windowTitle());
|
2019-10-03 19:43:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleWindowClassChanged()
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
const QByteArray applicationId = m_shellSurface->windowClass().toUtf8();
|
|
|
|
setResourceClass(resourceName(), applicationId);
|
|
|
|
if (shellSurface()->isConfigured() && supportsWindowRules()) {
|
|
|
|
evaluateWindowRules();
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
setDesktopFileName(applicationId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleWindowMenuRequested(SeatInterface *seat, const QPoint &surfacePos,
|
|
|
|
quint32 serial)
|
|
|
|
{
|
|
|
|
Q_UNUSED(seat)
|
|
|
|
Q_UNUSED(serial)
|
|
|
|
performMouseCommand(Options::MouseOperationsMenu, pos() + surfacePos);
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleMoveRequested(SeatInterface *seat, quint32 serial)
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(seat)
|
|
|
|
Q_UNUSED(serial)
|
2020-04-02 16:18:01 +00:00
|
|
|
performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos());
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleResizeRequested(SeatInterface *seat, Qt::Edges edges, quint32 serial)
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(seat)
|
|
|
|
Q_UNUSED(serial)
|
|
|
|
if (!isResizable() || isShade()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (isMoveResize()) {
|
|
|
|
finishMoveResize(false);
|
|
|
|
}
|
|
|
|
setMoveResizePointerButtonDown(true);
|
2020-04-02 16:18:01 +00:00
|
|
|
setMoveOffset(Cursors::self()->mouse()->pos() - pos()); // map from global
|
2019-09-15 10:54:53 +00:00
|
|
|
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
|
|
|
setUnrestrictedMoveResize(false);
|
|
|
|
auto toPosition = [edges] {
|
|
|
|
Position position = PositionCenter;
|
|
|
|
if (edges.testFlag(Qt::TopEdge)) {
|
|
|
|
position = PositionTop;
|
|
|
|
} else if (edges.testFlag(Qt::BottomEdge)) {
|
|
|
|
position = PositionBottom;
|
|
|
|
}
|
|
|
|
if (edges.testFlag(Qt::LeftEdge)) {
|
|
|
|
position = Position(position | PositionLeft);
|
|
|
|
} else if (edges.testFlag(Qt::RightEdge)) {
|
|
|
|
position = Position(position | PositionRight);
|
|
|
|
}
|
|
|
|
return position;
|
|
|
|
};
|
|
|
|
setMoveResizePointerMode(toPosition());
|
|
|
|
if (!startMoveResize()) {
|
|
|
|
setMoveResizePointerButtonDown(false);
|
|
|
|
}
|
|
|
|
updateCursor();
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleStatesAcknowledged(const XdgToplevelInterface::States &states)
|
|
|
|
{
|
|
|
|
const XdgToplevelInterface::States delta = m_acknowledgedStates ^ states;
|
|
|
|
|
|
|
|
if (delta & XdgToplevelInterface::State::Maximized) {
|
|
|
|
MaximizeMode maximizeMode = MaximizeRestore;
|
|
|
|
if (states & XdgToplevelInterface::State::MaximizedHorizontal) {
|
|
|
|
maximizeMode = MaximizeMode(maximizeMode | MaximizeHorizontal);
|
|
|
|
}
|
|
|
|
if (states & XdgToplevelInterface::State::MaximizedVertical) {
|
|
|
|
maximizeMode = MaximizeMode(maximizeMode | MaximizeVertical);
|
|
|
|
}
|
|
|
|
updateMaximizeMode(maximizeMode);
|
|
|
|
}
|
|
|
|
if (delta & XdgToplevelInterface::State::FullScreen) {
|
|
|
|
updateFullScreenMode(states & XdgToplevelInterface::State::FullScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_acknowledgedStates = states;
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleMaximizeRequested()
|
|
|
|
{
|
2020-06-26 09:14:38 +00:00
|
|
|
if (m_isInitialized) {
|
|
|
|
maximize(MaximizeFull);
|
|
|
|
scheduleConfigure();
|
|
|
|
} else {
|
|
|
|
m_initialStates |= XdgToplevelInterface::State::Maximized;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleUnmaximizeRequested()
|
|
|
|
{
|
2020-06-26 09:14:38 +00:00
|
|
|
if (m_isInitialized) {
|
|
|
|
maximize(MaximizeRestore);
|
|
|
|
scheduleConfigure();
|
|
|
|
} else {
|
|
|
|
m_initialStates &= ~XdgToplevelInterface::State::Maximized;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleFullscreenRequested(OutputInterface *output)
|
|
|
|
{
|
|
|
|
Q_UNUSED(output)
|
2020-06-26 09:14:38 +00:00
|
|
|
if (m_isInitialized) {
|
|
|
|
setFullScreen(/* set */ true, /* user */ false);
|
|
|
|
scheduleConfigure();
|
|
|
|
} else {
|
|
|
|
m_initialStates |= XdgToplevelInterface::State::FullScreen;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleUnfullscreenRequested()
|
|
|
|
{
|
2020-06-26 09:14:38 +00:00
|
|
|
if (m_isInitialized) {
|
|
|
|
setFullScreen(/* set */ false, /* user */ false);
|
|
|
|
scheduleConfigure();
|
|
|
|
} else {
|
|
|
|
m_initialStates &= ~XdgToplevelInterface::State::FullScreen;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleMinimizeRequested()
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-04-02 16:18:01 +00:00
|
|
|
performMouseCommand(Options::MouseMinimize, Cursors::self()->mouse()->pos());
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::handleTransientForChanged()
|
|
|
|
{
|
|
|
|
SurfaceInterface *transientForSurface = nullptr;
|
|
|
|
if (XdgToplevelInterface *parentToplevel = m_shellSurface->parentXdgToplevel()) {
|
|
|
|
transientForSurface = parentToplevel->surface();
|
|
|
|
}
|
|
|
|
if (!transientForSurface) {
|
|
|
|
transientForSurface = waylandServer()->findForeignTransientForSurface(surface());
|
|
|
|
}
|
|
|
|
AbstractClient *transientForClient = waylandServer()->findClient(transientForSurface);
|
|
|
|
if (transientForClient != transientFor()) {
|
|
|
|
if (transientFor()) {
|
|
|
|
transientFor()->removeTransient(this);
|
|
|
|
}
|
|
|
|
if (transientForClient) {
|
|
|
|
transientForClient->addTransient(this);
|
|
|
|
}
|
|
|
|
setTransientFor(transientForClient);
|
|
|
|
}
|
|
|
|
m_isTransient = transientForClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handleForeignTransientForChanged(SurfaceInterface *child)
|
|
|
|
{
|
|
|
|
if (surface() == child) {
|
|
|
|
handleTransientForChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handlePingTimeout(quint32 serial)
|
|
|
|
{
|
|
|
|
auto pingIt = m_pings.find(serial);
|
|
|
|
if (pingIt == m_pings.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (pingIt.value() == PingReason::CloseWindow) {
|
|
|
|
qCDebug(KWIN_CORE) << "Final ping timeout on a close attempt, asking to kill:" << caption();
|
|
|
|
|
|
|
|
//for internal windows, killing the window will delete this
|
|
|
|
QPointer<QObject> guard(this);
|
|
|
|
killWindow();
|
|
|
|
if (!guard) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_pings.erase(pingIt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handlePingDelayed(quint32 serial)
|
|
|
|
{
|
|
|
|
auto it = m_pings.find(serial);
|
|
|
|
if (it != m_pings.end()) {
|
|
|
|
qCDebug(KWIN_CORE) << "First ping timeout:" << caption();
|
|
|
|
setUnresponsive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::handlePongReceived(quint32 serial)
|
|
|
|
{
|
|
|
|
auto it = m_pings.find(serial);
|
|
|
|
if (it != m_pings.end()) {
|
|
|
|
setUnresponsive(false);
|
|
|
|
m_pings.erase(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XdgToplevelClient::sendPing(PingReason reason)
|
|
|
|
{
|
|
|
|
XdgShellInterface *shell = m_shellSurface->shell();
|
|
|
|
XdgSurfaceInterface *surface = m_shellSurface->xdgSurface();
|
|
|
|
|
|
|
|
const quint32 serial = shell->ping(surface);
|
|
|
|
m_pings.insert(serial, reason);
|
|
|
|
}
|
|
|
|
|
2020-06-26 09:14:38 +00:00
|
|
|
MaximizeMode XdgToplevelClient::initialMaximizeMode() const
|
|
|
|
{
|
|
|
|
MaximizeMode maximizeMode = MaximizeRestore;
|
|
|
|
if (m_initialStates & XdgToplevelInterface::State::MaximizedHorizontal) {
|
|
|
|
maximizeMode = MaximizeMode(maximizeMode | MaximizeHorizontal);
|
|
|
|
}
|
|
|
|
if (m_initialStates & XdgToplevelInterface::State::MaximizedVertical) {
|
|
|
|
maximizeMode = MaximizeMode(maximizeMode | MaximizeVertical);
|
|
|
|
}
|
|
|
|
return maximizeMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgToplevelClient::initialFullScreenMode() const
|
|
|
|
{
|
|
|
|
return m_initialStates & XdgToplevelInterface::State::FullScreen;
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::initialize()
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
blockGeometryUpdates(true);
|
|
|
|
|
|
|
|
bool needsPlacement = !isInitialPositionSet();
|
|
|
|
|
|
|
|
if (supportsWindowRules()) {
|
|
|
|
setupWindowRules(false);
|
|
|
|
|
|
|
|
const QRect originalGeometry = frameGeometry();
|
|
|
|
const QRect ruledGeometry = rules()->checkGeometry(originalGeometry, true);
|
|
|
|
if (originalGeometry != ruledGeometry) {
|
|
|
|
setFrameGeometry(ruledGeometry);
|
|
|
|
}
|
2020-06-26 09:14:38 +00:00
|
|
|
maximize(rules()->checkMaximize(initialMaximizeMode(), true));
|
|
|
|
setFullScreen(rules()->checkFullScreen(initialFullScreenMode(), true), false);
|
2020-02-17 18:39:17 +00:00
|
|
|
setDesktop(rules()->checkDesktop(desktop(), true));
|
|
|
|
setDesktopFileName(rules()->checkDesktopFile(desktopFileName(), true).toUtf8());
|
|
|
|
if (rules()->checkMinimize(isMinimized(), true)) {
|
|
|
|
minimize(true); // No animation.
|
|
|
|
}
|
|
|
|
setSkipTaskbar(rules()->checkSkipTaskbar(skipTaskbar(), true));
|
|
|
|
setSkipPager(rules()->checkSkipPager(skipPager(), true));
|
|
|
|
setSkipSwitcher(rules()->checkSkipSwitcher(skipSwitcher(), true));
|
|
|
|
setKeepAbove(rules()->checkKeepAbove(keepAbove(), true));
|
|
|
|
setKeepBelow(rules()->checkKeepBelow(keepBelow(), true));
|
|
|
|
setShortcut(rules()->checkShortcut(shortcut().toString(), true));
|
|
|
|
|
|
|
|
// Don't place the client if its position is set by a rule.
|
|
|
|
if (rules()->checkPosition(invalidPoint, true) != invalidPoint) {
|
|
|
|
needsPlacement = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't place the client if the maximize state is set by a rule.
|
|
|
|
if (requestedMaximizeMode() != MaximizeRestore) {
|
|
|
|
needsPlacement = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
discardTemporaryRules();
|
|
|
|
RuleBook::self()->discardUsed(this, false); // Remove Apply Now rules.
|
|
|
|
updateWindowRules(Rules::All);
|
|
|
|
}
|
|
|
|
if (isFullScreen()) {
|
|
|
|
needsPlacement = false;
|
|
|
|
}
|
|
|
|
if (needsPlacement) {
|
|
|
|
const QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop());
|
|
|
|
placeIn(area);
|
|
|
|
}
|
2019-09-15 10:54:53 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
blockGeometryUpdates(false);
|
|
|
|
scheduleConfigure();
|
|
|
|
updateColorScheme();
|
2020-06-26 09:14:38 +00:00
|
|
|
m_isInitialized = true;
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::updateMaximizeMode(MaximizeMode maximizeMode)
|
2015-05-19 10:03:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_maximizeMode == maximizeMode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_maximizeMode = maximizeMode;
|
|
|
|
updateWindowRules(Rules::MaximizeVert | Rules::MaximizeHoriz);
|
|
|
|
emit clientMaximizedStateChanged(this, maximizeMode);
|
|
|
|
emit clientMaximizedStateChanged(this, maximizeMode & MaximizeHorizontal, maximizeMode & MaximizeVertical);
|
2015-05-19 10:03:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::updateFullScreenMode(bool set)
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_isFullScreen == set) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_isFullScreen = set;
|
|
|
|
updateWindowRules(Rules::Fullscreen);
|
|
|
|
emit fullScreenChanged();
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::updateColorScheme()
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_paletteInterface) {
|
|
|
|
AbstractClient::updateColorScheme(rules()->checkDecoColor(m_paletteInterface->palette()));
|
|
|
|
} else {
|
|
|
|
AbstractClient::updateColorScheme(rules()->checkDecoColor(QString()));
|
|
|
|
}
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::installAppMenu(AppMenuInterface *appMenu)
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_appMenuInterface = appMenu;
|
|
|
|
|
|
|
|
auto updateMenu = [this](const AppMenuInterface::InterfaceAddress &address) {
|
|
|
|
updateApplicationMenuServiceName(address.serviceName);
|
|
|
|
updateApplicationMenuObjectPath(address.objectPath);
|
|
|
|
};
|
|
|
|
connect(m_appMenuInterface, &AppMenuInterface::addressChanged, this, updateMenu);
|
|
|
|
updateMenu(appMenu->address());
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::installServerDecoration(ServerSideDecorationInterface *decoration)
|
2019-09-15 10:54:53 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_serverDecoration = decoration;
|
2019-09-15 10:54:53 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(m_serverDecoration, &ServerSideDecorationInterface::destroyed, this, [this] {
|
2020-05-07 14:29:41 +00:00
|
|
|
if (!isClosing() && readyForPainting()) {
|
2020-02-17 18:39:17 +00:00
|
|
|
updateDecoration(/* check_workspace_pos */ true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
connect(m_serverDecoration, &ServerSideDecorationInterface::modeRequested, this,
|
|
|
|
[this] (ServerSideDecorationManagerInterface::Mode mode) {
|
|
|
|
const bool changed = mode != m_serverDecoration->mode();
|
2020-05-07 14:29:41 +00:00
|
|
|
if (changed && readyForPainting()) {
|
2020-02-17 18:39:17 +00:00
|
|
|
updateDecoration(/* check_workspace_pos */ false);
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
);
|
2020-05-07 14:29:41 +00:00
|
|
|
if (readyForPainting()) {
|
2020-02-17 18:39:17 +00:00
|
|
|
updateDecoration(/* check_workspace_pos */ true);
|
2019-09-15 10:54:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::installXdgDecoration(XdgToplevelDecorationV1Interface *decoration)
|
2019-09-26 15:02:09 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_xdgDecoration = decoration;
|
2019-09-26 15:02:09 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(m_xdgDecoration, &XdgToplevelDecorationV1Interface::destroyed, this, [this] {
|
|
|
|
if (!isClosing()) {
|
|
|
|
updateDecoration(/* check_workspace_pos */ true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
connect(m_xdgDecoration, &XdgToplevelDecorationV1Interface::preferredModeChanged, this, [this] {
|
|
|
|
// force is true as we must send a new configure response.
|
|
|
|
updateDecoration(/* check_workspace_pos */ false, /* force */ true);
|
|
|
|
});
|
2019-09-26 15:02:09 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::installPalette(ServerSideDecorationPaletteInterface *palette)
|
2015-05-27 09:48:33 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_paletteInterface = palette;
|
2015-05-27 09:48:33 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
auto updatePalette = [this](const QString &palette) {
|
|
|
|
AbstractClient::updateColorScheme(rules()->checkDecoColor(palette));
|
|
|
|
};
|
|
|
|
connect(m_paletteInterface, &ServerSideDecorationPaletteInterface::paletteChanged, this, [=](const QString &palette) {
|
|
|
|
updatePalette(palette);
|
|
|
|
});
|
|
|
|
connect(m_paletteInterface, &QObject::destroyed, this, [=]() {
|
|
|
|
updatePalette(QString());
|
|
|
|
});
|
|
|
|
updatePalette(palette->palette());
|
2015-06-03 19:19:00 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
/**
|
|
|
|
* \todo This whole plasma shell surface thing doesn't seem right. It turns xdg-toplevel into
|
|
|
|
* something completely different! Perhaps plasmashell surfaces need to be implemented via a
|
|
|
|
* proprietary protocol that doesn't piggyback on existing shell surface protocols. It'll lead
|
|
|
|
* to cleaner code and will be technically correct, but I'm not sure whether this is do-able.
|
|
|
|
*/
|
|
|
|
void XdgToplevelClient::installPlasmaShellSurface(PlasmaShellSurfaceInterface *shellSurface)
|
2015-06-09 17:10:56 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
m_plasmaShellSurface = shellSurface;
|
|
|
|
|
|
|
|
auto updatePosition = [this, shellSurface] { move(shellSurface->position()); };
|
|
|
|
auto updateRole = [this, shellSurface] {
|
2015-06-09 17:10:56 +00:00
|
|
|
NET::WindowType type = NET::Unknown;
|
2020-02-17 18:39:17 +00:00
|
|
|
switch (shellSurface->role()) {
|
2015-06-09 17:10:56 +00:00
|
|
|
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;
|
2016-06-17 07:46:16 +00:00
|
|
|
case PlasmaShellSurfaceInterface::Role::Notification:
|
|
|
|
type = NET::Notification;
|
|
|
|
break;
|
2016-06-28 11:25:15 +00:00
|
|
|
case PlasmaShellSurfaceInterface::Role::ToolTip:
|
|
|
|
type = NET::Tooltip;
|
|
|
|
break;
|
2019-05-02 08:29:38 +00:00
|
|
|
case PlasmaShellSurfaceInterface::Role::CriticalNotification:
|
|
|
|
type = NET::CriticalNotification;
|
|
|
|
break;
|
2015-06-09 17:10:56 +00:00
|
|
|
case PlasmaShellSurfaceInterface::Role::Normal:
|
|
|
|
default:
|
|
|
|
type = NET::Normal;
|
|
|
|
break;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (m_windowType == type) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_windowType = type;
|
|
|
|
switch (m_windowType) {
|
|
|
|
case NET::Desktop:
|
|
|
|
case NET::Dock:
|
|
|
|
case NET::OnScreenDisplay:
|
|
|
|
case NET::Notification:
|
|
|
|
case NET::CriticalNotification:
|
|
|
|
case NET::Tooltip:
|
|
|
|
setOnAllDesktops(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
workspace()->updateClientArea();
|
2015-06-09 17:10:56 +00:00
|
|
|
};
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::positionChanged, this, updatePosition);
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::roleChanged, this, updateRole);
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::panelBehaviorChanged, this, [this] {
|
|
|
|
updateShowOnScreenEdge();
|
|
|
|
workspace()->updateClientArea();
|
|
|
|
});
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::panelAutoHideHideRequested, this, [this] {
|
|
|
|
hideClient(true);
|
|
|
|
m_plasmaShellSurface->hideAutoHidingPanel();
|
|
|
|
updateShowOnScreenEdge();
|
|
|
|
});
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::panelAutoHideShowRequested, this, [this] {
|
|
|
|
hideClient(false);
|
|
|
|
ScreenEdges::self()->reserve(this, ElectricNone);
|
|
|
|
m_plasmaShellSurface->showAutoHidingPanel();
|
|
|
|
});
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::panelTakesFocusChanged, this, [this] {
|
|
|
|
if (m_plasmaShellSurface->panelTakesFocus()) {
|
2019-12-20 13:22:42 +00:00
|
|
|
workspace()->activateClient(this);
|
|
|
|
}
|
|
|
|
});
|
2020-02-17 18:39:17 +00:00
|
|
|
if (shellSurface->isPositionSet()) {
|
2020-03-30 12:49:43 +00:00
|
|
|
updatePosition();
|
2020-02-17 18:39:17 +00:00
|
|
|
}
|
2015-06-09 17:10:56 +00:00
|
|
|
updateRole();
|
2016-09-15 19:03:40 +00:00
|
|
|
updateShowOnScreenEdge();
|
2020-02-17 18:39:17 +00:00
|
|
|
connect(this, &XdgToplevelClient::frameGeometryChanged,
|
|
|
|
this, &XdgToplevelClient::updateShowOnScreenEdge);
|
|
|
|
connect(this, &XdgToplevelClient::windowShown,
|
|
|
|
this, &XdgToplevelClient::updateShowOnScreenEdge);
|
2015-09-29 18:25:04 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
setSkipTaskbar(shellSurface->skipTaskbar());
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::skipTaskbarChanged, this, [this] {
|
2015-09-29 18:25:04 +00:00
|
|
|
setSkipTaskbar(m_plasmaShellSurface->skipTaskbar());
|
|
|
|
});
|
2018-05-24 04:33:39 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
setSkipSwitcher(shellSurface->skipSwitcher());
|
|
|
|
connect(shellSurface, &PlasmaShellSurfaceInterface::skipSwitcherChanged, this, [this] {
|
2018-05-24 04:33:39 +00:00
|
|
|
setSkipSwitcher(m_plasmaShellSurface->skipSwitcher());
|
|
|
|
});
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::updateShowOnScreenEdge()
|
2016-09-15 19:03:40 +00:00
|
|
|
{
|
|
|
|
if (!ScreenEdges::self()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-05-07 14:29:41 +00:00
|
|
|
if (!readyForPainting() || !m_plasmaShellSurface ||
|
2020-02-17 18:39:17 +00:00
|
|
|
m_plasmaShellSurface->role() != PlasmaShellSurfaceInterface::Role::Panel) {
|
2016-09-15 19:03:40 +00:00
|
|
|
ScreenEdges::self()->reserve(this, ElectricNone);
|
|
|
|
return;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
const PlasmaShellSurfaceInterface::PanelBehavior panelBehavior = m_plasmaShellSurface->panelBehavior();
|
|
|
|
if ((panelBehavior == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide && isHidden()) ||
|
|
|
|
panelBehavior == PlasmaShellSurfaceInterface::PanelBehavior::WindowsCanCover) {
|
|
|
|
// Screen edge API requires an edge, thus we need to figure out which edge the window borders.
|
2019-09-27 10:01:10 +00:00
|
|
|
const QRect clientGeometry = frameGeometry();
|
2016-09-15 19:03:40 +00:00
|
|
|
Qt::Edges edges;
|
|
|
|
for (int i = 0; i < screens()->count(); i++) {
|
2019-08-10 14:31:06 +00:00
|
|
|
const QRect screenGeometry = screens()->geometry(i);
|
|
|
|
if (screenGeometry.left() == clientGeometry.left()) {
|
2016-09-15 19:03:40 +00:00
|
|
|
edges |= Qt::LeftEdge;
|
|
|
|
}
|
2019-08-10 14:31:06 +00:00
|
|
|
if (screenGeometry.right() == clientGeometry.right()) {
|
2016-09-15 19:03:40 +00:00
|
|
|
edges |= Qt::RightEdge;
|
|
|
|
}
|
2019-08-10 14:31:06 +00:00
|
|
|
if (screenGeometry.top() == clientGeometry.top()) {
|
2016-09-15 19:03:40 +00:00
|
|
|
edges |= Qt::TopEdge;
|
|
|
|
}
|
2019-08-10 14:31:06 +00:00
|
|
|
if (screenGeometry.bottom() == clientGeometry.bottom()) {
|
2016-09-15 19:03:40 +00:00
|
|
|
edges |= Qt::BottomEdge;
|
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
// A panel might border multiple screen edges. E.g. a horizontal panel at the bottom will
|
|
|
|
// also border the left and right edge. Let's remove such cases.
|
|
|
|
if (edges & Qt::LeftEdge && edges & Qt::RightEdge) {
|
2016-09-15 19:03:40 +00:00
|
|
|
edges = edges & (~(Qt::LeftEdge | Qt::RightEdge));
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (edges & Qt::TopEdge && edges & Qt::BottomEdge) {
|
2016-09-15 19:03:40 +00:00
|
|
|
edges = edges & (~(Qt::TopEdge | Qt::BottomEdge));
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
|
|
|
|
// It's still possible that a panel borders two edges, e.g. bottom and left
|
|
|
|
// in that case the one which is sharing more with the edge wins.
|
|
|
|
auto check = [clientGeometry](Qt::Edges edges, Qt::Edge horizontal, Qt::Edge vertical) {
|
|
|
|
if (edges & horizontal && edges & vertical) {
|
2019-08-10 14:31:06 +00:00
|
|
|
if (clientGeometry.width() >= clientGeometry.height()) {
|
2020-02-17 18:39:17 +00:00
|
|
|
return edges & ~horizontal;
|
2016-09-15 19:03:40 +00:00
|
|
|
} else {
|
2020-02-17 18:39:17 +00:00
|
|
|
return edges & ~vertical;
|
2016-09-15 19:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return edges;
|
|
|
|
};
|
|
|
|
edges = check(edges, Qt::LeftEdge, Qt::TopEdge);
|
|
|
|
edges = check(edges, Qt::LeftEdge, Qt::BottomEdge);
|
|
|
|
edges = check(edges, Qt::RightEdge, Qt::TopEdge);
|
|
|
|
edges = check(edges, Qt::RightEdge, Qt::BottomEdge);
|
|
|
|
|
|
|
|
ElectricBorder border = ElectricNone;
|
2020-02-17 18:39:17 +00:00
|
|
|
if (edges & Qt::LeftEdge) {
|
2016-09-15 19:03:40 +00:00
|
|
|
border = ElectricLeft;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (edges & Qt::RightEdge) {
|
2016-09-15 19:03:40 +00:00
|
|
|
border = ElectricRight;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (edges & Qt::TopEdge) {
|
2016-09-15 19:03:40 +00:00
|
|
|
border = ElectricTop;
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (edges & Qt::BottomEdge) {
|
2016-09-15 19:03:40 +00:00
|
|
|
border = ElectricBottom;
|
|
|
|
}
|
|
|
|
ScreenEdges::self()->reserve(this, border);
|
|
|
|
} else {
|
|
|
|
ScreenEdges::self()->reserve(this, ElectricNone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::setupWindowManagementIntegration()
|
2015-06-09 17:10:56 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (isLockScreen()) {
|
|
|
|
return;
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
2020-05-07 14:29:41 +00:00
|
|
|
connect(surface(), &SurfaceInterface::mapped,
|
2020-02-17 18:39:17 +00:00
|
|
|
this, &XdgToplevelClient::setupWindowManagementInterface);
|
2015-06-09 17:10:56 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::setupPlasmaShellIntegration()
|
2017-12-22 14:22:24 +00:00
|
|
|
{
|
2020-05-07 14:29:41 +00:00
|
|
|
connect(surface(), &SurfaceInterface::mapped,
|
2020-02-17 18:39:17 +00:00
|
|
|
this, &XdgToplevelClient::updateShowOnScreenEdge);
|
|
|
|
}
|
2017-12-22 14:22:24 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgToplevelClient::setFullScreen(bool set, bool user)
|
|
|
|
{
|
|
|
|
set = rules()->checkFullScreen(set);
|
|
|
|
|
|
|
|
const bool wasFullscreen = isFullScreen();
|
|
|
|
if (wasFullscreen == set) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (isSpecialWindow()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (user && !userCanSetFullScreen()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wasFullscreen) {
|
|
|
|
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event
|
|
|
|
} else {
|
|
|
|
m_fullScreenGeometryRestore = frameGeometry();
|
|
|
|
}
|
|
|
|
m_isFullScreen = set;
|
|
|
|
|
|
|
|
if (set) {
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
}
|
|
|
|
StackingUpdatesBlocker blocker1(workspace());
|
|
|
|
GeometryUpdatesBlocker blocker2(this);
|
|
|
|
|
|
|
|
workspace()->updateClientLayer(this); // active fullscreens get different layer
|
|
|
|
updateDecoration(false, false);
|
|
|
|
|
|
|
|
if (set) {
|
|
|
|
setFrameGeometry(workspace()->clientArea(FullScreenArea, this));
|
|
|
|
} else {
|
|
|
|
if (m_fullScreenGeometryRestore.isValid()) {
|
|
|
|
int currentScreen = screen();
|
|
|
|
setFrameGeometry(QRect(m_fullScreenGeometryRestore.topLeft(),
|
|
|
|
constrainFrameSize(m_fullScreenGeometryRestore.size())));
|
|
|
|
if( currentScreen != screen())
|
|
|
|
workspace()->sendClientToScreen( this, currentScreen );
|
|
|
|
} else {
|
|
|
|
// this can happen when the window was first shown already fullscreen,
|
|
|
|
// so let the client set the size by itself
|
|
|
|
setFrameGeometry(QRect(workspace()->clientArea(PlacementArea, this).topLeft(), QSize(0, 0)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
doSetFullScreen();
|
|
|
|
|
|
|
|
updateWindowRules(Rules::Fullscreen|Rules::Position|Rules::Size);
|
|
|
|
emit fullScreenChanged();
|
2017-12-22 14:22:24 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
/**
|
|
|
|
* \todo Move to AbstractClient.
|
|
|
|
*/
|
|
|
|
static bool changeMaximizeRecursion = false;
|
|
|
|
void XdgToplevelClient::changeMaximize(bool horizontal, bool vertical, bool adjust)
|
2018-01-04 18:32:18 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
if (changeMaximizeRecursion) {
|
|
|
|
return;
|
|
|
|
}
|
2018-01-04 18:32:18 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (!isResizable()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QRect clientArea = isElectricBorderMaximizing() ?
|
|
|
|
workspace()->clientArea(MaximizeArea, Cursors::self()->mouse()->pos(), desktop()) :
|
|
|
|
workspace()->clientArea(MaximizeArea, this);
|
|
|
|
|
|
|
|
const MaximizeMode oldMode = m_requestedMaximizeMode;
|
|
|
|
const QRect oldGeometry = frameGeometry();
|
|
|
|
|
|
|
|
// 'adjust == true' means to update the size only, e.g. after changing workspace size
|
|
|
|
if (!adjust) {
|
|
|
|
if (vertical)
|
|
|
|
m_requestedMaximizeMode = MaximizeMode(m_requestedMaximizeMode ^ MaximizeVertical);
|
|
|
|
if (horizontal)
|
|
|
|
m_requestedMaximizeMode = MaximizeMode(m_requestedMaximizeMode ^ MaximizeHorizontal);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_requestedMaximizeMode = rules()->checkMaximize(m_requestedMaximizeMode);
|
|
|
|
if (!adjust && m_requestedMaximizeMode == oldMode) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
|
|
|
|
|
|
|
// call into decoration update borders
|
|
|
|
if (isDecorated() && decoration()->client() && !(options->borderlessMaximizedWindows() && m_requestedMaximizeMode == KWin::MaximizeFull)) {
|
|
|
|
changeMaximizeRecursion = true;
|
|
|
|
const auto c = decoration()->client().toStrongRef();
|
|
|
|
if ((m_requestedMaximizeMode & MaximizeVertical) != (oldMode & MaximizeVertical)) {
|
|
|
|
emit c->maximizedVerticallyChanged(m_requestedMaximizeMode & MaximizeVertical);
|
|
|
|
}
|
|
|
|
if ((m_requestedMaximizeMode & MaximizeHorizontal) != (oldMode & MaximizeHorizontal)) {
|
|
|
|
emit c->maximizedHorizontallyChanged(m_requestedMaximizeMode & MaximizeHorizontal);
|
|
|
|
}
|
|
|
|
if ((m_requestedMaximizeMode == MaximizeFull) != (oldMode == MaximizeFull)) {
|
|
|
|
emit c->maximizedChanged(m_requestedMaximizeMode & MaximizeFull);
|
|
|
|
}
|
|
|
|
changeMaximizeRecursion = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options->borderlessMaximizedWindows()) {
|
|
|
|
// triggers a maximize change.
|
|
|
|
// The next setNoBorder interation will exit since there's no change but the first recursion pullutes the restore geometry
|
|
|
|
changeMaximizeRecursion = true;
|
|
|
|
setNoBorder(rules()->checkNoBorder(m_requestedMaximizeMode == MaximizeFull));
|
|
|
|
changeMaximizeRecursion = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Conditional quick tiling exit points
|
|
|
|
const auto oldQuickTileMode = quickTileMode();
|
|
|
|
if (quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
|
|
|
|
if (oldMode == MaximizeFull &&
|
|
|
|
!clientArea.contains(geometryRestore().center())) {
|
|
|
|
// Not restoring on the same screen
|
|
|
|
// TODO: The following doesn't work for some reason
|
|
|
|
//quick_tile_mode = QuickTileNone; // And exit quick tile mode manually
|
|
|
|
} else if ((oldMode == MaximizeVertical && m_requestedMaximizeMode == MaximizeRestore) ||
|
|
|
|
(oldMode == MaximizeFull && m_requestedMaximizeMode == MaximizeHorizontal)) {
|
|
|
|
// Modifying geometry of a tiled window
|
|
|
|
updateQuickTileMode(QuickTileFlag::None); // Exit quick tile mode without restoring geometry
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_requestedMaximizeMode == MaximizeFull) {
|
|
|
|
setGeometryRestore(oldGeometry);
|
|
|
|
// TODO: Client has more checks
|
|
|
|
if (options->electricBorderMaximize()) {
|
|
|
|
updateQuickTileMode(QuickTileFlag::Maximize);
|
|
|
|
} else {
|
|
|
|
updateQuickTileMode(QuickTileFlag::None);
|
|
|
|
}
|
|
|
|
if (quickTileMode() != oldQuickTileMode) {
|
|
|
|
emit quickTileModeChanged();
|
|
|
|
}
|
|
|
|
setFrameGeometry(workspace()->clientArea(MaximizeArea, this));
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
} else {
|
|
|
|
if (m_requestedMaximizeMode == MaximizeRestore) {
|
|
|
|
updateQuickTileMode(QuickTileFlag::None);
|
|
|
|
}
|
|
|
|
if (quickTileMode() != oldQuickTileMode) {
|
|
|
|
emit quickTileModeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (geometryRestore().isValid()) {
|
|
|
|
setFrameGeometry(geometryRestore());
|
|
|
|
} else {
|
|
|
|
setFrameGeometry(workspace()->clientArea(PlacementArea, this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
doSetMaximized();
|
|
|
|
}
|
|
|
|
|
|
|
|
XdgPopupClient::XdgPopupClient(XdgPopupInterface *shellSurface)
|
|
|
|
: XdgSurfaceClient(shellSurface->xdgSurface())
|
|
|
|
, m_shellSurface(shellSurface)
|
|
|
|
{
|
|
|
|
setDesktop(VirtualDesktopManager::self()->current());
|
|
|
|
|
|
|
|
connect(shellSurface, &XdgPopupInterface::grabRequested,
|
|
|
|
this, &XdgPopupClient::handleGrabRequested);
|
|
|
|
connect(shellSurface, &XdgPopupInterface::initializeRequested,
|
|
|
|
this, &XdgPopupClient::initialize);
|
|
|
|
connect(shellSurface, &XdgPopupInterface::destroyed,
|
|
|
|
this, &XdgPopupClient::destroyClient);
|
|
|
|
|
|
|
|
// The xdg-shell spec states that the parent xdg-surface may be null if it is specified
|
|
|
|
// via "some other protocol," but we don't support any such protocol yet. Notice that the
|
|
|
|
// xdg-foreign protocol is only for toplevel surfaces.
|
|
|
|
|
|
|
|
XdgSurfaceInterface *parentShellSurface = shellSurface->parentXdgSurface();
|
|
|
|
AbstractClient *parentClient = waylandServer()->findClient(parentShellSurface->surface());
|
|
|
|
parentClient->addTransient(this);
|
|
|
|
setTransientFor(parentClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
XdgPopupClient::~XdgPopupClient()
|
|
|
|
{
|
2018-01-04 18:32:18 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::debug(QDebug &stream) const
|
2017-10-01 14:38:57 +00:00
|
|
|
{
|
2020-06-19 08:32:20 +00:00
|
|
|
stream << "XdgPopupClient: transientFor:" << transientFor();
|
2017-10-01 14:38:57 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
NET::WindowType XdgPopupClient::windowType(bool direct, int supported_types) const
|
[wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.
This patch splits the requested, pending and current state, updating as
appropriate.
Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.
X code is untouched.
This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.
Test Plan:
Maximised a window with the button and double clicking title bar.
I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true
19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false
BUG: 382698
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 14:36:02 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
Q_UNUSED(direct)
|
|
|
|
Q_UNUSED(supported_types)
|
|
|
|
return NET::Normal;
|
|
|
|
}
|
[wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.
This patch splits the requested, pending and current state, updating as
appropriate.
Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.
X code is untouched.
This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.
Test Plan:
Maximised a window with the button and double clicking title bar.
I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true
19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false
BUG: 382698
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 14:36:02 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::hasPopupGrab() const
|
|
|
|
{
|
|
|
|
return m_haveExplicitGrab;
|
|
|
|
}
|
[wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.
This patch splits the requested, pending and current state, updating as
appropriate.
Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.
X code is untouched.
This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.
Test Plan:
Maximised a window with the button and double clicking title bar.
I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true
19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false
BUG: 382698
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 14:36:02 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::popupDone()
|
|
|
|
{
|
|
|
|
m_shellSurface->sendPopupDone();
|
[wayland] Asyncronously update maximise flags
Summary:
A window maximising is an async operation. We work out what size we want
the client to be, then request the client to update. The window isn't
really maximised until we get that new buffer with the new size.
This patch splits the requested, pending and current state, updating as
appropriate.
Things are a bit complex with things like borders. Technically we
shouldn't update them till we get a response, but we also need to have
the correct geometry of the full size window in our request. For now
they behave as before, updating when we request the change.
X code is untouched.
This hopefully fixes maximise animations on wayland as now we update the
geometry before emitting maximisedChanged.
Test Plan:
Maximised a window with the button and double clicking title bar.
I get only the following events on maximise/restore:
19:51:39.156 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(47,24 640x509) QRect(0,0 716x573)
19:51:39.157 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised true true
19:51:40.522 KWin::EffectsHandlerImpl::slotGeometryShapeChanged geometry
shape changed QRect(0,0 716x573) QRect(47,24 640x509)
19:51:40.522 KWin::EffectsHandlerImpl::slotClientMaximized slot client
maximised false false
BUG: 382698
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15150
2018-10-05 14:36:02 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::isPopupWindow() const
|
2015-06-19 22:14:49 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return true;
|
2015-06-19 22:14:49 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::isTransient() const
|
2019-09-15 09:41:21 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return true;
|
2019-09-15 09:41:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::isResizable() const
|
2015-06-19 23:11:42 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XdgPopupClient::isMovable() const
|
|
|
|
{
|
|
|
|
return false;
|
2015-06-19 23:11:42 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::isMovableAcrossScreens() const
|
2015-09-11 10:11:01 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
2015-09-11 10:11:01 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::hasTransientPlacementHint() const
|
2015-09-11 11:31:41 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return true;
|
2015-09-11 11:31:41 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
static QPoint popupOffset(const QRect &anchorRect, const Qt::Edges anchorEdge,
|
|
|
|
const Qt::Edges gravity, const QSize popupSize)
|
2015-09-11 11:31:41 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
QPoint anchorPoint;
|
|
|
|
switch (anchorEdge & (Qt::LeftEdge | Qt::RightEdge)) {
|
|
|
|
case Qt::LeftEdge:
|
|
|
|
anchorPoint.setX(anchorRect.x());
|
|
|
|
break;
|
|
|
|
case Qt::RightEdge:
|
|
|
|
anchorPoint.setX(anchorRect.x() + anchorRect.width());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
anchorPoint.setX(qRound(anchorRect.x() + anchorRect.width() / 2.0));
|
|
|
|
}
|
|
|
|
switch (anchorEdge & (Qt::TopEdge | Qt::BottomEdge)) {
|
|
|
|
case Qt::TopEdge:
|
|
|
|
anchorPoint.setY(anchorRect.y());
|
|
|
|
break;
|
|
|
|
case Qt::BottomEdge:
|
|
|
|
anchorPoint.setY(anchorRect.y() + anchorRect.height());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
anchorPoint.setY(qRound(anchorRect.y() + anchorRect.height() / 2.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate where the top left point of the popup will end up with the applied gravity
|
|
|
|
// gravity indicates direction. i.e if gravitating towards the top the popup's bottom edge
|
|
|
|
// will next to the anchor point
|
|
|
|
QPoint popupPosAdjust;
|
|
|
|
switch (gravity & (Qt::LeftEdge | Qt::RightEdge)) {
|
|
|
|
case Qt::LeftEdge:
|
|
|
|
popupPosAdjust.setX(-popupSize.width());
|
|
|
|
break;
|
|
|
|
case Qt::RightEdge:
|
|
|
|
popupPosAdjust.setX(0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
popupPosAdjust.setX(qRound(-popupSize.width() / 2.0));
|
|
|
|
}
|
|
|
|
switch (gravity & (Qt::TopEdge | Qt::BottomEdge)) {
|
|
|
|
case Qt::TopEdge:
|
|
|
|
popupPosAdjust.setY(-popupSize.height());
|
|
|
|
break;
|
|
|
|
case Qt::BottomEdge:
|
|
|
|
popupPosAdjust.setY(0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
popupPosAdjust.setY(qRound(-popupSize.height() / 2.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
return anchorPoint + popupPosAdjust;
|
|
|
|
}
|
2020-02-03 12:32:20 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect XdgPopupClient::transientPlacement(const QRect &bounds) const
|
|
|
|
{
|
|
|
|
const XdgPositioner positioner = m_shellSurface->positioner();
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
|
|
QSize desiredSize = size();
|
|
|
|
if (desiredSize.isEmpty()) {
|
|
|
|
desiredSize = positioner.size();
|
|
|
|
}
|
2018-10-19 22:21:54 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
const QPoint parentPosition = transientFor()->framePosToClientPos(transientFor()->pos());
|
2018-10-19 22:21:54 +00:00
|
|
|
|
|
|
|
// returns if a target is within the supplied bounds, optional edges argument states which side to check
|
|
|
|
auto inBounds = [bounds](const QRect &target, Qt::Edges edges = Qt::LeftEdge | Qt::RightEdge | Qt::TopEdge | Qt::BottomEdge) -> bool {
|
|
|
|
if (edges & Qt::LeftEdge && target.left() < bounds.left()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (edges & Qt::TopEdge && target.top() < bounds.top()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (edges & Qt::RightEdge && target.right() > bounds.right()) {
|
|
|
|
//normal QRect::right issue cancels out
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (edges & Qt::BottomEdge && target.bottom() > bounds.bottom()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
QRect popupRect(popupOffset(positioner.anchorRect(), positioner.anchorEdges(), positioner.gravityEdges(), desiredSize) + positioner.offset() + parentPosition, desiredSize);
|
2018-10-19 22:21:54 +00:00
|
|
|
|
|
|
|
//if that fits, we don't need to do anything
|
2020-02-03 12:43:48 +00:00
|
|
|
if (inBounds(popupRect)) {
|
|
|
|
return popupRect;
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
//otherwise apply constraint adjustment per axis in order XDG Shell Popup states
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (positioner.flipConstraintAdjustments() & Qt::Horizontal) {
|
2020-02-03 12:43:48 +00:00
|
|
|
if (!inBounds(popupRect, Qt::LeftEdge | Qt::RightEdge)) {
|
2018-10-19 22:21:54 +00:00
|
|
|
//flip both edges (if either bit is set, XOR both)
|
2020-02-17 18:39:17 +00:00
|
|
|
auto flippedAnchorEdge = positioner.anchorEdges();
|
2018-10-19 22:21:54 +00:00
|
|
|
if (flippedAnchorEdge & (Qt::LeftEdge | Qt::RightEdge)) {
|
|
|
|
flippedAnchorEdge ^= (Qt::LeftEdge | Qt::RightEdge);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
auto flippedGravity = positioner.gravityEdges();
|
2018-10-19 22:21:54 +00:00
|
|
|
if (flippedGravity & (Qt::LeftEdge | Qt::RightEdge)) {
|
|
|
|
flippedGravity ^= (Qt::LeftEdge | Qt::RightEdge);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
auto flippedPopupRect = QRect(popupOffset(positioner.anchorRect(), flippedAnchorEdge, flippedGravity, desiredSize) + positioner.offset() + parentPosition, desiredSize);
|
2018-10-19 22:21:54 +00:00
|
|
|
|
|
|
|
//if it still doesn't fit we should continue with the unflipped version
|
2020-02-03 12:43:48 +00:00
|
|
|
if (inBounds(flippedPopupRect, Qt::LeftEdge | Qt::RightEdge)) {
|
|
|
|
popupRect.moveLeft(flippedPopupRect.left());
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (positioner.slideConstraintAdjustments() & Qt::Horizontal) {
|
2020-02-03 12:43:48 +00:00
|
|
|
if (!inBounds(popupRect, Qt::LeftEdge)) {
|
|
|
|
popupRect.moveLeft(bounds.left());
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
2020-02-03 12:43:48 +00:00
|
|
|
if (!inBounds(popupRect, Qt::RightEdge)) {
|
|
|
|
popupRect.moveRight(bounds.right());
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (positioner.resizeConstraintAdjustments() & Qt::Horizontal) {
|
2020-02-03 12:43:48 +00:00
|
|
|
QRect unconstrainedRect = popupRect;
|
2020-01-31 02:36:45 +00:00
|
|
|
|
|
|
|
if (!inBounds(unconstrainedRect, Qt::LeftEdge)) {
|
|
|
|
unconstrainedRect.setLeft(bounds.left());
|
|
|
|
}
|
|
|
|
if (!inBounds(unconstrainedRect, Qt::RightEdge)) {
|
|
|
|
unconstrainedRect.setRight(bounds.right());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unconstrainedRect.isValid()) {
|
2020-02-03 12:43:48 +00:00
|
|
|
popupRect = unconstrainedRect;
|
2020-01-31 02:36:45 +00:00
|
|
|
}
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
if (positioner.flipConstraintAdjustments() & Qt::Vertical) {
|
2020-02-03 12:43:48 +00:00
|
|
|
if (!inBounds(popupRect, Qt::TopEdge | Qt::BottomEdge)) {
|
2018-10-19 22:21:54 +00:00
|
|
|
//flip both edges (if either bit is set, XOR both)
|
2020-02-17 18:39:17 +00:00
|
|
|
auto flippedAnchorEdge = positioner.anchorEdges();
|
2018-10-19 22:21:54 +00:00
|
|
|
if (flippedAnchorEdge & (Qt::TopEdge | Qt::BottomEdge)) {
|
|
|
|
flippedAnchorEdge ^= (Qt::TopEdge | Qt::BottomEdge);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
auto flippedGravity = positioner.gravityEdges();
|
2018-10-19 22:21:54 +00:00
|
|
|
if (flippedGravity & (Qt::TopEdge | Qt::BottomEdge)) {
|
|
|
|
flippedGravity ^= (Qt::TopEdge | Qt::BottomEdge);
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
auto flippedPopupRect = QRect(popupOffset(positioner.anchorRect(), flippedAnchorEdge, flippedGravity, desiredSize) + positioner.offset() + parentPosition, desiredSize);
|
2018-10-19 22:21:54 +00:00
|
|
|
|
|
|
|
//if it still doesn't fit we should continue with the unflipped version
|
2020-02-03 12:43:48 +00:00
|
|
|
if (inBounds(flippedPopupRect, Qt::TopEdge | Qt::BottomEdge)) {
|
|
|
|
popupRect.moveTop(flippedPopupRect.top());
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (positioner.slideConstraintAdjustments() & Qt::Vertical) {
|
2020-02-03 12:43:48 +00:00
|
|
|
if (!inBounds(popupRect, Qt::TopEdge)) {
|
|
|
|
popupRect.moveTop(bounds.top());
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
2020-02-03 12:43:48 +00:00
|
|
|
if (!inBounds(popupRect, Qt::BottomEdge)) {
|
|
|
|
popupRect.moveBottom(bounds.bottom());
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
2016-04-22 12:13:37 +00:00
|
|
|
}
|
2020-02-17 18:39:17 +00:00
|
|
|
if (positioner.resizeConstraintAdjustments() & Qt::Vertical) {
|
2020-02-03 12:43:48 +00:00
|
|
|
QRect unconstrainedRect = popupRect;
|
2020-01-31 02:36:45 +00:00
|
|
|
|
|
|
|
if (!inBounds(unconstrainedRect, Qt::TopEdge)) {
|
|
|
|
unconstrainedRect.setTop(bounds.top());
|
|
|
|
}
|
|
|
|
if (!inBounds(unconstrainedRect, Qt::BottomEdge)) {
|
|
|
|
unconstrainedRect.setBottom(bounds.bottom());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unconstrainedRect.isValid()) {
|
2020-02-03 12:43:48 +00:00
|
|
|
popupRect = unconstrainedRect;
|
2020-01-31 02:36:45 +00:00
|
|
|
}
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-03 12:43:48 +00:00
|
|
|
return popupRect;
|
2018-10-19 22:21:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::isCloseable() const
|
2015-12-07 13:27:06 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
2015-12-07 13:27:06 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::closeWindow()
|
2015-12-17 10:14:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::updateColorScheme()
|
2019-01-01 17:37:18 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
AbstractClient::updateColorScheme(QString());
|
2019-01-01 17:37:18 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::noBorder() const
|
2016-06-03 11:37:24 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::userCanSetNoBorder() const
|
2016-04-22 12:13:37 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
2016-04-22 12:13:37 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::setNoBorder(bool set)
|
2016-08-11 15:32:39 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
Q_UNUSED(set)
|
2016-08-11 15:32:39 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::updateDecoration(bool check_workspace_pos, bool force)
|
2016-09-15 19:03:40 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
Q_UNUSED(check_workspace_pos)
|
|
|
|
Q_UNUSED(force)
|
2016-09-15 19:03:40 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::showOnScreenEdge()
|
2016-10-12 13:09:52 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::supportsWindowRules() const
|
2016-11-15 15:48:20 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
2016-11-15 15:48:20 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::wantsInput() const
|
2019-09-15 09:41:21 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
2019-09-15 09:41:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::takeFocus()
|
2017-03-25 17:41:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
bool XdgPopupClient::acceptsFocus() const
|
2017-03-25 17:41:28 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
return false;
|
2017-03-25 17:41:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceConfigure *XdgPopupClient::sendRoleConfigure() const
|
2017-08-24 16:57:30 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
const QPoint parentPosition = transientFor()->framePosToClientPos(transientFor()->pos());
|
|
|
|
const QPoint popupPosition = requestedPos() - parentPosition;
|
2017-08-24 16:57:30 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
const quint32 serial = m_shellSurface->sendConfigure(QRect(popupPosition, requestedClientSize()));
|
[effects] Make Scale and Glide effects Wayland-friendly
Summary:
The Scale effect and the Glide effect have to animate only ordinary
windows(i.e. the ones that are considered to be apps).
On X11, in order to distinguish ordinary windows from combo box popups,
popup menus, and other popups, those effects check whether given window
is managed.
On Wayland, there is no concept of managed/unmanaged windows.
XDG Shell protocol defines 2 surface roles:
* xdg_toplevel;
* and, xdg_popup.
The former can be used to implement typical windows, the ones that can
be minimized, maximized, etc.
The latter can be used to implement tooltips, popup menus, etc. Thus,
that's a good criteria to filter popup windows.
CCBUG: 398100
Reviewers: #kwin, graesslin, davidedmundson
Reviewed By: #kwin, graesslin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D15117
2018-10-08 18:08:13 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
XdgSurfaceConfigure *configureEvent = new XdgSurfaceConfigure();
|
|
|
|
configureEvent->position = requestedPos();
|
|
|
|
configureEvent->size = requestedSize();
|
|
|
|
configureEvent->serial = serial;
|
[wayland] Apply window rules only to xdg-shell clients
Summary:
There are rules that have to be applied only once, e.g. every Remember
and Apply Initially rule, as well rules that need to configure the client,
e.g. size, etc. In the best scenario the compositor would evaluate such
rules when the client is about to be mapped.
This change limits window rules only to xdg-shell clients because right
now only this protocol lets compositors to intervene in the client
initialization process. Also, it makes things a bit easier for us on the
compositor side.
xdg-shell protocol satisfies most of ours requirements to implement window
rules, but not all of them. If the client is about to be mapped for the
second time and its size is forced by a rule, then compositor may need
to configure it. Currently, xdg-shell protocol doesn't have any mechanism
that a client could use to notify the compositor about its intent to map.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: fmonteiro, davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19411
2019-07-09 11:58:57 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
return configureEvent;
|
2020-01-23 21:40:34 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::handleGrabRequested(SeatInterface *seat, quint32 serial)
|
2020-01-23 21:40:34 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
Q_UNUSED(seat)
|
|
|
|
Q_UNUSED(serial)
|
|
|
|
m_haveExplicitGrab = true;
|
2020-01-23 21:40:34 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
void XdgPopupClient::initialize()
|
2020-01-28 22:02:05 +00:00
|
|
|
{
|
2020-02-17 18:39:17 +00:00
|
|
|
const QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop());
|
|
|
|
placeIn(area);
|
2020-01-28 22:02:05 +00:00
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
scheduleConfigure();
|
2020-01-28 22:02:05 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:39:17 +00:00
|
|
|
} // namespace KWin
|