21static const Qt::Edges AnchorHorizontal = Qt::LeftEdge | Qt::RightEdge;
 
   22static const Qt::Edges AnchorVertical = Qt::TopEdge | Qt::BottomEdge;
 
   31    m_rearrangeTimer = 
new QTimer(
this);
 
   32    m_rearrangeTimer->setSingleShot(
true);
 
 
   40        qCWarning(KWIN_CORE) << 
"Could not find any suitable output for a layer surface";
 
 
   57    for (
Window *window : windows) {
 
   59        if (layerShellWindow && layerShellWindow->
shellSurface() == shellSurface) {
 
 
   84static void rearrangeLayer(
const QList<LayerShellV1Window *> &windows, QRect *workArea,
 
   87    for (LayerShellV1Window *window : windows) {
 
   88        LayerSurfaceV1Interface *shellSurface = window->shellSurface();
 
   90        if (shellSurface->layer() != layer) {
 
   93        if (exclusive != (shellSurface->exclusiveZone() > 0)) {
 
   98        if (shellSurface->exclusiveZone() == -1) {
 
   99            bounds = window->desiredOutput()->geometry();
 
  104        QRect geometry(QPoint(0, 0), shellSurface->desiredSize());
 
  106        if ((shellSurface->anchor() & AnchorHorizontal) && geometry.width() == 0) {
 
  107            geometry.setLeft(bounds.left());
 
  108            geometry.setWidth(bounds.width());
 
  109        } 
else if (shellSurface->anchor() & Qt::LeftEdge) {
 
  110            geometry.moveLeft(bounds.left());
 
  111        } 
else if (shellSurface->anchor() & Qt::RightEdge) {
 
  112            geometry.moveRight(bounds.right());
 
  114            geometry.moveLeft(bounds.left() + (bounds.width() - geometry.width()) / 2);
 
  117        if ((shellSurface->anchor() & AnchorVertical) && geometry.height() == 0) {
 
  118            geometry.setTop(bounds.top());
 
  119            geometry.setHeight(bounds.height());
 
  120        } 
else if (shellSurface->anchor() & Qt::TopEdge) {
 
  121            geometry.moveTop(bounds.top());
 
  122        } 
else if (shellSurface->anchor() & Qt::BottomEdge) {
 
  123            geometry.moveBottom(bounds.bottom());
 
  125            geometry.moveTop(bounds.top() + (bounds.height() - geometry.height()) / 2);
 
  128        if ((shellSurface->anchor() & AnchorHorizontal) == AnchorHorizontal) {
 
  129            geometry.adjust(shellSurface->leftMargin(), 0, -shellSurface->rightMargin(), 0);
 
  130        } 
else if (shellSurface->anchor() & Qt::LeftEdge) {
 
  131            geometry.translate(shellSurface->leftMargin(), 0);
 
  132        } 
else if (shellSurface->anchor() & Qt::RightEdge) {
 
  133            geometry.translate(-shellSurface->rightMargin(), 0);
 
  136        if ((shellSurface->anchor() & AnchorVertical) == AnchorVertical) {
 
  137            geometry.adjust(0, shellSurface->topMargin(), 0, -shellSurface->bottomMargin());
 
  138        } 
else if (shellSurface->anchor() & Qt::TopEdge) {
 
  139            geometry.translate(0, shellSurface->topMargin());
 
  140        } 
else if (shellSurface->anchor() & Qt::BottomEdge) {
 
  141            geometry.translate(0, -shellSurface->bottomMargin());
 
  145        if (shellSurface->exclusiveZone() >= 0 && !window->virtualKeyboardGeometry().isEmpty() && geometry.bottom() > window->virtualKeyboardGeometry().top()) {
 
  146            geometry.setBottom(window->virtualKeyboardGeometry().top());
 
  149        window->updateLayer();
 
  151        if (geometry.isValid()) {
 
  152            window->moveResize(geometry);
 
  154            qCWarning(KWIN_CORE) << 
"Closing a layer shell window due to invalid geometry";
 
  155            window->closeWindow();
 
  159        if (exclusive && shellSurface->exclusiveZone() > 0) {
 
  160            adjustWorkArea(shellSurface, workArea);
 
  165static QList<LayerShellV1Window *> windowsForOutput(Output *output)
 
  167    QList<LayerShellV1Window *> result;
 
  169    for (
Window *window : windows) {
 
  170        LayerShellV1Window *layerShellWindow = qobject_cast<LayerShellV1Window *>(window);
 
  171        if (!layerShellWindow || layerShellWindow->desiredOutput() != output) {
 
  174        if (layerShellWindow->shellSurface()->isCommitted()) {
 
  175            result.append(layerShellWindow);
 
  181static void rearrangeOutput(Output *output)
 
  183    const QList<LayerShellV1Window *> windows = windowsForOutput(output);
 
  184    if (!windows.isEmpty()) {
 
  185        QRect workArea = output->geometry();
 
  201    m_rearrangeTimer->stop();
 
  204    for (
Output *output : outputs) {
 
  205        rearrangeOutput(output);
 
 
  215    m_rearrangeTimer->start();
 
 
  220#include "moc_layershellv1integration.cpp" 
void destroyWindow(LayerSurfaceV1Interface *shellSurface)
void createWindow(LayerSurfaceV1Interface *shellSurface)
LayerShellV1Integration(QObject *parent=nullptr)
void recreateWindow(LayerSurfaceV1Interface *shellSurface)
void surfaceCreated(LayerSurfaceV1Interface *surface)
LayerSurfaceV1Interface * shellSurface() const
void destroyWindow() override
int exclusiveZone() const
Qt::Edge exclusiveEdge() const
OutputInterface * output() const
QList< Window * > windows() const
void windowCreated(Window *window)
Output * activeOutput() const
QList< Output * > outputs() const
WaylandServer * waylandServer()