Commit 74e04949 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Merge branch 'Plasma/5.18'

parents 64786630 c43b25bd
......@@ -696,9 +696,15 @@ public:
*/
QRect clientRectToFrameRect(const QRect &rect) const;
/**
* Returns @c true if the Client is being interactively moved; otherwise @c false.
*/
bool isMove() const {
return isMoveResize() && moveResizePointerMode() == PositionCenter;
}
/**
* Returns @c true if the Client is being interactively resized; otherwise @c false.
*/
bool isResize() const {
return isMoveResize() && moveResizePointerMode() != PositionCenter;
}
......
......@@ -224,11 +224,6 @@ void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect
bottom = decoration_bottom;
}
QRect Deleted::decorationRect() const
{
return rect();
}
QRect Deleted::transparentRect() const
{
return transparent_rect;
......
......@@ -62,7 +62,6 @@ public:
return no_border;
}
void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const;
QRect decorationRect() const override;
Layer layer() const override {
return m_layer;
}
......
......@@ -464,7 +464,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
X11Client *client = dynamic_cast<X11Client *>(toplevel);
Deleted *deleted = dynamic_cast<Deleted*>(toplevel);
const QRect decorationRect = toplevel->decorationRect();
const QRect decorationRect = toplevel->rect();
if (((client && !client->noBorder()) || (deleted && !deleted->noBorder())) &&
true) {
// decorated client
......
......@@ -788,7 +788,7 @@ QRegion Scene::Window::clientShape() const
QRegion Scene::Window::decorationShape() const
{
return QRegion(toplevel->decorationRect()) - toplevel->transparentRect();
return QRegion(toplevel->rect()) - toplevel->transparentRect();
}
QPoint Scene::Window::bufferOffset() const
......
......@@ -75,11 +75,6 @@ QDebug& operator<<(QDebug& stream, const Toplevel* cl)
return stream;
}
QRect Toplevel::decorationRect() const
{
return rect();
}
void Toplevel::detectShape(xcb_window_t id)
{
const bool wasShape = is_shape;
......
......@@ -376,8 +376,10 @@ public:
*/
virtual QPoint clientContentPos() const;
virtual QSize clientSize() const = 0;
virtual QRect visibleRect() const; // the area the window occupies on the screen
virtual QRect decorationRect() const; // rect including the decoration shadows
/**
* Returns a rectangle that the window occupies on the screen, including drop-shadows.
*/
virtual QRect visibleRect() const;
virtual QRect transparentRect() const = 0;
virtual bool isClient() const;
virtual bool isDeleted() const;
......
......@@ -2562,11 +2562,6 @@ void X11Client::setSessionActivityOverride(bool needed)
updateActivities(false);
}
QRect X11Client::decorationRect() const
{
return QRect(0, 0, width(), height());
}
Xcb::Property X11Client::fetchFirstInTabBox() const
{
return Xcb::Property(false, m_client, atoms->kde_first_in_window_list,
......
......@@ -271,9 +271,6 @@ public:
*/
bool hasOffscreenXineramaStrut() const;
// Decorations <-> Effects
QRect decorationRect() const override;
QRect transparentRect() const override;
bool isClientSideDecorated() const;
......
......@@ -67,7 +67,7 @@ namespace KWin
XdgShellClient::XdgShellClient(XdgShellSurfaceInterface *surface)
: AbstractClient()
, m_xdgShellSurface(surface)
, m_xdgShellToplevel(surface)
, m_xdgShellPopup(nullptr)
{
setSurface(surface->surface());
......@@ -76,7 +76,7 @@ XdgShellClient::XdgShellClient(XdgShellSurfaceInterface *surface)
XdgShellClient::XdgShellClient(XdgShellPopupInterface *surface)
: AbstractClient()
, m_xdgShellSurface(nullptr)
, m_xdgShellToplevel(nullptr)
, m_xdgShellPopup(surface)
{
setSurface(surface->surface());
......@@ -106,36 +106,36 @@ void XdgShellClient::init()
connect(surface(), &SurfaceInterface::unbound, this, &XdgShellClient::destroyClient);
connect(surface(), &SurfaceInterface::destroyed, this, &XdgShellClient::destroyClient);
if (m_xdgShellSurface) {
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::destroyed, this, &XdgShellClient::destroyClient);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::configureAcknowledged, this, &XdgShellClient::handleConfigureAcknowledged);
if (m_xdgShellToplevel) {
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::destroyed, this, &XdgShellClient::destroyClient);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::configureAcknowledged, this, &XdgShellClient::handleConfigureAcknowledged);
m_caption = m_xdgShellSurface->title().simplified();
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::titleChanged, this, &XdgShellClient::handleWindowTitleChanged);
m_caption = m_xdgShellToplevel->title().simplified();
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::titleChanged, this, &XdgShellClient::handleWindowTitleChanged);
QTimer::singleShot(0, this, &XdgShellClient::updateCaption);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::moveRequested, this, &XdgShellClient::handleMoveRequested);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::resizeRequested, this, &XdgShellClient::handleResizeRequested);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::moveRequested, this, &XdgShellClient::handleMoveRequested);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::resizeRequested, this, &XdgShellClient::handleResizeRequested);
// Determine the resource name, this is inspired from ICCCM 4.1.2.5
// the binary name of the invoked client.
QFileInfo info{m_xdgShellSurface->client()->executablePath()};
QFileInfo info{m_xdgShellToplevel->client()->executablePath()};
QByteArray resourceName;
if (info.exists()) {
resourceName = info.fileName().toUtf8();
}
setResourceClass(resourceName, m_xdgShellSurface->windowClass());
setDesktopFileName(m_xdgShellSurface->windowClass());
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::windowClassChanged, this, &XdgShellClient::handleWindowClassChanged);
setResourceClass(resourceName, m_xdgShellToplevel->windowClass());
setDesktopFileName(m_xdgShellToplevel->windowClass());
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::windowClassChanged, this, &XdgShellClient::handleWindowClassChanged);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::minimizeRequested, this, &XdgShellClient::handleMinimizeRequested);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::maximizedChanged, this, &XdgShellClient::handleMaximizeRequested);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::fullscreenChanged, this, &XdgShellClient::handleFullScreenRequested);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::windowMenuRequested, this, &XdgShellClient::handleWindowMenuRequested);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::transientForChanged, this, &XdgShellClient::handleTransientForChanged);
connect(m_xdgShellSurface, &XdgShellSurfaceInterface::windowGeometryChanged, this, &XdgShellClient::handleWindowGeometryChanged);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::minimizeRequested, this, &XdgShellClient::handleMinimizeRequested);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::maximizedChanged, this, &XdgShellClient::handleMaximizeRequested);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::fullscreenChanged, this, &XdgShellClient::handleFullScreenRequested);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::windowMenuRequested, this, &XdgShellClient::handleWindowMenuRequested);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::transientForChanged, this, &XdgShellClient::handleTransientForChanged);
connect(m_xdgShellToplevel, &XdgShellSurfaceInterface::windowGeometryChanged, this, &XdgShellClient::handleWindowGeometryChanged);
auto global = static_cast<XdgShellInterface *>(m_xdgShellSurface->global());
auto global = static_cast<XdgShellInterface *>(m_xdgShellToplevel->global());
connect(global, &XdgShellInterface::pingDelayed, this, &XdgShellClient::handlePingDelayed);
connect(global, &XdgShellInterface::pingTimeout, this, &XdgShellClient::handlePingTimeout);
connect(global, &XdgShellInterface::pongReceived, this, &XdgShellClient::handlePongReceived);
......@@ -147,7 +147,7 @@ void XdgShellClient::init()
if (m_requestGeometryBlockCounter != 0 || areGeometryUpdatesBlocked()) {
return;
}
m_xdgShellSurface->configure(xdgSurfaceStates(), m_requestedClientSize);
m_xdgShellToplevel->configure(xdgSurfaceStates(), m_requestedClientSize);
};
connect(this, &AbstractClient::activeChanged, this, configure);
connect(this, &AbstractClient::clientStartUserMovedResized, this, configure);
......@@ -285,7 +285,7 @@ void XdgShellClient::destroyClient()
deleted->unrefWindow();
m_xdgShellSurface = nullptr;
m_xdgShellToplevel = nullptr;
m_xdgShellPopup = nullptr;
deleteClient(this);
}
......@@ -490,7 +490,7 @@ void XdgShellClient::updateDecoration(bool check_workspace_pos, bool force)
auto mode = isDecorated() || m_userNoBorder ? XdgDecorationInterface::Mode::ServerSide: XdgDecorationInterface::Mode::ClientSide;
m_xdgDecoration->configure(mode);
if (m_requestGeometryBlockCounter == 0) {
m_xdgShellSurface->configure(xdgSurfaceStates(), m_requestedClientSize);
m_xdgShellToplevel->configure(xdgSurfaceStates(), m_requestedClientSize);
}
}
updateShadow();
......@@ -650,10 +650,9 @@ void XdgShellClient::updateCaption()
void XdgShellClient::closeWindow()
{
if (m_xdgShellSurface && isCloseable()) {
m_xdgShellSurface->close();
const qint32 pingSerial = static_cast<XdgShellInterface *>(m_xdgShellSurface->global())->ping(m_xdgShellSurface);
m_pingSerials.insert(pingSerial, PingReason::CloseWindow);
if (m_xdgShellToplevel && isCloseable()) {
m_xdgShellToplevel->close();
ping(PingReason::CloseWindow);
}
}
......@@ -668,7 +667,7 @@ bool XdgShellClient::isCloseable() const
if (m_windowType == NET::Desktop || m_windowType == NET::Dock) {
return false;
}
if (m_xdgShellSurface) {
if (m_xdgShellToplevel) {
return true;
}
return false;
......@@ -988,9 +987,8 @@ void XdgShellClient::setOnAllActivities(bool set)
void XdgShellClient::takeFocus()
{
if (rules()->checkAcceptFocus(wantsInput())) {
if (m_xdgShellSurface) {
const qint32 pingSerial = static_cast<XdgShellInterface *>(m_xdgShellSurface->global())->ping(m_xdgShellSurface);
m_pingSerials.insert(pingSerial, PingReason::FocusWindow);
if (m_xdgShellToplevel) {
ping(PingReason::FocusWindow);
}
setActive(true);
}
......@@ -1011,7 +1009,7 @@ void XdgShellClient::doSetActive()
bool XdgShellClient::userCanSetFullScreen() const
{
if (m_xdgShellSurface) {
if (m_xdgShellToplevel) {
return true;
}
return false;
......@@ -1057,7 +1055,7 @@ bool XdgShellClient::acceptsFocus() const
// an unmapped window does not accept focus
return false;
}
if (m_xdgShellSurface) {
if (m_xdgShellToplevel) {
// TODO: proper
return true;
}
......@@ -1101,8 +1099,8 @@ void XdgShellClient::requestGeometry(const QRect &rect)
quint64 serialId = 0;
if (m_xdgShellSurface) {
serialId = m_xdgShellSurface->configure(xdgSurfaceStates(), size);
if (m_xdgShellToplevel) {
serialId = m_xdgShellToplevel->configure(xdgSurfaceStates(), size);
}
if (m_xdgShellPopup) {
auto parent = transientFor();
......@@ -1164,8 +1162,8 @@ void XdgShellClient::handleConfigureAcknowledged(quint32 serial)
void XdgShellClient::handleTransientForChanged()
{
SurfaceInterface *transientSurface = nullptr;
if (m_xdgShellSurface) {
if (auto transient = m_xdgShellSurface->transientFor().data()) {
if (m_xdgShellToplevel) {
if (auto transient = m_xdgShellToplevel->transientFor().data()) {
transientSurface = transient->surface();
}
}
......@@ -1849,7 +1847,7 @@ void XdgShellClient::installServerSideDecoration(KWayland::Server::ServerSideDec
void XdgShellClient::installXdgDecoration(XdgDecorationInterface *deco)
{
Q_ASSERT(m_xdgShellSurface);
Q_ASSERT(m_xdgShellToplevel);
m_xdgDecoration = deco;
......@@ -1971,11 +1969,11 @@ void XdgShellClient::popupDone()
void XdgShellClient::updateClientOutputs()
{
QVector<OutputInterface*> clientOutputs;
QVector<OutputInterface *> clientOutputs;
const auto outputs = waylandServer()->display()->outputs();
for (OutputInterface* output: qAsConst(outputs)) {
const QRect outputGeom(output->globalPosition(), output->pixelSize() / output->scale());
if (frameGeometry().intersects(outputGeom)) {
for (OutputInterface *output : outputs) {
const QRect outputGeometry(output->globalPosition(), output->pixelSize() / output->scale());
if (frameGeometry().intersects(outputGeometry)) {
clientOutputs << output;
}
}
......@@ -1998,7 +1996,7 @@ bool XdgShellClient::supportsWindowRules() const
if (m_plasmaShellSurface) {
return false;
}
return m_xdgShellSurface;
return m_xdgShellToplevel;
}
QRect XdgShellClient::adjustMoveGeometry(const QRect &rect) const
......@@ -2043,4 +2041,13 @@ QRect XdgShellClient::adjustResizeGeometry(const QRect &rect) const
return geometry;
}
void XdgShellClient::ping(PingReason reason)
{
Q_ASSERT(m_xdgShellToplevel);
XdgShellInterface *shell = static_cast<XdgShellInterface *>(m_xdgShellToplevel->global());
const quint32 serial = shell->ping(m_xdgShellToplevel);
m_pingSerials.insert(serial, reason);
}
}
......@@ -188,12 +188,13 @@ private:
void unmap();
void markAsMapped();
QRect determineBufferGeometry() const;
void ping(PingReason reason);
static void deleteClient(XdgShellClient *c);
QRect adjustMoveGeometry(const QRect &rect) const;
QRect adjustResizeGeometry(const QRect &rect) const;
KWayland::Server::XdgShellSurfaceInterface *m_xdgShellSurface;
KWayland::Server::XdgShellSurfaceInterface *m_xdgShellToplevel;
KWayland::Server::XdgShellPopupInterface *m_xdgShellPopup;
QRect m_bufferGeometry;
......@@ -260,7 +261,7 @@ private:
QRect m_blockedRequestGeometry;
QString m_caption;
QString m_captionSuffix;
QHash<qint32, PingReason> m_pingSerials;
QHash<quint32, PingReason> m_pingSerials;
bool m_isInitialized = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment