Initial commit
This commit is contained in:
		
						commit
						ea3e4b3139
					
				
					 17 changed files with 885 additions and 0 deletions
				
			
		
							
								
								
									
										16
									
								
								src/interfaces/shell.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/interfaces/shell.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
/*
 | 
			
		||||
 *   SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
 | 
			
		||||
 *
 | 
			
		||||
 *   SPDX-License-Identifier: LGPL-3.0-or-later
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "shell.h"
 | 
			
		||||
#include <qglobal.h>
 | 
			
		||||
#include <QByteArray>
 | 
			
		||||
 | 
			
		||||
using namespace LayerShellQt;
 | 
			
		||||
 | 
			
		||||
void Shell::useLayerShell()
 | 
			
		||||
{
 | 
			
		||||
    qputenv("QT_WAYLAND_SHELL_INTEGRATION", "layer-shell");
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								src/interfaces/shell.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/interfaces/shell.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
/*
 | 
			
		||||
 *   SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
 | 
			
		||||
 *
 | 
			
		||||
 *   SPDX-License-Identifier: LGPL-3.0-or-later
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef LAYERSHELLQTSHELL_H
 | 
			
		||||
#define LAYERSHELLQTSHELL_H
 | 
			
		||||
 | 
			
		||||
#include "layershellqt_export.h"
 | 
			
		||||
 | 
			
		||||
namespace LayerShellQt
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sets the right environment so the shells created from now on use wlr-layer-shell.
 | 
			
		||||
 */
 | 
			
		||||
class LAYERSHELLQT_EXPORT Shell {
 | 
			
		||||
public:
 | 
			
		||||
    static void useLayerShell();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										66
									
								
								src/interfaces/window.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								src/interfaces/window.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,66 @@
 | 
			
		|||
/*
 | 
			
		||||
 *   SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
 | 
			
		||||
 *
 | 
			
		||||
 *   SPDX-License-Identifier: LGPL-3.0-or-later
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "window.h"
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <private/qwaylandwindow_p.h>
 | 
			
		||||
#include <private/qwaylandshellsurface_p.h>
 | 
			
		||||
#include "../qwaylandlayersurface_p.h"
 | 
			
		||||
 | 
			
		||||
using namespace LayerShellQt;
 | 
			
		||||
 | 
			
		||||
class LayerShellQt::WindowPrivate
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    WindowPrivate(QWaylandLayerSurface *surface)
 | 
			
		||||
        : surface(surface)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QWaylandLayerSurface *const surface;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Window::~Window() = default;
 | 
			
		||||
 | 
			
		||||
void Window::setAnchor(Anchor anchor)
 | 
			
		||||
{
 | 
			
		||||
    d->surface->setAnchor(anchor);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Window::setExclusiveZone(int32_t zone)
 | 
			
		||||
{
 | 
			
		||||
    d->surface->setExclusiveZone(zone);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Window::setMargins(const QMargins &margins)
 | 
			
		||||
{
 | 
			
		||||
    d->surface->setMargins(margins);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Window::setKeyboardInteractivity(bool enabled)
 | 
			
		||||
{
 | 
			
		||||
    d->surface->setKeyboardInteractivity(enabled);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Window::Window(WindowPrivate *d)
 | 
			
		||||
    : d(d)
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
Window *Window::get(QWindow *window)
 | 
			
		||||
{
 | 
			
		||||
    auto ww = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
 | 
			
		||||
    if (!ww) {
 | 
			
		||||
        qDebug() << "window not a wayland window" << window;
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
    QWaylandLayerSurface* s = qobject_cast<QWaylandLayerSurface *>(ww->shellSurface());
 | 
			
		||||
    if (!s) {
 | 
			
		||||
        qDebug() << "window not using wlr-layer-shell" << window << ww->shellSurface();
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return new Window(new WindowPrivate(s));
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										48
									
								
								src/interfaces/window.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/interfaces/window.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,48 @@
 | 
			
		|||
/*
 | 
			
		||||
 *   SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
 | 
			
		||||
 *   SPDX-FileCopyrightText: 2018 Drew DeVault <sir@cmpwn.com>
 | 
			
		||||
 *
 | 
			
		||||
 *   SPDX-License-Identifier: LGPL-3.0-or-later
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef LAYERSHELLQTWINDOW_H
 | 
			
		||||
#define LAYERSHELLQTWINDOW_H
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QWindow>
 | 
			
		||||
 | 
			
		||||
#include "layershellqt_export.h"
 | 
			
		||||
 | 
			
		||||
namespace LayerShellQt
 | 
			
		||||
{
 | 
			
		||||
class WindowPrivate;
 | 
			
		||||
 | 
			
		||||
class LAYERSHELLQT_EXPORT Window : public QObject
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    ~Window() override;
 | 
			
		||||
 | 
			
		||||
    enum Anchor {
 | 
			
		||||
        AnchorTop = 1, // the top edge of the anchor rectangle
 | 
			
		||||
        AnchorBottom = 2, // the bottom edge of the anchor rectangle
 | 
			
		||||
        AnchorLeft = 4, // the left edge of the anchor rectangle
 | 
			
		||||
        AnchorRight = 8, // the right edge of the anchor rectangle
 | 
			
		||||
    };
 | 
			
		||||
    Q_ENUM(Anchor);
 | 
			
		||||
 | 
			
		||||
    void setAnchor(Anchor anchor);
 | 
			
		||||
    void setExclusiveZone(int32_t zone);
 | 
			
		||||
    void setMargins(const QMargins &margins);
 | 
			
		||||
    void setKeyboardInteractivity(bool enabled);
 | 
			
		||||
 | 
			
		||||
    static Window *get(QWindow *window);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Window(WindowPrivate *d);
 | 
			
		||||
    QScopedPointer<WindowPrivate> d;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue