fork from kwin-5.27.5

This commit is contained in:
Mouse Zhang 2023-07-31 04:43:00 -04:00
commit f1edfb45b5
3355 changed files with 1303924 additions and 0 deletions

83
.clang-format Normal file
View File

@ -0,0 +1,83 @@
---
---
# SPDX-FileCopyrightText: 2019 Christoph Cullmann <cullmann@kde.org>
# SPDX-FileCopyrightText: 2019 Gernot Gebhard <gebhard@absint.com>
#
# SPDX-License-Identifier: MIT
---
Language: JavaScript
DisableFormat: true
---
# Style for C++
Language: Cpp
Standard: c++17
# base is WebKit coding style: https://webkit.org/code-style-guidelines/
# below are only things set that diverge from this style!
BasedOnStyle: WebKit
# 4 spaces indent
TabWidth: 4
# No line limit
ColumnLimit: 0
# sort includes inside line separated groups
SortIncludes: true
# Braces are usually attached, but not after functions or class declarations.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
# CrlInstruction *a;
PointerAlignment: Right
# horizontally aligns arguments after an open bracket.
AlignAfterOpenBracket: Align
# don't move all parameters to new line
AllowAllParametersOfDeclarationOnNextLine: false
# no single line functions
AllowShortFunctionsOnASingleLine: None
# In case we have an if statement with multiple lines the operator should be at the beginning of the line
# but we do not want to break assignments
BreakBeforeBinaryOperators: NonAssignment
# format C++11 braced lists like function calls
Cpp11BracedListStyle: true
# do not put a space before C++11 braced lists
SpaceBeforeCpp11BracedList: false
# no namespace indentation to keep indent level low
NamespaceIndentation: None
# we use template< without space.
SpaceAfterTemplateKeyword: false
# Always break after template declaration
AlwaysBreakTemplateDeclarations: true
# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ]
# keep lambda formatting multi-line if not empty
AllowShortLambdasOnASingleLine: Empty
# We do not want clang-format to put all arguments on a new line
AllowAllArgumentsOnNextLine: false

27
.gitignore vendored Normal file
View File

@ -0,0 +1,27 @@
# Ignore the following files
.vscode
*~
*.[oa]
*.diff
*.kate-swp
*.kdev4
.kdev_include_paths
*.kdevelop.pcs
*.moc
*.moc.cpp
*.orig
*.user
.*.swp
.swp.*
Doxyfile
Makefile
avail
random_seed
/build*/
CMakeLists.txt.user*
*.unc-backup*
/compile_commands.json
.clangd
.idea
/cmake-build*
.cache

14
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
include:
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd-qt6.yml
suse_tumbleweed_qt515_reduced_featureset:
extends: suse_tumbleweed_qt515
script:
- git config --global --add safe.directory $CI_PROJECT_DIR
- python3 -u ci-utilities/run-ci-build.py --project $CI_PROJECT_NAME --branch $CI_COMMIT_REF_NAME --platform Linux --extra-cmake-args="-DKWIN_BUILD_KCMS=OFF -DKWIN_BUILD_SCREENLOCKER=OFF -DKWIN_BUILD_TABBOX=OFF -DKWIN_BUILD_ACTIVITIES=OFF -DKWIN_BUILD_RUNNERS=OFF -DKWIN_BUILD_NOTIFICATIONS=OFF" --skip-publishing

40
.kde-ci.yml Normal file
View File

@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
Dependencies:
- 'on': ['@all']
'require':
'frameworks/breeze-icons': '@stable'
'frameworks/extra-cmake-modules': '@stable'
'frameworks/kactivities': '@stable'
'frameworks/kcmutils': '@stable'
'frameworks/kconfig': '@stable'
'frameworks/kconfigwidgets': '@stable'
'frameworks/kcoreaddons': '@stable'
'frameworks/kcrash': '@stable'
'frameworks/kdeclarative': '@stable'
'frameworks/kdoctools': '@stable'
'frameworks/kglobalaccel': '@stable'
'frameworks/ki18n': '@stable'
'frameworks/kidletime': '@stable'
'frameworks/kirigami': '@stable'
'frameworks/knewstuff': '@stable'
'frameworks/knotifications': '@stable'
'frameworks/kpackage': '@stable'
'frameworks/krunner': '@stable'
'frameworks/kservice': '@stable'
'frameworks/kwayland': '@stable'
'frameworks/kwidgetsaddons': '@stable'
'frameworks/kwindowsystem': '@stable'
'frameworks/kxmlgui': '@stable'
'frameworks/plasma-framework': '@stable'
'libraries/libqaccessibilityclient': '@latest'
'libraries/plasma-wayland-protocols': '@latest'
'plasma/breeze': '@same'
'plasma/kdecoration': '@same'
'plasma/kscreenlocker': '@same'
Options:
ctest-arguments: '--repeat until-pass:5'
use-ccache: True
require-passing-tests-on: ['FreeBSD', 'Linux']

1
.pc/.quilt_patches Normal file
View File

@ -0,0 +1 @@
debian/patches

1
.pc/.quilt_series Normal file
View File

@ -0,0 +1 @@
series

1
.pc/.version Normal file
View File

@ -0,0 +1 @@
2

1
.pc/applied-patches Normal file
View File

@ -0,0 +1 @@
uninitialized-yuvformat.patch

View File

@ -0,0 +1,340 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
SPDX-FileCopyrightText: 2018 Fredrik Höglund <fredrik@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "egl_dmabuf.h"
#include "kwineglext.h"
#include "kwineglutils_p.h"
#include "utils/common.h"
#include "wayland_server.h"
#include <drm_fourcc.h>
#include <unistd.h>
namespace KWin
{
typedef EGLBoolean (*eglQueryDmaBufFormatsEXT_func)(EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
typedef EGLBoolean (*eglQueryDmaBufModifiersEXT_func)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
eglQueryDmaBufFormatsEXT_func eglQueryDmaBufFormatsEXT = nullptr;
eglQueryDmaBufModifiersEXT_func eglQueryDmaBufModifiersEXT = nullptr;
struct YuvPlane
{
int widthDivisor;
int heightDivisor;
uint32_t format;
int planeIndex;
};
struct YuvFormat
{
uint32_t format;
int inputPlanes;
int outputPlanes;
int textureType;
struct YuvPlane planes[3];
};
YuvFormat yuvFormats[] = {
{DRM_FORMAT_YUYV,
1,
2,
EGL_TEXTURE_Y_XUXV_WL,
{{1, 1,
DRM_FORMAT_GR88,
0},
{2, 1,
DRM_FORMAT_ARGB8888,
0}}},
{DRM_FORMAT_NV12,
2,
2,
EGL_TEXTURE_Y_UV_WL,
{{1, 1,
DRM_FORMAT_R8,
0},
{2, 2,
DRM_FORMAT_GR88,
1}}},
{DRM_FORMAT_YUV420,
3,
3,
EGL_TEXTURE_Y_U_V_WL,
{{1, 1,
DRM_FORMAT_R8,
0},
{2, 2,
DRM_FORMAT_R8,
1},
{2, 2,
DRM_FORMAT_R8,
2}}},
{DRM_FORMAT_YUV444,
3,
3,
EGL_TEXTURE_Y_U_V_WL,
{{1, 1,
DRM_FORMAT_R8,
0},
{1, 1,
DRM_FORMAT_R8,
1},
{1, 1,
DRM_FORMAT_R8,
2}}}};
EglDmabufBuffer::EglDmabufBuffer(EGLImage image,
DmaBufAttributes &&attrs,
quint32 flags,
EglDmabuf *interfaceImpl)
: EglDmabufBuffer(QVector<EGLImage>{image}, std::move(attrs), flags, interfaceImpl)
{
m_importType = ImportType::Direct;
}
EglDmabufBuffer::EglDmabufBuffer(const QVector<EGLImage> &images,
DmaBufAttributes &&attrs,
quint32 flags,
EglDmabuf *interfaceImpl)
: LinuxDmaBufV1ClientBuffer(std::move(attrs), flags)
, m_images(images)
, m_interfaceImpl(interfaceImpl)
, m_importType(ImportType::Conversion)
{
}
EglDmabufBuffer::~EglDmabufBuffer()
{
removeImages();
}
void EglDmabufBuffer::setInterfaceImplementation(EglDmabuf *interfaceImpl)
{
m_interfaceImpl = interfaceImpl;
}
void EglDmabufBuffer::setImages(const QVector<EGLImage> &images)
{
m_images = images;
}
void EglDmabufBuffer::removeImages()
{
for (auto image : std::as_const(m_images)) {
eglDestroyImageKHR(m_interfaceImpl->m_backend->eglDisplay(), image);
}
m_images.clear();
}
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::importBuffer(DmaBufAttributes &&attrs, quint32 flags)
{
Q_ASSERT(attrs.planeCount > 0);
// Try first to import as a single image
if (auto *img = m_backend->importDmaBufAsImage(attrs)) {
return new EglDmabufBuffer(img, std::move(attrs), flags, this);
}
// TODO: to enable this we must be able to store multiple textures per window pixmap
// and when on window draw do yuv to rgb transformation per shader (see Weston)
// // not a single image, try yuv import
// return yuvImport(attrs, flags);
return nullptr;
}
KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::yuvImport(DmaBufAttributes &&attrs, quint32 flags)
{
YuvFormat yuvFormat;
for (YuvFormat f : yuvFormats) {
if (f.format == attrs.format) {
yuvFormat = f;
break;
}
}
if (yuvFormat.format == 0) {
return nullptr;
}
if (attrs.planeCount != yuvFormat.inputPlanes) {
return nullptr;
}
QVector<EGLImage> images;
for (int i = 0; i < yuvFormat.outputPlanes; i++) {
const int planeIndex = yuvFormat.planes[i].planeIndex;
const DmaBufAttributes planeAttrs{
.planeCount = 1,
.width = attrs.width / yuvFormat.planes[i].widthDivisor,
.height = attrs.height / yuvFormat.planes[i].heightDivisor,
.format = yuvFormat.planes[i].format,
.modifier = attrs.modifier,
.fd = {attrs.fd[planeIndex].duplicate()},
.offset = {attrs.offset[planeIndex], 0, 0, 0},
.pitch = {attrs.pitch[planeIndex], 0, 0, 0},
};
auto *image = m_backend->importDmaBufAsImage(planeAttrs);
if (!image) {
return nullptr;
}
images.push_back(image);
}
return new EglDmabufBuffer(images, std::move(attrs), flags, this);
}
EglDmabuf *EglDmabuf::factory(AbstractEglBackend *backend)
{
if (!backend->hasExtension(QByteArrayLiteral("EGL_EXT_image_dma_buf_import"))) {
return nullptr;
}
if (backend->hasExtension(QByteArrayLiteral("EGL_EXT_image_dma_buf_import_modifiers"))) {
eglQueryDmaBufFormatsEXT = (eglQueryDmaBufFormatsEXT_func)eglGetProcAddress("eglQueryDmaBufFormatsEXT");
eglQueryDmaBufModifiersEXT = (eglQueryDmaBufModifiersEXT_func)eglGetProcAddress("eglQueryDmaBufModifiersEXT");
}
if (eglQueryDmaBufFormatsEXT == nullptr) {
return nullptr;
}
return new EglDmabuf(backend);
}
EglDmabuf::EglDmabuf(AbstractEglBackend *backend)
: m_backend(backend)
{
auto prevBuffersSet = waylandServer()->linuxDmabufBuffers();
for (auto *buffer : prevBuffersSet) {
auto *buf = static_cast<EglDmabufBuffer *>(buffer);
buf->setInterfaceImplementation(this);
buf->setImages({m_backend->importDmaBufAsImage(buf->attributes())});
}
setSupportedFormatsAndModifiers();
}
EglDmabuf::~EglDmabuf()
{
auto curBuffers = waylandServer()->linuxDmabufBuffers();
for (auto *buffer : curBuffers) {
auto *buf = static_cast<EglDmabufBuffer *>(buffer);
buf->removeImages();
}
}
static int bpcForFormat(uint32_t format)
{
switch (format) {
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_RGBX8888:
case DRM_FORMAT_BGRX8888:
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_RGBA8888:
case DRM_FORMAT_BGRA8888:
case DRM_FORMAT_RGB888:
case DRM_FORMAT_BGR888:
return 8;
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_XBGR2101010:
case DRM_FORMAT_RGBX1010102:
case DRM_FORMAT_BGRX1010102:
case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010:
case DRM_FORMAT_RGBA1010102:
case DRM_FORMAT_BGRA1010102:
return 10;
default:
return -1;
}
};
void EglDmabuf::setSupportedFormatsAndModifiers()
{
const EGLDisplay eglDisplay = m_backend->eglDisplay();
EGLint count = 0;
EGLBoolean success = eglQueryDmaBufFormatsEXT(eglDisplay, 0, nullptr, &count);
if (!success || count == 0) {
qCCritical(KWIN_OPENGL) << "eglQueryDmaBufFormatsEXT failed!" << getEglErrorString();
return;
}
QVector<uint32_t> formats(count);
if (!eglQueryDmaBufFormatsEXT(eglDisplay, count, (EGLint *)formats.data(), &count)) {
qCCritical(KWIN_OPENGL) << "eglQueryDmaBufFormatsEXT with count" << count << "failed!" << getEglErrorString();
return;
}
m_supportedFormats.clear();
for (auto format : std::as_const(formats)) {
if (eglQueryDmaBufModifiersEXT != nullptr) {
EGLint count = 0;
const EGLBoolean success = eglQueryDmaBufModifiersEXT(eglDisplay, format, 0, nullptr, nullptr, &count);
if (success && count > 0) {
QVector<uint64_t> modifiers(count);
QVector<EGLBoolean> externalOnly(count);
if (eglQueryDmaBufModifiersEXT(eglDisplay, format, count, modifiers.data(), externalOnly.data(), &count)) {
for (int i = modifiers.size() - 1; i >= 0; i--) {
if (externalOnly[i]) {
modifiers.remove(i);
externalOnly.remove(i);
}
}
if (!modifiers.empty()) {
m_supportedFormats.insert(format, modifiers);
}
continue;
}
}
}
m_supportedFormats.insert(format, {DRM_FORMAT_MOD_INVALID});
}
qCDebug(KWIN_OPENGL) << "EGL driver advertises" << m_supportedFormats.count() << "supported dmabuf formats" << (eglQueryDmaBufModifiersEXT != nullptr ? "with" : "without") << "modifiers";
auto filterFormats = [this](int bpc) {
QHash<uint32_t, QVector<uint64_t>> set;
for (auto it = m_supportedFormats.constBegin(); it != m_supportedFormats.constEnd(); it++) {
if (bpcForFormat(it.key()) == bpc) {
set.insert(it.key(), it.value());
}
}
return set;
};
if (m_backend->prefer10bpc()) {
m_tranches.append({
.device = m_backend->deviceId(),
.flags = {},
.formatTable = filterFormats(10),
});
}
m_tranches.append({
.device = m_backend->deviceId(),
.flags = {},
.formatTable = filterFormats(8),
});
m_tranches.append({
.device = m_backend->deviceId(),
.flags = {},
.formatTable = filterFormats(-1),
});
LinuxDmaBufV1RendererInterface::setSupportedFormatsAndModifiers(m_tranches);
}
QVector<KWaylandServer::LinuxDmaBufV1Feedback::Tranche> EglDmabuf::tranches() const
{
return m_tranches;
}
QHash<uint32_t, QVector<uint64_t>> EglDmabuf::supportedFormats() const
{
return m_supportedFormats;
}
}

479
CMakeLists.txt Normal file
View File

@ -0,0 +1,479 @@
cmake_minimum_required(VERSION 3.16)
set(PROJECT_VERSION "5.27.5") # Handled by release scripts
project(KWin VERSION ${PROJECT_VERSION})
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QT_MIN_VERSION "5.15.2")
set(KF5_MIN_VERSION "5.102.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(FeatureSummary)
include(WriteBasicConfigVersionFile)
include(GenerateExportHeader)
include(CheckCXXCompilerFlag)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEClangFormat)
include(KDEGitCommitHooks)
include(ECMFindQmlModule)
include(ECMInstallIcons)
include(ECMOptionalAddSubdirectory)
include(ECMConfiguredInstall)
include(ECMQtDeclareLoggingCategory)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Concurrent
Core
DBus
Quick
UiTools
Widgets
)
if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras)
find_package(Qt5XkbCommonSupport REQUIRED)
else()
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient ShaderTools)
if (Qt6WaylandClient_VERSION VERSION_LESS "6.4.1") # TODO Plasma 6: Drop once minimum Qt version is 6.4.1+
include(Qt6WaylandClientMacrosKde)
endif()
endif()
find_package(Qt${QT_MAJOR_VERSION}Test ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(Qt${QT_MAJOR_VERSION}Test PROPERTIES
PURPOSE "Required for tests"
TYPE OPTIONAL
)
add_feature_info("Qt${QT_MAJOR_VERSION}Test" Qt${QT_MAJOR_VERSION}Test_FOUND "Required for building tests")
if (NOT Qt${QT_MAJOR_VERSION}Test_FOUND)
set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
endif()
# required frameworks by Core
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Auth
Config
ConfigWidgets
CoreAddons
Crash
DBusAddons
GlobalAccel
I18n
IdleTime
Package
Plasma
WidgetsAddons
WindowSystem
)
# required frameworks by config modules
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Declarative
KCMUtils
NewStuff
Service
XmlGui
ItemViews
)
find_package(Threads)
set_package_properties(Threads PROPERTIES
PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
TYPE REQUIRED
)
find_package(KF5Wayland ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Wayland PROPERTIES
PURPOSE "Required to build wayland platform plugin and tests"
TYPE REQUIRED
)
# optional frameworks
find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Activities PROPERTIES
PURPOSE "Enable building of KWin with kactivities support"
TYPE OPTIONAL
)
add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")
find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5DocTools PROPERTIES
PURPOSE "Enable building documentation"
TYPE OPTIONAL
)
add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
find_package(KF5Runner ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Runner PROPERTIES
PURPOSE "Enable building of KWin with krunner support"
TYPE OPTIONAL
)
add_feature_info("KF5Runner" KF5Runner_FOUND "Enable building of KWin with krunner support")
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "A QtQuick based components set"
PURPOSE "Required at runtime for Virtual desktop KCM"
TYPE RUNTIME
)
find_package(KDecoration2 ${PROJECT_VERSION} CONFIG)
set_package_properties(KDecoration2 PROPERTIES
TYPE REQUIRED
PURPOSE "Required for server side decoration support"
)
find_package(Breeze 5.9.0 CONFIG)
set_package_properties(Breeze PROPERTIES
TYPE OPTIONAL
PURPOSE "For setting the default window decoration plugin"
)
if (${Breeze_FOUND})
if (${BREEZE_WITH_KDECORATION})
set(HAVE_BREEZE_DECO true)
else()
set(HAVE_BREEZE_DECO FALSE)
endif()
else()
set(HAVE_BREEZE_DECO FALSE)
endif()
add_feature_info("Breeze-Decoration" HAVE_BREEZE_DECO "Default decoration plugin Breeze")
find_package(EGL)
set_package_properties(EGL PROPERTIES
TYPE REQUIRED
PURPOSE "Required to build KWin with EGL support"
)
find_package(epoxy 1.3)
set_package_properties(epoxy PROPERTIES
DESCRIPTION "libepoxy"
URL "https://github.com/anholt/libepoxy"
TYPE REQUIRED
PURPOSE "OpenGL dispatch library"
)
set(HAVE_DL_LIBRARY FALSE)
if (epoxy_HAS_GLX)
find_library(DL_LIBRARY dl)
if (DL_LIBRARY)
set(HAVE_DL_LIBRARY TRUE)
endif()
endif()
check_cxx_source_compiles("
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
int main() {
const int size = 10;
int fd = memfd_create(\"test\", MFD_CLOEXEC | MFD_ALLOW_SEALING);
ftruncate(fd, size);
fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_SEAL);
mmap(nullptr, size, PROT_WRITE, MAP_SHARED, fd, 0);
}" HAVE_MEMFD)
find_package(Wayland 1.21)
set_package_properties(Wayland PROPERTIES
TYPE REQUIRED
PURPOSE "Required for building KWin with Wayland support"
)
find_package(WaylandProtocols 1.31)
set_package_properties(WaylandProtocols PROPERTIES
TYPE REQUIRED
PURPOSE "Collection of Wayland protocols that add functionality not available in the Wayland core protocol"
URL "https://gitlab.freedesktop.org/wayland/wayland-protocols/"
)
find_package(PlasmaWaylandProtocols 1.9.0 CONFIG)
set_package_properties(PlasmaWaylandProtocols PROPERTIES
TYPE REQUIRED
PURPOSE "Collection of Plasma-specific Wayland protocols"
URL "https://invent.kde.org/libraries/plasma-wayland-protocols/"
)
if (QT_MAJOR_VERSION EQUAL "5")
find_package(QtWaylandScanner)
set_package_properties(QtWaylandScanner PROPERTIES
TYPE REQUIRED
PURPOSE "Required for building KWin with Wayland support"
)
endif()
find_package(XKB 0.7.0)
set_package_properties(XKB PROPERTIES
TYPE REQUIRED
PURPOSE "Required for building KWin with Wayland support"
)
if (XKB_VERSION VERSION_GREATER_EQUAL 1.5.0)
set(HAVE_XKBCOMMON_NO_SECURE_GETENV 1)
else()
set(HAVE_XKBCOMMON_NO_SECURE_GETENV 0)
endif()
pkg_check_modules(XKBX11 IMPORTED_TARGET xkbcommon-x11 REQUIRED)
add_feature_info(XKBX11 XKBX11_FOUND "Required for handling keyboard events in X11 backend")
find_package(Libinput 1.19)
set_package_properties(Libinput PROPERTIES TYPE REQUIRED PURPOSE "Required for input handling on Wayland.")
find_package(UDev)
set_package_properties(UDev PROPERTIES
URL "https://www.freedesktop.org/wiki/Software/systemd/"
DESCRIPTION "Linux device library."
TYPE REQUIRED
PURPOSE "Required for input handling on Wayland."
)
find_package(Libdrm 2.4.112)
set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.")
find_package(gbm)
set_package_properties(gbm PROPERTIES TYPE REQUIRED PURPOSE "Required for egl output of drm backend.")
if (gbm_VERSION VERSION_GREATER_EQUAL 21.1)
set(HAVE_GBM_BO_GET_FD_FOR_PLANE 1)
else()
set(HAVE_GBM_BO_GET_FD_FOR_PLANE 0)
endif()
if (gbm_VERSION VERSION_GREATER_EQUAL 21.3)
set(HAVE_GBM_BO_CREATE_WITH_MODIFIERS2 1)
else()
set(HAVE_GBM_BO_CREATE_WITH_MODIFIERS2 0)
endif()
pkg_check_modules(Libxcvt IMPORTED_TARGET libxcvt>=0.1.1 REQUIRED)
add_feature_info(Libxcvt Libxcvt_FOUND "Required for generating modes in the drm backend")
find_package(X11)
set_package_properties(X11 PROPERTIES
DESCRIPTION "X11 libraries"
URL "https://www.x.org"
TYPE REQUIRED
)
add_feature_info("XInput" X11_Xi_FOUND "Required for poll-free mouse cursor updates")
set(HAVE_X11_XINPUT ${X11_Xinput_FOUND})
find_package(lcms2)
set_package_properties(lcms2 PROPERTIES
DESCRIPTION "Small-footprint color management engine"
URL "http://www.littlecms.com"
TYPE REQUIRED
PURPOSE "Required for the color management system"
)
# All the required XCB components
find_package(XCB 1.10 REQUIRED COMPONENTS
COMPOSITE
CURSOR
DAMAGE
GLX
ICCCM
IMAGE
KEYSYMS
PRESENT
RANDR
RENDER
SHAPE
SHM
SYNC
XCB
XFIXES
XKB
XINERAMA
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
# and the optional XCB dependencies
if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
set(XCB_ICCCM_FOUND FALSE)
endif()
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES
PURPOSE "Required for building X11 windowed backend of kwin_wayland"
TYPE OPTIONAL
)
# dependencies for QPA plugin
if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5FontDatabaseSupport REQUIRED)
find_package(Qt5ThemeSupport REQUIRED)
find_package(Qt5ServiceSupport REQUIRED)
find_package(Qt5EventDispatcherSupport REQUIRED)
endif()
find_package(Freetype)
set_package_properties(Freetype PROPERTIES
DESCRIPTION "A font rendering engine"
URL "https://www.freetype.org"
TYPE REQUIRED
PURPOSE "Needed for KWin's QPA plugin."
)
find_package(Fontconfig)
set_package_properties(Fontconfig PROPERTIES
TYPE REQUIRED
PURPOSE "Needed for KWin's QPA plugin."
)
find_package(Xwayland)
set_package_properties(Xwayland PROPERTIES
URL "https://x.org"
DESCRIPTION "Xwayland X server"
TYPE RUNTIME
PURPOSE "Needed for running kwin_wayland"
)
set(HAVE_XWAYLAND_LISTENFD ${Xwayland_HAVE_LISTENFD})
find_package(Libcap)
set_package_properties(Libcap PROPERTIES
TYPE OPTIONAL
PURPOSE "Needed for running kwin_wayland with real-time scheduling policy"
)
set(HAVE_LIBCAP ${Libcap_FOUND})
find_package(hwdata)
set_package_properties(hwdata PROPERTIES
TYPE RUNTIME
PURPOSE "Runtime-only dependency needed for mapping monitor hardware vendor IDs to full names"
URL "https://github.com/vcrhonek/hwdata"
)
find_package(QAccessibilityClient CONFIG)
set_package_properties(QAccessibilityClient PROPERTIES
URL "https://www.kde.org"
DESCRIPTION "KDE client-side accessibility library"
TYPE OPTIONAL
PURPOSE "Required to enable accessibility features"
)
set(HAVE_ACCESSIBILITY ${QAccessibilityClient_FOUND})
ecm_find_qmlmodule(QtQuick 2.3)
ecm_find_qmlmodule(QtQuick.Controls 2.15)
ecm_find_qmlmodule(QtQuick.Layouts 1.3)
ecm_find_qmlmodule(QtQuick.Window 2.1)
ecm_find_qmlmodule(QtMultimedia 5.0)
ecm_find_qmlmodule(org.kde.kquickcontrolsaddons 2.0)
ecm_find_qmlmodule(org.kde.plasma.core 2.0)
ecm_find_qmlmodule(org.kde.plasma.components 2.0)
########### configure tests ###############
option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
option(KWIN_BUILD_NOTIFICATIONS "Enable building of KWin with knotifications support" ON)
option(KWIN_BUILD_SCREENLOCKER "Enable building of KWin lockscreen functionality" ON)
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
# for kwin internal things
set(HAVE_X11_XCB ${X11_XCB_FOUND})
check_symbol_exists(SCHED_RESET_ON_FORK "sched.h" HAVE_SCHED_RESET_ON_FORK)
add_feature_info("SCHED_RESET_ON_FORK"
HAVE_SCHED_RESET_ON_FORK
"Required for running kwin_wayland with real-time scheduling")
pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3>=0.3.29)
add_feature_info(PipeWire PipeWire_FOUND "Required for Wayland screencasting")
if (KWIN_BUILD_NOTIFICATIONS)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Notifications)
endif()
if (KWIN_BUILD_SCREENLOCKER)
find_package(KScreenLocker CONFIG)
set_package_properties(KScreenLocker PROPERTIES
TYPE REQUIRED
PURPOSE "For screenlocker integration in kwin_wayland"
)
endif()
########### global ###############
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/src/libkwineffects
${CMAKE_CURRENT_BINARY_DIR}/src/wayland
${CMAKE_CURRENT_BINARY_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/libkwineffects
${CMAKE_CURRENT_SOURCE_DIR}/src/effects
${CMAKE_CURRENT_SOURCE_DIR}/src/tabbox
${CMAKE_CURRENT_SOURCE_DIR}/src/platformsupport
${CMAKE_CURRENT_SOURCE_DIR}/src/colors
)
check_cxx_compiler_flag(-Wno-unused-parameter COMPILER_UNUSED_PARAMETER_SUPPORTED)
if (COMPILER_UNUSED_PARAMETER_SUPPORTED)
add_compile_options(-Wno-unused-parameter)
endif()
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0
-DQT_NO_KEYWORDS
-DQT_USE_QSTRINGBUILDER
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_TO_ASCII
-DQT_NO_FOREACH
# Prevent EGL headers from including platform headers, in particular Xlib.h.
-DMESA_EGL_NO_X11_HEADERS
-DEGL_NO_X11
-DEGL_NO_PLATFORM_SPECIFIC_TYPES
)
if (KF5DocTools_FOUND)
add_subdirectory(doc)
kdoctools_install(po)
endif()
add_subdirectory(data)
add_subdirectory(kconf_update)
add_subdirectory(src)
if (BUILD_TESTING)
find_package(Wayland REQUIRED COMPONENTS Client)
add_subdirectory(autotests)
add_subdirectory(tests)
endif()
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KWinDBusInterface")
configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
DESTINATION ${CMAKECONFIG_INSTALL_DIR})
ecm_install_configured_files(INPUT plasma-kwin_x11.service.in plasma-kwin_wayland.service.in @ONLY
DESTINATION ${KDE_INSTALL_SYSTEMDUSERUNITDIR})
ki18n_install(po)

136
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,136 @@
# Contributing to KWin
## Chatting
Come on by and ask about anything you run into when hacking on KWin!
KWin's Matrix room on our instance is located here: https://matrix.to/#/#kwin:kde.org.
You can grab an Matrix account at https://webchat.kde.org/ if you don't already have one from us or another provider.
The Matrix room is bridged to `#kde-kwin` on Libera, allowing IRC users to access it.
## What Needs Doing
There's a large amount of bugs open for KWin on our [Bugzilla instance](https://bugs.kde.org/describecomponents.cgi?product=kwin).
## Where Stuff Is
Everything codewise for KWin itself is located in the `src` directory.
### Settings Pages / KCMs
All the settings pages for KWin found in System Settings are located in `src/kcmkwin`.
### Default Decorations
The Breeze decorations theme is not located in the KWin repository, and is in fact part of the [Breeze repository here](https://invent.kde.org/plasma/breeze), in `kdecoration`.
### Tab Switcher
The default visual appearance of the tab switcher is not located in the KWin repository, and is in fact part of [Plasma Workspace](https://invent.kde.org/plasma/plasma-workspace), located at `lookandfeel/contents/windowswitcher`.
Other window switchers usually shipped by default are located in [Plasma Addons](https://invent.kde.org/plasma/kdeplasma-addons), located in the `windowswitchers` directory.
### Window Management
Most window management stuff (layouting, movement, properties, communication between client<->server) is defined in files ending with `client`, such as `x11client.cpp` and `xdgshellclient.cpp`.
### Window Effects
Window effects are located in the `effects` folder in `src`, with one folder per effect.
Not everything here is an effect as exposed in the configuration UI, such as the colour picker in `src/effects/colorpicker`.
### Scripting API
Many objects in KWin are exposed directly to the scripting API; scriptable properties are marked with Q_PROPERTY and functions that scripts can invoke on them.
Other scripting stuff is located in `src/scripting`.
## Conventions
### Coding Conventions
KWin's coding conventions are located [here](doc/coding-conventions.md).
KWin additionally follows [KDE's Frameworks Coding Style]((https://techbase.kde.org/Policies/Frameworks_Coding_Style)).
### Commits
We usually use this convention for commits in KWin:
```
component/subcomponent: Do a thing
This is a body of the commit message,
elaborating on why we're doing thing.
```
While this isn't a hard rule, it's appreciated for easy scanning of commits by their messages.
## Contributing
KWin uses KDE's GitLab instance for submitting code.
You can read about the [KDE workflow here](https://community.kde.org/Infrastructure/GitLab).
## Running KWin From Source
KWin uses CMake like most KDE projects, so you can build it like this:
```bash
mkdir _build
cd _build
cmake ..
make
```
People hacking on much KDE software may want to set up [kdesrc-build](https://invent.kde.org/sdk/kdesrc-build).
Once built, you can either install it over your system KWin (not recommended) or run it from the build directory directly.
Running it from your build directory looks like this:
```bash
# from the root of your build directory
cd bin
# for wayland, starts nested session: with console
env QT_PLUGIN_PATH=`pwd` dbus-run-session ./kwin_wayland --xwayland konsole
# or for x11, replaces current kwin instance:
env QT_PLUGIN_PATH=`pwd` ./kwin_x11 --replace
```
QT_PLUGIN_PATH tells Qt to load KWin's plugins from the build directory, and not from your system KWin.
The dbus-run-session is needed to prevent the nested KWin instance from conflicting with your session KWin instance when exporting objects onto the bus, or with stuff like global shortcuts.
If you need to run a whole Wayland plasma session, you should install a development session by first building [plasma-workspace](https://invent.kde.org/plasma/plasma-workspace) and executing the `login-sessions/install-sessions.sh` in the build directory. This can be done using kdesrc-build.
```bash
kdesrc-build plasma-workspace
# assuming the root directory for kdesrc-build is ~/kde
bash ~/kde/build/plasma-workspace/login-sessions/install-sessions.sh
```
Then you can select the develop session in the sddm login screen.
You can look up the current boot kwin log via `journalctl --user-unit plasma-kwin_wayland --boot 0`.
## Using A Debugger
Trying to attach a debugger to a running KWin instance from within itself will likely be the last thing you do in the session, as KWin will freeze until you resume it from your debugger, which you need KWin to interact with.
Instead, either attach a debugger to a nested KWin instance or debug over SSH.
## Tests
KWin has a series of unit tests and integration tests that ensure everything is running as expected.
If you're adding substantial new code, it's expected that you'll write tests for it to ensure that it's working as expected.
If you're fixing a bug, it's appreciated, but not expected, that you add a test case for the bug you fix.
You can read more about [KWin's testing infrastructure here](doc/TESTING.md).

View File

@ -0,0 +1,10 @@
@PACKAGE_INIT@
set(KWIN_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.KWin.xml")
set(KWIN_COMPOSITING_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.kwin.Compositing.xml")
set(KWIN_EFFECTS_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.kwin.Effects.xml")
set(KWIN_VIRTUALKEYBOARD_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.kwin.VirtualKeyboard.xml")
set(KWIN_TABLETMODE_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.KWin.TabletModeManager.xml")
set(KWIN_INPUTDEVICE_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.kwin.InputDevice.xml")
set(KWIN_COLORCORRECT_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.kwin.ColorCorrect.xml")
set(KWIN_WAYLAND_BIN_PATH "@CMAKE_INSTALL_FULL_BINDIR@/kwin_wayland")

26
LICENSES/BSD-3-Clause.txt Normal file
View File

@ -0,0 +1,26 @@
Copyright (c) <year> <owner>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

121
LICENSES/CC0-1.0.txt Normal file
View File

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

319
LICENSES/GPL-2.0-only.txt Normal file
View File

@ -0,0 +1,319 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software
is covered by the GNU Lesser General Public License instead.) You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must give the recipients all the rights that you have. You
must make sure that they, too, receive or can get the source code. And you
must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If
the software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or translated
into another language. (Hereinafter, translation is included without limitation
in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program
is not restricted, and the output from the Program is covered only if its
contents constitute a work based on the Program (independent of having been
made by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and appropriately
publish on each copy an appropriate copyright notice and disclaimer of warranty;
keep intact all the notices that refer to this License and to the absence
of any warranty; and give any other recipients of the Program a copy of this
License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print
such an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Program, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Program.
In addition, mere aggregation of another work not based on the Program with
the Program (or with a work based on the Program) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under Section
2) in object code or executable form under the terms of Sections 1 and 2 above
provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code,
which must be distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for noncommercial
distribution and only if you received the program in object code or executable
form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with
the object code.
4. You may not copy, modify, sublicense, or distribute the Program except
as expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses terminated
so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Program
(or any work based on the Program), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor
to copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of
the rights granted herein. You are not responsible for enforcing compliance
by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Program at all. For example, if a
patent license would not permit royalty-free redistribution of the Program
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system, which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose
any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing and reuse
of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and an idea of what it does.>
Copyright (C)< yyyy> <name of author>
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, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when
it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
and you are welcome to redistribute it under certain conditions; type `show
c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than `show w' and `show c'; they could even be mouse-clicks
or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
(which makes passes at compilers) written by James Hacker.
<signature of Ty Coon >, 1 April 1989 Ty Coon, President of Vice This General
Public License does not permit incorporating your program into proprietary
programs. If your program is a subroutine library, you may consider it more
useful to permit linking proprietary applications with the library. If this
is what you want to do, use the GNU Lesser General Public License instead
of this License.

View File

@ -0,0 +1,319 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software
is covered by the GNU Lesser General Public License instead.) You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must give the recipients all the rights that you have. You
must make sure that they, too, receive or can get the source code. And you
must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If
the software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or translated
into another language. (Hereinafter, translation is included without limitation
in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program
is not restricted, and the output from the Program is covered only if its
contents constitute a work based on the Program (independent of having been
made by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and appropriately
publish on each copy an appropriate copyright notice and disclaimer of warranty;
keep intact all the notices that refer to this License and to the absence
of any warranty; and give any other recipients of the Program a copy of this
License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print
such an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Program, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Program.
In addition, mere aggregation of another work not based on the Program with
the Program (or with a work based on the Program) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under Section
2) in object code or executable form under the terms of Sections 1 and 2 above
provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code,
which must be distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for noncommercial
distribution and only if you received the program in object code or executable
form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with
the object code.
4. You may not copy, modify, sublicense, or distribute the Program except
as expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses terminated
so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Program
(or any work based on the Program), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor
to copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of
the rights granted herein. You are not responsible for enforcing compliance
by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Program at all. For example, if a
patent license would not permit royalty-free redistribution of the Program
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system, which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose
any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing and reuse
of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and an idea of what it does.>
Copyright (C) <yyyy> <name of author>
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, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when
it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
and you are welcome to redistribute it under certain conditions; type `show
c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than `show w' and `show c'; they could even be mouse-clicks
or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
(which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General
Public License does not permit incorporating your program into proprietary
programs. If your program is a subroutine library, you may consider it more
useful to permit linking proprietary applications with the library. If this
is what you want to do, use the GNU Lesser General Public License instead
of this License.

625
LICENSES/GPL-3.0-only.txt Normal file
View File

@ -0,0 +1,625 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and
other kinds of works.
The licenses for most software and other practical works are designed to take
away your freedom to share and change the works. By contrast, the GNU General
Public License is intended to guarantee your freedom to share and change all
versions of a program--to make sure it remains free software for all its users.
We, the Free Software Foundation, use the GNU General Public License for most
of our software; it applies also to any other work released this way by its
authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for them if you wish), that
you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs, and that you know you
can do these things.
To protect your rights, we need to prevent others from denying you these rights
or asking you to surrender the rights. Therefore, you have certain responsibilities
if you distribute copies of the software, or if you modify it: responsibilities
to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must pass on to the recipients the same freedoms that you received.
You must make sure that they, too, receive or can get the source code. And
you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert
copyright on the software, and (2) offer you this License giving you legal
permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that
there is no warranty for this free software. For both users' and authors'
sake, the GPL requires that modified versions be marked as changed, so that
their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified
versions of the software inside them, although the manufacturer can do so.
This is fundamentally incompatible with the aim of protecting users' freedom
to change the software. The systematic pattern of such abuse occurs in the
area of products for individuals to use, which is precisely where it is most
unacceptable. Therefore, we have designed this version of the GPL to prohibit
the practice for those products. If such problems arise substantially in other
domains, we stand ready to extend this provision to those domains in future
versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States
should not allow patents to restrict development and use of software on general-purpose
computers, but in those that do, we wish to avoid the special danger that
patents applied to a free program could make it effectively proprietary. To
prevent this, the GPL assures that patents cannot be used to render the program
non-free.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works,
such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License.
Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals
or organizations.
To "modify" a work means to copy from or adapt all or part of the work in
a fashion requiring copyright permission, other than the making of an exact
copy. The resulting work is called a "modified version" of the earlier work
or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the
Program.
To "propagate" a work means to do anything with it that, without permission,
would make you directly or secondarily liable for infringement under applicable
copyright law, except executing it on a computer or modifying a private copy.
Propagation includes copying, distribution (with or without modification),
making available to the public, and in some countries other activities as
well.
To "convey" a work means any kind of propagation that enables other parties
to make or receive copies. Mere interaction with a user through a computer
network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the
extent that it includes a convenient and prominently visible feature that
(1) displays an appropriate copyright notice, and (2) tells the user that
there is no warranty for the work (except to the extent that warranties are
provided), that licensees may convey the work under this License, and how
to view a copy of this License. If the interface presents a list of user commands
or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making
modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard
defined by a recognized standards body, or, in the case of interfaces specified
for a particular programming language, one that is widely used among developers
working in that language.
The "System Libraries" of an executable work include anything, other than
the work as a whole, that (a) is included in the normal form of packaging
a Major Component, but which is not part of that Major Component, and (b)
serves only to enable use of the work with that Major Component, or to implement
a Standard Interface for which an implementation is available to the public
in source code form. A "Major Component", in this context, means a major essential
component (kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to produce
the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source
code needed to generate, install, and (for an executable work) run the object
code and to modify the work, including scripts to control those activities.
However, it does not include the work's System Libraries, or general-purpose
tools or generally available free programs which are used unmodified in performing
those activities but which are not part of the work. For example, Corresponding
Source includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically linked
subprograms that the work is specifically designed to require, such as by
intimate data communication or control flow between those subprograms and
other parts of the work.
The Corresponding Source need not include anything that users can regenerate
automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright
on the Program, and are irrevocable provided the stated conditions are met.
This License explicitly affirms your unlimited permission to run the unmodified
Program. The output from running a covered work is covered by this License
only if the output, given its content, constitutes a covered work. This License
acknowledges your rights of fair use or other equivalent, as provided by copyright
law.
You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey
covered works to others for the sole purpose of having them make modifications
exclusively for you, or provide you with facilities for running those works,
provided that you comply with the terms of this License in conveying all material
for which you do not control copyright. Those thus making or running the covered
works for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of your copyrighted
material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure
under any applicable law fulfilling obligations under article 11 of the WIPO
copyright treaty adopted on 20 December 1996, or similar laws prohibiting
or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention
of technological measures to the extent such circumvention is effected by
exercising rights under this License with respect to the covered work, and
you disclaim any intention to limit operation or modification of the work
as a means of enforcing, against the work's users, your or third parties'
legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive
it, in any medium, provided that you conspicuously and appropriately publish
on each copy an appropriate copyright notice; keep intact all notices stating
that this License and any non-permissive terms added in accord with section
7 apply to the code; keep intact all notices of the absence of any warranty;
and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you
may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce
it from the Program, in the form of source code under the terms of section
4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and
giving a relevant date.
b) The work must carry prominent notices stating that it is released under
this License and any conditions added under section 7. This requirement modifies
the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone
who comes into possession of a copy. This License will therefore apply, along
with any applicable section 7 additional terms, to the whole of the work,
and all its parts, regardless of how they are packaged. This License gives
no permission to license the work in any other way, but it does not invalidate
such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate
Legal Notices; however, if the Program has interactive interfaces that do
not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works,
which are not by their nature extensions of the covered work, and which are
not combined with it such as to form a larger program, in or on a volume of
a storage or distribution medium, is called an "aggregate" if the compilation
and its resulting copyright are not used to limit the access or legal rights
of the compilation's users beyond what the individual works permit. Inclusion
of a covered work in an aggregate does not cause this License to apply to
the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections
4 and 5, provided that you also convey the machine-readable Corresponding
Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by the Corresponding Source fixed
on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by a written offer, valid for
at least three years and valid for as long as you offer spare parts or customer
support for that product model, to give anyone who possesses the object code
either (1) a copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical medium customarily
used for software interchange, for a price no more than your reasonable cost
of physically performing this conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written
offer to provide the Corresponding Source. This alternative is allowed only
occasionally and noncommercially, and only if you received the object code
with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis
or for a charge), and offer equivalent access to the Corresponding Source
in the same way through the same place at no further charge. You need not
require recipients to copy the Corresponding Source along with the object
code. If the place to copy the object code is a network server, the Corresponding
Source may be on a different server (operated by you or a third party) that
supports equivalent copying facilities, provided you maintain clear directions
next to the object code saying where to find the Corresponding Source. Regardless
of what server hosts the Corresponding Source, you remain obligated to ensure
that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform
other peers where the object code and Corresponding Source of the work are
being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from
the Corresponding Source as a System Library, need not be included in conveying
the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible
personal property which is normally used for personal, family, or household
purposes, or (2) anything designed or sold for incorporation into a dwelling.
In determining whether a product is a consumer product, doubtful cases shall
be resolved in favor of coverage. For a particular product received by a particular
user, "normally used" refers to a typical or common use of that class of product,
regardless of the status of the particular user or of the way in which the
particular user actually uses, or expects or is expected to use, the product.
A product is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent the
only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures,
authorization keys, or other information required to install and execute modified
versions of a covered work in that User Product from a modified version of
its Corresponding Source. The information must suffice to ensure that the
continued functioning of the modified object code is in no case prevented
or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically
for use in, a User Product, and the conveying occurs as part of a transaction
in which the right of possession and use of the User Product is transferred
to the recipient in perpetuity or for a fixed term (regardless of how the
transaction is characterized), the Corresponding Source conveyed under this
section must be accompanied by the Installation Information. But this requirement
does not apply if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has been installed
in ROM).
The requirement to provide Installation Information does not include a requirement
to continue to provide support service, warranty, or updates for a work that
has been modified or installed by the recipient, or for the User Product in
which it has been modified or installed. Access to a network may be denied
when the modification itself materially and adversely affects the operation
of the network or violates the rules and protocols for communication across
the network.
Corresponding Source conveyed, and Installation Information provided, in accord
with this section must be in a format that is publicly documented (and with
an implementation available to the public in source code form), and must require
no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License
by making exceptions from one or more of its conditions. Additional permissions
that are applicable to the entire Program shall be treated as though they
were included in this License, to the extent that they are valid under applicable
law. If additional permissions apply only to part of the Program, that part
may be used separately under those permissions, but the entire Program remains
governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional
permissions may be written to require their own removal in certain cases when
you modify the work.) You may place additional permissions on material, added
by you to a covered work, for which you have or can give appropriate copyright
permission.
Notwithstanding any other provision of this License, for material you add
to a covered work, you may (if authorized by the copyright holders of that
material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of
sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices displayed
by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring
that modified versions of such material be marked in reasonable ways as different
from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors
of the material; or
e) Declining to grant rights under trademark law for use of some trade names,
trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by
anyone who conveys the material (or modified versions of it) with contractual
assumptions of liability to the recipient, for any liability that these contractual
assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions"
within the meaning of section 10. If the Program as you received it, or any
part of it, contains a notice stating that it is governed by this License
along with a term that is a further restriction, you may remove that term.
If a license document contains a further restriction but permits relicensing
or conveying under this License, you may add to a covered work material governed
by the terms of that license document, provided that the further restriction
does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place,
in the relevant source files, a statement of the additional terms that apply
to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form
of a separately written license, or stated as exceptions; the above requirements
apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided
under this License. Any attempt otherwise to propagate or modify it is void,
and will automatically terminate your rights under this License (including
any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from
a particular copyright holder is reinstated (a) provisionally, unless and
until the copyright holder explicitly and finally terminates your license,
and (b) permanently, if the copyright holder fails to notify you of the violation
by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently
if the copyright holder notifies you of the violation by some reasonable means,
this is the first time you have received notice of violation of this License
(for any work) from that copyright holder, and you cure the violation prior
to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses
of parties who have received copies or rights from you under this License.
If your rights have been terminated and not permanently reinstated, you do
not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy
of the Program. Ancillary propagation of a covered work occurring solely as
a consequence of using peer-to-peer transmission to receive a copy likewise
does not require acceptance. However, nothing other than this License grants
you permission to propagate or modify any covered work. These actions infringe
copyright if you do not accept this License. Therefore, by modifying or propagating
a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives
a license from the original licensors, to run, modify and propagate that work,
subject to this License. You are not responsible for enforcing compliance
by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization,
or substantially all assets of one, or subdividing an organization, or merging
organizations. If propagation of a covered work results from an entity transaction,
each party to that transaction who receives a copy of the work also receives
whatever licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the Corresponding
Source of the work from the predecessor in interest, if the predecessor has
it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights
granted or affirmed under this License. For example, you may not impose a
license fee, royalty, or other charge for exercise of rights granted under
this License, and you may not initiate litigation (including a cross-claim
or counterclaim in a lawsuit) alleging that any patent claim is infringed
by making, using, selling, offering for sale, or importing the Program or
any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License
of the Program or a work on which the Program is based. The work thus licensed
is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled
by the contributor, whether already acquired or hereafter acquired, that would
be infringed by some manner, permitted by this License, of making, using,
or selling its contributor version, but do not include claims that would be
infringed only as a consequence of further modification of the contributor
version. For purposes of this definition, "control" includes the right to
grant patent sublicenses in a manner consistent with the requirements of this
License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
license under the contributor's essential patent claims, to make, use, sell,
offer for sale, import and otherwise run, modify and propagate the contents
of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement
or commitment, however denominated, not to enforce a patent (such as an express
permission to practice a patent or covenant not to sue for patent infringement).
To "grant" such a patent license to a party means to make such an agreement
or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the
Corresponding Source of the work is not available for anyone to copy, free
of charge and under the terms of this License, through a publicly available
network server or other readily accessible means, then you must either (1)
cause the Corresponding Source to be so available, or (2) arrange to deprive
yourself of the benefit of the patent license for this particular work, or
(3) arrange, in a manner consistent with the requirements of this License,
to extend the patent license to downstream recipients. "Knowingly relying"
means you have actual knowledge that, but for the patent license, your conveying
the covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that country
that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement,
you convey, or propagate by procuring conveyance of, a covered work, and grant
a patent license to some of the parties receiving the covered work authorizing
them to use, propagate, modify or convey a specific copy of the covered work,
then the patent license you grant is automatically extended to all recipients
of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope
of its coverage, prohibits the exercise of, or is conditioned on the non-exercise
of one or more of the rights that are specifically granted under this License.
You may not convey a covered work if you are a party to an arrangement with
a third party that is in the business of distributing software, under which
you make payment to the third party based on the extent of your activity of
conveying the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by you
(or copies made from those copies), or (b) primarily for and in connection
with specific products or compilations that contain the covered work, unless
you entered into that arrangement, or that patent license was granted, prior
to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied
license or other defenses to infringement that may otherwise be available
to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise)
that contradict the conditions of this License, they do not excuse you from
the conditions of this License. If you cannot convey a covered work so as
to satisfy simultaneously your obligations under this License and any other
pertinent obligations, then as a consequence you may not convey it at all.
For example, if you agree to terms that obligate you to collect a royalty
for further conveying from those to whom you convey the Program, the only
way you could satisfy both those terms and this License would be to refrain
entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to
link or combine any covered work with a work licensed under version 3 of the
GNU Affero General Public License into a single combined work, and to convey
the resulting work. The terms of this License will continue to apply to the
part which is the covered work, but the special requirements of the GNU Affero
General Public License, section 13, concerning interaction through a network
will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the
GNU General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
that a certain numbered version of the GNU General Public License "or any
later version" applies to it, you have the option of following the terms and
conditions either of that numbered version or of any later version published
by the Free Software Foundation. If the Program does not specify a version
number of the GNU General Public License, you may choose any version ever
published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of
the GNU General Public License can be used, that proxy's public statement
of acceptance of a version permanently authorizes you to choose that version
for the Program.
Later license versions may give you additional or different permissions. However,
no additional obligations are imposed on any author or copyright holder as
a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM
PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM
AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO
USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot
be given local legal effect according to their terms, reviewing courts shall
apply local law that most closely approximates an absolute waiver of all civil
liability in connection with the Program, unless a warranty or assumption
of liability accompanies a copy of the Program in return for a fee. END OF
TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively state the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 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 <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like
this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain
conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands might
be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. For
more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General Public
License instead of this License. But first, please read <https://www.gnu.org/
licenses /why-not-lgpl.html>.

View File

@ -0,0 +1,625 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and
other kinds of works.
The licenses for most software and other practical works are designed to take
away your freedom to share and change the works. By contrast, the GNU General
Public License is intended to guarantee your freedom to share and change all
versions of a program--to make sure it remains free software for all its users.
We, the Free Software Foundation, use the GNU General Public License for most
of our software; it applies also to any other work released this way by its
authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for them if you wish), that
you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs, and that you know you
can do these things.
To protect your rights, we need to prevent others from denying you these rights
or asking you to surrender the rights. Therefore, you have certain responsibilities
if you distribute copies of the software, or if you modify it: responsibilities
to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must pass on to the recipients the same freedoms that you received.
You must make sure that they, too, receive or can get the source code. And
you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert
copyright on the software, and (2) offer you this License giving you legal
permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that
there is no warranty for this free software. For both users' and authors'
sake, the GPL requires that modified versions be marked as changed, so that
their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified
versions of the software inside them, although the manufacturer can do so.
This is fundamentally incompatible with the aim of protecting users' freedom
to change the software. The systematic pattern of such abuse occurs in the
area of products for individuals to use, which is precisely where it is most
unacceptable. Therefore, we have designed this version of the GPL to prohibit
the practice for those products. If such problems arise substantially in other
domains, we stand ready to extend this provision to those domains in future
versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States
should not allow patents to restrict development and use of software on general-purpose
computers, but in those that do, we wish to avoid the special danger that
patents applied to a free program could make it effectively proprietary. To
prevent this, the GPL assures that patents cannot be used to render the program
non-free.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works,
such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License.
Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals
or organizations.
To "modify" a work means to copy from or adapt all or part of the work in
a fashion requiring copyright permission, other than the making of an exact
copy. The resulting work is called a "modified version" of the earlier work
or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the
Program.
To "propagate" a work means to do anything with it that, without permission,
would make you directly or secondarily liable for infringement under applicable
copyright law, except executing it on a computer or modifying a private copy.
Propagation includes copying, distribution (with or without modification),
making available to the public, and in some countries other activities as
well.
To "convey" a work means any kind of propagation that enables other parties
to make or receive copies. Mere interaction with a user through a computer
network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the
extent that it includes a convenient and prominently visible feature that
(1) displays an appropriate copyright notice, and (2) tells the user that
there is no warranty for the work (except to the extent that warranties are
provided), that licensees may convey the work under this License, and how
to view a copy of this License. If the interface presents a list of user commands
or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making
modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard
defined by a recognized standards body, or, in the case of interfaces specified
for a particular programming language, one that is widely used among developers
working in that language.
The "System Libraries" of an executable work include anything, other than
the work as a whole, that (a) is included in the normal form of packaging
a Major Component, but which is not part of that Major Component, and (b)
serves only to enable use of the work with that Major Component, or to implement
a Standard Interface for which an implementation is available to the public
in source code form. A "Major Component", in this context, means a major essential
component (kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to produce
the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source
code needed to generate, install, and (for an executable work) run the object
code and to modify the work, including scripts to control those activities.
However, it does not include the work's System Libraries, or general-purpose
tools or generally available free programs which are used unmodified in performing
those activities but which are not part of the work. For example, Corresponding
Source includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically linked
subprograms that the work is specifically designed to require, such as by
intimate data communication or control flow between those subprograms and
other parts of the work.
The Corresponding Source need not include anything that users can regenerate
automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright
on the Program, and are irrevocable provided the stated conditions are met.
This License explicitly affirms your unlimited permission to run the unmodified
Program. The output from running a covered work is covered by this License
only if the output, given its content, constitutes a covered work. This License
acknowledges your rights of fair use or other equivalent, as provided by copyright
law.
You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey
covered works to others for the sole purpose of having them make modifications
exclusively for you, or provide you with facilities for running those works,
provided that you comply with the terms of this License in conveying all material
for which you do not control copyright. Those thus making or running the covered
works for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of your copyrighted
material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure
under any applicable law fulfilling obligations under article 11 of the WIPO
copyright treaty adopted on 20 December 1996, or similar laws prohibiting
or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention
of technological measures to the extent such circumvention is effected by
exercising rights under this License with respect to the covered work, and
you disclaim any intention to limit operation or modification of the work
as a means of enforcing, against the work's users, your or third parties'
legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive
it, in any medium, provided that you conspicuously and appropriately publish
on each copy an appropriate copyright notice; keep intact all notices stating
that this License and any non-permissive terms added in accord with section
7 apply to the code; keep intact all notices of the absence of any warranty;
and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you
may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce
it from the Program, in the form of source code under the terms of section
4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and
giving a relevant date.
b) The work must carry prominent notices stating that it is released under
this License and any conditions added under section 7. This requirement modifies
the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone
who comes into possession of a copy. This License will therefore apply, along
with any applicable section 7 additional terms, to the whole of the work,
and all its parts, regardless of how they are packaged. This License gives
no permission to license the work in any other way, but it does not invalidate
such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate
Legal Notices; however, if the Program has interactive interfaces that do
not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works,
which are not by their nature extensions of the covered work, and which are
not combined with it such as to form a larger program, in or on a volume of
a storage or distribution medium, is called an "aggregate" if the compilation
and its resulting copyright are not used to limit the access or legal rights
of the compilation's users beyond what the individual works permit. Inclusion
of a covered work in an aggregate does not cause this License to apply to
the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections
4 and 5, provided that you also convey the machine-readable Corresponding
Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by the Corresponding Source fixed
on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including
a physical distribution medium), accompanied by a written offer, valid for
at least three years and valid for as long as you offer spare parts or customer
support for that product model, to give anyone who possesses the object code
either (1) a copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical medium customarily
used for software interchange, for a price no more than your reasonable cost
of physically performing this conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written
offer to provide the Corresponding Source. This alternative is allowed only
occasionally and noncommercially, and only if you received the object code
with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis
or for a charge), and offer equivalent access to the Corresponding Source
in the same way through the same place at no further charge. You need not
require recipients to copy the Corresponding Source along with the object
code. If the place to copy the object code is a network server, the Corresponding
Source may be on a different server (operated by you or a third party) that
supports equivalent copying facilities, provided you maintain clear directions
next to the object code saying where to find the Corresponding Source. Regardless
of what server hosts the Corresponding Source, you remain obligated to ensure
that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform
other peers where the object code and Corresponding Source of the work are
being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from
the Corresponding Source as a System Library, need not be included in conveying
the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible
personal property which is normally used for personal, family, or household
purposes, or (2) anything designed or sold for incorporation into a dwelling.
In determining whether a product is a consumer product, doubtful cases shall
be resolved in favor of coverage. For a particular product received by a particular
user, "normally used" refers to a typical or common use of that class of product,
regardless of the status of the particular user or of the way in which the
particular user actually uses, or expects or is expected to use, the product.
A product is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent the
only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures,
authorization keys, or other information required to install and execute modified
versions of a covered work in that User Product from a modified version of
its Corresponding Source. The information must suffice to ensure that the
continued functioning of the modified object code is in no case prevented
or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically
for use in, a User Product, and the conveying occurs as part of a transaction
in which the right of possession and use of the User Product is transferred
to the recipient in perpetuity or for a fixed term (regardless of how the
transaction is characterized), the Corresponding Source conveyed under this
section must be accompanied by the Installation Information. But this requirement
does not apply if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has been installed
in ROM).
The requirement to provide Installation Information does not include a requirement
to continue to provide support service, warranty, or updates for a work that
has been modified or installed by the recipient, or for the User Product in
which it has been modified or installed. Access to a network may be denied
when the modification itself materially and adversely affects the operation
of the network or violates the rules and protocols for communication across
the network.
Corresponding Source conveyed, and Installation Information provided, in accord
with this section must be in a format that is publicly documented (and with
an implementation available to the public in source code form), and must require
no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License
by making exceptions from one or more of its conditions. Additional permissions
that are applicable to the entire Program shall be treated as though they
were included in this License, to the extent that they are valid under applicable
law. If additional permissions apply only to part of the Program, that part
may be used separately under those permissions, but the entire Program remains
governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional
permissions may be written to require their own removal in certain cases when
you modify the work.) You may place additional permissions on material, added
by you to a covered work, for which you have or can give appropriate copyright
permission.
Notwithstanding any other provision of this License, for material you add
to a covered work, you may (if authorized by the copyright holders of that
material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of
sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices displayed
by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring
that modified versions of such material be marked in reasonable ways as different
from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors
of the material; or
e) Declining to grant rights under trademark law for use of some trade names,
trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by
anyone who conveys the material (or modified versions of it) with contractual
assumptions of liability to the recipient, for any liability that these contractual
assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions"
within the meaning of section 10. If the Program as you received it, or any
part of it, contains a notice stating that it is governed by this License
along with a term that is a further restriction, you may remove that term.
If a license document contains a further restriction but permits relicensing
or conveying under this License, you may add to a covered work material governed
by the terms of that license document, provided that the further restriction
does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place,
in the relevant source files, a statement of the additional terms that apply
to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form
of a separately written license, or stated as exceptions; the above requirements
apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided
under this License. Any attempt otherwise to propagate or modify it is void,
and will automatically terminate your rights under this License (including
any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from
a particular copyright holder is reinstated (a) provisionally, unless and
until the copyright holder explicitly and finally terminates your license,
and (b) permanently, if the copyright holder fails to notify you of the violation
by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently
if the copyright holder notifies you of the violation by some reasonable means,
this is the first time you have received notice of violation of this License
(for any work) from that copyright holder, and you cure the violation prior
to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses
of parties who have received copies or rights from you under this License.
If your rights have been terminated and not permanently reinstated, you do
not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy
of the Program. Ancillary propagation of a covered work occurring solely as
a consequence of using peer-to-peer transmission to receive a copy likewise
does not require acceptance. However, nothing other than this License grants
you permission to propagate or modify any covered work. These actions infringe
copyright if you do not accept this License. Therefore, by modifying or propagating
a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives
a license from the original licensors, to run, modify and propagate that work,
subject to this License. You are not responsible for enforcing compliance
by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization,
or substantially all assets of one, or subdividing an organization, or merging
organizations. If propagation of a covered work results from an entity transaction,
each party to that transaction who receives a copy of the work also receives
whatever licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the Corresponding
Source of the work from the predecessor in interest, if the predecessor has
it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights
granted or affirmed under this License. For example, you may not impose a
license fee, royalty, or other charge for exercise of rights granted under
this License, and you may not initiate litigation (including a cross-claim
or counterclaim in a lawsuit) alleging that any patent claim is infringed
by making, using, selling, offering for sale, or importing the Program or
any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License
of the Program or a work on which the Program is based. The work thus licensed
is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled
by the contributor, whether already acquired or hereafter acquired, that would
be infringed by some manner, permitted by this License, of making, using,
or selling its contributor version, but do not include claims that would be
infringed only as a consequence of further modification of the contributor
version. For purposes of this definition, "control" includes the right to
grant patent sublicenses in a manner consistent with the requirements of this
License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
license under the contributor's essential patent claims, to make, use, sell,
offer for sale, import and otherwise run, modify and propagate the contents
of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement
or commitment, however denominated, not to enforce a patent (such as an express
permission to practice a patent or covenant not to sue for patent infringement).
To "grant" such a patent license to a party means to make such an agreement
or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the
Corresponding Source of the work is not available for anyone to copy, free
of charge and under the terms of this License, through a publicly available
network server or other readily accessible means, then you must either (1)
cause the Corresponding Source to be so available, or (2) arrange to deprive
yourself of the benefit of the patent license for this particular work, or
(3) arrange, in a manner consistent with the requirements of this License,
to extend the patent license to downstream recipients. "Knowingly relying"
means you have actual knowledge that, but for the patent license, your conveying
the covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that country
that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement,
you convey, or propagate by procuring conveyance of, a covered work, and grant
a patent license to some of the parties receiving the covered work authorizing
them to use, propagate, modify or convey a specific copy of the covered work,
then the patent license you grant is automatically extended to all recipients
of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope
of its coverage, prohibits the exercise of, or is conditioned on the non-exercise
of one or more of the rights that are specifically granted under this License.
You may not convey a covered work if you are a party to an arrangement with
a third party that is in the business of distributing software, under which
you make payment to the third party based on the extent of your activity of
conveying the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by you
(or copies made from those copies), or (b) primarily for and in connection
with specific products or compilations that contain the covered work, unless
you entered into that arrangement, or that patent license was granted, prior
to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied
license or other defenses to infringement that may otherwise be available
to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise)
that contradict the conditions of this License, they do not excuse you from
the conditions of this License. If you cannot convey a covered work so as
to satisfy simultaneously your obligations under this License and any other
pertinent obligations, then as a consequence you may not convey it at all.
For example, if you agree to terms that obligate you to collect a royalty
for further conveying from those to whom you convey the Program, the only
way you could satisfy both those terms and this License would be to refrain
entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to
link or combine any covered work with a work licensed under version 3 of the
GNU Affero General Public License into a single combined work, and to convey
the resulting work. The terms of this License will continue to apply to the
part which is the covered work, but the special requirements of the GNU Affero
General Public License, section 13, concerning interaction through a network
will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the
GNU General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
that a certain numbered version of the GNU General Public License "or any
later version" applies to it, you have the option of following the terms and
conditions either of that numbered version or of any later version published
by the Free Software Foundation. If the Program does not specify a version
number of the GNU General Public License, you may choose any version ever
published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of
the GNU General Public License can be used, that proxy's public statement
of acceptance of a version permanently authorizes you to choose that version
for the Program.
Later license versions may give you additional or different permissions. However,
no additional obligations are imposed on any author or copyright holder as
a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM
PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM
AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO
USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot
be given local legal effect according to their terms, reviewing courts shall
apply local law that most closely approximates an absolute waiver of all civil
liability in connection with the Program, unless a warranty or assumption
of liability accompanies a copy of the Program in return for a fee. END OF
TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively state the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 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 <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like
this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain
conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands might
be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. For
more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General Public
License instead of this License. But first, please read <https://www.gnu.org/
licenses /why-not-lgpl.html>.

446
LICENSES/LGPL-2.0-only.txt Normal file
View File

@ -0,0 +1,446 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the library GPL. It is numbered 2 because
it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Library General Public License, applies to some specially
designated Free Software Foundation software, and to any other libraries whose
authors decide to use it. You can use it for your libraries, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
a program with the library, you must provide complete object files to the
recipients so that they can relink them with the library, after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
Our method of protecting your rights has two steps: (1) copyright the library,
and (2) offer you this license which gives you legal permission to copy, distribute
and/or modify the library.
Also, for each distributor's protection, we want to make certain that everyone
understands that there is no warranty for this free library. If the library
is modified by someone else and passed on, we want its recipients to know
that what they have is not the original version, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that companies distributing free software will individually
obtain patent licenses, thus in effect transforming the program into proprietary
software. To prevent this, we have made it clear that any patent must be licensed
for everyone's free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License, which was designed for utility programs. This license,
the GNU Library General Public License, applies to certain designated libraries.
This license is quite different from the ordinary one; be sure to read it
in full, and don't assume that anything in it is the same as in the ordinary
license.
The reason we have a separate public license for some libraries is that they
blur the distinction we usually make between modifying or adding to a program
and simply using it. Linking a program with a library, without changing the
library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal
sense, the linked executable is a combined work, a derivative of the original
library, and the ordinary General Public License treats it as such.
Because of this blurred distinction, using the ordinary General Public License
for libraries did not effectively promote software sharing, because most developers
did not use the libraries. We concluded that weaker conditions might promote
sharing better.
However, unrestricted linking of non-free programs would deprive the users
of those programs of all benefit from the free status of the libraries themselves.
This Library General Public License is intended to permit developers of non-free
programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them.
(We have not seen how to achieve this as regards changes in header files,
but we have achieved it as regards changes in the actual functions of the
Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General
Public License rather than by this special one.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which contains a
notice placed by the copyright holder or other authorized party saying it
may be distributed under the terms of this Library General Public License
(also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also compile or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
d) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the source code distributed need
not include anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the operating
system on which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Library General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This library 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 Library General Public License for more
details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,446 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the library GPL. It is numbered 2 because
it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Library General Public License, applies to some specially
designated Free Software Foundation software, and to any other libraries whose
authors decide to use it. You can use it for your libraries, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
a program with the library, you must provide complete object files to the
recipients so that they can relink them with the library, after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
Our method of protecting your rights has two steps: (1) copyright the library,
and (2) offer you this license which gives you legal permission to copy, distribute
and/or modify the library.
Also, for each distributor's protection, we want to make certain that everyone
understands that there is no warranty for this free library. If the library
is modified by someone else and passed on, we want its recipients to know
that what they have is not the original version, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that companies distributing free software will individually
obtain patent licenses, thus in effect transforming the program into proprietary
software. To prevent this, we have made it clear that any patent must be licensed
for everyone's free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License, which was designed for utility programs. This license,
the GNU Library General Public License, applies to certain designated libraries.
This license is quite different from the ordinary one; be sure to read it
in full, and don't assume that anything in it is the same as in the ordinary
license.
The reason we have a separate public license for some libraries is that they
blur the distinction we usually make between modifying or adding to a program
and simply using it. Linking a program with a library, without changing the
library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal
sense, the linked executable is a combined work, a derivative of the original
library, and the ordinary General Public License treats it as such.
Because of this blurred distinction, using the ordinary General Public License
for libraries did not effectively promote software sharing, because most developers
did not use the libraries. We concluded that weaker conditions might promote
sharing better.
However, unrestricted linking of non-free programs would deprive the users
of those programs of all benefit from the free status of the libraries themselves.
This Library General Public License is intended to permit developers of non-free
programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them.
(We have not seen how to achieve this as regards changes in header files,
but we have achieved it as regards changes in the actual functions of the
Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General
Public License rather than by this special one.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which contains a
notice placed by the copyright holder or other authorized party saying it
may be distributed under the terms of this Library General Public License
(also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also compile or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
d) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the source code distributed need
not include anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the operating
system on which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Library General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This library 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 Library General Public License for more
details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

467
LICENSES/LGPL-2.1-only.txt Normal file
View File

@ -0,0 +1,467 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts as the
successor of the GNU Library Public License, version 2, hence the version
number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Lesser General Public License, applies to some specially
designated software packages--typically libraries--of the Free Software Foundation
and other authors who decide to use it. You can use it too, but we suggest
you first think carefully about whether this license or the ordinary General
Public License is the better strategy to use in any particular case, based
on the explanations below.
When we speak of free software, we are referring to freedom of use, not price.
Our General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish); that you receive source code or can get it if you want it; that you
can change the software and use pieces of it in new free programs; and that
you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors
to deny you these rights or to ask you to surrender these rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
other code with the library, you must provide complete object files to the
recipients, so that they can relink them with the library after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
We protect your rights with a two-step method: (1) we copyright the library,
and (2) we offer you this license, which gives you legal permission to copy,
distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no
warranty for the free library. Also, if the library is modified by someone
else and passed on, the recipients should know that what they have is not
the original version, so that the original author's reputation will not be
affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free
program. We wish to make sure that a company cannot effectively restrict the
users of a free program by obtaining a restrictive license from a patent holder.
Therefore, we insist that any patent license obtained for a version of the
library must be consistent with the full freedom of use specified in this
license.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License. This license, the GNU Lesser General Public License,
applies to certain designated libraries, and is quite different from the ordinary
General Public License. We use this license for certain libraries in order
to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared
library, the combination of the two is legally speaking a combined work, a
derivative of the original library. The ordinary General Public License therefore
permits such linking only if the entire combination fits its criteria of freedom.
The Lesser General Public License permits more lax criteria for linking other
code with the library.
We call this license the "Lesser" General Public License because it does Less
to protect the user's freedom than the ordinary General Public License. It
also provides other free software developers Less of an advantage over competing
non-free programs. These disadvantages are the reason we use the ordinary
General Public License for many libraries. However, the Lesser license provides
advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the
widest possible use of a certain library, so that it becomes a de-facto standard.
To achieve this, non-free programs must be allowed to use the library. A more
frequent case is that a free library does the same job as widely used non-free
libraries. In this case, there is little to gain by limiting the free library
to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs
enables a greater number of people to use a large body of free software. For
example, permission to use the GNU C Library in non-free programs enables
many more people to use the whole GNU operating system, as well as its variant,
the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users'
freedom, it does ensure that the user of a program that is linked with the
Library has the freedom and the wherewithal to run that program using a modified
version of the Library.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, whereas the latter must be combined with the library in
order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program
which contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Lesser General
Public License (also called "this License"). Each licensee is addressed as
"you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (1) uses at run time a copy of the library
already present on the user's computer system, rather than copying library
functions into the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the modified
version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
e) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the materials to be distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
< one line to give the library's name and an idea of what it does. >
Copyright (C) < year > < name of author >
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library 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 Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information
on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
< signature of Ty Coon > , 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,175 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License).
To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

163
LICENSES/LGPL-3.0-only.txt Normal file
View File

@ -0,0 +1,163 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms
and conditions of version 3 of the GNU General Public License, supplemented
by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser General
Public License, and the "GNU GPL" refers to version 3 of the GNU General Public
License.
"The Library" refers to a covered work governed by this License, other than
an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided by the
Library, but which is not otherwise based on the Library. Defining a subclass
of a class defined by the Library is deemed a mode of using an interface provided
by the Library.
A "Combined Work" is a work produced by combining or linking an Application
with the Library. The particular version of the Library with which the Combined
Work was made is also called the "Linked Version".
The "Minimal Corresponding Source" for a Combined Work means the Corresponding
Source for the Combined Work, excluding any source code for portions of the
Combined Work that, considered in isolation, are based on the Application,
and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the object
code and/or source code for the Application, including any data and utility
programs needed for reproducing the Combined Work from the Application, but
excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without
being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility
refers to a function or data to be supplied by an Application that uses the
facility (other than as an argument passed when the facility is invoked),
then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure
that, in the event an Application does not supply the function or data, the
facility still operates, and performs whatever part of its purpose remains
meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License
applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header
file that is part of the Library. You may convey such object code under terms
of your choice, provided that, if the incorporated material is not limited
to numerical parameters, data structure layouts and accessors, or small macros,
inline functions and templates (ten or fewer lines in length), you do both
of the following:
a) Give prominent notice with each copy of the object code that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together,
effectively do not restrict modification of the portions of the Library contained
in the Combined Work and reverse engineering for debugging such modifications,
if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during execution, include
the copyright notice for the Library among these notices, as well as a reference
directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License,
and the Corresponding Application Code in a form suitable for, and under terms
that permit, the user to recombine or relink the Application with a modified
version of the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (a) uses at run time a copy of the Library
already present on the user's computer system, and (b) will operate properly
with a modified version of the Library that is interface-compatible with the
Linked Version.
e) Provide Installation Information, but only if you would otherwise be required
to provide such information under section 6 of the GNU GPL, and only to the
extent that such information is necessary to install and execute a modified
version of the Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option 4d0, the
Installation Information must accompany the Minimal Corresponding Source and
Corresponding Application Code. If you use option 4d1, you must provide the
Installation Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side
by side in a single library together with other library facilities that are
not Applications and are not covered by this License, and convey such a combined
library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities, conveyed under the
terms of this License.
b) Give prominent notice with the combined library that part of it is a work
based on the Library, and explaining where to find the accompanying uncombined
form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the
GNU Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library as you
received it specifies that a certain numbered version of the GNU Lesser General
Public License "or any later version" applies to it, you have the option of
following the terms and conditions either of that published version or of
any later version published by the Free Software Foundation. If the Library
as you received it does not specify a version number of the GNU Lesser General
Public License, you may choose any version of the GNU Lesser General Public
License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether
future versions of the GNU Lesser General Public License shall apply, that
proxy's public statement of acceptance of any version is permanent authorization
for you to choose that version for the Library.

View File

@ -0,0 +1,12 @@
This library 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 3 of
the license or (at your option) at any later version that is
accepted by the membership of KDE e.V. (or its successor
approved by the membership of KDE e.V.), which shall act as a
proxy as defined in Section 14 of version 3 of the license.
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.

View File

@ -0,0 +1,12 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the license or (at your option) any later version
that is accepted by the membership of KDE e.V. (or its successor
approved by the membership of KDE e.V.), which shall act as a
proxy as defined in Section 6 of version 3 of the license.
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.

19
LICENSES/MIT.txt Normal file
View File

@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

19
Mainpage.dox Normal file
View File

@ -0,0 +1,19 @@
/** @mainpage KWin
KWin is the KDE window manager.
@authors
Matthias Ettrich \<ettrich@kde.org\><br>
Lubos Lunak \<l.lunak@kde.org\>
@maintainers
Lubos Lunak \<l.lunak@kde.org\>
@licenses
@gpl
*/
// DOXYGEN_SET_PROJECT_NAME = KWin
// vim:ts=4:sw=4:expandtab:filetype=doxygen

49
README.md Normal file
View File

@ -0,0 +1,49 @@
# KWin
KWin is an easy to use, but flexible, composited Window Manager for Xorg windowing systems (Wayland, X11) on Linux. Its primary usage is in conjunction with a Desktop Shell (e.g. KDE Plasma Desktop). KWin is designed to go out of the way; users should not notice that they use a window manager at all. Nevertheless KWin provides a steep learning curve for advanced features, which are available, if they do not conflict with the primary mission. KWin does not have a dedicated targeted user group, but follows the targeted user group of the Desktop Shell using KWin as it's window manager.
## KWin is not...
* a standalone window manager (c.f. openbox, i3) and does not provide any functionality belonging to a Desktop Shell.
* a replacement for window managers designed for use with a specific Desktop Shell (e.g. GNOME Shell)
* a minimalistic window manager
* designed for use without compositing or for X11 network transparency, though both are possible.
# Contributing to KWin
Please refer to the [contributing document](CONTRIBUTING.md) for everything you need to know to get started contributing to KWin.
# Contacting KWin development team
* mailing list: [kwin@kde.org](https://mail.kde.org/mailman/listinfo/kwin)
* IRC: #kde-kwin on irc.libera.chat
# Support
## Application Developer
If you are an application developer having questions regarding windowing systems (either X11 or Wayland) please do not hesitate to contact us. Preferable through our mailing list. Ideally subscribe to the mailing list, so that your mail doesn't get stuck in the moderation queue.
## End user
Please contact the support channels of your Linux distribution for user support. The KWin development team does not provide end user support.
# Reporting bugs
Please use [KDE's bugtracker](https://bugs.kde.org) and report for [product KWin](https://bugs.kde.org/enter_bug.cgi?product=kwin).
## Guidelines for new features
A new Feature can only be added to KWin if:
* it does not violate the primary missions as stated at the start of this document
* it does not introduce instabilities
* it is maintained, that is bugs are fixed in a timely manner (second next minor release) if it is not a corner case.
* it works together with all existing features
* it supports both single and multi screen (xrandr)
* it adds a significant advantage
* it is feature complete, that is supports at least all useful features from competitive implementations
* it is not a special case for a small user group
* it does not increase code complexity significantly
* it does not affect KWin's license (GPLv2+)
All new added features are under probation, that is if any of the non-functional requirements as listed above do not hold true in the next two feature releases, the added feature will be removed again.
The same non functional requirements hold true for any kind of plugins (effects, scripts, etc.). It is suggested to use scripted plugins and distribute them separately.

253
autotests/CMakeLists.txt Normal file
View File

@ -0,0 +1,253 @@
add_definitions(-DKWIN_UNIT_TEST)
remove_definitions(-DQT_USE_QSTRINGBUILDER)
add_subdirectory(libkwineffects)
add_subdirectory(integration)
add_subdirectory(libinput)
add_subdirectory(tabbox)
add_subdirectory(drm)
########################################################
# Test WindowPaintData
########################################################
set(testWindowPaintData_SRCS test_window_paint_data.cpp)
add_executable(testWindowPaintData ${testWindowPaintData_SRCS})
target_link_libraries(testWindowPaintData kwineffects Qt::Widgets Qt::Test )
add_test(NAME kwin-testWindowPaintData COMMAND testWindowPaintData)
ecm_mark_as_test(testWindowPaintData)
########################################################
# Test VirtualDesktopManager
########################################################
set(testVirtualDesktops_SRCS
../src/virtualdesktops.cpp
test_virtual_desktops.cpp
)
add_executable(testVirtualDesktops ${testVirtualDesktops_SRCS})
target_link_libraries(testVirtualDesktops
kwin
Qt::Test
Qt::Widgets
KF5::ConfigCore
KF5::GlobalAccel
KF5::I18n
KF5::WindowSystem
)
add_test(NAME kwin-testVirtualDesktops COMMAND testVirtualDesktops)
ecm_mark_as_test(testVirtualDesktops)
########################################################
# Test ClientMachine
########################################################
set(testClientMachine_SRCS
../src/client_machine.cpp
test_client_machine.cpp
xcb_scaling_mock.cpp
)
add_executable(testClientMachine ${testClientMachine_SRCS})
set_target_properties(testClientMachine PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries(testClientMachine
Qt::Concurrent
Qt::Test
Qt::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
XCB::XFIXES
${X11_X11_LIB} # to make jenkins happy
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(testClientMachine Qt::X11Extras)
else()
target_link_libraries(testClientMachine Qt::GuiPrivate)
endif()
add_test(NAME kwin-testClientMachine COMMAND testClientMachine)
ecm_mark_as_test(testClientMachine)
########################################################
# Test XcbWrapper
########################################################
add_executable(testXcbWrapper test_xcb_wrapper.cpp xcb_scaling_mock.cpp)
target_link_libraries(testXcbWrapper
Qt::Test
Qt::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(testXcbWrapper Qt::X11Extras)
else()
target_link_libraries(testXcbWrapper Qt::GuiPrivate)
endif()
add_test(NAME kwin-testXcbWrapper COMMAND testXcbWrapper)
ecm_mark_as_test(testXcbWrapper)
if (XCB_ICCCM_FOUND)
add_executable(testXcbSizeHints test_xcb_size_hints.cpp xcb_scaling_mock.cpp)
set_target_properties(testXcbSizeHints PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries(testXcbSizeHints
Qt::Test
Qt::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::ICCCM
XCB::XCB
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(testXcbSizeHints Qt::X11Extras)
else()
target_link_libraries(testXcbSizeHints Qt::GuiPrivate)
endif()
add_test(NAME kwin-testXcbSizeHints COMMAND testXcbSizeHints)
ecm_mark_as_test(testXcbSizeHints)
endif()
########################################################
# Test XcbWindow
########################################################
add_executable(testXcbWindow test_xcb_window.cpp xcb_scaling_mock.cpp)
target_link_libraries(testXcbWindow
Qt::Test
Qt::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(testXcbWindow Qt::X11Extras)
else()
target_link_libraries(testXcbWindow Qt::GuiPrivate)
endif()
add_test(NAME kwin-testXcbWindow COMMAND testXcbWindow)
ecm_mark_as_test(testXcbWindow)
include_directories(${KWin_SOURCE_DIR}/src)
########################################################
# Test OnScreenNotification
########################################################
set(testOnScreenNotification_SRCS
../src/input_event_spy.cpp
../src/onscreennotification.cpp
onscreennotificationtest.cpp
)
add_executable(testOnScreenNotification ${testOnScreenNotification_SRCS})
target_link_libraries(testOnScreenNotification
Qt::DBus
Qt::Quick
Qt::Test
Qt::Widgets # QAction include
KF5::ConfigCore
)
add_test(NAME kwin-testOnScreenNotification COMMAND testOnScreenNotification)
ecm_mark_as_test(testOnScreenNotification)
########################################################
# Test Gestures
########################################################
set(testGestures_SRCS
../src/gestures.cpp
test_gestures.cpp
)
add_executable(testGestures ${testGestures_SRCS})
target_link_libraries(testGestures
Qt::Test
)
add_test(NAME kwin-testGestures COMMAND testGestures)
ecm_mark_as_test(testGestures)
########################################################
# Test X11 TimestampUpdate
########################################################
add_executable(testX11TimestampUpdate test_x11_timestamp_update.cpp)
target_link_libraries(testX11TimestampUpdate
KF5::CoreAddons
Qt::Test
kwin
)
add_test(NAME kwin-testX11TimestampUpdate COMMAND testX11TimestampUpdate)
ecm_mark_as_test(testX11TimestampUpdate)
set(testOpenGLContextAttributeBuilder_SRCS
../src/utils/abstract_opengl_context_attribute_builder.cpp
../src/utils/egl_context_attribute_builder.cpp
opengl_context_attribute_builder_test.cpp
)
if (HAVE_EPOXY_GLX)
set(testOpenGLContextAttributeBuilder_SRCS ${testOpenGLContextAttributeBuilder_SRCS} ../src/backends/x11/standalone/x11_standalone_glx_context_attribute_builder.cpp)
endif()
add_executable(testOpenGLContextAttributeBuilder ${testOpenGLContextAttributeBuilder_SRCS})
target_link_libraries(testOpenGLContextAttributeBuilder epoxy::epoxy Qt::Test)
add_test(NAME kwin-testOpenGLContextAttributeBuilder COMMAND testOpenGLContextAttributeBuilder)
ecm_mark_as_test(testOpenGLContextAttributeBuilder)
set(testXkb_SRCS
../src/xkb.cpp
test_xkb.cpp
)
qt_add_dbus_interface(testXkb_SRCS ${CMAKE_SOURCE_DIR}/src/org.freedesktop.DBus.Properties.xml dbusproperties_interface)
add_executable(testXkb ${testXkb_SRCS})
target_link_libraries(testXkb
kwin
Qt::Gui
Qt::Test
Qt::Widgets
KF5::ConfigCore
KF5::WindowSystem
kwineffects
XKB::XKB
)
if (QT_MAJOR_VERSION EQUAL "5")
target_link_libraries(testXkb Qt5::XkbCommonSupportPrivate)
else()
target_link_libraries(testXkb Qt::GuiPrivate)
endif()
add_test(NAME kwin-testXkb COMMAND testXkb)
ecm_mark_as_test(testXkb)
########################################################
# Test FTrace
########################################################
add_executable(testFtrace test_ftrace.cpp)
target_link_libraries(testFtrace
Qt::Test
kwin
)
add_test(NAME kwin-testFtrace COMMAND testFtrace)
ecm_mark_as_test(testFtrace)
########################################################
# Test KWin Utils
########################################################
add_executable(testUtils test_utils.cpp)
target_link_libraries(testUtils
Qt::Test
kwin
)
add_test(NAME kwin-testUtils COMMAND testUtils)
ecm_mark_as_test(testUtils)

View File

@ -0,0 +1,62 @@
set(mockDRM_SRCS
mock_drm.cpp
../../src/backends/drm/drm_abstract_output.cpp
../../src/backends/drm/drm_backend.cpp
../../src/backends/drm/drm_buffer.cpp
../../src/backends/drm/drm_buffer_gbm.cpp
../../src/backends/drm/drm_dmabuf_feedback.cpp
../../src/backends/drm/drm_dumb_buffer.cpp
../../src/backends/drm/drm_dumb_swapchain.cpp
../../src/backends/drm/drm_egl_backend.cpp
../../src/backends/drm/drm_egl_cursor_layer.cpp
../../src/backends/drm/drm_egl_layer.cpp
../../src/backends/drm/drm_egl_layer_surface.cpp
../../src/backends/drm/drm_gbm_surface.cpp
../../src/backends/drm/drm_gpu.cpp
../../src/backends/drm/drm_layer.cpp
../../src/backends/drm/drm_logging.cpp
../../src/backends/drm/drm_connector.cpp
../../src/backends/drm/drm_object.cpp
../../src/backends/drm/drm_crtc.cpp
../../src/backends/drm/drm_plane.cpp
../../src/backends/drm/drm_output.cpp
../../src/backends/drm/drm_pipeline.cpp
../../src/backends/drm/drm_pipeline_legacy.cpp
../../src/backends/drm/drm_property.cpp
../../src/backends/drm/drm_qpainter_backend.cpp
../../src/backends/drm/drm_qpainter_layer.cpp
../../src/backends/drm/drm_shadow_buffer.cpp
../../src/backends/drm/drm_virtual_egl_layer.cpp
../../src/backends/drm/drm_virtual_output.cpp
)
include_directories(${Libdrm_INCLUDE_DIRS})
add_library(LibDrmTest STATIC ${mockDRM_SRCS})
target_link_libraries(LibDrmTest
Qt::Gui
Qt::Widgets
KF5::ConfigCore
KF5::WindowSystem
KF5::CoreAddons
KF5::I18n
XCB::XCB
PkgConfig::Libxcvt
gbm::gbm
kwin
)
target_include_directories(LibDrmTest
PUBLIC
../../src
../../src/platformsupport/scenes/opengl
../../src/platformsupport/scenes/qpainter
../../src/backends/drm/
)
########################################################
# Tests
########################################################
add_executable(testDrm drmTest.cpp)
target_link_libraries(testDrm LibDrmTest Qt::Test)
add_test(NAME kwin-testDrm COMMAND testDrm)
ecm_mark_as_test(testDrm)

320
autotests/drm/drmTest.cpp Normal file
View File

@ -0,0 +1,320 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QSize>
#include <QtTest>
#include "mock_drm.h"
#include "drm_backend.h"
#include "drm_dumb_buffer.h"
#include "drm_egl_backend.h"
#include "drm_gpu.h"
#include "drm_connector.h"
#include "drm_crtc.h"
#include "drm_plane.h"
#include "drm_output.h"
#include "drm_pipeline.h"
#include "drm_pointer.h"
#include "qpainterbackend.h"
#include "core/session.h"
#include <drm_fourcc.h>
using namespace KWin;
class DrmTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testAmsDetection();
void testOutputDetection();
void testZeroModesHandling();
void testModeGeneration_data();
void testModeGeneration();
void testConnectorLifetime();
};
static void verifyCleanup(MockGpu *mockGpu)
{
QVERIFY(mockGpu->drmConnectors.isEmpty());
QVERIFY(mockGpu->drmEncoders.isEmpty());
QVERIFY(mockGpu->drmCrtcs.isEmpty());
QVERIFY(mockGpu->drmPlanes.isEmpty());
QVERIFY(mockGpu->drmPlaneRes.isEmpty());
QVERIFY(mockGpu->fbs.isEmpty());
QVERIFY(mockGpu->drmProps.isEmpty());
QVERIFY(mockGpu->drmObjectProperties.isEmpty());
QVERIFY(mockGpu->drmPropertyBlobs.isEmpty());
}
void DrmTest::testAmsDetection()
{
const auto mockGpu = std::make_unique<MockGpu>(1, 0);
const auto session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
// gpu without planes should use legacy mode
auto gpu = std::make_unique<DrmGpu>(backend.get(), "legacy", 1, 0);
QVERIFY(!gpu->atomicModeSetting());
// gpu with planes should use AMS
mockGpu->planes << std::make_shared<MockPlane>(mockGpu.get(), PlaneType::Primary, 0);
gpu = std::make_unique<DrmGpu>(backend.get(), "AMS", 1, 0);
QVERIFY(gpu->atomicModeSetting());
// but not if the kernel doesn't allow it
mockGpu->deviceCaps[MOCKDRM_DEVICE_CAP_ATOMIC] = 0;
gpu = std::make_unique<DrmGpu>(backend.get(), "legacy 2", 1, 0);
QVERIFY(!gpu->atomicModeSetting());
gpu.reset();
verifyCleanup(mockGpu.get());
}
void DrmTest::testOutputDetection()
{
const auto mockGpu = std::make_unique<MockGpu>(1, 5);
const auto one = std::make_shared<MockConnector>(mockGpu.get());
const auto two = std::make_shared<MockConnector>(mockGpu.get());
const auto vr = std::make_shared<MockConnector>(mockGpu.get(), true);
mockGpu->connectors.push_back(one);
mockGpu->connectors.push_back(two);
mockGpu->connectors.push_back(vr);
const auto session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
const auto renderBackend = backend->createQPainterBackend();
auto gpu = std::make_unique<DrmGpu>(backend.get(), "test", 1, 0);
QVERIFY(gpu->updateOutputs());
// 3 outputs should be detected, one of them non-desktop
const auto outputs = gpu->drmOutputs();
QCOMPARE(outputs.size(), 3);
const auto vrOutput = std::find_if(outputs.begin(), outputs.end(), [](const auto &output) {
return output->isNonDesktop();
});
QVERIFY(vrOutput != outputs.end());
QVERIFY(static_cast<DrmOutput *>(*vrOutput)->connector()->id() == vr->id);
// test hotunplugging
mockGpu->connectors.removeOne(one);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 2);
// test hotplugging
mockGpu->connectors.push_back(one);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 3);
// connector state changing to disconnected should count as a hotunplug
one->connection = DRM_MODE_DISCONNECTED;
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 2);
// don't crash if all connectors are disconnected
two->connection = DRM_MODE_DISCONNECTED;
vr->connection = DRM_MODE_DISCONNECTED;
QVERIFY(gpu->updateOutputs());
QVERIFY(gpu->drmOutputs().empty());
gpu.reset();
verifyCleanup(mockGpu.get());
}
void DrmTest::testZeroModesHandling()
{
const auto mockGpu = std::make_unique<MockGpu>(1, 5);
const auto conn = std::make_shared<MockConnector>(mockGpu.get());
mockGpu->connectors.push_back(conn);
const auto session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
const auto renderBackend = backend->createQPainterBackend();
auto gpu = std::make_unique<DrmGpu>(backend.get(), "test", 1, 0);
// connector with zero modes should be ignored
conn->modes.clear();
QVERIFY(gpu->updateOutputs());
QVERIFY(gpu->drmOutputs().empty());
// once it has modes, it should be detected
conn->addMode(1920, 1080, 60);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
// if an update says it has no modes anymore but it's still connected, ignore that
conn->modes.clear();
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
QVERIFY(!gpu->drmOutputs().constFirst()->modes().empty());
gpu.reset();
verifyCleanup(mockGpu.get());
}
void DrmTest::testModeGeneration_data()
{
QTest::addColumn<QSize>("nativeMode");
QTest::addColumn<QVector<QSize>>("expectedModes");
QTest::newRow("2160p") << QSize(3840, 2160) << QVector<QSize>{
QSize(1600, 1200),
QSize(1280, 1024),
QSize(1024, 768),
QSize(2560, 1600),
QSize(1920, 1200),
QSize(1280, 800),
QSize(3840, 2160),
QSize(3200, 1800),
QSize(2880, 1620),
QSize(2560, 1440),
QSize(1920, 1080),
QSize(1600, 900),
QSize(1368, 768),
QSize(1280, 720),
};
QTest::newRow("1440p") << QSize(2560, 1440) << QVector<QSize>{
QSize(1600, 1200),
QSize(1280, 1024),
QSize(1024, 768),
QSize(1920, 1200),
QSize(1280, 800),
QSize(2560, 1440),
QSize(1920, 1080),
QSize(1600, 900),
QSize(1368, 768),
QSize(1280, 720),
};
QTest::newRow("1080p") << QSize(1920, 1080) << QVector<QSize>{
QSize(1280, 1024),
QSize(1024, 768),
QSize(1280, 800),
QSize(1920, 1080),
QSize(1600, 900),
QSize(1368, 768),
QSize(1280, 720),
};
QTest::newRow("2160p 21:9") << QSize(5120, 2160) << QVector<QSize>{
QSize(5120, 2160),
QSize(1600, 1200),
QSize(1280, 1024),
QSize(1024, 768),
QSize(2560, 1600),
QSize(1920, 1200),
QSize(1280, 800),
QSize(3840, 2160),
QSize(3200, 1800),
QSize(2880, 1620),
QSize(2560, 1440),
QSize(1920, 1080),
QSize(1600, 900),
QSize(1368, 768),
QSize(1280, 720),
};
QTest::newRow("1440p 21:9") << QSize(3440, 1440) << QVector<QSize>{
QSize(3440, 1440),
QSize(1600, 1200),
QSize(1280, 1024),
QSize(1024, 768),
QSize(1920, 1200),
QSize(1280, 800),
QSize(2560, 1440),
QSize(1920, 1080),
QSize(1600, 900),
QSize(1368, 768),
QSize(1280, 720),
};
QTest::newRow("1080p 21:9") << QSize(2560, 1080) << QVector<QSize>{
QSize(2560, 1080),
QSize(1280, 1024),
QSize(1024, 768),
QSize(1280, 800),
QSize(1920, 1080),
QSize(1600, 900),
QSize(1368, 768),
QSize(1280, 720),
};
}
void DrmTest::testModeGeneration()
{
const auto mockGpu = std::make_unique<MockGpu>(1, 5);
const auto conn = std::make_shared<MockConnector>(mockGpu.get());
mockGpu->connectors.push_back(conn);
const auto session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
const auto renderBackend = backend->createQPainterBackend();
auto gpu = std::make_unique<DrmGpu>(backend.get(), "test", 1, 0);
QFETCH(QSize, nativeMode);
QFETCH(QVector<QSize>, expectedModes);
conn->modes.clear();
conn->addMode(nativeMode.width(), nativeMode.height(), 60);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
// no mode generation without the scaling property
QCOMPARE(gpu->drmOutputs().front()->modes().size(), 1);
mockGpu->connectors.removeAll(conn);
QVERIFY(gpu->updateOutputs());
conn->props.push_back(MockProperty(conn.get(), QStringLiteral("scaling mode"), 0, 0, QVector<QByteArray>{"None", "Full", "Center", "Full aspect"}));
mockGpu->connectors.push_back(conn);
QVERIFY(gpu->updateOutputs());
DrmOutput *const output = gpu->drmOutputs().front();
QCOMPARE(output->modes().size(), expectedModes.size());
for (const auto &mode : output->modes()) {
QVERIFY(expectedModes.contains(mode->size()));
QVERIFY(mode->size().width() <= nativeMode.width());
QVERIFY(mode->size().height() <= nativeMode.height());
QVERIFY(mode->refreshRate() <= 60000);
}
gpu.reset();
verifyCleanup(mockGpu.get());
}
void DrmTest::testConnectorLifetime()
{
// don't crash if output lifetime is extended beyond the connector
const auto mockGpu = std::make_unique<MockGpu>(1, 5);
const auto conn = std::make_shared<MockConnector>(mockGpu.get());
mockGpu->connectors.push_back(conn);
const auto session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
const auto renderBackend = backend->createQPainterBackend();
auto gpu = std::make_unique<DrmGpu>(backend.get(), "test", 1, 0);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
DrmOutput *const output = gpu->drmOutputs().front();
output->ref();
mockGpu->connectors.clear();
QVERIFY(gpu->updateOutputs());
output->unref();
gpu.reset();
verifyCleanup(mockGpu.get());
}
QTEST_GUILESS_MAIN(DrmTest)
#include "drmTest.moc"

1286
autotests/drm/mock_drm.cpp Normal file

File diff suppressed because it is too large Load Diff

204
autotests/drm/mock_drm.h Normal file
View File

@ -0,0 +1,204 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <QMap>
#include <QRect>
#include <QVector>
#include <memory>
#include <vector>
class MockGpu;
class MockFb;
class MockCrtc;
class MockEncoder;
class MockObject;
class MockDumbBuffer;
class MockPlane;
class MockProperty {
public:
MockProperty(MockObject *obj, QString name, uint64_t initialValue, uint32_t flags, QVector<QByteArray> enums = {});
~MockProperty() = default;
MockObject *obj;
uint32_t id;
uint32_t flags;
QString name;
uint64_t value;
QVector<QByteArray> enums;
};
class MockPropertyBlob {
public:
MockPropertyBlob(MockGpu *gpu, const void *data, size_t size);
~MockPropertyBlob();
MockGpu *gpu;
uint32_t id;
void *data;
size_t size;
};
class MockObject {
public:
MockObject(MockGpu *gpu);
virtual ~MockObject();
uint64_t getProp(const QString &propName) const;
void setProp(const QString &propName, uint64_t value);
uint32_t getPropId(const QString &propName) const;
uint32_t id;
QVector<MockProperty> props;
MockGpu *gpu;
};
class MockConnector : public MockObject {
public:
MockConnector(MockGpu *gpu, bool nonDesktop = false);
MockConnector(const MockConnector &obj) = default;
~MockConnector() = default;
void addMode(uint32_t width, uint32_t height, float refreshRate, bool preferred = false);
drmModeConnection connection;
uint32_t type;
std::shared_ptr<MockEncoder> encoder;
QVector<drmModeModeInfo> modes;
};
class MockEncoder : public MockObject {
public:
MockEncoder(MockGpu *gpu, uint32_t possible_crtcs);
MockEncoder(const MockEncoder &obj) = default;
~MockEncoder() = default;
MockCrtc *crtc = nullptr;
uint32_t possible_crtcs;
uint32_t possible_clones = 0;
};
class MockCrtc : public MockObject {
public:
MockCrtc(MockGpu *gpu, const std::shared_ptr<MockPlane> &legacyPlane, int pipeIndex, int gamma_size = 255);
MockCrtc(const MockCrtc &obj) = default;
~MockCrtc() = default;
int pipeIndex;
int gamma_size;
drmModeModeInfo mode;
bool modeValid = true;
MockFb *currentFb = nullptr;
MockFb *nextFb = nullptr;
QRect cursorRect;
MockDumbBuffer *cursorBo = nullptr;
std::shared_ptr<MockPlane> legacyPlane;
};
enum class PlaneType {
Primary,
Overlay,
Cursor
};
class MockPlane : public MockObject {
public:
MockPlane(MockGpu *gpu, PlaneType type, int crtcIndex);
MockPlane(const MockPlane &obj) = default;
~MockPlane() = default;
MockFb *currentFb = nullptr;
MockFb *nextFb = nullptr;
int possibleCrtcs;
PlaneType type;
};
class MockFb {
public:
MockFb(MockGpu *gpu, uint32_t width, uint32_t height);
~MockFb();
uint32_t id;
uint32_t width, height;
MockGpu *gpu;
};
class MockDumbBuffer {
public:
MockDumbBuffer(MockGpu *gpu, uint32_t width, uint32_t height, uint32_t bpp);
uint32_t handle;
uint32_t pitch;
std::vector<std::byte> data;
MockGpu *gpu;
};
struct Prop {
uint32_t obj;
uint32_t prop;
uint64_t value;
};
struct _drmModeAtomicReq {
bool legacyEmulation = false;
QVector<Prop> props;
};
#define MOCKDRM_DEVICE_CAP_ATOMIC 0xFF
class MockGpu {
public:
MockGpu(int fd, int numCrtcs, int gammaSize = 255);
~MockGpu();
MockConnector *findConnector(uint32_t id) const;
MockCrtc *findCrtc(uint32_t id) const;
MockPlane *findPlane(uint32_t id) const;
MockPropertyBlob *getBlob(uint32_t id) const;
void flipPage(uint32_t crtcId);
int fd;
QByteArray name = QByteArrayLiteral("mock");
QMap<uint32_t, uint64_t> clientCaps;
QMap<uint32_t, uint64_t> deviceCaps;
uint32_t idCounter = 1;
QVector<MockObject*> objects;
QVector<std::shared_ptr<MockConnector>> connectors;
QVector<drmModeConnectorPtr> drmConnectors;
QVector<std::shared_ptr<MockEncoder>> encoders;
QVector<drmModeEncoderPtr> drmEncoders;
QVector<std::shared_ptr<MockCrtc>> crtcs;
QVector<drmModeCrtcPtr> drmCrtcs;
QVector<std::shared_ptr<MockPlane>> planes;
QVector<drmModePlanePtr> drmPlanes;
QVector<MockFb*> fbs;
QVector<std::shared_ptr<MockDumbBuffer>> dumbBuffers;
std::vector<std::unique_ptr<MockPropertyBlob>> propertyBlobs;
QVector<drmModeResPtr> resPtrs;
QVector<drmModePropertyPtr> drmProps;
QVector<drmModePropertyBlobPtr> drmPropertyBlobs;
QVector<drmModeObjectPropertiesPtr> drmObjectProperties;
QVector<drmModePlaneResPtr> drmPlaneRes;
};

View File

@ -0,0 +1,181 @@
add_subdirectory(helper)
add_library(KWinIntegrationTestFramework SHARED)
if (QT_MAJOR_VERSION EQUAL "5")
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml
BASENAME input-method-unstable-v1
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml
BASENAME text-input-unstable-v3
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL protocols/wlr-layer-shell-unstable-v1.xml
BASENAME wlr-layer-shell-unstable-v1
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
BASENAME xdg-shell
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
BASENAME xdg-decoration-unstable-v1
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
BASENAME idle-inhibit-unstable-v1
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
BASENAME kde-output-device-v2
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
BASENAME kde-output-management-v2
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/staging/fractional-scale/fractional-scale-v1.xml
BASENAME fractional-scale-v1
)
else()
qt6_generate_wayland_protocol_client_sources(KWinIntegrationTestFramework
NO_INCLUDE_CORE_ONLY
FILES
${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml
)
qt6_generate_wayland_protocol_client_sources(KWinIntegrationTestFramework
FILES
${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml
${CMAKE_CURRENT_SOURCE_DIR}/protocols/wlr-layer-shell-unstable-v1.xml
${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
${WaylandProtocols_DATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
${WaylandProtocols_DATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
${WaylandProtocols_DATADIR}/staging/fractional-scale/fractional-scale-v1.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
)
endif()
target_sources(KWinIntegrationTestFramework PRIVATE
../../src/cursor.cpp
generic_scene_opengl_test.cpp
kwin_wayland_test.cpp
test_helpers.cpp
)
target_link_libraries(KWinIntegrationTestFramework
PUBLIC
Qt::Test
KF5::WaylandClient
Wayland::Client
kwin
PRIVATE
# Own libraries
KWinXwaylandServerModule
# Static plugins
KWinQpaPlugin
KF5GlobalAccelKWinPlugin
KF5WindowSystemKWinPlugin
KF5IdleTimeKWinPlugin
)
kcoreaddons_target_static_plugins(KWinIntegrationTestFramework "kwin/effects/plugins" LINK_OPTION "PRIVATE")
set_target_properties(KWinIntegrationTestFramework PROPERTIES CXX_VISIBILITY_PRESET default)
function(integrationTest)
set(optionArgs WAYLAND_ONLY)
set(oneValueArgs NAME)
set(multiValueArgs SRCS LIBS)
cmake_parse_arguments(ARGS "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${ARGS_NAME} ${ARGS_SRCS})
target_link_libraries(${ARGS_NAME} KWinIntegrationTestFramework Qt::Test ${ARGS_LIBS})
add_test(NAME kwin-${ARGS_NAME} COMMAND dbus-run-session ${CMAKE_BINARY_DIR}/bin/${ARGS_NAME})
if (${ARGS_WAYLAND_ONLY})
add_executable(${ARGS_NAME}_waylandonly ${ARGS_SRCS} )
set_target_properties(${ARGS_NAME}_waylandonly PROPERTIES COMPILE_DEFINITIONS "NO_XWAYLAND")
target_link_libraries(${ARGS_NAME}_waylandonly KWinIntegrationTestFramework Qt::Test ${ARGS_LIBS})
add_test(NAME kwin-${ARGS_NAME}-waylandonly COMMAND dbus-run-session ${CMAKE_BINARY_DIR}/bin/${ARGS_NAME}_waylandonly)
endif()
endfunction()
integrationTest(NAME testDontCrashGlxgears SRCS dont_crash_glxgears.cpp)
if (KWIN_BUILD_SCREENLOCKER)
integrationTest(NAME testLockScreen SRCS lockscreen.cpp)
endif()
integrationTest(WAYLAND_ONLY NAME testDecorationInput SRCS decoration_input_test.cpp)
integrationTest(WAYLAND_ONLY NAME testInternalWindow SRCS internal_window.cpp)
integrationTest(WAYLAND_ONLY NAME testTouchInput SRCS touch_input_test.cpp)
integrationTest(WAYLAND_ONLY NAME testInputStackingOrder SRCS input_stacking_order.cpp)
integrationTest(NAME testPointerInput SRCS pointer_input.cpp)
integrationTest(NAME testPlatformCursor SRCS platformcursor.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashCancelAnimation SRCS dont_crash_cancel_animation.cpp)
integrationTest(WAYLAND_ONLY NAME testTransientPlacement SRCS transient_placement.cpp)
integrationTest(NAME testDebugConsole SRCS debug_console_test.cpp)
integrationTest(NAME testDontCrashEmptyDeco SRCS dont_crash_empty_deco.cpp)
integrationTest(WAYLAND_ONLY NAME testPlasmaSurface SRCS plasma_surface_test.cpp)
integrationTest(WAYLAND_ONLY NAME testMaximized SRCS maximize_test.cpp)
integrationTest(WAYLAND_ONLY NAME testXdgShellWindow SRCS xdgshellwindow_test.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashNoBorder SRCS dont_crash_no_border.cpp)
integrationTest(NAME testXwaylandSelections SRCS xwayland_selections_test.cpp)
integrationTest(WAYLAND_ONLY NAME testSceneOpenGL SRCS scene_opengl_test.cpp )
integrationTest(WAYLAND_ONLY NAME testSceneOpenGLES SRCS scene_opengl_es_test.cpp )
integrationTest(WAYLAND_ONLY NAME testScreenChanges SRCS screen_changes_test.cpp)
integrationTest(NAME testModiferOnlyShortcut SRCS modifier_only_shortcut_test.cpp)
if (KWIN_BUILD_TABBOX)
integrationTest(WAYLAND_ONLY NAME testTabBox SRCS tabbox_test.cpp)
endif()
integrationTest(WAYLAND_ONLY NAME testWindowSelection SRCS window_selection_test.cpp)
integrationTest(WAYLAND_ONLY NAME testPointerConstraints SRCS pointer_constraints_test.cpp)
integrationTest(WAYLAND_ONLY NAME testKeyboardLayout SRCS keyboard_layout_test.cpp)
integrationTest(WAYLAND_ONLY NAME testKeymapCreationFailure SRCS keymap_creation_failure_test.cpp)
integrationTest(WAYLAND_ONLY NAME testShowingDesktop SRCS showing_desktop_test.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashUseractionsMenu SRCS dont_crash_useractions_menu.cpp)
integrationTest(WAYLAND_ONLY NAME testKWinBindings SRCS kwinbindings_test.cpp)
integrationTest(WAYLAND_ONLY NAME testLayerShellV1Window SRCS layershellv1window_test.cpp)
integrationTest(WAYLAND_ONLY NAME testVirtualDesktop SRCS virtual_desktop_test.cpp)
integrationTest(WAYLAND_ONLY NAME testXdgShellWindowRules SRCS xdgshellwindow_rules_test.cpp)
integrationTest(WAYLAND_ONLY NAME testIdleInhibition SRCS idle_inhibition_test.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashReinitializeCompositor SRCS dont_crash_reinitialize_compositor.cpp)
integrationTest(WAYLAND_ONLY NAME testNoGlobalShortcuts SRCS no_global_shortcuts_test.cpp)
integrationTest(WAYLAND_ONLY NAME testBufferSizeChange SRCS buffer_size_change_test.cpp )
integrationTest(WAYLAND_ONLY NAME testPlacement SRCS placement_test.cpp)
integrationTest(WAYLAND_ONLY NAME testActivation SRCS activation_test.cpp)
integrationTest(WAYLAND_ONLY NAME testInputMethod SRCS inputmethod_test.cpp)
integrationTest(WAYLAND_ONLY NAME testScreens SRCS screens_test.cpp)
integrationTest(WAYLAND_ONLY NAME testScreenEdges SRCS screenedges_test.cpp)
integrationTest(WAYLAND_ONLY NAME testOutputChanges SRCS outputchanges_test.cpp)
integrationTest(WAYLAND_ONLY NAME testTiles SRCS tiles_test.cpp)
integrationTest(WAYLAND_ONLY NAME testFractionalScaling SRCS fractional_scaling_test.cpp)
qt_add_dbus_interfaces(DBUS_SRCS ${CMAKE_BINARY_DIR}/src/org.kde.kwin.VirtualKeyboard.xml)
integrationTest(WAYLAND_ONLY NAME testVirtualKeyboardDBus SRCS test_virtualkeyboard_dbus.cpp ${DBUS_SRCS})
integrationTest(WAYLAND_ONLY NAME testNightColor SRCS nightcolor_test.cpp LIBS KWinNightColorPlugin)
if (XCB_ICCCM_FOUND)
integrationTest(NAME testMoveResize SRCS move_resize_window_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testStruts SRCS struts_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testShade SRCS shade_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testDontCrashAuroraeDestroyDeco SRCS dont_crash_aurorae_destroy_deco.cpp LIBS XCB::ICCCM)
integrationTest(NAME testPlasmaWindow SRCS plasmawindow_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testScreenEdgeClientShow SRCS screenedge_client_show_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testX11DesktopWindow SRCS desktop_window_x11_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testXwaylandInput SRCS xwayland_input_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testWindowRules SRCS window_rules_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testX11Window SRCS x11_window_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testQuickTiling SRCS quick_tiling_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testGlobalShortcuts SRCS globalshortcuts_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testStackingOrder SRCS stacking_order_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testDbusInterface SRCS dbus_interface_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testXwaylandServerCrash SRCS xwaylandserver_crash_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testXwaylandServerRestart SRCS xwaylandserver_restart_test.cpp LIBS XCB::ICCCM)
if (KWIN_BUILD_ACTIVITIES)
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM)
endif()
endif()
add_subdirectory(scripting)
add_subdirectory(effects)
add_subdirectory(fakes)

View File

@ -0,0 +1,543 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_activation-0");
class ActivationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testSwitchToWindowToLeft();
void testSwitchToWindowToRight();
void testSwitchToWindowAbove();
void testSwitchToWindowBelow();
void testSwitchToWindowMaximized();
void testSwitchToWindowFullScreen();
private:
void stackScreensHorizontally();
void stackScreensVertically();
};
void ActivationTest::initTestCase()
{
qRegisterMetaType<Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
}
void ActivationTest::init()
{
QVERIFY(Test::setupWaylandConnection());
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ActivationTest::cleanup()
{
Test::destroyWaylandConnection();
stackScreensHorizontally();
}
void ActivationTest::testSwitchToWindowToLeft()
{
// This test verifies that "Switch to Window to the Left" shortcut works.
// Prepare the test environment.
stackScreensHorizontally();
// Create several windows on the left screen.
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window1);
QVERIFY(window1->isActive());
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
QVERIFY(window2);
QVERIFY(window2->isActive());
window1->move(QPoint(300, 200));
window2->move(QPoint(500, 200));
// Create several windows on the right screen.
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
QVERIFY(window3);
QVERIFY(window3->isActive());
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
QVERIFY(window4);
QVERIFY(window4->isActive());
window3->move(QPoint(1380, 200));
window4->move(QPoint(1580, 200));
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window3->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window2->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window1->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window4->isActive());
// Destroy all windows.
shellSurface1.reset();
QVERIFY(Test::waitForWindowDestroyed(window1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(window2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowDestroyed(window3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowDestroyed(window4));
}
void ActivationTest::testSwitchToWindowToRight()
{
// This test verifies that "Switch to Window to the Right" shortcut works.
// Prepare the test environment.
stackScreensHorizontally();
// Create several windows on the left screen.
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window1);
QVERIFY(window1->isActive());
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
QVERIFY(window2);
QVERIFY(window2->isActive());
window1->move(QPoint(300, 200));
window2->move(QPoint(500, 200));
// Create several windows on the right screen.
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
QVERIFY(window3);
QVERIFY(window3->isActive());
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
QVERIFY(window4);
QVERIFY(window4->isActive());
window3->move(QPoint(1380, 200));
window4->move(QPoint(1580, 200));
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window1->isActive());
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window2->isActive());
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window3->isActive());
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window4->isActive());
// Destroy all windows.
shellSurface1.reset();
QVERIFY(Test::waitForWindowDestroyed(window1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(window2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowDestroyed(window3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowDestroyed(window4));
}
void ActivationTest::testSwitchToWindowAbove()
{
// This test verifies that "Switch to Window Above" shortcut works.
// Prepare the test environment.
stackScreensVertically();
// Create several windows on the top screen.
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window1);
QVERIFY(window1->isActive());
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
QVERIFY(window2);
QVERIFY(window2->isActive());
window1->move(QPoint(200, 300));
window2->move(QPoint(200, 500));
// Create several windows on the bottom screen.
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
QVERIFY(window3);
QVERIFY(window3->isActive());
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
QVERIFY(window4);
QVERIFY(window4->isActive());
window3->move(QPoint(200, 1224));
window4->move(QPoint(200, 1424));
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window3->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window2->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window1->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window4->isActive());
// Destroy all windows.
shellSurface1.reset();
QVERIFY(Test::waitForWindowDestroyed(window1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(window2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowDestroyed(window3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowDestroyed(window4));
}
void ActivationTest::testSwitchToWindowBelow()
{
// This test verifies that "Switch to Window Bottom" shortcut works.
// Prepare the test environment.
stackScreensVertically();
// Create several windows on the top screen.
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window1);
QVERIFY(window1->isActive());
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
QVERIFY(window2);
QVERIFY(window2->isActive());
window1->move(QPoint(200, 300));
window2->move(QPoint(200, 500));
// Create several windows on the bottom screen.
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
QVERIFY(window3);
QVERIFY(window3->isActive());
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
QVERIFY(window4);
QVERIFY(window4->isActive());
window3->move(QPoint(200, 1224));
window4->move(QPoint(200, 1424));
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window1->isActive());
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window2->isActive());
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window3->isActive());
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window4->isActive());
// Destroy all windows.
shellSurface1.reset();
QVERIFY(Test::waitForWindowDestroyed(window1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(window2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowDestroyed(window3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowDestroyed(window4));
}
void ActivationTest::testSwitchToWindowMaximized()
{
// This test verifies that we switch to the top-most maximized window, i.e.
// the one that user sees at the moment. See bug 411356.
// Prepare the test environment.
stackScreensHorizontally();
// Create several maximized windows on the left screen.
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
QSignalSpy toplevelConfigureRequestedSpy1(shellSurface1.get(), &Test::XdgToplevel::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy1(shellSurface1->xdgSurface(), &Test::XdgSurface::configureRequested);
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window1);
QVERIFY(window1->isActive());
QVERIFY(surfaceConfigureRequestedSpy1.wait()); // Wait for the configure event with the activated state.
workspace()->slotWindowMaximize();
QVERIFY(surfaceConfigureRequestedSpy1.wait());
QSignalSpy frameGeometryChangedSpy1(window1, &Window::frameGeometryChanged);
shellSurface1->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy1.last().at(0).value<quint32>());
Test::render(surface1.get(), toplevelConfigureRequestedSpy1.last().at(0).toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy1.wait());
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
QSignalSpy toplevelConfigureRequestedSpy2(shellSurface2.get(), &Test::XdgToplevel::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
QVERIFY(window2);
QVERIFY(window2->isActive());
QVERIFY(surfaceConfigureRequestedSpy2.wait()); // Wait for the configure event with the activated state.
workspace()->slotWindowMaximize();
QVERIFY(surfaceConfigureRequestedSpy2.wait());
QSignalSpy frameGeometryChangedSpy2(window2, &Window::frameGeometryChanged);
shellSurface2->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy2.last().at(0).value<quint32>());
Test::render(surface2.get(), toplevelConfigureRequestedSpy2.last().at(0).toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy2.wait());
const QList<Window *> stackingOrder = workspace()->stackingOrder();
QVERIFY(stackingOrder.indexOf(window1) < stackingOrder.indexOf(window2));
QCOMPARE(window1->maximizeMode(), MaximizeFull);
QCOMPARE(window2->maximizeMode(), MaximizeFull);
// Create several windows on the right screen.
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
QVERIFY(window3);
QVERIFY(window3->isActive());
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
QVERIFY(window4);
QVERIFY(window4->isActive());
window3->move(QPoint(1380, 200));
window4->move(QPoint(1580, 200));
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window3->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window2->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window4->isActive());
// Destroy all windows.
shellSurface1.reset();
QVERIFY(Test::waitForWindowDestroyed(window1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(window2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowDestroyed(window3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowDestroyed(window4));
}
void ActivationTest::testSwitchToWindowFullScreen()
{
// This test verifies that we switch to the top-most fullscreen window, i.e.
// the one that user sees at the moment. See bug 411356.
// Prepare the test environment.
stackScreensVertically();
// Create several maximized windows on the top screen.
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
QSignalSpy toplevelConfigureRequestedSpy1(shellSurface1.get(), &Test::XdgToplevel::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy1(shellSurface1->xdgSurface(), &Test::XdgSurface::configureRequested);
Window *window1 = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window1);
QVERIFY(window1->isActive());
QVERIFY(surfaceConfigureRequestedSpy1.wait()); // Wait for the configure event with the activated state.
workspace()->slotWindowFullScreen();
QVERIFY(surfaceConfigureRequestedSpy1.wait());
QSignalSpy frameGeometryChangedSpy1(window1, &Window::frameGeometryChanged);
shellSurface1->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy1.last().at(0).value<quint32>());
Test::render(surface1.get(), toplevelConfigureRequestedSpy1.last().at(0).toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy1.wait());
std::unique_ptr<KWayland::Client::Surface> surface2(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.get()));
QSignalSpy toplevelConfigureRequestedSpy2(shellSurface2.get(), &Test::XdgToplevel::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy2(shellSurface2->xdgSurface(), &Test::XdgSurface::configureRequested);
Window *window2 = Test::renderAndWaitForShown(surface2.get(), QSize(100, 50), Qt::blue);
QVERIFY(window2);
QVERIFY(window2->isActive());
QVERIFY(surfaceConfigureRequestedSpy2.wait()); // Wait for the configure event with the activated state.
workspace()->slotWindowFullScreen();
QVERIFY(surfaceConfigureRequestedSpy2.wait());
QSignalSpy frameGeometryChangedSpy2(window2, &Window::frameGeometryChanged);
shellSurface2->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy2.last().at(0).value<quint32>());
Test::render(surface2.get(), toplevelConfigureRequestedSpy2.last().at(0).toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy2.wait());
const QList<Window *> stackingOrder = workspace()->stackingOrder();
QVERIFY(stackingOrder.indexOf(window1) < stackingOrder.indexOf(window2));
QVERIFY(window1->isFullScreen());
QVERIFY(window2->isFullScreen());
// Create several windows on the bottom screen.
std::unique_ptr<KWayland::Client::Surface> surface3(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface3(Test::createXdgToplevelSurface(surface3.get()));
Window *window3 = Test::renderAndWaitForShown(surface3.get(), QSize(100, 50), Qt::blue);
QVERIFY(window3);
QVERIFY(window3->isActive());
std::unique_ptr<KWayland::Client::Surface> surface4(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface4(Test::createXdgToplevelSurface(surface4.get()));
Window *window4 = Test::renderAndWaitForShown(surface4.get(), QSize(100, 50), Qt::blue);
QVERIFY(window4);
QVERIFY(window4->isActive());
window3->move(QPoint(200, 1224));
window4->move(QPoint(200, 1424));
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window3->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window2->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window4->isActive());
// Destroy all windows.
shellSurface1.reset();
QVERIFY(Test::waitForWindowDestroyed(window1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowDestroyed(window2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowDestroyed(window3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowDestroyed(window4));
}
void ActivationTest::stackScreensHorizontally()
{
// Process pending wl_output bind requests before destroying all outputs.
QTest::qWait(1);
const QVector<QRect> screenGeometries{
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
};
QMetaObject::invokeMethod(kwinApp()->outputBackend(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(QVector<QRect>, screenGeometries));
}
void ActivationTest::stackScreensVertically()
{
// Process pending wl_output bind requests before destroying all outputs.
QTest::qWait(1);
const QVector<QRect> screenGeometries{
QRect(0, 0, 1280, 1024),
QRect(0, 1024, 1280, 1024),
};
QMetaObject::invokeMethod(kwinApp()->outputBackend(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(QVector<QRect>, screenGeometries));
}
}
WAYLANDTEST_MAIN(KWin::ActivationTest)
#include "activation_test.moc"

View File

@ -0,0 +1,147 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "activities.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingCall>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_activities-0");
class ActivitiesTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
void testSetOnActivitiesValidates();
private:
};
void ActivitiesTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->setUseKActivities(true);
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
}
void ActivitiesTest::cleanupTestCase()
{
// terminate any still running kactivitymanagerd
QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(
QStringLiteral("org.kde.ActivityManager"),
QStringLiteral("/ActivityManager"),
QStringLiteral("org.qtproject.Qt.QCoreApplication"),
QStringLiteral("quit")));
}
void ActivitiesTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ActivitiesTest::cleanup()
{
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void ActivitiesTest::testSetOnActivitiesValidates()
{
// this test verifies that windows can't be placed on activities that don't exist
// create an xcb window
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
xcb_window_t windowId = xcb_generate_id(c.get());
const QRect windowGeometry(0, 0, 100, 200);
auto cookie = xcb_create_window_checked(c.get(), 0, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, 0, nullptr);
QVERIFY(!xcb_request_check(c.get(), cookie));
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
// verify the test machine doesn't have the following activities used
QVERIFY(!Workspace::self()->activities()->all().contains(QStringLiteral("foo")));
QVERIFY(!Workspace::self()->activities()->all().contains(QStringLiteral("bar")));
window->setOnActivities(QStringList{QStringLiteral("foo"), QStringLiteral("bar")});
QVERIFY(!window->activities().contains(QLatin1String("foo")));
QVERIFY(!window->activities().contains(QLatin1String("bar")));
// and destroy the window again
xcb_unmap_window(c.get(), windowId);
xcb_destroy_window(c.get(), windowId);
xcb_flush(c.get());
c.reset();
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::ActivitiesTest)
#include "activities_test.moc"

View File

@ -0,0 +1,110 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "generic_scene_opengl_test.h"
#include "composite.h"
#include "scene/workspacescene.h"
#include "wayland_server.h"
#include "window.h"
#include <KWayland/Client/subsurface.h>
#include <KWayland/Client/surface.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_buffer_size_change-0");
class BufferSizeChangeTest : public GenericSceneOpenGLTest
{
Q_OBJECT
public:
BufferSizeChangeTest()
: GenericSceneOpenGLTest(QByteArrayLiteral("O2"))
{
}
private Q_SLOTS:
void init();
void testShmBufferSizeChange();
void testShmBufferSizeChangeOnSubSurface();
};
void BufferSizeChangeTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void BufferSizeChangeTest::testShmBufferSizeChange()
{
// This test verifies that an SHM buffer size change is handled correctly
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
// set buffer size
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// add a first repaint
QSignalSpy frameRenderedSpy(Compositor::self()->scene(), &WorkspaceScene::frameRendered);
Compositor::self()->scene()->addRepaintFull();
QVERIFY(frameRenderedSpy.wait());
// now change buffer size
Test::render(surface.get(), QSize(30, 10), Qt::red);
QSignalSpy damagedSpy(window, &Window::damaged);
QVERIFY(damagedSpy.wait());
KWin::Compositor::self()->scene()->addRepaintFull();
QVERIFY(frameRenderedSpy.wait());
}
void BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface()
{
// setup parent surface
std::unique_ptr<KWayland::Client::Surface> parentSurface(Test::createSurface());
QVERIFY(parentSurface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(parentSurface.get()));
QVERIFY(shellSurface != nullptr);
// setup sub surface
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<KWayland::Client::SubSurface> subSurface(Test::createSubSurface(surface.get(), parentSurface.get()));
QVERIFY(subSurface != nullptr);
// set buffer sizes
Test::render(surface.get(), QSize(30, 10), Qt::red);
Window *parent = Test::renderAndWaitForShown(parentSurface.get(), QSize(100, 50), Qt::blue);
QVERIFY(parent);
// add a first repaint
QSignalSpy frameRenderedSpy(Compositor::self()->scene(), &WorkspaceScene::frameRendered);
Compositor::self()->scene()->addRepaintFull();
QVERIFY(frameRenderedSpy.wait());
// change buffer size of sub surface
QSignalSpy damagedParentSpy(parent, &Window::damaged);
Test::render(surface.get(), QSize(20, 10), Qt::red);
parentSurface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(damagedParentSpy.wait());
// add a second repaint
KWin::Compositor::self()->scene()->addRepaintFull();
QVERIFY(frameRenderedSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::BufferSizeChangeTest)
#include "buffer_size_change_test.moc"

View File

@ -0,0 +1,14 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
effects.windowAdded.connect(function(w) {
w.fadeAnimation = effect.animate(w, Effect.Opacity, 100, 1.0, 0.0);
});
effect.animationEnded.connect(function(w) {
cancel(w.fadeAnimation);
});

View File

@ -0,0 +1,3 @@
[Desktop Entry]
Name=An example application
Icon=kwin

View File

@ -0,0 +1,13 @@
Description=Window settings for kpat
clientmachine=localhost
clientmachinematch=0
maximizevert=true
maximizevertrule=3
title=KPatience
titlematch=0
types=1
windowrole=mainwindow
windowrolematch=1
wmclass=kpat
wmclasscomplete=false
wmclassmatch=1

View File

@ -0,0 +1,386 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 Martin Flöser <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "config-kwin.h"
#include "kwin_wayland_test.h"
#include "atoms.h"
#include "core/outputbackend.h"
#include "deleted.h"
#include "rules.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include <KWayland/Client/surface.h>
#include <QDBusArgument>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingReply>
#include <QUuid>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dbus_interface-0");
const QString s_destination{QStringLiteral("org.kde.KWin")};
const QString s_path{QStringLiteral("/KWin")};
const QString s_interface{QStringLiteral("org.kde.KWin")};
class TestDbusInterface : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testGetWindowInfoInvalidUuid();
void testGetWindowInfoXdgShellClient();
void testGetWindowInfoX11Client();
};
void TestDbusInterface::initTestCase()
{
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
VirtualDesktopManager::self()->setCount(4);
}
void TestDbusInterface::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void TestDbusInterface::cleanup()
{
Test::destroyWaylandConnection();
}
namespace
{
QDBusPendingCall getWindowInfo(const QUuid &uuid)
{
auto msg = QDBusMessage::createMethodCall(s_destination, s_path, s_interface, QStringLiteral("getWindowInfo"));
msg.setArguments({uuid.toString()});
return QDBusConnection::sessionBus().asyncCall(msg);
}
}
void TestDbusInterface::testGetWindowInfoInvalidUuid()
{
QDBusPendingReply<QVariantMap> reply{getWindowInfo(QUuid::createUuid())};
reply.waitForFinished();
QVERIFY(reply.isValid());
QVERIFY(!reply.isError());
const auto windowData = reply.value();
QVERIFY(windowData.empty());
}
void TestDbusInterface::testGetWindowInfoXdgShellClient()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
shellSurface->set_app_id(QStringLiteral("org.kde.foo"));
shellSurface->set_title(QStringLiteral("Test window"));
// now let's render
Test::render(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(windowAddedSpy.isEmpty());
QVERIFY(windowAddedSpy.wait());
auto window = windowAddedSpy.first().first().value<Window *>();
QVERIFY(window);
const QVariantMap expectedData = {
{QStringLiteral("type"), int(NET::Normal)},
{QStringLiteral("x"), window->x()},
{QStringLiteral("y"), window->y()},
{QStringLiteral("width"), window->width()},
{QStringLiteral("height"), window->height()},
{QStringLiteral("desktops"), window->desktopIds()},
{QStringLiteral("minimized"), false},
{QStringLiteral("shaded"), false},
{QStringLiteral("fullscreen"), false},
{QStringLiteral("keepAbove"), false},
{QStringLiteral("keepBelow"), false},
{QStringLiteral("skipTaskbar"), false},
{QStringLiteral("skipPager"), false},
{QStringLiteral("skipSwitcher"), false},
{QStringLiteral("maximizeHorizontal"), false},
{QStringLiteral("maximizeVertical"), false},
{QStringLiteral("noBorder"), false},
{QStringLiteral("clientMachine"), QString()},
{QStringLiteral("localhost"), true},
{QStringLiteral("role"), QString()},
{QStringLiteral("resourceName"), QStringLiteral("testDbusInterface")},
{QStringLiteral("resourceClass"), QStringLiteral("org.kde.foo")},
{QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo")},
{QStringLiteral("caption"), QStringLiteral("Test window")},
#if KWIN_BUILD_ACTIVITIES
{QStringLiteral("activities"), QStringList()},
#endif
};
// let's get the window info
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
reply.waitForFinished();
QVERIFY(reply.isValid());
QVERIFY(!reply.isError());
auto windowData = reply.value();
windowData.remove(QStringLiteral("uuid"));
QCOMPARE(windowData, expectedData);
auto verifyProperty = [window](const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
reply.waitForFinished();
return reply.value().value(name).toBool();
};
QVERIFY(!window->isMinimized());
window->setMinimized(true);
QVERIFY(window->isMinimized());
QCOMPARE(verifyProperty(QStringLiteral("minimized")), true);
QVERIFY(!window->keepAbove());
window->setKeepAbove(true);
QVERIFY(window->keepAbove());
QCOMPARE(verifyProperty(QStringLiteral("keepAbove")), true);
QVERIFY(!window->keepBelow());
window->setKeepBelow(true);
QVERIFY(window->keepBelow());
QCOMPARE(verifyProperty(QStringLiteral("keepBelow")), true);
QVERIFY(!window->skipTaskbar());
window->setSkipTaskbar(true);
QVERIFY(window->skipTaskbar());
QCOMPARE(verifyProperty(QStringLiteral("skipTaskbar")), true);
QVERIFY(!window->skipPager());
window->setSkipPager(true);
QVERIFY(window->skipPager());
QCOMPARE(verifyProperty(QStringLiteral("skipPager")), true);
QVERIFY(!window->skipSwitcher());
window->setSkipSwitcher(true);
QVERIFY(window->skipSwitcher());
QCOMPARE(verifyProperty(QStringLiteral("skipSwitcher")), true);
// not testing shaded as that's X11
// not testing fullscreen, maximizeHorizontal, maximizeVertical and noBorder as those require window geometry changes
QCOMPARE(window->desktop(), 1);
workspace()->sendWindowToDesktop(window, 2, false);
QCOMPARE(window->desktop(), 2);
reply = getWindowInfo(window->internalId());
reply.waitForFinished();
QCOMPARE(reply.value().value(QStringLiteral("desktops")).toStringList(), window->desktopIds());
window->move(QPoint(10, 20));
reply = getWindowInfo(window->internalId());
reply.waitForFinished();
QCOMPARE(reply.value().value(QStringLiteral("x")).toInt(), window->x());
QCOMPARE(reply.value().value(QStringLiteral("y")).toInt(), window->y());
// not testing width, height as that would require window geometry change
// finally close window
const auto id = window->internalId();
QSignalSpy windowClosedSpy(window, &Window::windowClosed);
shellSurface.reset();
surface.reset();
QVERIFY(windowClosedSpy.wait());
QCOMPARE(windowClosedSpy.count(), 1);
reply = getWindowInfo(id);
reply.waitForFinished();
QVERIFY(reply.value().empty());
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void TestDbusInterface::testGetWindowInfoX11Client()
{
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
const QRect windowGeometry(0, 0, 600, 400);
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
xcb_icccm_set_wm_class(c.get(), windowId, 7, "foo\0bar");
NETWinInfo winInfo(c.get(), windowId, rootWindow(), NET::Properties(), NET::Properties2());
winInfo.setName("Some caption");
winInfo.setDesktopFileName("org.kde.foo");
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QCOMPARE(window->clientSize(), windowGeometry.size());
const QVariantMap expectedData = {
{QStringLiteral("type"), NET::Normal},
{QStringLiteral("x"), window->x()},
{QStringLiteral("y"), window->y()},
{QStringLiteral("width"), window->width()},
{QStringLiteral("height"), window->height()},
{QStringLiteral("desktops"), window->desktopIds()},
{QStringLiteral("minimized"), false},
{QStringLiteral("shaded"), false},
{QStringLiteral("fullscreen"), false},
{QStringLiteral("keepAbove"), false},
{QStringLiteral("keepBelow"), false},
{QStringLiteral("skipTaskbar"), false},
{QStringLiteral("skipPager"), false},
{QStringLiteral("skipSwitcher"), false},
{QStringLiteral("maximizeHorizontal"), false},
{QStringLiteral("maximizeVertical"), false},
{QStringLiteral("noBorder"), false},
{QStringLiteral("role"), QString()},
{QStringLiteral("resourceName"), QStringLiteral("foo")},
{QStringLiteral("resourceClass"), QStringLiteral("bar")},
{QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo")},
{QStringLiteral("caption"), QStringLiteral("Some caption")},
#if KWIN_BUILD_ACTIVITIES
{QStringLiteral("activities"), QStringList()},
#endif
};
// let's get the window info
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
reply.waitForFinished();
QVERIFY(reply.isValid());
QVERIFY(!reply.isError());
auto windowData = reply.value();
// not testing clientmachine as that is system dependent due to that also not testing localhost
windowData.remove(QStringLiteral("clientMachine"));
windowData.remove(QStringLiteral("localhost"));
windowData.remove(QStringLiteral("uuid"));
QCOMPARE(windowData, expectedData);
auto verifyProperty = [window](const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
reply.waitForFinished();
return reply.value().value(name).toBool();
};
QVERIFY(!window->isMinimized());
window->setMinimized(true);
QVERIFY(window->isMinimized());
QCOMPARE(verifyProperty(QStringLiteral("minimized")), true);
QVERIFY(!window->keepAbove());
window->setKeepAbove(true);
QVERIFY(window->keepAbove());
QCOMPARE(verifyProperty(QStringLiteral("keepAbove")), true);
QVERIFY(!window->keepBelow());
window->setKeepBelow(true);
QVERIFY(window->keepBelow());
QCOMPARE(verifyProperty(QStringLiteral("keepBelow")), true);
QVERIFY(!window->skipTaskbar());
window->setSkipTaskbar(true);
QVERIFY(window->skipTaskbar());
QCOMPARE(verifyProperty(QStringLiteral("skipTaskbar")), true);
QVERIFY(!window->skipPager());
window->setSkipPager(true);
QVERIFY(window->skipPager());
QCOMPARE(verifyProperty(QStringLiteral("skipPager")), true);
QVERIFY(!window->skipSwitcher());
window->setSkipSwitcher(true);
QVERIFY(window->skipSwitcher());
QCOMPARE(verifyProperty(QStringLiteral("skipSwitcher")), true);
QVERIFY(!window->isShade());
window->setShade(ShadeNormal);
QVERIFY(window->isShade());
QCOMPARE(verifyProperty(QStringLiteral("shaded")), true);
window->setShade(ShadeNone);
QVERIFY(!window->isShade());
QVERIFY(!window->noBorder());
window->setNoBorder(true);
QVERIFY(window->noBorder());
QCOMPARE(verifyProperty(QStringLiteral("noBorder")), true);
window->setNoBorder(false);
QVERIFY(!window->noBorder());
QVERIFY(!window->isFullScreen());
window->setFullScreen(true);
QVERIFY(window->isFullScreen());
QVERIFY(window->clientSize() != windowGeometry.size());
QCOMPARE(verifyProperty(QStringLiteral("fullscreen")), true);
reply = getWindowInfo(window->internalId());
reply.waitForFinished();
QCOMPARE(reply.value().value(QStringLiteral("width")).toInt(), window->width());
QCOMPARE(reply.value().value(QStringLiteral("height")).toInt(), window->height());
window->setFullScreen(false);
QVERIFY(!window->isFullScreen());
// maximize
window->setMaximize(true, false);
QCOMPARE(verifyProperty(QStringLiteral("maximizeVertical")), true);
QCOMPARE(verifyProperty(QStringLiteral("maximizeHorizontal")), false);
window->setMaximize(false, true);
QCOMPARE(verifyProperty(QStringLiteral("maximizeVertical")), false);
QCOMPARE(verifyProperty(QStringLiteral("maximizeHorizontal")), true);
const auto id = window->internalId();
// destroy the window
xcb_unmap_window(c.get(), windowId);
xcb_flush(c.get());
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.wait());
xcb_destroy_window(c.get(), windowId);
c.reset();
reply = getWindowInfo(id);
reply.waitForFinished();
QVERIFY(reply.value().empty());
}
WAYLANDTEST_MAIN(TestDbusInterface)
#include "dbus_interface_test.moc"

View File

@ -0,0 +1,494 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "debug_console.h"
#include "internalwindow.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
#include <QPainter>
#include <QRasterWindow>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_debug_console-0");
class DebugConsoleTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanup();
void topLevelTest_data();
void topLevelTest();
void testX11Window();
void testX11Unmanaged();
void testWaylandClient();
void testInternalWindow();
void testClosingDebugConsole();
};
void DebugConsoleTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::InternalWindow *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
}
void DebugConsoleTest::cleanup()
{
Test::destroyWaylandConnection();
}
void DebugConsoleTest::topLevelTest_data()
{
QTest::addColumn<int>("row");
QTest::addColumn<int>("column");
QTest::addColumn<bool>("expectedValid");
// this tests various combinations of row/column on the top level whether they are valid
// valid are rows 0-4 with column 0, everything else is invalid
QTest::newRow("0/0") << 0 << 0 << true;
QTest::newRow("0/1") << 0 << 1 << false;
QTest::newRow("0/3") << 0 << 3 << false;
QTest::newRow("1/0") << 1 << 0 << true;
QTest::newRow("1/1") << 1 << 1 << false;
QTest::newRow("1/3") << 1 << 3 << false;
QTest::newRow("2/0") << 2 << 0 << true;
QTest::newRow("3/0") << 3 << 0 << true;
QTest::newRow("4/0") << 4 << 0 << false;
QTest::newRow("100/0") << 4 << 0 << false;
}
void DebugConsoleTest::topLevelTest()
{
DebugConsoleModel model;
QCOMPARE(model.rowCount(QModelIndex()), 4);
QCOMPARE(model.columnCount(QModelIndex()), 2);
QFETCH(int, row);
QFETCH(int, column);
const QModelIndex index = model.index(row, column, QModelIndex());
QTEST(index.isValid(), "expectedValid");
if (index.isValid()) {
QVERIFY(!model.parent(index).isValid());
QVERIFY(model.data(index, Qt::DisplayRole).isValid());
QCOMPARE(model.data(index, Qt::DisplayRole).userType(), int(QMetaType::QString));
for (int i = Qt::DecorationRole; i <= Qt::UserRole; i++) {
QVERIFY(!model.data(index, i).isValid());
}
}
}
void DebugConsoleTest::testX11Window()
{
DebugConsoleModel model;
QModelIndex x11TopLevelIndex = model.index(0, 0, QModelIndex());
QVERIFY(x11TopLevelIndex.isValid());
// we don't have any windows yet
QCOMPARE(model.rowCount(x11TopLevelIndex), 0);
QVERIFY(!model.hasChildren(x11TopLevelIndex));
// child index must be invalid
QVERIFY(!model.index(0, 0, x11TopLevelIndex).isValid());
QVERIFY(!model.index(0, 1, x11TopLevelIndex).isValid());
QVERIFY(!model.index(0, 2, x11TopLevelIndex).isValid());
QVERIFY(!model.index(1, 0, x11TopLevelIndex).isValid());
// start glxgears, to get a window, which should be added to the model
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
QProcess glxgears;
glxgears.setProgram(QStringLiteral("glxgears"));
glxgears.start();
QVERIFY(glxgears.waitForStarted());
QVERIFY(rowsInsertedSpy.wait());
QCOMPARE(rowsInsertedSpy.count(), 1);
QVERIFY(model.hasChildren(x11TopLevelIndex));
QCOMPARE(model.rowCount(x11TopLevelIndex), 1);
QCOMPARE(rowsInsertedSpy.first().at(0).value<QModelIndex>(), x11TopLevelIndex);
QCOMPARE(rowsInsertedSpy.first().at(1).value<int>(), 0);
QCOMPARE(rowsInsertedSpy.first().at(2).value<int>(), 0);
QModelIndex windowIndex = model.index(0, 0, x11TopLevelIndex);
QVERIFY(windowIndex.isValid());
QCOMPARE(model.parent(windowIndex), x11TopLevelIndex);
QVERIFY(model.hasChildren(windowIndex));
QVERIFY(model.rowCount(windowIndex) != 0);
QCOMPARE(model.columnCount(windowIndex), 2);
// other indexes are still invalid
QVERIFY(!model.index(0, 1, x11TopLevelIndex).isValid());
QVERIFY(!model.index(0, 2, x11TopLevelIndex).isValid());
QVERIFY(!model.index(1, 0, x11TopLevelIndex).isValid());
// the windowIndex has children and those are properties
for (int i = 0; i < model.rowCount(windowIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, windowIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QVERIFY(!model.hasChildren(propNameIndex));
QVERIFY(!model.index(0, 0, propNameIndex).isValid());
QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid());
QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString));
// and the value
const QModelIndex propValueIndex = model.index(i, 1, windowIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QVERIFY(!model.index(0, 0, propValueIndex).isValid());
QVERIFY(!model.hasChildren(propValueIndex));
// TODO: how to test whether the values actually work?
// and on third column we should not get an index any more
QVERIFY(!model.index(i, 2, windowIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
// creating a second model should be initialized directly with the X11 child
DebugConsoleModel model2;
QVERIFY(model2.hasChildren(model2.index(0, 0, QModelIndex())));
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
glxgears.terminate();
QVERIFY(glxgears.waitForFinished());
QVERIFY(rowsRemovedSpy.wait());
QCOMPARE(rowsRemovedSpy.count(), 1);
QCOMPARE(rowsRemovedSpy.first().first().value<QModelIndex>(), x11TopLevelIndex);
QCOMPARE(rowsRemovedSpy.first().at(1).value<int>(), 0);
QCOMPARE(rowsRemovedSpy.first().at(2).value<int>(), 0);
// the child should be gone again
QVERIFY(!model.hasChildren(x11TopLevelIndex));
QVERIFY(!model2.hasChildren(model2.index(0, 0, QModelIndex())));
}
void DebugConsoleTest::testX11Unmanaged()
{
DebugConsoleModel model;
QModelIndex unmanagedTopLevelIndex = model.index(1, 0, QModelIndex());
QVERIFY(unmanagedTopLevelIndex.isValid());
// we don't have any windows yet
QCOMPARE(model.rowCount(unmanagedTopLevelIndex), 0);
QVERIFY(!model.hasChildren(unmanagedTopLevelIndex));
// child index must be invalid
QVERIFY(!model.index(0, 0, unmanagedTopLevelIndex).isValid());
QVERIFY(!model.index(0, 1, unmanagedTopLevelIndex).isValid());
QVERIFY(!model.index(0, 2, unmanagedTopLevelIndex).isValid());
QVERIFY(!model.index(1, 0, unmanagedTopLevelIndex).isValid());
// we need to create an unmanaged window
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
// let's create an override redirect window
const uint32_t values[] = {true};
Xcb::Window window(QRect(0, 0, 10, 10), XCB_CW_OVERRIDE_REDIRECT, values);
window.map();
QVERIFY(rowsInsertedSpy.wait());
QCOMPARE(rowsInsertedSpy.count(), 1);
QVERIFY(model.hasChildren(unmanagedTopLevelIndex));
QCOMPARE(model.rowCount(unmanagedTopLevelIndex), 1);
QCOMPARE(rowsInsertedSpy.first().at(0).value<QModelIndex>(), unmanagedTopLevelIndex);
QCOMPARE(rowsInsertedSpy.first().at(1).value<int>(), 0);
QCOMPARE(rowsInsertedSpy.first().at(2).value<int>(), 0);
QModelIndex windowIndex = model.index(0, 0, unmanagedTopLevelIndex);
QVERIFY(windowIndex.isValid());
QCOMPARE(model.parent(windowIndex), unmanagedTopLevelIndex);
QVERIFY(model.hasChildren(windowIndex));
QVERIFY(model.rowCount(windowIndex) != 0);
QCOMPARE(model.columnCount(windowIndex), 2);
// other indexes are still invalid
QVERIFY(!model.index(0, 1, unmanagedTopLevelIndex).isValid());
QVERIFY(!model.index(0, 2, unmanagedTopLevelIndex).isValid());
QVERIFY(!model.index(1, 0, unmanagedTopLevelIndex).isValid());
QCOMPARE(model.data(windowIndex, Qt::DisplayRole).toString(), QStringLiteral("0x%1").arg(window, 0, 16));
// the windowIndex has children and those are properties
for (int i = 0; i < model.rowCount(windowIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, windowIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QVERIFY(!model.hasChildren(propNameIndex));
QVERIFY(!model.index(0, 0, propNameIndex).isValid());
QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid());
QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString));
// and the value
const QModelIndex propValueIndex = model.index(i, 1, windowIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QVERIFY(!model.index(0, 0, propValueIndex).isValid());
QVERIFY(!model.hasChildren(propValueIndex));
// TODO: how to test whether the values actually work?
// and on third column we should not get an index any more
QVERIFY(!model.index(i, 2, windowIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
// creating a second model should be initialized directly with the X11 child
DebugConsoleModel model2;
QVERIFY(model2.hasChildren(model2.index(1, 0, QModelIndex())));
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
window.unmap();
QVERIFY(rowsRemovedSpy.wait());
QCOMPARE(rowsRemovedSpy.count(), 1);
QCOMPARE(rowsRemovedSpy.first().first().value<QModelIndex>(), unmanagedTopLevelIndex);
QCOMPARE(rowsRemovedSpy.first().at(1).value<int>(), 0);
QCOMPARE(rowsRemovedSpy.first().at(2).value<int>(), 0);
// the child should be gone again
QVERIFY(!model.hasChildren(unmanagedTopLevelIndex));
QVERIFY(!model2.hasChildren(model2.index(1, 0, QModelIndex())));
}
void DebugConsoleTest::testWaylandClient()
{
DebugConsoleModel model;
QModelIndex waylandTopLevelIndex = model.index(2, 0, QModelIndex());
QVERIFY(waylandTopLevelIndex.isValid());
// we don't have any windows yet
QCOMPARE(model.rowCount(waylandTopLevelIndex), 0);
QVERIFY(!model.hasChildren(waylandTopLevelIndex));
// child index must be invalid
QVERIFY(!model.index(0, 0, waylandTopLevelIndex).isValid());
QVERIFY(!model.index(0, 1, waylandTopLevelIndex).isValid());
QVERIFY(!model.index(0, 2, waylandTopLevelIndex).isValid());
QVERIFY(!model.index(1, 0, waylandTopLevelIndex).isValid());
// we need to create a wayland window
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
// create our connection
QVERIFY(Test::setupWaylandConnection());
// create the Surface and ShellSurface
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface->isValid());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
Test::render(surface.get(), QSize(10, 10), Qt::red);
// now we have the window, it should be added to our model
QVERIFY(rowsInsertedSpy.wait());
QCOMPARE(rowsInsertedSpy.count(), 1);
QVERIFY(model.hasChildren(waylandTopLevelIndex));
QCOMPARE(model.rowCount(waylandTopLevelIndex), 1);
QCOMPARE(rowsInsertedSpy.first().at(0).value<QModelIndex>(), waylandTopLevelIndex);
QCOMPARE(rowsInsertedSpy.first().at(1).value<int>(), 0);
QCOMPARE(rowsInsertedSpy.first().at(2).value<int>(), 0);
QModelIndex windowIndex = model.index(0, 0, waylandTopLevelIndex);
QVERIFY(windowIndex.isValid());
QCOMPARE(model.parent(windowIndex), waylandTopLevelIndex);
QVERIFY(model.hasChildren(windowIndex));
QVERIFY(model.rowCount(windowIndex) != 0);
QCOMPARE(model.columnCount(windowIndex), 2);
// other indexes are still invalid
QVERIFY(!model.index(0, 1, waylandTopLevelIndex).isValid());
QVERIFY(!model.index(0, 2, waylandTopLevelIndex).isValid());
QVERIFY(!model.index(1, 0, waylandTopLevelIndex).isValid());
// the windowIndex has children and those are properties
for (int i = 0; i < model.rowCount(windowIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, windowIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QVERIFY(!model.hasChildren(propNameIndex));
QVERIFY(!model.index(0, 0, propNameIndex).isValid());
QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid());
QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString));
// and the value
const QModelIndex propValueIndex = model.index(i, 1, windowIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QVERIFY(!model.index(0, 0, propValueIndex).isValid());
QVERIFY(!model.hasChildren(propValueIndex));
// TODO: how to test whether the values actually work?
// and on third column we should not get an index any more
QVERIFY(!model.index(i, 2, windowIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
// creating a second model should be initialized directly with the X11 child
DebugConsoleModel model2;
QVERIFY(model2.hasChildren(model2.index(2, 0, QModelIndex())));
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
surface->attachBuffer(KWayland::Client::Buffer::Ptr());
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(rowsRemovedSpy.wait());
QCOMPARE(rowsRemovedSpy.count(), 1);
QCOMPARE(rowsRemovedSpy.first().first().value<QModelIndex>(), waylandTopLevelIndex);
QCOMPARE(rowsRemovedSpy.first().at(1).value<int>(), 0);
QCOMPARE(rowsRemovedSpy.first().at(2).value<int>(), 0);
// the child should be gone again
QVERIFY(!model.hasChildren(waylandTopLevelIndex));
QVERIFY(!model2.hasChildren(model2.index(2, 0, QModelIndex())));
}
class HelperWindow : public QRasterWindow
{
Q_OBJECT
public:
HelperWindow()
: QRasterWindow(nullptr)
{
}
~HelperWindow() override = default;
Q_SIGNALS:
void entered();
void left();
void mouseMoved(const QPoint &global);
void mousePressed();
void mouseReleased();
void wheel();
void keyPressed();
void keyReleased();
protected:
void paintEvent(QPaintEvent *event) override
{
QPainter p(this);
p.fillRect(0, 0, width(), height(), Qt::red);
}
};
void DebugConsoleTest::testInternalWindow()
{
DebugConsoleModel model;
QModelIndex internalTopLevelIndex = model.index(3, 0, QModelIndex());
QVERIFY(internalTopLevelIndex.isValid());
// there might already be some internal windows, so we cannot reliable test whether there are children
// given that we just test whether adding a window works.
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
std::unique_ptr<HelperWindow> w(new HelperWindow);
w->setGeometry(0, 0, 100, 100);
w->show();
QTRY_COMPARE(rowsInsertedSpy.count(), 1);
QCOMPARE(rowsInsertedSpy.first().first().value<QModelIndex>(), internalTopLevelIndex);
QModelIndex windowIndex = model.index(rowsInsertedSpy.first().last().toInt(), 0, internalTopLevelIndex);
QVERIFY(windowIndex.isValid());
QCOMPARE(model.parent(windowIndex), internalTopLevelIndex);
QVERIFY(model.hasChildren(windowIndex));
QVERIFY(model.rowCount(windowIndex) != 0);
QCOMPARE(model.columnCount(windowIndex), 2);
// other indexes are still invalid
QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt(), 1, internalTopLevelIndex).isValid());
QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt(), 2, internalTopLevelIndex).isValid());
QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt() + 1, 0, internalTopLevelIndex).isValid());
// the wayland shell client top level should not have gained this window
QVERIFY(!model.hasChildren(model.index(2, 0, QModelIndex())));
// the windowIndex has children and those are properties
for (int i = 0; i < model.rowCount(windowIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, windowIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QVERIFY(!model.hasChildren(propNameIndex));
QVERIFY(!model.index(0, 0, propNameIndex).isValid());
QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid());
QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString));
// and the value
const QModelIndex propValueIndex = model.index(i, 1, windowIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QVERIFY(!model.index(0, 0, propValueIndex).isValid());
QVERIFY(!model.hasChildren(propValueIndex));
// TODO: how to test whether the values actually work?
// and on third column we should not get an index any more
QVERIFY(!model.index(i, 2, windowIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
w->hide();
w.reset();
QTRY_COMPARE(rowsRemovedSpy.count(), 1);
QCOMPARE(rowsRemovedSpy.first().first().value<QModelIndex>(), internalTopLevelIndex);
}
void DebugConsoleTest::testClosingDebugConsole()
{
// this test verifies that the DebugConsole gets destroyed when closing the window
// BUG: 369858
DebugConsole *console = new DebugConsole;
QSignalSpy destroyedSpy(console, &QObject::destroyed);
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
console->show();
QCOMPARE(console->windowHandle()->isVisible(), true);
QTRY_COMPARE(windowAddedSpy.count(), 1);
InternalWindow *window = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(window->isInternal());
QCOMPARE(window->handle(), console->windowHandle());
QVERIFY(window->isDecorated());
QCOMPARE(window->isMinimizable(), false);
window->closeWindow();
QVERIFY(destroyedSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::DebugConsoleTest)
#include "debug_console_test.moc"

View File

@ -0,0 +1,787 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "internalwindow.h"
#include "pointer_input.h"
#include "touch_input.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <kwineffects.h>
#include "decorations/decoratedclient.h"
#include "decorations/decorationbridge.h"
#include "decorations/settings.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
#include <KDecoration2/Decoration>
#include <KDecoration2/DecorationSettings>
#include <linux/input.h>
Q_DECLARE_METATYPE(Qt::WindowFrameSection)
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_decoration_input-0");
class DecorationInputTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testAxis_data();
void testAxis();
void testDoubleClick_data();
void testDoubleClick();
void testDoubleTap_data();
void testDoubleTap();
void testHover();
void testPressToMove_data();
void testPressToMove();
void testTapToMove_data();
void testTapToMove();
void testResizeOutsideWindow_data();
void testResizeOutsideWindow();
void testModifierClickUnrestrictedMove_data();
void testModifierClickUnrestrictedMove();
void testModifierScrollOpacity_data();
void testModifierScrollOpacity();
void testTouchEvents();
void testTooltipDoesntEatKeyEvents();
private:
std::pair<Window *, std::unique_ptr<KWayland::Client::Surface>> showWindow();
};
#define MOTION(target) Test::pointerMotion(target, timestamp++)
#define PRESS Test::pointerButtonPressed(BTN_LEFT, timestamp++)
#define RELEASE Test::pointerButtonReleased(BTN_LEFT, timestamp++)
std::pair<Window *, std::unique_ptr<KWayland::Client::Surface>> DecorationInputTest::showWindow()
{
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \
return {nullptr, nullptr};
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \
return {nullptr, nullptr};
std::unique_ptr<KWayland::Client::Surface> surface{Test::createSurface()};
VERIFY(surface.get());
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly, surface.get());
VERIFY(shellSurface);
Test::XdgToplevelDecorationV1 *decoration = Test::createXdgToplevelDecorationV1(shellSurface, shellSurface);
VERIFY(decoration);
QSignalSpy decorationConfigureRequestedSpy(decoration, &Test::XdgToplevelDecorationV1::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
decoration->set_mode(Test::XdgToplevelDecorationV1::mode_server_side);
surface->commit(KWayland::Client::Surface::CommitFlag::None);
VERIFY(surfaceConfigureRequestedSpy.wait());
COMPARE(decorationConfigureRequestedSpy.last().at(0).value<Test::XdgToplevelDecorationV1::mode>(), Test::XdgToplevelDecorationV1::mode_server_side);
// let's render
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
auto window = Test::renderAndWaitForShown(surface.get(), QSize(500, 50), Qt::blue);
VERIFY(window);
COMPARE(workspace()->activeWindow(), window);
#undef VERIFY
#undef COMPARE
return {window, std::move(surface)};
}
void DecorationInputTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::InternalWindow *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// change some options
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group(QStringLiteral("MouseBindings")).writeEntry("CommandTitlebarWheel", QStringLiteral("above/below"));
config->group(QStringLiteral("Windows")).writeEntry("TitlebarDoubleClickCommand", QStringLiteral("OnAllDesktops"));
config->group(QStringLiteral("Desktops")).writeEntry("Number", 2);
config->sync();
kwinApp()->setConfig(config);
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
}
void DecorationInputTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1));
QVERIFY(Test::waitForWaylandPointer());
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DecorationInputTest::cleanup()
{
Test::destroyWaylandConnection();
}
void DecorationInputTest::testAxis_data()
{
QTest::addColumn<QPoint>("decoPoint");
QTest::addColumn<Qt::WindowFrameSection>("expectedSection");
QTest::newRow("topLeft") << QPoint(0, 0) << Qt::TopLeftSection;
QTest::newRow("top") << QPoint(250, 0) << Qt::TopSection;
QTest::newRow("topRight") << QPoint(499, 0) << Qt::TopRightSection;
}
void DecorationInputTest::testAxis()
{
static constexpr double oneTick = 15;
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QCOMPARE(window->titlebarPosition(), Qt::TopEdge);
QVERIFY(!window->keepAbove());
QVERIFY(!window->keepBelow());
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
QVERIFY(input()->pointer()->decoration());
QCOMPARE(input()->pointer()->decoration()->decoration()->sectionUnderMouse(), Qt::TitleBarArea);
// TODO: mouse wheel direction looks wrong to me
// simulate wheel
Test::pointerAxisVertical(oneTick, timestamp++);
QVERIFY(window->keepBelow());
QVERIFY(!window->keepAbove());
Test::pointerAxisVertical(-oneTick, timestamp++);
QVERIFY(!window->keepBelow());
QVERIFY(!window->keepAbove());
Test::pointerAxisVertical(-oneTick, timestamp++);
QVERIFY(!window->keepBelow());
QVERIFY(window->keepAbove());
// test top most deco pixel, BUG: 362860
window->move(QPoint(0, 0));
QFETCH(QPoint, decoPoint);
MOTION(decoPoint);
QVERIFY(input()->pointer()->decoration());
QCOMPARE(input()->pointer()->decoration()->window(), window);
QTEST(input()->pointer()->decoration()->decoration()->sectionUnderMouse(), "expectedSection");
Test::pointerAxisVertical(oneTick, timestamp++);
QVERIFY(!window->keepBelow());
QVERIFY(!window->keepAbove());
}
void DecorationInputTest::testDoubleClick_data()
{
QTest::addColumn<QPoint>("decoPoint");
QTest::addColumn<Qt::WindowFrameSection>("expectedSection");
QTest::newRow("topLeft") << QPoint(0, 0) << Qt::TopLeftSection;
QTest::newRow("top") << QPoint(250, 0) << Qt::TopSection;
QTest::newRow("topRight") << QPoint(499, 0) << Qt::TopRightSection;
}
void KWin::DecorationInputTest::testDoubleClick()
{
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QVERIFY(!window->isOnAllDesktops());
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
// double click
PRESS;
RELEASE;
PRESS;
RELEASE;
QVERIFY(window->isOnAllDesktops());
// double click again
PRESS;
RELEASE;
QVERIFY(window->isOnAllDesktops());
PRESS;
RELEASE;
QVERIFY(!window->isOnAllDesktops());
// test top most deco pixel, BUG: 362860
window->move(QPoint(0, 0));
QFETCH(QPoint, decoPoint);
MOTION(decoPoint);
QVERIFY(input()->pointer()->decoration());
QCOMPARE(input()->pointer()->decoration()->window(), window);
QTEST(input()->pointer()->decoration()->decoration()->sectionUnderMouse(), "expectedSection");
// double click
PRESS;
RELEASE;
QVERIFY(!window->isOnAllDesktops());
PRESS;
RELEASE;
QVERIFY(window->isOnAllDesktops());
}
void DecorationInputTest::testDoubleTap_data()
{
QTest::addColumn<QPoint>("decoPoint");
QTest::addColumn<Qt::WindowFrameSection>("expectedSection");
QTest::newRow("topLeft") << QPoint(10, 10) << Qt::TopLeftSection;
QTest::newRow("top") << QPoint(260, 10) << Qt::TopSection;
QTest::newRow("topRight") << QPoint(509, 10) << Qt::TopRightSection;
}
void KWin::DecorationInputTest::testDoubleTap()
{
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QVERIFY(!window->isOnAllDesktops());
quint32 timestamp = 1;
const QPoint tapPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0);
// double tap
Test::touchDown(0, tapPoint, timestamp++);
Test::touchUp(0, timestamp++);
Test::touchDown(0, tapPoint, timestamp++);
Test::touchUp(0, timestamp++);
QVERIFY(window->isOnAllDesktops());
// double tap again
Test::touchDown(0, tapPoint, timestamp++);
Test::touchUp(0, timestamp++);
QVERIFY(window->isOnAllDesktops());
Test::touchDown(0, tapPoint, timestamp++);
Test::touchUp(0, timestamp++);
QVERIFY(!window->isOnAllDesktops());
// test top most deco pixel, BUG: 362860
//
// Not directly at (0, 0), otherwise ScreenEdgeInputFilter catches
// event before DecorationEventFilter.
window->move(QPoint(10, 10));
QFETCH(QPoint, decoPoint);
// double click
Test::touchDown(0, decoPoint, timestamp++);
QVERIFY(input()->touch()->decoration());
QCOMPARE(input()->touch()->decoration()->window(), window);
QTEST(input()->touch()->decoration()->decoration()->sectionUnderMouse(), "expectedSection");
Test::touchUp(0, timestamp++);
QVERIFY(!window->isOnAllDesktops());
Test::touchDown(0, decoPoint, timestamp++);
Test::touchUp(0, timestamp++);
QVERIFY(window->isOnAllDesktops());
}
void DecorationInputTest::testHover()
{
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
// our left border is moved out of the visible area, so move the window to a better place
window->move(QPoint(20, 0));
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
QCOMPARE(window->cursor(), CursorShape(Qt::ArrowCursor));
// There is a mismatch of the cursor key positions between windows
// with and without borders (with borders one can move inside a bit and still
// be on an edge, without not). We should make this consistent in KWin's core.
//
// TODO: Test input position with different border sizes.
// TODO: We should test with the fake decoration to have a fixed test environment.
const bool hasBorders = Workspace::self()->decorationBridge()->settings()->borderSize() != KDecoration2::BorderSize::None;
auto deviation = [hasBorders] {
return hasBorders ? -1 : 0;
};
MOTION(QPoint(window->frameGeometry().x(), 0));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorthWest));
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() / 2, 0));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorth));
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() - 1, 0));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorthEast));
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() + deviation(), window->height() / 2));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeEast));
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() + deviation(), window->height() - 1));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouthEast));
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() / 2, window->height() + deviation()));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouth));
MOTION(QPoint(window->frameGeometry().x(), window->height() + deviation()));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouthWest));
MOTION(QPoint(window->frameGeometry().x() - 1, window->height() / 2));
QCOMPARE(window->cursor(), CursorShape(KWin::ExtendedCursor::SizeWest));
MOTION(window->frameGeometry().center());
QEXPECT_FAIL("", "Cursor not set back on leave", Continue);
QCOMPARE(window->cursor(), CursorShape(Qt::ArrowCursor));
}
void DecorationInputTest::testPressToMove_data()
{
QTest::addColumn<QPoint>("offset");
QTest::addColumn<QPoint>("offset2");
QTest::addColumn<QPoint>("offset3");
QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0);
QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0);
QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30);
QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30);
}
void DecorationInputTest::testPressToMove()
{
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
QSignalSpy startMoveResizedSpy(window, &Window::clientStartUserMovedResized);
QSignalSpy clientFinishUserMovedResizedSpy(window, &Window::clientFinishUserMovedResized);
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0));
QCOMPARE(window->cursor(), CursorShape(Qt::ArrowCursor));
PRESS;
QVERIFY(!window->isInteractiveMove());
QFETCH(QPoint, offset);
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset);
const QPointF oldPos = window->pos();
QVERIFY(window->isInteractiveMove());
QCOMPARE(startMoveResizedSpy.count(), 1);
RELEASE;
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1);
QEXPECT_FAIL("", "Just trigger move doesn't move the window", Continue);
QCOMPARE(window->pos(), oldPos + offset);
// again
PRESS;
QVERIFY(!window->isInteractiveMove());
QFETCH(QPoint, offset2);
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset2);
QVERIFY(window->isInteractiveMove());
QCOMPARE(startMoveResizedSpy.count(), 2);
QFETCH(QPoint, offset3);
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset3);
RELEASE;
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2);
// TODO: the offset should also be included
QCOMPARE(window->pos(), oldPos + offset2 + offset3);
}
void DecorationInputTest::testTapToMove_data()
{
QTest::addColumn<QPoint>("offset");
QTest::addColumn<QPoint>("offset2");
QTest::addColumn<QPoint>("offset3");
QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0);
QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0);
QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30);
QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30);
}
void DecorationInputTest::testTapToMove()
{
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
QSignalSpy startMoveResizedSpy(window, &Window::clientStartUserMovedResized);
QSignalSpy clientFinishUserMovedResizedSpy(window, &Window::clientFinishUserMovedResized);
quint32 timestamp = 1;
QPoint p = QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0);
Test::touchDown(0, p, timestamp++);
QVERIFY(!window->isInteractiveMove());
QFETCH(QPoint, offset);
QCOMPARE(input()->touch()->decorationPressId(), 0);
Test::touchMotion(0, p + offset, timestamp++);
const QPointF oldPos = window->pos();
QVERIFY(window->isInteractiveMove());
QCOMPARE(startMoveResizedSpy.count(), 1);
Test::touchUp(0, timestamp++);
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1);
QEXPECT_FAIL("", "Just trigger move doesn't move the window", Continue);
QCOMPARE(window->pos(), oldPos + offset);
// again
Test::touchDown(1, p + offset, timestamp++);
QCOMPARE(input()->touch()->decorationPressId(), 1);
QVERIFY(!window->isInteractiveMove());
QFETCH(QPoint, offset2);
Test::touchMotion(1, QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset2, timestamp++);
QVERIFY(window->isInteractiveMove());
QCOMPARE(startMoveResizedSpy.count(), 2);
QFETCH(QPoint, offset3);
Test::touchMotion(1, QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset3, timestamp++);
Test::touchUp(1, timestamp++);
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2);
// TODO: the offset should also be included
QCOMPARE(window->pos(), oldPos + offset2 + offset3);
}
void DecorationInputTest::testResizeOutsideWindow_data()
{
QTest::addColumn<Qt::Edge>("edge");
QTest::addColumn<Qt::CursorShape>("expectedCursor");
QTest::newRow("left") << Qt::LeftEdge << Qt::SizeHorCursor;
QTest::newRow("right") << Qt::RightEdge << Qt::SizeHorCursor;
QTest::newRow("bottom") << Qt::BottomEdge << Qt::SizeVerCursor;
}
void DecorationInputTest::testResizeOutsideWindow()
{
// this test verifies that one can resize the window outside the decoration with NoSideBorder
// first adjust config
kwinApp()->config()->group("org.kde.kdecoration2").writeEntry("BorderSize", QStringLiteral("None"));
kwinApp()->config()->sync();
workspace()->slotReconfigure();
// now create window
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
QVERIFY(window->frameGeometry() != window->inputGeometry());
QVERIFY(window->inputGeometry().contains(window->frameGeometry()));
QSignalSpy startMoveResizedSpy(window, &Window::clientStartUserMovedResized);
// go to border
quint32 timestamp = 1;
QFETCH(Qt::Edge, edge);
switch (edge) {
case Qt::LeftEdge:
MOTION(QPoint(window->frameGeometry().x() - 1, window->frameGeometry().center().y()));
break;
case Qt::RightEdge:
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() + 1, window->frameGeometry().center().y()));
break;
case Qt::BottomEdge:
MOTION(QPoint(window->frameGeometry().center().x(), window->frameGeometry().y() + window->frameGeometry().height() + 1));
break;
default:
break;
}
QVERIFY(!window->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos()));
// pressing should trigger resize
PRESS;
QVERIFY(!window->isInteractiveResize());
QVERIFY(startMoveResizedSpy.wait());
QVERIFY(window->isInteractiveResize());
RELEASE;
QVERIFY(!window->isInteractiveResize());
}
void DecorationInputTest::testModifierClickUnrestrictedMove_data()
{
QTest::addColumn<int>("modifierKey");
QTest::addColumn<int>("mouseButton");
QTest::addColumn<QString>("modKey");
QTest::addColumn<bool>("capsLock");
const QString alt = QStringLiteral("Alt");
const QString meta = QStringLiteral("Meta");
QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false;
QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false;
QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false;
QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false;
QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false;
QTest::newRow("Right Alt + Middle Click") << KEY_RIGHTALT << BTN_MIDDLE << alt << false;
// now everything with meta
QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false;
QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false;
QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false;
QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false;
QTest::newRow("Right Meta + Middle Click") << KEY_RIGHTMETA << BTN_MIDDLE << meta << false;
// and with capslock
QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true;
QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true;
QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true;
QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true;
QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true;
QTest::newRow("Right Alt + Middle Click/CapsLock") << KEY_RIGHTALT << BTN_MIDDLE << alt << true;
// now everything with meta
QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true;
QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true;
QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true;
QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true;
QTest::newRow("Right Meta + Middle Click/CapsLock") << KEY_RIGHTMETA << BTN_MIDDLE << meta << true;
}
void DecorationInputTest::testModifierClickUnrestrictedMove()
{
// this test ensures that Alt+mouse button press triggers unrestricted move
// first modify the config for this run
QFETCH(QString, modKey);
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", modKey);
group.writeEntry("CommandAll1", "Move");
group.writeEntry("CommandAll2", "Move");
group.writeEntry("CommandAll3", "Move");
group.sync();
workspace()->slotReconfigure();
QCOMPARE(options->commandAllModifier(), modKey == QStringLiteral("Alt") ? Qt::AltModifier : Qt::MetaModifier);
QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove);
QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove);
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
// create a window
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
// move cursor on window
Cursors::self()->mouse()->setPos(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0));
// simulate modifier+click
quint32 timestamp = 1;
QFETCH(bool, capsLock);
if (capsLock) {
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
}
QFETCH(int, modifierKey);
QFETCH(int, mouseButton);
Test::keyboardKeyPressed(modifierKey, timestamp++);
QVERIFY(!window->isInteractiveMove());
Test::pointerButtonPressed(mouseButton, timestamp++);
QVERIFY(window->isInteractiveMove());
// release modifier should not change it
Test::keyboardKeyReleased(modifierKey, timestamp++);
QVERIFY(window->isInteractiveMove());
// but releasing the key should end move/resize
Test::pointerButtonReleased(mouseButton, timestamp++);
QVERIFY(!window->isInteractiveMove());
if (capsLock) {
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
}
}
void DecorationInputTest::testModifierScrollOpacity_data()
{
QTest::addColumn<int>("modifierKey");
QTest::addColumn<QString>("modKey");
QTest::addColumn<bool>("capsLock");
const QString alt = QStringLiteral("Alt");
const QString meta = QStringLiteral("Meta");
QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false;
QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false;
QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false;
QTest::newRow("Right Meta") << KEY_RIGHTMETA << meta << false;
QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true;
QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true;
QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true;
QTest::newRow("Right Meta/CapsLock") << KEY_RIGHTMETA << meta << true;
}
void DecorationInputTest::testModifierScrollOpacity()
{
// this test verifies that mod+wheel performs a window operation
// first modify the config for this run
QFETCH(QString, modKey);
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", modKey);
group.writeEntry("CommandAllWheel", "change opacity");
group.sync();
workspace()->slotReconfigure();
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
// move cursor on window
Cursors::self()->mouse()->setPos(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0));
// set the opacity to 0.5
window->setOpacity(0.5);
QCOMPARE(window->opacity(), 0.5);
// simulate modifier+wheel
quint32 timestamp = 1;
QFETCH(bool, capsLock);
if (capsLock) {
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
}
QFETCH(int, modifierKey);
Test::keyboardKeyPressed(modifierKey, timestamp++);
Test::pointerAxisVertical(-5, timestamp++);
QCOMPARE(window->opacity(), 0.6);
Test::pointerAxisVertical(5, timestamp++);
QCOMPARE(window->opacity(), 0.5);
Test::keyboardKeyReleased(modifierKey, timestamp++);
if (capsLock) {
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
}
}
class EventHelper : public QObject
{
Q_OBJECT
public:
EventHelper()
: QObject()
{
}
~EventHelper() override = default;
bool eventFilter(QObject *watched, QEvent *event) override
{
if (event->type() == QEvent::HoverMove) {
Q_EMIT hoverMove();
} else if (event->type() == QEvent::HoverLeave) {
Q_EMIT hoverLeave();
}
return false;
}
Q_SIGNALS:
void hoverMove();
void hoverLeave();
};
void DecorationInputTest::testTouchEvents()
{
// this test verifies that the decoration gets a hover leave event on touch release
// see BUG 386231
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
EventHelper helper;
window->decoration()->installEventFilter(&helper);
QSignalSpy hoverMoveSpy(&helper, &EventHelper::hoverMove);
QSignalSpy hoverLeaveSpy(&helper, &EventHelper::hoverLeave);
quint32 timestamp = 1;
const QPoint tapPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0);
QVERIFY(!input()->touch()->decoration());
Test::touchDown(0, tapPoint, timestamp++);
QVERIFY(input()->touch()->decoration());
QCOMPARE(input()->touch()->decoration()->decoration(), window->decoration());
QCOMPARE(hoverMoveSpy.count(), 1);
QCOMPARE(hoverLeaveSpy.count(), 0);
Test::touchUp(0, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 1);
QCOMPARE(hoverLeaveSpy.count(), 1);
QCOMPARE(window->isInteractiveMove(), false);
// let's check that a hover motion is sent if the pointer is on deco, when touch release
Cursors::self()->mouse()->setPos(tapPoint);
QCOMPARE(hoverMoveSpy.count(), 2);
Test::touchDown(0, tapPoint, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 3);
QCOMPARE(hoverLeaveSpy.count(), 1);
Test::touchUp(0, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 3);
QCOMPARE(hoverLeaveSpy.count(), 2);
}
void DecorationInputTest::testTooltipDoesntEatKeyEvents()
{
// this test verifies that a tooltip on the decoration does not steal key events
// BUG: 393253
// first create a keyboard
auto keyboard = Test::waylandSeat()->createKeyboard(Test::waylandSeat());
QVERIFY(keyboard);
QSignalSpy enteredSpy(keyboard, &KWayland::Client::Keyboard::entered);
const auto [window, surface] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QVERIFY(enteredSpy.wait());
QSignalSpy keyEvent(keyboard, &KWayland::Client::Keyboard::keyChanged);
QVERIFY(keyEvent.isValid());
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
window->decoratedClient()->requestShowToolTip(QStringLiteral("test"));
// now we should get an internal window
QVERIFY(windowAddedSpy.wait());
InternalWindow *internal = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internal->isInternal());
QVERIFY(internal->handle()->flags().testFlag(Qt::ToolTip));
// now send a key
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_A, timestamp++);
QVERIFY(keyEvent.wait());
Test::keyboardKeyReleased(KEY_A, timestamp++);
QVERIFY(keyEvent.wait());
window->decoratedClient()->requestHideToolTip();
Test::waitForWindowDestroyed(internal);
}
}
WAYLANDTEST_MAIN(KWin::DecorationInputTest)
#include "decoration_input_test.moc"

View File

@ -0,0 +1,162 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "utils/xcbutils.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_x11_desktop_window-0");
class X11DesktopWindowTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testDesktopWindow();
private:
};
void X11DesktopWindowTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
}
void X11DesktopWindowTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void X11DesktopWindowTest::cleanup()
{
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void X11DesktopWindowTest::testDesktopWindow()
{
// this test creates a desktop window with an RGBA visual and verifies that it's only considered
// as an RGB (opaque) window in KWin
// create an xcb window
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
xcb_window_t windowId = xcb_generate_id(c.get());
const QRect windowGeometry(0, 0, 1280, 1024);
// helper to find the visual
auto findDepth = [&c]() -> xcb_visualid_t {
// find a visual with 32 depth
const xcb_setup_t *setup = xcb_get_setup(c.get());
for (auto screen = xcb_setup_roots_iterator(setup); screen.rem; xcb_screen_next(&screen)) {
for (auto depth = xcb_screen_allowed_depths_iterator(screen.data); depth.rem; xcb_depth_next(&depth)) {
if (depth.data->depth != 32) {
continue;
}
const int len = xcb_depth_visuals_length(depth.data);
const xcb_visualtype_t *visuals = xcb_depth_visuals(depth.data);
for (int i = 0; i < len; i++) {
return visuals[0].visual_id;
}
}
}
return 0;
};
auto visualId = findDepth();
auto colormapId = xcb_generate_id(c.get());
auto cmCookie = xcb_create_colormap_checked(c.get(), XCB_COLORMAP_ALLOC_NONE, colormapId, rootWindow(), visualId);
QVERIFY(!xcb_request_check(c.get(), cmCookie));
const uint32_t values[] = {XCB_PIXMAP_NONE, Xcb::defaultScreen()->black_pixel, colormapId};
auto cookie = xcb_create_window_checked(c.get(), 32, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualId, XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP, values);
QVERIFY(!xcb_request_check(c.get(), cookie));
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
info.setWindowType(NET::Desktop);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// verify through a geometry request that it's depth 32
Xcb::WindowGeometry geo(windowId);
QCOMPARE(geo->depth, uint8_t(32));
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(!window->isDecorated());
QCOMPARE(window->windowType(), NET::Desktop);
QCOMPARE(window->frameGeometry(), windowGeometry);
QVERIFY(window->isDesktop());
QCOMPARE(window->depth(), 24);
QVERIFY(!window->hasAlpha());
// and destroy the window again
xcb_unmap_window(c.get(), windowId);
xcb_destroy_window(c.get(), windowId);
xcb_flush(c.get());
c.reset();
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::X11DesktopWindowTest)
#include "desktop_window_x11_test.moc"

View File

@ -0,0 +1,138 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
#include <QQuickItem>
#include <linux/input.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_aurorae_destroy_deco-0");
class DontCrashAuroraeDestroyDecoTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void testBorderlessMaximizedWindows();
};
void DontCrashAuroraeDestroyDecoTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group("org.kde.kdecoration2").writeEntry("library", "org.kde.kwin.aurorae");
config->sync();
kwinApp()->setConfig(config);
// this test needs to enforce OpenGL compositing to get into the crashy condition
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void DontCrashAuroraeDestroyDecoTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows()
{
// this test verifies that Aurorae doesn't crash when clicking the maximize button
// with kwin config option BorderlessMaximizedWindows
// see BUG 362772
// first adjust the config
KConfigGroup group = kwinApp()->config()->group("Windows");
group.writeEntry("BorderlessMaximizedWindows", true);
group.sync();
workspace()->slotReconfigure();
QCOMPARE(options->borderlessMaximizedWindows(), true);
// create an xcb window
xcb_connection_t *c = xcb_connect(nullptr, nullptr);
QVERIFY(!xcb_connection_has_error(c));
xcb_window_t windowId = xcb_generate_id(c);
xcb_create_window(c, XCB_COPY_FROM_PARENT, windowId, rootWindow(), 0, 0, 100, 200, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_map_window(c, windowId);
xcb_flush(c);
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
QCOMPARE(window->maximizeMode(), MaximizeRestore);
QCOMPARE(window->noBorder(), false);
// verify that the deco is Aurorae
QCOMPARE(qstrcmp(window->decoration()->metaObject()->className(), "Aurorae::Decoration"), 0);
// find the maximize button
QQuickItem *item = window->decoration()->property("item").value<QQuickItem *>()->findChild<QQuickItem *>("maximizeButton");
QVERIFY(item);
const QPointF scenePoint = item->mapToScene(QPoint(0, 0));
// mark the window as ready for painting, otherwise it doesn't get input events
QMetaObject::invokeMethod(window, "setReadyForPainting");
QVERIFY(window->readyForPainting());
// simulate click on maximize button
QSignalSpy maximizedStateChangedSpy(window, static_cast<void (Window::*)(KWin::Window *, MaximizeMode)>(&Window::clientMaximizedStateChanged));
quint32 timestamp = 1;
Test::pointerMotion(window->frameGeometry().topLeft() + scenePoint.toPoint(), timestamp++);
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
QVERIFY(maximizedStateChangedSpy.wait());
QCOMPARE(window->maximizeMode(), MaximizeFull);
QCOMPARE(window->noBorder(), true);
// and destroy the window again
xcb_unmap_window(c, windowId);
xcb_destroy_window(c, windowId);
xcb_flush(c);
xcb_disconnect(c);
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::DontCrashAuroraeDestroyDecoTest)
#include "dont_crash_aurorae_destroy_deco.moc"

View File

@ -0,0 +1,109 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "scripting/scriptedeffect.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include <KDecoration2/Decoration>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_cancel_animation-0");
class DontCrashCancelAnimationFromAnimationEndedTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testScript();
};
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
{
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Window *>();
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(Compositor::self());
QSignalSpy compositorToggledSpy(Compositor::self(), &Compositor::compositingToggled);
QVERIFY(compositorToggledSpy.wait());
QVERIFY(effects);
}
void DontCrashCancelAnimationFromAnimationEndedTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void DontCrashCancelAnimationFromAnimationEndedTest::cleanup()
{
Test::destroyWaylandConnection();
}
void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
{
// load a scripted effect which deletes animation data
ScriptedEffect *effect = ScriptedEffect::create(QStringLiteral("crashy"), QFINDTESTDATA("data/anim-data-delete-effect/effect.js"), 10, QString());
QVERIFY(effect);
const auto children = effects->children();
for (auto it = children.begin(); it != children.end(); ++it) {
if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) {
continue;
}
QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, effect), Q_ARG(QString, QStringLiteral("crashy"))));
break;
}
QVERIFY(static_cast<EffectsHandlerImpl *>(effects)->isEffectLoaded(QStringLiteral("crashy")));
// create a window
std::unique_ptr<KWayland::Client::Surface> surface{Test::createSurface()};
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
// let's render
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
// make sure we animate
QTest::qWait(200);
// wait for the window to be passed to Deleted
QSignalSpy windowDeletedSpy(window, &Window::windowClosed);
surface.reset();
QVERIFY(windowDeletedSpy.wait());
// make sure we animate
QTest::qWait(200);
}
}
WAYLANDTEST_MAIN(KWin::DontCrashCancelAnimationFromAnimationEndedTest)
#include "dont_crash_cancel_animation.moc"

View File

@ -0,0 +1,105 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
#include <linux/input.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_empty_decoration-0");
class DontCrashEmptyDecorationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void testBug361551();
};
void DontCrashEmptyDecorationTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// this test needs to enforce OpenGL compositing to get into the crashy condition
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void DontCrashEmptyDecorationTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashEmptyDecorationTest::testBug361551()
{
// this test verifies that resizing an X11 window to an invalid size does not result in crash on unmap
// when the DecorationRenderer gets copied to the Deleted
// there a repaint is scheduled and the resulting texture is invalid if the window size is invalid
// create an xcb window
xcb_connection_t *c = xcb_connect(nullptr, nullptr);
QVERIFY(!xcb_connection_has_error(c));
xcb_window_t windowId = xcb_generate_id(c);
xcb_create_window(c, XCB_COPY_FROM_PARENT, windowId, rootWindow(), 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_map_window(c, windowId);
xcb_flush(c);
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
// let's set a stupid geometry
window->moveResize({0, 0, 0, 0});
QCOMPARE(window->frameGeometry(), QRect(0, 0, 0, 0));
// and destroy the window again
xcb_unmap_window(c, windowId);
xcb_destroy_window(c, windowId);
xcb_flush(c);
xcb_disconnect(c);
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::DontCrashEmptyDecorationTest)
#include "dont_crash_empty_deco.moc"

View File

@ -0,0 +1,92 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/outputbackend.h"
#include "deleted.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include <KDecoration2/Decoration>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_glxgears-0");
class DontCrashGlxgearsTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testGlxgears();
};
void DontCrashGlxgearsTest::initTestCase()
{
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void DontCrashGlxgearsTest::testGlxgears()
{
// closing a glxgears window through Aurorae themes used to crash KWin
// Let's make sure that doesn't happen anymore
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QProcess glxgears;
glxgears.setProgram(QStringLiteral("glxgears"));
glxgears.start();
QVERIFY(glxgears.waitForStarted());
QVERIFY(windowAddedSpy.wait());
QCOMPARE(windowAddedSpy.count(), 1);
QCOMPARE(workspace()->clientList().count(), 1);
X11Window *glxgearsWindow = workspace()->clientList().first();
QVERIFY(glxgearsWindow->isDecorated());
QSignalSpy closedSpy(glxgearsWindow, &X11Window::windowClosed);
KDecoration2::Decoration *decoration = glxgearsWindow->decoration();
QVERIFY(decoration);
// send a mouse event to the position of the close button
// TODO: position is dependent on the decoration in use. We should use a static target instead, a fake deco for autotests.
QPointF pos = decoration->rect().topRight() + QPointF(-decoration->borderTop() / 2, decoration->borderTop() / 2);
QHoverEvent event(QEvent::HoverMove, pos, pos);
QCoreApplication::instance()->sendEvent(decoration, &event);
// mouse press
QMouseEvent mousePressevent(QEvent::MouseButtonPress, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
mousePressevent.setAccepted(false);
QCoreApplication::sendEvent(decoration, &mousePressevent);
QVERIFY(mousePressevent.isAccepted());
// mouse Release
QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
mouseReleaseEvent.setAccepted(false);
QCoreApplication::sendEvent(decoration, &mouseReleaseEvent);
QVERIFY(mouseReleaseEvent.isAccepted());
QVERIFY(closedSpy.wait());
QCOMPARE(closedSpy.count(), 1);
xcb_flush(connection());
if (glxgears.state() == QProcess::Running) {
QVERIFY(glxgears.waitForFinished());
}
}
}
WAYLANDTEST_MAIN(KWin::DontCrashGlxgearsTest)
#include "dont_crash_glxgears.moc"

View File

@ -0,0 +1,107 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <KWayland/Client/surface.h>
#include <KDecoration2/Decoration>
#include <linux/input.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_no_border-0");
class DontCrashNoBorder : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testCreateWindow();
};
void DontCrashNoBorder::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group("org.kde.kdecoration2").writeEntry("NoPlugin", true);
config->sync();
kwinApp()->setConfig(config);
// this test needs to enforce OpenGL compositing to get into the crashy condition
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void DontCrashNoBorder::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::XdgDecorationV1));
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashNoBorder::cleanup()
{
Test::destroyWaylandConnection();
}
void DontCrashNoBorder::testCreateWindow()
{
// create a window and ensure that this doesn't crash
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration(Test::createXdgToplevelDecorationV1(shellSurface.get()));
QSignalSpy decorationConfigureRequestedSpy(decoration.get(), &Test::XdgToplevelDecorationV1::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
// Initialize the xdg-toplevel surface.
decoration->set_mode(Test::XdgToplevelDecorationV1::mode_server_side);
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(decorationConfigureRequestedSpy.last().at(0).value<Test::XdgToplevelDecorationV1::mode>(), Test::XdgToplevelDecorationV1::mode_client_side);
// let's render
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
auto window = Test::renderAndWaitForShown(surface.get(), QSize(500, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
QVERIFY(!window->isDecorated());
}
}
WAYLANDTEST_MAIN(KWin::DontCrashNoBorder)
#include "dont_crash_no_border.moc"

View File

@ -0,0 +1,146 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_reinitialize_compositor-0");
class DontCrashReinitializeCompositorTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testReinitializeCompositor_data();
void testReinitializeCompositor();
};
void DontCrashReinitializeCompositorTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (const QString &name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void DontCrashReinitializeCompositorTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void DontCrashReinitializeCompositorTest::cleanup()
{
// Unload all effects.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
Test::destroyWaylandConnection();
}
void DontCrashReinitializeCompositorTest::testReinitializeCompositor_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
}
void DontCrashReinitializeCompositorTest::testReinitializeCompositor()
{
// This test verifies that KWin doesn't crash when the compositor settings
// have been changed while a scripted effect animates the disappearing of
// a window.
// Make sure that we have the right effects ptr.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// Make sure that only the test effect is loaded.
QFETCH(QString, effectName);
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Close the test window.
QSignalSpy windowClosedSpy(window, &Window::windowClosed);
shellSurface.reset();
surface.reset();
QVERIFY(windowClosedSpy.wait());
// The test effect should start animating the test window. Is there a better
// way to verify that the test effect actually animates the test window?
QVERIFY(effect->isActive());
// Re-initialize the compositor, effects will be destroyed and created again.
Compositor::self()->reinitialize();
// By this time, KWin should still be alive.
}
} // namespace KWin
WAYLANDTEST_MAIN(KWin::DontCrashReinitializeCompositorTest)
#include "dont_crash_reinitialize_compositor.moc"

View File

@ -0,0 +1,102 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "keyboard_input.h"
#include "pointer_input.h"
#include "useractions.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/touch.h>
#include <linux/input.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dont_crash_useractions_menu-0");
class TestDontCrashUseractionsMenu : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testShowHideShowUseractionsMenu();
};
void TestDontCrashUseractionsMenu::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// force style to breeze as that's the one which triggered the crash
QVERIFY(kwinApp()->setStyle(QStringLiteral("breeze")));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
}
void TestDontCrashUseractionsMenu::init()
{
QVERIFY(Test::setupWaylandConnection());
workspace()->setActiveOutput(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void TestDontCrashUseractionsMenu::cleanup()
{
Test::destroyWaylandConnection();
}
void TestDontCrashUseractionsMenu::testShowHideShowUseractionsMenu()
{
// this test creates the condition of BUG 382063
std::unique_ptr<KWayland::Client::Surface> surface1(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface1(Test::createXdgToplevelSurface(surface1.get()));
auto window = Test::renderAndWaitForShown(surface1.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
workspace()->showWindowMenu(QRect(), window);
auto userActionsMenu = workspace()->userActionsMenu();
QTRY_VERIFY(userActionsMenu->isShown());
QVERIFY(userActionsMenu->hasWindow());
Test::keyboardKeyPressed(KEY_ESC, 0);
Test::keyboardKeyReleased(KEY_ESC, 1);
QTRY_VERIFY(!userActionsMenu->isShown());
QVERIFY(!userActionsMenu->hasWindow());
// and show again, this triggers BUG 382063
workspace()->showWindowMenu(QRect(), window);
QTRY_VERIFY(userActionsMenu->isShown());
QVERIFY(userActionsMenu->hasWindow());
}
WAYLANDTEST_MAIN(TestDontCrashUseractionsMenu)
#include "dont_crash_useractions_menu.moc"

View File

@ -0,0 +1,11 @@
if (XCB_ICCCM_FOUND)
integrationTest(NAME testTranslucency SRCS translucency_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testSlidingPopups SRCS slidingpopups_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testShadeWobblyWindows SRCS wobbly_shade_test.cpp LIBS XCB::ICCCM)
endif()
integrationTest(NAME testScriptedEffects SRCS scripted_effects_test.cpp)
integrationTest(WAYLAND_ONLY NAME testToplevelOpenCloseAnimation SRCS toplevel_open_close_animation_test.cpp)
integrationTest(WAYLAND_ONLY NAME testPopupOpenCloseAnimation SRCS popup_open_close_animation_test.cpp)
integrationTest(WAYLAND_ONLY NAME testDesktopSwitchingAnimation SRCS desktop_switching_animation_test.cpp)
integrationTest(WAYLAND_ONLY NAME testMinimizeAnimation SRCS minimize_animation_test.cpp)
integrationTest(WAYLAND_ONLY NAME testMaximizeAnimation SRCS maximize_animation_test.cpp)

View File

@ -0,0 +1,141 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "effectloader.h"
#include "effects.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_desktop_switching_animation-0");
class DesktopSwitchingAnimationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testSwitchDesktops_data();
void testSwitchDesktops();
};
void DesktopSwitchingAnimationTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (const QString &name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void DesktopSwitchingAnimationTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void DesktopSwitchingAnimationTest::cleanup()
{
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
VirtualDesktopManager::self()->setCount(1);
Test::destroyWaylandConnection();
}
void DesktopSwitchingAnimationTest::testSwitchDesktops_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade Desktop") << QStringLiteral("kwin4_effect_fadedesktop");
QTest::newRow("Slide") << QStringLiteral("slide");
}
void DesktopSwitchingAnimationTest::testSwitchDesktops()
{
// This test verifies that virtual desktop switching animation effects actually
// try to animate switching between desktops.
// We need at least 2 virtual desktops for the test.
VirtualDesktopManager::self()->setCount(2);
QCOMPARE(VirtualDesktopManager::self()->current(), 1u);
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
// The Fade Desktop effect will do nothing if there are no windows to fade,
// so we have to create a dummy test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(window->desktops().count(), 1);
QCOMPARE(window->desktops().first(), VirtualDesktopManager::self()->desktops().first());
// Load effect that will be tested.
QFETCH(QString, effectName);
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Switch to the second virtual desktop.
VirtualDesktopManager::self()->setCurrent(2u);
QCOMPARE(VirtualDesktopManager::self()->current(), 2u);
QVERIFY(effect->isActive());
QCOMPARE(effects->activeFullScreenEffect(), effect);
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
QTRY_COMPARE(effects->activeFullScreenEffect(), nullptr);
// Destroy the test window.
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
WAYLANDTEST_MAIN(DesktopSwitchingAnimationTest)
#include "desktop_switching_animation_test.moc"

View File

@ -0,0 +1,180 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "effectloader.h"
#include "effects.h"
#include "scene/workspacescene.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_maximize_animation-0");
class MaximizeAnimationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testMaximizeRestore();
};
void MaximizeAnimationTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (const QString &name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void MaximizeAnimationTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void MaximizeAnimationTest::cleanup()
{
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
Test::destroyWaylandConnection();
}
void MaximizeAnimationTest::testMaximizeRestore()
{
// This test verifies that the maximize effect animates a window
// when it's maximized or restored.
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
// Wait for the initial configure event.
Test::XdgToplevel::States states;
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0));
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Activated));
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
// Draw contents of the surface.
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->maximizeMode(), MaximizeMode::MaximizeRestore);
// We should receive a configure event when the window becomes active.
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
// Load effect that will be tested.
const QString effectName = QStringLiteral("kwin4_effect_maximize");
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Maximize the window.
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
QSignalSpy maximizeChangedSpy(window, qOverload<Window *, bool, bool>(&Window::clientMaximizedStateChanged));
workspace()->slotWindowMaximize();
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024));
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
QVERIFY(states.testFlag(Test::XdgToplevel::State::Maximized));
// Draw contents of the maximized window.
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 1);
QCOMPARE(maximizeChangedSpy.count(), 1);
QCOMPARE(window->maximizeMode(), MaximizeMode::MaximizeFull);
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Restore the window.
workspace()->slotWindowMaximize();
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 4);
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).value<QSize>(), QSize(100, 50));
states = toplevelConfigureRequestedSpy.last().at(1).value<Test::XdgToplevel::States>();
QVERIFY(states.testFlag(Test::XdgToplevel::State::Activated));
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
// Draw contents of the restored window.
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 2);
QCOMPARE(maximizeChangedSpy.count(), 2);
QCOMPARE(window->maximizeMode(), MaximizeMode::MaximizeRestore);
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Destroy the test window.
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
WAYLANDTEST_MAIN(MaximizeAnimationTest)
#include "maximize_animation_test.moc"

View File

@ -0,0 +1,172 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "effectloader.h"
#include "effects.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/surface.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_minimize_animation-0");
class MinimizeAnimationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testMinimizeUnminimize_data();
void testMinimizeUnminimize();
};
void MinimizeAnimationTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (const QString &name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void MinimizeAnimationTest::init()
{
QVERIFY(Test::setupWaylandConnection(
Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::WindowManagement));
}
void MinimizeAnimationTest::cleanup()
{
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
Test::destroyWaylandConnection();
}
void MinimizeAnimationTest::testMinimizeUnminimize_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Magic Lamp") << QStringLiteral("magiclamp");
QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash");
}
void MinimizeAnimationTest::testMinimizeUnminimize()
{
// This test verifies that a minimize effect tries to animate a window
// when it's minimized or unminimized.
QSignalSpy plasmaWindowCreatedSpy(Test::waylandWindowManagement(), &KWayland::Client::PlasmaWindowManagement::windowCreated);
// Create a panel at the top of the screen.
const QRect panelRect = QRect(0, 0, 1280, 36);
std::unique_ptr<KWayland::Client::Surface> panelSurface(Test::createSurface());
QVERIFY(panelSurface != nullptr);
std::unique_ptr<Test::XdgToplevel> panelShellSurface(Test::createXdgToplevelSurface(panelSurface.get()));
QVERIFY(panelShellSurface != nullptr);
std::unique_ptr<KWayland::Client::PlasmaShellSurface> plasmaPanelShellSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.get()));
QVERIFY(plasmaPanelShellSurface != nullptr);
plasmaPanelShellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel);
plasmaPanelShellSurface->setPosition(panelRect.topLeft());
plasmaPanelShellSurface->setPanelBehavior(KWayland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible);
Window *panel = Test::renderAndWaitForShown(panelSurface.get(), panelRect.size(), Qt::blue);
QVERIFY(panel);
QVERIFY(panel->isDock());
QCOMPARE(panel->frameGeometry(), panelRect);
QVERIFY(plasmaWindowCreatedSpy.wait());
QCOMPARE(plasmaWindowCreatedSpy.count(), 1);
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::red);
QVERIFY(window);
QVERIFY(plasmaWindowCreatedSpy.wait());
QCOMPARE(plasmaWindowCreatedSpy.count(), 2);
// We have to set the minimized geometry because the squash effect needs it,
// otherwise it won't start animation.
auto plasmaWindow = plasmaWindowCreatedSpy.last().first().value<KWayland::Client::PlasmaWindow *>();
QVERIFY(plasmaWindow);
const QRect iconRect = QRect(0, 0, 42, 36);
plasmaWindow->setMinimizedGeometry(panelSurface.get(), iconRect);
Test::flushWaylandConnection();
QTRY_COMPARE(window->iconGeometry(), iconRect.translated(panel->frameGeometry().topLeft().toPoint()));
// Load effect that will be tested.
QFETCH(QString, effectName);
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Start the minimize animation.
window->minimize();
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Start the unminimize animation.
window->unminimize();
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Destroy the panel.
panelSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(panel));
// Destroy the test window.
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
WAYLANDTEST_MAIN(MinimizeAnimationTest)
#include "minimize_animation_test.moc"

View File

@ -0,0 +1,262 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/outputbackend.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "internalwindow.h"
#include "useractions.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "decorations/decoratedclient.h"
#include <KWayland/Client/surface.h>
#include <linux/input.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_popup_open_close_animation-0");
class PopupOpenCloseAnimationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testAnimatePopups();
void testAnimateUserActionsPopup();
void testAnimateDecorationTooltips();
};
void PopupOpenCloseAnimationTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::InternalWindow *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (const QString &name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void PopupOpenCloseAnimationTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::XdgDecorationV1));
}
void PopupOpenCloseAnimationTest::cleanup()
{
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
Test::destroyWaylandConnection();
}
void PopupOpenCloseAnimationTest::testAnimatePopups()
{
// This test verifies that popup open/close animation effects try
// to animate popups(e.g. popup menus, tooltips, etc).
// Make sure that we have the right effects ptr.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
// Create the main window.
std::unique_ptr<KWayland::Client::Surface> mainWindowSurface(Test::createSurface());
QVERIFY(mainWindowSurface != nullptr);
std::unique_ptr<Test::XdgToplevel> mainWindowShellSurface(Test::createXdgToplevelSurface(mainWindowSurface.get()));
QVERIFY(mainWindowShellSurface != nullptr);
Window *mainWindow = Test::renderAndWaitForShown(mainWindowSurface.get(), QSize(100, 50), Qt::blue);
QVERIFY(mainWindow);
// Load effect that will be tested.
const QString effectName = QStringLiteral("kwin4_effect_fadingpopups");
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Create a popup, it should be animated.
std::unique_ptr<KWayland::Client::Surface> popupSurface(Test::createSurface());
QVERIFY(popupSurface != nullptr);
std::unique_ptr<Test::XdgPositioner> positioner(Test::createXdgPositioner());
positioner->set_size(20, 20);
positioner->set_anchor_rect(0, 0, 10, 10);
positioner->set_gravity(Test::XdgPositioner::gravity_bottom_right);
positioner->set_anchor(Test::XdgPositioner::anchor_bottom_left);
std::unique_ptr<Test::XdgPopup> popupShellSurface(Test::createXdgPopupSurface(popupSurface.get(), mainWindowShellSurface->xdgSurface(), positioner.get()));
QVERIFY(popupShellSurface != nullptr);
Window *popup = Test::renderAndWaitForShown(popupSurface.get(), QSize(20, 20), Qt::red);
QVERIFY(popup);
QVERIFY(popup->isPopupWindow());
QCOMPARE(popup->transientFor(), mainWindow);
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Destroy the popup, it should not be animated.
QSignalSpy popupClosedSpy(popup, &Window::windowClosed);
popupShellSurface.reset();
popupSurface.reset();
QVERIFY(popupClosedSpy.wait());
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Destroy the main window.
mainWindowSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(mainWindow));
}
void PopupOpenCloseAnimationTest::testAnimateUserActionsPopup()
{
// This test verifies that popup open/close animation effects try
// to animate the user actions popup.
// Make sure that we have the right effects ptr.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// Load effect that will be tested.
const QString effectName = QStringLiteral("kwin4_effect_fadingpopups");
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Show the user actions popup.
workspace()->showWindowMenu(QRect(), window);
auto userActionsMenu = workspace()->userActionsMenu();
QTRY_VERIFY(userActionsMenu->isShown());
QVERIFY(userActionsMenu->hasWindow());
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Close the user actions popup.
Test::keyboardKeyPressed(KEY_ESC, 0);
Test::keyboardKeyReleased(KEY_ESC, 1);
QTRY_VERIFY(!userActionsMenu->isShown());
QVERIFY(!userActionsMenu->hasWindow());
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Destroy the test window.
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
void PopupOpenCloseAnimationTest::testAnimateDecorationTooltips()
{
// This test verifies that popup open/close animation effects try
// to animate decoration tooltips.
// Make sure that we have the right effects ptr.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly));
QVERIFY(shellSurface != nullptr);
std::unique_ptr<Test::XdgToplevelDecorationV1> deco(Test::createXdgToplevelDecorationV1(shellSurface.get()));
QVERIFY(deco != nullptr);
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
deco->set_mode(Test::XdgToplevelDecorationV1::mode_server_side);
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(surfaceConfigureRequestedSpy.wait());
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QVERIFY(window->isDecorated());
// Load effect that will be tested.
const QString effectName = QStringLiteral("kwin4_effect_fadingpopups");
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Show a decoration tooltip.
QSignalSpy tooltipAddedSpy(workspace(), &Workspace::internalWindowAdded);
window->decoratedClient()->requestShowToolTip(QStringLiteral("KWin rocks!"));
QVERIFY(tooltipAddedSpy.wait());
InternalWindow *tooltip = tooltipAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(tooltip->isInternal());
QVERIFY(tooltip->isPopupWindow());
QVERIFY(tooltip->handle()->flags().testFlag(Qt::ToolTip));
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Hide the decoration tooltip.
QSignalSpy tooltipClosedSpy(tooltip, &InternalWindow::windowClosed);
window->decoratedClient()->requestHideToolTip();
QVERIFY(tooltipClosedSpy.wait());
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Destroy the test window.
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
WAYLANDTEST_MAIN(PopupOpenCloseAnimationTest)
#include "popup_open_close_animation_test.moc"

View File

@ -0,0 +1,748 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "libkwineffects/anidata_p.h"
#include "scripting/scriptedeffect.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KConfigGroup>
#include <KGlobalAccel>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/slide.h>
#include <KWayland/Client/surface.h>
#include <QJSValue>
#include <QQmlEngine>
using namespace KWin;
using namespace std::chrono_literals;
static const QString s_socketName = QStringLiteral("wayland_test_effects_scripts-0");
class ScriptedEffectsTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testEffectsHandler();
void testEffectsContext();
void testShortcuts();
void testAnimations_data();
void testAnimations();
void testScreenEdge();
void testScreenEdgeTouch();
void testFullScreenEffect_data();
void testFullScreenEffect();
void testKeepAlive_data();
void testKeepAlive();
void testGrab();
void testGrabAlreadyGrabbedWindow();
void testGrabAlreadyGrabbedWindowForced();
void testUngrab();
void testRedirect_data();
void testRedirect();
void testComplete();
private:
ScriptedEffect *loadEffect(const QString &name);
};
class ScriptedEffectWithDebugSpy : public KWin::ScriptedEffect
{
Q_OBJECT
public:
ScriptedEffectWithDebugSpy();
bool load(const QString &name);
using AnimationEffect::AniMap;
using AnimationEffect::state;
Q_INVOKABLE void sendTestResponse(const QString &out); // proxies triggers out from the tests
QList<QAction *> actions(); // returns any QActions owned by the ScriptEngine
Q_SIGNALS:
void testOutput(const QString &data);
};
void ScriptedEffectWithDebugSpy::sendTestResponse(const QString &out)
{
Q_EMIT testOutput(out);
}
QList<QAction *> ScriptedEffectWithDebugSpy::actions()
{
return findChildren<QAction *>(QString(), Qt::FindDirectChildrenOnly);
}
ScriptedEffectWithDebugSpy::ScriptedEffectWithDebugSpy()
: ScriptedEffect()
{
}
bool ScriptedEffectWithDebugSpy::load(const QString &name)
{
auto selfContext = engine()->newQObject(this);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
const QString path = QFINDTESTDATA("./scripts/" + name + ".js");
engine()->globalObject().setProperty("sendTestResponse", selfContext.property("sendTestResponse"));
if (!init(name, path)) {
return false;
}
// inject our newly created effect to be registered with the EffectsHandlerImpl::loaded_effects
// this is private API so some horrible code is used to find the internal effectloader
// and register ourselves
auto children = effects->children();
for (auto it = children.begin(); it != children.end(); ++it) {
if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) {
continue;
}
QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, this), Q_ARG(QString, name));
break;
}
return (static_cast<EffectsHandlerImpl *>(effects)->isEffectLoaded(name));
}
void ScriptedEffectsTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024)));
// disable all effects - we don't want to have it interact with the rendering
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (QString name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QVERIFY(Compositor::self());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
KWin::VirtualDesktopManager::self()->setCount(2);
}
void ScriptedEffectsTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void ScriptedEffectsTest::cleanup()
{
Test::destroyWaylandConnection();
auto effectsImpl = static_cast<EffectsHandlerImpl *>(effects);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
KWin::VirtualDesktopManager::self()->setCurrent(1);
}
void ScriptedEffectsTest::testEffectsHandler()
{
// this triggers and tests some of the signals in EffectHandler, which is exposed to JS as context property "effects"
auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
auto waitFor = [&effectOutputSpy](const QString &expected) {
QVERIFY(effectOutputSpy.count() > 0 || effectOutputSpy.wait());
QCOMPARE(effectOutputSpy.first().first(), expected);
effectOutputSpy.removeFirst();
};
QVERIFY(effect->load("effectsHandler"));
// trigger windowAdded signal
// create a window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
auto *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
shellSurface->set_title("WindowA");
auto *c = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QCOMPARE(workspace()->activeWindow(), c);
waitFor("windowAdded - WindowA");
waitFor("stackingOrder - 1 WindowA");
// windowMinimsed
c->minimize();
waitFor("windowMinimized - WindowA");
c->unminimize();
waitFor("windowUnminimized - WindowA");
surface.reset();
waitFor("windowClosed - WindowA");
// desktop management
KWin::VirtualDesktopManager::self()->setCurrent(2);
waitFor("desktopChanged - 1 2");
}
void ScriptedEffectsTest::testEffectsContext()
{
// this tests misc non-objects exposed to the script engine: animationTime, displaySize, use of external enums
auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load("effectContext"));
QCOMPARE(effectOutputSpy[0].first(), "1280x1024");
QCOMPARE(effectOutputSpy[1].first(), "100");
QCOMPARE(effectOutputSpy[2].first(), "2");
QCOMPARE(effectOutputSpy[3].first(), "0");
}
void ScriptedEffectsTest::testShortcuts()
{
// this tests method registerShortcut
auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load("shortcutsTest"));
QCOMPARE(effect->actions().count(), 1);
auto action = effect->actions()[0];
QCOMPARE(action->objectName(), "testShortcut");
QCOMPARE(action->text(), "Test Shortcut");
QCOMPARE(KGlobalAccel::self()->shortcut(action).first(), QKeySequence("Meta+Shift+Y"));
action->trigger();
QCOMPARE(effectOutputSpy[0].first(), "shortcutTriggered");
}
void ScriptedEffectsTest::testAnimations_data()
{
QTest::addColumn<QString>("file");
QTest::addColumn<int>("animationCount");
QTest::newRow("single") << "animationTest" << 1;
QTest::newRow("multi") << "animationTestMulti" << 2;
}
void ScriptedEffectsTest::testAnimations()
{
// this tests animate/set/cancel
// methods take either an int or an array, as forced in the data above
// also splits animate vs effects.animate(..)
QFETCH(QString, file);
QFETCH(int, animationCount);
auto *effect = new ScriptedEffectWithDebugSpy;
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load(file));
// animated after window added connect
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
auto *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
shellSurface->set_title("Window 1");
auto *c = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QCOMPARE(workspace()->activeWindow(), c);
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), c->effectWindow());
const auto &animationsForWindow = state.first().first;
QCOMPARE(animationsForWindow.count(), animationCount);
QCOMPARE(animationsForWindow[0].timeLine.duration(), 100ms);
QCOMPARE(animationsForWindow[0].to, FPx2(1.4));
QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale);
QCOMPARE(animationsForWindow[0].timeLine.easingCurve().type(), QEasingCurve::OutCubic);
QCOMPARE(animationsForWindow[0].terminationFlags,
AnimationEffect::TerminateAtSource | AnimationEffect::TerminateAtTarget);
if (animationCount == 2) {
QCOMPARE(animationsForWindow[1].timeLine.duration(), 100ms);
QCOMPARE(animationsForWindow[1].to, FPx2(0.0));
QCOMPARE(animationsForWindow[1].attribute, AnimationEffect::Opacity);
QCOMPARE(animationsForWindow[1].terminationFlags,
AnimationEffect::TerminateAtSource | AnimationEffect::TerminateAtTarget);
}
}
QCOMPARE(effectOutputSpy[0].first(), "true");
// window state changes, scale should be retargetted
c->setMinimized(true);
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
const auto &animationsForWindow = state.first().first;
QCOMPARE(animationsForWindow.count(), animationCount);
QCOMPARE(animationsForWindow[0].timeLine.duration(), 200ms);
QCOMPARE(animationsForWindow[0].to, FPx2(1.5));
QCOMPARE(animationsForWindow[0].attribute, AnimationEffect::Scale);
QCOMPARE(animationsForWindow[0].terminationFlags,
AnimationEffect::TerminateAtSource | AnimationEffect::TerminateAtTarget);
if (animationCount == 2) {
QCOMPARE(animationsForWindow[1].timeLine.duration(), 200ms);
QCOMPARE(animationsForWindow[1].to, FPx2(1.5));
QCOMPARE(animationsForWindow[1].attribute, AnimationEffect::Opacity);
QCOMPARE(animationsForWindow[1].terminationFlags,
AnimationEffect::TerminateAtSource | AnimationEffect::TerminateAtTarget);
}
}
c->setMinimized(false);
{
const auto state = effect->state();
QCOMPARE(state.count(), 0);
}
}
void ScriptedEffectsTest::testScreenEdge()
{
// this test checks registerScreenEdge functions
auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load("screenEdgeTest"));
effect->borderActivated(KWin::ElectricTopRight);
QCOMPARE(effectOutputSpy.count(), 1);
}
void ScriptedEffectsTest::testScreenEdgeTouch()
{
// this test checks registerTouchScreenEdge functions
auto *effect = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load("screenEdgeTouchTest"));
effect->actions()[0]->trigger();
QCOMPARE(effectOutputSpy.count(), 1);
}
void ScriptedEffectsTest::testFullScreenEffect_data()
{
QTest::addColumn<QString>("file");
QTest::newRow("single") << "fullScreenEffectTest";
QTest::newRow("multi") << "fullScreenEffectTestMulti";
QTest::newRow("global") << "fullScreenEffectTestGlobal";
}
void ScriptedEffectsTest::testFullScreenEffect()
{
QFETCH(QString, file);
auto *effectMain = new ScriptedEffectWithDebugSpy; // cleaned up in ::clean
QSignalSpy effectOutputSpy(effectMain, &ScriptedEffectWithDebugSpy::testOutput);
QSignalSpy fullScreenEffectActiveSpy(effects, &EffectsHandler::hasActiveFullScreenEffectChanged);
QSignalSpy isActiveFullScreenEffectSpy(effectMain, &ScriptedEffect::isActiveFullScreenEffectChanged);
QVERIFY(effectMain->load(file));
// load any random effect from another test to confirm fullscreen effect state is correctly
// shown as being someone else
auto effectOther = new ScriptedEffectWithDebugSpy();
QVERIFY(effectOther->load("screenEdgeTouchTest"));
QSignalSpy isActiveFullScreenEffectSpyOther(effectOther, &ScriptedEffect::isActiveFullScreenEffectChanged);
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
auto *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
shellSurface->set_title("Window 1");
auto *c = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QCOMPARE(workspace()->activeWindow(), c);
QCOMPARE(effects->hasActiveFullScreenEffect(), false);
QCOMPARE(effectMain->isActiveFullScreenEffect(), false);
// trigger animation
KWin::VirtualDesktopManager::self()->setCurrent(2);
QCOMPARE(effects->activeFullScreenEffect(), effectMain);
QCOMPARE(effects->hasActiveFullScreenEffect(), true);
QCOMPARE(fullScreenEffectActiveSpy.count(), 1);
QCOMPARE(effectMain->isActiveFullScreenEffect(), true);
QCOMPARE(isActiveFullScreenEffectSpy.count(), 1);
QCOMPARE(effectOther->isActiveFullScreenEffect(), false);
QCOMPARE(isActiveFullScreenEffectSpyOther.count(), 0);
// after 500ms trigger another full screen animation
QTest::qWait(500);
KWin::VirtualDesktopManager::self()->setCurrent(1);
QCOMPARE(effects->activeFullScreenEffect(), effectMain);
// after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect
// despite first animation expiring
QTest::qWait(500 + 100);
QCOMPARE(effects->activeFullScreenEffect(), effectMain);
// after 1500ms (+a safetey margin) we should have no full screen effect
QTest::qWait(500 + 100);
QCOMPARE(effects->activeFullScreenEffect(), nullptr);
}
void ScriptedEffectsTest::testKeepAlive_data()
{
QTest::addColumn<QString>("file");
QTest::addColumn<bool>("keepAlive");
QTest::newRow("keep") << "keepAliveTest" << true;
QTest::newRow("don't keep") << "keepAliveTestDontKeep" << false;
}
void ScriptedEffectsTest::testKeepAlive()
{
// this test checks whether closed windows are kept alive
// when keepAlive property is set to true(false)
QFETCH(QString, file);
QFETCH(bool, keepAlive);
auto *effect = new ScriptedEffectWithDebugSpy;
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load(file));
// create a window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
auto *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
auto *c = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QCOMPARE(workspace()->activeWindow(), c);
// no active animations at the beginning
QCOMPARE(effect->state().count(), 0);
// trigger windowClosed signal
surface.reset();
QVERIFY(effectOutputSpy.count() == 1 || effectOutputSpy.wait());
if (keepAlive) {
QCOMPARE(effect->state().count(), 1);
QTest::qWait(500);
QCOMPARE(effect->state().count(), 1);
QTest::qWait(500 + 100); // 100ms is extra safety margin
QCOMPARE(effect->state().count(), 0);
} else {
// the test effect doesn't keep the window alive, so it should be
// removed immediately
QSignalSpy deletedRemovedSpy(workspace(), &Workspace::deletedRemoved);
QVERIFY(deletedRemovedSpy.count() == 1 || deletedRemovedSpy.wait(100)); // 100ms is less than duration of the animation
QCOMPARE(effect->state().count(), 0);
}
}
void ScriptedEffectsTest::testGrab()
{
// this test verifies that scripted effects can grab windows that are
// not already grabbed
// load the test effect
auto effect = new ScriptedEffectWithDebugSpy;
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load(QStringLiteral("grabTest")));
// create test window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
// the test effect should grab the test window successfully
QCOMPARE(effectOutputSpy.count(), 1);
QCOMPARE(effectOutputSpy.first().first(), QStringLiteral("ok"));
QCOMPARE(window->effectWindow()->data(WindowAddedGrabRole).value<void *>(), effect);
}
void ScriptedEffectsTest::testGrabAlreadyGrabbedWindow()
{
// this test verifies that scripted effects cannot grab already grabbed
// windows (unless force is set to true of course)
// load effect that will hold the window grab
auto owner = new ScriptedEffectWithDebugSpy;
QSignalSpy ownerOutputSpy(owner, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(owner->load(QStringLiteral("grabAlreadyGrabbedWindowTest_owner")));
// load effect that will try to grab already grabbed window
auto grabber = new ScriptedEffectWithDebugSpy;
QSignalSpy grabberOutputSpy(grabber, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(grabber->load(QStringLiteral("grabAlreadyGrabbedWindowTest_grabber")));
// create test window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
// effect that initially held the grab should still hold the grab
QCOMPARE(ownerOutputSpy.count(), 1);
QCOMPARE(ownerOutputSpy.first().first(), QStringLiteral("ok"));
QCOMPARE(window->effectWindow()->data(WindowAddedGrabRole).value<void *>(), owner);
// effect that tried to grab already grabbed window should fail miserably
QCOMPARE(grabberOutputSpy.count(), 1);
QCOMPARE(grabberOutputSpy.first().first(), QStringLiteral("fail"));
}
void ScriptedEffectsTest::testGrabAlreadyGrabbedWindowForced()
{
// this test verifies that scripted effects can steal window grabs when
// they forcefully try to grab windows
// load effect that initially will be holding the window grab
auto owner = new ScriptedEffectWithDebugSpy;
QSignalSpy ownerOutputSpy(owner, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(owner->load(QStringLiteral("grabAlreadyGrabbedWindowForcedTest_owner")));
// load effect that will try to steal the window grab
auto thief = new ScriptedEffectWithDebugSpy;
QSignalSpy thiefOutputSpy(thief, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(thief->load(QStringLiteral("grabAlreadyGrabbedWindowForcedTest_thief")));
// create test window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
// verify that the owner in fact held the grab
QCOMPARE(ownerOutputSpy.count(), 1);
QCOMPARE(ownerOutputSpy.first().first(), QStringLiteral("ok"));
// effect that grabbed the test window forcefully should now hold the grab
QCOMPARE(thiefOutputSpy.count(), 1);
QCOMPARE(thiefOutputSpy.first().first(), QStringLiteral("ok"));
QCOMPARE(window->effectWindow()->data(WindowAddedGrabRole).value<void *>(), thief);
}
void ScriptedEffectsTest::testUngrab()
{
// this test verifies that scripted effects can ungrab windows that they
// are previously grabbed
// load the test effect
auto effect = new ScriptedEffectWithDebugSpy;
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
QVERIFY(effect->load(QStringLiteral("ungrabTest")));
// create test window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
// the test effect should grab the test window successfully
QCOMPARE(effectOutputSpy.count(), 1);
QCOMPARE(effectOutputSpy.first().first(), QStringLiteral("ok"));
QCOMPARE(window->effectWindow()->data(WindowAddedGrabRole).value<void *>(), effect);
// when the test effect sees that a window was minimized, it will try to ungrab it
effectOutputSpy.clear();
window->setMinimized(true);
QCOMPARE(effectOutputSpy.count(), 1);
QCOMPARE(effectOutputSpy.first().first(), QStringLiteral("ok"));
QCOMPARE(window->effectWindow()->data(WindowAddedGrabRole).value<void *>(), nullptr);
}
void ScriptedEffectsTest::testRedirect_data()
{
QTest::addColumn<QString>("file");
QTest::addColumn<bool>("shouldTerminate");
QTest::newRow("animate/DontTerminateAtSource") << "redirectAnimateDontTerminateTest" << false;
QTest::newRow("animate/TerminateAtSource") << "redirectAnimateTerminateTest" << true;
QTest::newRow("set/DontTerminate") << "redirectSetDontTerminateTest" << false;
QTest::newRow("set/Terminate") << "redirectSetTerminateTest" << true;
}
void ScriptedEffectsTest::testRedirect()
{
// this test verifies that redirect() works
// load the test effect
auto effect = new ScriptedEffectWithDebugSpy;
QFETCH(QString, file);
QVERIFY(effect->load(file));
// create test window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
auto around = [](std::chrono::milliseconds elapsed,
std::chrono::milliseconds pivot,
std::chrono::milliseconds margin) {
return std::abs(elapsed.count() - pivot.count()) < margin.count();
};
// initially, the test animation is at the source position
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), window->effectWindow());
const QList<AniData> animations = state.first().first;
QCOMPARE(animations.count(), 1);
QCOMPARE(animations[0].timeLine.direction(), TimeLine::Forward);
QVERIFY(around(animations[0].timeLine.elapsed(), 0ms, 50ms));
}
// minimize the test window after 250ms, when the test effect sees that
// a window was minimized, it will try to reverse animation for it
QTest::qWait(250);
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
window->setMinimized(true);
QCOMPARE(effectOutputSpy.count(), 1);
QCOMPARE(effectOutputSpy.first().first(), QStringLiteral("ok"));
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), window->effectWindow());
const QList<AniData> animations = state.first().first;
QCOMPARE(animations.count(), 1);
QCOMPARE(animations[0].timeLine.direction(), TimeLine::Backward);
QVERIFY(around(animations[0].timeLine.elapsed(), 1000ms - 250ms, 50ms));
}
// wait for the animation to reach the start position, 100ms is an extra
// safety margin
QTest::qWait(250 + 100);
QFETCH(bool, shouldTerminate);
if (shouldTerminate) {
const auto state = effect->state();
QCOMPARE(state.count(), 0);
} else {
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), window->effectWindow());
const QList<AniData> animations = state.first().first;
QCOMPARE(animations.count(), 1);
QCOMPARE(animations[0].timeLine.direction(), TimeLine::Backward);
QCOMPARE(animations[0].timeLine.elapsed(), 1000ms);
QCOMPARE(animations[0].timeLine.value(), 0.0);
}
}
void ScriptedEffectsTest::testComplete()
{
// this test verifies that complete works
// load the test effect
auto effect = new ScriptedEffectWithDebugSpy;
QVERIFY(effect->load(QStringLiteral("completeTest")));
// create test window
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
QVERIFY(surface);
Test::XdgToplevel *shellSurface = Test::createXdgToplevelSurface(surface.get(), surface.get());
QVERIFY(shellSurface);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
auto around = [](std::chrono::milliseconds elapsed,
std::chrono::milliseconds pivot,
std::chrono::milliseconds margin) {
return std::abs(elapsed.count() - pivot.count()) < margin.count();
};
// initially, the test animation should be at the start position
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), window->effectWindow());
const QList<AniData> animations = state.first().first;
QCOMPARE(animations.count(), 1);
QVERIFY(around(animations[0].timeLine.elapsed(), 0ms, 50ms));
QVERIFY(!animations[0].timeLine.done());
}
// wait for 250ms
QTest::qWait(250);
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), window->effectWindow());
const QList<AniData> animations = state.first().first;
QCOMPARE(animations.count(), 1);
QVERIFY(around(animations[0].timeLine.elapsed(), 250ms, 50ms));
QVERIFY(!animations[0].timeLine.done());
}
// minimize the test window, when the test effect sees that a window was
// minimized, it will try to complete animation for it
QSignalSpy effectOutputSpy(effect, &ScriptedEffectWithDebugSpy::testOutput);
window->setMinimized(true);
QCOMPARE(effectOutputSpy.count(), 1);
QCOMPARE(effectOutputSpy.first().first(), QStringLiteral("ok"));
{
const auto state = effect->state();
QCOMPARE(state.count(), 1);
QCOMPARE(state.firstKey(), window->effectWindow());
const QList<AniData> animations = state.first().first;
QCOMPARE(animations.count(), 1);
QCOMPARE(animations[0].timeLine.elapsed(), 1000ms);
QVERIFY(animations[0].timeLine.done());
}
}
WAYLANDTEST_MAIN(ScriptedEffectsTest)
#include "scripted_effects_test.moc"

View File

@ -0,0 +1,12 @@
effects.windowAdded.connect(function(w) {
w.anim1 = effect.animate(w, Effect.Scale, 100, 1.4, 0.2, 0, QEasingCurve.OutCubic);
sendTestResponse(typeof(w.anim1) == "number");
});
effects.windowUnminimized.connect(function(w) {
cancel(w.anim1);
});
effects.windowMinimized.connect(function(w) {
retarget(w.anim1, 1.5, 200);
});

View File

@ -0,0 +1,24 @@
effects.windowAdded.connect(function(w) {
w.anim1 = animate({
window: w,
duration: 100,
animations: [{
type: Effect.Scale,
to: 1.4,
curve: QEasingCurve.OutCubic
}, {
type: Effect.Opacity,
curve: QEasingCurve.OutCubic,
to: 0.0
}]
});
sendTestResponse(typeof(w.anim1) == "object" && Array.isArray(w.anim1));
});
effects.windowUnminimized.connect(function(w) {
cancel(w.anim1);
});
effects.windowMinimized.connect(function(w) {
retarget(w.anim1, 1.5, 200);
});

View File

@ -0,0 +1,19 @@
effects.windowAdded.connect(function (window) {
window.animation = set({
window: window,
curve: QEasingCurve.Linear,
duration: animationTime(1000),
type: Effect.Opacity,
from: 0,
to: 1,
keepAlive: false
});
});
effects.windowMinimized.connect(function (window) {
if (complete(window.animation)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,6 @@
sendTestResponse(displayWidth() + "x" + displayHeight());
sendTestResponse(animationTime(100));
//test enums for Effect / QEasingCurve
sendTestResponse(Effect.Saturation)
sendTestResponse(QEasingCurve.Linear)

View File

@ -0,0 +1,16 @@
effects.windowAdded.connect(function(window) {
sendTestResponse("windowAdded - " + window.caption);
sendTestResponse("stackingOrder - " + effects.stackingOrder.length + " " + effects.stackingOrder[0].caption);
});
effects.windowClosed.connect(function(window) {
sendTestResponse("windowClosed - " + window.caption);
});
effects.windowMinimized.connect(function(window) {
sendTestResponse("windowMinimized - " + window.caption);
});
effects.windowUnminimized.connect(function(window) {
sendTestResponse("windowUnminimized - " + window.caption);
});
effects['desktopChanged(int,int)'].connect(function(old, current) {
sendTestResponse("desktopChanged - " + old + " " + current);
});

View File

@ -0,0 +1,8 @@
effects['desktopChanged(int,int)'].connect(function(old, current) {
var stackingOrder = effects.stackingOrder;
for (var i=0; i<stackingOrder.length; i++) {
var w = stackingOrder[i];
//1 second long random animation. Final param indicates fullscreen
w.anim1 = effect.animate(w, Effect.Scale, 1000, 1.4, 0.2, 0, QEasingCurve.Linear, 0, true);
}
});

View File

@ -0,0 +1,21 @@
effects['desktopChanged(int,int)'].connect(function(old, current) {
var stackingOrder = effects.stackingOrder;
for (var i=0; i<stackingOrder.length; i++) {
var w = stackingOrder[i];
//1 second long random animation, marked as fullscreen
w.anim1 = animate({
window: w,
duration: 1000,
fullScreen: true,
animations: [{
type: Effect.Scale,
curve: Effect.GaussianCurve,
to: 1.4
}, {
type: Effect.Opacity,
curve: Effect.GaussianCurve,
to: 0.0
}]
});
}
});

View File

@ -0,0 +1,22 @@
effects['desktopChanged(int,int)'].connect(function(old, current) {
var stackingOrder = effects.stackingOrder;
for (var i=0; i<stackingOrder.length; i++) {
var w = stackingOrder[i];
//1 second long random animation, marked as fullscreen
w.anim1 = animate({
window: w,
duration: 1000,
animations: [{
type: Effect.Scale,
curve: Effect.GaussianCurve,
to: 1.4,
fullScreen: true
}, {
type: Effect.Opacity,
curve: Effect.GaussianCurve,
to: 0.0,
fullScreen: true
}]
});
}
});

View File

@ -0,0 +1,7 @@
effects.windowAdded.connect(function (window) {
if (effect.grab(window, Effect.WindowAddedGrabRole)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,7 @@
effects.windowAdded.connect(function (window) {
if (effect.grab(window, Effect.WindowAddedGrabRole, true)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,7 @@
effects.windowAdded.connect(function (window) {
if (effect.grab(window, Effect.WindowAddedGrabRole)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,7 @@
effects.windowAdded.connect(function (window) {
if (effect.grab(window, Effect.WindowAddedGrabRole)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,7 @@
effects.windowAdded.connect(function (window) {
if (effect.grab(window, Effect.WindowAddedGrabRole)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,13 @@
"use strict";
effects.windowClosed.connect(function (window) {
animate({
window: window,
type: Effect.Scale,
duration: 1000,
from: 1.0,
to: 0.0
// by default, keepAlive is set to true
});
sendTestResponse("triggered");
});

View File

@ -0,0 +1,13 @@
"use strict";
effects.windowClosed.connect(function (window) {
animate({
window: window,
type: Effect.Scale,
duration: 1000,
from: 1.0,
to: 0.0,
keepAlive: false
});
sendTestResponse("triggered");
});

View File

@ -0,0 +1,18 @@
effects.windowAdded.connect(function (window) {
window.animation = animate({
window: window,
curve: QEasingCurve.Linear,
duration: animationTime(1000),
type: Effect.Opacity,
from: 0.0,
to: 1.0
})
});
effects.windowMinimized.connect(function (window) {
if (redirect(window.animation, Effect.Backward, Effect.DontTerminate)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,18 @@
effects.windowAdded.connect(function (window) {
window.animation = animate({
window: window,
curve: QEasingCurve.Linear,
duration: animationTime(1000),
type: Effect.Opacity,
from: 0.0,
to: 1.0
})
});
effects.windowMinimized.connect(function (window) {
if (redirect(window.animation, Effect.Backward, Effect.TerminateAtSource)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,19 @@
effects.windowAdded.connect(function (window) {
window.animation = set({
window: window,
curve: QEasingCurve.Linear,
duration: animationTime(1000),
type: Effect.Opacity,
from: 0.0,
to: 1.0,
keepAlive: false
});
});
effects.windowMinimized.connect(function (window) {
if (redirect(window.animation, Effect.Backward, Effect.DontTerminate)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,19 @@
effects.windowAdded.connect(function (window) {
window.animation = set({
window: window,
curve: QEasingCurve.Linear,
duration: animationTime(1000),
type: Effect.Opacity,
from: 0.0,
to: 1.0,
keepAlive: false
});
});
effects.windowMinimized.connect(function (window) {
if (redirect(window.animation, Effect.Backward, Effect.TerminateAtSource)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,3 @@
registerScreenEdge(1, function() {
sendTestResponse("triggered");
});

View File

@ -0,0 +1,3 @@
registerTouchScreenEdge(1, function() {
sendTestResponse("triggered");
});

View File

@ -0,0 +1,3 @@
registerShortcut("testShortcut", "Test Shortcut", "Meta+Shift+Y", function() {
sendTestResponse("shortcutTriggered");
});

View File

@ -0,0 +1,15 @@
effects.windowAdded.connect(function (window) {
if (effect.grab(window, Effect.WindowAddedGrabRole)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});
effects.windowMinimized.connect(function (window) {
if (effect.ungrab(window, Effect.WindowAddedGrabRole)) {
sendTestResponse('ok');
} else {
sendTestResponse('fail');
}
});

View File

@ -0,0 +1,343 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "kwin_wayland_test.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <KConfigGroup>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/slide.h>
#include <KWayland/Client/surface.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_slidingpopups-0");
class SlidingPopupsTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testWithOtherEffect_data();
void testWithOtherEffect();
void testWithOtherEffectWayland_data();
void testWithOtherEffectWayland();
};
void SlidingPopupsTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// disable all effects - we don't want to have it interact with the rendering
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (QString name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
KConfigGroup wobblyGroup = config->group("Effect-Wobbly");
wobblyGroup.writeEntry(QStringLiteral("Settings"), QStringLiteral("Custom"));
wobblyGroup.writeEntry(QStringLiteral("OpenEffect"), true);
wobblyGroup.writeEntry(QStringLiteral("CloseEffect"), true);
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QVERIFY(Compositor::self());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void SlidingPopupsTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
}
void SlidingPopupsTest::cleanup()
{
Test::destroyWaylandConnection();
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
while (!e->loadedEffects().isEmpty()) {
const QString effect = e->loadedEffects().first();
e->unloadEffect(effect);
QVERIFY(!e->isEffectLoaded(effect));
}
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void SlidingPopupsTest::testWithOtherEffect_data()
{
QTest::addColumn<QStringList>("effectsToLoad");
QTest::newRow("fade, slide") << QStringList{QStringLiteral("kwin4_effect_fade"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, fade") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("kwin4_effect_fade")};
QTest::newRow("scale, slide") << QStringList{QStringLiteral("kwin4_effect_scale"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, scale") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("kwin4_effect_scale")};
if (effects->compositingType() & KWin::OpenGLCompositing) {
QTest::newRow("glide, slide") << QStringList{QStringLiteral("glide"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, glide") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("glide")};
QTest::newRow("wobblywindows, slide") << QStringList{QStringLiteral("wobblywindows"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, wobblywindows") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("wobblywindows")};
QTest::newRow("fallapart, slide") << QStringList{QStringLiteral("fallapart"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, fallapart") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("fallapart")};
}
}
void SlidingPopupsTest::testWithOtherEffect()
{
// this test verifies that slidingpopups effect grabs the window added role
// independently of the sequence how the effects are loaded.
// see BUG 336866
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
// find the effectsloader
auto effectloader = e->findChild<AbstractEffectLoader *>();
QVERIFY(effectloader);
QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded);
Effect *slidingPoupus = nullptr;
Effect *otherEffect = nullptr;
QFETCH(QStringList, effectsToLoad);
for (const QString &effectName : effectsToLoad) {
QVERIFY(!e->isEffectLoaded(effectName));
QVERIFY(e->loadEffect(effectName));
QVERIFY(e->isEffectLoaded(effectName));
QCOMPARE(effectLoadedSpy.count(), 1);
Effect *effect = effectLoadedSpy.first().first().value<Effect *>();
if (effectName == QStringLiteral("slidingpopups")) {
slidingPoupus = effect;
} else {
otherEffect = effect;
}
effectLoadedSpy.clear();
}
QVERIFY(slidingPoupus);
QVERIFY(otherEffect);
QVERIFY(!slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded);
// create an xcb window
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
const QRect windowGeometry(0, 0, 100, 200);
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
NETWinInfo winInfo(c.get(), windowId, rootWindow(), NET::Properties(), NET::Properties2());
winInfo.setWindowType(NET::Normal);
// and get the slide atom
const QByteArray effectAtomName = QByteArrayLiteral("_KDE_SLIDE");
xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c.get(), false, effectAtomName.length(), effectAtomName.constData());
const int size = 2;
int32_t data[size];
data[0] = 0;
data[1] = 0;
UniqueCPtr<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply(c.get(), atomCookie, nullptr));
QVERIFY(atom != nullptr);
xcb_change_property(c.get(), XCB_PROP_MODE_REPLACE, windowId, atom->atom, atom->atom, 32, size, data);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isNormalWindow());
// sliding popups should be active
QVERIFY(windowAddedSpy.wait());
QTRY_VERIFY(slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
// wait till effect ends
QTRY_VERIFY(!slidingPoupus->isActive());
QTRY_VERIFY(!otherEffect->isActive());
// and destroy the window again
xcb_unmap_window(c.get(), windowId);
xcb_flush(c.get());
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QSignalSpy windowDeletedSpy(effects, &EffectsHandler::windowDeleted);
QVERIFY(windowClosedSpy.wait());
// again we should have the sliding popups active
QVERIFY(slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
QVERIFY(windowDeletedSpy.wait());
QCOMPARE(windowDeletedSpy.count(), 1);
QVERIFY(!slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
xcb_destroy_window(c.get(), windowId);
c.reset();
}
void SlidingPopupsTest::testWithOtherEffectWayland_data()
{
QTest::addColumn<QStringList>("effectsToLoad");
QTest::newRow("fade, slide") << QStringList{QStringLiteral("kwin4_effect_fade"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, fade") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("kwin4_effect_fade")};
QTest::newRow("scale, slide") << QStringList{QStringLiteral("kwin4_effect_scale"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, scale") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("kwin4_effect_scale")};
if (effects->compositingType() & KWin::OpenGLCompositing) {
QTest::newRow("glide, slide") << QStringList{QStringLiteral("glide"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, glide") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("glide")};
QTest::newRow("wobblywindows, slide") << QStringList{QStringLiteral("wobblywindows"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, wobblywindows") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("wobblywindows")};
QTest::newRow("fallapart, slide") << QStringList{QStringLiteral("fallapart"), QStringLiteral("slidingpopups")};
QTest::newRow("slide, fallapart") << QStringList{QStringLiteral("slidingpopups"), QStringLiteral("fallapart")};
}
}
void SlidingPopupsTest::testWithOtherEffectWayland()
{
// this test verifies that slidingpopups effect grabs the window added role
// independently of the sequence how the effects are loaded.
// see BUG 336866
// the test is like testWithOtherEffect, but simulates using a Wayland window
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
// find the effectsloader
auto effectloader = e->findChild<AbstractEffectLoader *>();
QVERIFY(effectloader);
QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded);
Effect *slidingPoupus = nullptr;
Effect *otherEffect = nullptr;
QFETCH(QStringList, effectsToLoad);
for (const QString &effectName : effectsToLoad) {
QVERIFY(!e->isEffectLoaded(effectName));
QVERIFY(e->loadEffect(effectName));
QVERIFY(e->isEffectLoaded(effectName));
QCOMPARE(effectLoadedSpy.count(), 1);
Effect *effect = effectLoadedSpy.first().first().value<Effect *>();
if (effectName == QStringLiteral("slidingpopups")) {
slidingPoupus = effect;
} else {
otherEffect = effect;
}
effectLoadedSpy.clear();
}
QVERIFY(slidingPoupus);
QVERIFY(otherEffect);
QVERIFY(!slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded);
// the test created the slide protocol, let's create a Registry and listen for it
std::unique_ptr<KWayland::Client::Registry> registry(new KWayland::Client::Registry);
registry->create(Test::waylandConnection());
QSignalSpy interfacesAnnouncedSpy(registry.get(), &KWayland::Client::Registry::interfacesAnnounced);
registry->setup();
QVERIFY(interfacesAnnouncedSpy.wait());
auto slideInterface = registry->interface(KWayland::Client::Registry::Interface::Slide);
QVERIFY(slideInterface.name != 0);
std::unique_ptr<KWayland::Client::SlideManager> slideManager(registry->createSlideManager(slideInterface.name, slideInterface.version));
QVERIFY(slideManager);
// create Wayland window
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface);
std::unique_ptr<KWayland::Client::Slide> slide(slideManager->createSlide(surface.get()));
slide->setLocation(KWayland::Client::Slide::Location::Left);
slide->commit();
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface);
QCOMPARE(windowAddedSpy.count(), 0);
auto window = Test::renderAndWaitForShown(surface.get(), QSize(10, 20), Qt::blue);
QVERIFY(window);
QVERIFY(window->isNormalWindow());
// sliding popups should be active
QCOMPARE(windowAddedSpy.count(), 1);
QTRY_VERIFY(slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
// wait till effect ends
QTRY_VERIFY(!slidingPoupus->isActive());
QTRY_VERIFY(!otherEffect->isActive());
// and destroy the window again
shellSurface.reset();
surface.reset();
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QSignalSpy windowDeletedSpy(effects, &EffectsHandler::windowDeleted);
QVERIFY(windowClosedSpy.wait());
// again we should have the sliding popups active
QVERIFY(slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
QVERIFY(windowDeletedSpy.wait());
QCOMPARE(windowDeletedSpy.count(), 1);
QVERIFY(!slidingPoupus->isActive());
QVERIFY(!otherEffect->isActive());
}
WAYLANDTEST_MAIN(SlidingPopupsTest)
#include "slidingpopups_test.moc"

View File

@ -0,0 +1,202 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "deleted.h"
#include "effectloader.h"
#include "effects.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_toplevel_open_close_animation-0");
class ToplevelOpenCloseAnimationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testAnimateToplevels_data();
void testAnimateToplevels();
void testDontAnimatePopups_data();
void testDontAnimatePopups();
};
void ToplevelOpenCloseAnimationTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (const QString &name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", QByteArrayLiteral("1"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void ToplevelOpenCloseAnimationTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void ToplevelOpenCloseAnimationTest::cleanup()
{
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
Test::destroyWaylandConnection();
}
void ToplevelOpenCloseAnimationTest::testAnimateToplevels_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
}
void ToplevelOpenCloseAnimationTest::testAnimateToplevels()
{
// This test verifies that window open/close animation effects try to
// animate the appearing and the disappearing of toplevel windows.
// Make sure that we have the right effects ptr.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
// Load effect that will be tested.
QFETCH(QString, effectName);
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
// Close the test window, the effect should start animating the disappearing
// of the window.
QSignalSpy windowClosedSpy(window, &Window::windowClosed);
shellSurface.reset();
surface.reset();
QVERIFY(windowClosedSpy.wait());
QVERIFY(effect->isActive());
// Eventually, the animation will be complete.
QTRY_VERIFY(!effect->isActive());
}
void ToplevelOpenCloseAnimationTest::testDontAnimatePopups_data()
{
QTest::addColumn<QString>("effectName");
QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade");
QTest::newRow("Glide") << QStringLiteral("glide");
QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale");
}
void ToplevelOpenCloseAnimationTest::testDontAnimatePopups()
{
// This test verifies that window open/close animation effects don't try
// to animate popups(e.g. popup menus, tooltips, etc).
// Make sure that we have the right effects ptr.
auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects);
QVERIFY(effectsImpl);
// Create the main window.
std::unique_ptr<KWayland::Client::Surface> mainWindowSurface(Test::createSurface());
QVERIFY(mainWindowSurface != nullptr);
std::unique_ptr<Test::XdgToplevel> mainWindowShellSurface(Test::createXdgToplevelSurface(mainWindowSurface.get()));
QVERIFY(mainWindowShellSurface != nullptr);
Window *mainWindow = Test::renderAndWaitForShown(mainWindowSurface.get(), QSize(100, 50), Qt::blue);
QVERIFY(mainWindow);
// Load effect that will be tested.
QFETCH(QString, effectName);
QVERIFY(effectsImpl->loadEffect(effectName));
QCOMPARE(effectsImpl->loadedEffects().count(), 1);
QCOMPARE(effectsImpl->loadedEffects().first(), effectName);
Effect *effect = effectsImpl->findEffect(effectName);
QVERIFY(effect);
QVERIFY(!effect->isActive());
// Create a popup, it should not be animated.
std::unique_ptr<KWayland::Client::Surface> popupSurface(Test::createSurface());
QVERIFY(popupSurface != nullptr);
std::unique_ptr<Test::XdgPositioner> positioner(Test::createXdgPositioner());
QVERIFY(positioner);
positioner->set_size(20, 20);
positioner->set_anchor_rect(0, 0, 10, 10);
positioner->set_gravity(Test::XdgPositioner::gravity_bottom_right);
positioner->set_anchor(Test::XdgPositioner::anchor_bottom_left);
std::unique_ptr<Test::XdgPopup> popupShellSurface(Test::createXdgPopupSurface(popupSurface.get(), mainWindowShellSurface->xdgSurface(), positioner.get()));
QVERIFY(popupShellSurface != nullptr);
Window *popup = Test::renderAndWaitForShown(popupSurface.get(), QSize(20, 20), Qt::red);
QVERIFY(popup);
QVERIFY(popup->isPopupWindow());
QCOMPARE(popup->transientFor(), mainWindow);
QVERIFY(!effect->isActive());
// Destroy the popup, it should not be animated.
QSignalSpy popupClosedSpy(popup, &Window::windowClosed);
popupShellSurface.reset();
popupSurface.reset();
QVERIFY(popupClosedSpy.wait());
QVERIFY(!effect->isActive());
// Destroy the main window.
mainWindowSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(mainWindow));
}
WAYLANDTEST_MAIN(ToplevelOpenCloseAnimationTest)
#include "toplevel_open_close_animation_test.moc"

View File

@ -0,0 +1,227 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "effectloader.h"
#include "effects.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <KConfigGroup>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_translucency-0");
class TranslucencyTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testMoveAfterDesktopChange();
void testDialogClose();
private:
Effect *m_translucencyEffect = nullptr;
};
void TranslucencyTest::initTestCase()
{
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// disable all effects - we don't want to have it interact with the rendering
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (QString name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->group("Outline").writeEntry(QStringLiteral("QmlPath"), QString("/does/not/exist.qml"));
config->group("Effect-kwin4_effect_translucency").writeEntry(QStringLiteral("Dialogs"), 90);
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QVERIFY(Compositor::self());
}
void TranslucencyTest::init()
{
// load the translucency effect
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
// find the effectsloader
auto effectloader = e->findChild<AbstractEffectLoader *>();
QVERIFY(effectloader);
QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded);
QVERIFY(!e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency")));
QVERIFY(e->loadEffect(QStringLiteral("kwin4_effect_translucency")));
QVERIFY(e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency")));
QCOMPARE(effectLoadedSpy.count(), 1);
m_translucencyEffect = effectLoadedSpy.first().first().value<Effect *>();
QVERIFY(m_translucencyEffect);
}
void TranslucencyTest::cleanup()
{
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
if (e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency"))) {
e->unloadEffect(QStringLiteral("kwin4_effect_translucency"));
}
QVERIFY(!e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency")));
m_translucencyEffect = nullptr;
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void TranslucencyTest::testMoveAfterDesktopChange()
{
// test tries to simulate the condition of bug 366081
QVERIFY(!m_translucencyEffect->isActive());
QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded);
// create an xcb window
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
const QRect windowGeometry(0, 0, 100, 200);
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
QVERIFY(windowAddedSpy.wait());
QVERIFY(!m_translucencyEffect->isActive());
// let's send the window to desktop 2
effects->setNumberOfDesktops(2);
QCOMPARE(effects->numberOfDesktops(), 2);
workspace()->sendWindowToDesktop(window, 2, false);
effects->setCurrentDesktop(2);
QVERIFY(!m_translucencyEffect->isActive());
KWin::Cursors::self()->mouse()->setPos(window->frameGeometry().center());
workspace()->performWindowOperation(window, Options::MoveOp);
QVERIFY(m_translucencyEffect->isActive());
QTest::qWait(200);
QVERIFY(m_translucencyEffect->isActive());
// now end move resize
window->endInteractiveMoveResize();
QVERIFY(m_translucencyEffect->isActive());
QTest::qWait(500);
QTRY_VERIFY(!m_translucencyEffect->isActive());
// and destroy the window again
xcb_unmap_window(c.get(), windowId);
xcb_flush(c.get());
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QVERIFY(windowClosedSpy.wait());
xcb_destroy_window(c.get(), windowId);
c.reset();
}
void TranslucencyTest::testDialogClose()
{
// this test simulates the condition of BUG 342716
// with translucency settings for window type dialog the effect never ends when the window gets destroyed
QVERIFY(!m_translucencyEffect->isActive());
QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded);
// create an xcb window
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
const QRect windowGeometry(0, 0, 100, 200);
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
NETWinInfo winInfo(c.get(), windowId, rootWindow(), NET::Properties(), NET::Properties2());
winInfo.setWindowType(NET::Dialog);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
QVERIFY(window->isDialog());
QVERIFY(windowAddedSpy.wait());
QTRY_VERIFY(m_translucencyEffect->isActive());
// and destroy the window again
xcb_unmap_window(c.get(), windowId);
xcb_flush(c.get());
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
QSignalSpy windowDeletedSpy(effects, &EffectsHandler::windowDeleted);
QVERIFY(windowClosedSpy.wait());
if (windowDeletedSpy.isEmpty()) {
QVERIFY(windowDeletedSpy.wait());
}
QCOMPARE(windowDeletedSpy.count(), 1);
QTRY_VERIFY(!m_translucencyEffect->isActive());
xcb_destroy_window(c.get(), windowId);
c.reset();
}
WAYLANDTEST_MAIN(TranslucencyTest)
#include "translucency_test.moc"

View File

@ -0,0 +1,178 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 Martin Flöser <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "effectloader.h"
#include "effects.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <KConfigGroup>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/slide.h>
#include <KWayland/Client/surface.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_effects_wobbly_shade-0");
class WobblyWindowsShadeTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testShadeMove();
};
void WobblyWindowsShadeTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Effect *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// disable all effects - we don't want to have it interact with the rendering
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (QString name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2"));
qputenv("KWIN_EFFECTS_FORCE_ANIMATIONS", "1");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QVERIFY(Compositor::self());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void WobblyWindowsShadeTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
}
void WobblyWindowsShadeTest::cleanup()
{
Test::destroyWaylandConnection();
auto effectsImpl = static_cast<EffectsHandlerImpl *>(effects);
effectsImpl->unloadAllEffects();
QVERIFY(effectsImpl->loadedEffects().isEmpty());
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void WobblyWindowsShadeTest::testShadeMove()
{
// this test simulates the condition from BUG 390953
EffectsHandlerImpl *e = static_cast<EffectsHandlerImpl *>(effects);
QVERIFY(e->loadEffect(QStringLiteral("wobblywindows")));
QVERIFY(e->isEffectLoaded(QStringLiteral("wobblywindows")));
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
const QRect windowGeometry(0, 0, 100, 200);
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
QVERIFY(window->isShadeable());
QVERIFY(!window->isShade());
QVERIFY(window->isActive());
QSignalSpy windowShownSpy(window, &Window::windowShown);
QVERIFY(windowShownSpy.wait());
// now shade the window
workspace()->slotWindowShade();
QVERIFY(window->isShade());
QSignalSpy windowStartUserMovedResizedSpy(e, &EffectsHandler::windowStartUserMovedResized);
// begin move
QVERIFY(workspace()->moveResizeWindow() == nullptr);
QCOMPARE(window->isInteractiveMove(), false);
workspace()->slotWindowMove();
QCOMPARE(workspace()->moveResizeWindow(), window);
QCOMPARE(window->isInteractiveMove(), true);
QCOMPARE(windowStartUserMovedResizedSpy.count(), 1);
// wait for frame rendered
QTest::qWait(100);
// send some key events, not going through input redirection
window->keyPressEvent(Qt::Key_Right);
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
// wait for frame rendered
QTest::qWait(100);
window->keyPressEvent(Qt::Key_Right);
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
// wait for frame rendered
QTest::qWait(100);
window->keyPressEvent(Qt::Key_Down | Qt::ALT);
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
// wait for frame rendered
QTest::qWait(100);
// let's end
window->keyPressEvent(Qt::Key_Enter);
// wait for frame rendered
QTest::qWait(100);
}
WAYLANDTEST_MAIN(WobblyWindowsShadeTest)
#include "wobbly_shade_test.moc"

View File

@ -0,0 +1,2 @@
add_subdirectory(org.kde.kdecoration2)

View File

@ -0,0 +1,15 @@
########################################################
# FakeDecoWithShadows
########################################################
add_library(fakedecoshadows MODULE fakedecoration_with_shadows.cpp)
set_target_properties(fakedecoshadows PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/fakes/org.kde.kdecoration2")
target_link_libraries(fakedecoshadows
PUBLIC
Qt::Core
Qt::Gui
PRIVATE
KDecoration2::KDecoration
KF5::CoreAddons)

View File

@ -0,0 +1,63 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QPainter>
#include <KDecoration2/Decoration>
#include <KPluginFactory>
class FakeDecoWithShadows : public KDecoration2::Decoration
{
Q_OBJECT
public:
explicit FakeDecoWithShadows(QObject *parent = nullptr, const QVariantList &args = QVariantList())
: Decoration(parent, args)
{
}
~FakeDecoWithShadows() override
{
}
void paint(QPainter *painter, const QRect &repaintRegion) override
{
}
public Q_SLOTS:
void init() override
{
const int shadowSize = 128;
const int offsetTop = 64;
const int offsetLeft = 48;
const QRect shadowRect(0, 0, 4 * shadowSize + 1, 4 * shadowSize + 1);
QImage shadowTexture(shadowRect.size(), QImage::Format_ARGB32_Premultiplied);
shadowTexture.fill(Qt::transparent);
const QMargins padding(
shadowSize - offsetLeft,
shadowSize - offsetTop,
shadowSize + offsetLeft,
shadowSize + offsetTop);
auto decoShadow = QSharedPointer<KDecoration2::DecorationShadow>::create();
decoShadow->setPadding(padding);
decoShadow->setInnerShadowRect(QRect(shadowRect.center(), QSize(1, 1)));
decoShadow->setShadow(shadowTexture);
setShadow(decoShadow);
}
};
K_PLUGIN_FACTORY_WITH_JSON(
FakeDecoWithShadowsFactory,
"fakedecoration_with_shadows.json",
registerPlugin<FakeDecoWithShadows>();)
#include "fakedecoration_with_shadows.moc"

View File

@ -0,0 +1,12 @@
{
"KPlugin": {
"Description": "Window decoration to test shadow tile overlaps",
"EnabledByDefault": false,
"Id": "org.kde.test.fakedecowithshadows",
"Name": "Fake Decoration With Shadows"
},
"org.kde.kdecoration2": {
"blur": false,
"kcmodule": false
}
}

View File

@ -0,0 +1,103 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "wayland/clientconnection.h"
#include "wayland/display.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/output.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/surface.h>
#include <QDBusConnection>
// system
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <csignal>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_fractionalScale-0");
class TestFractionalScale : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testShow();
};
void TestFractionalScale::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWayland::Client::Output *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)),
Q_ARG(QVector<qreal>, QVector<qreal>() << 1.25 << 2.0));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1024, 819));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 640, 512));
QCOMPARE(outputs[0]->scale(), 1.25);
QCOMPARE(outputs[1]->scale(), 2.0);
}
void TestFractionalScale::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::FractionalScaleManagerV1));
workspace()->setActiveOutput(QPoint(640, 512));
// put mouse in the middle of screen one
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void TestFractionalScale::cleanup()
{
Test::destroyWaylandConnection();
}
void TestFractionalScale::testShow()
{
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::FractionalScaleV1> fractionalScale(Test::createFractionalScaleV1(surface.get()));
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
// above call commits the surface and blocks for the configure event. We should have received the scale already
// We are sent the value in 120ths
QCOMPARE(fractionalScale->preferredScale(), 1.25 * 120);
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(fractionalScale->preferredScale(), 1.25 * 120);
}
WAYLANDTEST_MAIN(TestFractionalScale)
#include "fractional_scaling_test.moc"

View File

@ -0,0 +1,84 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "generic_scene_opengl_test.h"
#include "composite.h"
#include "core/outputbackend.h"
#include "core/renderbackend.h"
#include "cursor.h"
#include "effectloader.h"
#include "scene/workspacescene.h"
#include "wayland_server.h"
#include "window.h"
#include <KConfigGroup>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_opengl-0");
GenericSceneOpenGLTest::GenericSceneOpenGLTest(const QByteArray &envVariable)
: QObject()
, m_envVariable(envVariable)
{
}
GenericSceneOpenGLTest::~GenericSceneOpenGLTest()
{
}
void GenericSceneOpenGLTest::cleanup()
{
Test::destroyWaylandConnection();
}
void GenericSceneOpenGLTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
// disable all effects - we don't want to have it interact with the rendering
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
KConfigGroup plugins(config, QStringLiteral("Plugins"));
const auto builtinNames = EffectLoader().listOfKnownEffects();
for (QString name : builtinNames) {
plugins.writeEntry(name + QStringLiteral("Enabled"), false);
}
config->sync();
kwinApp()->setConfig(config);
qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White"));
qputenv("XCURSOR_SIZE", QByteArrayLiteral("24"));
qputenv("KWIN_COMPOSE", m_envVariable);
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
QVERIFY(Compositor::self());
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
}
void GenericSceneOpenGLTest::testRestart()
{
// simple restart of the OpenGL compositor without any windows being shown
QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &Compositor::sceneCreated);
KWin::Compositor::self()->reinitialize();
if (sceneCreatedSpy.isEmpty()) {
QVERIFY(sceneCreatedSpy.wait());
}
QCOMPARE(sceneCreatedSpy.count(), 1);
QCOMPARE(Compositor::self()->backend()->compositingType(), KWin::OpenGLCompositing);
// trigger a repaint
KWin::Compositor::self()->scene()->addRepaintFull();
// and wait 100 msec to ensure it's rendered
// TODO: introduce frameRendered signal in SceneOpenGL
QTest::qWait(100);
}

View File

@ -0,0 +1,29 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "kwin_wayland_test.h"
#include <QObject>
class GenericSceneOpenGLTest : public QObject
{
Q_OBJECT
public:
~GenericSceneOpenGLTest() override;
protected:
GenericSceneOpenGLTest(const QByteArray &envVariable);
private Q_SLOTS:
void initTestCase();
void cleanup();
void testRestart();
private:
QByteArray m_envVariable;
};

View File

@ -0,0 +1,440 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "input.h"
#include "internalwindow.h"
#include "keyboard_input.h"
#include "useractions.h"
#include "wayland/keyboard_interface.h"
#include "wayland/seat_interface.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include "xkb.h"
#include <KWayland/Client/surface.h>
#include <KGlobalAccel>
#include <QAction>
#include <linux/input.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_globalshortcuts-0");
class GlobalShortcutsTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testNonLatinLayout_data();
void testNonLatinLayout();
void testConsumedShift();
void testRepeatedTrigger();
void testUserActionsMenu();
void testMetaShiftW();
void testComponseKey();
void testX11WindowShortcut();
void testWaylandWindowShortcut();
void testSetupWindowShortcut();
};
void GlobalShortcutsTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::InternalWindow *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1");
qputenv("XKB_DEFAULT_RULES", "evdev");
qputenv("XKB_DEFAULT_LAYOUT", "us,ru");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void GlobalShortcutsTest::init()
{
QVERIFY(Test::setupWaylandConnection());
workspace()->setActiveOutput(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
auto xkb = input()->keyboard()->xkb();
xkb->switchToLayout(0);
}
void GlobalShortcutsTest::cleanup()
{
Test::destroyWaylandConnection();
}
Q_DECLARE_METATYPE(Qt::Modifier)
void GlobalShortcutsTest::testNonLatinLayout_data()
{
QTest::addColumn<int>("modifierKey");
QTest::addColumn<Qt::Modifier>("qtModifier");
QTest::addColumn<int>("key");
QTest::addColumn<Qt::Key>("qtKey");
// KEY_W is "ц" in the RU layout and "w" in the US layout
// KEY_GRAVE is "ё" in the RU layout and "`" in the US layout
// TAB_KEY is the same both in the US and RU layout
QTest::newRow("Left Ctrl + Tab") << KEY_LEFTCTRL << Qt::CTRL << KEY_TAB << Qt::Key_Tab;
QTest::newRow("Left Ctrl + W") << KEY_LEFTCTRL << Qt::CTRL << KEY_W << Qt::Key_W;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QTest::newRow("Left Ctrl + `") << KEY_LEFTCTRL << Qt::CTRL << KEY_GRAVE << Qt::Key_QuoteLeft;
#endif
QTest::newRow("Left Alt + Tab") << KEY_LEFTALT << Qt::ALT << KEY_TAB << Qt::Key_Tab;
QTest::newRow("Left Alt + W") << KEY_LEFTALT << Qt::ALT << KEY_W << Qt::Key_W;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QTest::newRow("Left Alt + `") << KEY_LEFTALT << Qt::ALT << KEY_GRAVE << Qt::Key_QuoteLeft;
#endif
QTest::newRow("Left Shift + Tab") << KEY_LEFTSHIFT << Qt::SHIFT << KEY_TAB << Qt::Key_Tab;
QTest::newRow("Left Meta + Tab") << KEY_LEFTMETA << Qt::META << KEY_TAB << Qt::Key_Tab;
QTest::newRow("Left Meta + W") << KEY_LEFTMETA << Qt::META << KEY_W << Qt::Key_W;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QTest::newRow("Left Meta + `") << KEY_LEFTMETA << Qt::META << KEY_GRAVE << Qt::Key_QuoteLeft;
#endif
}
void GlobalShortcutsTest::testNonLatinLayout()
{
// Shortcuts on non-Latin layouts should still work, see BUG 375518
auto xkb = input()->keyboard()->xkb();
xkb->switchToLayout(1);
QCOMPARE(xkb->layoutName(), QStringLiteral("Russian"));
QFETCH(int, modifierKey);
QFETCH(Qt::Modifier, qtModifier);
QFETCH(int, key);
QFETCH(Qt::Key, qtKey);
const QKeySequence seq(qtModifier + qtKey);
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName("globalshortcuts-test-non-latin-layout");
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->stealShortcutSystemwide(seq);
KGlobalAccel::self()->setShortcut(action.get(), {seq}, KGlobalAccel::NoAutoloading);
quint32 timestamp = 0;
Test::keyboardKeyPressed(modifierKey, timestamp++);
QCOMPARE(input()->keyboardModifiers(), qtModifier);
Test::keyboardKeyPressed(key, timestamp++);
Test::keyboardKeyReleased(key, timestamp++);
Test::keyboardKeyReleased(modifierKey, timestamp++);
QTRY_COMPARE_WITH_TIMEOUT(triggeredSpy.count(), 1, 100);
}
void GlobalShortcutsTest::testConsumedShift()
{
// this test verifies that a shortcut with a consumed shift modifier triggers
// create the action
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-consumed-shift"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::Key_Percent}, KGlobalAccel::NoAutoloading);
// press shift+5
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier);
Test::keyboardKeyPressed(KEY_5, timestamp++);
QTRY_COMPARE(triggeredSpy.count(), 1);
Test::keyboardKeyReleased(KEY_5, timestamp++);
// release shift
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
}
void GlobalShortcutsTest::testRepeatedTrigger()
{
// this test verifies that holding a key, triggers repeated global shortcut
// in addition pressing another key should stop triggering the shortcut
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-consumed-shift"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::Key_Percent}, KGlobalAccel::NoAutoloading);
// we need to configure the key repeat first. It is only enabled on libinput
waylandServer()->seat()->keyboard()->setRepeatInfo(25, 300);
// press shift+5
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_WAKEUP, timestamp++);
Test::keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier);
Test::keyboardKeyPressed(KEY_5, timestamp++);
QTRY_COMPARE(triggeredSpy.count(), 1);
// and should repeat
QVERIFY(triggeredSpy.wait());
QVERIFY(triggeredSpy.wait());
// now release the key
Test::keyboardKeyReleased(KEY_5, timestamp++);
QVERIFY(!triggeredSpy.wait(50));
Test::keyboardKeyReleased(KEY_WAKEUP, timestamp++);
QVERIFY(!triggeredSpy.wait(50));
// release shift
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
}
void GlobalShortcutsTest::testUserActionsMenu()
{
// this test tries to trigger the user actions menu with Alt+F3
// the problem here is that pressing F3 consumes modifiers as it's part of the
// Ctrl+alt+F3 keysym for vt switching. xkbcommon considers all modifiers as consumed
// which a transformation to any keysym would cause
// for more information see:
// https://bugs.freedesktop.org/show_bug.cgi?id=92818
// https://github.com/xkbcommon/libxkbcommon/issues/17
// first create a window
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QVERIFY(window->isActive());
quint32 timestamp = 0;
QVERIFY(!workspace()->userActionsMenu()->isShown());
Test::keyboardKeyPressed(KEY_LEFTALT, timestamp++);
Test::keyboardKeyPressed(KEY_F3, timestamp++);
Test::keyboardKeyReleased(KEY_F3, timestamp++);
QTRY_VERIFY(workspace()->userActionsMenu()->isShown());
Test::keyboardKeyReleased(KEY_LEFTALT, timestamp++);
}
void GlobalShortcutsTest::testMetaShiftW()
{
// BUG 370341
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-meta-shift-w"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::META | Qt::SHIFT | Qt::Key_W}, KGlobalAccel::NoAutoloading);
// press meta+shift+w
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::MetaModifier);
Test::keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier | Qt::MetaModifier);
Test::keyboardKeyPressed(KEY_W, timestamp++);
QTRY_COMPARE(triggeredSpy.count(), 1);
Test::keyboardKeyReleased(KEY_W, timestamp++);
// release meta+shift
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
}
void GlobalShortcutsTest::testComponseKey()
{
// BUG 390110
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-accent"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::NoModifier}, KGlobalAccel::NoAutoloading);
// press & release `
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_RESERVED, timestamp++);
Test::keyboardKeyReleased(KEY_RESERVED, timestamp++);
QTRY_COMPARE(triggeredSpy.count(), 0);
}
struct XcbConnectionDeleter
{
void operator()(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void GlobalShortcutsTest::testX11WindowShortcut()
{
#ifdef NO_XWAYLAND
QSKIP("x11 test, unnecessary without xwayland");
#endif
// create an X11 window
std::unique_ptr<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.get()));
xcb_window_t windowId = xcb_generate_id(c.get());
const QRect windowGeometry = QRect(0, 0, 10, 20);
const uint32_t values[] = {
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW};
xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
windowGeometry.height(),
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, XCB_CW_EVENT_MASK, values);
xcb_size_hints_t hints;
memset(&hints, 0, sizeof(hints));
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
info.setWindowType(NET::Normal);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.last().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
QVERIFY(window->isActive());
QCOMPARE(window->shortcut(), QKeySequence());
const QKeySequence seq(Qt::META | Qt::SHIFT | Qt::Key_Y);
QVERIFY(workspace()->shortcutAvailable(seq));
window->setShortcut(seq.toString());
QCOMPARE(window->shortcut(), seq);
QVERIFY(!workspace()->shortcutAvailable(seq));
QCOMPARE(window->caption(), QStringLiteral(" {Meta+Shift+Y}"));
// it's delayed
QCoreApplication::processEvents();
workspace()->activateWindow(nullptr);
QVERIFY(!workspace()->activeWindow());
QVERIFY(!window->isActive());
// now let's trigger the shortcut
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
Test::keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyPressed(KEY_Y, timestamp++);
QTRY_COMPARE(workspace()->activeWindow(), window);
Test::keyboardKeyReleased(KEY_Y, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
// destroy window again
QSignalSpy windowClosedSpy(window, &X11Window::windowClosed);
xcb_unmap_window(c.get(), windowId);
xcb_destroy_window(c.get(), windowId);
xcb_flush(c.get());
QVERIFY(windowClosedSpy.wait());
}
void GlobalShortcutsTest::testWaylandWindowShortcut()
{
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QCOMPARE(workspace()->activeWindow(), window);
QVERIFY(window->isActive());
QCOMPARE(window->shortcut(), QKeySequence());
const QKeySequence seq(Qt::META | Qt::SHIFT | Qt::Key_Y);
QVERIFY(workspace()->shortcutAvailable(seq));
window->setShortcut(seq.toString());
QCOMPARE(window->shortcut(), seq);
QVERIFY(!workspace()->shortcutAvailable(seq));
QCOMPARE(window->caption(), QStringLiteral(" {Meta+Shift+Y}"));
workspace()->activateWindow(nullptr);
QVERIFY(!workspace()->activeWindow());
QVERIFY(!window->isActive());
// now let's trigger the shortcut
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
Test::keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyPressed(KEY_Y, timestamp++);
QTRY_COMPARE(workspace()->activeWindow(), window);
Test::keyboardKeyReleased(KEY_Y, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
shellSurface.reset();
surface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
QTRY_VERIFY_WITH_TIMEOUT(workspace()->shortcutAvailable(seq), 500); // we need the try since KGlobalAccelPrivate::unregister is async
}
void GlobalShortcutsTest::testSetupWindowShortcut()
{
// QTBUG-62102
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QCOMPARE(workspace()->activeWindow(), window);
QVERIFY(window->isActive());
QCOMPARE(window->shortcut(), QKeySequence());
QSignalSpy shortcutDialogAddedSpy(workspace(), &Workspace::internalWindowAdded);
workspace()->slotSetupWindowShortcut();
QTRY_COMPARE(shortcutDialogAddedSpy.count(), 1);
auto dialog = shortcutDialogAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(dialog);
QVERIFY(dialog->isInternal());
auto sequenceEdit = workspace()->shortcutDialog()->findChild<QKeySequenceEdit *>();
QVERIFY(sequenceEdit);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// the QKeySequenceEdit field does not get focus, we need to pass it focus manually
QEXPECT_FAIL("", "Edit does not have focus", Continue);
QVERIFY(sequenceEdit->hasFocus());
sequenceEdit->setFocus();
#endif
QTRY_VERIFY(sequenceEdit->hasFocus());
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
Test::keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyPressed(KEY_Y, timestamp++);
Test::keyboardKeyReleased(KEY_Y, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
// the sequence gets accepted after one second, so wait a bit longer
QTest::qWait(2000);
// now send in enter
Test::keyboardKeyPressed(KEY_ENTER, timestamp++);
Test::keyboardKeyReleased(KEY_ENTER, timestamp++);
QTRY_COMPARE(window->shortcut(), QKeySequence(Qt::META | Qt::SHIFT | Qt::Key_Y));
}
WAYLANDTEST_MAIN(GlobalShortcutsTest)
#include "globalshortcuts_test.moc"

View File

@ -0,0 +1,11 @@
add_executable(copy copy.cpp)
target_link_libraries(copy Qt::Gui)
ecm_mark_as_test(copy)
######################
add_executable(paste paste.cpp)
target_link_libraries(paste Qt::Gui)
ecm_mark_as_test(paste)
######################
add_executable(kill kill.cpp)
target_link_libraries(kill Qt::Widgets)
ecm_mark_as_test(kill)

View File

@ -0,0 +1,59 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QClipboard>
#include <QGuiApplication>
#include <QPainter>
#include <QRasterWindow>
#include <QTimer>
class Window : public QRasterWindow
{
Q_OBJECT
public:
explicit Window();
~Window() override;
protected:
void paintEvent(QPaintEvent *event) override;
void focusInEvent(QFocusEvent *event) override;
};
Window::Window()
: QRasterWindow()
{
}
Window::~Window() = default;
void Window::paintEvent(QPaintEvent *event)
{
QPainter p(this);
p.fillRect(0, 0, width(), height(), Qt::red);
}
void Window::focusInEvent(QFocusEvent *event)
{
QRasterWindow::focusInEvent(event);
// TODO: make it work without singleshot
QTimer::singleShot(100, [] {
qApp->clipboard()->setText(QStringLiteral("test"));
});
}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
std::unique_ptr<Window> w(new Window);
w->setGeometry(QRect(0, 0, 100, 200));
w->show();
return app.exec();
}
#include "copy.moc"

View File

@ -0,0 +1,35 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QApplication>
#include <QEventLoop>
#include <QTimer>
#include <QWidget>
#include <unistd.h>
#include <csignal>
int main(int argc, char *argv[])
{
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
QApplication app(argc, argv);
QWidget w;
w.setGeometry(QRect(0, 0, 100, 200));
w.show();
auto freezeHandler = [](int) {
while (true) {
sleep(10000);
}
};
signal(SIGUSR1, freezeHandler);
return app.exec();
}

View File

@ -0,0 +1,55 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QClipboard>
#include <QGuiApplication>
#include <QPainter>
#include <QRasterWindow>
#include <QTimer>
class Window : public QRasterWindow
{
Q_OBJECT
public:
explicit Window();
~Window() override;
protected:
void paintEvent(QPaintEvent *event) override;
};
Window::Window()
: QRasterWindow()
{
}
Window::~Window() = default;
void Window::paintEvent(QPaintEvent *event)
{
QPainter p(this);
p.fillRect(0, 0, width(), height(), Qt::blue);
}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QObject::connect(app.clipboard(), &QClipboard::changed, &app,
[] {
if (qApp->clipboard()->text() == QLatin1String("test")) {
QTimer::singleShot(100, qApp, &QCoreApplication::quit);
}
});
std::unique_ptr<Window> w(new Window);
w->setGeometry(QRect(0, 0, 100, 200));
w->show();
return app.exec();
}
#include "paste.moc"

View File

@ -0,0 +1,302 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/outputbackend.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_idle_inhbition_test-0");
class TestIdleInhibition : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testInhibit();
void testDontInhibitWhenNotOnCurrentDesktop();
void testDontInhibitWhenMinimized();
void testDontInhibitWhenUnmapped();
void testDontInhibitWhenLeftCurrentDesktop();
};
void TestIdleInhibition::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void TestIdleInhibition::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibitV1));
}
void TestIdleInhibition::cleanup()
{
Test::destroyWaylandConnection();
VirtualDesktopManager::self()->setCount(1);
QCOMPARE(VirtualDesktopManager::self()->count(), 1u);
}
void TestIdleInhibition::testInhibit()
{
// no idle inhibitors at the start
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
// now create window
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
// now create inhibition on window
std::unique_ptr<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.get()));
QVERIFY(inhibitor);
// render the window
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// this should inhibit our server object
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// deleting the object should uninhibit again
inhibitor.reset();
Test::flushWaylandConnection(); // don't use QTRY_COMPARE(), it doesn't spin event loop
QGuiApplication::processEvents();
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
// inhibit again and destroy window
std::unique_ptr<Test::IdleInhibitorV1> inhibitor2(Test::createIdleInhibitorV1(surface.get()));
Test::flushWaylandConnection();
QGuiApplication::processEvents();
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
}
void TestIdleInhibition::testDontInhibitWhenNotOnCurrentDesktop()
{
// This test verifies that the idle inhibitor object is not honored when
// the associated surface is not on the current virtual desktop.
VirtualDesktopManager::self()->setCount(2);
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
// Create the inhibitor object.
std::unique_ptr<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.get()));
QVERIFY(inhibitor);
// Render the window.
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// The test window should be only on the first virtual desktop.
QCOMPARE(window->desktops().count(), 1);
QCOMPARE(window->desktops().first(), VirtualDesktopManager::self()->desktops().first());
// This should inhibit our server object.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Switch to the second virtual desktop.
VirtualDesktopManager::self()->setCurrent(2);
// The surface is no longer visible, so the compositor don't have to honor the
// idle inhibitor object.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
// Switch back to the first virtual desktop.
VirtualDesktopManager::self()->setCurrent(1);
// The test window became visible again, so the compositor has to honor the idle
// inhibitor object back again.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
}
void TestIdleInhibition::testDontInhibitWhenMinimized()
{
// This test verifies that the idle inhibitor object is not honored when the
// associated surface is minimized.
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
// Create the inhibitor object.
std::unique_ptr<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.get()));
QVERIFY(inhibitor);
// Render the window.
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// This should inhibit our server object.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Minimize the window, the idle inhibitor object should not be honored.
window->minimize();
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
// Unminimize the window, the idle inhibitor object should be honored back again.
window->unminimize();
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
}
void TestIdleInhibition::testDontInhibitWhenUnmapped()
{
// This test verifies that the idle inhibitor object is not honored by KWin
// when the associated window is unmapped.
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
// Create the inhibitor object.
std::unique_ptr<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.get()));
QVERIFY(inhibitor);
// Map the window.
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
Test::render(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(windowAddedSpy.isEmpty());
QVERIFY(windowAddedSpy.wait());
QCOMPARE(windowAddedSpy.count(), 1);
Window *window = windowAddedSpy.last().first().value<Window *>();
QVERIFY(window);
QCOMPARE(window->readyForPainting(), true);
// The compositor will respond with a configure event when the surface becomes active.
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
// This should inhibit our server object.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Unmap the window.
surface->attachBuffer(KWayland::Client::Buffer::Ptr());
surface->commit(KWayland::Client::Surface::CommitFlag::None);
QVERIFY(Test::waitForWindowDestroyed(window));
// The surface is no longer visible, so the compositor doesn't have to honor the
// idle inhibitor object.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
// Tell the compositor that we want to map the surface.
surface->commit(KWayland::Client::Surface::CommitFlag::None);
// The compositor will respond with a configure event.
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
// Map the window.
Test::render(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(windowAddedSpy.wait());
QCOMPARE(windowAddedSpy.count(), 2);
window = windowAddedSpy.last().first().value<Window *>();
QVERIFY(window);
QCOMPARE(window->readyForPainting(), true);
// The test window became visible again, so the compositor has to honor the idle
// inhibitor object back again.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
}
void TestIdleInhibition::testDontInhibitWhenLeftCurrentDesktop()
{
// This test verifies that the idle inhibitor object is not honored by KWin
// when the associated surface leaves the current virtual desktop.
VirtualDesktopManager::self()->setCount(2);
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
// Create the test window.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
QVERIFY(surface != nullptr);
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
QVERIFY(shellSurface != nullptr);
// Create the inhibitor object.
std::unique_ptr<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.get()));
QVERIFY(inhibitor);
// Render the window.
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
// The test window should be only on the first virtual desktop.
QCOMPARE(window->desktops().count(), 1);
QCOMPARE(window->desktops().first(), VirtualDesktopManager::self()->desktops().first());
// This should inhibit our server object.
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Let the window enter the second virtual desktop.
window->enterDesktop(VirtualDesktopManager::self()->desktops().at(1));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// If the window leaves the first virtual desktop, then the associated idle
// inhibitor object should not be honored.
window->leaveDesktop(VirtualDesktopManager::self()->desktops().at(0));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
// If the window enters the first desktop, then the associated idle inhibitor
// object should be honored back again.
window->enterDesktop(VirtualDesktopManager::self()->desktops().at(0));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{window});
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
QCOMPARE(input()->idleInhibitors(), QList<Window *>{});
}
WAYLANDTEST_MAIN(TestIdleInhibition)
#include "idle_inhibition_test.moc"

View File

@ -0,0 +1,158 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "wayland/seat_interface.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <kwineffects.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/event_queue.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_input_stacking_order-0");
class InputStackingOrderTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testPointerFocusUpdatesOnStackingOrderChange();
private:
void render(KWayland::Client::Surface *surface);
};
void InputStackingOrderTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
}
void InputStackingOrderTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
QVERIFY(Test::waitForWaylandPointer());
workspace()->setActiveOutput(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void InputStackingOrderTest::cleanup()
{
Test::destroyWaylandConnection();
}
void InputStackingOrderTest::render(KWayland::Client::Surface *surface)
{
Test::render(surface, QSize(100, 50), Qt::blue);
Test::flushWaylandConnection();
}
void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange()
{
// this test creates two windows which overlap
// the pointer is in the overlapping area which means the top most window has focus
// as soon as the top most window gets lowered the window should lose focus and the
// other window should gain focus without a mouse event in between
// create pointer and signal spy for enter and leave signals
auto pointer = Test::waylandSeat()->createPointer(Test::waylandSeat());
QVERIFY(pointer);
QVERIFY(pointer->isValid());
QSignalSpy enteredSpy(pointer, &KWayland::Client::Pointer::entered);
QSignalSpy leftSpy(pointer, &KWayland::Client::Pointer::left);
// now create the two windows and make them overlap
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
std::unique_ptr<KWayland::Client::Surface> surface1 = Test::createSurface();
QVERIFY(surface1);
Test::XdgToplevel *shellSurface1 = Test::createXdgToplevelSurface(surface1.get(), surface1.get());
QVERIFY(shellSurface1);
render(surface1.get());
QVERIFY(windowAddedSpy.wait());
Window *window1 = workspace()->activeWindow();
QVERIFY(window1);
std::unique_ptr<KWayland::Client::Surface> surface2 = Test::createSurface();
QVERIFY(surface2);
Test::XdgToplevel *shellSurface2 = Test::createXdgToplevelSurface(surface2.get(), surface2.get());
QVERIFY(shellSurface2);
render(surface2.get());
QVERIFY(windowAddedSpy.wait());
Window *window2 = workspace()->activeWindow();
QVERIFY(window2);
QVERIFY(window1 != window2);
// now make windows overlap
window2->move(window1->pos());
QCOMPARE(window1->frameGeometry(), window2->frameGeometry());
// enter
Test::pointerMotion(QPointF(25, 25), 1);
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 1);
// window 2 should have focus
QCOMPARE(pointer->enteredSurface(), surface2.get());
// also on the server
QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window2->surface());
// raise window 1 above window 2
QVERIFY(leftSpy.isEmpty());
workspace()->raiseWindow(window1);
// should send leave to window2
QVERIFY(leftSpy.wait());
QCOMPARE(leftSpy.count(), 1);
// and an enter to window1
QCOMPARE(enteredSpy.count(), 2);
QCOMPARE(pointer->enteredSurface(), surface1.get());
QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window1->surface());
// let's destroy window1, that should pass focus to window2 again
QSignalSpy windowClosedSpy(window1, &Window::windowClosed);
surface1.reset();
QVERIFY(windowClosedSpy.wait());
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 3);
QCOMPARE(pointer->enteredSurface(), surface2.get());
QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window2->surface());
}
}
WAYLANDTEST_MAIN(KWin::InputStackingOrderTest)
#include "input_stacking_order.moc"

View File

@ -0,0 +1,692 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "effects.h"
#include "inputmethod.h"
#include "keyboard_input.h"
#include "qwayland-input-method-unstable-v1.h"
#include "qwayland-text-input-unstable-v3.h"
#include "virtualkeyboard_dbus.h"
#include "wayland/clientconnection.h"
#include "wayland/display.h"
#include "wayland/seat_interface.h"
#include "wayland/surface_interface.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "xkb.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingReply>
#include <QSignalSpy>
#include <QTest>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/output.h>
#include <KWayland/Client/region.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/textinput.h>
#include <linux/input-event-codes.h>
using namespace KWin;
using KWin::VirtualKeyboardDBus;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_inputmethod-0");
class InputMethodTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testOpenClose();
void testEnableDisableV3();
void testEnableActive();
void testHidePanel();
void testSwitchFocusedSurfaces();
void testV2V3SameClient();
void testV3Styling();
void testDisableShowInputPanel();
void testModifierForwarding();
void testFakeEventFallback();
private:
void touchNow()
{
static int time = 0;
Test::touchDown(0, {100, 100}, ++time);
Test::touchUp(0, ++time);
}
};
void InputMethodTest::initTestCase()
{
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.testvirtualkeyboard"));
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWayland::Client::Output *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
static_cast<WaylandTestApplication *>(kwinApp())->setInputMethodServerToStart("internal");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
}
void InputMethodTest::init()
{
touchNow();
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::TextInputManagerV2 | Test::AdditionalWaylandInterface::InputMethodV1 | Test::AdditionalWaylandInterface::TextInputManagerV3));
workspace()->setActiveOutput(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
kwinApp()->inputMethod()->setEnabled(true);
}
void InputMethodTest::cleanup()
{
Test::destroyWaylandConnection();
}
void InputMethodTest::testOpenClose()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged);
QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested);
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
QVERIFY(surfaceConfigureRequestedSpy.wait());
std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
QVERIFY(textInput != nullptr);
// Show the keyboard
touchNow();
textInput->enable(surface.get());
textInput->showInputPanel();
QSignalSpy paneladded(kwinApp()->inputMethod(), &KWin::InputMethod::panelChanged);
QVERIFY(windowAddedSpy.wait());
QCOMPARE(paneladded.count(), 1);
Window *keyboardClient = windowAddedSpy.last().first().value<Window *>();
QVERIFY(keyboardClient);
QVERIFY(keyboardClient->isInputMethod());
// Do the actual resize
QVERIFY(surfaceConfigureRequestedSpy.wait());
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().first().value<QSize>(), Qt::red);
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(window->frameGeometry().height(), 1024 - keyboardClient->inputGeometry().height());
// Hide the keyboard
textInput->hideInputPanel();
QVERIFY(surfaceConfigureRequestedSpy.wait());
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().first().value<QSize>(), Qt::red);
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(window->frameGeometry().height(), 1024);
// show the keyboard again
touchNow();
textInput->enable(surface.get());
textInput->showInputPanel();
QVERIFY(surfaceConfigureRequestedSpy.wait());
QVERIFY(keyboardClient->isShown());
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
void InputMethodTest::testEnableDisableV3()
{
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
auto textInputV3 = std::make_unique<Test::TextInputV3>();
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
// Show the keyboard
touchNow();
textInputV3->enable();
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
// just enabling the text-input should not show it but rather on commit
QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
QVERIFY(windowAddedSpy.wait());
Window *keyboardClient = windowAddedSpy.last().first().value<Window *>();
QVERIFY(keyboardClient);
QVERIFY(keyboardClient->isInputMethod());
QVERIFY(keyboardClient->isShown());
// Text input v3 doesn't have hideInputPanel, just simiulate the hide from dbus call
kwinApp()->inputMethod()->hide();
QVERIFY(!keyboardClient->isShown());
QSignalSpy windowShownSpy(keyboardClient, &Window::windowShown);
// Force enable the text input object. This is what's done by Gtk.
textInputV3->enable();
textInputV3->commit();
windowShownSpy.wait();
QVERIFY(keyboardClient->isShown());
// disable text input and ensure that it is not hiding input panel without commit
inputMethodActiveSpy.clear();
QVERIFY(kwinApp()->inputMethod()->isActive());
textInputV3->disable();
textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
}
void InputMethodTest::testEnableActive()
{
// This test verifies that enabling text-input twice won't change the active input method status.
QVERIFY(!kwinApp()->inputMethod()->isActive());
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
// Show the keyboard
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
textInput->enable(surface.get());
QSignalSpy paneladded(kwinApp()->inputMethod(), &KWin::InputMethod::panelChanged);
QVERIFY(paneladded.wait());
textInput->showInputPanel();
QVERIFY(windowAddedSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
// Ask the keyboard to be shown again.
QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
textInput->enable(surface.get());
textInput->showInputPanel();
activateSpy.wait(200);
QVERIFY(activateSpy.isEmpty());
QVERIFY(kwinApp()->inputMethod()->isActive());
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
void InputMethodTest::testHidePanel()
{
QVERIFY(!kwinApp()->inputMethod()->isActive());
touchNow();
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
waylandServer()->seat()->setFocusedTextInputSurface(window->surface());
textInput->enable(surface.get());
QSignalSpy paneladded(kwinApp()->inputMethod(), &KWin::InputMethod::panelChanged);
QVERIFY(paneladded.wait());
textInput->showInputPanel();
QVERIFY(windowAddedSpy.wait());
QCOMPARE(workspace()->activeWindow(), window);
QCOMPARE(windowAddedSpy.count(), 2);
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
auto keyboardWindow = kwinApp()->inputMethod()->panel();
auto ipsurface = Test::inputPanelSurface();
QVERIFY(keyboardWindow);
windowRemovedSpy.clear();
delete ipsurface;
QVERIFY(kwinApp()->inputMethod()->isVisible());
QVERIFY(windowRemovedSpy.count() || windowRemovedSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isVisible());
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
void InputMethodTest::testSwitchFocusedSurfaces()
{
touchNow();
QVERIFY(!kwinApp()->inputMethod()->isActive());
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
QVector<Window *> windows;
std::vector<std::unique_ptr<KWayland::Client::Surface>> surfaces;
QVector<Test::XdgToplevel *> toplevels;
// We create 3 surfaces
for (int i = 0; i < 3; ++i) {
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
auto shellSurface = Test::createXdgToplevelSurface(surface.get());
windows += Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QCOMPARE(workspace()->activeWindow(), windows.constLast());
surfaces.push_back(std::move(surface));
toplevels += shellSurface;
}
QCOMPARE(windowAddedSpy.count(), 3);
waylandServer()->seat()->setFocusedTextInputSurface(windows.constFirst()->surface());
QVERIFY(!kwinApp()->inputMethod()->isActive());
textInput->enable(surfaces.back().get());
QVERIFY(!kwinApp()->inputMethod()->isActive());
waylandServer()->seat()->setFocusedTextInputSurface(windows.first()->surface());
QVERIFY(!kwinApp()->inputMethod()->isActive());
activateSpy.clear();
waylandServer()->seat()->setFocusedTextInputSurface(windows.last()->surface());
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
activateSpy.clear();
waylandServer()->seat()->setFocusedTextInputSurface(windows.first()->surface());
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
// Destroy the test window.
for (int i = 0; i < windows.count(); ++i) {
delete toplevels[i];
QVERIFY(Test::waitForWindowDestroyed(windows[i]));
}
}
void InputMethodTest::testV2V3SameClient()
{
touchNow();
QVERIFY(!kwinApp()->inputMethod()->isActive());
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy windowRemovedSpy(workspace(), &Workspace::windowRemoved);
QSignalSpy activateSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
std::unique_ptr<KWayland::Client::TextInput> textInput(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
auto textInputV3 = std::make_unique<Test::TextInputV3>();
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
std::unique_ptr<Test::XdgToplevel> toplevel(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QCOMPARE(workspace()->activeWindow(), window);
QCOMPARE(windowAddedSpy.count(), 1);
waylandServer()->seat()->setFocusedTextInputSurface(window->surface());
QVERIFY(!kwinApp()->inputMethod()->isActive());
// Enable and disable v2
textInput->enable(surface.get());
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
activateSpy.clear();
textInput->disable(surface.get());
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
// Enable and disable v3
activateSpy.clear();
textInputV3->enable();
textInputV3->commit();
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
activateSpy.clear();
textInputV3->disable();
textInputV3->commit();
activateSpy.clear();
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
// Enable v2 and v3
activateSpy.clear();
textInputV3->enable();
textInputV3->commit();
textInput->enable(surface.get());
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
// Disable v3, should still be active since v2 is active.
activateSpy.clear();
textInputV3->disable();
textInputV3->commit();
activateSpy.wait(200);
QVERIFY(kwinApp()->inputMethod()->isActive());
// Disable v2
activateSpy.clear();
textInput->disable(surface.get());
QVERIFY(activateSpy.count() || activateSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
toplevel.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
void InputMethodTest::testV3Styling()
{
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
auto textInputV3 = std::make_unique<Test::TextInputV3>();
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
textInputV3->enable();
QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
QSignalSpy inputMethodActivateSpy(Test::inputMethod(), &Test::MockInputMethod::activate);
// just enabling the text-input should not show it but rather on commit
QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
QVERIFY(inputMethodActivateSpy.wait());
auto context = Test::inputMethod()->context();
QSignalSpy textInputPreeditSpy(textInputV3.get(), &Test::TextInputV3::preeditString);
zwp_input_method_context_v1_preedit_cursor(context, 0);
zwp_input_method_context_v1_preedit_styling(context, 0, 3, 7);
zwp_input_method_context_v1_preedit_string(context, 0, "ABCD", "ABCD");
QVERIFY(textInputPreeditSpy.wait());
QCOMPARE(textInputPreeditSpy.last().at(0), QString("ABCD"));
QCOMPARE(textInputPreeditSpy.last().at(1), 0);
QCOMPARE(textInputPreeditSpy.last().at(2), 0);
zwp_input_method_context_v1_preedit_cursor(context, 1);
zwp_input_method_context_v1_preedit_styling(context, 0, 3, 7);
zwp_input_method_context_v1_preedit_string(context, 0, "ABCDE", "ABCDE");
QVERIFY(textInputPreeditSpy.wait());
QCOMPARE(textInputPreeditSpy.last().at(0), QString("ABCDE"));
QCOMPARE(textInputPreeditSpy.last().at(1), 1);
QCOMPARE(textInputPreeditSpy.last().at(2), 1);
zwp_input_method_context_v1_preedit_cursor(context, 2);
// Use selection for [2, 2+2)
zwp_input_method_context_v1_preedit_styling(context, 2, 2, 6);
// Use high light for [3, 3+3)
zwp_input_method_context_v1_preedit_styling(context, 3, 3, 4);
zwp_input_method_context_v1_preedit_string(context, 0, "ABCDEF", "ABCDEF");
QVERIFY(textInputPreeditSpy.wait());
QCOMPARE(textInputPreeditSpy.last().at(0), QString("ABCDEF"));
// Merged range should be [2, 6)
QCOMPARE(textInputPreeditSpy.last().at(1), 2);
QCOMPARE(textInputPreeditSpy.last().at(2), 6);
zwp_input_method_context_v1_preedit_cursor(context, 2);
// Use selection for [0, 0+2)
zwp_input_method_context_v1_preedit_styling(context, 0, 2, 6);
// Use high light for [3, 3+3)
zwp_input_method_context_v1_preedit_styling(context, 3, 3, 4);
zwp_input_method_context_v1_preedit_string(context, 0, "ABCDEF", "ABCDEF");
QVERIFY(textInputPreeditSpy.wait());
QCOMPARE(textInputPreeditSpy.last().at(0), QString("ABCDEF"));
// Merged range should be none, because of the disjunction highlight.
QCOMPARE(textInputPreeditSpy.last().at(1), 2);
QCOMPARE(textInputPreeditSpy.last().at(2), 2);
zwp_input_method_context_v1_preedit_cursor(context, 1);
// Use selection for [0, 0+2)
zwp_input_method_context_v1_preedit_styling(context, 0, 2, 6);
// Use high light for [2, 2+3)
zwp_input_method_context_v1_preedit_styling(context, 2, 3, 4);
zwp_input_method_context_v1_preedit_string(context, 0, "ABCDEF", "ABCDEF");
QVERIFY(textInputPreeditSpy.wait());
QCOMPARE(textInputPreeditSpy.last().at(0), QString("ABCDEF"));
// Merged range should be none, starting offset does not match.
QCOMPARE(textInputPreeditSpy.last().at(1), 1);
QCOMPARE(textInputPreeditSpy.last().at(2), 1);
// Use different order of styling and cursor
// Use high light for [3, 3+3)
zwp_input_method_context_v1_preedit_styling(context, 3, 3, 4);
zwp_input_method_context_v1_preedit_cursor(context, 1);
// Use selection for [1, 1+2)
zwp_input_method_context_v1_preedit_styling(context, 1, 2, 6);
zwp_input_method_context_v1_preedit_string(context, 0, "ABCDEF", "ABCDEF");
QVERIFY(textInputPreeditSpy.wait());
QCOMPARE(textInputPreeditSpy.last().at(0), QString("ABCDEF"));
// Merged range should be [1,6).
QCOMPARE(textInputPreeditSpy.last().at(1), 1);
QCOMPARE(textInputPreeditSpy.last().at(2), 6);
}
void InputMethodTest::testDisableShowInputPanel()
{
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
std::unique_ptr<KWayland::Client::TextInput> textInputV2(Test::waylandTextInputManager()->createTextInput(Test::waylandSeat()));
QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
// just enabling the text-input should not show it but rather on commit
QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV2->enable(surface.get());
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
// disable text input and ensure that it is not hiding input panel without commit
inputMethodActiveSpy.clear();
QVERIFY(kwinApp()->inputMethod()->isActive());
textInputV2->disable(surface.get());
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
QSignalSpy requestShowInputPanelSpy(waylandServer()->seat()->textInputV2(), &KWaylandServer::TextInputV2Interface::requestShowInputPanel);
textInputV2->showInputPanel();
QVERIFY(requestShowInputPanelSpy.count() || requestShowInputPanelSpy.wait());
QVERIFY(!kwinApp()->inputMethod()->isActive());
}
void InputMethodTest::testModifierForwarding()
{
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
auto textInputV3 = std::make_unique<Test::TextInputV3>();
textInputV3->init(Test::waylandTextInputManagerV3()->get_text_input(*(Test::waylandSeat())));
textInputV3->enable();
QSignalSpy inputMethodActiveSpy(kwinApp()->inputMethod(), &InputMethod::activeChanged);
QSignalSpy inputMethodActivateSpy(Test::inputMethod(), &Test::MockInputMethod::activate);
// just enabling the text-input should not show it but rather on commit
QVERIFY(!kwinApp()->inputMethod()->isActive());
textInputV3->commit();
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
QVERIFY(kwinApp()->inputMethod()->isActive());
QVERIFY(inputMethodActivateSpy.wait());
auto context = Test::inputMethod()->context();
std::unique_ptr<KWayland::Client::Keyboard> keyboardGrab(new KWayland::Client::Keyboard);
keyboardGrab->setup(zwp_input_method_context_v1_grab_keyboard(context));
QSignalSpy modifierSpy(keyboardGrab.get(), &KWayland::Client::Keyboard::modifiersChanged);
// Wait for initial modifiers update
QVERIFY(modifierSpy.wait());
quint32 timestamp = 1;
QSignalSpy keySpy(keyboardGrab.get(), &KWayland::Client::Keyboard::keyChanged);
bool keyChanged = false;
bool modifiersChanged = false;
// We want to verify the order of two signals, so SignalSpy is not very useful here.
auto keyChangedConnection = connect(keyboardGrab.get(), &KWayland::Client::Keyboard::keyChanged, [&keyChanged, &modifiersChanged]() {
QVERIFY(!modifiersChanged);
keyChanged = true;
});
auto modifiersChangedConnection = connect(keyboardGrab.get(), &KWayland::Client::Keyboard::modifiersChanged, [&keyChanged, &modifiersChanged]() {
QVERIFY(keyChanged);
modifiersChanged = true;
});
Test::keyboardKeyPressed(KEY_LEFTCTRL, timestamp++);
QVERIFY(keySpy.count() == 1 || keySpy.wait());
QVERIFY(modifierSpy.count() == 2 || modifierSpy.wait());
disconnect(keyChangedConnection);
disconnect(modifiersChangedConnection);
Test::keyboardKeyPressed(KEY_A, timestamp++);
QVERIFY(keySpy.count() == 2 || keySpy.wait());
QVERIFY(modifierSpy.count() == 2 || modifierSpy.wait());
// verify the order of key and modifiers again. Key first, then modifiers.
keyChanged = false;
modifiersChanged = false;
keyChangedConnection = connect(keyboardGrab.get(), &KWayland::Client::Keyboard::keyChanged, [&keyChanged, &modifiersChanged]() {
QVERIFY(!modifiersChanged);
keyChanged = true;
});
modifiersChangedConnection = connect(keyboardGrab.get(), &KWayland::Client::Keyboard::modifiersChanged, [&keyChanged, &modifiersChanged]() {
QVERIFY(keyChanged);
modifiersChanged = true;
});
Test::keyboardKeyReleased(KEY_LEFTCTRL, timestamp++);
QVERIFY(keySpy.count() == 3 || keySpy.wait());
QVERIFY(modifierSpy.count() == 3 || modifierSpy.wait());
disconnect(keyChangedConnection);
disconnect(modifiersChangedConnection);
}
void InputMethodTest::testFakeEventFallback()
{
// Create an xdg_toplevel surface and wait for the compositor to catch up.
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(1280, 1024), Qt::red);
QVERIFY(window);
QVERIFY(window->isActive());
QCOMPARE(window->frameGeometry().size(), QSize(1280, 1024));
// Since we don't have a way to communicate with the client, manually activate
// the input method.
QSignalSpy inputMethodActiveSpy(Test::inputMethod(), &Test::MockInputMethod::activate);
kwinApp()->inputMethod()->setActive(true);
QVERIFY(inputMethodActiveSpy.count() || inputMethodActiveSpy.wait());
// Without a way to communicate to the client, we send fake key events. This
// means the client needs to be able to receive them, so create a keyboard for
// the client and listen whether it gets the right events.
auto keyboard = Test::waylandSeat()->createKeyboard(window);
QSignalSpy keySpy(keyboard, &KWayland::Client::Keyboard::keyChanged);
auto context = Test::inputMethod()->context();
QVERIFY(context);
// First, send a simple one-character string and check to see if that
// generates a key press followed by a key release on the client side.
zwp_input_method_context_v1_commit_string(context, 0, "a");
keySpy.wait();
QVERIFY(keySpy.count() == 2);
auto compare = [](const QList<QVariant> &input, quint32 key, KWayland::Client::Keyboard::KeyState state) {
auto inputKey = input.at(0).toInt();
auto inputState = input.at(1).value<KWayland::Client::Keyboard::KeyState>();
QCOMPARE(inputKey, key);
QCOMPARE(inputState, state);
};
compare(keySpy.at(0), KEY_A, KWayland::Client::Keyboard::KeyState::Pressed);
compare(keySpy.at(1), KEY_A, KWayland::Client::Keyboard::KeyState::Released);
keySpy.clear();
// Capital letters are recognised and sent as a combination of Shift + the
// letter.
zwp_input_method_context_v1_commit_string(context, 0, "A");
keySpy.wait();
QVERIFY(keySpy.count() == 4);
compare(keySpy.at(0), KEY_LEFTSHIFT, KWayland::Client::Keyboard::KeyState::Pressed);
compare(keySpy.at(1), KEY_A, KWayland::Client::Keyboard::KeyState::Pressed);
compare(keySpy.at(2), KEY_A, KWayland::Client::Keyboard::KeyState::Released);
compare(keySpy.at(3), KEY_LEFTSHIFT, KWayland::Client::Keyboard::KeyState::Released);
keySpy.clear();
// Special keys are not sent through commit_string but instead use keysym.
auto enter = input()->keyboard()->xkb()->toKeysym(KEY_ENTER);
zwp_input_method_context_v1_keysym(context, 0, 0, enter, uint32_t(KWaylandServer::KeyboardKeyState::Pressed), 0);
zwp_input_method_context_v1_keysym(context, 0, 1, enter, uint32_t(KWaylandServer::KeyboardKeyState::Released), 0);
keySpy.wait();
QVERIFY(keySpy.count() == 2);
compare(keySpy.at(0), KEY_ENTER, KWayland::Client::Keyboard::KeyState::Pressed);
compare(keySpy.at(1), KEY_ENTER, KWayland::Client::Keyboard::KeyState::Released);
}
WAYLANDTEST_MAIN(InputMethodTest)
#include "inputmethod_test.moc"

View File

@ -0,0 +1,816 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "core/outputbackend.h"
#include "cursor.h"
#include "deleted.h"
#include "effects.h"
#include "internalwindow.h"
#include "wayland/surface_interface.h"
#include "wayland_server.h"
#include "workspace.h"
#include <QPainter>
#include <QRasterWindow>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/surface.h>
#include <KWindowSystem>
#include <linux/input.h>
Q_DECLARE_METATYPE(NET::WindowType);
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_internal_window-0");
class InternalWindowTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testEnterLeave();
void testPointerPressRelease();
void testPointerAxis();
void testKeyboard_data();
void testKeyboard();
void testKeyboardShowWithoutActivating();
void testKeyboardTriggersLeave();
void testTouch();
void testOpacity();
void testMove();
void testSkipCloseAnimation_data();
void testSkipCloseAnimation();
void testModifierClickUnrestrictedMove();
void testModifierScroll();
void testPopup();
void testScale();
void testWindowType_data();
void testWindowType();
void testChangeWindowType_data();
void testChangeWindowType();
void testEffectWindow();
void testReentrantMoveResize();
void testDismissPopup();
};
class HelperWindow : public QRasterWindow
{
Q_OBJECT
public:
HelperWindow();
~HelperWindow() override;
QPoint latestGlobalMousePos() const
{
return m_latestGlobalMousePos;
}
Qt::MouseButtons pressedButtons() const
{
return m_pressedButtons;
}
Q_SIGNALS:
void entered();
void left();
void mouseMoved(const QPoint &global);
void mousePressed();
void mouseReleased();
void wheel();
void keyPressed();
void keyReleased();
protected:
void paintEvent(QPaintEvent *event) override;
bool event(QEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
private:
QPoint m_latestGlobalMousePos;
Qt::MouseButtons m_pressedButtons = Qt::MouseButtons();
};
HelperWindow::HelperWindow()
: QRasterWindow(nullptr)
{
setFlags(Qt::FramelessWindowHint);
}
HelperWindow::~HelperWindow() = default;
void HelperWindow::paintEvent(QPaintEvent *event)
{
QPainter p(this);
p.fillRect(0, 0, width(), height(), Qt::red);
}
bool HelperWindow::event(QEvent *event)
{
if (event->type() == QEvent::Enter) {
Q_EMIT entered();
}
if (event->type() == QEvent::Leave) {
Q_EMIT left();
}
return QRasterWindow::event(event);
}
void HelperWindow::mouseMoveEvent(QMouseEvent *event)
{
m_latestGlobalMousePos = event->globalPos();
Q_EMIT mouseMoved(event->globalPos());
}
void HelperWindow::mousePressEvent(QMouseEvent *event)
{
m_latestGlobalMousePos = event->globalPos();
m_pressedButtons = event->buttons();
Q_EMIT mousePressed();
}
void HelperWindow::mouseReleaseEvent(QMouseEvent *event)
{
m_latestGlobalMousePos = event->globalPos();
m_pressedButtons = event->buttons();
Q_EMIT mouseReleased();
}
void HelperWindow::wheelEvent(QWheelEvent *event)
{
Q_EMIT wheel();
}
void HelperWindow::keyPressEvent(QKeyEvent *event)
{
Q_EMIT keyPressed();
}
void HelperWindow::keyReleaseEvent(QKeyEvent *event)
{
Q_EMIT keyReleased();
}
void InternalWindowTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted *>();
qRegisterMetaType<KWin::InternalWindow *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(QVector<QRect>, QVector<QRect>() << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024)));
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
const auto outputs = workspace()->outputs();
QCOMPARE(outputs.count(), 2);
QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024));
}
void InternalWindowTest::init()
{
Cursors::self()->mouse()->setPos(QPoint(512, 512));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
QVERIFY(Test::waitForWaylandKeyboard());
}
void InternalWindowTest::cleanup()
{
Test::destroyWaylandConnection();
}
void InternalWindowTest::testEnterLeave()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
QVERIFY(!workspace()->findInternal(nullptr));
QVERIFY(!workspace()->findInternal(&win));
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
QVERIFY(!workspace()->activeWindow());
InternalWindow *window = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(window);
QVERIFY(window->isInternal());
QVERIFY(!window->isDecorated());
QCOMPARE(workspace()->findInternal(&win), window);
QCOMPARE(window->frameGeometry(), QRect(0, 0, 100, 100));
QVERIFY(window->isShown());
QVERIFY(workspace()->stackingOrder().contains(window));
QSignalSpy enterSpy(&win, &HelperWindow::entered);
QSignalSpy leaveSpy(&win, &HelperWindow::left);
QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved);
quint32 timestamp = 1;
Test::pointerMotion(QPoint(50, 50), timestamp++);
QTRY_COMPARE(moveSpy.count(), 1);
Test::pointerMotion(QPoint(60, 50), timestamp++);
QTRY_COMPARE(moveSpy.count(), 2);
QCOMPARE(moveSpy[1].first().toPoint(), QPoint(60, 50));
Test::pointerMotion(QPoint(101, 50), timestamp++);
QTRY_COMPARE(leaveSpy.count(), 1);
// set a mask on the window
win.setMask(QRegion(10, 20, 30, 40));
// outside the mask we should not get an enter
Test::pointerMotion(QPoint(5, 5), timestamp++);
QVERIFY(!enterSpy.wait(100));
QCOMPARE(enterSpy.count(), 1);
// inside the mask we should still get an enter
Test::pointerMotion(QPoint(25, 27), timestamp++);
QTRY_COMPARE(enterSpy.count(), 2);
}
void InternalWindowTest::testPointerPressRelease()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QSignalSpy pressSpy(&win, &HelperWindow::mousePressed);
QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased);
QTRY_COMPARE(windowAddedSpy.count(), 1);
quint32 timestamp = 1;
Test::pointerMotion(QPoint(50, 50), timestamp++);
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
QTRY_COMPARE(pressSpy.count(), 1);
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
QTRY_COMPARE(releaseSpy.count(), 1);
}
void InternalWindowTest::testPointerAxis()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QSignalSpy wheelSpy(&win, &HelperWindow::wheel);
QTRY_COMPARE(windowAddedSpy.count(), 1);
quint32 timestamp = 1;
Test::pointerMotion(QPoint(50, 50), timestamp++);
Test::pointerAxisVertical(5.0, timestamp++);
QTRY_COMPARE(wheelSpy.count(), 1);
Test::pointerAxisHorizontal(5.0, timestamp++);
QTRY_COMPARE(wheelSpy.count(), 2);
}
void InternalWindowTest::testKeyboard_data()
{
QTest::addColumn<QPoint>("cursorPos");
QTest::newRow("on Window") << QPoint(50, 50);
QTest::newRow("outside Window") << QPoint(250, 250);
}
void InternalWindowTest::testKeyboard()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->isInternal());
QVERIFY(internalWindow->readyForPainting());
quint32 timestamp = 1;
QFETCH(QPoint, cursorPos);
Test::pointerMotion(cursorPos, timestamp++);
Test::keyboardKeyPressed(KEY_A, timestamp++);
QTRY_COMPARE(pressSpy.count(), 1);
QCOMPARE(releaseSpy.count(), 0);
Test::keyboardKeyReleased(KEY_A, timestamp++);
QTRY_COMPARE(releaseSpy.count(), 1);
QCOMPARE(pressSpy.count(), 1);
}
void InternalWindowTest::testKeyboardShowWithoutActivating()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setProperty("_q_showWithoutActivating", true);
win.setGeometry(0, 0, 100, 100);
win.show();
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->isInternal());
QVERIFY(internalWindow->readyForPainting());
quint32 timestamp = 1;
const QPoint cursorPos = QPoint(50, 50);
Test::pointerMotion(cursorPos, timestamp++);
Test::keyboardKeyPressed(KEY_A, timestamp++);
QCOMPARE(pressSpy.count(), 0);
QVERIFY(!pressSpy.wait(100));
QCOMPARE(releaseSpy.count(), 0);
Test::keyboardKeyReleased(KEY_A, timestamp++);
QCOMPARE(releaseSpy.count(), 0);
QVERIFY(!releaseSpy.wait(100));
QCOMPARE(pressSpy.count(), 0);
}
void InternalWindowTest::testKeyboardTriggersLeave()
{
// this test verifies that a leave event is sent to a window when an internal window
// gets a key event
std::unique_ptr<KWayland::Client::Keyboard> keyboard(Test::waylandSeat()->createKeyboard());
QVERIFY(keyboard != nullptr);
QVERIFY(keyboard->isValid());
QSignalSpy enteredSpy(keyboard.get(), &KWayland::Client::Keyboard::entered);
QSignalSpy leftSpy(keyboard.get(), &KWayland::Client::Keyboard::left);
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
std::unique_ptr<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.get()));
// now let's render
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QVERIFY(window->isActive());
QVERIFY(!window->isInternal());
if (enteredSpy.isEmpty()) {
QVERIFY(enteredSpy.wait());
}
QCOMPARE(enteredSpy.count(), 1);
// create internal window
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QSignalSpy pressSpy(&win, &HelperWindow::keyPressed);
QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased);
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->isInternal());
QVERIFY(internalWindow->readyForPainting());
QVERIFY(leftSpy.isEmpty());
QVERIFY(!leftSpy.wait(100));
// now let's trigger a key, which should result in a leave
quint32 timestamp = 1;
Test::keyboardKeyPressed(KEY_A, timestamp++);
QVERIFY(leftSpy.wait());
QCOMPARE(pressSpy.count(), 1);
Test::keyboardKeyReleased(KEY_A, timestamp++);
QTRY_COMPARE(releaseSpy.count(), 1);
// after hiding the internal window, next key press should trigger an enter
win.hide();
Test::keyboardKeyPressed(KEY_A, timestamp++);
QVERIFY(enteredSpy.wait());
Test::keyboardKeyReleased(KEY_A, timestamp++);
// Destroy the test window.
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
}
void InternalWindowTest::testTouch()
{
// touch events for internal windows are emulated through mouse events
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
QSignalSpy pressSpy(&win, &HelperWindow::mousePressed);
QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased);
QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved);
quint32 timestamp = 1;
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
Test::touchDown(0, QPointF(50, 50), timestamp++);
QCOMPARE(pressSpy.count(), 1);
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
// further touch down should not trigger
Test::touchDown(1, QPointF(75, 75), timestamp++);
QCOMPARE(pressSpy.count(), 1);
Test::touchUp(1, timestamp++);
QCOMPARE(releaseSpy.count(), 0);
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
// another press
Test::touchDown(1, QPointF(10, 10), timestamp++);
QCOMPARE(pressSpy.count(), 1);
QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
// simulate the move
QCOMPARE(moveSpy.count(), 0);
Test::touchMotion(0, QPointF(80, 90), timestamp++);
QCOMPARE(moveSpy.count(), 1);
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
// move on other ID should not do anything
Test::touchMotion(1, QPointF(20, 30), timestamp++);
QCOMPARE(moveSpy.count(), 1);
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton));
// now up our main point
Test::touchUp(0, timestamp++);
QCOMPARE(releaseSpy.count(), 1);
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
// and up the additional point
Test::touchUp(1, timestamp++);
QCOMPARE(releaseSpy.count(), 1);
QCOMPARE(moveSpy.count(), 1);
QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90));
QCOMPARE(win.pressedButtons(), Qt::MouseButtons());
}
void InternalWindowTest::testOpacity()
{
// this test verifies that opacity is properly synced from QWindow to InternalClient
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setOpacity(0.5);
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->isInternal());
QCOMPARE(internalWindow->opacity(), 0.5);
QSignalSpy opacityChangedSpy(internalWindow, &InternalWindow::opacityChanged);
win.setOpacity(0.75);
QCOMPARE(opacityChangedSpy.count(), 1);
QCOMPARE(internalWindow->opacity(), 0.75);
}
void InternalWindowTest::testMove()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setOpacity(0.5);
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QCOMPARE(internalWindow->frameGeometry(), QRect(0, 0, 100, 100));
// normal move should be synced
internalWindow->move(QPoint(5, 10));
QCOMPARE(internalWindow->frameGeometry(), QRect(5, 10, 100, 100));
QTRY_COMPARE(win.geometry(), QRect(5, 10, 100, 100));
// another move should also be synced
internalWindow->move(QPoint(10, 20));
QCOMPARE(internalWindow->frameGeometry(), QRect(10, 20, 100, 100));
QTRY_COMPARE(win.geometry(), QRect(10, 20, 100, 100));
// now move with a Geometry update blocker
{
GeometryUpdatesBlocker blocker(internalWindow);
internalWindow->move(QPoint(5, 10));
// not synced!
QCOMPARE(win.geometry(), QRect(10, 20, 100, 100));
}
// after destroying the blocker it should be synced
QTRY_COMPARE(win.geometry(), QRect(5, 10, 100, 100));
}
void InternalWindowTest::testSkipCloseAnimation_data()
{
QTest::addColumn<bool>("initial");
QTest::newRow("set") << true;
QTest::newRow("not set") << false;
}
void InternalWindowTest::testSkipCloseAnimation()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setOpacity(0.5);
win.setGeometry(0, 0, 100, 100);
QFETCH(bool, initial);
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QCOMPARE(internalWindow->skipsCloseAnimation(), initial);
QSignalSpy skipCloseChangedSpy(internalWindow, &Window::skipCloseAnimationChanged);
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial);
QCOMPARE(skipCloseChangedSpy.count(), 1);
QCOMPARE(internalWindow->skipsCloseAnimation(), !initial);
win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial);
QCOMPARE(skipCloseChangedSpy.count(), 2);
QCOMPARE(internalWindow->skipsCloseAnimation(), initial);
}
void InternalWindowTest::testModifierClickUnrestrictedMove()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.setFlags(win.flags() & ~Qt::FramelessWindowHint);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->isDecorated());
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", "Meta");
group.writeEntry("CommandAll1", "Move");
group.writeEntry("CommandAll2", "Move");
group.writeEntry("CommandAll3", "Move");
group.sync();
workspace()->slotReconfigure();
QCOMPARE(options->commandAllModifier(), Qt::MetaModifier);
QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove);
QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove);
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
// move cursor on window
Cursors::self()->mouse()->setPos(internalWindow->frameGeometry().center());
// simulate modifier+click
quint32 timestamp = 1;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
QVERIFY(!internalWindow->isInteractiveMove());
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
QVERIFY(internalWindow->isInteractiveMove());
// release modifier should not change it
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
QVERIFY(internalWindow->isInteractiveMove());
// but releasing the key should end move/resize
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
QVERIFY(!internalWindow->isInteractiveMove());
}
void InternalWindowTest::testModifierScroll()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.setFlags(win.flags() & ~Qt::FramelessWindowHint);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->isDecorated());
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", "Meta");
group.writeEntry("CommandAllWheel", "change opacity");
group.sync();
workspace()->slotReconfigure();
// move cursor on window
Cursors::self()->mouse()->setPos(internalWindow->frameGeometry().center());
// set the opacity to 0.5
internalWindow->setOpacity(0.5);
QCOMPARE(internalWindow->opacity(), 0.5);
quint32 timestamp = 1;
Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++);
Test::pointerAxisVertical(-5, timestamp++);
QCOMPARE(internalWindow->opacity(), 0.6);
Test::pointerAxisVertical(5, timestamp++);
QCOMPARE(internalWindow->opacity(), 0.5);
Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++);
}
void InternalWindowTest::testPopup()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.setFlags(win.flags() | Qt::Popup);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QCOMPARE(internalWindow->isPopupWindow(), true);
}
void InternalWindowTest::testScale()
{
QMetaObject::invokeMethod(kwinApp()->outputBackend(), "setVirtualOutputs", Qt::DirectConnection,
Q_ARG(QVector<QRect>, QVector<QRect>({QRect(0, 0, 1280, 1024), QRect(1280 / 2, 0, 1280, 1024)})),
Q_ARG(QVector<qreal>, QVector<qreal>({2, 2})));
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.setFlags(win.flags() | Qt::Popup);
win.show();
QCOMPARE(win.devicePixelRatio(), 2.0);
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QCOMPARE(internalWindow->bufferScale(), 2);
}
void InternalWindowTest::testWindowType_data()
{
QTest::addColumn<NET::WindowType>("windowType");
QTest::newRow("normal") << NET::Normal;
QTest::newRow("desktop") << NET::Desktop;
QTest::newRow("Dock") << NET::Dock;
QTest::newRow("Toolbar") << NET::Toolbar;
QTest::newRow("Menu") << NET::Menu;
QTest::newRow("Dialog") << NET::Dialog;
QTest::newRow("Utility") << NET::Utility;
QTest::newRow("Splash") << NET::Splash;
QTest::newRow("DropdownMenu") << NET::DropdownMenu;
QTest::newRow("PopupMenu") << NET::PopupMenu;
QTest::newRow("Tooltip") << NET::Tooltip;
QTest::newRow("Notification") << NET::Notification;
QTest::newRow("ComboBox") << NET::ComboBox;
QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay;
QTest::newRow("CriticalNotification") << NET::CriticalNotification;
QTest::newRow("AppletPopup") << NET::AppletPopup;
}
void InternalWindowTest::testWindowType()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
QFETCH(NET::WindowType, windowType);
KWindowSystem::setType(win.winId(), windowType);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QCOMPARE(internalWindow->windowType(), windowType);
}
void InternalWindowTest::testChangeWindowType_data()
{
QTest::addColumn<NET::WindowType>("windowType");
QTest::newRow("desktop") << NET::Desktop;
QTest::newRow("Dock") << NET::Dock;
QTest::newRow("Toolbar") << NET::Toolbar;
QTest::newRow("Menu") << NET::Menu;
QTest::newRow("Dialog") << NET::Dialog;
QTest::newRow("Utility") << NET::Utility;
QTest::newRow("Splash") << NET::Splash;
QTest::newRow("DropdownMenu") << NET::DropdownMenu;
QTest::newRow("PopupMenu") << NET::PopupMenu;
QTest::newRow("Tooltip") << NET::Tooltip;
QTest::newRow("Notification") << NET::Notification;
QTest::newRow("ComboBox") << NET::ComboBox;
QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay;
QTest::newRow("CriticalNotification") << NET::CriticalNotification;
QTest::newRow("AppletPopup") << NET::AppletPopup;
}
void InternalWindowTest::testChangeWindowType()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QCOMPARE(internalWindow->windowType(), NET::Normal);
QFETCH(NET::WindowType, windowType);
KWindowSystem::setType(win.winId(), windowType);
QTRY_COMPARE(internalWindow->windowType(), windowType);
KWindowSystem::setType(win.winId(), NET::Normal);
QTRY_COMPARE(internalWindow->windowType(), NET::Normal);
}
void InternalWindowTest::testEffectWindow()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto internalWindow = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(internalWindow);
QVERIFY(internalWindow->effectWindow());
QCOMPARE(internalWindow->effectWindow()->internalWindow(), &win);
QCOMPARE(effects->findWindow(&win), internalWindow->effectWindow());
QCOMPARE(effects->findWindow(&win)->internalWindow(), &win);
}
void InternalWindowTest::testReentrantMoveResize()
{
// This test verifies that calling moveResize() from a slot connected directly
// to the frameGeometryChanged() signal won't cause an infinite recursion.
// Create an internal window.
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow win;
win.setGeometry(0, 0, 100, 100);
win.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto window = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(window);
QCOMPARE(window->pos(), QPoint(0, 0));
// Let's pretend that there is a script that really wants the window to be at (100, 100).
connect(window, &Window::frameGeometryChanged, this, [window]() {
window->moveResize(QRectF(QPointF(100, 100), window->size()));
});
// Trigger the lambda above.
window->move(QPoint(40, 50));
// Eventually, the window will end up at (100, 100).
QCOMPARE(window->pos(), QPoint(100, 100));
}
void InternalWindowTest::testDismissPopup()
{
// This test verifies that a popup window created by the compositor will be dismissed
// when user clicks another window.
// Create a toplevel window.
QSignalSpy windowAddedSpy(workspace(), &Workspace::internalWindowAdded);
HelperWindow clientToplevel;
clientToplevel.setGeometry(0, 0, 100, 100);
clientToplevel.show();
QTRY_COMPARE(windowAddedSpy.count(), 1);
auto serverToplevel = windowAddedSpy.last().first().value<InternalWindow *>();
QVERIFY(serverToplevel);
// Create a popup window.
QRasterWindow clientPopup;
clientPopup.setFlag(Qt::Popup);
clientPopup.setTransientParent(&clientToplevel);
clientPopup.setGeometry(0, 0, 50, 50);
clientPopup.show();
QTRY_COMPARE(windowAddedSpy.count(), 2);
auto serverPopup = windowAddedSpy.last().first().value<InternalWindow *>();
QVERIFY(serverPopup);
// Create the other window to click
HelperWindow otherClientToplevel;
otherClientToplevel.setGeometry(100, 100, 100, 100);
otherClientToplevel.show();
QTRY_COMPARE(windowAddedSpy.count(), 3);
auto serverOtherToplevel = windowAddedSpy.last().first().value<InternalWindow *>();
QVERIFY(serverOtherToplevel);
// Click somewhere outside the popup window.
QSignalSpy popupClosedSpy(serverPopup, &InternalWindow::windowClosed);
quint32 timestamp = 0;
Test::pointerMotion(serverOtherToplevel->frameGeometry().center(), timestamp++);
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
QTRY_COMPARE(popupClosedSpy.count(), 1);
}
}
WAYLANDTEST_MAIN(KWin::InternalWindowTest)
#include "internal_window.moc"

Some files were not shown because too many files have changed in this diff Show More