2020-08-07 19:01:42 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
#include "layershellv1window.h"
|
2022-08-29 07:55:49 +00:00
|
|
|
#include "core/output.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "layershellv1integration.h"
|
2023-03-08 08:07:39 +00:00
|
|
|
#include "screenedge.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
#include "wayland/layershell_v1_interface.h"
|
|
|
|
#include "wayland/output_interface.h"
|
2023-03-08 08:07:39 +00:00
|
|
|
#include "wayland/screenedge_v1_interface.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
#include "wayland/surface_interface.h"
|
2020-08-07 19:01:42 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
using namespace KWaylandServer;
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
static NET::WindowType scopeToType(const QString &scope)
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
static const QHash<QString, NET::WindowType> scopeToType{
|
|
|
|
{QStringLiteral("desktop"), NET::Desktop},
|
|
|
|
{QStringLiteral("dock"), NET::Dock},
|
|
|
|
{QStringLiteral("crititical-notification"), NET::CriticalNotification},
|
|
|
|
{QStringLiteral("notification"), NET::Notification},
|
|
|
|
{QStringLiteral("tooltip"), NET::Tooltip},
|
|
|
|
{QStringLiteral("on-screen-display"), NET::OnScreenDisplay},
|
|
|
|
{QStringLiteral("dialog"), NET::Dialog},
|
|
|
|
{QStringLiteral("splash"), NET::Splash},
|
|
|
|
{QStringLiteral("utility"), NET::Utility},
|
2020-08-07 19:01:42 +00:00
|
|
|
};
|
|
|
|
return scopeToType.value(scope.toLower(), NET::Normal);
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
LayerShellV1Window::LayerShellV1Window(LayerSurfaceV1Interface *shellSurface,
|
2022-04-14 12:33:28 +00:00
|
|
|
Output *output,
|
2020-08-07 19:01:42 +00:00
|
|
|
LayerShellV1Integration *integration)
|
2022-04-22 17:51:07 +00:00
|
|
|
: WaylandWindow(shellSurface->surface())
|
2021-08-25 10:47:44 +00:00
|
|
|
, m_desiredOutput(output)
|
2020-08-07 19:01:42 +00:00
|
|
|
, m_integration(integration)
|
|
|
|
, m_shellSurface(shellSurface)
|
|
|
|
, m_windowType(scopeToType(shellSurface->scope()))
|
|
|
|
{
|
|
|
|
setSkipSwitcher(!isDesktop());
|
|
|
|
setSkipPager(true);
|
|
|
|
setSkipTaskbar(true);
|
|
|
|
|
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::aboutToBeDestroyed,
|
2022-04-23 08:33:23 +00:00
|
|
|
this, &LayerShellV1Window::destroyWindow);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::aboutToBeDestroyed,
|
2022-04-23 08:33:23 +00:00
|
|
|
this, &LayerShellV1Window::destroyWindow);
|
2020-08-07 19:01:42 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
connect(output, &Output::geometryChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::scheduleRearrange);
|
2022-04-14 12:33:28 +00:00
|
|
|
connect(output, &Output::enabledChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::handleOutputEnabledChanged);
|
2022-04-14 12:33:28 +00:00
|
|
|
connect(output, &Output::destroyed,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::handleOutputDestroyed);
|
2020-08-07 19:01:42 +00:00
|
|
|
|
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::sizeChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::handleSizeChanged);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::unmapped,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::handleUnmapped);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface->surface(), &SurfaceInterface::committed,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::handleCommitted);
|
2020-08-07 19:01:42 +00:00
|
|
|
|
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::desiredSizeChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::scheduleRearrange);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::layerChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::scheduleRearrange);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::marginsChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::scheduleRearrange);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::anchorChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::scheduleRearrange);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::exclusiveZoneChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::scheduleRearrange);
|
2020-08-07 19:01:42 +00:00
|
|
|
connect(shellSurface, &LayerSurfaceV1Interface::acceptsFocusChanged,
|
2022-04-22 17:46:41 +00:00
|
|
|
this, &LayerShellV1Window::handleAcceptsFocusChanged);
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
LayerSurfaceV1Interface *LayerShellV1Window::shellSurface() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return m_shellSurface;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
Output *LayerShellV1Window::desiredOutput() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
2021-08-25 10:47:44 +00:00
|
|
|
return m_desiredOutput;
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::scheduleRearrange()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
m_integration->scheduleRearrange();
|
|
|
|
}
|
|
|
|
|
2023-03-28 10:48:11 +00:00
|
|
|
NET::WindowType LayerShellV1Window::windowType(bool) const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return m_windowType;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::isPlaceable() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::isCloseable() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::isMovable() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::isMovableAcrossScreens() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::isResizable() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::takeFocus()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
setActive(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::wantsInput() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return acceptsFocus() && readyForPainting();
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
StrutRect LayerShellV1Window::strutRect(StrutArea area) const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
switch (area) {
|
|
|
|
case StrutAreaLeft:
|
|
|
|
if (m_shellSurface->exclusiveEdge() == Qt::LeftEdge) {
|
|
|
|
return StrutRect(x(), y(), m_shellSurface->exclusiveZone(), height(), StrutAreaLeft);
|
|
|
|
}
|
|
|
|
return StrutRect();
|
|
|
|
case StrutAreaRight:
|
|
|
|
if (m_shellSurface->exclusiveEdge() == Qt::RightEdge) {
|
|
|
|
return StrutRect(x() + width() - m_shellSurface->exclusiveZone(), y(),
|
|
|
|
m_shellSurface->exclusiveZone(), height(), StrutAreaRight);
|
|
|
|
}
|
|
|
|
return StrutRect();
|
|
|
|
case StrutAreaTop:
|
|
|
|
if (m_shellSurface->exclusiveEdge() == Qt::TopEdge) {
|
|
|
|
return StrutRect(x(), y(), width(), m_shellSurface->exclusiveZone(), StrutAreaTop);
|
|
|
|
}
|
|
|
|
return StrutRect();
|
|
|
|
case StrutAreaBottom:
|
|
|
|
if (m_shellSurface->exclusiveEdge() == Qt::BottomEdge) {
|
|
|
|
return StrutRect(x(), y() + height() - m_shellSurface->exclusiveZone(),
|
|
|
|
width(), m_shellSurface->exclusiveZone(), StrutAreaBottom);
|
|
|
|
}
|
|
|
|
return StrutRect();
|
|
|
|
default:
|
|
|
|
return StrutRect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::hasStrut() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return m_shellSurface->exclusiveZone() > 0;
|
|
|
|
}
|
|
|
|
|
2022-04-23 08:33:23 +00:00
|
|
|
void LayerShellV1Window::destroyWindow()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
2023-03-08 08:07:39 +00:00
|
|
|
if (m_screenEdge) {
|
|
|
|
m_screenEdge->disconnect(this);
|
|
|
|
}
|
Drop Deleted
Currently, the normal window lifecycle looks as follows: create Window,
wait until it's shown, add it to Workspace, wait until it's closed,
create a Deleted, copy properties from the original window to the
deleted one, destroy the original window, wait until the last deleted
window reference is dropped.
There are a couple of issues with this design: we can't nicely
encapsulate X11 or Wayland specific implementation details if they need
to be accessed for closed windows; manual copying of properties is
cumbersome and error prone and we've had a dozen of cases where effects
worked incorrectly because some properties had not been copied.
The goal of this patch is to drop Deleted and extend the lifetime of the
original window, but with a special state set: Window::isDeleted().
The main danger is that somebody can try to do something with deleted
windows that they should not do, but on the other hand, such code needs
to be guarded with relevant checks too.
2023-03-14 09:45:18 +00:00
|
|
|
m_shellSurface->disconnect(this);
|
|
|
|
m_shellSurface->surface()->disconnect(this);
|
|
|
|
|
|
|
|
markAsDeleted();
|
2020-08-07 19:01:42 +00:00
|
|
|
cleanTabBox();
|
Drop Deleted
Currently, the normal window lifecycle looks as follows: create Window,
wait until it's shown, add it to Workspace, wait until it's closed,
create a Deleted, copy properties from the original window to the
deleted one, destroy the original window, wait until the last deleted
window reference is dropped.
There are a couple of issues with this design: we can't nicely
encapsulate X11 or Wayland specific implementation details if they need
to be accessed for closed windows; manual copying of properties is
cumbersome and error prone and we've had a dozen of cases where effects
worked incorrectly because some properties had not been copied.
The goal of this patch is to drop Deleted and extend the lifetime of the
original window, but with a special state set: Window::isDeleted().
The main danger is that somebody can try to do something with deleted
windows that they should not do, but on the other hand, such code needs
to be guarded with relevant checks too.
2023-03-14 09:45:18 +00:00
|
|
|
Q_EMIT closed();
|
2020-08-07 19:01:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(workspace());
|
|
|
|
cleanGrouping();
|
2022-04-23 08:33:23 +00:00
|
|
|
waylandServer()->removeWindow(this);
|
2020-08-07 19:01:42 +00:00
|
|
|
scheduleRearrange();
|
2023-03-02 20:51:46 +00:00
|
|
|
unref();
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::closeWindow()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
m_shellSurface->sendClosed();
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
Layer LayerShellV1Window::belongsToLayer() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
switch (m_shellSurface->layer()) {
|
|
|
|
case LayerSurfaceV1Interface::BackgroundLayer:
|
|
|
|
return DesktopLayer;
|
|
|
|
case LayerSurfaceV1Interface::BottomLayer:
|
|
|
|
return BelowLayer;
|
|
|
|
case LayerSurfaceV1Interface::TopLayer:
|
|
|
|
return AboveLayer;
|
|
|
|
case LayerSurfaceV1Interface::OverlayLayer:
|
|
|
|
return UnmanagedLayer;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
bool LayerShellV1Window::acceptsFocus() const
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
return m_shellSurface->acceptsFocus();
|
|
|
|
}
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
void LayerShellV1Window::moveResizeInternal(const QRectF &rect, MoveResizeMode mode)
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
if (areGeometryUpdatesBlocked()) {
|
|
|
|
setPendingMoveResizeMode(mode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
const QSizeF requestedClientSize = frameSizeToClientSize(rect.size());
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
if (requestedClientSize != clientSize()) {
|
2022-05-16 20:13:39 +00:00
|
|
|
m_shellSurface->sendConfigure(rect.size().toSize());
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
} else {
|
|
|
|
updateGeometry(rect);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The surface position is updated synchronously.
|
2022-05-16 20:13:39 +00:00
|
|
|
QRectF updateRect = m_frameGeometry;
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
updateRect.moveTopLeft(rect.topLeft());
|
|
|
|
updateGeometry(updateRect);
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::handleSizeChanged()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
2022-05-16 20:13:39 +00:00
|
|
|
updateGeometry(QRectF(pos(), clientSizeToFrameSize(surface()->size())));
|
2020-08-07 19:01:42 +00:00
|
|
|
scheduleRearrange();
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::handleUnmapped()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
2022-04-23 08:33:23 +00:00
|
|
|
m_integration->recreateWindow(shellSurface());
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::handleCommitted()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
if (surface()->buffer()) {
|
2023-03-02 15:02:09 +00:00
|
|
|
markAsMapped();
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::handleAcceptsFocusChanged()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
switch (m_shellSurface->layer()) {
|
|
|
|
case LayerSurfaceV1Interface::TopLayer:
|
|
|
|
case LayerSurfaceV1Interface::OverlayLayer:
|
|
|
|
if (wantsInput()) {
|
2022-04-23 08:33:23 +00:00
|
|
|
workspace()->activateWindow(this);
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LayerSurfaceV1Interface::BackgroundLayer:
|
|
|
|
case LayerSurfaceV1Interface::BottomLayer:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::handleOutputEnabledChanged()
|
2021-01-22 08:22:24 +00:00
|
|
|
{
|
2021-08-25 10:47:44 +00:00
|
|
|
if (!m_desiredOutput->isEnabled()) {
|
2021-01-22 08:22:24 +00:00
|
|
|
closeWindow();
|
2022-04-23 08:33:23 +00:00
|
|
|
destroyWindow();
|
2021-01-22 08:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-22 17:46:41 +00:00
|
|
|
void LayerShellV1Window::handleOutputDestroyed()
|
2020-08-07 19:01:42 +00:00
|
|
|
{
|
|
|
|
closeWindow();
|
2022-04-23 08:33:23 +00:00
|
|
|
destroyWindow();
|
2020-08-07 19:01:42 +00:00
|
|
|
}
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
void LayerShellV1Window::setVirtualKeyboardGeometry(const QRectF &geo)
|
2021-04-09 14:44:44 +00:00
|
|
|
{
|
|
|
|
if (m_virtualKeyboardGeometry == geo) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_virtualKeyboardGeometry = geo;
|
|
|
|
scheduleRearrange();
|
|
|
|
}
|
|
|
|
|
2023-03-08 08:07:39 +00:00
|
|
|
void LayerShellV1Window::showOnScreenEdge()
|
|
|
|
{
|
2023-06-01 10:31:04 +00:00
|
|
|
// ShowOnScreenEdge can be called by an Edge, and setHidden could destroy the Edge
|
2023-03-08 08:07:39 +00:00
|
|
|
// Use the singleshot to avoid use-after-free
|
|
|
|
QTimer::singleShot(0, this, &LayerShellV1Window::deactivateScreenEdge);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerShellV1Window::installAutoHideScreenEdgeV1(KWaylandServer::AutoHideScreenEdgeV1Interface *edge)
|
|
|
|
{
|
|
|
|
m_screenEdge = edge;
|
|
|
|
|
|
|
|
connect(edge, &KWaylandServer::AutoHideScreenEdgeV1Interface::destroyed,
|
|
|
|
this, &LayerShellV1Window::deactivateScreenEdge);
|
|
|
|
connect(edge, &KWaylandServer::AutoHideScreenEdgeV1Interface::activateRequested,
|
|
|
|
this, &LayerShellV1Window::activateScreenEdge);
|
|
|
|
connect(edge, &KWaylandServer::AutoHideScreenEdgeV1Interface::deactivateRequested,
|
|
|
|
this, &LayerShellV1Window::deactivateScreenEdge);
|
|
|
|
|
|
|
|
connect(this, &LayerShellV1Window::frameGeometryChanged, edge, [this]() {
|
|
|
|
if (m_screenEdgeActive) {
|
|
|
|
reserveScreenEdge();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerShellV1Window::reserveScreenEdge()
|
|
|
|
{
|
2023-05-25 07:57:36 +00:00
|
|
|
if (workspace()->screenEdges()->reserve(this, m_screenEdge->border())) {
|
2023-06-01 10:31:04 +00:00
|
|
|
setHidden(true);
|
2023-05-25 07:57:36 +00:00
|
|
|
} else {
|
2023-06-01 10:31:04 +00:00
|
|
|
setHidden(false);
|
2023-05-25 07:57:36 +00:00
|
|
|
}
|
2023-03-08 08:07:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayerShellV1Window::unreserveScreenEdge()
|
|
|
|
{
|
2023-06-01 10:31:04 +00:00
|
|
|
setHidden(false);
|
2023-03-08 08:07:39 +00:00
|
|
|
workspace()->screenEdges()->reserve(this, ElectricNone);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerShellV1Window::activateScreenEdge()
|
|
|
|
{
|
|
|
|
m_screenEdgeActive = true;
|
|
|
|
reserveScreenEdge();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayerShellV1Window::deactivateScreenEdge()
|
|
|
|
{
|
|
|
|
m_screenEdgeActive = false;
|
|
|
|
unreserveScreenEdge();
|
|
|
|
}
|
|
|
|
|
2020-08-07 19:01:42 +00:00
|
|
|
} // namespace KWin
|