Compare commits

..

1 Commits

Author SHA1 Message Date
Vitaliy Filippov d9369375d2 ICC Color Correction effect 2020-10-08 12:01:30 +03:00
4380 changed files with 246972 additions and 1237528 deletions

View File

@ -1,86 +0,0 @@
---
---
# 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
# Indent lambdas to the start of the line, not to the start of the lambda
LambdaBodyIndentation: OuterScope

28
.gitignore vendored
View File

@ -1,28 +0,0 @@
# 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
.directory

View File

@ -1,14 +0,0 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
include:
- project: sysadmin/ci-utilities
file:
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/freebsd-qt6.yml
suse_tumbleweed_qt67_reduced_featureset:
extends: suse_tumbleweed_qt67
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 -DKWIN_BUILD_GLOBALSHORTCUTS=OFF -DKWIN_BUILD_X11=OFF -DKWIN_BUILD_EIS=OFF" --skip-publishing

View File

@ -1,49 +0,0 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
Dependencies:
- 'on': ['@all']
'require':
'frameworks/breeze-icons': '@latest-kf6'
'frameworks/extra-cmake-modules': '@latest-kf6'
'frameworks/kcmutils': '@latest-kf6'
'frameworks/kconfig': '@latest-kf6'
'frameworks/kconfigwidgets': '@latest-kf6'
'frameworks/kcoreaddons': '@latest-kf6'
'frameworks/kcrash': '@latest-kf6'
'frameworks/kdeclarative': '@latest-kf6'
'frameworks/kdoctools': '@latest-kf6'
'frameworks/kglobalaccel': '@latest-kf6'
'frameworks/ki18n': '@latest-kf6'
'frameworks/kidletime': '@latest-kf6'
'frameworks/knewstuff': '@latest-kf6'
'frameworks/knotifications': '@latest-kf6'
'frameworks/kpackage': '@latest-kf6'
'frameworks/kservice': '@latest-kf6'
'frameworks/ksvg': '@latest-kf6'
'frameworks/kwidgetsaddons': '@latest-kf6'
'frameworks/kwindowsystem': '@latest-kf6'
'frameworks/kxmlgui': '@latest-kf6'
'libraries/libqaccessibilityclient': '@latest-kf6'
'libraries/plasma-wayland-protocols': '@latest-kf6'
'plasma/breeze': '@same'
'plasma/plasma-activities': '@same'
'plasma/kdecoration': '@same'
'plasma/kglobalacceld': '@same'
'plasma/kpipewire': '@same'
'plasma/kscreenlocker': '@same'
'plasma/kwayland': '@same'
'third-party/wayland': '@latest'
'third-party/wayland-protocols': '@latest'
RuntimeDependencies:
- 'on': ['@all']
'require':
'frameworks/kirigami': '@latest-kf6'
'plasma/libplasma': '@same'
'plasma/plasma-workspace': '@same' # kscreenlocker needs it
Options:
ctest-arguments: '--repeat until-pass:5'
use-ccache: True
require-passing-tests-on: ['FreeBSD', 'Linux']

978
3rdparty/xcursor.c vendored Normal file
View File

@ -0,0 +1,978 @@
/*
* Copyright © 2002 Keith Packard
*
* 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.
*/
#include "xcursor.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
/*
* From libXcursor/include/X11/extensions/Xcursor.h
*/
#define XcursorTrue 1
#define XcursorFalse 0
/*
* Cursor files start with a header. The header
* contains a magic number, a version number and a
* table of contents which has type and offset information
* for the remaining tables in the file.
*
* File minor versions increment for compatible changes
* File major versions increment for incompatible changes (never, we hope)
*
* Chunks of the same type are always upward compatible. Incompatible
* changes are made with new chunk types; the old data can remain under
* the old type. Upward compatible changes can add header data as the
* header lengths are specified in the file.
*
* File:
* FileHeader
* LISTofChunk
*
* FileHeader:
* CARD32 magic magic number
* CARD32 header bytes in file header
* CARD32 version file version
* CARD32 ntoc number of toc entries
* LISTofFileToc toc table of contents
*
* FileToc:
* CARD32 type entry type
* CARD32 subtype entry subtype (size for images)
* CARD32 position absolute file position
*/
#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
/*
* Current Xcursor version number. Will be substituted by configure
* from the version in the libXcursor configure.ac file.
*/
#define XCURSOR_LIB_MAJOR 1
#define XCURSOR_LIB_MINOR 1
#define XCURSOR_LIB_REVISION 13
#define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \
(XCURSOR_LIB_MINOR * 100) + \
(XCURSOR_LIB_REVISION))
/*
* This version number is stored in cursor files; changes to the
* file format require updating this version number
*/
#define XCURSOR_FILE_MAJOR 1
#define XCURSOR_FILE_MINOR 0
#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
#define XCURSOR_FILE_HEADER_LEN (4 * 4)
#define XCURSOR_FILE_TOC_LEN (3 * 4)
typedef struct _XcursorFileToc {
XcursorUInt type; /* chunk type */
XcursorUInt subtype; /* subtype (size for images) */
XcursorUInt position; /* absolute position in file */
} XcursorFileToc;
typedef struct _XcursorFileHeader {
XcursorUInt magic; /* magic number */
XcursorUInt header; /* byte length of header */
XcursorUInt version; /* file version number */
XcursorUInt ntoc; /* number of toc entries */
XcursorFileToc *tocs; /* table of contents */
} XcursorFileHeader;
/*
* The rest of the file is a list of chunks, each tagged by type
* and version.
*
* Chunk:
* ChunkHeader
* <extra type-specific header fields>
* <type-specific data>
*
* ChunkHeader:
* CARD32 header bytes in chunk header + type header
* CARD32 type chunk type
* CARD32 subtype chunk subtype
* CARD32 version chunk type version
*/
#define XCURSOR_CHUNK_HEADER_LEN (4 * 4)
typedef struct _XcursorChunkHeader {
XcursorUInt header; /* bytes in chunk header */
XcursorUInt type; /* chunk type */
XcursorUInt subtype; /* chunk subtype (size for images) */
XcursorUInt version; /* version of this type */
} XcursorChunkHeader;
/*
* Here's a list of the known chunk types
*/
/*
* Comments consist of a 4-byte length field followed by
* UTF-8 encoded text
*
* Comment:
* ChunkHeader header chunk header
* CARD32 length bytes in text
* LISTofCARD8 text UTF-8 encoded text
*/
#define XCURSOR_COMMENT_TYPE 0xfffe0001
#define XCURSOR_COMMENT_VERSION 1
#define XCURSOR_COMMENT_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (1 *4))
#define XCURSOR_COMMENT_COPYRIGHT 1
#define XCURSOR_COMMENT_LICENSE 2
#define XCURSOR_COMMENT_OTHER 3
#define XCURSOR_COMMENT_MAX_LEN 0x100000
typedef struct _XcursorComment {
XcursorUInt version;
XcursorUInt comment_type;
char *comment;
} XcursorComment;
/*
* Each cursor image occupies a separate image chunk.
* The length of the image header follows the chunk header
* so that future versions can extend the header without
* breaking older applications
*
* Image:
* ChunkHeader header chunk header
* CARD32 width actual width
* CARD32 height actual height
* CARD32 xhot hot spot x
* CARD32 yhot hot spot y
* CARD32 delay animation delay
* LISTofCARD32 pixels ARGB pixels
*/
#define XCURSOR_IMAGE_TYPE 0xfffd0002
#define XCURSOR_IMAGE_VERSION 1
#define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))
#define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */
typedef struct _XcursorFile XcursorFile;
struct _XcursorFile {
void *closure;
int (*read) (XcursorFile *file, unsigned char *buf, int len);
int (*write) (XcursorFile *file, unsigned char *buf, int len);
int (*seek) (XcursorFile *file, long offset, int whence);
};
typedef struct _XcursorComments {
int ncomment; /* number of comments */
XcursorComment **comments; /* array of XcursorComment pointers */
} XcursorComments;
/*
* From libXcursor/src/file.c
*/
static XcursorImage *
XcursorImageCreate (int width, int height)
{
XcursorImage *image;
if (width < 0 || height < 0)
return NULL;
if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE)
return NULL;
image = malloc (sizeof (XcursorImage) +
width * height * sizeof (XcursorPixel));
if (!image)
return NULL;
image->version = XCURSOR_IMAGE_VERSION;
image->pixels = (XcursorPixel *) (image + 1);
image->size = width > height ? width : height;
image->width = width;
image->height = height;
image->delay = 0;
return image;
}
static void
XcursorImageDestroy (XcursorImage *image)
{
free (image);
}
static XcursorImages *
XcursorImagesCreate (int size)
{
XcursorImages *images;
images = malloc (sizeof (XcursorImages) +
size * sizeof (XcursorImage *));
if (!images)
return NULL;
images->nimage = 0;
images->images = (XcursorImage **) (images + 1);
images->name = NULL;
return images;
}
void
XcursorImagesDestroy (XcursorImages *images)
{
int n;
if (!images)
return;
for (n = 0; n < images->nimage; n++)
XcursorImageDestroy (images->images[n]);
if (images->name)
free (images->name);
free (images);
}
static void
XcursorImagesSetName (XcursorImages *images, const char *name)
{
char *new;
if (!images || !name)
return;
new = malloc (strlen (name) + 1);
if (!new)
return;
strcpy (new, name);
if (images->name)
free (images->name);
images->name = new;
}
static XcursorBool
_XcursorReadUInt (XcursorFile *file, XcursorUInt *u)
{
unsigned char bytes[4];
if (!file || !u)
return XcursorFalse;
if ((*file->read) (file, bytes, 4) != 4)
return XcursorFalse;
*u = ((XcursorUInt)(bytes[0]) << 0) |
((XcursorUInt)(bytes[1]) << 8) |
((XcursorUInt)(bytes[2]) << 16) |
((XcursorUInt)(bytes[3]) << 24);
return XcursorTrue;
}
static void
_XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader)
{
free (fileHeader);
}
static XcursorFileHeader *
_XcursorFileHeaderCreate (int ntoc)
{
XcursorFileHeader *fileHeader;
if (ntoc > 0x10000)
return NULL;
fileHeader = malloc (sizeof (XcursorFileHeader) +
ntoc * sizeof (XcursorFileToc));
if (!fileHeader)
return NULL;
fileHeader->magic = XCURSOR_MAGIC;
fileHeader->header = XCURSOR_FILE_HEADER_LEN;
fileHeader->version = XCURSOR_FILE_VERSION;
fileHeader->ntoc = ntoc;
fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1);
return fileHeader;
}
static XcursorFileHeader *
_XcursorReadFileHeader (XcursorFile *file)
{
XcursorFileHeader head, *fileHeader;
XcursorUInt skip;
unsigned int n;
if (!file)
return NULL;
if (!_XcursorReadUInt (file, &head.magic))
return NULL;
if (head.magic != XCURSOR_MAGIC)
return NULL;
if (!_XcursorReadUInt (file, &head.header))
return NULL;
if (!_XcursorReadUInt (file, &head.version))
return NULL;
if (!_XcursorReadUInt (file, &head.ntoc))
return NULL;
skip = head.header - XCURSOR_FILE_HEADER_LEN;
if (skip)
if ((*file->seek) (file, skip, SEEK_CUR) == EOF)
return NULL;
fileHeader = _XcursorFileHeaderCreate (head.ntoc);
if (!fileHeader)
return NULL;
fileHeader->magic = head.magic;
fileHeader->header = head.header;
fileHeader->version = head.version;
fileHeader->ntoc = head.ntoc;
for (n = 0; n < fileHeader->ntoc; n++)
{
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type))
break;
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype))
break;
if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position))
break;
}
if (n != fileHeader->ntoc)
{
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
return fileHeader;
}
static XcursorBool
_XcursorSeekToToc (XcursorFile *file,
XcursorFileHeader *fileHeader,
int toc)
{
if (!file || !fileHeader || \
(*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF)
return XcursorFalse;
return XcursorTrue;
}
static XcursorBool
_XcursorFileReadChunkHeader (XcursorFile *file,
XcursorFileHeader *fileHeader,
int toc,
XcursorChunkHeader *chunkHeader)
{
if (!file || !fileHeader || !chunkHeader)
return XcursorFalse;
if (!_XcursorSeekToToc (file, fileHeader, toc))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->header))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->type))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->subtype))
return XcursorFalse;
if (!_XcursorReadUInt (file, &chunkHeader->version))
return XcursorFalse;
/* sanity check */
if (chunkHeader->type != fileHeader->tocs[toc].type ||
chunkHeader->subtype != fileHeader->tocs[toc].subtype)
return XcursorFalse;
return XcursorTrue;
}
#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a))
static XcursorDim
_XcursorFindBestSize (XcursorFileHeader *fileHeader,
XcursorDim size,
int *nsizesp)
{
unsigned int n;
int nsizes = 0;
XcursorDim bestSize = 0;
XcursorDim thisSize;
if (!fileHeader || !nsizesp)
return 0;
for (n = 0; n < fileHeader->ntoc; n++)
{
if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE)
continue;
thisSize = fileHeader->tocs[n].subtype;
if (!bestSize || dist (thisSize, size) < dist (bestSize, size))
{
bestSize = thisSize;
nsizes = 1;
}
else if (thisSize == bestSize)
nsizes++;
}
*nsizesp = nsizes;
return bestSize;
}
static int
_XcursorFindImageToc (XcursorFileHeader *fileHeader,
XcursorDim size,
int count)
{
unsigned int toc;
XcursorDim thisSize;
if (!fileHeader)
return 0;
for (toc = 0; toc < fileHeader->ntoc; toc++)
{
if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE)
continue;
thisSize = fileHeader->tocs[toc].subtype;
if (thisSize != size)
continue;
if (!count)
break;
count--;
}
if (toc == fileHeader->ntoc)
return -1;
return toc;
}
static XcursorImage *
_XcursorReadImage (XcursorFile *file,
XcursorFileHeader *fileHeader,
int toc)
{
XcursorChunkHeader chunkHeader;
XcursorImage head;
XcursorImage *image;
int n;
XcursorPixel *p;
if (!file || !fileHeader)
return NULL;
if (!_XcursorFileReadChunkHeader (file, fileHeader, toc, &chunkHeader))
return NULL;
if (!_XcursorReadUInt (file, &head.width))
return NULL;
if (!_XcursorReadUInt (file, &head.height))
return NULL;
if (!_XcursorReadUInt (file, &head.xhot))
return NULL;
if (!_XcursorReadUInt (file, &head.yhot))
return NULL;
if (!_XcursorReadUInt (file, &head.delay))
return NULL;
/* sanity check data */
if (head.width > XCURSOR_IMAGE_MAX_SIZE ||
head.height > XCURSOR_IMAGE_MAX_SIZE)
return NULL;
if (head.width == 0 || head.height == 0)
return NULL;
if (head.xhot > head.width || head.yhot > head.height)
return NULL;
/* Create the image and initialize it */
image = XcursorImageCreate (head.width, head.height);
if (image == NULL)
return NULL;
if (chunkHeader.version < image->version)
image->version = chunkHeader.version;
image->size = chunkHeader.subtype;
image->xhot = head.xhot;
image->yhot = head.yhot;
image->delay = head.delay;
n = image->width * image->height;
p = image->pixels;
while (n--)
{
if (!_XcursorReadUInt (file, p))
{
XcursorImageDestroy (image);
return NULL;
}
p++;
}
return image;
}
static XcursorImages *
XcursorXcFileLoadImages (XcursorFile *file, int size)
{
XcursorFileHeader *fileHeader;
XcursorDim bestSize;
int nsize;
XcursorImages *images;
int n;
int toc;
if (!file || size < 0)
return NULL;
fileHeader = _XcursorReadFileHeader (file);
if (!fileHeader)
return NULL;
bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize);
if (!bestSize)
{
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
images = XcursorImagesCreate (nsize);
if (!images)
{
_XcursorFileHeaderDestroy (fileHeader);
return NULL;
}
for (n = 0; n < nsize; n++)
{
toc = _XcursorFindImageToc (fileHeader, bestSize, n);
if (toc < 0)
break;
images->images[images->nimage] = _XcursorReadImage (file, fileHeader,
toc);
if (!images->images[images->nimage])
break;
images->nimage++;
}
_XcursorFileHeaderDestroy (fileHeader);
if (images->nimage != nsize)
{
XcursorImagesDestroy (images);
images = NULL;
}
return images;
}
static int
_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len)
{
FILE *f = file->closure;
return fread (buf, 1, len, f);
}
static int
_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len)
{
FILE *f = file->closure;
return fwrite (buf, 1, len, f);
}
static int
_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence)
{
FILE *f = file->closure;
return fseek (f, offset, whence);
}
static void
_XcursorStdioFileInitialize (FILE *stdfile, XcursorFile *file)
{
file->closure = stdfile;
file->read = _XcursorStdioFileRead;
file->write = _XcursorStdioFileWrite;
file->seek = _XcursorStdioFileSeek;
}
static XcursorImages *
XcursorFileLoadImages (FILE *file, int size)
{
XcursorFile f;
if (!file)
return NULL;
_XcursorStdioFileInitialize (file, &f);
return XcursorXcFileLoadImages (&f, size);
}
/*
* From libXcursor/src/library.c
*/
#ifndef ICONDIR
#define ICONDIR "/usr/X11R6/lib/X11/icons"
#endif
#ifndef XCURSORPATH
#define XCURSORPATH "~/.icons:/usr/share/icons:/usr/share/pixmaps:~/.cursors:/usr/share/cursors/xorg-x11:"ICONDIR
#endif
static const char *
XcursorLibraryPath (void)
{
static const char *path;
if (!path)
{
path = getenv ("XCURSOR_PATH");
if (!path)
path = XCURSORPATH;
}
return path;
}
static void
_XcursorAddPathElt (char *path, const char *elt, int len)
{
int pathlen = strlen (path);
/* append / if the path doesn't currently have one */
if (path[0] == '\0' || path[pathlen - 1] != '/')
{
strcat (path, "/");
pathlen++;
}
if (len == -1)
len = strlen (elt);
/* strip leading slashes */
while (len && elt[0] == '/')
{
elt++;
len--;
}
strncpy (path + pathlen, elt, len);
path[pathlen + len] = '\0';
}
static char *
_XcursorBuildThemeDir (const char *dir, const char *theme)
{
const char *colon;
const char *tcolon;
char *full;
char *home;
int dirlen;
int homelen;
int themelen;
int len;
if (!dir || !theme)
return NULL;
colon = strchr (dir, ':');
if (!colon)
colon = dir + strlen (dir);
dirlen = colon - dir;
tcolon = strchr (theme, ':');
if (!tcolon)
tcolon = theme + strlen (theme);
themelen = tcolon - theme;
home = NULL;
homelen = 0;
if (*dir == '~')
{
home = getenv ("HOME");
if (!home)
return NULL;
homelen = strlen (home);
dir++;
dirlen--;
}
/*
* add space for any needed directory separators, one per component,
* and one for the trailing null
*/
len = 1 + homelen + 1 + dirlen + 1 + themelen + 1;
full = malloc (len);
if (!full)
return NULL;
full[0] = '\0';
if (home)
_XcursorAddPathElt (full, home, -1);
_XcursorAddPathElt (full, dir, dirlen);
_XcursorAddPathElt (full, theme, themelen);
return full;
}
static char *
_XcursorBuildFullname (const char *dir, const char *subdir, const char *file)
{
char *full;
if (!dir || !subdir || !file)
return NULL;
full = malloc (strlen (dir) + 1 + strlen (subdir) + 1 + strlen (file) + 1);
if (!full)
return NULL;
full[0] = '\0';
_XcursorAddPathElt (full, dir, -1);
_XcursorAddPathElt (full, subdir, -1);
_XcursorAddPathElt (full, file, -1);
return full;
}
static const char *
_XcursorNextPath (const char *path)
{
char *colon = strchr (path, ':');
if (!colon)
return NULL;
return colon + 1;
}
#define XcursorWhite(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
#define XcursorSep(c) ((c) == ';' || (c) == ',')
static char *
_XcursorThemeInherits (const char *full)
{
char line[8192];
char *result = NULL;
FILE *f;
if (!full)
return NULL;
f = fopen (full, "r");
if (f)
{
while (fgets (line, sizeof (line), f))
{
if (!strncmp (line, "Inherits", 8))
{
char *l = line + 8;
char *r;
while (*l == ' ') l++;
if (*l != '=') continue;
l++;
while (*l == ' ') l++;
result = malloc (strlen (l) + 1);
if (result)
{
r = result;
while (*l)
{
while (XcursorSep(*l) || XcursorWhite (*l)) l++;
if (!*l)
break;
if (r != result)
*r++ = ':';
while (*l && !XcursorWhite(*l) &&
!XcursorSep(*l))
*r++ = *l++;
}
*r++ = '\0';
}
break;
}
}
fclose (f);
}
return result;
}
static FILE *
XcursorScanTheme (const char *theme, const char *name)
{
FILE *f = NULL;
char *full;
char *dir;
const char *path;
char *inherits = NULL;
const char *i;
if (!theme || !name)
return NULL;
/*
* Scan this theme
*/
for (path = XcursorLibraryPath ();
path && f == NULL;
path = _XcursorNextPath (path))
{
dir = _XcursorBuildThemeDir (path, theme);
if (dir)
{
full = _XcursorBuildFullname (dir, "cursors", name);
if (full)
{
f = fopen (full, "r");
free (full);
}
if (!f && !inherits)
{
full = _XcursorBuildFullname (dir, "", "index.theme");
if (full)
{
inherits = _XcursorThemeInherits (full);
free (full);
}
}
free (dir);
}
}
/*
* Recurse to scan inherited themes
*/
for (i = inherits; i && f == NULL; i = _XcursorNextPath (i))
f = XcursorScanTheme (i, name);
if (inherits != NULL)
free (inherits);
return f;
}
XcursorImages *
XcursorLibraryLoadImages (const char *file, const char *theme, int size)
{
FILE *f = NULL;
XcursorImages *images = NULL;
if (!file)
return NULL;
if (theme)
f = XcursorScanTheme (theme, file);
if (!f)
f = XcursorScanTheme ("default", file);
if (f)
{
images = XcursorFileLoadImages (f, size);
if (images)
XcursorImagesSetName (images, file);
fclose (f);
}
return images;
}
static void
load_all_cursors_from_dir(const char *path, int size,
void (*load_callback)(XcursorImages *, void *),
void *user_data)
{
FILE *f;
DIR *dir = opendir(path);
struct dirent *ent;
char *full;
XcursorImages *images;
if (!dir)
return;
for(ent = readdir(dir); ent; ent = readdir(dir)) {
#ifdef _DIRENT_HAVE_D_TYPE
if (ent->d_type != DT_UNKNOWN &&
(ent->d_type != DT_REG && ent->d_type != DT_LNK))
continue;
#endif
full = _XcursorBuildFullname(path, "", ent->d_name);
if (!full)
continue;
f = fopen(full, "r");
if (!f) {
free(full);
continue;
}
images = XcursorFileLoadImages(f, size);
if (images) {
XcursorImagesSetName(images, ent->d_name);
load_callback(images, user_data);
}
fclose (f);
free(full);
}
closedir(dir);
}
/** Load all the cursor of a theme
*
* This function loads all the cursor images of a given theme and its
* inherited themes. Each cursor is loaded into an XcursorImages object
* which is passed to the caller's load callback. If a cursor appears
* more than once across all the inherited themes, the load callback
* will be called multiple times, with possibly different XcursorImages
* object which have the same name. The user is expected to destroy the
* XcursorImages objects passed to the callback with
* XcursorImagesDestroy().
*
* \param theme The name of theme that should be loaded
* \param size The desired size of the cursor images
* \param load_callback A callback function that will be called
* for each cursor loaded. The first parameter is the XcursorImages
* object representing the loaded cursor and the second is a pointer
* to data provided by the user.
* \param user_data The data that should be passed to the load callback
*/
void
xcursor_load_theme(const char *theme, int size,
void (*load_callback)(XcursorImages *, void *),
void *user_data)
{
char *full, *dir;
char *inherits = NULL;
const char *path, *i;
if (!theme)
theme = "default";
for (path = XcursorLibraryPath();
path;
path = _XcursorNextPath(path)) {
dir = _XcursorBuildThemeDir(path, theme);
if (!dir)
continue;
full = _XcursorBuildFullname(dir, "cursors", "");
if (full) {
load_all_cursors_from_dir(full, size, load_callback,
user_data);
free(full);
}
if (!inherits) {
full = _XcursorBuildFullname(dir, "", "index.theme");
if (full) {
inherits = _XcursorThemeInherits(full);
free(full);
}
}
free(dir);
}
for (i = inherits; i; i = _XcursorNextPath(i))
xcursor_load_theme(i, size, load_callback, user_data);
if (inherits)
free(inherits);
}

76
3rdparty/xcursor.h vendored Normal file
View File

@ -0,0 +1,76 @@
/*
* Copyright © 2002 Keith Packard
*
* 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.
*/
#ifndef XCURSOR_H
#define XCURSOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
typedef int XcursorBool;
typedef uint32_t XcursorUInt;
typedef XcursorUInt XcursorDim;
typedef XcursorUInt XcursorPixel;
typedef struct _XcursorImage {
XcursorUInt version; /* version of the image data */
XcursorDim size; /* nominal size for matching */
XcursorDim width; /* actual width */
XcursorDim height; /* actual height */
XcursorDim xhot; /* hot spot x (must be inside image) */
XcursorDim yhot; /* hot spot y (must be inside image) */
XcursorUInt delay; /* animation delay to next frame (ms) */
XcursorPixel *pixels; /* pointer to pixels */
} XcursorImage;
/*
* Other data structures exposed by the library API
*/
typedef struct _XcursorImages {
int nimage; /* number of images */
XcursorImage **images; /* array of XcursorImage pointers */
char *name; /* name used to load images */
} XcursorImages;
XcursorImages *
XcursorLibraryLoadImages (const char *file, const char *theme, int size);
void
XcursorImagesDestroy (XcursorImages *images);
void
xcursor_load_theme(const char *theme, int size,
void (*load_callback)(XcursorImages *, void *),
void *user_data);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,138 +0,0 @@
# 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 located in `src/tabbox/switchers`.
Other window switchers usually shipped by default are located in [Plasma Addons](https://invent.kde.org/plasma/kdeplasma-addons), located in the `kwin/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 `src/plugins`, one effect plugin per folder. Folder `src/plugins/private` contains the plugin (`org.kde.kwin.private.effects`) that exposes layouting properties and `WindowHeap.qml` for QML effects. Not everything here is an effect as exposed in the configuration UI, such as the colour picker in `src/plugins/colorpicker`.
Of note, the Effects QML engine is shared with the Scripting components (see `src/scripting`).
### 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://community.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
source prefix.sh
cd bin
# for wayland, starts nested session: with console
env QT_PLUGIN_PATH="$(pwd)":"$QT_PLUGIN_PATH" dbus-run-session ./kwin_wayland --xwayland konsole
# or for x11, replaces current kwin instance:
env QT_PLUGIN_PATH="$(pwd)":"$QT_PLUGIN_PATH" ./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).

98
HACKING.md Normal file
View File

@ -0,0 +1,98 @@
# Quick building
KWin uses CMake. This means that KWin can be build in a normal cmake-style out of source tree.
mkdir build
cd build
cmake ../
make
# Dependencies
All of KWin's dependencies are found through CMake. CMake will report what is missing. The dependencies can be installed using system packages. For the master branch it is possible that system packages are not up to date. KWin master sometimes depends from the master branch of some KDE frameworks (mostly KWayland and KWindowSystems) and other components inside Plasma (KDecoration). KWin never depends on unreleased third party components. In such a case it is required to build these components also from master. Alternatively some distributions provide daily build packages which can also be used instead. Stable branches never depend on unstable components. On Debian based distributions the easiest way to install all build dependencies is
sudo apt build-dep kwin-wayland
# Running the build KWin
KWin can be executed directly from the build directory. All binaries are put into a subdirectory bin. From there KWin and its tests can be started.
## Nested KWin/Wayland
The best way to test changes in KWin is through using the nested KWin Wayland in a running X11 or Wayland session.
To start a nested KWin Wayland use:
cd build
cd bin
QT_PLUGIN_PATH=`pwd` dbus-run-session ./kwin_wayland --xwayland --socket=wayland-1
The socket option is not required if KWin is started from an X11 session. On Wayland of course a socket not matching the session's socket must be chosen. To show windows in the nested KWin adjust the environment variables DISPLAY (for X11 windows) and WAYLAND_DISPLAY (for Wayland windows). Alternatively it's possible to pass applications to launch as command line arguments to kwin_wayland command. E.g.
QT_PLUGIN_PATH=`pwd` dbus-run-session ./kwin_wayland --xwayland --socket=wayland-1 konsole
Will start a konsole in the nested KWin.
### Why adjusting QT_PLUGIN_PATH?
Qt's plugin path needs to point to the build directory so that KWin can load the plugins from the build directory instead of using the system installed plugins which would normally be preferred.
### Why start a dedicated DBus session?
KWin interacts with kglobalaccel, so starting KWin without a dedicated DBus session would steal all global shortcuts from the running session. KGlobalaccel is just a very prominent example, there are further DBus interaction problems without a dedicated DBus session.
## DRM platform
The nested setup only works for the X11 and Wayland platform plugins. Changes in the DRM platform plugin or libinput cannot be tested in a nested setup. To test these, change to a tty, login and start kwin_wayland with the same command as for nested. KWin automatically picks the DRM platform as neither DISPLAY nor WAYLAND_DISPLAY environment variables should be defined.
## KWin/X11
KWin for the X11 windowing system cannot be tested with a nested Wayland setup. Instead the common way is to run KWin and replace the existing window manager of the X session:
cd build
cd bin
QT_PLUGIN_PATH=`pwd` ./kwin_x11 --replace
In this case also the current DBus session should be used and dbus-run-session should not be used. Of course it's only possible to start kwin_x11 in an X session. On Wayland kwin_x11 will refuse to start.
### Xephyr
It is possible to run kwin_x11 in a Xephyr window, but this is rather limited and especially the OpenGL compositor cannot really be tested. For X11 it's better to replace the running session. On Wayland using Xephyr is better than nothing.
## Containers
While it is possible to run KWin through container technologies such as docker this is not recommended. KWin needs to interact with the actual hardware such as the OpenGL drivers, input devices, etc. Getting this setup is possible, but complicated. With containers one can only achieve a nested setup and this requires passing through the socket of the host's windowing system, device files for graphics stack, etc.
# Attaching a debugger
Debugging KWin is challenging as KWin is drawing the screen. If you gdb into a running kwin_x11 or kwin_wayland from your current session, it's probably the last thing you'll do in the session. The session hard locks the moment the debugger is attached to the process. Due to that never attach a debugger from your running session.
It is possible to attach gdb from another tty, but that is only a solution for X11. On Wayland one would not be able to switch back to the tty once a breakpoint is hit as KWin is responsible for tty switching.
Overall the only sensible solution for attaching gdb is from another system through ssh.
## Better ways of debugging
As attaching gdb to a running session is not a satisfying solution it is better to run nested KWin Wayland in gdb. E.g.
cd build
cd bin
QT_PLUGIN_PATH=`pwd` dbus-run-session gdb --args ./kwin_wayland --xwayland --socket=wayland-1
Another solution is using KWin's extensive test suite and run the appropriate test binary through gdb.
# Automatic tests
KWin's test suite is explained in document [TESTING](TESTING.md).
# Contributing patches
KWin uses [KDE's phabricator instance](https://phabricator.kde.org) for code review. Patches can be uploaded automatically using the tool arcanist. A possible workflow could look like:
git checkout -b my-feature-branch
git add ...
git commit
arc diff
More complete documentation can be found in [KDE's wiki](https://community.kde.org/Infrastructure/Phabricator). Please add "#KWin" as reviewers. Please run KWin's automated test suite prior to uploading a patch to ensure that the change does not break existing code.
# Coding conventions
KWin's coding conventions are explained in document [coding-conventions.md](doc/coding-conventions.md).
# Coding style
KWin code follows the [Frameworks coding style](https://techbase.kde.org/Policies/Frameworks_Coding_Style).

View File

@ -3,8 +3,4 @@
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_NIGHTLIGHT_INTERFACE "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@/org.kde.KWin.NightLight.xml")
set(KWIN_WAYLAND_BIN_PATH "@CMAKE_INSTALL_FULL_BINDIR@/kwin_wayland")

22
LICENSES/BSD-2-Clause.txt Normal file
View File

@ -0,0 +1,22 @@
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.
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.

View File

@ -1,121 +0,0 @@
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.

View File

@ -1,175 +0,0 @@
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!

3
Messages.sh Normal file
View File

@ -0,0 +1,3 @@
#! /usr/bin/env bash
$EXTRACTRC *.kcfg *.ui >> rc.cpp
$XGETTEXT *.h *.cpp colorcorrection/*.cpp helpers/killer/*.cpp plugins/scenes/opengl/*.cpp tabbox/*.cpp scripting/*.cpp -o $podir/kwin.pot

View File

@ -9,14 +9,10 @@ KWin is an easy to use, but flexible, composited Window Manager for Xorg windowi
* 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
* IRC: #kwin on freenode
# Support
## Application Developer
@ -29,6 +25,9 @@ Please contact the support channels of your Linux distribution for user support.
Please use [KDE's bugtracker](https://bugs.kde.org) and report for [product KWin](https://bugs.kde.org/enter_bug.cgi?product=kwin).
# Developing on KWin
Please refer to [hacking documentation](HACKING.md) for how to build and start KWin. Further information about KWin's test suite can be found in [TESTING.md](TESTING.md).
## Guidelines for new features
A new Feature can only be added to KWin if:

33
TESTING.md Normal file
View File

@ -0,0 +1,33 @@
# Testing in KWin
KWin provides a unit and integration test suit for X11 and Wayland. The source code for the tests can be found in the subdirectory autotests. The test suite should be run prior to any merge to KWin.
# Dependencies
The following additional software needs to be installed for running the test suite:
* Xvfb
* Xephyr
* glxgears
* DMZ-white cursor theme
* breeze window decoration
# Preparing OpenGL
Some of the tests require OpenGL. The test suite is implemented against Mesa and uses the Mesa specific EGL extension
EGL_MESA_platform_surfaceless. This extension supports rendering without any real GPU using llvmpipe as software
emulation. This gives the tests a stable base removing variance introduced by different hardware and drivers.
Users of non-Mesa drivers (e.g. proprietary NVIDIA driver) need to ensure that Mesa is also installed. If your system
uses libglvnd this should work out of the box, if not you might need to tune LD_LIBRARY_PATH.
# Running the test suite
The test suite can be run from the build directory. Best is to do:
cd path/to/build/directory
xvfb-run ctest
# Running individual tests
All tests executables are created in the directory "bin" in the build directory. Each test can be executed by just starting it from within the test directory. To prevent side effects with the running session it is recommended to start a dedicated dbus session:
cd path/to/build/directory/bin
dbus-run-session ./testFoo
For tests relying on X11 one should also either start a dedicated Xvfb and export DISPLAY or use xvfb-run as described above.

3521
abstract_client.cpp Normal file

File diff suppressed because it is too large Load Diff

1377
abstract_client.h Normal file

File diff suppressed because it is too large Load Diff

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
*/
#include "abstract_opengl_context_attribute_builder.h"
namespace KWin
{
QDebug AbstractOpenGLContextAttributeBuilder::operator<<(QDebug dbg) const
{
QDebugStateSaver saver(dbg);
dbg.nospace() << "\nVersion requested:\t" << isVersionRequested() << "\n";
if (isVersionRequested()) {
dbg.nospace() << "Version:\t" << majorVersion() << "." << minorVersion() << "\n";
}
dbg.nospace() << "Robust:\t" << isRobust() << "\n";
dbg.nospace() << "Forward compatible:\t" << isForwardCompatible() << "\n";
dbg.nospace() << "Core profile:\t" << isCoreProfile() << "\n";
dbg.nospace() << "Compatibility profile:\t" << isCompatibilityProfile() << "\n";
dbg.nospace() << "High priority:\t" << isHighPriority();
return dbg;
}
}

View File

@ -0,0 +1,115 @@
/*
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 <QDebug>
#include <kwin_export.h>
namespace KWin
{
class KWIN_EXPORT AbstractOpenGLContextAttributeBuilder
{
public:
virtual ~AbstractOpenGLContextAttributeBuilder() {
}
void setVersion(int major, int minor = 0) {
m_versionRequested = true;
m_majorVersion = major;
m_minorVersion = minor;
}
bool isVersionRequested() const {
return m_versionRequested;
}
int majorVersion() const {
return m_majorVersion;
}
int minorVersion() const {
return m_minorVersion;
}
void setRobust(bool robust) {
m_robust = robust;
}
bool isRobust() const {
return m_robust;
}
void setForwardCompatible(bool forward) {
m_forwardCompatible = forward;
}
bool isForwardCompatible() const {
return m_forwardCompatible;
}
void setCoreProfile(bool core) {
m_coreProfile = core;
if (m_coreProfile) {
setCompatibilityProfile(false);
}
}
bool isCoreProfile() const {
return m_coreProfile;
}
void setCompatibilityProfile(bool compatibility) {
m_compatibilityProfile = compatibility;
if (m_compatibilityProfile) {
setCoreProfile(false);
}
}
bool isCompatibilityProfile() const {
return m_compatibilityProfile;
}
void setResetOnVideoMemoryPurge(bool reset) {
m_resetOnVideoMemoryPurge = reset;
}
bool isResetOnVideoMemoryPurge() const {
return m_resetOnVideoMemoryPurge;
}
void setHighPriority(bool highPriority) {
m_highPriority = highPriority;
}
bool isHighPriority() const {
return m_highPriority;
}
virtual std::vector<int> build() const = 0;
QDebug operator<<(QDebug dbg) const;
private:
bool m_versionRequested = false;
int m_majorVersion = 0;
int m_minorVersion = 0;
bool m_robust = false;
bool m_forwardCompatible = false;
bool m_coreProfile = false;
bool m_compatibilityProfile = false;
bool m_resetOnVideoMemoryPurge = false;
bool m_highPriority = false;
};
inline QDebug operator<<(QDebug dbg, const AbstractOpenGLContextAttributeBuilder *attribs)
{
return attribs->operator<<(dbg);
}
}

106
abstract_output.cpp Normal file
View File

@ -0,0 +1,106 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "abstract_output.h"
namespace KWin
{
GammaRamp::GammaRamp(uint32_t size)
: m_table(3 * size)
, m_size(size)
{
}
uint32_t GammaRamp::size() const
{
return m_size;
}
uint16_t *GammaRamp::red()
{
return m_table.data();
}
const uint16_t *GammaRamp::red() const
{
return m_table.data();
}
uint16_t *GammaRamp::green()
{
return m_table.data() + m_size;
}
const uint16_t *GammaRamp::green() const
{
return m_table.data() + m_size;
}
uint16_t *GammaRamp::blue()
{
return m_table.data() + 2 * m_size;
}
const uint16_t *GammaRamp::blue() const
{
return m_table.data() + 2 * m_size;
}
AbstractOutput::AbstractOutput(QObject *parent)
: QObject(parent)
{
}
AbstractOutput::~AbstractOutput()
{
}
QByteArray AbstractOutput::uuid() const
{
return QByteArray();
}
void AbstractOutput::setEnabled(bool enable)
{
Q_UNUSED(enable)
}
void AbstractOutput::applyChanges(const KWaylandServer::OutputChangeSet *changeSet)
{
Q_UNUSED(changeSet)
}
bool AbstractOutput::isInternal() const
{
return false;
}
qreal AbstractOutput::scale() const
{
return 1;
}
QSize AbstractOutput::physicalSize() const
{
return QSize();
}
int AbstractOutput::gammaRampSize() const
{
return 0;
}
bool AbstractOutput::setGammaRamp(const GammaRamp &gamma)
{
Q_UNUSED(gamma);
return false;
}
} // namespace KWin

179
abstract_output.h Normal file
View File

@ -0,0 +1,179 @@
/*
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
*/
#ifndef KWIN_ABSTRACT_OUTPUT_H
#define KWIN_ABSTRACT_OUTPUT_H
#include <kwin_export.h>
#include <QObject>
#include <QRect>
#include <QSize>
#include <QVector>
namespace KWaylandServer
{
class OutputChangeSet;
}
namespace KWin
{
class KWIN_EXPORT GammaRamp
{
public:
GammaRamp(uint32_t size);
/**
* Returns the size of the gamma ramp.
*/
uint32_t size() const;
/**
* Returns pointer to the first red component in the gamma ramp.
*
* The returned pointer can be used for altering the red component
* in the gamma ramp.
*/
uint16_t *red();
/**
* Returns pointer to the first red component in the gamma ramp.
*/
const uint16_t *red() const;
/**
* Returns pointer to the first green component in the gamma ramp.
*
* The returned pointer can be used for altering the green component
* in the gamma ramp.
*/
uint16_t *green();
/**
* Returns pointer to the first green component in the gamma ramp.
*/
const uint16_t *green() const;
/**
* Returns pointer to the first blue component in the gamma ramp.
*
* The returned pointer can be used for altering the blue component
* in the gamma ramp.
*/
uint16_t *blue();
/**
* Returns pointer to the first blue component in the gamma ramp.
*/
const uint16_t *blue() const;
private:
QVector<uint16_t> m_table;
uint32_t m_size;
};
/**
* Generic output representation.
*/
class KWIN_EXPORT AbstractOutput : public QObject
{
Q_OBJECT
public:
explicit AbstractOutput(QObject *parent = nullptr);
~AbstractOutput() override;
/**
* Returns a short identifiable name of this output.
*/
virtual QString name() const = 0;
/**
* Returns the identifying uuid of this output.
*
* Default implementation returns an empty byte array.
*/
virtual QByteArray uuid() const;
/**
* Enable or disable the output.
*
* Default implementation does nothing
*/
virtual void setEnabled(bool enable);
/**
* This sets the changes and tests them against the specific output.
*
* Default implementation does nothing
*/
virtual void applyChanges(const KWaylandServer::OutputChangeSet *changeSet);
/**
* Returns geometry of this output in device independent pixels.
*/
virtual QRect geometry() const = 0;
/**
* Returns the approximate vertical refresh rate of this output, in mHz.
*/
virtual int refreshRate() const = 0;
/**
* Returns whether this output is connected through an internal connector,
* e.g. LVDS, or eDP.
*
* Default implementation returns @c false.
*/
virtual bool isInternal() const;
/**
* Returns the ratio between physical pixels and logical pixels.
*
* Default implementation returns 1.
*/
virtual qreal scale() const;
/**
* Returns the physical size of this output, in millimeters.
*
* Default implementation returns an invalid QSize.
*/
virtual QSize physicalSize() const;
/**
* Returns the size of the gamma lookup table.
*
* Default implementation returns 0.
*/
virtual int gammaRampSize() const;
/**
* Sets the gamma ramp of this output.
*
* Returns @c true if the gamma ramp was successfully set.
*/
virtual bool setGammaRamp(const GammaRamp &gamma);
/** Returns the resolution of the output. */
virtual QSize pixelSize() const = 0;
Q_SIGNALS:
/**
* This signal is emitted when the geometry of this output has changed.
*/
void geometryChanged();
private:
Q_DISABLE_COPY(AbstractOutput)
};
} // namespace KWin
#endif

356
abstract_wayland_output.cpp Normal file
View File

@ -0,0 +1,356 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "abstract_wayland_output.h"
#include "screens.h"
#include "wayland_server.h"
// KWayland
#include <KWaylandServer/display.h>
#include <KWaylandServer/outputchangeset.h>
#include <KWaylandServer/xdgoutput_v1_interface.h>
// KF5
#include <KLocalizedString>
#include <QMatrix4x4>
#include <cmath>
namespace KWin
{
AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent)
: AbstractOutput(parent)
{
m_waylandOutput = waylandServer()->display()->createOutput(this);
m_waylandOutputDevice = waylandServer()->display()->createOutputDevice(this);
m_xdgOutputV1 = waylandServer()->xdgOutputManagerV1()->createXdgOutput(m_waylandOutput, this);
connect(m_waylandOutput, &KWaylandServer::OutputInterface::dpmsModeRequested, this,
[this] (KWaylandServer::OutputInterface::DpmsMode mode) {
updateDpms(mode);
});
connect(m_waylandOutput, &KWaylandServer::OutputInterface::globalPositionChanged, this, &AbstractWaylandOutput::geometryChanged);
connect(m_waylandOutput, &KWaylandServer::OutputInterface::pixelSizeChanged, this, &AbstractWaylandOutput::geometryChanged);
connect(m_waylandOutput, &KWaylandServer::OutputInterface::scaleChanged, this, &AbstractWaylandOutput::geometryChanged);
}
AbstractWaylandOutput::~AbstractWaylandOutput()
{
}
QString AbstractWaylandOutput::name() const
{
return m_name;
}
QByteArray AbstractWaylandOutput::uuid() const
{
return m_waylandOutputDevice->uuid();
}
QRect AbstractWaylandOutput::geometry() const
{
return QRect(globalPos(), pixelSize() / scale());
}
QSize AbstractWaylandOutput::physicalSize() const
{
return orientateSize(m_waylandOutputDevice->physicalSize());
}
int AbstractWaylandOutput::refreshRate() const
{
return m_waylandOutputDevice->refreshRate();
}
QPoint AbstractWaylandOutput::globalPos() const
{
return m_waylandOutputDevice->globalPosition();
}
void AbstractWaylandOutput::setGlobalPos(const QPoint &pos)
{
m_waylandOutputDevice->setGlobalPosition(pos);
m_waylandOutput->setGlobalPosition(pos);
m_xdgOutputV1->setLogicalPosition(pos);
m_xdgOutputV1->done();
}
QSize AbstractWaylandOutput::modeSize() const
{
return m_waylandOutputDevice->pixelSize();
}
QSize AbstractWaylandOutput::pixelSize() const
{
return orientateSize(m_waylandOutputDevice->pixelSize());
}
qreal AbstractWaylandOutput::scale() const
{
return m_waylandOutputDevice->scaleF();
}
void AbstractWaylandOutput::setScale(qreal scale)
{
m_waylandOutputDevice->setScaleF(scale);
// this is the scale that clients will ideally use for their buffers
// this has to be an int which is fine
// I don't know whether we want to round or ceil
// or maybe even set this to 3 when we're scaling to 1.5
// don't treat this like it's chosen deliberately
m_waylandOutput->setScale(std::ceil(scale));
m_xdgOutputV1->setLogicalSize(pixelSize() / scale);
m_xdgOutputV1->done();
}
using DeviceInterface = KWaylandServer::OutputDeviceInterface;
KWaylandServer::OutputInterface::Transform toOutputTransform(DeviceInterface::Transform transform)
{
using Transform = DeviceInterface::Transform;
using OutputTransform = KWaylandServer::OutputInterface::Transform;
switch (transform) {
case Transform::Rotated90:
return OutputTransform::Rotated90;
case Transform::Rotated180:
return OutputTransform::Rotated180;
case Transform::Rotated270:
return OutputTransform::Rotated270;
case Transform::Flipped:
return OutputTransform::Flipped;
case Transform::Flipped90:
return OutputTransform::Flipped90;
case Transform::Flipped180:
return OutputTransform::Flipped180;
case Transform::Flipped270:
return OutputTransform::Flipped270;
default:
return OutputTransform::Normal;
}
}
void AbstractWaylandOutput::setTransform(DeviceInterface::Transform transform)
{
m_waylandOutputDevice->setTransform(transform);
m_waylandOutput->setTransform(toOutputTransform(transform));
m_xdgOutputV1->setLogicalSize(pixelSize() / scale());
m_xdgOutputV1->done();
}
inline
AbstractWaylandOutput::Transform toTransform(DeviceInterface::Transform deviceTransform)
{
return static_cast<AbstractWaylandOutput::Transform>(deviceTransform);
}
inline
DeviceInterface::Transform toDeviceTransform(AbstractWaylandOutput::Transform transform)
{
return static_cast<DeviceInterface::Transform>(transform);
}
void AbstractWaylandOutput::applyChanges(const KWaylandServer::OutputChangeSet *changeSet)
{
qCDebug(KWIN_CORE) << "Apply changes to the Wayland output.";
bool emitModeChanged = false;
bool overallSizeCheckNeeded = false;
// Enablement changes are handled by platform.
if (changeSet->modeChanged()) {
qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode();
m_waylandOutputDevice->setCurrentMode(changeSet->mode());
updateMode(changeSet->mode());
emitModeChanged = true;
}
if (changeSet->transformChanged()) {
qCDebug(KWIN_CORE) << "Server setting transform: " << (int)(changeSet->transform());
setTransform(changeSet->transform());
updateTransform(toTransform(changeSet->transform()));
emitModeChanged = true;
}
if (changeSet->positionChanged()) {
qCDebug(KWIN_CORE) << "Server setting position: " << changeSet->position();
setGlobalPos(changeSet->position());
// may just work already!
overallSizeCheckNeeded = true;
}
if (changeSet->scaleChanged()) {
qCDebug(KWIN_CORE) << "Setting scale:" << changeSet->scaleF();
setScale(changeSet->scaleF());
emitModeChanged = true;
}
overallSizeCheckNeeded |= emitModeChanged;
if (overallSizeCheckNeeded) {
emit screens()->changed();
}
if (emitModeChanged) {
emit modeChanged();
}
}
bool AbstractWaylandOutput::isEnabled() const
{
return m_waylandOutputDevice->enabled() == DeviceInterface::Enablement::Enabled;
}
void AbstractWaylandOutput::setEnabled(bool enable)
{
if (enable == isEnabled()) {
return;
}
if (enable) {
m_waylandOutputDevice->setEnabled(DeviceInterface::Enablement::Enabled);
m_waylandOutput->create();
updateEnablement(true);
} else {
m_waylandOutputDevice->setEnabled(DeviceInterface::Enablement::Disabled);
m_waylandOutput->destroy();
// xdg-output is destroyed in KWayland on wl_output going away.
updateEnablement(false);
}
}
QString AbstractWaylandOutput::description() const
{
return QStringLiteral("%1 %2").arg(m_waylandOutputDevice->manufacturer()).arg(
m_waylandOutputDevice->model());
}
void AbstractWaylandOutput::setWaylandMode(const QSize &size, int refreshRate)
{
m_waylandOutput->setCurrentMode(size, refreshRate);
m_xdgOutputV1->setLogicalSize(pixelSize() / scale());
m_xdgOutputV1->done();
}
void AbstractWaylandOutput::initInterfaces(const QString &model, const QString &manufacturer,
const QByteArray &uuid, const QSize &physicalSize,
const QVector<DeviceInterface::Mode> &modes)
{
m_waylandOutputDevice->setUuid(uuid);
if (!manufacturer.isEmpty()) {
m_waylandOutputDevice->setManufacturer(manufacturer);
} else {
m_waylandOutputDevice->setManufacturer(i18n("unknown"));
}
m_waylandOutputDevice->setModel(model);
m_waylandOutputDevice->setPhysicalSize(physicalSize);
m_waylandOutput->setManufacturer(m_waylandOutputDevice->manufacturer());
m_waylandOutput->setModel(m_waylandOutputDevice->model());
m_waylandOutput->setPhysicalSize(m_waylandOutputDevice->physicalSize());
int i = 0;
for (auto mode : modes) {
qCDebug(KWIN_CORE).nospace() << "Adding mode " << ++i << ": " << mode.size << " [" << mode.refreshRate << "]";
m_waylandOutputDevice->addMode(mode);
KWaylandServer::OutputInterface::ModeFlags flags;
if (mode.flags & DeviceInterface::ModeFlag::Current) {
flags |= KWaylandServer::OutputInterface::ModeFlag::Current;
}
if (mode.flags & DeviceInterface::ModeFlag::Preferred) {
flags |= KWaylandServer::OutputInterface::ModeFlag::Preferred;
}
m_waylandOutput->addMode(mode.size, flags, mode.refreshRate);
}
m_waylandOutputDevice->create();
// start off enabled
m_waylandOutput->create();
m_xdgOutputV1->setName(name());
m_xdgOutputV1->setDescription(description());
m_xdgOutputV1->setLogicalSize(pixelSize() / scale());
m_xdgOutputV1->done();
}
QSize AbstractWaylandOutput::orientateSize(const QSize &size) const
{
using Transform = DeviceInterface::Transform;
const Transform transform = m_waylandOutputDevice->transform();
if (transform == Transform::Rotated90 || transform == Transform::Rotated270 ||
transform == Transform::Flipped90 || transform == Transform::Flipped270) {
return size.transposed();
}
return size;
}
void AbstractWaylandOutput::setTransform(Transform transform)
{
const auto deviceTransform = toDeviceTransform(transform);
if (deviceTransform == m_waylandOutputDevice->transform()) {
return;
}
setTransform(deviceTransform);
emit modeChanged();
}
AbstractWaylandOutput::Transform AbstractWaylandOutput::transform() const
{
return static_cast<Transform>(m_waylandOutputDevice->transform());
}
// TODO: Do we need to handle the flipped cases differently?
int transformToRotation(AbstractWaylandOutput::Transform transform)
{
switch (transform) {
case AbstractWaylandOutput::Transform::Normal:
case AbstractWaylandOutput::Transform::Flipped:
return 0;
case AbstractWaylandOutput::Transform::Rotated90:
case AbstractWaylandOutput::Transform::Flipped90:
return 90;
case AbstractWaylandOutput::Transform::Rotated180:
case AbstractWaylandOutput::Transform::Flipped180:
return 180;
case AbstractWaylandOutput::Transform::Rotated270:
case AbstractWaylandOutput::Transform::Flipped270:
return 270;
}
Q_UNREACHABLE();
return 0;
}
int AbstractWaylandOutput::rotation() const
{
return transformToRotation(transform());
}
QMatrix4x4 AbstractWaylandOutput::transformation() const
{
const QSize outputSize = modeSize();
const QSize logicalSize = pixelSize();
QMatrix4x4 matrix;
matrix.translate(outputSize.width()/2, outputSize.height()/2);
matrix.rotate(rotation(), 0, 0, 1);
matrix.translate(-logicalSize.width()/2, -logicalSize.height()/2);
matrix.scale(scale());
const QPoint topLeft = -globalPos();
matrix.translate(-topLeft.x(), -topLeft.y());
return matrix;
}
}

183
abstract_wayland_output.h Normal file
View File

@ -0,0 +1,183 @@
/*
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
*/
#ifndef KWIN_ABSTRACT_WAYLAND_OUTPUT_H
#define KWIN_ABSTRACT_WAYLAND_OUTPUT_H
#include "abstract_output.h"
#include "utils.h"
#include <kwin_export.h>
#include <QObject>
#include <QPoint>
#include <QPointer>
#include <QRect>
#include <QSize>
#include <QVector>
#include <KWaylandServer/output_interface.h>
#include <KWaylandServer/outputdevice_interface.h>
namespace KWaylandServer
{
class OutputInterface;
class OutputDeviceInterface;
class OutputChangeSet;
class OutputManagementInterface;
class XdgOutputV1Interface;
}
namespace KWin
{
/**
* Generic output representation in a Wayland session
*/
class KWIN_EXPORT AbstractWaylandOutput : public AbstractOutput
{
Q_OBJECT
public:
enum class Transform {
Normal,
Rotated90,
Rotated180,
Rotated270,
Flipped,
Flipped90,
Flipped180,
Flipped270
};
explicit AbstractWaylandOutput(QObject *parent = nullptr);
~AbstractWaylandOutput() override;
QString name() const override;
QByteArray uuid() const override;
QSize modeSize() const;
// TODO: The name is ambiguous. Rename this function.
QSize pixelSize() const override;
qreal scale() const override;
/**
* The geometry of this output in global compositor co-ordinates (i.e scaled)
*/
QRect geometry() const override;
QSize physicalSize() const override;
/**
* Returns the orientation of this output.
*
* - Flipped along the vertical axis is landscape + inv. portrait.
* - Rotated 90° and flipped along the horizontal axis is portrait + inv. landscape
* - Rotated 180° and flipped along the vertical axis is inv. landscape + inv. portrait
* - Rotated 270° and flipped along the horizontal axis is inv. portrait + inv. landscape +
* portrait
*/
Transform transform() const;
/**
* Current refresh rate in 1/ms.
*/
int refreshRate() const override;
bool isInternal() const override {
return m_internal;
}
void setGlobalPos(const QPoint &pos);
void setScale(qreal scale);
void applyChanges(const KWaylandServer::OutputChangeSet *changeSet) override;
QPointer<KWaylandServer::OutputInterface> waylandOutput() const {
return m_waylandOutput;
}
bool isEnabled() const;
/**
* Enable or disable the output.
*
* This differs from updateDpms as it also removes the wl_output.
* The default is on.
*/
void setEnabled(bool enable) override;
QString description() const;
/**
* The current rotation of the output
*
* @return rotation in degrees
*/
int rotation() const;
/**
* Returns a matrix that can translate into the display's coordinates system
*/
QMatrix4x4 transformation() const;
Q_SIGNALS:
void modeChanged();
void outputChange(const QRegion &damagedRegion);
protected:
void initInterfaces(const QString &model, const QString &manufacturer,
const QByteArray &uuid, const QSize &physicalSize,
const QVector<KWaylandServer::OutputDeviceInterface::Mode> &modes);
QPoint globalPos() const;
bool internal() const {
return m_internal;
}
void setName(const QString &name) {
m_name = name;
}
void setInternal(bool set) {
m_internal = set;
}
void setDpmsSupported(bool set) {
m_waylandOutput->setDpmsSupported(set);
}
virtual void updateEnablement(bool enable) {
Q_UNUSED(enable);
}
virtual void updateDpms(KWaylandServer::OutputInterface::DpmsMode mode) {
Q_UNUSED(mode);
}
virtual void updateMode(int modeIndex) {
Q_UNUSED(modeIndex);
}
virtual void updateTransform(Transform transform) {
Q_UNUSED(transform);
}
void setWaylandMode(const QSize &size, int refreshRate);
void setTransform(Transform transform);
QSize orientateSize(const QSize &size) const;
private:
void setTransform(KWaylandServer::OutputDeviceInterface::Transform transform);
KWaylandServer::OutputInterface *m_waylandOutput;
KWaylandServer::XdgOutputV1Interface *m_xdgOutputV1;
KWaylandServer::OutputDeviceInterface *m_waylandOutputDevice;
KWaylandServer::OutputInterface::DpmsMode m_dpms = KWaylandServer::OutputInterface::DpmsMode::On;
QString m_name;
bool m_internal = false;
};
}
#endif // KWIN_OUTPUT_H

881
activation.cpp Normal file
View File

@ -0,0 +1,881 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
This file contains things relevant to window activation and focus
stealing prevention.
*/
#include "x11client.h"
#include "cursor.h"
#include "focuschain.h"
#include "netinfo.h"
#include "workspace.h"
#ifdef KWIN_BUILD_ACTIVITIES
#include "activities.h"
#endif
#include <kstartupinfo.h>
#include <kstringhandler.h>
#include <KLocalizedString>
#include "atoms.h"
#include "group.h"
#include "rules.h"
#include "screens.h"
#include "useractions.h"
#include <QDebug>
namespace KWin
{
/*
Prevention of focus stealing:
KWin tries to prevent unwanted changes of focus, that would result
from mapping a new window. Also, some nasty applications may try
to force focus change even in cases when ICCCM 4.2.7 doesn't allow it
(e.g. they may try to activate their main window because the user
definitely "needs" to see something happened - misusing
of QWidget::setActiveWindow() may be such case).
There are 4 ways how a window may become active:
- the user changes the active window (e.g. focus follows mouse, clicking
on some window's titlebar) - the change of focus will
be done by KWin, so there's nothing to solve in this case
- the change of active window will be requested using the _NET_ACTIVE_WINDOW
message (handled in RootInfo::changeActiveWindow()) - such requests
will be obeyed, because this request is meant mainly for e.g. taskbar
asking the WM to change the active window as a result of some user action.
Normal applications should use this request only rarely in special cases.
See also below the discussion of _NET_ACTIVE_WINDOW_TRANSFER.
- the change of active window will be done by performing XSetInputFocus()
on a window that's not currently active. ICCCM 4.2.7 describes when
the application may perform change of input focus. In order to handle
misbehaving applications, KWin will try to detect focus changes to
windows that don't belong to currently active application, and restore
focus back to the currently active window, instead of activating the window
that got focus (unfortunately there's no way to FocusChangeRedirect similar
to e.g. SubstructureRedirect, so there will be short time when the focus
will be changed). The check itself that's done is
Workspace::allowClientActivation() (see below).
- a new window will be mapped - this is the most complicated case. If
the new window belongs to the currently active application, it may be safely
mapped on top and activated. The same if there's no active window,
or the active window is the desktop. These checks are done by
Workspace::allowClientActivation().
Following checks need to compare times. One time is the timestamp
of last user action in the currently active window, the other time is
the timestamp of the action that originally caused mapping of the new window
(e.g. when the application was started). If the first time is newer than
the second one, the window will not be activated, as that indicates
futher user actions took place after the action leading to this new
mapped window. This check is done by Workspace::allowClientActivation().
There are several ways how to get the timestamp of action that caused
the new mapped window (done in X11Client::readUserTimeMapTimestamp()) :
- the window may have the _NET_WM_USER_TIME property. This way
the application may either explicitly request that the window is not
activated (by using 0 timestamp), or the property contains the time
of last user action in the application.
- KWin itself tries to detect time of last user action in every window,
by watching KeyPress and ButtonPress events on windows. This way some
events may be missed (if they don't propagate to the toplevel window),
but it's good as a fallback for applications that don't provide
_NET_WM_USER_TIME, and missing some events may at most lead
to unwanted focus stealing.
- the timestamp may come from application startup notification.
Application startup notification, if it exists for the new mapped window,
should include time of the user action that caused it.
- if there's no timestamp available, it's checked whether the new window
belongs to some already running application - if yes, the timestamp
will be 0 (i.e. refuse activation)
- if the window is from session restored window, the timestamp will
be 0 too, unless this application was the active one at the time
when the session was saved, in which case the window will be
activated if there wasn't any user interaction since the time
KWin was started.
- as the last resort, the _KDE_NET_USER_CREATION_TIME timestamp
is used. For every toplevel window that is created (see CreateNotify
handling), this property is set to the at that time current time.
Since at this time it's known that the new window doesn't belong
to any existing application (better said, the application doesn't
have any other window mapped), it is either the very first window
of the application, or it is the only window of the application
that was hidden before. The latter case is handled by removing
the property from windows before withdrawing them, making
the timestamp empty for next mapping of the window. In the sooner
case, the timestamp will be used. This helps in case when
an application is launched without application startup notification,
it creates its mainwindow, and starts its initialization (that
may possibly take long time). The timestamp used will be older
than any user action done after launching this application.
- if no timestamp is found at all, the window is activated.
The check whether two windows belong to the same application (same
process) is done in X11Client::belongToSameApplication(). Not 100% reliable,
but hopefully 99,99% reliable.
As a somewhat special case, window activation is always enabled when
session saving is in progress. When session saving, the session
manager allows only one application to interact with the user.
Not allowing window activation in such case would result in e.g. dialogs
not becoming active, so focus stealing prevention would cause here
more harm than good.
Windows that attempted to become active but KWin prevented this will
be marked as demanding user attention. They'll get
the _NET_WM_STATE_DEMANDS_ATTENTION state, and the taskbar should mark
them specially (blink, etc.). The state will be reset when the window
eventually really becomes active.
There are two more ways how a window can become obtrusive, window stealing
focus: By showing above the active window, by either raising itself,
or by moving itself on the active desktop.
- KWin will refuse raising non-active window above the active one,
unless they belong to the same application. Applications shouldn't
raise their windows anyway (unless the app wants to raise one
of its windows above another of its windows).
- KWin activates windows moved to the current desktop (as that seems
logical from the user's point of view, after sending the window
there directly from KWin, or e.g. using pager). This means
applications shouldn't send their windows to another desktop
(SELI TODO - but what if they do?)
Special cases I can think of:
- konqueror reusing, i.e. kfmclient tells running Konqueror instance
to open new window
- without focus stealing prevention - no problem
- with ASN (application startup notification) - ASN is forwarded,
and because it's newer than the instance's user timestamp,
it takes precedence
- without ASN - user timestamp needs to be reset, otherwise it would
be used, and it's old; moreover this new window mustn't be detected
as window belonging to already running application, or it wouldn't
be activated - see X11Client::sameAppWindowRoleMatch() for the (rather ugly)
hack
- konqueror preloading, i.e. window is created in advance, and kfmclient
tells this Konqueror instance to show it later
- without focus stealing prevention - no problem
- with ASN - ASN is forwarded, and because it's newer than the instance's
user timestamp, it takes precedence
- without ASN - user timestamp needs to be reset, otherwise it would
be used, and it's old; also, creation timestamp is changed to
the time the instance starts (re-)initializing the window,
this ensures creation timestamp will still work somewhat even in this case
- KUniqueApplication - when the window is already visible, and the new instance
wants it to activate
- without focus stealing prevention - _NET_ACTIVE_WINDOW - no problem
- with ASN - ASN is forwarded, and set on the already visible window, KWin
treats the window as new with that ASN
- without ASN - _NET_ACTIVE_WINDOW as application request is used,
and there's no really usable timestamp, only timestamp
from the time the (new) application instance was started,
so KWin will activate the window *sigh*
- the bad thing here is that there's absolutely no chance to recognize
the case of starting this KUniqueApp from Konsole (and thus wanting
the already visible window to become active) from the case
when something started this KUniqueApp without ASN (in which case
the already visible window shouldn't become active)
- the only solution is using ASN for starting applications, at least silent
(i.e. without feedback)
- when one application wants to activate another application's window (e.g. KMail
activating already running KAddressBook window ?)
- without focus stealing prevention - _NET_ACTIVE_WINDOW - no problem
- with ASN - can't be here, it's the KUniqueApp case then
- without ASN - _NET_ACTIVE_WINDOW as application request should be used,
KWin will activate the new window depending on the timestamp and
whether it belongs to the currently active application
_NET_ACTIVE_WINDOW usage:
data.l[0]= 1 ->app request
= 2 ->pager request
= 0 - backwards compatibility
data.l[1]= timestamp
*/
//****************************************
// Workspace
//****************************************
/**
* Informs the workspace about the active client, i.e. the client that
* has the focus (or None if no client has the focus). This functions
* is called by the client itself that gets focus. It has no other
* effect than fixing the focus chain and the return value of
* activeClient(). And of course, to propagate the active client to the
* world.
*/
void Workspace::setActiveClient(AbstractClient* c)
{
if (active_client == c)
return;
if (active_popup && active_popup_client != c && set_active_client_recursion == 0)
closeActivePopup();
if (m_userActionsMenu->hasClient() && !m_userActionsMenu->isMenuClient(c) && set_active_client_recursion == 0) {
m_userActionsMenu->close();
}
StackingUpdatesBlocker blocker(this);
++set_active_client_recursion;
updateFocusMousePosition(Cursors::self()->mouse()->pos());
if (active_client != nullptr) {
// note that this may call setActiveClient( NULL ), therefore the recursion counter
active_client->setActive(false);
}
active_client = c;
Q_ASSERT(c == nullptr || c->isActive());
if (active_client) {
last_active_client = active_client;
FocusChain::self()->update(active_client, FocusChain::MakeFirst);
active_client->demandAttention(false);
// activating a client can cause a non active fullscreen window to loose the ActiveLayer status on > 1 screens
if (screens()->count() > 1) {
for (auto it = m_allClients.begin(); it != m_allClients.end(); ++it) {
if (*it != active_client && (*it)->layer() == ActiveLayer && (*it)->screen() == active_client->screen()) {
updateClientLayer(*it);
}
}
}
}
updateToolWindows(false);
if (c)
disableGlobalShortcutsForClient(c->rules()->checkDisableGlobalShortcuts(false));
else
disableGlobalShortcutsForClient(false);
updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active
if (rootInfo()) {
rootInfo()->setActiveClient(active_client);
}
emit clientActivated(active_client);
--set_active_client_recursion;
}
/**
* Tries to activate the client \a c. This function performs what you
* expect when clicking the respective entry in a taskbar: showing and
* raising the client (this may imply switching to the another virtual
* desktop) and putting the focus onto it. Once X really gave focus to
* the client window as requested, the client itself will call
* setActiveClient() and the operation is complete. This may not happen
* with certain focus policies, though.
*
* @see setActiveClient
* @see requestFocus
*/
void Workspace::activateClient(AbstractClient* c, bool force)
{
if (c == nullptr) {
focusToNull();
setActiveClient(nullptr);
return;
}
raiseClient(c);
if (!c->isOnCurrentDesktop()) {
++block_focus;
VirtualDesktopManager::self()->setCurrent(c->desktop());
--block_focus;
}
#ifdef KWIN_BUILD_ACTIVITIES
if (!c->isOnCurrentActivity()) {
++block_focus;
//DBUS!
Activities::self()->setCurrent(c->activities().first()); //first isn't necessarily best, but it's easiest
--block_focus;
}
#endif
if (c->isMinimized())
c->unminimize();
// ensure the window is really visible - could eg. be a hidden utility window, see bug #348083
c->hideClient(false);
// TODO force should perhaps allow this only if the window already contains the mouse
if (options->focusPolicyIsReasonable() || force)
requestFocus(c, force);
// Don't update user time for clients that have focus stealing workaround.
// As they usually belong to the current active window but fail to provide
// this information, updating their user time would make the user time
// of the currently active window old, and reject further activation for it.
// E.g. typing URL in minicli which will show kio_uiserver dialog (with workaround),
// and then kdesktop shows dialog about SSL certificate.
// This needs also avoiding user creation time in X11Client::readUserTimeMapTimestamp().
if (X11Client *client = dynamic_cast<X11Client *>(c)) {
// updateUserTime is X11 specific
client->updateUserTime();
}
}
/**
* Tries to activate the client by asking X for the input focus. This
* function does not perform any show, raise or desktop switching. See
* Workspace::activateClient() instead.
*
* @see activateClient
*/
bool Workspace::requestFocus(AbstractClient* c, bool force)
{
return takeActivity(c, force ? ActivityFocusForce : ActivityFocus);
}
bool Workspace::takeActivity(AbstractClient* c, ActivityFlags flags)
{
// the 'if ( c == active_client ) return;' optimization mustn't be done here
if (!focusChangeEnabled() && (c != active_client))
flags &= ~ActivityFocus;
if (!c) {
focusToNull();
return true;
}
if (flags & ActivityFocus) {
AbstractClient* modal = c->findModal();
if (modal != nullptr && modal != c) {
if (!modal->isOnDesktop(c->desktop()))
modal->setDesktop(c->desktop());
if (!modal->isShown(true) && !modal->isMinimized()) // forced desktop or utility window
activateClient(modal); // activating a minimized blocked window will unminimize its modal implicitly
// if the click was inside the window (i.e. handled is set),
// but it has a modal, there's no need to use handled mode, because
// the modal doesn't get the click anyway
// raising of the original window needs to be still done
if (flags & ActivityRaise)
raiseClient(c);
c = modal;
}
cancelDelayFocus();
}
if (!flags.testFlag(ActivityFocusForce) && (c->isDock() || c->isSplash())) {
// toplevel menus and dock windows don't take focus if not forced
// and don't have a flag that they take focus
if (!c->dockWantsInput()) {
flags &= ~ActivityFocus;
}
}
if (c->isShade()) {
if (c->wantsInput() && (flags & ActivityFocus)) {
// client cannot accept focus, but at least the window should be active (window menu, et. al. )
c->setActive(true);
focusToNull();
}
flags &= ~ActivityFocus;
}
if (!c->isShown(true)) { // shouldn't happen, call activateClient() if needed
qCWarning(KWIN_CORE) << "takeActivity: not shown" ;
return false;
}
bool ret = true;
if (flags & ActivityFocus)
ret &= c->takeFocus();
if (flags & ActivityRaise)
workspace()->raiseClient(c);
if (!c->isOnActiveScreen())
screens()->setCurrent(c->screen());
return ret;
}
/**
* Informs the workspace that the client \a c has been hidden. If it
* was the active client (or to-become the active client),
* the workspace activates another one.
*
* @note @p c may already be destroyed.
*/
void Workspace::clientHidden(AbstractClient* c)
{
Q_ASSERT(!c->isShown(true) || !c->isOnCurrentDesktop() || !c->isOnCurrentActivity());
activateNextClient(c);
}
AbstractClient *Workspace::clientUnderMouse(int screen) const
{
auto it = stackingOrder().constEnd();
while (it != stackingOrder().constBegin()) {
AbstractClient *client = qobject_cast<AbstractClient*>(*(--it));
if (!client) {
continue;
}
// rule out clients which are not really visible.
// the screen test is rather superfluous for xrandr & twinview since the geometry would differ -> TODO: might be dropped
if (!(client->isShown(false) && client->isOnCurrentDesktop() &&
client->isOnCurrentActivity() && client->isOnScreen(screen)))
continue;
if (client->frameGeometry().contains(Cursors::self()->mouse()->pos())) {
return client;
}
}
return nullptr;
}
// deactivates 'c' and activates next client
bool Workspace::activateNextClient(AbstractClient* c)
{
// if 'c' is not the active or the to-become active one, do nothing
if (!(c == active_client || (should_get_focus.count() > 0 && c == should_get_focus.last())))
return false;
closeActivePopup();
if (c != nullptr) {
if (c == active_client)
setActiveClient(nullptr);
should_get_focus.removeAll(c);
}
// if blocking focus, move focus to the desktop later if needed
// in order to avoid flickering
if (!focusChangeEnabled()) {
focusToNull();
return true;
}
if (!options->focusPolicyIsReasonable())
return false;
AbstractClient* get_focus = nullptr;
const int desktop = VirtualDesktopManager::self()->current();
if (!get_focus && showingDesktop())
get_focus = findDesktop(true, desktop); // to not break the state
if (!get_focus && options->isNextFocusPrefersMouse()) {
get_focus = clientUnderMouse(c ? c->screen() : screens()->current());
if (get_focus && (get_focus == c || get_focus->isDesktop())) {
// should rather not happen, but it cannot get the focus. rest of usability is tested above
get_focus = nullptr;
}
}
if (!get_focus) { // no suitable window under the mouse -> find sth. else
// first try to pass the focus to the (former) active clients leader
if (c && c->isTransient()) {
auto leaders = c->mainClients();
if (leaders.count() == 1 && FocusChain::self()->isUsableFocusCandidate(leaders.at(0), c)) {
get_focus = leaders.at(0);
raiseClient(get_focus); // also raise - we don't know where it came from
}
}
if (!get_focus) {
// nope, ask the focus chain for the next candidate
get_focus = FocusChain::self()->nextForDesktop(c, desktop);
}
}
if (get_focus == nullptr) // last chance: focus the desktop
get_focus = findDesktop(true, desktop);
if (get_focus != nullptr)
requestFocus(get_focus);
else
focusToNull();
return true;
}
void Workspace::setCurrentScreen(int new_screen)
{
if (new_screen < 0 || new_screen >= screens()->count())
return;
if (!options->focusPolicyIsReasonable())
return;
closeActivePopup();
const int desktop = VirtualDesktopManager::self()->current();
AbstractClient *get_focus = FocusChain::self()->getForActivation(desktop, new_screen);
if (get_focus == nullptr)
get_focus = findDesktop(true, desktop);
if (get_focus != nullptr && get_focus != mostRecentlyActivatedClient())
requestFocus(get_focus);
screens()->setCurrent(new_screen);
}
void Workspace::gotFocusIn(const AbstractClient* c)
{
if (should_get_focus.contains(const_cast< AbstractClient* >(c))) {
// remove also all sooner elements that should have got FocusIn,
// but didn't for some reason (and also won't anymore, because they were sooner)
while (should_get_focus.first() != c)
should_get_focus.pop_front();
should_get_focus.pop_front(); // remove 'c'
}
}
void Workspace::setShouldGetFocus(AbstractClient* c)
{
should_get_focus.append(c);
updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active
}
namespace FSP {
enum Level { None = 0, Low, Medium, High, Extreme };
}
// focus_in -> the window got FocusIn event
// ignore_desktop - call comes from _NET_ACTIVE_WINDOW message, don't refuse just because of window
// is on a different desktop
bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timestamp_t time, bool focus_in, bool ignore_desktop)
{
// options->focusStealingPreventionLevel :
// 0 - none - old KWin behaviour, new windows always get focus
// 1 - low - focus stealing prevention is applied normally, when unsure, activation is allowed
// 2 - normal - focus stealing prevention is applied normally, when unsure, activation is not allowed,
// this is the default
// 3 - high - new window gets focus only if it belongs to the active application,
// or when no window is currently active
// 4 - extreme - no window gets focus without user intervention
if (time == -1U)
time = c->userTime();
int level = c->rules()->checkFSP(options->focusStealingPreventionLevel());
if (sessionManager()->state() == SessionState::Saving && level <= FSP::Medium) { // <= normal
return true;
}
AbstractClient* ac = mostRecentlyActivatedClient();
if (focus_in) {
if (should_get_focus.contains(const_cast< AbstractClient* >(c)))
return true; // FocusIn was result of KWin's action
// Before getting FocusIn, the active Client already
// got FocusOut, and therefore got deactivated.
ac = last_active_client;
}
if (time == 0) { // explicitly asked not to get focus
if (!c->rules()->checkAcceptFocus(false))
return false;
}
const int protection = ac ? ac->rules()->checkFPP(2) : 0;
// stealing is unconditionally allowed (NETWM behavior)
if (level == FSP::None || protection == FSP::None)
return true;
// The active client "grabs" the focus or stealing is generally forbidden
if (level == FSP::Extreme || protection == FSP::Extreme)
return false;
// Desktop switching is only allowed in the "no protection" case
if (!ignore_desktop && !c->isOnCurrentDesktop())
return false; // allow only with level == 0
// No active client, it's ok to pass focus
// NOTICE that extreme protection needs to be handled before to allow protection on unmanged windows
if (ac == nullptr || ac->isDesktop()) {
qCDebug(KWIN_CORE) << "Activation: No client active, allowing";
return true; // no active client -> always allow
}
// TODO window urgency -> return true?
// Unconditionally allow intra-client passing around for lower stealing protections
// unless the active client has High interest
if (AbstractClient::belongToSameApplication(c, ac, AbstractClient::SameApplicationCheck::RelaxedForActive) && protection < FSP::High) {
qCDebug(KWIN_CORE) << "Activation: Belongs to active application";
return true;
}
if (!c->isOnCurrentDesktop()) // we allowed explicit self-activation across virtual desktops
return false; // inside a client or if no client was active, but not otherwise
// High FPS, not intr-client change. Only allow if the active client has only minor interest
if (level > FSP::Medium && protection > FSP::Low)
return false;
if (time == -1U) { // no time known
qCDebug(KWIN_CORE) << "Activation: No timestamp at all";
// Only allow for Low protection unless active client has High interest in focus
if (level < FSP::Medium && protection < FSP::High)
return true;
// no timestamp at all, don't activate - because there's also creation timestamp
// done on CreateNotify, this case should happen only in case application
// maps again already used window, i.e. this won't happen after app startup
return false;
}
// Low or medium FSP, usertime comparism is possible
const xcb_timestamp_t user_time = ac->userTime();
qCDebug(KWIN_CORE) << "Activation, compared:" << c << ":" << time << ":" << user_time
<< ":" << (NET::timestampCompare(time, user_time) >= 0);
return NET::timestampCompare(time, user_time) >= 0; // time >= user_time
}
// basically the same like allowClientActivation(), this time allowing
// a window to be fully raised upon its own request (XRaiseWindow),
// if refused, it will be raised only on top of windows belonging
// to the same application
bool Workspace::allowFullClientRaising(const KWin::AbstractClient *c, xcb_timestamp_t time)
{
int level = c->rules()->checkFSP(options->focusStealingPreventionLevel());
if (sessionManager()->state() == SessionState::Saving && level <= 2) { // <= normal
return true;
}
AbstractClient* ac = mostRecentlyActivatedClient();
if (level == 0) // none
return true;
if (level == 4) // extreme
return false;
if (ac == nullptr || ac->isDesktop()) {
qCDebug(KWIN_CORE) << "Raising: No client active, allowing";
return true; // no active client -> always allow
}
// TODO window urgency -> return true?
if (AbstractClient::belongToSameApplication(c, ac, AbstractClient::SameApplicationCheck::RelaxedForActive)) {
qCDebug(KWIN_CORE) << "Raising: Belongs to active application";
return true;
}
if (level == 3) // high
return false;
xcb_timestamp_t user_time = ac->userTime();
qCDebug(KWIN_CORE) << "Raising, compared:" << time << ":" << user_time
<< ":" << (NET::timestampCompare(time, user_time) >= 0);
return NET::timestampCompare(time, user_time) >= 0; // time >= user_time
}
/**
* Called from X11Client after FocusIn that wasn't initiated by KWin and the client wasn't
* allowed to activate.
*
* Returns @c true if the focus has been restored successfully; otherwise returns @c false.
*/
bool Workspace::restoreFocus()
{
// this updateXTime() is necessary - as FocusIn events don't have
// a timestamp *sigh*, kwin's timestamp would be older than the timestamp
// that was used by whoever caused the focus change, and therefore
// the attempt to restore the focus would fail due to old timestamp
updateXTime();
if (should_get_focus.count() > 0)
return requestFocus(should_get_focus.last());
else if (last_active_client)
return requestFocus(last_active_client);
return true;
}
void Workspace::clientAttentionChanged(AbstractClient* c, bool set)
{
if (set) {
attention_chain.removeAll(c);
attention_chain.prepend(c);
} else
attention_chain.removeAll(c);
emit clientDemandsAttentionChanged(c, set);
}
//********************************************
// Client
//********************************************
/**
* Updates the user time (time of last action in the active window).
* This is called inside kwin for every action with the window
* that qualifies for user interaction (clicking on it, activate it
* externally, etc.).
*/
void X11Client::updateUserTime(xcb_timestamp_t time)
{
// copied in Group::updateUserTime
if (time == XCB_TIME_CURRENT_TIME) {
updateXTime();
time = xTime();
}
if (time != -1U
&& (m_userTime == XCB_TIME_CURRENT_TIME
|| NET::timestampCompare(time, m_userTime) > 0)) { // time > user_time
m_userTime = time;
shade_below = nullptr; // do not hover re-shade a window after it got interaction
}
group()->updateUserTime(m_userTime);
}
xcb_timestamp_t X11Client::readUserCreationTime() const
{
Xcb::Property prop(false, window(), atoms->kde_net_wm_user_creation_time, XCB_ATOM_CARDINAL, 0, 1);
return prop.value<xcb_timestamp_t>(-1);
}
xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id, const KStartupInfoData *asn_data,
bool session) const
{
xcb_timestamp_t time = info->userTime();
//qDebug() << "User timestamp, initial:" << time;
//^^ this deadlocks kwin --replace sometimes.
// newer ASN timestamp always replaces user timestamp, unless user timestamp is 0
// helps e.g. with konqy reusing
if (asn_data != nullptr && time != 0) {
if (asn_id->timestamp() != 0
&& (time == -1U || NET::timestampCompare(asn_id->timestamp(), time) > 0)) {
time = asn_id->timestamp();
}
}
qCDebug(KWIN_CORE) << "User timestamp, ASN:" << time;
if (time == -1U) {
// The window doesn't have any timestamp.
// If it's the first window for its application
// (i.e. there's no other window from the same app),
// use the _KDE_NET_WM_USER_CREATION_TIME trick.
// Otherwise, refuse activation of a window
// from already running application if this application
// is not the active one (unless focus stealing prevention is turned off).
X11Client *act = dynamic_cast<X11Client *>(workspace()->mostRecentlyActivatedClient());
if (act != nullptr && !belongToSameApplication(act, this, SameApplicationCheck::RelaxedForActive)) {
bool first_window = true;
auto sameApplicationActiveHackPredicate = [this](const X11Client *cl) {
// ignore already existing splashes, toolbars, utilities and menus,
// as the app may show those before the main window
return !cl->isSplash() && !cl->isToolbar() && !cl->isUtility() && !cl->isMenu()
&& cl != this && X11Client::belongToSameApplication(cl, this, SameApplicationCheck::RelaxedForActive);
};
if (isTransient()) {
auto clientMainClients = [this]() {
QList<X11Client *> ret;
const auto mcs = mainClients();
for (auto mc: mcs) {
if (X11Client *c = dynamic_cast<X11Client *>(mc)) {
ret << c;
}
}
return ret;
};
if (act->hasTransient(this, true))
; // is transient for currently active window, even though it's not
// the same app (e.g. kcookiejar dialog) -> allow activation
else if (groupTransient() &&
findInList<X11Client, X11Client>(clientMainClients(), sameApplicationActiveHackPredicate) == nullptr)
; // standalone transient
else
first_window = false;
} else {
if (workspace()->findClient(sameApplicationActiveHackPredicate))
first_window = false;
}
// don't refuse if focus stealing prevention is turned off
if (!first_window && rules()->checkFSP(options->focusStealingPreventionLevel()) > 0) {
qCDebug(KWIN_CORE) << "User timestamp, already exists:" << 0;
return 0; // refuse activation
}
}
// Creation time would just mess things up during session startup,
// as possibly many apps are started up at the same time.
// If there's no active window yet, no timestamp will be needed,
// as plain Workspace::allowClientActivation() will return true
// in such case. And if there's already active window,
// it's better not to activate the new one.
// Unless it was the active window at the time
// of session saving and there was no user interaction yet,
// this check will be done in manage().
if (session)
return -1U;
time = readUserCreationTime();
}
qCDebug(KWIN_CORE) << "User timestamp, final:" << this << ":" << time;
return time;
}
xcb_timestamp_t X11Client::userTime() const
{
xcb_timestamp_t time = m_userTime;
if (time == 0) // doesn't want focus after showing
return 0;
Q_ASSERT(group() != nullptr);
if (time == -1U
|| (group()->userTime() != -1U
&& NET::timestampCompare(group()->userTime(), time) > 0))
time = group()->userTime();
return time;
}
void X11Client::doSetActive()
{
updateUrgency(); // demand attention again if it's still urgent
info->setState(isActive() ? NET::Focused : NET::States(), NET::Focused);
}
void X11Client::startupIdChanged()
{
KStartupInfoId asn_id;
KStartupInfoData asn_data;
bool asn_valid = workspace()->checkStartupNotification(window(), asn_id, asn_data);
if (!asn_valid)
return;
// If the ASN contains desktop, move it to the desktop, otherwise move it to the current
// desktop (since the new ASN should make the window act like if it's a new application
// launched). However don't affect the window's desktop if it's set to be on all desktops.
int desktop = VirtualDesktopManager::self()->current();
if (asn_data.desktop() != 0)
desktop = asn_data.desktop();
if (!isOnAllDesktops())
workspace()->sendClientToDesktop(this, desktop, true);
if (asn_data.xinerama() != -1)
workspace()->sendClientToScreen(this, asn_data.xinerama());
const xcb_timestamp_t timestamp = asn_id.timestamp();
if (timestamp != 0) {
bool activate = workspace()->allowClientActivation(this, timestamp);
if (asn_data.desktop() != 0 && !isOnCurrentDesktop())
activate = false; // it was started on different desktop than current one
if (activate)
workspace()->activateClient(this);
else
demandAttention();
}
}
void X11Client::updateUrgency()
{
if (info->urgency())
demandAttention();
}
//****************************************
// Group
//****************************************
void Group::startupIdChanged()
{
KStartupInfoId asn_id;
KStartupInfoData asn_data;
bool asn_valid = workspace()->checkStartupNotification(leader_wid, asn_id, asn_data);
if (!asn_valid)
return;
if (asn_id.timestamp() != 0 && user_time != -1U
&& NET::timestampCompare(asn_id.timestamp(), user_time) > 0) {
user_time = asn_id.timestamp();
}
}
void Group::updateUserTime(xcb_timestamp_t time)
{
// copy of X11Client::updateUserTime
if (time == XCB_CURRENT_TIME) {
updateXTime();
time = xTime();
}
if (time != -1U
&& (user_time == XCB_CURRENT_TIME
|| NET::timestampCompare(time, user_time) > 0)) // time > user_time
user_time = time;
}
} // namespace

211
activities.cpp Normal file
View File

@ -0,0 +1,211 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "activities.h"
// KWin
#include "x11client.h"
#include "workspace.h"
// KDE
#include <KConfigGroup>
#include <kactivities/controller.h>
// Qt
#include <QtConcurrentRun>
#include <QDBusInterface>
#include <QDBusPendingCall>
#include <QFutureWatcher>
namespace KWin
{
KWIN_SINGLETON_FACTORY(Activities)
Activities::Activities(QObject *parent)
: QObject(parent)
, m_controller(new KActivities::Controller(this))
{
connect(m_controller, &KActivities::Controller::activityRemoved, this, &Activities::slotRemoved);
connect(m_controller, &KActivities::Controller::activityRemoved, this, &Activities::removed);
connect(m_controller, &KActivities::Controller::activityAdded, this, &Activities::added);
connect(m_controller, &KActivities::Controller::currentActivityChanged, this, &Activities::slotCurrentChanged);
}
Activities::~Activities()
{
s_self = nullptr;
}
KActivities::Consumer::ServiceStatus Activities::serviceStatus() const
{
return m_controller->serviceStatus();
}
void Activities::setCurrent(const QString &activity)
{
m_controller->setCurrentActivity(activity);
}
void Activities::slotCurrentChanged(const QString &newActivity)
{
if (m_current == newActivity) {
return;
}
m_previous = m_current;
m_current = newActivity;
emit currentChanged(newActivity);
}
void Activities::slotRemoved(const QString &activity)
{
foreach (X11Client *client, Workspace::self()->clientList()) {
if (client->isDesktop())
continue;
client->setOnActivity(activity, false);
}
//toss out any session data for it
KConfigGroup cg(KSharedConfig::openConfig(), QByteArray("SubSession: ").append(activity.toUtf8()).constData());
cg.deleteGroup();
}
void Activities::toggleClientOnActivity(X11Client *c, const QString &activity, bool dont_activate)
{
//int old_desktop = c->desktop();
bool was_on_activity = c->isOnActivity(activity);
bool was_on_all = c->isOnAllActivities();
//note: all activities === no activities
bool enable = was_on_all || !was_on_activity;
c->setOnActivity(activity, enable);
if (c->isOnActivity(activity) == was_on_activity && c->isOnAllActivities() == was_on_all) // No change
return;
Workspace *ws = Workspace::self();
if (c->isOnCurrentActivity()) {
if (c->wantsTabFocus() && options->focusPolicyIsReasonable() &&
!was_on_activity && // for stickyness changes
//FIXME not sure if the line above refers to the correct activity
!dont_activate)
ws->requestFocus(c);
else
ws->restackClientUnderActive(c);
} else
ws->raiseClient(c);
//notifyWindowDesktopChanged( c, old_desktop );
auto transients_stacking_order = ws->ensureStackingOrder(c->transients());
for (auto it = transients_stacking_order.constBegin();
it != transients_stacking_order.constEnd();
++it) {
X11Client *c = dynamic_cast<X11Client *>(*it);
if (!c) {
continue;
}
toggleClientOnActivity(c, activity, dont_activate);
}
ws->updateClientArea();
}
bool Activities::start(const QString &id)
{
Workspace *ws = Workspace::self();
if (ws->sessionManager()->state() == SessionState::Saving) {
return false; //ksmserver doesn't queue requests (yet)
}
if (!all().contains(id)) {
return false; //bogus id
}
ws->loadSubSessionInfo(id);
QDBusInterface ksmserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
if (ksmserver.isValid()) {
ksmserver.asyncCall("restoreSubSession", id);
} else {
qCDebug(KWIN_CORE) << "couldn't get ksmserver interface";
return false;
}
return true;
}
bool Activities::stop(const QString &id)
{
if (Workspace::self()->sessionManager()->state() == SessionState::Saving) {
return false; //ksmserver doesn't queue requests (yet)
//FIXME what about session *loading*?
}
//ugly hack to avoid dbus deadlocks
QMetaObject::invokeMethod(this, "reallyStop", Qt::QueuedConnection, Q_ARG(QString, id));
//then lie and assume it worked.
return true;
}
void Activities::reallyStop(const QString &id)
{
Workspace *ws = Workspace::self();
if (ws->sessionManager()->state() == SessionState::Saving)
return; //ksmserver doesn't queue requests (yet)
qCDebug(KWIN_CORE) << id;
QSet<QByteArray> saveSessionIds;
QSet<QByteArray> dontCloseSessionIds;
const QList<X11Client *> &clients = ws->clientList();
for (auto it = clients.constBegin(); it != clients.constEnd(); ++it) {
const X11Client *c = (*it);
if (c->isDesktop())
continue;
const QByteArray sessionId = c->sessionId();
if (sessionId.isEmpty()) {
continue; //TODO support old wm_command apps too?
}
//qDebug() << sessionId;
//if it's on the activity that's closing, it needs saving
//but if a process is on some other open activity, I don't wanna close it yet
//this is, of course, complicated by a process having many windows.
if (c->isOnAllActivities()) {
dontCloseSessionIds << sessionId;
continue;
}
const QStringList activities = c->activities();
foreach (const QString & activityId, activities) {
if (activityId == id) {
saveSessionIds << sessionId;
} else if (running().contains(activityId)) {
dontCloseSessionIds << sessionId;
}
}
}
ws->storeSubSession(id, saveSessionIds);
QStringList saveAndClose;
QStringList saveOnly;
foreach (const QByteArray & sessionId, saveSessionIds) {
if (dontCloseSessionIds.contains(sessionId)) {
saveOnly << sessionId;
} else {
saveAndClose << sessionId;
}
}
qCDebug(KWIN_CORE) << "saveActivity" << id << saveAndClose << saveOnly;
//pass off to ksmserver
QDBusInterface ksmserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
if (ksmserver.isValid()) {
ksmserver.asyncCall("saveSubSession", id, saveAndClose, saveOnly);
} else {
qCDebug(KWIN_CORE) << "couldn't get ksmserver interface";
}
}
} // namespace

118
activities.h Normal file
View File

@ -0,0 +1,118 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_ACTIVITIES_H
#define KWIN_ACTIVITIES_H
#include <kwinglobals.h>
#include <QObject>
#include <QStringList>
#include <kactivities/controller.h>
namespace KActivities {
class Controller;
}
namespace KWin
{
class X11Client;
class KWIN_EXPORT Activities : public QObject
{
Q_OBJECT
public:
~Activities() override;
bool stop(const QString &id);
bool start(const QString &id);
void setCurrent(const QString &activity);
/**
* Adds/removes client \a c to/from \a activity.
*
* Takes care of transients as well.
*/
void toggleClientOnActivity(X11Client *c, const QString &activity, bool dont_activate);
QStringList running() const;
QStringList all() const;
const QString &current() const;
const QString &previous() const;
static QString nullUuid();
KActivities::Controller::ServiceStatus serviceStatus() const;
Q_SIGNALS:
/**
* This signal is emitted when the global
* activity is changed
* @param id id of the new current activity
*/
void currentChanged(const QString &id);
/**
* This signal is emitted when a new activity is added
* @param id id of the new activity
*/
void added(const QString &id);
/**
* This signal is emitted when the activity
* is removed
* @param id id of the removed activity
*/
void removed(const QString &id);
private Q_SLOTS:
void slotRemoved(const QString &activity);
void slotCurrentChanged(const QString &newActivity);
void reallyStop(const QString &id); //dbus deadlocks suck
private:
QString m_previous;
QString m_current;
KActivities::Controller *m_controller;
KWIN_SINGLETON(Activities)
};
inline
QStringList Activities::all() const
{
return m_controller->activities();
}
inline
const QString &Activities::current() const
{
return m_current;
}
inline
const QString &Activities::previous() const
{
return m_previous;
}
inline
QStringList Activities::running() const
{
return m_controller->activities(KActivities::Info::Running);
}
inline
QString Activities::nullUuid()
{
// cloned from kactivities/src/lib/core/consumer.cpp
return QStringLiteral("00000000-0000-0000-0000-000000000000");
}
}
#endif // KWIN_ACTIVITIES_H

123
appmenu.cpp Normal file
View File

@ -0,0 +1,123 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2011 Lionel Chauvin <megabigbug@yahoo.fr>
SPDX-FileCopyrightText: 2011, 2012 Cédric Bellegarde <gnumdk@gmail.com>
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "appmenu.h"
#include "x11client.h"
#include "workspace.h"
#include <appmenu_interface.h>
#include <QDBusObjectPath>
#include <QDBusServiceWatcher>
#include "decorations/decorationbridge.h"
#include <KDecoration2/DecorationSettings>
namespace KWin
{
KWIN_SINGLETON_FACTORY(ApplicationMenu)
static const QString s_viewService(QStringLiteral("org.kde.kappmenuview"));
ApplicationMenu::ApplicationMenu(QObject *parent)
: QObject(parent)
, m_appmenuInterface(new OrgKdeKappmenuInterface(QStringLiteral("org.kde.kappmenu"), QStringLiteral("/KAppMenu"), QDBusConnection::sessionBus(), this))
{
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::showRequest, this, &ApplicationMenu::slotShowRequest);
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuShown, this, &ApplicationMenu::slotMenuShown);
connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuHidden, this, &ApplicationMenu::slotMenuHidden);
m_kappMenuWatcher = new QDBusServiceWatcher(QStringLiteral("org.kde.kappmenu"), QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration, this);
connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceRegistered,
this, [this] () {
m_applicationMenuEnabled = true;
emit applicationMenuEnabledChanged(true);
});
connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceUnregistered,
this, [this] () {
m_applicationMenuEnabled = false;
emit applicationMenuEnabledChanged(false);
});
m_applicationMenuEnabled = QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.kappmenu"));
}
ApplicationMenu::~ApplicationMenu()
{
s_self = nullptr;
}
bool ApplicationMenu::applicationMenuEnabled() const
{
return m_applicationMenuEnabled;
}
void ApplicationMenu::setViewEnabled(bool enabled)
{
if (enabled) {
QDBusConnection::sessionBus().interface()->registerService(s_viewService,
QDBusConnectionInterface::QueueService,
QDBusConnectionInterface::DontAllowReplacement);
} else {
QDBusConnection::sessionBus().interface()->unregisterService(s_viewService);
}
}
void ApplicationMenu::slotShowRequest(const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId)
{
// Ignore show request when user has not configured the application menu title bar button
auto decorationSettings = Decoration::DecorationBridge::self()->settings();
if (!decorationSettings->decorationButtonsLeft().contains(KDecoration2::DecorationButtonType::ApplicationMenu)
&& !decorationSettings->decorationButtonsRight().contains(KDecoration2::DecorationButtonType::ApplicationMenu)) {
return;
}
if (AbstractClient *c = findAbstractClientWithApplicationMenu(serviceName, menuObjectPath)) {
c->showApplicationMenu(actionId);
}
}
void ApplicationMenu::slotMenuShown(const QString &serviceName, const QDBusObjectPath &menuObjectPath)
{
if (AbstractClient *c = findAbstractClientWithApplicationMenu(serviceName, menuObjectPath)) {
c->setApplicationMenuActive(true);
}
}
void ApplicationMenu::slotMenuHidden(const QString &serviceName, const QDBusObjectPath &menuObjectPath)
{
if (AbstractClient *c = findAbstractClientWithApplicationMenu(serviceName, menuObjectPath)) {
c->setApplicationMenuActive(false);
}
}
void ApplicationMenu::showApplicationMenu(const QPoint &p, AbstractClient *c, int actionId)
{
if (!c->hasApplicationMenu()) {
return;
}
m_appmenuInterface->showMenu(p.x(), p.y(), c->applicationMenuServiceName(), QDBusObjectPath(c->applicationMenuObjectPath()), actionId);
}
AbstractClient *ApplicationMenu::findAbstractClientWithApplicationMenu(const QString &serviceName, const QDBusObjectPath &menuObjectPath)
{
if (serviceName.isEmpty() || menuObjectPath.path().isEmpty()) {
return nullptr;
}
return Workspace::self()->findAbstractClient([&](const AbstractClient *c) {
return c->applicationMenuServiceName() == serviceName
&& c->applicationMenuObjectPath() == menuObjectPath.path();
});
}
} // namespace KWin

64
appmenu.h Normal file
View File

@ -0,0 +1,64 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2011 Lionel Chauvin <megabigbug@yahoo.fr>
SPDX-FileCopyrightText: 2011, 2012 Cédric Bellegarde <gnumdk@gmail.com>
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_APPMENU_H
#define KWIN_APPMENU_H
// KWin
#include <kwinglobals.h>
// Qt
#include <QObject>
// xcb
#include <xcb/xcb.h>
class QPoint;
class OrgKdeKappmenuInterface;
class QDBusObjectPath;
class QDBusServiceWatcher;
namespace KWin
{
class AbstractClient;
class ApplicationMenu : public QObject
{
Q_OBJECT
public:
~ApplicationMenu() override;
void showApplicationMenu(const QPoint &pos, AbstractClient *c, int actionId);
bool applicationMenuEnabled() const;
void setViewEnabled(bool enabled);
signals:
void applicationMenuEnabledChanged(bool enabled);
private Q_SLOTS:
void slotShowRequest(const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId);
void slotMenuShown(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
void slotMenuHidden(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
private:
OrgKdeKappmenuInterface *m_appmenuInterface;
QDBusServiceWatcher *m_kappMenuWatcher;
AbstractClient *findAbstractClientWithApplicationMenu(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
bool m_applicationMenuEnabled = false;
KWIN_SINGLETON(ApplicationMenu)
};
}
#endif // KWIN_APPMENU_H

91
atoms.cpp Normal file
View File

@ -0,0 +1,91 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "atoms.h"
namespace KWin
{
Atoms::Atoms()
: kwin_running(QByteArrayLiteral("KWIN_RUNNING"))
, activities(QByteArrayLiteral("_KDE_NET_WM_ACTIVITIES"))
, wm_protocols(QByteArrayLiteral("WM_PROTOCOLS"))
, wm_delete_window(QByteArrayLiteral("WM_DELETE_WINDOW"))
, wm_take_focus(QByteArrayLiteral("WM_TAKE_FOCUS"))
, wm_change_state(QByteArrayLiteral("WM_CHANGE_STATE"))
, wm_client_leader(QByteArrayLiteral("WM_CLIENT_LEADER"))
, wm_window_role(QByteArrayLiteral("WM_WINDOW_ROLE"))
, wm_state(QByteArrayLiteral("WM_STATE"))
, sm_client_id(QByteArrayLiteral("SM_CLIENT_ID"))
, motif_wm_hints(QByteArrayLiteral("_MOTIF_WM_HINTS"))
, net_wm_context_help(QByteArrayLiteral("_NET_WM_CONTEXT_HELP"))
, net_wm_ping(QByteArrayLiteral("_NET_WM_PING"))
, net_wm_user_time(QByteArrayLiteral("_NET_WM_USER_TIME"))
, kde_net_wm_user_creation_time(QByteArrayLiteral("_KDE_NET_WM_USER_CREATION_TIME"))
, net_wm_take_activity(QByteArrayLiteral("_NET_WM_TAKE_ACTIVITY"))
, net_wm_window_opacity(QByteArrayLiteral("_NET_WM_WINDOW_OPACITY"))
, xdnd_selection(QByteArrayLiteral("XdndSelection"))
, xdnd_aware(QByteArrayLiteral("XdndAware"))
, xdnd_enter(QByteArrayLiteral("XdndEnter"))
, xdnd_type_list(QByteArrayLiteral("XdndTypeList"))
, xdnd_position(QByteArrayLiteral("XdndPosition"))
, xdnd_status(QByteArrayLiteral("XdndStatus"))
, xdnd_action_copy(QByteArrayLiteral("XdndActionCopy"))
, xdnd_action_move(QByteArrayLiteral("XdndActionMove"))
, xdnd_action_ask(QByteArrayLiteral("XdndActionAsk"))
, xdnd_drop(QByteArrayLiteral("XdndDrop"))
, xdnd_leave(QByteArrayLiteral("XdndLeave"))
, xdnd_finished(QByteArrayLiteral("XdndFinished"))
, net_frame_extents(QByteArrayLiteral("_NET_FRAME_EXTENTS"))
, kde_net_wm_frame_strut(QByteArrayLiteral("_KDE_NET_WM_FRAME_STRUT"))
, net_wm_sync_request_counter(QByteArrayLiteral("_NET_WM_SYNC_REQUEST_COUNTER"))
, net_wm_sync_request(QByteArrayLiteral("_NET_WM_SYNC_REQUEST"))
, kde_net_wm_shadow(QByteArrayLiteral("_KDE_NET_WM_SHADOW"))
, kde_first_in_window_list(QByteArrayLiteral("_KDE_FIRST_IN_WINDOWLIST"))
, kde_color_sheme(QByteArrayLiteral("_KDE_NET_WM_COLOR_SCHEME"))
, kde_skip_close_animation(QByteArrayLiteral("_KDE_NET_WM_SKIP_CLOSE_ANIMATION"))
, kde_screen_edge_show(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"))
, kwin_dbus_service(QByteArrayLiteral("_ORG_KDE_KWIN_DBUS_SERVICE"))
, utf8_string(QByteArrayLiteral("UTF8_STRING"))
, text(QByteArrayLiteral("TEXT"))
, uri_list(QByteArrayLiteral("text/uri-list"))
, netscape_url(QByteArrayLiteral("_NETSCAPE_URL"))
, moz_url(QByteArrayLiteral("text/x-moz-url"))
, wl_surface_id(QByteArrayLiteral("WL_SURFACE_ID"))
, kde_net_wm_appmenu_service_name(QByteArrayLiteral("_KDE_NET_WM_APPMENU_SERVICE_NAME"))
, kde_net_wm_appmenu_object_path(QByteArrayLiteral("_KDE_NET_WM_APPMENU_OBJECT_PATH"))
, clipboard(QByteArrayLiteral("CLIPBOARD"))
, timestamp(QByteArrayLiteral("TIMESTAMP"))
, targets(QByteArrayLiteral("TARGETS"))
, delete_atom(QByteArrayLiteral("DELETE"))
, incr(QByteArrayLiteral("INCR"))
, wl_selection(QByteArrayLiteral("WL_SELECTION"))
, m_dtSmWindowInfo(QByteArrayLiteral("_DT_SM_WINDOW_INFO"))
, m_motifSupport(QByteArrayLiteral("_MOTIF_WM_INFO"))
, m_helpersRetrieved(false)
{
}
void Atoms::retrieveHelpers()
{
if (m_helpersRetrieved) {
return;
}
// just retrieve the atoms once, all others are retrieved when being accessed
// Q_UNUSED is used in the hope that the compiler doesn't optimize the operations away
xcb_atom_t atom = m_dtSmWindowInfo;
Q_UNUSED(atom)
atom = m_motifSupport;
Q_UNUSED(atom)
m_helpersRetrieved = true;
}
} // namespace

98
atoms.h Normal file
View File

@ -0,0 +1,98 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_ATOMS_H
#define KWIN_ATOMS_H
#include "xcbutils.h"
namespace KWin
{
class KWIN_EXPORT Atoms
{
public:
Atoms();
Xcb::Atom kwin_running;
Xcb::Atom activities;
Xcb::Atom wm_protocols;
Xcb::Atom wm_delete_window;
Xcb::Atom wm_take_focus;
Xcb::Atom wm_change_state;
Xcb::Atom wm_client_leader;
Xcb::Atom wm_window_role;
Xcb::Atom wm_state;
Xcb::Atom sm_client_id;
Xcb::Atom motif_wm_hints;
Xcb::Atom net_wm_context_help;
Xcb::Atom net_wm_ping;
Xcb::Atom net_wm_user_time;
Xcb::Atom kde_net_wm_user_creation_time;
Xcb::Atom net_wm_take_activity;
Xcb::Atom net_wm_window_opacity;
Xcb::Atom xdnd_selection;
Xcb::Atom xdnd_aware;
Xcb::Atom xdnd_enter;
Xcb::Atom xdnd_type_list;
Xcb::Atom xdnd_position;
Xcb::Atom xdnd_status;
Xcb::Atom xdnd_action_copy;
Xcb::Atom xdnd_action_move;
Xcb::Atom xdnd_action_ask;
Xcb::Atom xdnd_drop;
Xcb::Atom xdnd_leave;
Xcb::Atom xdnd_finished;
Xcb::Atom net_frame_extents;
Xcb::Atom kde_net_wm_frame_strut;
Xcb::Atom net_wm_sync_request_counter;
Xcb::Atom net_wm_sync_request;
Xcb::Atom kde_net_wm_shadow;
Xcb::Atom kde_first_in_window_list;
Xcb::Atom kde_color_sheme;
Xcb::Atom kde_skip_close_animation;
Xcb::Atom kde_screen_edge_show;
Xcb::Atom kwin_dbus_service;
Xcb::Atom utf8_string;
Xcb::Atom text;
Xcb::Atom uri_list;
Xcb::Atom netscape_url;
Xcb::Atom moz_url;
Xcb::Atom wl_surface_id;
Xcb::Atom kde_net_wm_appmenu_service_name;
Xcb::Atom kde_net_wm_appmenu_object_path;
Xcb::Atom clipboard;
Xcb::Atom timestamp;
Xcb::Atom targets;
Xcb::Atom delete_atom;
Xcb::Atom incr;
Xcb::Atom wl_selection;
/**
* @internal
*/
void retrieveHelpers();
private:
// helper atoms we need to resolve to "announce" support (see #172028)
Xcb::Atom m_dtSmWindowInfo;
Xcb::Atom m_motifSupport;
bool m_helpersRetrieved;
};
extern KWIN_EXPORT Atoms* atoms;
} // namespace
#endif

View File

@ -1,21 +1,29 @@
add_definitions(-DKWIN_UNIT_TEST)
remove_definitions(-DQT_USE_QSTRINGBUILDER)
add_subdirectory(effect)
add_subdirectory(libkwineffects)
add_subdirectory(libxrenderutils)
add_subdirectory(integration)
add_subdirectory(libinput)
add_subdirectory(wayland)
# drm autotests are broken on FreeBSD for yet unknown reasons
# As the test isn't doing anything platform specific, only run it on Linux
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (HAVE_DRM)
add_subdirectory(drm)
endif()
add_subdirectory(tabbox)
########################################################
# Test ScreenPaintData
########################################################
set(testScreenPaintData_SRCS test_screen_paint_data.cpp)
add_executable(testScreenPaintData ${testScreenPaintData_SRCS})
target_link_libraries(testScreenPaintData kwineffects Qt5::Test Qt5::Widgets KF5::WindowSystem)
add_test(NAME kwin-testScreenPaintData COMMAND testScreenPaintData)
ecm_mark_as_test(testScreenPaintData)
########################################################
# Test WindowPaintData
########################################################
set(testWindowPaintData_SRCS test_window_paint_data.cpp)
add_executable(testWindowPaintData ${testWindowPaintData_SRCS})
target_link_libraries(testWindowPaintData kwin Qt::Widgets Qt::Test )
target_link_libraries(testWindowPaintData kwineffects Qt5::Widgets Qt5::Test )
add_test(NAME kwin-testWindowPaintData COMMAND testWindowPaintData)
ecm_mark_as_test(testWindowPaintData)
@ -23,21 +31,20 @@ ecm_mark_as_test(testWindowPaintData)
# Test VirtualDesktopManager
########################################################
set(testVirtualDesktops_SRCS
../src/virtualdesktops.cpp
../virtualdesktops.cpp
test_virtual_desktops.cpp
)
add_executable(testVirtualDesktops ${testVirtualDesktops_SRCS})
target_link_libraries(testVirtualDesktops
kwin
Qt5::Test
Qt5::Widgets
Qt::Test
Qt::Widgets
KF6::ConfigCore
KF6::GlobalAccel
KF6::I18n
KF6::WindowSystem
KF5::ConfigCore
KF5::GlobalAccel
KF5::I18n
Plasma::KWaylandServer
KF5::WindowSystem
)
add_test(NAME kwin-testVirtualDesktops COMMAND testVirtualDesktops)
ecm_mark_as_test(testVirtualDesktops)
@ -45,115 +52,298 @@ ecm_mark_as_test(testVirtualDesktops)
########################################################
# Test ClientMachine
########################################################
if(KWIN_BUILD_X11)
set(testClientMachine_SRCS
../src/client_machine.cpp
set(testClientMachine_SRCS
../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")
)
add_executable(testClientMachine ${testClientMachine_SRCS})
set_target_properties(testClientMachine PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries(testClientMachine
Qt::Concurrent
Qt::GuiPrivate
Qt::Test
Qt::Widgets
target_link_libraries(testClientMachine
Qt5::Concurrent
Qt5::Test
Qt5::Widgets
Qt5::X11Extras
KF6::ConfigCore
KF6::WindowSystem
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
XCB::XFIXES
${X11_X11_LIB} # to make jenkins happy
)
add_test(NAME kwin-testClientMachine COMMAND testClientMachine)
ecm_mark_as_test(testClientMachine)
)
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)
########################################################
# Test XcbWrapper
########################################################
set(testXcbWrapper_SRCS
test_xcb_wrapper.cpp
)
add_executable(testXcbWrapper ${testXcbWrapper_SRCS})
target_link_libraries(testXcbWrapper
Qt::GuiPrivate
Qt::Test
Qt::Widgets
target_link_libraries(testXcbWrapper
Qt5::Test
Qt5::Widgets
Qt5::X11Extras
KF6::ConfigCore
KF6::WindowSystem
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
)
add_test(NAME kwin-testXcbWrapper COMMAND testXcbWrapper)
ecm_mark_as_test(testXcbWrapper)
)
add_test(NAME kwin-testXcbWrapper COMMAND testXcbWrapper)
ecm_mark_as_test(testXcbWrapper)
add_executable(testXcbSizeHints test_xcb_size_hints.cpp xcb_scaling_mock.cpp)
if (XCB_ICCCM_FOUND)
add_executable(testXcbSizeHints test_xcb_size_hints.cpp)
set_target_properties(testXcbSizeHints PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries(testXcbSizeHints
Qt::GuiPrivate
Qt::Test
Qt::Widgets
Qt5::Test
Qt5::Widgets
Qt5::X11Extras
KF6::ConfigCore
KF6::WindowSystem
KF5::ConfigCore
KF5::WindowSystem
XCB::ICCCM
XCB::XCB
)
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)
########################################################
# Test XcbWindow
########################################################
set(testXcbWindow_SRCS
test_xcb_window.cpp
)
add_executable(testXcbWindow ${testXcbWindow_SRCS})
target_link_libraries(testXcbWindow
Qt::GuiPrivate
Qt::Test
Qt::Widgets
target_link_libraries(testXcbWindow
Qt5::Test
Qt5::Widgets
Qt5::X11Extras
KF6::ConfigCore
KF6::WindowSystem
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
)
add_test(NAME kwin-testXcbWindow COMMAND testXcbWindow)
ecm_mark_as_test(testXcbWindow)
)
add_test(NAME kwin-testXcbWindow COMMAND testXcbWindow)
ecm_mark_as_test(testXcbWindow)
########################################################
# Test X11 TimestampUpdate
########################################################
add_executable(testX11TimestampUpdate test_x11_timestamp_update.cpp)
target_link_libraries(testX11TimestampUpdate
KF6::CoreAddons
Qt::Test
Qt::GuiPrivate
kwin
)
add_test(NAME kwin-testX11TimestampUpdate COMMAND testX11TimestampUpdate)
ecm_mark_as_test(testX11TimestampUpdate)
endif()
########################################################
# Test BuiltInEffectLoader
########################################################
set(testBuiltInEffectLoader_SRCS
../effectloader.cpp
mock_effectshandler.cpp
test_builtin_effectloader.cpp
)
add_executable(testBuiltInEffectLoader ${testBuiltInEffectLoader_SRCS})
set_target_properties(testBuiltInEffectLoader PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries(testBuiltInEffectLoader
Qt5::Concurrent
Qt5::Test
Qt5::X11Extras
KF5::Package
kwineffects
kwin4_effect_builtins
)
add_test(NAME kwin-testBuiltInEffectLoader COMMAND testBuiltInEffectLoader)
ecm_mark_as_test(testBuiltInEffectLoader)
########################################################
# Test ScriptedEffectLoader
########################################################
include_directories(${KWin_SOURCE_DIR})
set(testScriptedEffectLoader_SRCS
../effectloader.cpp
../cursor.cpp
../screens.cpp
../scripting/scriptedeffect.cpp
../scripting/scripting_logging.cpp
../scripting/scriptingutils.cpp
mock_abstract_client.cpp
mock_effectshandler.cpp
mock_screens.cpp
mock_workspace.cpp
test_scripted_effectloader.cpp
)
kconfig_add_kcfg_files(testScriptedEffectLoader_SRCS ../settings.kcfgc)
add_executable(testScriptedEffectLoader ${testScriptedEffectLoader_SRCS})
target_link_libraries(testScriptedEffectLoader
Qt5::Concurrent
Qt5::Qml
Qt5::Script
Qt5::Sensors
Qt5::Test
Qt5::X11Extras
KF5::ConfigGui
KF5::GlobalAccel
KF5::I18n
KF5::Notifications
KF5::Package
kwineffects
kwin4_effect_builtins
)
add_test(NAME kwin-testScriptedEffectLoader COMMAND testScriptedEffectLoader)
ecm_mark_as_test(testScriptedEffectLoader)
########################################################
# Test PluginEffectLoader
########################################################
set(testPluginEffectLoader_SRCS
../effectloader.cpp
mock_effectshandler.cpp
test_plugin_effectloader.cpp
)
add_executable(testPluginEffectLoader ${testPluginEffectLoader_SRCS})
target_link_libraries(testPluginEffectLoader
Qt5::Concurrent
Qt5::Test
Qt5::X11Extras
KF5::Package
kwineffects
kwin4_effect_builtins
)
add_test(NAME kwin-testPluginEffectLoader COMMAND testPluginEffectLoader)
ecm_mark_as_test(testPluginEffectLoader)
########################################################
# FakeEffectPlugin
########################################################
add_library(fakeeffectplugin MODULE fakeeffectplugin.cpp)
set_target_properties(fakeeffectplugin PROPERTIES PREFIX "")
target_link_libraries(fakeeffectplugin kwineffects)
########################################################
# FakeEffectPlugin-Version
########################################################
add_library(effectversionplugin MODULE fakeeffectplugin_version.cpp)
set_target_properties(effectversionplugin PROPERTIES PREFIX "")
target_link_libraries(effectversionplugin kwineffects)
########################################################
# Test Screens
########################################################
set(testScreens_SRCS
../screens.cpp
../cursor.cpp
../x11eventfilter.cpp
mock_abstract_client.cpp
mock_screens.cpp
mock_workspace.cpp
mock_x11client.cpp
test_screens.cpp
)
kconfig_add_kcfg_files(testScreens_SRCS ../settings.kcfgc)
add_executable(testScreens ${testScreens_SRCS})
target_include_directories(testScreens BEFORE PRIVATE ./)
target_link_libraries(testScreens
Qt5::DBus
Qt5::Sensors
Qt5::Test
Qt5::Widgets
Qt5::X11Extras
KF5::ConfigCore
KF5::ConfigGui
KF5::I18n
KF5::Notifications
KF5::WindowSystem
XCB::XCB #for xcbutils.h
)
add_test(NAME kwin_testScreens COMMAND testScreens)
ecm_mark_as_test(testScreens)
########################################################
# Test ScreenEdges
########################################################
set(testScreenEdges_SRCS
../atoms.cpp
../gestures.cpp
../plugins/platforms/x11/standalone/edge.cpp
../screenedge.cpp
../screens.cpp
../virtualdesktops.cpp
../cursor.cpp
../xcbutils.cpp # init of extensions
mock_abstract_client.cpp
mock_screens.cpp
mock_workspace.cpp
mock_x11client.cpp
test_screen_edges.cpp
)
kconfig_add_kcfg_files(testScreenEdges_SRCS ../settings.kcfgc)
qt5_add_dbus_interface(testScreenEdges_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.ScreenSaver.xml screenlocker_interface )
add_executable(testScreenEdges ${testScreenEdges_SRCS})
set_target_properties(testScreenEdges PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_include_directories(testScreenEdges BEFORE PRIVATE ./)
target_link_libraries(testScreenEdges
Qt5::DBus
Qt5::Sensors
Qt5::Test
Qt5::X11Extras
KF5::ConfigCore
KF5::ConfigGui
KF5::GlobalAccel
KF5::I18n
KF5::Notifications
Plasma::KWaylandServer
KF5::WindowSystem
XCB::COMPOSITE
XCB::DAMAGE
XCB::GLX
XCB::RANDR
XCB::SHM
XCB::SYNC
XCB::XCB
XCB::XFIXES
)
add_test(NAME kwin_testScreenEdges COMMAND testScreenEdges)
ecm_mark_as_test(testScreenEdges)
########################################################
# Test OnScreenNotification
########################################################
set(testOnScreenNotification_SRCS
../src/input_event_spy.cpp
../src/onscreennotification.cpp
../input_event_spy.cpp
../onscreennotification.cpp
onscreennotificationtest.cpp
)
add_executable(testOnScreenNotification ${testOnScreenNotification_SRCS})
target_link_libraries(testOnScreenNotification
Qt::DBus
Qt::Quick
Qt::Test
Qt::Widgets # QAction include
Qt5::DBus
Qt5::Quick
Qt5::Test
Qt5::Widgets # QAction include
KF6::ConfigCore
KF5::ConfigCore
)
add_test(NAME kwin-testOnScreenNotification COMMAND testOnScreenNotification)
@ -163,95 +353,74 @@ ecm_mark_as_test(testOnScreenNotification)
# Test Gestures
########################################################
set(testGestures_SRCS
../src/gestures.cpp
../gestures.cpp
test_gestures.cpp
)
add_executable(testGestures ${testGestures_SRCS})
target_link_libraries(testGestures
Qt::Test
Qt::Widgets
Qt5::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
Qt5::Test
kwin
)
add_test(NAME kwin-testX11TimestampUpdate COMMAND testX11TimestampUpdate)
ecm_mark_as_test(testX11TimestampUpdate)
set(testOpenGLContextAttributeBuilder_SRCS
../src/opengl/abstract_opengl_context_attribute_builder.cpp
../src/opengl/egl_context_attribute_builder.cpp
../abstract_opengl_context_attribute_builder.cpp
../egl_context_attribute_builder.cpp
opengl_context_attribute_builder_test.cpp
)
if (HAVE_GLX)
set(testOpenGLContextAttributeBuilder_SRCS ${testOpenGLContextAttributeBuilder_SRCS} ../src/backends/x11/standalone/x11_standalone_glx_context_attribute_builder.cpp)
if (HAVE_EPOXY_GLX)
set(testOpenGLContextAttributeBuilder_SRCS ${testOpenGLContextAttributeBuilder_SRCS} ../plugins/platforms/x11/standalone/glx_context_attribute_builder.cpp)
endif()
add_executable(testOpenGLContextAttributeBuilder ${testOpenGLContextAttributeBuilder_SRCS})
target_link_libraries(testOpenGLContextAttributeBuilder epoxy::epoxy Qt::Test)
target_link_libraries(testOpenGLContextAttributeBuilder Qt5::Test)
add_test(NAME kwin-testOpenGLContextAttributeBuilder COMMAND testOpenGLContextAttributeBuilder)
ecm_mark_as_test(testOpenGLContextAttributeBuilder)
set(testXkb_SRCS
../src/xkb.cpp
../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
Qt5::Gui
Qt5::Test
Qt5::Widgets
Qt::Gui
Qt::GuiPrivate
Qt::Test
Qt::Widgets
KF6::ConfigCore
KF6::WindowSystem
KF5::ConfigCore
Plasma::KWaylandServer
KF5::WindowSystem
XKB::XKB
)
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)
if (HAVE_GBM)
add_executable(testGbmSurface test_gbm_surface.cpp ../plugins/platforms/drm/gbm_surface.cpp)
target_link_libraries(testGbmSurface Qt5::Test)
add_test(NAME kwin-testGbmSurface COMMAND testGbmSurface)
ecm_mark_as_test(testGbmSurface)
endif()
########################################################
# Test KWin Utils
########################################################
add_executable(testUtils test_utils.cpp)
target_link_libraries(testUtils
Qt::Test
kwin
add_executable(testVirtualKeyboardDBus test_virtualkeyboard_dbus.cpp ../virtualkeyboard_dbus.cpp)
target_link_libraries(testVirtualKeyboardDBus
Qt5::DBus
Qt5::Test
)
add_test(NAME kwin-testUtils COMMAND testUtils)
ecm_mark_as_test(testUtils)
########################################################
# Test OutputTransform
########################################################
add_executable(testOutputTransform output_transform_test.cpp)
target_link_libraries(testOutputTransform
Qt::Test
kwin
)
add_test(NAME kwin-testOutputTransform COMMAND testOutputTransform)
ecm_mark_as_test(testOutputTransform)
########################################################
# Test Colorspace
########################################################
add_executable(testColorspaces test_colorspaces.cpp)
target_link_libraries(testColorspaces
Qt::Test
kwin
)
add_test(NAME kwin-testColorspaces COMMAND testColorspaces)
ecm_mark_as_test(testColorspaces)
add_test(NAME kwin-testVirtualKeyboardDBus COMMAND testVirtualKeyboardDBus)
ecm_mark_as_test(testVirtualKeyboardDBus)

View File

@ -0,0 +1 @@
#include "mock_abstract_client.h"

View File

@ -1,59 +1,26 @@
set(mockDRM_SRCS
mock_drm.cpp
../../src/backends/drm/drm_abstract_output.cpp
../../src/backends/drm/drm_backend.cpp
../../src/backends/drm/drm_blob.cpp
../../src/backends/drm/drm_buffer.cpp
../../src/backends/drm/drm_commit.cpp
../../src/backends/drm/drm_commit_thread.cpp
../../src/backends/drm/drm_connector.cpp
../../src/backends/drm/drm_crtc.cpp
../../src/backends/drm/drm_egl_backend.cpp
../../src/backends/drm/drm_egl_layer.cpp
../../src/backends/drm/drm_egl_layer_surface.cpp
../../src/backends/drm/drm_gpu.cpp
../../src/backends/drm/drm_layer.cpp
../../src/backends/drm/drm_logging.cpp
../../src/backends/drm/drm_object.cpp
../../src/backends/drm/drm_output.cpp
../../src/backends/drm/drm_pipeline.cpp
../../src/backends/drm/drm_pipeline_legacy.cpp
../../src/backends/drm/drm_plane.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_virtual_egl_layer.cpp
../../src/backends/drm/drm_virtual_output.cpp
../../src/backends/drm/icc_shader.cpp
)
include_directories(${Libdrm_INCLUDE_DIRS})
add_library(LibDrmTest STATIC ${mockDRM_SRCS})
target_link_libraries(LibDrmTest
Qt::Gui
Qt::Widgets
KF6::ConfigCore
KF6::WindowSystem
KF6::CoreAddons
KF6::I18n
PkgConfig::Libxcvt
gbm::gbm
Libdrm::Libdrm
kwin
)
target_include_directories(LibDrmTest
PUBLIC
../../src
../../src/platformsupport/scenes/opengl
../../src/platformsupport/scenes/qpainter
../../src/backends/drm/
set(mockDRM_SRCS
mock_drm.cpp
../../plugins/platforms/drm/drm_buffer.cpp
../../plugins/platforms/drm/drm_object.cpp
../../plugins/platforms/drm/drm_object_connector.cpp
../../plugins/platforms/drm/drm_object_plane.cpp
../../plugins/platforms/drm/logging.cpp
)
########################################################
# 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)
add_library(mockDrm STATIC ${mockDRM_SRCS})
target_link_libraries(mockDrm Qt5::Gui)
ecm_mark_as_test(mockDrm)
function(drmTest)
set(oneValueArgs NAME)
set(multiValueArgs SRCS )
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${ARGS_NAME} ${ARGS_SRCS})
target_link_libraries(${ARGS_NAME} mockDrm Qt5::Test)
add_test(NAME kwin-drm-${ARGS_NAME} COMMAND ${ARGS_NAME})
ecm_mark_as_test(${ARGS_NAME})
endfunction()
drmTest(NAME objecttest SRCS objecttest.cpp)

View File

@ -1,427 +0,0 @@
/*
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 <QSignalSpy>
#include <QSize>
#include <QTest>
#include "mock_drm.h"
#include "core/outputlayer.h"
#include "core/session.h"
#include "drm_backend.h"
#include "drm_connector.h"
#include "drm_crtc.h"
#include "drm_egl_backend.h"
#include "drm_gpu.h"
#include "drm_output.h"
#include "drm_pipeline.h"
#include "drm_plane.h"
#include "drm_pointer.h"
#include "platformsupport/scenes/qpainter/qpainterbackend.h"
#include <drm_fourcc.h>
#include <fcntl.h>
#include <sys/utsname.h>
using namespace KWin;
static std::unique_ptr<MockGpu> findPrimaryDevice(int crtcCount)
{
const int deviceCount = drmGetDevices2(0, nullptr, 0);
if (deviceCount <= 0) {
return nullptr;
}
QList<drmDevice *> devices(deviceCount);
if (drmGetDevices2(0, devices.data(), devices.size()) < 0) {
return nullptr;
}
auto deviceCleanup = qScopeGuard([&devices]() {
drmFreeDevices(devices.data(), devices.size());
});
for (drmDevice *device : std::as_const(devices)) {
if (device->available_nodes & (1 << DRM_NODE_PRIMARY)) {
int fd = open(device->nodes[DRM_NODE_PRIMARY], O_RDWR | O_CLOEXEC);
if (fd != -1) {
return std::make_unique<MockGpu>(fd, device->nodes[DRM_NODE_PRIMARY], crtcCount);
}
}
}
return nullptr;
}
class DrmTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testAmsDetection();
void testOutputDetection();
void testZeroModesHandling();
void testModeGeneration_data();
void testModeGeneration();
void testConnectorLifetime();
void testModeset_data();
void testModeset();
void testVrrChange();
};
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 session = Session::create(Session::Type::Noop);
const auto backend = std::make_unique<DrmBackend>(session.get());
// gpu without planes should use legacy mode
{
const auto mockGpu = findPrimaryDevice(0);
auto gpu = std::make_unique<DrmGpu>(backend.get(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
QVERIFY(!gpu->atomicModeSetting());
}
// gpu with planes should use AMS
{
const auto mockGpu = findPrimaryDevice(0);
mockGpu->planes << std::make_shared<MockPlane>(mockGpu.get(), PlaneType::Primary, 0);
auto gpu = std::make_unique<DrmGpu>(backend.get(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
gpu = std::make_unique<DrmGpu>(backend.get(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
QVERIFY(gpu->atomicModeSetting());
}
// but not if the kernel doesn't allow it
{
const auto mockGpu = findPrimaryDevice(0);
mockGpu->deviceCaps[MOCKDRM_DEVICE_CAP_ATOMIC] = 0;
auto gpu = std::make_unique<DrmGpu>(backend.get(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
QVERIFY(!gpu->atomicModeSetting());
gpu.reset();
verifyCleanup(mockGpu.get());
}
}
void DrmTest::testOutputDetection()
{
const auto mockGpu = findPrimaryDevice(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(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
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 = findPrimaryDevice(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(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
// 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<QList<QSize>>("expectedModes");
QTest::newRow("2160p") << QSize(3840, 2160) << QList<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) << QList<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) << QList<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) << QList<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) << QList<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) << QList<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 = findPrimaryDevice(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(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
QFETCH(QSize, nativeMode);
QFETCH(QList<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.emplace_back(conn.get(), QStringLiteral("scaling mode"), 0, DRM_MODE_PROP_ENUM, QList<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 = findPrimaryDevice(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(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
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());
}
void DrmTest::testModeset_data()
{
QTest::addColumn<int>("AMS");
// TODO to uncomment this, implement page flip callbacks
// QTest::newRow("disabled") << 0;
QTest::newRow("enabled") << 1;
}
void DrmTest::testModeset()
{
// to reenable, make this part of an integration test, so that kwinApp() isn't nullptr
QSKIP("this test needs output pipelines to be enabled by default, which is no longer the case");
// test if doing a modeset would succeed
QFETCH(int, AMS);
const auto mockGpu = findPrimaryDevice(5);
mockGpu->deviceCaps[MOCKDRM_DEVICE_CAP_ATOMIC] = AMS;
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(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().size(), 1);
const auto output = gpu->drmOutputs().front();
const auto layer = renderBackend->primaryLayer(output);
layer->beginFrame();
output->renderLoop()->prepareNewFrame();
output->renderLoop()->beginPaint();
const auto frame = std::make_shared<OutputFrame>(output->renderLoop(), std::chrono::nanoseconds(1'000'000'000'000 / output->refreshRate()));
layer->endFrame(infiniteRegion(), infiniteRegion(), frame.get());
QVERIFY(output->present(frame));
gpu.reset();
verifyCleanup(mockGpu.get());
}
void DrmTest::testVrrChange()
{
const auto mockGpu = findPrimaryDevice(5);
mockGpu->deviceCaps[MOCKDRM_DEVICE_CAP_ATOMIC] = 1;
const auto conn = std::make_shared<MockConnector>(mockGpu.get());
conn->setVrrCapable(false);
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(), mockGpu->fd, DrmDevice::open(mockGpu->devNode));
QVERIFY(gpu->updateOutputs());
const auto output = gpu->drmOutputs().front();
QVERIFY(!(output->capabilities() & Output::Capability::Vrr));
QSignalSpy capsChanged(output, &Output::capabilitiesChanged);
conn->setVrrCapable(true);
QVERIFY(gpu->updateOutputs());
QCOMPARE(gpu->drmOutputs().front(), output);
QCOMPARE(capsChanged.count(), 1);
QVERIFY(output->capabilities() & Output::Capability::Vrr);
}
QTEST_GUILESS_MAIN(DrmTest)
#include "drmTest.moc"

File diff suppressed because it is too large Load Diff

View File

@ -2,194 +2,20 @@
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <xf86drm.h>
#include <cstddef>
#include <cstdint>
#include <xf86drmMode.h>
#include <QList>
#include <QMap>
#include <QRect>
#include <memory>
#include <mutex>
#include <vector>
class MockGpu;
class MockFb;
class MockCrtc;
class MockEncoder;
class MockObject;
class MockPlane;
class MockProperty {
public:
MockProperty(MockObject *obj, QString name, uint64_t initialValue, uint32_t flags, QList<QByteArray> enums = {});
~MockProperty() = default;
MockObject *obj;
uint32_t id;
uint32_t flags;
QString name;
uint64_t value;
QList<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;
QList<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);
void setVrrCapable(bool cap);
drmModeConnection connection;
uint32_t type;
std::shared_ptr<MockEncoder> encoder;
QList<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;
std::shared_ptr<MockPlane> legacyPlane;
};
enum class PlaneType {
Primary = 0,
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;
};
struct Prop {
uint32_t obj;
uint32_t prop;
uint64_t value;
};
struct _drmModeAtomicReq {
bool legacyEmulation = false;
QList<Prop> props;
};
#define MOCKDRM_DEVICE_CAP_ATOMIC 0xFF
class MockGpu {
public:
MockGpu(int fd, const QString &devNode, 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;
QString devNode;
QByteArray name = QByteArrayLiteral("mock");
QMap<uint32_t, uint64_t> clientCaps;
QMap<uint32_t, uint64_t> deviceCaps;
uint32_t idCounter = 1;
QList<MockObject *> objects;
QList<std::shared_ptr<MockConnector>> connectors;
QList<drmModeConnectorPtr> drmConnectors;
QList<std::shared_ptr<MockEncoder>> encoders;
QList<drmModeEncoderPtr> drmEncoders;
QList<std::shared_ptr<MockCrtc>> crtcs;
QList<drmModeCrtcPtr> drmCrtcs;
QList<std::shared_ptr<MockPlane>> planes;
QList<drmModePlanePtr> drmPlanes;
QList<MockFb *> fbs;
std::vector<std::unique_ptr<MockPropertyBlob>> propertyBlobs;
QList<drmModeResPtr> resPtrs;
QList<drmModePropertyPtr> drmProps;
QList<drmModePropertyBlobPtr> drmPropertyBlobs;
QList<drmModeObjectPropertiesPtr> drmObjectProperties;
QList<drmModePlaneResPtr> drmPlaneRes;
std::mutex m_mutex;
};
#include <QVector>
namespace MockDrm
{
void addDrmModeProperties(int fd, const QVector<_drmModeProperty> &properties);
}

View File

@ -0,0 +1,208 @@
/*
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 "mock_drm.h"
#include "../../plugins/platforms/drm/drm_object.h"
#include <QtTest>
class MockDrmObject : public KWin::DrmObject
{
public:
MockDrmObject(uint32_t id, int fd)
: DrmObject(id, fd)
{
}
~MockDrmObject() override {}
bool atomicInit() override;
bool initProps() override;
void setProperties(uint32_t count, uint32_t *props, uint64_t *values) {
m_count = count;
m_props = props;
m_values = values;
}
QByteArray name(int prop) const {
auto property = DrmObject::m_props.at(prop);
if (!property) {
return QByteArray();
}
return property->name();
}
uint32_t propertyId(int prop) const {
auto property = DrmObject::m_props.at(prop);
if (!property) {
return 0xFFFFFFFFu;
}
return property->propId();
}
private:
uint32_t m_count = 0;
uint32_t *m_props = nullptr;
uint64_t *m_values = nullptr;
};
bool MockDrmObject::atomicInit()
{
return initProps();
}
bool MockDrmObject::initProps()
{
setPropertyNames({"foo", "bar", "baz"});
drmModeObjectProperties properties{m_count, m_props, m_values};
for (int i = 0; i < 3; i++) {
initProp(i, &properties);
}
return false;
}
class ObjectTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testId_data();
void testId();
void testFd_data();
void testFd();
void testOutput();
void testInitProperties();
};
void ObjectTest::testId_data()
{
QTest::addColumn<quint32>("id");
QTest::newRow("0") << 0u;
QTest::newRow("1") << 1u;
QTest::newRow("10") << 10u;
QTest::newRow("uint max") << 0xFFFFFFFFu;
}
void ObjectTest::testId()
{
QFETCH(quint32, id);
MockDrmObject object{id, -1};
QCOMPARE(object.id(), id);
}
void ObjectTest::testFd_data()
{
QTest::addColumn<int>("fd");
QTest::newRow("-1") << -1;
QTest::newRow("0") << 0;
QTest::newRow("1") << 1;
QTest::newRow("2") << 2;
QTest::newRow("100") << 100;
QTest::newRow("int max") << 0x7FFFFFFF;
}
void ObjectTest::testFd()
{
QFETCH(int, fd);
MockDrmObject object{0, fd};
QCOMPARE(object.fd(), fd);
}
namespace KWin
{
class DrmOutput {
public:
int foo;
};
}
void ObjectTest::testOutput()
{
MockDrmObject object{0, 1};
QVERIFY(!object.output());
KWin::DrmOutput output{2};
object.setOutput(&output);
QCOMPARE(object.output(), &output);
QCOMPARE(object.output()->foo, 2);
}
void ObjectTest::testInitProperties()
{
MockDrmObject object{0, 20};
uint32_t propertiesIds[] = { 0, 1, 2, 3};
uint64_t values[] = { 0, 2, 10, 20 };
object.setProperties(4, propertiesIds, values);
MockDrm::addDrmModeProperties(20, QVector<_drmModeProperty>{
_drmModeProperty{
0,
0,
"foo\0",
0,
nullptr,
0,
nullptr,
0,
nullptr
},
_drmModeProperty{
1,
0,
"foobar\0",
0,
nullptr,
0,
nullptr,
0,
nullptr
},
_drmModeProperty{
2,
0,
"baz\0",
0,
nullptr,
0,
nullptr,
0,
nullptr
},
_drmModeProperty{
3,
0,
"foobarbaz\0",
0,
nullptr,
0,
nullptr,
0,
nullptr
}
});
object.atomicInit();
// verify the names
QCOMPARE(object.name(0), QByteArrayLiteral("foo"));
QCOMPARE(object.name(1), QByteArray());
QCOMPARE(object.name(2), QByteArrayLiteral("baz"));
// verify the property ids
QCOMPARE(object.propertyId(0), 0u);
QCOMPARE(object.propertyId(1), 0xFFFFFFFFu);
QCOMPARE(object.propertyId(2), 2u);
// doesn't have enums
QCOMPARE(object.propHasEnum(0, 0), false);
QCOMPARE(object.propHasEnum(1, 0), false);
QCOMPARE(object.propHasEnum(2, 0), false);
}
QTEST_GUILESS_MAIN(ObjectTest)
#include "objecttest.moc"

View File

@ -1,20 +0,0 @@
include(ECMMarkAsTest)
macro(KWINEFFECTS_UNIT_TESTS)
foreach(_testname ${ARGN})
add_executable(${_testname} ${_testname}.cpp)
add_test(NAME kwineffects-${_testname} COMMAND ${_testname})
target_link_libraries(${_testname} Qt::Test kwin)
ecm_mark_as_test(${_testname})
endforeach()
endmacro()
kwineffects_unit_tests(
windowquadlisttest
timelinetest
)
add_executable(kwinglplatformtest kwinglplatformtest.cpp ../../src/opengl/glplatform.cpp ../../src/utils/version.cpp)
add_test(NAME kwineffects-kwinglplatformtest COMMAND kwinglplatformtest)
target_link_libraries(kwinglplatformtest Qt::Test Qt::Gui KF6::ConfigCore)
ecm_mark_as_test(kwinglplatformtest)

View File

@ -1,17 +0,0 @@
[Driver]
Vendor=Broadcom VideoCore 3D
Renderer=V3D 4.2
Version=2.1 Mesa 19.1
[Settings]
LooseBinding=true
GLSL=false
TextureNPOT=false
Mesa=true
V3D=true
GLVersion=2,1
MesaVersion=19,1
DriverVersion=19,1
Driver=21
ChipClass=7000
Compositor=4

View File

@ -1,17 +0,0 @@
[Driver]
Vendor=Broadcom VideoCore IV
Renderer=VC4 V3D 2.1
Version=2.1 Mesa 19.1
[Settings]
LooseBinding=true
GLSL=false
TextureNPOT=false
Mesa=true
VC4=true
GLVersion=2,1
MesaVersion=19,1
DriverVersion=19,1
Driver=20
ChipClass=6000
Compositor=4

View File

@ -1,18 +0,0 @@
[Driver]
Vendor=ATI Technologies Inc.
Renderer=AMD Radeon HD 7700M Series
Version=3.1.13399 Compatibility Profile Context FireGL 15.201.1151
ShadingLanguageVersion=4.40
[Settings]
LooseBinding=false
GLSL=true
TextureNPOT=true
Catalyst=true
Radeon=true
GLVersion=3,1,13399
GLSLVersion=4,40
DriverVersion=15,201,1151
Driver=9
ChipClass=999
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Gallium 0.4 on AMD BONAIRE (DRM 2.43.0, LLVM 3.8.0)
Version=3.0 Mesa 11.2.2
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=11,2,2
GalliumVersion=0,4
DriverVersion=11,2,2
Driver=16
ChipClass=10
Compositor=1

View File

@ -1,22 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Gallium 0.4 on AMD CAYMAN (DRM 2.43.0, LLVM 3.8.0)
Version=OpenGL ES 3.0 Mesa 11.2.2
ShadingLanguageVersion=OpenGL ES GLSL ES 3.00
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=3,0
GLSLVersion=3,0
GLES=true
MesaVersion=11,2,2
GalliumVersion=0,4
DriverVersion=11,2,2
Driver=5
ChipClass=8
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Gallium 0.4 on AMD HAWAII (DRM 2.43.0, LLVM 3.7.1)
Version=3.0 Mesa 11.1.2
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=11,1,2
GalliumVersion=0,4
DriverVersion=11,1,2
Driver=16
ChipClass=10
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=AMD NAVI10 (DRM 3.36.0, 5.5.1-arch1-1, LLVM 9.0.1)
Version=4.5 (Core Profile) Mesa 19.3.3
ShadingLanguageVersion=4.50
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,5
GLSLVersion=4,50
MesaVersion=19,3,3
GalliumVersion=0,4
DriverVersion=19,3,3
Driver=16
ChipClass=14
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=AMD Radeon R9 200 Series (HAWAII DRM 3.26.0 4.18.9-92.current LLVM 6.0.1)
Version=4.5 Mesa 18.1.6
ShadingLanguageVersion=4.50
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,5
GLSLVersion=4,50
MesaVersion=18,1,6
GalliumVersion=0,4
DriverVersion=18,1,6
Driver=16
ChipClass=10
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=AMD Radeon (TM) RX 480 Graphics (POLARIS10 / DRM 3.23.0 / 4.15.0-rc1-g516fb7f2e73d, LLVM 6.0.0)
Version=4.5 (Core Profile) Mesa 17.4.0-devel (git-b6b4b2c6d8)
ShadingLanguageVersion=4.50
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,5
GLSLVersion=4,50
MesaVersion=17,4,0
GalliumVersion=0,4
DriverVersion=17,4,0
Driver=16
ChipClass=12
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Radeon RX 550 Series (POLARIS12, DRM 3.25.0, 4.17.0-rc6-GTW1+, LLVM 6.0.0)
Version=3.1 Mesa 18.1.0
ShadingLanguageVersion=1.40
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=3,1
GLSLVersion=1,40
MesaVersion=18,1,0
GalliumVersion=0,4
DriverVersion=18,1,0
Driver=16
ChipClass=12
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=AMD
Renderer=AMD Radeon RX 5700 XT (NAVI10, DRM 3.40.0, 5.10.9-arch1-1, LLVM 11.0.1)
Version=4.6 (Compatibility Profile) Mesa 20.3.3
ShadingLanguageVersion=4.60
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,6
GLSLVersion=4,60
MesaVersion=20,3,3
GalliumVersion=0,4
DriverVersion=20,3,3
Driver=16
ChipClass=14
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Radeon RX 580 Series (POLARIS10, DRM 3.27.0, 4.19.10-arch1-1-ARCH, LLVM 7.0.0)
Version=4.5 (Compatibility Profile) Mesa 18.3.1
ShadingLanguageVersion=4.50
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,5
GLSLVersion=4,50
MesaVersion=18,3,1
GalliumVersion=0,4
DriverVersion=18,3,1
Driver=16
ChipClass=12
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Radeon RX Vega (VEGA10, DRM 3.25.0, 4.17.0-trunk-amd64, LLVM 6.0.0)
Version=4.5 (Core Profile) Mesa 18.1.2
ShadingLanguageVersion=4.50
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,5
GLSLVersion=4,50
MesaVersion=18,1,2
GalliumVersion=0,4
DriverVersion=18,1,2
Driver=16
ChipClass=13
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Radeon RX Vega (VEGA10 / DRM 3.23.0 / 4.16.16-300.fc28.x86_64, LLVM 6.0.0)
Version=4.5 (Core Profile) Mesa 18.0.5
ShadingLanguageVersion=4.50
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,5
GLSLVersion=4,50
MesaVersion=18,0,5
GalliumVersion=0,4
DriverVersion=18,0,5
Driver=16
ChipClass=13
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Gallium 0.4 on AMD REDWOOD (DRM 2.43.0 / 4.6.4-1-ARCH, LLVM 3.8.0)
Version=3.0 Mesa 12.0.1
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=12,0,1
GalliumVersion=0,4
DriverVersion=12,0,1
Driver=5
ChipClass=7
Compositor=1

View File

@ -1,21 +0,0 @@
[Driver]
Vendor=X.Org
Renderer=Gallium 0.4 on AMD TONGA (DRM 3.2.0 / 4.7.0-0-MANJARO, LLVM 3.8.0)
Version=4.1 (Core Profile) Mesa 12.0.1
ShadingLanguageVersion=4.10
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Radeon=true
GLVersion=4,1
GLSLVersion=4,10
MesaVersion=12,0,1
GalliumVersion=0,4
DriverVersion=12,0,1
Driver=16
ChipClass=11
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2)
Version=3.3 (Core Profile) Mesa 11.2.2
ShadingLanguageVersion=3.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,3
GLSLVersion=3,30
MesaVersion=11,2,2
DriverVersion=11,2,2
Driver=7
ChipClass=2999
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) Haswell Mobile
Version=3.3 (Core Profile) Mesa 11.2.2
ShadingLanguageVersion=3.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,3
GLSLVersion=3,30
MesaVersion=11,2,2
DriverVersion=11,2,2
Driver=7
ChipClass=2005
Compositor=1

View File

@ -1,20 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) Ivybridge Desktop
Version=3.0 Mesa 11.1.0 (git-525f3c2)
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=11,1,0
DriverVersion=11,1,0
Driver=7
ChipClass=2004
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) Ivybridge Desktop
Version=3.3 (Core Profile) Mesa 11.2.2
ShadingLanguageVersion=3.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,3
GLSLVersion=3,30
MesaVersion=11,2,2
DriverVersion=11,2,2
Driver=7
ChipClass=2004
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) Ivybridge Mobile
Version=3.3 (Core Profile) Mesa 12.0.1
ShadingLanguageVersion=3.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,3
GLSLVersion=3,30
MesaVersion=12,0,1
DriverVersion=12,0,1
Driver=7
ChipClass=2004
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel
Renderer=Mesa Intel(R) UHD Graphics 620 (KBL GT2)
Version=4.6 (Compatibility Profile) Mesa 20.3.2
ShadingLanguageVersion=4.60
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=4,6
GLSLVersion=4,60
MesaVersion=20,3,2
DriverVersion=20,3,2
Driver=7
ChipClass=2012
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) Sandybridge Mobile
Version=3.3 (Core Profile) Mesa 12.0.1
ShadingLanguageVersion=3.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,3
GLSLVersion=3,30
MesaVersion=12,0,1
DriverVersion=12,0,1
Driver=7
ChipClass=2003
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Intel Open Source Technology Center
Renderer=Mesa DRI Intel(R) HD Graphics 520 (Skylake GT2)
Version=3.0 Mesa 11.2.0
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Intel=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=11,2,0
DriverVersion=11,2,0
Driver=7
ChipClass=2999
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Mali (Lima)
Renderer=Mali 400 (Lima)
Version=3.0 Mesa 19.1
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Lima=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=19,1
DriverVersion=19,1
Driver=19
ChipClass=5000
Compositor=1

View File

@ -1,22 +0,0 @@
[Driver]
Vendor=Mesa/X.org
Renderer=llvmpipe (LLVM 10.0.1, 256 bits)
Version=3.1 Mesa 20.2.1
ShadingLanguageVersion=1.40
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
SoftwareEmulation=true
GLVersion=3,1
GLSLVersion=1,40
MesaVersion=20,2,1
GalliumVersion=0,4
DriverVersion=20,2,1
Driver=12
ChipClass=99999
Compositor=1

View File

@ -1,22 +0,0 @@
[Driver]
Vendor=VMware, Inc.
Renderer=Gallium 0.4 on llvmpipe (LLVM 3.8, 256 bits)
Version=3.0 Mesa 11.2.0
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
SoftwareEmulation=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=11,2,0
GalliumVersion=0,4
DriverVersion=11,2,0
Driver=12
ChipClass=99999
Compositor=1

View File

@ -1,22 +0,0 @@
[Driver]
Vendor=VMware, Inc.
Renderer=llvmpipe (LLVM 5.0, 256 bits)
Version=3.0 Mesa 17.2.6
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
SoftwareEmulation=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=17,2,6
GalliumVersion=0,4
DriverVersion=17,2,6
Driver=12
ChipClass=99999
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=NVIDIA Corporation
Renderer=GeForce GTX 560/PCIe/SSE2
Version=4.5.0 NVIDIA 361.28
ShadingLanguageVersion=4.50 NVIDIA
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Nvidia=true
PreferBufferSubData=true
GLVersion=4,5
GLSLVersion=4,50
DriverVersion=361,28
Driver=8
ChipClass=1005
Compositor=1

View File

@ -1,18 +0,0 @@
[Driver]
Vendor=NVIDIA Corporation
Renderer=GeForce GTX 660/PCIe/SSE2
Version=3.1.0 NVIDIA 367.27
ShadingLanguageVersion=1.40 NVIDIA via Cg compiler
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Nvidia=true
PreferBufferSubData=true
GLVersion=3,1
GLSLVersion=1,40
DriverVersion=367,27
Driver=8
ChipClass=1999
Compositor=1

View File

@ -1,18 +0,0 @@
[Driver]
Vendor=NVIDIA Corporation
Renderer=GeForce GTX 950/PCIe/SSE2
Version=4.5.0 NVIDIA 364.19
ShadingLanguageVersion=4.50 NVIDIA
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Nvidia=true
PreferBufferSubData=true
GLVersion=4,5
GLSLVersion=4,50
DriverVersion=364,19
Driver=8
ChipClass=1999
Compositor=1

View File

@ -1,18 +0,0 @@
[Driver]
Vendor=NVIDIA Corporation
Renderer=GeForce GTX 970/PCIe/SSE2
Version=3.1.0 NVIDIA 367.35
ShadingLanguageVersion=1.40 NVIDIA via Cg compiler
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Nvidia=true
PreferBufferSubData=true
GLVersion=3,1
GLSLVersion=1,40
DriverVersion=367,35
Driver=8
ChipClass=1999
Compositor=1

View File

@ -1,18 +0,0 @@
[Driver]
Vendor=NVIDIA Corporation
Renderer=GeForce GTX 970M/PCIe/SSE2
Version=3.1.0 NVIDIA 364.12
ShadingLanguageVersion=1.40 NVIDIA via Cg compiler
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Nvidia=true
PreferBufferSubData=true
GLVersion=3,1
GLSLVersion=1,40
DriverVersion=364,12
Driver=8
ChipClass=1999
Compositor=1

View File

@ -1,18 +0,0 @@
[Driver]
Vendor=NVIDIA Corporation
Renderer=GeForce GTX 980/PCIe/SSE2
Version=3.1.0 NVIDIA 364.19
ShadingLanguageVersion=1.40 NVIDIA via Cg compiler
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Nvidia=true
PreferBufferSubData=true
GLVersion=3,1
GLSLVersion=1,40
DriverVersion=364,19
Driver=8
ChipClass=1999
Compositor=1

View File

@ -1,19 +0,0 @@
[Driver]
Vendor=Panfrost
Renderer=Mali T860 (Panfrost)
Version=3.0 Mesa 19.1
ShadingLanguageVersion=1.30
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Panfrost=true
GLVersion=3,0
GLSLVersion=1,30
MesaVersion=19,1
DriverVersion=19,1
Driver=18
ChipClass=4001
Compositor=1

View File

@ -1,16 +0,0 @@
[Driver]
Vendor=Qualcomm
Renderer=Adreno (TM) 330
Version=OpenGL ES 2.0 (OpenGL ES 3.0 V@104.0 AU@ (GIT@Id3510ff6dc))
ShadingLanguageVersion=OpenGL ES GLSL ES 3.00
[Settings]
GLSL=true
TextureNPOT=true
GLVersion=2,0
GLSLVersion=3,0
GLES=true
Adreno=true
Driver=15
ChipClass=3002
Compositor=1

View File

@ -1,22 +0,0 @@
[Driver]
Vendor=Red Hat
Renderer=virgl
Version=3.1 Mesa 19.0.8
ShadingLanguageVersion=1.40
[Settings]
LooseBinding=true
GLSL=true
TextureNPOT=true
Mesa=true
Gallium=true
Virgl=true
VirtualMachine=true
GLVersion=3,1
GLSLVersion=1,40
MesaVersion=19,0,8
GalliumVersion=0,4
DriverVersion=19,0,8
Driver=17
ChipClass=99999
Compositor=1

View File

@ -1,215 +0,0 @@
/*
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 "opengl/glplatform.h"
#include <QTest>
#include <KConfig>
#include <KConfigGroup>
Q_DECLARE_METATYPE(KWin::Driver)
Q_DECLARE_METATYPE(KWin::ChipClass)
using namespace KWin;
class GLPlatformTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testDriverToString_data();
void testDriverToString();
void testChipClassToString_data();
void testChipClassToString();
void testDetect_data();
void testDetect();
};
void GLPlatformTest::testDriverToString_data()
{
QTest::addColumn<Driver>("driver");
QTest::addColumn<QString>("expected");
QTest::newRow("R100") << Driver_R100 << QStringLiteral("Radeon");
QTest::newRow("R200") << Driver_R200 << QStringLiteral("R200");
QTest::newRow("R300C") << Driver_R300C << QStringLiteral("R300C");
QTest::newRow("R300G") << Driver_R300G << QStringLiteral("R300G");
QTest::newRow("R600C") << Driver_R600C << QStringLiteral("R600C");
QTest::newRow("R600G") << Driver_R600G << QStringLiteral("R600G");
QTest::newRow("RadeonSI") << Driver_RadeonSI << QStringLiteral("RadeonSI");
QTest::newRow("Nouveau") << Driver_Nouveau << QStringLiteral("Nouveau");
QTest::newRow("Intel") << Driver_Intel << QStringLiteral("Intel");
QTest::newRow("NVidia") << Driver_NVidia << QStringLiteral("NVIDIA");
QTest::newRow("Catalyst") << Driver_Catalyst << QStringLiteral("Catalyst");
QTest::newRow("Swrast") << Driver_Swrast << QStringLiteral("Software rasterizer");
QTest::newRow("Softpipe") << Driver_Softpipe << QStringLiteral("softpipe");
QTest::newRow("Llvmpipe") << Driver_Llvmpipe << QStringLiteral("LLVMpipe");
QTest::newRow("VirtualBox") << Driver_VirtualBox << QStringLiteral("VirtualBox (Chromium)");
QTest::newRow("VMware") << Driver_VMware << QStringLiteral("VMware (SVGA3D)");
QTest::newRow("Qualcomm") << Driver_Qualcomm << QStringLiteral("Qualcomm");
QTest::newRow("Virgl") << Driver_Virgl << QStringLiteral("Virgl (virtio-gpu, Qemu/KVM guest)");
QTest::newRow("Panfrost") << Driver_Panfrost << QStringLiteral("Panfrost");
QTest::newRow("Lima") << Driver_Lima << QStringLiteral("Mali (Lima)");
QTest::newRow("VC4") << Driver_VC4 << QStringLiteral("VideoCore IV");
QTest::newRow("V3D") << Driver_V3D << QStringLiteral("VideoCore 3D");
QTest::newRow("Unknown") << Driver_Unknown << QStringLiteral("Unknown");
}
void GLPlatformTest::testDriverToString()
{
QFETCH(Driver, driver);
QTEST(GLPlatform::driverToString(driver), "expected");
}
void GLPlatformTest::testChipClassToString_data()
{
QTest::addColumn<ChipClass>("chipClass");
QTest::addColumn<QString>("expected");
QTest::newRow("R100") << R100 << QStringLiteral("R100");
QTest::newRow("R200") << R200 << QStringLiteral("R200");
QTest::newRow("R300") << R300 << QStringLiteral("R300");
QTest::newRow("R400") << R400 << QStringLiteral("R400");
QTest::newRow("R500") << R500 << QStringLiteral("R500");
QTest::newRow("R600") << R600 << QStringLiteral("R600");
QTest::newRow("R700") << R700 << QStringLiteral("R700");
QTest::newRow("Evergreen") << Evergreen << QStringLiteral("EVERGREEN");
QTest::newRow("NorthernIslands") << NorthernIslands << QStringLiteral("Northern Islands");
QTest::newRow("SouthernIslands") << SouthernIslands << QStringLiteral("Southern Islands");
QTest::newRow("SeaIslands") << SeaIslands << QStringLiteral("Sea Islands");
QTest::newRow("VolcanicIslands") << VolcanicIslands << QStringLiteral("Volcanic Islands");
QTest::newRow("Arctic Islands") << ArcticIslands << QStringLiteral("Arctic Islands");
QTest::newRow("Vega") << Vega << QStringLiteral("Vega");
QTest::newRow("UnknownRadeon") << UnknownRadeon << QStringLiteral("Unknown");
QTest::newRow("NV10") << NV10 << QStringLiteral("NV10");
QTest::newRow("NV20") << NV20 << QStringLiteral("NV20");
QTest::newRow("NV30") << NV30 << QStringLiteral("NV30");
QTest::newRow("NV40") << NV40 << QStringLiteral("NV40/G70");
QTest::newRow("G80") << G80 << QStringLiteral("G80/G90");
QTest::newRow("GF100") << GF100 << QStringLiteral("GF100");
QTest::newRow("UnknownNVidia") << UnknownNVidia << QStringLiteral("Unknown");
QTest::newRow("I8XX") << I8XX << QStringLiteral("i830/i835");
QTest::newRow("I915") << I915 << QStringLiteral("i915/i945");
QTest::newRow("I965") << I965 << QStringLiteral("i965");
QTest::newRow("SandyBridge") << SandyBridge << QStringLiteral("SandyBridge");
QTest::newRow("IvyBridge") << IvyBridge << QStringLiteral("IvyBridge");
QTest::newRow("Haswell") << Haswell << QStringLiteral("Haswell");
QTest::newRow("UnknownIntel") << UnknownIntel << QStringLiteral("Unknown");
QTest::newRow("Adreno1XX") << Adreno1XX << QStringLiteral("Adreno 1xx series");
QTest::newRow("Adreno2XX") << Adreno2XX << QStringLiteral("Adreno 2xx series");
QTest::newRow("Adreno3XX") << Adreno3XX << QStringLiteral("Adreno 3xx series");
QTest::newRow("Adreno4XX") << Adreno4XX << QStringLiteral("Adreno 4xx series");
QTest::newRow("Adreno5XX") << Adreno5XX << QStringLiteral("Adreno 5xx series");
QTest::newRow("UnknownAdreno") << UnknownAdreno << QStringLiteral("Unknown");
QTest::newRow("MaliT7XX") << MaliT7XX << QStringLiteral("Mali T7xx series");
QTest::newRow("MaliT8XX") << MaliT8XX << QStringLiteral("Mali T8xx series");
QTest::newRow("MaliGXX") << MaliGXX << QStringLiteral("Mali Gxx series");
QTest::newRow("UnknownPanfrost") << UnknownPanfrost << QStringLiteral("Unknown");
QTest::newRow("Mali400") << Mali400 << QStringLiteral("Mali 400 series");
QTest::newRow("Mali450") << Mali450 << QStringLiteral("Mali 450 series");
QTest::newRow("Mali470") << Mali470 << QStringLiteral("Mali 470 series");
QTest::newRow("UnknownLima") << UnknownLima << QStringLiteral("Unknown");
QTest::newRow("VC4_2_1") << VC4_2_1 << QStringLiteral("VideoCore IV");
QTest::newRow("UnknownVideoCore4") << UnknownVideoCore4 << QStringLiteral("Unknown");
QTest::newRow("V3D_4_2") << V3D_4_2 << QStringLiteral("VideoCore 3D");
QTest::newRow("UnknownVideoCore3D") << UnknownVideoCore3D << QStringLiteral("Unknown");
QTest::newRow("UnknownChipClass") << UnknownChipClass << QStringLiteral("Unknown");
}
void GLPlatformTest::testChipClassToString()
{
QFETCH(ChipClass, chipClass);
QTEST(GLPlatform::chipClassToString(chipClass), "expected");
}
void GLPlatformTest::testDetect_data()
{
QTest::addColumn<QString>("configFile");
QDir dir(QFINDTESTDATA("data/glplatform"));
const QStringList entries = dir.entryList(QDir::NoDotAndDotDot | QDir::Files);
for (const QString &file : entries) {
QTest::newRow(file.toUtf8().constData()) << dir.absoluteFilePath(file);
}
}
static Version readVersion(const KConfigGroup &group, const char *entry)
{
const QStringList parts = group.readEntry(entry, QString()).split(',');
if (parts.count() < 2) {
return Version();
}
QList<qint64> versionParts;
for (int i = 0; i < parts.count(); ++i) {
bool ok = false;
const auto value = parts.at(i).toLongLong(&ok);
if (ok) {
versionParts << value;
} else {
versionParts << 0;
}
}
while (versionParts.count() < 3) {
versionParts << 0;
}
return Version(versionParts.at(0), versionParts.at(1), versionParts.at(2));
}
void GLPlatformTest::testDetect()
{
QFETCH(QString, configFile);
KConfig config(configFile);
const KConfigGroup driverGroup = config.group(QStringLiteral("Driver"));
const auto version = driverGroup.readEntry("Version").toUtf8();
const auto glslVersion = driverGroup.readEntry("ShadingLanguageVersion").toUtf8();
const auto renderer = driverGroup.readEntry("Renderer").toUtf8();
const auto vendor = driverGroup.readEntry("Vendor").toUtf8();
GLPlatform gl(EglPlatformInterface, version, glslVersion, renderer, vendor);
QCOMPARE(gl.platformInterface(), EglPlatformInterface);
const KConfigGroup settingsGroup = config.group(QStringLiteral("Settings"));
QCOMPARE(gl.isLooseBinding(), settingsGroup.readEntry("LooseBinding", false));
QCOMPARE(gl.glVersion(), readVersion(settingsGroup, "GLVersion"));
QCOMPARE(gl.glslVersion(), readVersion(settingsGroup, "GLSLVersion"));
QCOMPARE(gl.mesaVersion(), readVersion(settingsGroup, "MesaVersion"));
QEXPECT_FAIL("amd-catalyst-radeonhd-7700M-3.1.13399", "Detects GL version instead of driver version", Continue);
QCOMPARE(gl.driverVersion(), readVersion(settingsGroup, "DriverVersion"));
QCOMPARE(gl.driver(), Driver(settingsGroup.readEntry("Driver", int(Driver_Unknown))));
QCOMPARE(gl.chipClass(), ChipClass(settingsGroup.readEntry("ChipClass", int(UnknownChipClass))));
QCOMPARE(gl.isMesaDriver(), settingsGroup.readEntry("Mesa", false));
QCOMPARE(gl.isRadeon(), settingsGroup.readEntry("Radeon", false));
QCOMPARE(gl.isNvidia(), settingsGroup.readEntry("Nvidia", false));
QCOMPARE(gl.isIntel(), settingsGroup.readEntry("Intel", false));
QCOMPARE(gl.isVirtualBox(), settingsGroup.readEntry("VirtualBox", false));
QCOMPARE(gl.isVMware(), settingsGroup.readEntry("VMware", false));
QCOMPARE(gl.isAdreno(), settingsGroup.readEntry("Adreno", false));
QCOMPARE(gl.isPanfrost(), settingsGroup.readEntry("Panfrost", false));
QCOMPARE(gl.isLima(), settingsGroup.readEntry("Lima", false));
QCOMPARE(gl.isVideoCore4(), settingsGroup.readEntry("VC4", false));
QCOMPARE(gl.isVideoCore3D(), settingsGroup.readEntry("V3D", false));
QCOMPARE(gl.isVirgl(), settingsGroup.readEntry("Virgl", false));
QCOMPARE(gl.isVirtualMachine(), settingsGroup.readEntry("VirtualMachine", false));
QCOMPARE(gl.glVersionString(), version);
QCOMPARE(gl.glRendererString(), renderer);
QCOMPARE(gl.glVendorString(), vendor);
QCOMPARE(gl.glShadingLanguageVersionString(), glslVersion);
QCOMPARE(gl.isLooseBinding(), settingsGroup.readEntry("LooseBinding", false));
QCOMPARE(gl.recommendedCompositor(), CompositingType(settingsGroup.readEntry("Compositor", int(NoCompositing))));
QCOMPARE(gl.preferBufferSubData(), settingsGroup.readEntry("PreferBufferSubData", false));
}
QTEST_GUILESS_MAIN(GLPlatformTest)
#include "kwinglplatformtest.moc"

View File

@ -1,415 +0,0 @@
/*
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 "effect/timeline.h"
#include <QTest>
using namespace std::chrono_literals;
// FIXME: Delete it in the future.
Q_DECLARE_METATYPE(std::chrono::milliseconds)
class TimeLineTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testUpdateForward();
void testUpdateBackward();
void testUpdateFinished();
void testToggleDirection();
void testReset();
void testSetElapsed_data();
void testSetElapsed();
void testSetDuration();
void testSetDurationRetargeting();
void testSetDurationRetargetingSmallDuration();
void testRunning();
void testStrictRedirectSourceMode_data();
void testStrictRedirectSourceMode();
void testRelaxedRedirectSourceMode_data();
void testRelaxedRedirectSourceMode();
void testStrictRedirectTargetMode_data();
void testStrictRedirectTargetMode();
void testRelaxedRedirectTargetMode_data();
void testRelaxedRedirectTargetMode();
};
void TimeLineTest::testUpdateForward()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
// 0/1000
timeLine.advance(0ms);
QCOMPARE(timeLine.value(), 0.0);
QVERIFY(!timeLine.done());
// 100/1000
timeLine.advance(100ms);
QCOMPARE(timeLine.value(), 0.1);
QVERIFY(!timeLine.done());
// 400/1000
timeLine.advance(400ms);
QCOMPARE(timeLine.value(), 0.4);
QVERIFY(!timeLine.done());
// 900/1000
timeLine.advance(900ms);
QCOMPARE(timeLine.value(), 0.9);
QVERIFY(!timeLine.done());
// 1000/1000
timeLine.advance(3000ms);
QCOMPARE(timeLine.value(), 1.0);
QVERIFY(timeLine.done());
}
void TimeLineTest::testUpdateBackward()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Backward);
timeLine.setEasingCurve(QEasingCurve::Linear);
// 0/1000
timeLine.advance(0ms);
QCOMPARE(timeLine.value(), 1.0);
QVERIFY(!timeLine.done());
// 100/1000
timeLine.advance(100ms);
QCOMPARE(timeLine.value(), 0.9);
QVERIFY(!timeLine.done());
// 400/1000
timeLine.advance(400ms);
QCOMPARE(timeLine.value(), 0.6);
QVERIFY(!timeLine.done());
// 900/1000
timeLine.advance(900ms);
QCOMPARE(timeLine.value(), 0.1);
QVERIFY(!timeLine.done());
// 1000/1000
timeLine.advance(3000ms);
QCOMPARE(timeLine.value(), 0.0);
QVERIFY(timeLine.done());
}
void TimeLineTest::testUpdateFinished()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.advance(0ms);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(1000ms);
QCOMPARE(timeLine.value(), 1.0);
QVERIFY(timeLine.done());
timeLine.advance(1042ms);
QCOMPARE(timeLine.value(), 1.0);
QVERIFY(timeLine.done());
}
void TimeLineTest::testToggleDirection()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(0ms);
QCOMPARE(timeLine.value(), 0.0);
QVERIFY(!timeLine.done());
timeLine.advance(600ms);
QCOMPARE(timeLine.value(), 0.6);
QVERIFY(!timeLine.done());
timeLine.toggleDirection();
QCOMPARE(timeLine.value(), 0.6);
QVERIFY(!timeLine.done());
timeLine.advance(800ms);
QCOMPARE(timeLine.value(), 0.4);
QVERIFY(!timeLine.done());
timeLine.advance(3000ms);
QCOMPARE(timeLine.value(), 0.0);
QVERIFY(timeLine.done());
}
void TimeLineTest::testReset()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(0ms);
timeLine.advance(1000ms);
QCOMPARE(timeLine.value(), 1.0);
QVERIFY(timeLine.done());
timeLine.reset();
QCOMPARE(timeLine.value(), 0.0);
QVERIFY(!timeLine.done());
}
void TimeLineTest::testSetElapsed_data()
{
QTest::addColumn<std::chrono::milliseconds>("duration");
QTest::addColumn<std::chrono::milliseconds>("elapsed");
QTest::addColumn<std::chrono::milliseconds>("expectedElapsed");
QTest::addColumn<bool>("expectedDone");
QTest::addColumn<bool>("initiallyDone");
QTest::newRow("Less than duration, not finished") << 1000ms << 300ms << 300ms << false << false;
QTest::newRow("Less than duration, finished") << 1000ms << 300ms << 300ms << false << true;
QTest::newRow("Greater than duration, not finished") << 1000ms << 3000ms << 1000ms << true << false;
QTest::newRow("Greater than duration, finished") << 1000ms << 3000ms << 1000ms << true << true;
QTest::newRow("Equal to duration, not finished") << 1000ms << 1000ms << 1000ms << true << false;
QTest::newRow("Equal to duration, finished") << 1000ms << 1000ms << 1000ms << true << true;
}
void TimeLineTest::testSetElapsed()
{
QFETCH(std::chrono::milliseconds, duration);
QFETCH(std::chrono::milliseconds, elapsed);
QFETCH(std::chrono::milliseconds, expectedElapsed);
QFETCH(bool, expectedDone);
QFETCH(bool, initiallyDone);
KWin::TimeLine timeLine(duration, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(0ms);
if (initiallyDone) {
timeLine.advance(duration);
QVERIFY(timeLine.done());
}
timeLine.setElapsed(elapsed);
QCOMPARE(timeLine.elapsed(), expectedElapsed);
QCOMPARE(timeLine.done(), expectedDone);
}
void TimeLineTest::testSetDuration()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
QCOMPARE(timeLine.duration(), 1000ms);
timeLine.setDuration(3000ms);
QCOMPARE(timeLine.duration(), 3000ms);
}
void TimeLineTest::testSetDurationRetargeting()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(0ms);
timeLine.advance(500ms);
QCOMPARE(timeLine.value(), 0.5);
QVERIFY(!timeLine.done());
timeLine.setDuration(3000ms);
QCOMPARE(timeLine.value(), 0.5);
QVERIFY(!timeLine.done());
}
void TimeLineTest::testSetDurationRetargetingSmallDuration()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(0ms);
timeLine.advance(999ms);
QCOMPARE(timeLine.value(), 0.999);
QVERIFY(!timeLine.done());
timeLine.setDuration(3ms);
QCOMPARE(timeLine.value(), 1.0);
QVERIFY(timeLine.done());
}
void TimeLineTest::testRunning()
{
KWin::TimeLine timeLine(1000ms, KWin::TimeLine::Forward);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.advance(0ms);
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
timeLine.advance(100ms);
QVERIFY(timeLine.running());
QVERIFY(!timeLine.done());
timeLine.advance(1000ms);
QVERIFY(!timeLine.running());
QVERIFY(timeLine.done());
}
void TimeLineTest::testStrictRedirectSourceMode_data()
{
QTest::addColumn<KWin::TimeLine::Direction>("initialDirection");
QTest::addColumn<qreal>("initialValue");
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 0.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 1.0;
}
void TimeLineTest::testStrictRedirectSourceMode()
{
QFETCH(KWin::TimeLine::Direction, initialDirection);
KWin::TimeLine timeLine(1000ms, initialDirection);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.setSourceRedirectMode(KWin::TimeLine::RedirectMode::Strict);
QTEST(timeLine.direction(), "initialDirection");
QTEST(timeLine.value(), "initialValue");
QCOMPARE(timeLine.sourceRedirectMode(), KWin::TimeLine::RedirectMode::Strict);
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
QFETCH(KWin::TimeLine::Direction, finalDirection);
timeLine.setDirection(finalDirection);
QTEST(timeLine.direction(), "finalDirection");
QTEST(timeLine.value(), "finalValue");
QCOMPARE(timeLine.sourceRedirectMode(), KWin::TimeLine::RedirectMode::Strict);
QVERIFY(!timeLine.running());
QVERIFY(timeLine.done());
}
void TimeLineTest::testRelaxedRedirectSourceMode_data()
{
QTest::addColumn<KWin::TimeLine::Direction>("initialDirection");
QTest::addColumn<qreal>("initialValue");
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
}
void TimeLineTest::testRelaxedRedirectSourceMode()
{
QFETCH(KWin::TimeLine::Direction, initialDirection);
KWin::TimeLine timeLine(1000ms, initialDirection);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.setSourceRedirectMode(KWin::TimeLine::RedirectMode::Relaxed);
QTEST(timeLine.direction(), "initialDirection");
QTEST(timeLine.value(), "initialValue");
QCOMPARE(timeLine.sourceRedirectMode(), KWin::TimeLine::RedirectMode::Relaxed);
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
QFETCH(KWin::TimeLine::Direction, finalDirection);
timeLine.setDirection(finalDirection);
QTEST(timeLine.direction(), "finalDirection");
QTEST(timeLine.value(), "finalValue");
QCOMPARE(timeLine.sourceRedirectMode(), KWin::TimeLine::RedirectMode::Relaxed);
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
}
void TimeLineTest::testStrictRedirectTargetMode_data()
{
QTest::addColumn<KWin::TimeLine::Direction>("initialDirection");
QTest::addColumn<qreal>("initialValue");
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
}
void TimeLineTest::testStrictRedirectTargetMode()
{
QFETCH(KWin::TimeLine::Direction, initialDirection);
KWin::TimeLine timeLine(1000ms, initialDirection);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.setTargetRedirectMode(KWin::TimeLine::RedirectMode::Strict);
timeLine.advance(0ms);
QTEST(timeLine.direction(), "initialDirection");
QTEST(timeLine.value(), "initialValue");
QCOMPARE(timeLine.targetRedirectMode(), KWin::TimeLine::RedirectMode::Strict);
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
timeLine.advance(1000ms);
QTEST(timeLine.value(), "finalValue");
QVERIFY(!timeLine.running());
QVERIFY(timeLine.done());
QFETCH(KWin::TimeLine::Direction, finalDirection);
timeLine.setDirection(finalDirection);
QTEST(timeLine.direction(), "finalDirection");
QTEST(timeLine.value(), "finalValue");
QVERIFY(!timeLine.running());
QVERIFY(timeLine.done());
}
void TimeLineTest::testRelaxedRedirectTargetMode_data()
{
QTest::addColumn<KWin::TimeLine::Direction>("initialDirection");
QTest::addColumn<qreal>("initialValue");
QTest::addColumn<KWin::TimeLine::Direction>("finalDirection");
QTest::addColumn<qreal>("finalValue");
QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0;
QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0;
}
void TimeLineTest::testRelaxedRedirectTargetMode()
{
QFETCH(KWin::TimeLine::Direction, initialDirection);
KWin::TimeLine timeLine(1000ms, initialDirection);
timeLine.setEasingCurve(QEasingCurve::Linear);
timeLine.setTargetRedirectMode(KWin::TimeLine::RedirectMode::Relaxed);
timeLine.advance(0ms);
QTEST(timeLine.direction(), "initialDirection");
QTEST(timeLine.value(), "initialValue");
QCOMPARE(timeLine.targetRedirectMode(), KWin::TimeLine::RedirectMode::Relaxed);
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
timeLine.advance(1000ms);
QTEST(timeLine.value(), "finalValue");
QVERIFY(!timeLine.running());
QVERIFY(timeLine.done());
QFETCH(KWin::TimeLine::Direction, finalDirection);
timeLine.setDirection(finalDirection);
timeLine.advance(1000ms);
QTEST(timeLine.direction(), "finalDirection");
QTEST(timeLine.value(), "finalValue");
QVERIFY(!timeLine.running());
QVERIFY(!timeLine.done());
timeLine.advance(2000ms);
QTEST(timeLine.direction(), "finalDirection");
QTEST(timeLine.value(), "initialValue");
QVERIFY(!timeLine.running());
QVERIFY(timeLine.done());
}
QTEST_MAIN(TimeLineTest)
#include "timelinetest.moc"

View File

@ -1,214 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "scene/itemgeometry.h"
#include <QTest>
Q_DECLARE_METATYPE(KWin::WindowQuadList)
class WindowQuadListTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testMakeGrid_data();
void testMakeGrid();
void testMakeRegularGrid_data();
void testMakeRegularGrid();
private:
KWin::WindowQuad makeQuad(const QRectF &rect);
};
KWin::WindowQuad WindowQuadListTest::makeQuad(const QRectF &r)
{
KWin::WindowQuad quad;
quad[0] = KWin::WindowVertex(r.x(), r.y(), r.x(), r.y());
quad[1] = KWin::WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width(), r.y());
quad[2] = KWin::WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height());
quad[3] = KWin::WindowVertex(r.x(), r.y() + r.height(), r.x(), r.y() + r.height());
return quad;
}
void WindowQuadListTest::testMakeGrid_data()
{
QTest::addColumn<KWin::WindowQuadList>("orig");
QTest::addColumn<int>("quadSize");
QTest::addColumn<int>("expectedCount");
QTest::addColumn<KWin::WindowQuadList>("expected");
KWin::WindowQuadList orig;
KWin::WindowQuadList expected;
QTest::newRow("empty") << orig << 10 << 0 << expected;
orig.append(makeQuad(QRectF(0, 0, 10, 10)));
expected.append(makeQuad(QRectF(0, 0, 10, 10)));
QTest::newRow("quadSizeTooLarge") << orig << 10 << 1 << expected;
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 5, 5)));
expected.append(makeQuad(QRectF(0, 5, 5, 5)));
expected.append(makeQuad(QRectF(5, 0, 5, 5)));
expected.append(makeQuad(QRectF(5, 5, 5, 5)));
QTest::newRow("regularGrid") << orig << 5 << 4 << expected;
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 9, 9)));
expected.append(makeQuad(QRectF(0, 9, 9, 1)));
expected.append(makeQuad(QRectF(9, 0, 1, 9)));
expected.append(makeQuad(QRectF(9, 9, 1, 1)));
QTest::newRow("irregularGrid") << orig << 9 << 4 << expected;
orig.append(makeQuad(QRectF(0, 10, 4, 3)));
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 4, 4)));
expected.append(makeQuad(QRectF(0, 4, 4, 4)));
expected.append(makeQuad(QRectF(0, 8, 4, 2)));
expected.append(makeQuad(QRectF(0, 10, 4, 2)));
expected.append(makeQuad(QRectF(0, 12, 4, 1)));
expected.append(makeQuad(QRectF(4, 0, 4, 4)));
expected.append(makeQuad(QRectF(4, 4, 4, 4)));
expected.append(makeQuad(QRectF(4, 8, 4, 2)));
expected.append(makeQuad(QRectF(8, 0, 2, 4)));
expected.append(makeQuad(QRectF(8, 4, 2, 4)));
expected.append(makeQuad(QRectF(8, 8, 2, 2)));
QTest::newRow("irregularGrid2") << orig << 4 << 11 << expected;
}
void WindowQuadListTest::testMakeGrid()
{
QFETCH(KWin::WindowQuadList, orig);
QFETCH(int, quadSize);
QFETCH(int, expectedCount);
KWin::WindowQuadList actual = orig.makeGrid(quadSize);
QCOMPARE(actual.count(), expectedCount);
QFETCH(KWin::WindowQuadList, expected);
for (auto it = actual.constBegin(); it != actual.constEnd(); ++it) {
bool found = false;
const KWin::WindowQuad &actualQuad = (*it);
for (auto it2 = expected.constBegin(); it2 != expected.constEnd(); ++it2) {
const KWin::WindowQuad &expectedQuad = (*it2);
auto vertexTest = [actualQuad, expectedQuad](int index) {
const KWin::WindowVertex &actualVertex = actualQuad[index];
const KWin::WindowVertex &expectedVertex = expectedQuad[index];
if (actualVertex.x() != expectedVertex.x()) {
return false;
}
if (actualVertex.y() != expectedVertex.y()) {
return false;
}
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) {
return false;
}
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) {
return false;
}
return true;
};
found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3);
if (found) {
break;
}
}
QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), QString::number(actualQuad.top()), QString::number(actualQuad.right()), QString::number(actualQuad.bottom()))));
}
}
void WindowQuadListTest::testMakeRegularGrid_data()
{
QTest::addColumn<KWin::WindowQuadList>("orig");
QTest::addColumn<int>("xSubdivisions");
QTest::addColumn<int>("ySubdivisions");
QTest::addColumn<int>("expectedCount");
QTest::addColumn<KWin::WindowQuadList>("expected");
KWin::WindowQuadList orig;
KWin::WindowQuadList expected;
QTest::newRow("empty") << orig << 1 << 1 << 0 << expected;
orig.append(makeQuad(QRectF(0, 0, 10, 10)));
expected.append(makeQuad(QRectF(0, 0, 10, 10)));
QTest::newRow("noSplit") << orig << 1 << 1 << 1 << expected;
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 5, 10)));
expected.append(makeQuad(QRectF(5, 0, 5, 10)));
QTest::newRow("xSplit") << orig << 2 << 1 << 2 << expected;
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 10, 5)));
expected.append(makeQuad(QRectF(0, 5, 10, 5)));
QTest::newRow("ySplit") << orig << 1 << 2 << 2 << expected;
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 5, 5)));
expected.append(makeQuad(QRectF(5, 0, 5, 5)));
expected.append(makeQuad(QRectF(0, 5, 5, 5)));
expected.append(makeQuad(QRectF(5, 5, 5, 5)));
QTest::newRow("xySplit") << orig << 2 << 2 << 4 << expected;
orig.append(makeQuad(QRectF(0, 10, 4, 2)));
expected.clear();
expected.append(makeQuad(QRectF(0, 0, 5, 3)));
expected.append(makeQuad(QRectF(5, 0, 5, 3)));
expected.append(makeQuad(QRectF(0, 3, 5, 3)));
expected.append(makeQuad(QRectF(5, 3, 5, 3)));
expected.append(makeQuad(QRectF(0, 6, 5, 3)));
expected.append(makeQuad(QRectF(5, 6, 5, 3)));
expected.append(makeQuad(QRectF(0, 9, 5, 1)));
expected.append(makeQuad(QRectF(0, 10, 4, 2)));
expected.append(makeQuad(QRectF(5, 9, 5, 1)));
QTest::newRow("multipleQuads") << orig << 2 << 4 << 9 << expected;
}
void WindowQuadListTest::testMakeRegularGrid()
{
QFETCH(KWin::WindowQuadList, orig);
QFETCH(int, xSubdivisions);
QFETCH(int, ySubdivisions);
QFETCH(int, expectedCount);
KWin::WindowQuadList actual = orig.makeRegularGrid(xSubdivisions, ySubdivisions);
QCOMPARE(actual.count(), expectedCount);
QFETCH(KWin::WindowQuadList, expected);
for (auto it = actual.constBegin(); it != actual.constEnd(); ++it) {
bool found = false;
const KWin::WindowQuad &actualQuad = (*it);
for (auto it2 = expected.constBegin(); it2 != expected.constEnd(); ++it2) {
const KWin::WindowQuad &expectedQuad = (*it2);
auto vertexTest = [actualQuad, expectedQuad](int index) {
const KWin::WindowVertex &actualVertex = actualQuad[index];
const KWin::WindowVertex &expectedVertex = expectedQuad[index];
if (actualVertex.x() != expectedVertex.x()) {
return false;
}
if (actualVertex.y() != expectedVertex.y()) {
return false;
}
if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) {
return false;
}
if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) {
return false;
}
return true;
};
found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3);
if (found) {
break;
}
}
QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), QString::number(actualQuad.top()), QString::number(actualQuad.right()), QString::number(actualQuad.bottom()))));
}
}
QTEST_MAIN(WindowQuadListTest)
#include "windowquadlisttest.moc"

View File

@ -0,0 +1,38 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <kwineffects.h>
namespace KWin
{
class FakeEffect : public Effect
{
Q_OBJECT
public:
FakeEffect() {}
~FakeEffect() override {}
static bool supported() {
return effects->isOpenGLCompositing();
}
static bool enabledByDefault() {
return effects->property("testEnabledByDefault").toBool();
}
};
} // namespace
KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( FakeEffectPluginFactory,
KWin::FakeEffect,
"fakeeffectplugin.json",
return KWin::FakeEffect::supported();,
return KWin::FakeEffect::enabledByDefault();)
#include "fakeeffectplugin.moc"

View File

@ -0,0 +1,13 @@
{
"KPlugin": {
"Id": "fakeeffectplugin",
"ServiceTypes": ["KWin/Effect"]
},
"Type": "Service",
"X-KDE-Library": "fakeeffectplugin",
"X-KDE-PluginInfo-EnabledByDefault": true,
"X-KDE-PluginInfo-Name": "fakeeffectplugin",
"X-KDE-ServiceTypes": [
"KWin/Effect"
]
}

View File

@ -0,0 +1,39 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <kwineffects.h>
namespace KWin
{
class FakeVersionEffect : public Effect
{
Q_OBJECT
public:
FakeVersionEffect() {}
~FakeVersionEffect() override {}
};
} // namespace
class FakeEffectPluginFactory : public KWin::EffectPluginFactory
{
Q_OBJECT
Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "fakeeffectplugin_version.json")
Q_INTERFACES(KPluginFactory)
public:
FakeEffectPluginFactory() {}
~FakeEffectPluginFactory() override {}
KWin::Effect *createEffect() const override {
return new KWin::FakeVersionEffect();
}
};
K_EXPORT_PLUGIN_VERSION(quint32(KWIN_EFFECT_API_VERSION) - 1)
#include "fakeeffectplugin_version.moc"

View File

@ -0,0 +1,13 @@
{
"KPlugin": {
"Id": "effectversion",
"ServiceTypes": ["KWin/Effect"]
},
"Type": "Service",
"X-KDE-Library": "effectversionplugin",
"X-KDE-PluginInfo-EnabledByDefault": true,
"X-KDE-PluginInfo-Name": "effectversion",
"X-KDE-ServiceTypes": [
"KWin/Effect"
]
}

View File

@ -1,189 +1,116 @@
add_subdirectory(helper)
add_library(KWinIntegrationTestFramework STATIC)
set(KWinIntegrationTestFramework_SOURCES
../../cursor.cpp
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_SOURCE_DIR}/src/wayland/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
${WaylandProtocols_DATADIR}/staging/cursor-shape/cursor-shape-v1.xml
${WaylandProtocols_DATADIR}/staging/security-context/security-context-v1.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-screen-edge-v1.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/zkde-screencast-unstable-v1.xml
${PLASMA_WAYLAND_PROTOCOLS_DIR}/fake-input.xml
)
if (Qt6_VERSION VERSION_LESS "6.7.1")
# the qtwaylandscanner macro cannot handle the mismatched file name and <protocol name=""
find_package(QtWaylandScanner REQUIRED)
if (WaylandProtocols_VERSION VERSION_LESS 1.36)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/staging/xdg-dialog/xdg-dialog-v1.xml
BASENAME dialog-v1
)
target_compile_definitions(KWinIntegrationTestFramework PUBLIC
-DHAVE_XDG_DIALOG_V1_HEADER=0
)
else()
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework
PROTOCOL ${WaylandProtocols_DATADIR}/staging/xdg-dialog/xdg-dialog-v1.xml
BASENAME xdg-dialog-v1
)
target_compile_definitions(KWinIntegrationTestFramework PUBLIC
-DHAVE_XDG_DIALOG_V1_HEADER=1
)
endif()
else()
qt6_generate_wayland_protocol_client_sources(KWinIntegrationTestFramework
FILES
${WaylandProtocols_DATADIR}/staging/xdg-dialog/xdg-dialog-v1.xml
)
target_compile_definitions(KWinIntegrationTestFramework PUBLIC
-DHAVE_XDG_DIALOG_V1_HEADER=1
)
endif()
target_sources(KWinIntegrationTestFramework PRIVATE
generic_scene_opengl_test.cpp
kwin_wayland_test.cpp
test_helpers.cpp
)
target_link_libraries(KWinIntegrationTestFramework
PUBLIC
Qt::Test
Qt::Concurrent
Plasma::KWaylandClient
Wayland::Client
Libdrm::Libdrm
kwin
PRIVATE
# Static plugins
KWinQpaPlugin
KF6WindowSystemKWinPlugin
KF6IdleTimeKWinPlugin
${kwin_XWAYLAND_SRCS}
)
if(KWIN_BUILD_X11)
target_link_libraries(KWinIntegrationTestFramework PRIVATE KWinXwaylandServerModule)
endif()
if(TARGET KF6GlobalAccelKWinPlugin)
target_link_libraries(KWinIntegrationTestFramework PUBLIC KF6GlobalAccelKWinPlugin)
endif()
if(TARGET PW::KScreenLocker)
target_link_libraries(KWinIntegrationTestFramework PUBLIC PW::KScreenLocker)
endif()
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework_SOURCES
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml
BASENAME input-method-unstable-v1
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework_SOURCES
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml
BASENAME text-input-unstable-v3
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework_SOURCES
PROTOCOL protocols/wlr-layer-shell-unstable-v1.xml
BASENAME wlr-layer-shell-unstable-v1
)
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework_SOURCES
PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
BASENAME xdg-shell
)
add_library(KWinIntegrationTestFramework STATIC ${KWinIntegrationTestFramework_SOURCES})
target_link_libraries(KWinIntegrationTestFramework kwin Qt5::Test Wayland::Client)
function(integrationTest)
set(optionArgs BUILTIN_EFFECTS)
set(optionArgs WAYLAND_ONLY)
set(oneValueArgs NAME)
set(multiValueArgs SRCS LIBS)
cmake_parse_arguments(ARGS "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT KWIN_BUILD_X11 AND ARGS_LIBS MATCHES XCB::)
return()
endif()
add_executable(${ARGS_NAME} ${ARGS_SRCS})
target_link_libraries(${ARGS_NAME} KWinIntegrationTestFramework Qt::Test ${ARGS_LIBS})
if(${ARGS_BUILTIN_EFFECTS})
kcoreaddons_target_static_plugins(${ARGS_NAME} NAMESPACE "kwin/effects/plugins")
endif()
target_link_libraries(${ARGS_NAME} KWinIntegrationTestFramework kwin Qt5::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 kwin Qt5::Test ${ARGS_LIBS})
add_test(NAME kwin-${ARGS_NAME}-waylandonly COMMAND dbus-run-session ${CMAKE_BINARY_DIR}/bin/${ARGS_NAME}_waylandonly)
endif()
endfunction()
if(KWIN_BUILD_X11)
integrationTest(NAME testDontCrashGlxgears SRCS dont_crash_glxgears.cpp LIBS KF6::I18n KDecoration2::KDecoration)
endif()
if (KWIN_BUILD_SCREENLOCKER)
integrationTest(NAME testLockScreen SRCS lockscreen.cpp LIBS KF6::GlobalAccel)
endif()
integrationTest(NAME testBounceKeys SRCS bounce_keys_test.cpp)
integrationTest(NAME testButtonRebind SRCS buttonrebind_test.cpp)
integrationTest(NAME testDecorationInput SRCS decoration_input_test.cpp LIBS KDecoration2::KDecoration KDecoration2::KDecoration2Private)
integrationTest(NAME testInternalWindow SRCS internal_window.cpp)
integrationTest(NAME testTouchInput SRCS touch_input_test.cpp)
integrationTest(NAME testInputStackingOrder SRCS input_stacking_order.cpp)
integrationTest(NAME testPointerInput SRCS pointer_input.cpp LIBS Libdrm::Libdrm XCB::ICCCM)
integrationTest(NAME testDontCrashGlxgears SRCS dont_crash_glxgears.cpp)
integrationTest(NAME testLockScreen SRCS lockscreen.cpp)
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(NAME testDontCrashCancelAnimation SRCS dont_crash_cancel_animation.cpp LIBS KDecoration2::KDecoration)
integrationTest(NAME testTransientPlacement SRCS transient_placement.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 testPlasmaSurface SRCS plasma_surface_test.cpp)
integrationTest(NAME testMaximized SRCS maximize_test.cpp LIBS KDecoration2::KDecoration KF6::Package)
integrationTest(NAME testXdgShellWindow SRCS xdgshellwindow_test.cpp LIBS KDecoration2::KDecoration)
integrationTest(NAME testSceneOpenGL SRCS scene_opengl_test.cpp )
integrationTest(NAME testSceneOpenGLES SRCS scene_opengl_es_test.cpp )
integrationTest(NAME testScreenChanges SRCS screen_changes_test.cpp)
if (KWIN_BUILD_TABBOX)
integrationTest(NAME testTabBox SRCS tabbox_test.cpp)
endif()
integrationTest(NAME testWindowSelection SRCS window_selection_test.cpp)
integrationTest(NAME testPointerConstraints SRCS pointer_constraints_test.cpp)
integrationTest(NAME testKeyboardLayout SRCS keyboard_layout_test.cpp LIBS KF6::GlobalAccel XKB::XKB)
integrationTest(NAME testKeymapCreationFailure SRCS keymap_creation_failure_test.cpp LIBS KF6::GlobalAccel)
integrationTest(NAME testShowingDesktop SRCS showing_desktop_test.cpp)
integrationTest(NAME testDontCrashUseractionsMenu SRCS dont_crash_useractions_menu.cpp LIBS KF6::I18n)
integrationTest(NAME testLayerShellV1Window SRCS layershellv1window_test.cpp)
integrationTest(NAME testVirtualDesktop SRCS virtual_desktop_test.cpp)
integrationTest(NAME testXdgShellWindowRules SRCS xdgshellwindow_rules_test.cpp)
integrationTest(NAME testIdleInhibition SRCS idle_inhibition_test.cpp)
integrationTest(NAME testDontCrashReinitializeCompositor SRCS dont_crash_reinitialize_compositor.cpp BUILTIN_EFFECTS)
integrationTest(NAME testNoGlobalShortcuts SRCS no_global_shortcuts_test.cpp LIBS KF6::GlobalAccel)
integrationTest(NAME testPlacement SRCS placement_test.cpp)
integrationTest(NAME testActivation SRCS activation_test.cpp)
integrationTest(NAME testInputMethod SRCS inputmethod_test.cpp LIBS XKB::XKB)
integrationTest(NAME testScreens SRCS screens_test.cpp)
integrationTest(NAME testScreenEdges SRCS screenedges_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testOutputChanges SRCS outputchanges_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testTiles SRCS tiles_test.cpp)
integrationTest(NAME testFractionalScaling SRCS fractional_scaling_test.cpp)
integrationTest(NAME testMoveResize SRCS move_resize_window_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testStruts SRCS struts_test.cpp LIBS XCB::ICCCM KDecoration2::KDecoration)
integrationTest(NAME testShade SRCS shade_test.cpp LIBS XCB::ICCCM KDecoration2::KDecoration)
integrationTest(NAME testDontCrashAuroraeDestroyDeco SRCS dont_crash_aurorae_destroy_deco.cpp LIBS XCB::ICCCM KDecoration2::KDecoration)
integrationTest(NAME testPlasmaWindow SRCS plasmawindow_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 KDecoration2::KDecoration)
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)
integrationTest(NAME testFakeInput SRCS fakeinput_test.cpp)
integrationTest(NAME testSecurityContext SRCS security_context_test.cpp)
integrationTest(NAME testStickyKeys SRCS sticky_keys_test.cpp)
if(KWIN_BUILD_X11)
integrationTest(NAME testDontCrashEmptyDeco SRCS dont_crash_empty_deco.cpp LIBS KDecoration2::KDecoration)
integrationTest(NAME testXwaylandSelections SRCS xwayland_selections_test.cpp)
integrationTest(NAME testXinerama SRCS xinerama_test.cpp)
integrationTest(NAME testX11KeyRead SRCS x11keyread.cpp LIBS XCB::XINPUT)
endif()
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 testXdgShellClient SRCS xdgshellclient_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 testSceneOpenGLShadow SRCS scene_opengl_shadow_test.cpp)
integrationTest(WAYLAND_ONLY NAME testSceneOpenGLES SRCS scene_opengl_es_test.cpp )
integrationTest(WAYLAND_ONLY NAME testNoXdgRuntimeDir SRCS no_xdg_runtime_dir_test.cpp)
integrationTest(WAYLAND_ONLY NAME testScreenChanges SRCS screen_changes_test.cpp)
integrationTest(NAME testModiferOnlyShortcut SRCS modifier_only_shortcut_test.cpp)
integrationTest(WAYLAND_ONLY NAME testTabBox SRCS tabbox_test.cpp)
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 testLayerShellV1Client SRCS layershellv1client_test.cpp)
integrationTest(WAYLAND_ONLY NAME testVirtualDesktop SRCS virtual_desktop_test.cpp)
integrationTest(WAYLAND_ONLY NAME testXdgShellClientRules SRCS xdgshellclient_rules_test.cpp)
integrationTest(WAYLAND_ONLY NAME testIdleInhibition SRCS idle_inhibition_test.cpp)
integrationTest(WAYLAND_ONLY NAME testColorCorrectNightColor SRCS colorcorrect_nightcolor_test.cpp)
integrationTest(WAYLAND_ONLY NAME testDontCrashCursorPhysicalSizeEmpty SRCS dont_crash_cursor_physical_size_empty.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)
qt_add_dbus_interfaces(DBUS_SRCS ${CMAKE_BINARY_DIR}/src/org.kde.kwin.VirtualKeyboard.xml)
integrationTest(NAME testVirtualKeyboardDBus SRCS test_virtualkeyboard_dbus.cpp ${DBUS_SRCS})
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 testX11Client SRCS x11_client_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 testSceneQPainter SRCS scene_qpainter_test.cpp LIBS XCB::ICCCM)
integrationTest(NAME testSceneQPainterShadow SRCS scene_qpainter_shadow_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_GLOBALSHORTCUTS)
integrationTest(NAME testGlobalShortcuts SRCS globalshortcuts_test.cpp LIBS XCB::ICCCM KF6::GlobalAccel KF6::I18n XKB::XKB)
integrationTest(NAME testKWinBindings SRCS kwinbindings_test.cpp LIBS KF6::I18n)
endif()
if (TARGET K::KPipeWire)
integrationTest(NAME testScreencasting SRCS screencasting_test.cpp LIBS K::KPipeWire)
endif()
if (KWIN_BUILD_ACTIVITIES)
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM Plasma::Activities)
if (KWIN_BUILD_ACTIVITIES)
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM)
endif()
endif()
add_subdirectory(scripting)

View File

@ -6,12 +6,14 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "pointer_input.h"
#include "abstract_client.h"
#include "cursor.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/surface.h>
@ -44,29 +46,28 @@ private:
void ActivationTest::initTestCase()
{
qRegisterMetaType<Window *>();
qRegisterMetaType<AbstractClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
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(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
waylandServer()->initWorkspace();
}
void ActivationTest::init()
{
QVERIFY(Test::setupWaylandConnection());
workspace()->setActiveOutput(QPoint(640, 512));
input()->pointer()->warp(QPoint(640, 512));
screens()->setCurrent(0);
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ActivationTest::cleanup()
@ -80,430 +81,442 @@ void ActivationTest::testSwitchToWindowToLeft()
{
// This test verifies that "Switch to Window to the Left" shortcut works.
using namespace KWayland::Client;
// 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());
// Create several clients on the left screen.
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(client1);
QVERIFY(client1->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());
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data()));
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(client2);
QVERIFY(client2->isActive());
window1->move(QPoint(300, 200));
window2->move(QPoint(500, 200));
client1->move(QPoint(300, 200));
client2->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());
// Create several clients on the right screen.
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data()));
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
QVERIFY(client3);
QVERIFY(client3->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());
QScopedPointer<Surface> surface4(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data()));
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
QVERIFY(client4);
QVERIFY(client4->isActive());
window3->move(QPoint(1380, 200));
window4->move(QPoint(1580, 200));
client3->move(QPoint(1380, 200));
client4->move(QPoint(1580, 200));
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window3->isActive());
QVERIFY(client3->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window2->isActive());
QVERIFY(client2->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window1->isActive());
QVERIFY(client1->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window4->isActive());
QVERIFY(client4->isActive());
// Destroy all windows.
// Destroy all clients.
shellSurface1.reset();
QVERIFY(Test::waitForWindowClosed(window1));
QVERIFY(Test::waitForWindowDestroyed(client1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowClosed(window2));
QVERIFY(Test::waitForWindowDestroyed(client2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowClosed(window3));
QVERIFY(Test::waitForWindowDestroyed(client3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowClosed(window4));
QVERIFY(Test::waitForWindowDestroyed(client4));
}
void ActivationTest::testSwitchToWindowToRight()
{
// This test verifies that "Switch to Window to the Right" shortcut works.
using namespace KWayland::Client;
// 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());
// Create several clients on the left screen.
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(client1);
QVERIFY(client1->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());
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data()));
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(client2);
QVERIFY(client2->isActive());
window1->move(QPoint(300, 200));
window2->move(QPoint(500, 200));
client1->move(QPoint(300, 200));
client2->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());
// Create several clients on the right screen.
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data()));
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
QVERIFY(client3);
QVERIFY(client3->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());
QScopedPointer<Surface> surface4(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data()));
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
QVERIFY(client4);
QVERIFY(client4->isActive());
window3->move(QPoint(1380, 200));
window4->move(QPoint(1580, 200));
client3->move(QPoint(1380, 200));
client4->move(QPoint(1580, 200));
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window1->isActive());
QVERIFY(client1->isActive());
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window2->isActive());
QVERIFY(client2->isActive());
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window3->isActive());
QVERIFY(client3->isActive());
// Switch to window to the right.
workspace()->switchWindow(Workspace::DirectionEast);
QVERIFY(window4->isActive());
QVERIFY(client4->isActive());
// Destroy all windows.
// Destroy all clients.
shellSurface1.reset();
QVERIFY(Test::waitForWindowClosed(window1));
QVERIFY(Test::waitForWindowDestroyed(client1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowClosed(window2));
QVERIFY(Test::waitForWindowDestroyed(client2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowClosed(window3));
QVERIFY(Test::waitForWindowDestroyed(client3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowClosed(window4));
QVERIFY(Test::waitForWindowDestroyed(client4));
}
void ActivationTest::testSwitchToWindowAbove()
{
// This test verifies that "Switch to Window Above" shortcut works.
using namespace KWayland::Client;
// 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());
// Create several clients on the top screen.
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(client1);
QVERIFY(client1->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());
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data()));
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(client2);
QVERIFY(client2->isActive());
window1->move(QPoint(200, 300));
window2->move(QPoint(200, 500));
client1->move(QPoint(200, 300));
client2->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());
// Create several clients on the bottom screen.
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data()));
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
QVERIFY(client3);
QVERIFY(client3->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());
QScopedPointer<Surface> surface4(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data()));
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
QVERIFY(client4);
QVERIFY(client4->isActive());
window3->move(QPoint(200, 1224));
window4->move(QPoint(200, 1424));
client3->move(QPoint(200, 1224));
client4->move(QPoint(200, 1424));
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window3->isActive());
QVERIFY(client3->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window2->isActive());
QVERIFY(client2->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window1->isActive());
QVERIFY(client1->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window4->isActive());
QVERIFY(client4->isActive());
// Destroy all windows.
// Destroy all clients.
shellSurface1.reset();
QVERIFY(Test::waitForWindowClosed(window1));
QVERIFY(Test::waitForWindowDestroyed(client1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowClosed(window2));
QVERIFY(Test::waitForWindowDestroyed(client2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowClosed(window3));
QVERIFY(Test::waitForWindowDestroyed(client3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowClosed(window4));
QVERIFY(Test::waitForWindowDestroyed(client4));
}
void ActivationTest::testSwitchToWindowBelow()
{
// This test verifies that "Switch to Window Bottom" shortcut works.
using namespace KWayland::Client;
// 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());
// Create several clients on the top screen.
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(client1);
QVERIFY(client1->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());
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data()));
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(client2);
QVERIFY(client2->isActive());
window1->move(QPoint(200, 300));
window2->move(QPoint(200, 500));
client1->move(QPoint(200, 300));
client2->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());
// Create several clients on the bottom screen.
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data()));
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
QVERIFY(client3);
QVERIFY(client3->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());
QScopedPointer<Surface> surface4(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data()));
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
QVERIFY(client4);
QVERIFY(client4->isActive());
window3->move(QPoint(200, 1224));
window4->move(QPoint(200, 1424));
client3->move(QPoint(200, 1224));
client4->move(QPoint(200, 1424));
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window1->isActive());
QVERIFY(client1->isActive());
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window2->isActive());
QVERIFY(client2->isActive());
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window3->isActive());
QVERIFY(client3->isActive());
// Switch to window below.
workspace()->switchWindow(Workspace::DirectionSouth);
QVERIFY(window4->isActive());
QVERIFY(client4->isActive());
// Destroy all windows.
// Destroy all clients.
shellSurface1.reset();
QVERIFY(Test::waitForWindowClosed(window1));
QVERIFY(Test::waitForWindowDestroyed(client1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowClosed(window2));
QVERIFY(Test::waitForWindowDestroyed(client2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowClosed(window3));
QVERIFY(Test::waitForWindowDestroyed(client3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowClosed(window4));
QVERIFY(Test::waitForWindowDestroyed(client4));
}
void ActivationTest::testSwitchToWindowMaximized()
{
// This test verifies that we switch to the top-most maximized window, i.e.
// This test verifies that we switch to the top-most maximized client, i.e.
// the one that user sees at the moment. See bug 411356.
using namespace KWayland::Client;
// 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.
// Create several maximized clients on the left screen.
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(client1);
QVERIFY(client1->isActive());
QSignalSpy configureRequestedSpy1(shellSurface1.data(), &XdgShellSurface::configureRequested);
QVERIFY(configureRequestedSpy1.wait());
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(configureRequestedSpy1.wait());
QSignalSpy frameGeometryChangedSpy1(client1, &AbstractClient::frameGeometryChanged);
QVERIFY(frameGeometryChangedSpy1.isValid());
shellSurface1->ackConfigure(configureRequestedSpy1.last().at(2).value<quint32>());
Test::render(surface1.data(), configureRequestedSpy1.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.
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data()));
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(client2);
QVERIFY(client2->isActive());
QSignalSpy configureRequestedSpy2(shellSurface2.data(), &XdgShellSurface::configureRequested);
QVERIFY(configureRequestedSpy2.wait());
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(configureRequestedSpy2.wait());
QSignalSpy frameGeometryChangedSpy2(client2, &AbstractClient::frameGeometryChanged);
QVERIFY(frameGeometryChangedSpy2.isValid());
shellSurface2->ackConfigure(configureRequestedSpy2.last().at(2).value<quint32>());
Test::render(surface2.data(), configureRequestedSpy2.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);
const QList<Toplevel *> stackingOrder = workspace()->stackingOrder();
QVERIFY(stackingOrder.indexOf(client1) < stackingOrder.indexOf(client2));
QCOMPARE(client1->maximizeMode(), MaximizeFull);
QCOMPARE(client2->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());
// Create several clients on the right screen.
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data()));
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
QVERIFY(client3);
QVERIFY(client3->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());
QScopedPointer<Surface> surface4(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data()));
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
QVERIFY(client4);
QVERIFY(client4->isActive());
window3->move(QPoint(1380, 200));
window4->move(QPoint(1580, 200));
client3->move(QPoint(1380, 200));
client4->move(QPoint(1580, 200));
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window3->isActive());
QVERIFY(client3->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window2->isActive());
QVERIFY(client2->isActive());
// Switch to window to the left.
workspace()->switchWindow(Workspace::DirectionWest);
QVERIFY(window4->isActive());
QVERIFY(client4->isActive());
// Destroy all windows.
// Destroy all clients.
shellSurface1.reset();
QVERIFY(Test::waitForWindowClosed(window1));
QVERIFY(Test::waitForWindowDestroyed(client1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowClosed(window2));
QVERIFY(Test::waitForWindowDestroyed(client2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowClosed(window3));
QVERIFY(Test::waitForWindowDestroyed(client3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowClosed(window4));
QVERIFY(Test::waitForWindowDestroyed(client4));
}
void ActivationTest::testSwitchToWindowFullScreen()
{
// This test verifies that we switch to the top-most fullscreen window, i.e.
// This test verifies that we switch to the top-most fullscreen client, i.e.
// the one that user sees at the moment. See bug 411356.
using namespace KWayland::Client;
// 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.
// Create several maximized clients on the top screen.
QScopedPointer<Surface> surface1(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data()));
AbstractClient *client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue);
QVERIFY(client1);
QVERIFY(client1->isActive());
QSignalSpy configureRequestedSpy1(shellSurface1.data(), &XdgShellSurface::configureRequested);
QVERIFY(configureRequestedSpy1.wait());
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(configureRequestedSpy1.wait());
QSignalSpy frameGeometryChangedSpy1(client1, &AbstractClient::frameGeometryChanged);
QVERIFY(frameGeometryChangedSpy1.isValid());
shellSurface1->ackConfigure(configureRequestedSpy1.last().at(2).value<quint32>());
Test::render(surface1.data(), configureRequestedSpy1.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.
QScopedPointer<Surface> surface2(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data()));
AbstractClient *client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
QVERIFY(client2);
QVERIFY(client2->isActive());
QSignalSpy configureRequestedSpy2(shellSurface2.data(), &XdgShellSurface::configureRequested);
QVERIFY(configureRequestedSpy2.wait());
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(configureRequestedSpy2.wait());
QSignalSpy frameGeometryChangedSpy2(client2, &AbstractClient::frameGeometryChanged);
QVERIFY(frameGeometryChangedSpy2.isValid());
shellSurface2->ackConfigure(configureRequestedSpy2.last().at(2).value<quint32>());
Test::render(surface2.data(), configureRequestedSpy2.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());
const QList<Toplevel *> stackingOrder = workspace()->stackingOrder();
QVERIFY(stackingOrder.indexOf(client1) < stackingOrder.indexOf(client2));
QVERIFY(client1->isFullScreen());
QVERIFY(client2->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());
// Create several clients on the bottom screen.
QScopedPointer<Surface> surface3(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface3(Test::createXdgShellStableSurface(surface3.data()));
AbstractClient *client3 = Test::renderAndWaitForShown(surface3.data(), QSize(100, 50), Qt::blue);
QVERIFY(client3);
QVERIFY(client3->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());
QScopedPointer<Surface> surface4(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface4(Test::createXdgShellStableSurface(surface4.data()));
AbstractClient *client4 = Test::renderAndWaitForShown(surface4.data(), QSize(100, 50), Qt::blue);
QVERIFY(client4);
QVERIFY(client4->isActive());
window3->move(QPoint(200, 1224));
window4->move(QPoint(200, 1424));
client3->move(QPoint(200, 1224));
client4->move(QPoint(200, 1424));
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window3->isActive());
QVERIFY(client3->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window2->isActive());
QVERIFY(client2->isActive());
// Switch to window above.
workspace()->switchWindow(Workspace::DirectionNorth);
QVERIFY(window4->isActive());
QVERIFY(client4->isActive());
// Destroy all windows.
// Destroy all clients.
shellSurface1.reset();
QVERIFY(Test::waitForWindowClosed(window1));
QVERIFY(Test::waitForWindowDestroyed(client1));
shellSurface2.reset();
QVERIFY(Test::waitForWindowClosed(window2));
QVERIFY(Test::waitForWindowDestroyed(client2));
shellSurface3.reset();
QVERIFY(Test::waitForWindowClosed(window3));
QVERIFY(Test::waitForWindowDestroyed(client3));
shellSurface4.reset();
QVERIFY(Test::waitForWindowClosed(window4));
QVERIFY(Test::waitForWindowDestroyed(client4));
}
void ActivationTest::stackScreensHorizontally()
@ -511,11 +524,23 @@ void ActivationTest::stackScreensHorizontally()
// Process pending wl_output bind requests before destroying all outputs.
QTest::qWait(1);
const QList<QRect> screenGeometries{
const QVector<QRect> screenGeometries {
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
};
Test::setOutputConfig(screenGeometries);
const QVector<int> screenScales {
1,
1,
};
QMetaObject::invokeMethod(kwinApp()->platform(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, screenGeometries.count()),
Q_ARG(QVector<QRect>, screenGeometries),
Q_ARG(QVector<int>, screenScales)
);
}
void ActivationTest::stackScreensVertically()
@ -523,11 +548,23 @@ void ActivationTest::stackScreensVertically()
// Process pending wl_output bind requests before destroying all outputs.
QTest::qWait(1);
const QList<QRect> screenGeometries{
const QVector<QRect> screenGeometries {
QRect(0, 0, 1280, 1024),
QRect(0, 1024, 1280, 1024),
};
Test::setOutputConfig(screenGeometries);
const QVector<int> screenScales {
1,
1,
};
QMetaObject::invokeMethod(kwinApp()->platform(),
"setVirtualOutputs",
Qt::DirectConnection,
Q_ARG(int, screenGeometries.count()),
Q_ARG(QVector<QRect>, screenGeometries),
Q_ARG(QVector<int>, screenScales)
);
}
}

View File

@ -7,14 +7,17 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "activities.h"
#include "core/output.h"
#include "pointer_input.h"
#include "utils/xcbutils.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "screenedge.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include "xcbutils.h"
#include <kwineffects.h>
#include <QDBusConnection>
#include <QDBusMessage>
@ -43,22 +46,22 @@ private:
void ActivitiesTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
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));
QCOMPARE(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
waylandServer()->initWorkspace();
}
void ActivitiesTest::cleanupTestCase()
@ -73,62 +76,72 @@ void ActivitiesTest::cleanupTestCase()
void ActivitiesTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
input()->pointer()->warp(QPoint(640, 512));
screens()->setCurrent(0);
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ActivitiesTest::cleanup()
{
}
struct XcbConnectionDeleter
{
static inline void cleanup(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
Test::XcbConnectionPtr c = Test::createX11Connection();
QVERIFY(!xcb_connection_has_error(c.get()));
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_window_t w = xcb_generate_id(c.data());
const QRect windowGeometry(0, 0, 100, 200);
auto cookie = xcb_create_window_checked(c.get(), 0, windowId, rootWindow(),
auto cookie = xcb_create_window_checked(c.data(), 0, w, 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));
QVERIFY(!xcb_request_check(c.data(), 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());
xcb_icccm_set_wm_normal_hints(c.data(), w, &hints);
xcb_map_window(c.data(), w);
xcb_flush(c.data());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
// we should get a client for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(windowCreatedSpy.isValid());
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
X11Client *client = windowCreatedSpy.first().first().value<X11Client *>();
QVERIFY(client);
QCOMPARE(client->window(), w);
QVERIFY(client->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")));
//verify the test machine doesn't have the following activities used
QVERIFY(!Activities::self()->all().contains(QStringLiteral("foo")));
QVERIFY(!Activities::self()->all().contains(QStringLiteral("bar")));
window->setOnActivities(QStringList{QStringLiteral("foo"), QStringLiteral("bar")});
QVERIFY(!window->activities().contains(QLatin1String("foo")));
QVERIFY(!window->activities().contains(QLatin1String("bar")));
client->setOnActivities(QStringList{QStringLiteral("foo"), QStringLiteral("bar")});
QVERIFY(!client->activities().contains(QLatin1String("foo")));
QVERIFY(!client->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());
xcb_unmap_window(c.data(), w);
xcb_destroy_window(c.data(), w);
xcb_flush(c.data());
c.reset();
QSignalSpy windowClosedSpy(window, &X11Window::closed);
QSignalSpy windowClosedSpy(client, &X11Client::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
}

View File

@ -1,127 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2023 Nicolas Fella <nicolas.fella@gmx.de>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "keyboard_input.h"
#include "pluginmanager.h"
#include "pointer_input.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/seat.h>
#include <linux/input.h>
namespace KWin
{
static const QString s_socketName = QStringLiteral("wayland_test_kwin_bounce_keys-0");
class BounceKeysTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testBounce();
};
void BounceKeysTest::initTestCase()
{
KConfig kaccessConfig("kaccessrc");
kaccessConfig.group(QStringLiteral("Keyboard")).writeEntry("BounceKeys", true);
kaccessConfig.group(QStringLiteral("Keyboard")).writeEntry("BounceKeysDelay", 200);
kaccessConfig.sync();
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
qputenv("XKB_DEFAULT_RULES", "evdev");
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void BounceKeysTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
QVERIFY(Test::waitForWaylandKeyboard());
}
void BounceKeysTest::cleanup()
{
Test::destroyWaylandConnection();
}
void BounceKeysTest::testBounce()
{
std::unique_ptr<KWayland::Client::Keyboard> keyboard(Test::waylandSeat()->createKeyboard());
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 *waylandWindow = Test::renderAndWaitForShown(surface.get(), QSize(10, 10), Qt::blue);
QVERIFY(waylandWindow);
QVERIFY(keyboard);
QSignalSpy enteredSpy(keyboard.get(), &KWayland::Client::Keyboard::entered);
QVERIFY(enteredSpy.wait());
QSignalSpy keySpy(keyboard.get(), &KWayland::Client::Keyboard::keyChanged);
QVERIFY(keySpy.isValid());
quint32 timestamp = 0;
// Press a key, verify that it goes through
Test::keyboardKeyPressed(KEY_A, timestamp);
QVERIFY(keySpy.wait());
QCOMPARE(keySpy.first()[0], KEY_A);
QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Pressed);
keySpy.clear();
Test::keyboardKeyReleased(KEY_A, timestamp++);
QVERIFY(keySpy.wait());
QCOMPARE(keySpy.first()[0], KEY_A);
QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Released);
keySpy.clear();
// Press it again within the bounce interval, verify that it does *not* go through
timestamp += 100;
Test::keyboardKeyPressed(KEY_A, timestamp);
QVERIFY(!keySpy.wait(100));
keySpy.clear();
// Press it again after the bouce interval, verify that it does go through
timestamp += 1000;
Test::keyboardKeyPressed(KEY_A, timestamp);
QVERIFY(keySpy.wait());
QCOMPARE(keySpy.first()[0], KEY_A);
QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Pressed);
keySpy.clear();
Test::keyboardKeyReleased(KEY_A, timestamp++);
QVERIFY(keySpy.wait());
QCOMPARE(keySpy.first()[0], KEY_A);
QCOMPARE(keySpy.first()[1].value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Released);
keySpy.clear();
}
}
WAYLANDTEST_MAIN(KWin::BounceKeysTest)
#include "bounce_keys_test.moc"

View File

@ -0,0 +1,115 @@
/*
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 "abstract_client.h"
#include "composite.h"
#include "wayland_server.h"
#include <KWayland/Client/xdgshell.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
using namespace KWayland::Client;
QScopedPointer<Surface> surface(Test::createSurface());
QVERIFY(!surface.isNull());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
// set buffer size
AbstractClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(client);
// add a first repaint
QSignalSpy swapSpy(Compositor::self(), &Compositor::bufferSwapCompleted);
QVERIFY(swapSpy.isValid());
Compositor::self()->addRepaintFull();
QVERIFY(swapSpy.wait());
// now change buffer size
Test::render(surface.data(), QSize(30, 10), Qt::red);
QSignalSpy damagedSpy(client, &AbstractClient::damaged);
QVERIFY(damagedSpy.isValid());
QVERIFY(damagedSpy.wait());
KWin::Compositor::self()->addRepaintFull();
QVERIFY(swapSpy.wait());
}
void BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface()
{
using namespace KWayland::Client;
// setup parent surface
QScopedPointer<Surface> parentSurface(Test::createSurface());
QVERIFY(!parentSurface.isNull());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(parentSurface.data()));
QVERIFY(!shellSurface.isNull());
// setup sub surface
QScopedPointer<Surface> surface(Test::createSurface());
QVERIFY(!surface.isNull());
QScopedPointer<SubSurface> subSurface(Test::createSubSurface(surface.data(), parentSurface.data()));
QVERIFY(!subSurface.isNull());
// set buffer sizes
Test::render(surface.data(), QSize(30, 10), Qt::red);
AbstractClient *parent = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue);
QVERIFY(parent);
// add a first repaint
QSignalSpy swapSpy(Compositor::self(), &Compositor::bufferSwapCompleted);
QVERIFY(swapSpy.isValid());
Compositor::self()->addRepaintFull();
QVERIFY(swapSpy.wait());
// change buffer size of sub surface
QSignalSpy damagedParentSpy(parent, &AbstractClient::damaged);
QVERIFY(damagedParentSpy.isValid());
Test::render(surface.data(), QSize(20, 10), Qt::red);
parentSurface->commit(Surface::CommitFlag::None);
QVERIFY(damagedParentSpy.wait());
// add a second repaint
KWin::Compositor::self()->addRepaintFull();
QVERIFY(swapSpy.wait());
}
}
WAYLANDTEST_MAIN(KWin::BufferSizeChangeTest)
#include "buffer_size_change_test.moc"

View File

@ -1,108 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2024 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "pointer_input.h"
#include "wayland_server.h"
#include "workspace.h"
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/seat.h>
#include <linux/input-event-codes.h>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_buttonrebind-0");
class TestButtonRebind : public QObject
{
Q_OBJECT
private Q_SLOTS:
void init();
void cleanup();
void initTestCase();
void testKey_data();
void testKey();
private:
quint32 timestamp = 1;
};
void TestButtonRebind::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
QVERIFY(Test::waitForWaylandKeyboard());
}
void TestButtonRebind::cleanup()
{
Test::destroyWaylandConnection();
QVERIFY(QFile::remove(QStandardPaths::locate(QStandardPaths::ConfigLocation, QStringLiteral("kcminputrc"))));
}
void TestButtonRebind::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void TestButtonRebind::testKey_data()
{
QTest::addColumn<QKeySequence>("boundKeys");
QTest::addColumn<QList<quint32>>("expectedKeys");
QTest::newRow("single key") << QKeySequence(Qt::Key_A) << QList<quint32>{KEY_A};
QTest::newRow("single modifier") << QKeySequence(Qt::Key_Control) << QList<quint32>{KEY_LEFTCTRL};
QTest::newRow("single modifier plus key") << QKeySequence(Qt::ControlModifier | Qt::Key_N) << QList<quint32>{KEY_LEFTCTRL, KEY_N};
QTest::newRow("multiple modifiers plus key") << QKeySequence(Qt::ControlModifier | Qt::MetaModifier | Qt::Key_Y) << QList<quint32>{KEY_LEFTCTRL, KEY_LEFTMETA, KEY_Y};
QTest::newRow("delete") << QKeySequence(Qt::Key_Delete) << QList<quint32>{KEY_DELETE};
QTest::newRow("keypad delete") << QKeySequence(Qt::KeypadModifier | Qt::Key_Delete) << QList<quint32>{KEY_KPDOT};
QTest::newRow("keypad enter") << QKeySequence(Qt::KeypadModifier | Qt::Key_Enter) << QList<quint32>{KEY_KPENTER};
}
void TestButtonRebind::testKey()
{
KConfigGroup buttonGroup = KSharedConfig::openConfig(QStringLiteral("kcminputrc"))->group(QStringLiteral("ButtonRebinds")).group(QStringLiteral("Mouse"));
QFETCH(QKeySequence, boundKeys);
buttonGroup.writeEntry("ExtraButton7", QStringList{"Key", boundKeys.toString(QKeySequence::PortableText)}, KConfig::Notify);
buttonGroup.sync();
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
std::unique_ptr<Test::XdgToplevel> shellSurface = Test::createXdgToplevelSurface(surface.get());
Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
std::unique_ptr<KWayland::Client::Keyboard> keyboard(Test::waylandSeat()->createKeyboard());
QSignalSpy enteredSpy(keyboard.get(), &KWayland::Client::Keyboard::entered);
QSignalSpy keyChangedSpy(keyboard.get(), &KWayland::Client::Keyboard::keyChanged);
QVERIFY(enteredSpy.wait());
// 0x119 is Qt::ExtraButton7
Test::pointerButtonPressed(0x119, timestamp++);
QVERIFY(keyChangedSpy.wait());
QFETCH(QList<quint32>, expectedKeys);
QCOMPARE(keyChangedSpy.count(), expectedKeys.count());
for (int i = 0; i < keyChangedSpy.count(); i++) {
QCOMPARE(keyChangedSpy.at(i).at(0).value<quint32>(), expectedKeys.at(i));
QCOMPARE(keyChangedSpy.at(i).at(1).value<KWayland::Client::Keyboard::KeyState>(), KWayland::Client::Keyboard::KeyState::Pressed);
}
Test::pointerButtonReleased(0x119, timestamp++);
}
WAYLANDTEST_MAIN(TestButtonRebind)
#include "buttonrebind_test.moc"

View File

@ -0,0 +1,328 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "wayland_server.h"
#include "colorcorrection/manager.h"
#include "colorcorrection/constants.h"
#include <KConfigGroup>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_colorcorrect_nightcolor-0");
class ColorCorrectNightColorTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testConfigRead_data();
void testConfigRead();
void testChangeConfiguration_data();
void testChangeConfiguration();
void testAutoLocationUpdate();
};
void ColorCorrectNightColorTest::initTestCase()
{
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
waylandServer()->initWorkspace();
}
void ColorCorrectNightColorTest::init()
{
QVERIFY(Test::setupWaylandConnection());
}
void ColorCorrectNightColorTest::cleanup()
{
Test::destroyWaylandConnection();
}
void ColorCorrectNightColorTest::testConfigRead_data()
{
QTest::addColumn<QString>("active");
QTest::addColumn<int>("mode");
QTest::addColumn<int>("nightTemperature");
QTest::addColumn<double>("latitudeFixed");
QTest::addColumn<double>("longitudeFixed");
QTest::addColumn<QString>("morningBeginFixed");
QTest::addColumn<QString>("eveningBeginFixed");
QTest::addColumn<int>("transitionTime");
QTest::addColumn<bool>("success");
QTest::newRow("activeMode0") << "true" << 0 << 4500 << 45.5 << 35.1 << "0600" << "1800" << 30 << true;
QTest::newRow("activeMode1") << "true" << 1 << 2500 << -10.5 << -8. << "0020" << "2000" << 60 << true;
QTest::newRow("activeMode2") << "true" << 3 << 3500 << 45.5 << 35.1 << "0600" << "1800" << 60 << true;
QTest::newRow("notActiveMode2") << "false" << 2 << 5000 << 90. << -180. << "0600" << "1800" << 1 << true;
QTest::newRow("wrongData1") << "fa" << 4 << 7000 << 91. << -181. << "060" << "800" << 999999 << false;
QTest::newRow("wrongData2") << "fa" << 4 << 7000 << 91. << -181. << "060" << "800" << -2 << false;
}
void ColorCorrectNightColorTest::testConfigRead()
{
QFETCH(QString, active);
QFETCH(int, mode);
QFETCH(int, nightTemperature);
QFETCH(double, latitudeFixed);
QFETCH(double, longitudeFixed);
QFETCH(QString, morningBeginFixed);
QFETCH(QString, eveningBeginFixed);
QFETCH(int, transitionTime);
QFETCH(bool, success);
const bool activeDefault = true;
const int modeDefault = 0;
const int nightTemperatureUpperEnd = ColorCorrect::NEUTRAL_TEMPERATURE;
const double latitudeFixedDefault = 0;
const double longitudeFixedDefault = 0;
const QTime morningBeginFixedDefault = QTime(6,0,0);
const QTime eveningBeginFixedDefault = QTime(18,0,0);
const int transitionTimeDefault = 30;
KConfigGroup cfgGroup = kwinApp()->config()->group("NightColor");
cfgGroup.writeEntry("Active", activeDefault);
cfgGroup.writeEntry("Mode", modeDefault);
cfgGroup.writeEntry("NightTemperature", nightTemperatureUpperEnd);
cfgGroup.writeEntry("LatitudeFixed", latitudeFixedDefault);
cfgGroup.writeEntry("LongitudeFixed", longitudeFixedDefault);
cfgGroup.writeEntry("MorningBeginFixed", morningBeginFixedDefault.toString("hhmm"));
cfgGroup.writeEntry("EveningBeginFixed", eveningBeginFixedDefault.toString("hhmm"));
cfgGroup.writeEntry("TransitionTime", transitionTimeDefault);
ColorCorrect::Manager *manager = kwinApp()->platform()->colorCorrectManager();
manager->reparseConfigAndReset();
auto info = manager->info();
QVERIFY(!info.isEmpty());
QCOMPARE(info.value("Active").toBool(), activeDefault);
QCOMPARE(info.value("Mode").toInt(), modeDefault);
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperatureUpperEnd);
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixedDefault);
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixedDefault);
QCOMPARE(QTime::fromString(info.value("MorningBeginFixed").toString(), Qt::ISODate), morningBeginFixedDefault);
QCOMPARE(QTime::fromString(info.value("EveningBeginFixed").toString(), Qt::ISODate), eveningBeginFixedDefault);
QCOMPARE(info.value("TransitionTime").toInt(), transitionTimeDefault);
cfgGroup.writeEntry("Active", active);
cfgGroup.writeEntry("Mode", mode);
cfgGroup.writeEntry("NightTemperature", nightTemperature);
cfgGroup.writeEntry("LatitudeFixed", latitudeFixed);
cfgGroup.writeEntry("LongitudeFixed", longitudeFixed);
cfgGroup.writeEntry("MorningBeginFixed", morningBeginFixed);
cfgGroup.writeEntry("EveningBeginFixed", eveningBeginFixed);
cfgGroup.writeEntry("TransitionTime", transitionTime);
manager->reparseConfigAndReset();
info = manager->info();
QVERIFY(!info.isEmpty());
if (success) {
QCOMPARE(info.value("Active").toBool() ? QString("true") : QString("false"), active);
QCOMPARE(info.value("Mode").toInt(), mode);
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperature);
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixed);
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixed);
QCOMPARE(QTime::fromString(info.value("MorningBeginFixed").toString(), Qt::ISODate), QTime::fromString(morningBeginFixed, "hhmm"));
QCOMPARE(QTime::fromString(info.value("EveningBeginFixed").toString(), Qt::ISODate), QTime::fromString(eveningBeginFixed, "hhmm"));
QCOMPARE(info.value("TransitionTime").toInt(), transitionTime);
} else {
QCOMPARE(info.value("Active").toBool(), activeDefault);
QCOMPARE(info.value("Mode").toInt(), modeDefault);
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperatureUpperEnd);
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixedDefault);
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixedDefault);
QCOMPARE(QTime::fromString(info.value("MorningBeginFixed").toString(), Qt::ISODate), morningBeginFixedDefault);
QCOMPARE(QTime::fromString(info.value("EveningBeginFixed").toString(), Qt::ISODate), eveningBeginFixedDefault);
QCOMPARE(info.value("TransitionTime").toInt(), transitionTimeDefault);
}
}
void ColorCorrectNightColorTest::testChangeConfiguration_data()
{
QTest::addColumn<bool>("activeReadIn");
QTest::addColumn<int>("modeReadIn");
QTest::addColumn<int>("nightTemperatureReadIn");
QTest::addColumn<double>("latitudeFixedReadIn");
QTest::addColumn<double>("longitudeFixedReadIn");
QTest::addColumn<QTime>("morBeginFixedReadIn");
QTest::addColumn<QTime>("eveBeginFixedReadIn");
QTest::addColumn<int>("transitionTimeReadIn");
QTest::addColumn<bool>("successReadIn");
QTest::newRow("data0") << true << 0 << 4500 << 45.5 << 35.1 << QTime(6,0,0) << QTime(18,0,0) << 30 << true;
QTest::newRow("data1") << true << 1 << 2500 << -10.5 << -8. << QTime(0,2,0) << QTime(20,0,0) << 60 << true;
QTest::newRow("data2") << false << 2 << 5000 << 90. << -180. << QTime(6,0,0) << QTime(19,1,1) << 1 << true;
QTest::newRow("data3") << false << 3 << 2000 << 90. << -180. << QTime(6,0,0) << QTime(18,0,0) << 1 << true;
QTest::newRow("wrongData0") << true << 4 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
QTest::newRow("wrongData1") << true << 0 << 500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
QTest::newRow("wrongData2") << true << 0 << 7000 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
QTest::newRow("wrongData3") << true << 0 << 4500 << 91. << -181. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
QTest::newRow("wrongData4") << true << 0 << 4500 << 0. << 0. << QTime(18,0,0) << QTime(6,0,0) << 30 << false;
QTest::newRow("wrongData5") << true << 0 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 0 << false;
QTest::newRow("wrongData6") << true << 0 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << -1 << false;
QTest::newRow("wrongData7") << true << 0 << 4500 << 0. << 0. << QTime(12,0,0) << QTime(12,30,0) << 30 << false;
QTest::newRow("wrongData8") << true << 0 << 4500 << 0. << 0. << QTime(1,0,0) << QTime(23,30,0) << 90 << false;
}
void ColorCorrectNightColorTest::testChangeConfiguration()
{
QFETCH(bool, activeReadIn);
QFETCH(int, modeReadIn);
QFETCH(int, nightTemperatureReadIn);
QFETCH(double, latitudeFixedReadIn);
QFETCH(double, longitudeFixedReadIn);
QFETCH(QTime, morBeginFixedReadIn);
QFETCH(QTime, eveBeginFixedReadIn);
QFETCH(int, transitionTimeReadIn);
QFETCH(bool, successReadIn);
const bool activeDefault = true;
const int modeDefault = 0;
const int nightTemperatureDefault = ColorCorrect::DEFAULT_NIGHT_TEMPERATURE;
const double latitudeFixedDefault = 0;
const double longitudeFixedDefault = 0;
const QTime morningBeginFixedDefault = QTime(6,0,0);
const QTime eveningBeginFixedDefault = QTime(18,0,0);
const int transitionTimeDefault = 30;
// init with default values
bool active = activeDefault;
int mode = modeDefault;
int nightTemperature = nightTemperatureDefault;
double latitudeFixed = latitudeFixedDefault;
double longitudeFixed = longitudeFixedDefault;
QTime morningBeginFixed = morningBeginFixedDefault;
QTime eveningBeginFixed = eveningBeginFixedDefault;
int transitionTime = transitionTimeDefault;
bool activeExpect = activeDefault;
int modeExpect = modeDefault;
int nightTemperatureExpect = nightTemperatureDefault;
double latitudeFixedExpect = latitudeFixedDefault;
double longitudeFixedExpect = longitudeFixedDefault;
QTime morningBeginFixedExpect = morningBeginFixedDefault;
QTime eveningBeginFixedExpect = eveningBeginFixedDefault;
int transitionTimeExpect = transitionTimeDefault;
QHash<QString, QVariant> data;
auto setData = [&active, &mode, &nightTemperature,
&latitudeFixed, &longitudeFixed,
&morningBeginFixed, &eveningBeginFixed, &transitionTime,
&data]() {
data["Active"] = active;
data["Mode"] = mode;
data["NightTemperature"] = nightTemperature;
data["LatitudeFixed"] = latitudeFixed;
data["LongitudeFixed"] = longitudeFixed;
data["MorningBeginFixed"] = morningBeginFixed.toString(Qt::ISODate);
data["EveningBeginFixed"] = eveningBeginFixed.toString(Qt::ISODate);
data["TransitionTime"] = transitionTime;
};
auto compareValues = [&activeExpect, &modeExpect, &nightTemperatureExpect,
&latitudeFixedExpect, &longitudeFixedExpect,
&morningBeginFixedExpect, &eveningBeginFixedExpect,
&transitionTimeExpect](QHash<QString, QVariant> info) {
QCOMPARE(info.value("Active").toBool(), activeExpect);
QCOMPARE(info.value("Mode").toInt(), modeExpect);
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperatureExpect);
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixedExpect);
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixedExpect);
QCOMPARE(info.value("MorningBeginFixed").toString(), morningBeginFixedExpect.toString(Qt::ISODate));
QCOMPARE(info.value("EveningBeginFixed").toString(), eveningBeginFixedExpect.toString(Qt::ISODate));
QCOMPARE(info.value("TransitionTime").toInt(), transitionTimeExpect);
};
ColorCorrect::Manager *manager = kwinApp()->platform()->colorCorrectManager();
// test with default values
setData();
manager->changeConfiguration(data);
compareValues(manager->info());
// set to test values
active = activeReadIn;
mode = modeReadIn;
nightTemperature = nightTemperatureReadIn;
latitudeFixed = latitudeFixedReadIn;
longitudeFixed = longitudeFixedReadIn;
morningBeginFixed = morBeginFixedReadIn;
eveningBeginFixed = eveBeginFixedReadIn;
transitionTime = transitionTimeReadIn;
if (successReadIn) {
activeExpect = activeReadIn;
modeExpect = modeReadIn;
nightTemperatureExpect = nightTemperatureReadIn;
latitudeFixedExpect = latitudeFixedReadIn;
longitudeFixedExpect = longitudeFixedReadIn;
morningBeginFixedExpect = morBeginFixedReadIn;
eveningBeginFixedExpect = eveBeginFixedReadIn;
transitionTimeExpect = transitionTimeReadIn;
}
// test with test values
setData();
QCOMPARE(manager->changeConfiguration(data), successReadIn);
compareValues(manager->info());
}
void ColorCorrectNightColorTest::testAutoLocationUpdate()
{
ColorCorrect::Manager *manager = kwinApp()->platform()->colorCorrectManager();
auto info = manager->info();
QCOMPARE(info.value("LatitudeAuto").toDouble(), 0.);
QCOMPARE(info.value("LongitudeAuto").toDouble(), 0.);
// wrong latitude value
manager->autoLocationUpdate(91, 15);
info = manager->info();
QCOMPARE(info.value("LatitudeAuto").toDouble(), 0.);
QCOMPARE(info.value("LongitudeAuto").toDouble(), 0.);
// wrong longitude value
manager->autoLocationUpdate(50, -181);
info = manager->info();
QCOMPARE(info.value("LatitudeAuto").toDouble(), 0.);
QCOMPARE(info.value("LongitudeAuto").toDouble(), 0.);
// change
manager->autoLocationUpdate(50, -180);
info = manager->info();
QCOMPARE(info.value("LatitudeAuto").toDouble(), 50.);
QCOMPARE(info.value("LongitudeAuto").toDouble(), -180.);
// small deviation only
manager->autoLocationUpdate(51.5, -179.5);
info = manager->info();
QCOMPARE(info.value("LongitudeAuto").toDouble(), -180.);
QCOMPARE(info.value("LatitudeAuto").toDouble(), 50.);
}
WAYLANDTEST_MAIN(ColorCorrectNightColorTest)
#include "colorcorrect_nightcolor_test.moc"

View File

@ -1,4 +1,3 @@
[1]
Description=Window settings for kpat
clientmachine=localhost
clientmachinematch=0
@ -12,6 +11,3 @@ windowrolematch=1
wmclass=kpat
wmclasscomplete=false
wmclassmatch=1
[General]
count=1

View File

@ -6,17 +6,17 @@
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 "abstract_client.h"
#include "atoms.h"
#include "x11client.h"
#include "deleted.h"
#include "platform.h"
#include "rules.h"
#include "screens.h"
#include "virtualdesktops.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include <KWayland/Client/surface.h>
@ -30,6 +30,7 @@
#include <xcb/xcb_icccm.h>
using namespace KWin;
using namespace KWayland::Client;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_dbus_interface-0");
@ -52,17 +53,17 @@ private Q_SLOTS:
void TestDbusInterface::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
waylandServer()->initWorkspace();
VirtualDesktopManager::self()->setCount(4);
}
@ -76,8 +77,7 @@ void TestDbusInterface::cleanup()
Test::destroyWaylandConnection();
}
namespace
{
namespace {
QDBusPendingCall getWindowInfo(const QUuid &uuid)
{
auto msg = QDBusMessage::createMethodCall(s_destination, s_path, s_interface, QStringLiteral("getWindowInfo"));
@ -98,117 +98,111 @@ void TestDbusInterface::testGetWindowInfoInvalidUuid()
void TestDbusInterface::testGetWindowInfoXdgShellClient()
{
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid());
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"));
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
shellSurface->setAppId(QByteArrayLiteral("org.kde.foo"));
shellSurface->setTitle(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
{QStringLiteral("layer"), NormalLayer},
};
Test::render(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(clientAddedSpy.isEmpty());
QVERIFY(clientAddedSpy.wait());
auto client = clientAddedSpy.first().first().value<AbstractClient *>();
QVERIFY(client);
// let's get the window info
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())};
reply.waitForFinished();
QVERIFY(reply.isValid());
QVERIFY(!reply.isError());
auto windowData = reply.value();
windowData.remove(QStringLiteral("uuid"));
QCOMPARE(windowData, expectedData);
QVERIFY(!windowData.isEmpty());
QCOMPARE(windowData.size(), 24);
QCOMPARE(windowData.value(QStringLiteral("type")).toInt(), NET::Normal);
QCOMPARE(windowData.value(QStringLiteral("x")).toInt(), client->x());
QCOMPARE(windowData.value(QStringLiteral("y")).toInt(), client->y());
QCOMPARE(windowData.value(QStringLiteral("width")).toInt(), client->width());
QCOMPARE(windowData.value(QStringLiteral("height")).toInt(), client->height());
QCOMPARE(windowData.value(QStringLiteral("x11DesktopNumber")).toInt(), 1);
QCOMPARE(windowData.value(QStringLiteral("minimized")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("shaded")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("fullscreen")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("keepAbove")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("keepBelow")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("skipTaskbar")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("skipPager")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("skipSwitcher")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("maximizeHorizontal")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("maximizeVertical")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("noBorder")).toBool(), true);
QCOMPARE(windowData.value(QStringLiteral("clientMachine")).toString(), QString());
QCOMPARE(windowData.value(QStringLiteral("localhost")).toBool(), true);
QCOMPARE(windowData.value(QStringLiteral("role")).toString(), QString());
QCOMPARE(windowData.value(QStringLiteral("resourceName")).toString(), QStringLiteral("testDbusInterface"));
QCOMPARE(windowData.value(QStringLiteral("resourceClass")).toString(), QStringLiteral("org.kde.foo"));
QCOMPARE(windowData.value(QStringLiteral("desktopFile")).toString(), QStringLiteral("org.kde.foo"));
QCOMPARE(windowData.value(QStringLiteral("caption")).toString(), QStringLiteral("Test window"));
auto verifyProperty = [window](const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
auto verifyProperty = [client] (const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())};
reply.waitForFinished();
return reply.value().value(name).toBool();
};
QVERIFY(!window->isMinimized());
window->setMinimized(true);
QVERIFY(window->isMinimized());
QVERIFY(!client->isMinimized());
client->setMinimized(true);
QVERIFY(client->isMinimized());
QCOMPARE(verifyProperty(QStringLiteral("minimized")), true);
QVERIFY(!window->keepAbove());
window->setKeepAbove(true);
QVERIFY(window->keepAbove());
QVERIFY(!client->keepAbove());
client->setKeepAbove(true);
QVERIFY(client->keepAbove());
QCOMPARE(verifyProperty(QStringLiteral("keepAbove")), true);
QVERIFY(!window->keepBelow());
window->setKeepBelow(true);
QVERIFY(window->keepBelow());
QVERIFY(!client->keepBelow());
client->setKeepBelow(true);
QVERIFY(client->keepBelow());
QCOMPARE(verifyProperty(QStringLiteral("keepBelow")), true);
QVERIFY(!window->skipTaskbar());
window->setSkipTaskbar(true);
QVERIFY(window->skipTaskbar());
QVERIFY(!client->skipTaskbar());
client->setSkipTaskbar(true);
QVERIFY(client->skipTaskbar());
QCOMPARE(verifyProperty(QStringLiteral("skipTaskbar")), true);
QVERIFY(!window->skipPager());
window->setSkipPager(true);
QVERIFY(window->skipPager());
QVERIFY(!client->skipPager());
client->setSkipPager(true);
QVERIFY(client->skipPager());
QCOMPARE(verifyProperty(QStringLiteral("skipPager")), true);
QVERIFY(!window->skipSwitcher());
window->setSkipSwitcher(true);
QVERIFY(window->skipSwitcher());
QVERIFY(!client->skipSwitcher());
client->setSkipSwitcher(true);
QVERIFY(client->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
const QList<VirtualDesktop *> desktops = VirtualDesktopManager::self()->desktops();
QCOMPARE(window->desktops(), QList<VirtualDesktop *>{desktops[0]});
workspace()->sendWindowToDesktops(window, {desktops[1]}, false);
QCOMPARE(window->desktops(), QList<VirtualDesktop *>{desktops[1]});
reply = getWindowInfo(window->internalId());
QCOMPARE(client->desktop(), 1);
workspace()->sendClientToDesktop(client, 2, false);
QCOMPARE(client->desktop(), 2);
reply = getWindowInfo(client->internalId());
reply.waitForFinished();
QCOMPARE(reply.value().value(QStringLiteral("desktops")).toStringList(), window->desktopIds());
QCOMPARE(reply.value().value(QStringLiteral("x11DesktopNumber")).toInt(), 2);
window->move(QPoint(10, 20));
reply = getWindowInfo(window->internalId());
client->move(10, 20);
reply = getWindowInfo(client->internalId());
reply.waitForFinished();
QCOMPARE(reply.value().value(QStringLiteral("x")).toInt(), window->x());
QCOMPARE(reply.value().value(QStringLiteral("y")).toInt(), window->y());
QCOMPARE(reply.value().value(QStringLiteral("x")).toInt(), client->x());
QCOMPARE(reply.value().value(QStringLiteral("y")).toInt(), client->y());
// not testing width, height as that would require window geometry change
// finally close window
const auto id = window->internalId();
QSignalSpy windowClosedSpy(window, &Window::closed);
const auto id = client->internalId();
QSignalSpy windowClosedSpy(client, &AbstractClient::windowClosed);
QVERIFY(windowClosedSpy.isValid());
shellSurface.reset();
surface.reset();
QVERIFY(windowClosedSpy.wait());
@ -219,13 +213,22 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient()
QVERIFY(reply.value().empty());
}
struct XcbConnectionDeleter
{
static inline void cleanup(xcb_connection_t *pointer)
{
xcb_disconnect(pointer);
}
};
void TestDbusInterface::testGetWindowInfoX11Client()
{
Test::XcbConnectionPtr c = Test::createX11Connection();
QVERIFY(!xcb_connection_has_error(c.get()));
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
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(),
xcb_window_t w = xcb_generate_id(c.data());
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
windowGeometry.x(),
windowGeometry.y(),
windowGeometry.width(),
@ -235,141 +238,135 @@ void TestDbusInterface::testGetWindowInfoX11Client()
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());
xcb_icccm_set_wm_normal_hints(c.data(), w, &hints);
xcb_icccm_set_wm_class(c.data(), w, 7, "foo\0bar");
NETWinInfo winInfo(c.data(), w, rootWindow(), NET::Properties(), NET::Properties2());
winInfo.setName("Some caption");
winInfo.setDesktopFileName("org.kde.foo");
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
xcb_map_window(c.data(), w);
xcb_flush(c.data());
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
// we should get a client for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(windowCreatedSpy.isValid());
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
{QStringLiteral("layer"), NormalLayer},
};
X11Client *client = windowCreatedSpy.first().first().value<X11Client *>();
QVERIFY(client);
QCOMPARE(client->window(), w);
QCOMPARE(client->clientSize(), windowGeometry.size());
// let's get the window info
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->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);
QVERIFY(!windowData.isEmpty());
QCOMPARE(windowData.size(), 24);
QCOMPARE(windowData.value(QStringLiteral("type")).toInt(), NET::Normal);
QCOMPARE(windowData.value(QStringLiteral("x")).toInt(), client->x());
QCOMPARE(windowData.value(QStringLiteral("y")).toInt(), client->y());
QCOMPARE(windowData.value(QStringLiteral("width")).toInt(), client->width());
QCOMPARE(windowData.value(QStringLiteral("height")).toInt(), client->height());
QCOMPARE(windowData.value(QStringLiteral("x11DesktopNumber")).toInt(), 1);
QCOMPARE(windowData.value(QStringLiteral("minimized")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("shaded")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("fullscreen")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("keepAbove")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("keepBelow")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("skipTaskbar")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("skipPager")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("skipSwitcher")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("maximizeHorizontal")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("maximizeVertical")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("noBorder")).toBool(), false);
QCOMPARE(windowData.value(QStringLiteral("role")).toString(), QString());
QCOMPARE(windowData.value(QStringLiteral("resourceName")).toString(), QStringLiteral("foo"));
QCOMPARE(windowData.value(QStringLiteral("resourceClass")).toString(), QStringLiteral("bar"));
QCOMPARE(windowData.value(QStringLiteral("desktopFile")).toString(), QStringLiteral("org.kde.foo"));
QCOMPARE(windowData.value(QStringLiteral("caption")).toString(), QStringLiteral("Some caption"));
// not testing clientmachine as that is system dependent
// due to that also not testing localhost
auto verifyProperty = [window](const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(window->internalId())};
auto verifyProperty = [client] (const QString &name) {
QDBusPendingReply<QVariantMap> reply{getWindowInfo(client->internalId())};
reply.waitForFinished();
return reply.value().value(name).toBool();
};
QVERIFY(!window->isMinimized());
window->setMinimized(true);
QVERIFY(window->isMinimized());
QVERIFY(!client->isMinimized());
client->setMinimized(true);
QVERIFY(client->isMinimized());
QCOMPARE(verifyProperty(QStringLiteral("minimized")), true);
QVERIFY(!window->keepAbove());
window->setKeepAbove(true);
QVERIFY(window->keepAbove());
QVERIFY(!client->keepAbove());
client->setKeepAbove(true);
QVERIFY(client->keepAbove());
QCOMPARE(verifyProperty(QStringLiteral("keepAbove")), true);
QVERIFY(!window->keepBelow());
window->setKeepBelow(true);
QVERIFY(window->keepBelow());
QVERIFY(!client->keepBelow());
client->setKeepBelow(true);
QVERIFY(client->keepBelow());
QCOMPARE(verifyProperty(QStringLiteral("keepBelow")), true);
QVERIFY(!window->skipTaskbar());
window->setSkipTaskbar(true);
QVERIFY(window->skipTaskbar());
QVERIFY(!client->skipTaskbar());
client->setSkipTaskbar(true);
QVERIFY(client->skipTaskbar());
QCOMPARE(verifyProperty(QStringLiteral("skipTaskbar")), true);
QVERIFY(!window->skipPager());
window->setSkipPager(true);
QVERIFY(window->skipPager());
QVERIFY(!client->skipPager());
client->setSkipPager(true);
QVERIFY(client->skipPager());
QCOMPARE(verifyProperty(QStringLiteral("skipPager")), true);
QVERIFY(!window->skipSwitcher());
window->setSkipSwitcher(true);
QVERIFY(window->skipSwitcher());
QVERIFY(!client->skipSwitcher());
client->setSkipSwitcher(true);
QVERIFY(client->skipSwitcher());
QCOMPARE(verifyProperty(QStringLiteral("skipSwitcher")), true);
QVERIFY(!window->isShade());
window->setShade(ShadeNormal);
QVERIFY(window->isShade());
QVERIFY(!client->isShade());
client->setShade(ShadeNormal);
QVERIFY(client->isShade());
QCOMPARE(verifyProperty(QStringLiteral("shaded")), true);
window->setShade(ShadeNone);
QVERIFY(!window->isShade());
client->setShade(ShadeNone);
QVERIFY(!client->isShade());
QVERIFY(!window->noBorder());
window->setNoBorder(true);
QVERIFY(window->noBorder());
QVERIFY(!client->noBorder());
client->setNoBorder(true);
QVERIFY(client->noBorder());
QCOMPARE(verifyProperty(QStringLiteral("noBorder")), true);
window->setNoBorder(false);
QVERIFY(!window->noBorder());
client->setNoBorder(false);
QVERIFY(!client->noBorder());
QVERIFY(!window->isFullScreen());
window->setFullScreen(true);
QVERIFY(window->isFullScreen());
QVERIFY(window->clientSize() != windowGeometry.size());
QVERIFY(!client->isFullScreen());
client->setFullScreen(true);
QVERIFY(client->isFullScreen());
QVERIFY(client->clientSize() != windowGeometry.size());
QCOMPARE(verifyProperty(QStringLiteral("fullscreen")), true);
reply = getWindowInfo(window->internalId());
reply = getWindowInfo(client->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());
QCOMPARE(reply.value().value(QStringLiteral("width")).toInt(), client->width());
QCOMPARE(reply.value().value(QStringLiteral("height")).toInt(), client->height());
client->setFullScreen(false);
QVERIFY(!client->isFullScreen());
// maximize
window->setMaximize(true, false);
client->setMaximize(true, false);
QCOMPARE(verifyProperty(QStringLiteral("maximizeVertical")), true);
QCOMPARE(verifyProperty(QStringLiteral("maximizeHorizontal")), false);
window->setMaximize(false, true);
client->setMaximize(false, true);
QCOMPARE(verifyProperty(QStringLiteral("maximizeVertical")), false);
QCOMPARE(verifyProperty(QStringLiteral("maximizeHorizontal")), true);
const auto id = window->internalId();
const auto id = client->internalId();
// destroy the window
xcb_unmap_window(c.get(), windowId);
xcb_flush(c.get());
xcb_unmap_window(c.data(), w);
xcb_flush(c.data());
QSignalSpy windowClosedSpy(window, &X11Window::closed);
QSignalSpy windowClosedSpy(client, &X11Client::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
xcb_destroy_window(c.get(), windowId);
xcb_destroy_window(c.data(), w);
c.reset();
reply = getWindowInfo(id);

View File

@ -7,26 +7,22 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "abstract_client.h"
#include "debug_console.h"
#include "internalwindow.h"
#include "internal_client.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "xcbutils.h"
#if KWIN_BUILD_X11
#include "utils/xcbutils.h"
#endif
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
#include <QPainter>
#include <QRasterWindow>
#include <QSignalSpy>
namespace KWin
{
@ -41,10 +37,8 @@ private Q_SLOTS:
void cleanup();
void topLevelTest_data();
void topLevelTest();
#if KWIN_BUILD_X11
void testX11Window();
void testX11Client();
void testX11Unmanaged();
#endif
void testWaylandClient();
void testInternalWindow();
void testClosingDebugConsole();
@ -52,22 +46,21 @@ private Q_SLOTS:
void DebugConsoleTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::InternalWindow *>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::InternalClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
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(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
waylandServer()->initWorkspace();
}
void DebugConsoleTest::cleanup()
@ -114,8 +107,7 @@ void DebugConsoleTest::topLevelTest()
}
}
#if KWIN_BUILD_X11
void DebugConsoleTest::testX11Window()
void DebugConsoleTest::testX11Client()
{
DebugConsoleModel model;
QModelIndex x11TopLevelIndex = model.index(0, 0, QModelIndex());
@ -131,6 +123,7 @@ void DebugConsoleTest::testX11Window()
// start glxgears, to get a window, which should be added to the model
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
QVERIFY(rowsInsertedSpy.isValid());
QProcess glxgears;
glxgears.setProgram(QStringLiteral("glxgears"));
@ -145,40 +138,40 @@ void DebugConsoleTest::testX11Window()
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);
QModelIndex clientIndex = model.index(0, 0, x11TopLevelIndex);
QVERIFY(clientIndex.isValid());
QCOMPARE(model.parent(clientIndex), x11TopLevelIndex);
QVERIFY(model.hasChildren(clientIndex));
QVERIFY(model.rowCount(clientIndex) != 0);
QCOMPARE(model.columnCount(clientIndex), 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);
// the clientIndex has children and those are properties
for (int i = 0; i < model.rowCount(clientIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, clientIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QCOMPARE(model.parent(propNameIndex), clientIndex);
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);
const QModelIndex propValueIndex = model.index(i, 1, clientIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QCOMPARE(model.parent(propValueIndex), clientIndex);
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());
QVERIFY(!model.index(i, 2, clientIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid());
// creating a second model should be initialized directly with the X11 child
DebugConsoleModel model2;
@ -186,6 +179,7 @@ void DebugConsoleTest::testX11Window()
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
QVERIFY(rowsRemovedSpy.isValid());
glxgears.terminate();
QVERIFY(glxgears.waitForFinished());
@ -217,6 +211,7 @@ void DebugConsoleTest::testX11Unmanaged()
// we need to create an unmanaged window
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
QVERIFY(rowsInsertedSpy.isValid());
// let's create an override redirect window
const uint32_t values[] = {true};
@ -231,42 +226,42 @@ void DebugConsoleTest::testX11Unmanaged()
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);
QModelIndex clientIndex = model.index(0, 0, unmanagedTopLevelIndex);
QVERIFY(clientIndex.isValid());
QCOMPARE(model.parent(clientIndex), unmanagedTopLevelIndex);
QVERIFY(model.hasChildren(clientIndex));
QVERIFY(model.rowCount(clientIndex) != 0);
QCOMPARE(model.columnCount(clientIndex), 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));
QCOMPARE(model.data(clientIndex, Qt::DisplayRole).toString(), QString::number(window));
// 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);
// the clientIndex has children and those are properties
for (int i = 0; i < model.rowCount(clientIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, clientIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QCOMPARE(model.parent(propNameIndex), clientIndex);
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);
const QModelIndex propValueIndex = model.index(i, 1, clientIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QCOMPARE(model.parent(propValueIndex), clientIndex);
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());
QVERIFY(!model.index(i, 2, clientIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid());
// creating a second model should be initialized directly with the X11 child
DebugConsoleModel model2;
@ -274,6 +269,7 @@ void DebugConsoleTest::testX11Unmanaged()
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
QVERIFY(rowsRemovedSpy.isValid());
window.unmap();
@ -287,7 +283,6 @@ void DebugConsoleTest::testX11Unmanaged()
QVERIFY(!model.hasChildren(unmanagedTopLevelIndex));
QVERIFY(!model2.hasChildren(model2.index(1, 0, QModelIndex())));
}
#endif
void DebugConsoleTest::testWaylandClient()
{
@ -306,16 +301,18 @@ void DebugConsoleTest::testWaylandClient()
// we need to create a wayland window
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
QVERIFY(rowsInsertedSpy.isValid());
// create our connection
QVERIFY(Test::setupWaylandConnection());
// create the Surface and ShellSurface
std::unique_ptr<KWayland::Client::Surface> surface(Test::createSurface());
using namespace KWayland::Client;
QScopedPointer<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);
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
QVERIFY(!shellSurface.isNull());
Test::render(surface.data(), QSize(10, 10), Qt::red);
// now we have the window, it should be added to our model
QVERIFY(rowsInsertedSpy.wait());
@ -327,40 +324,40 @@ void DebugConsoleTest::testWaylandClient()
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);
QModelIndex clientIndex = model.index(0, 0, waylandTopLevelIndex);
QVERIFY(clientIndex.isValid());
QCOMPARE(model.parent(clientIndex), waylandTopLevelIndex);
QVERIFY(model.hasChildren(clientIndex));
QVERIFY(model.rowCount(clientIndex) != 0);
QCOMPARE(model.columnCount(clientIndex), 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);
// the clientIndex has children and those are properties
for (int i = 0; i < model.rowCount(clientIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, clientIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QCOMPARE(model.parent(propNameIndex), clientIndex);
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);
const QModelIndex propValueIndex = model.index(i, 1, clientIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QCOMPARE(model.parent(propValueIndex), clientIndex);
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());
QVERIFY(!model.index(i, 2, clientIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid());
// creating a second model should be initialized directly with the X11 child
DebugConsoleModel model2;
@ -368,9 +365,10 @@ void DebugConsoleTest::testWaylandClient()
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
QVERIFY(rowsRemovedSpy.isValid());
surface->attachBuffer(KWayland::Client::Buffer::Ptr());
surface->commit(KWayland::Client::Surface::CommitFlag::None);
surface->attachBuffer(Buffer::Ptr());
surface->commit(Surface::CommitFlag::None);
QVERIFY(rowsRemovedSpy.wait());
QCOMPARE(rowsRemovedSpy.count(), 1);
@ -387,10 +385,7 @@ class HelperWindow : public QRasterWindow
{
Q_OBJECT
public:
HelperWindow()
: QRasterWindow(nullptr)
{
}
HelperWindow() : QRasterWindow(nullptr) {}
~HelperWindow() override = default;
Q_SIGNALS:
@ -404,8 +399,8 @@ Q_SIGNALS:
void keyReleased();
protected:
void paintEvent(QPaintEvent *event) override
{
void paintEvent(QPaintEvent *event) override {
Q_UNUSED(event)
QPainter p(this);
p.fillRect(0, 0, width(), height(), Qt::red);
}
@ -421,20 +416,21 @@ void DebugConsoleTest::testInternalWindow()
// given that we just test whether adding a window works.
QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted);
QVERIFY(rowsInsertedSpy.isValid());
std::unique_ptr<HelperWindow> w(new HelperWindow);
QScopedPointer<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);
QModelIndex clientIndex = model.index(rowsInsertedSpy.first().last().toInt(), 0, internalTopLevelIndex);
QVERIFY(clientIndex.isValid());
QCOMPARE(model.parent(clientIndex), internalTopLevelIndex);
QVERIFY(model.hasChildren(clientIndex));
QVERIFY(model.rowCount(clientIndex) != 0);
QCOMPARE(model.columnCount(clientIndex), 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());
@ -443,32 +439,33 @@ void DebugConsoleTest::testInternalWindow()
// 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);
// the clientIndex has children and those are properties
for (int i = 0; i < model.rowCount(clientIndex); i++) {
const QModelIndex propNameIndex = model.index(i, 0, clientIndex);
QVERIFY(propNameIndex.isValid());
QCOMPARE(model.parent(propNameIndex), windowIndex);
QCOMPARE(model.parent(propNameIndex), clientIndex);
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);
const QModelIndex propValueIndex = model.index(i, 1, clientIndex);
QVERIFY(propValueIndex.isValid());
QCOMPARE(model.parent(propValueIndex), windowIndex);
QCOMPARE(model.parent(propValueIndex), clientIndex);
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());
QVERIFY(!model.index(i, 2, clientIndex).isValid());
}
// row after count should be invalid
QVERIFY(!model.index(model.rowCount(windowIndex), 0, windowIndex).isValid());
QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid());
// now close the window again, it should be removed from the model
QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved);
QVERIFY(rowsRemovedSpy.isValid());
w->hide();
w.reset();
@ -484,17 +481,19 @@ void DebugConsoleTest::testClosingDebugConsole()
DebugConsole *console = new DebugConsole;
QSignalSpy destroyedSpy(console, &QObject::destroyed);
QVERIFY(destroyedSpy.isValid());
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
QSignalSpy clientAddedSpy(workspace(), &Workspace::internalClientAdded);
QVERIFY(clientAddedSpy.isValid());
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();
QTRY_COMPARE(clientAddedSpy.count(), 1);
InternalClient *c = clientAddedSpy.first().first().value<InternalClient *>();
QVERIFY(c->isInternal());
QCOMPARE(c->internalWindow(), console->windowHandle());
QVERIFY(c->isDecorated());
QCOMPARE(c->isMinimizable(), false);
c->closeWindow();
QVERIFY(destroyedSpy.wait());
}

View File

@ -7,24 +7,27 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "abstract_client.h"
#include "cursor.h"
#include "internalwindow.h"
#include "internal_client.h"
#include "platform.h"
#include "pointer_input.h"
#include "touch_input.h"
#include "screenedge.h"
#include "screens.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/compositor.h>
#include <KWayland/Client/keyboard.h>
#include <KWayland/Client/pointer.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
@ -32,8 +35,6 @@
#include <KDecoration2/Decoration>
#include <KDecoration2/DecorationSettings>
#include <QSignalSpy>
#include <linux/input.h>
Q_DECLARE_METATYPE(Qt::WindowFrameSection)
@ -52,8 +53,9 @@ private Q_SLOTS:
void cleanup();
void testAxis_data();
void testAxis();
void testDoubleClickOnAllDesktops();
void testDoubleClickClose();
void testDoubleClick_data();
void testDoubleClick();
void testDoubleTap_data();
void testDoubleTap();
void testHover();
void testPressToMove_data();
@ -70,61 +72,59 @@ private Q_SLOTS:
void testTooltipDoesntEatKeyEvents();
private:
std::tuple<Window *, std::unique_ptr<KWayland::Client::Surface>, std::unique_ptr<Test::XdgToplevel>, std::unique_ptr<Test::XdgToplevelDecorationV1>> showWindow();
AbstractClient *showWindow();
};
#define MOTION(target) Test::pointerMotion(target, timestamp++)
#define MOTION(target) \
kwinApp()->platform()->pointerMotion(target, timestamp++)
#define PRESS Test::pointerButtonPressed(BTN_LEFT, timestamp++)
#define PRESS \
kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++)
#define RELEASE Test::pointerButtonReleased(BTN_LEFT, timestamp++)
#define RELEASE \
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++)
std::tuple<Window *, std::unique_ptr<KWayland::Client::Surface>, std::unique_ptr<Test::XdgToplevel>, std::unique_ptr<Test::XdgToplevelDecorationV1>> DecorationInputTest::showWindow()
AbstractClient *DecorationInputTest::showWindow()
{
using namespace KWayland::Client;
#define VERIFY(statement) \
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) \
return {nullptr, nullptr, nullptr, nullptr};
if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
return nullptr;
#define COMPARE(actual, expected) \
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \
return {nullptr, nullptr, nullptr, nullptr};
std::unique_ptr<KWayland::Client::Surface> surface{Test::createSurface()};
VERIFY(surface.get());
std::unique_ptr<Test::XdgToplevel> shellSurface = Test::createXdgToplevelSurface(surface.get(), Test::CreationSetup::CreateOnly);
VERIFY(shellSurface.get());
std::unique_ptr<Test::XdgToplevelDecorationV1> decoration = Test::createXdgToplevelDecorationV1(shellSurface.get());
VERIFY(decoration.get());
QSignalSpy decorationConfigureRequestedSpy(decoration.get(), &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);
if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
return nullptr;
Surface *surface = Test::createSurface(Test::waylandCompositor());
VERIFY(surface);
XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface);
VERIFY(shellSurface);
auto deco = Test::waylandServerSideDecoration()->create(surface, surface);
QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged);
VERIFY(decoSpy.isValid());
VERIFY(decoSpy.wait());
deco->requestMode(ServerSideDecoration::Mode::Server);
VERIFY(decoSpy.wait());
COMPARE(deco->mode(), ServerSideDecoration::Mode::Server);
// 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);
auto c = Test::renderAndWaitForShown(surface, QSize(500, 50), Qt::blue);
VERIFY(c);
COMPARE(workspace()->activeClient(), c);
#undef VERIFY
#undef COMPARE
return {window, std::move(surface), std::move(shellSurface), std::move(decoration)};
return c;
}
void DecorationInputTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::InternalWindow *>();
qRegisterMetaType<KWin::AbstractClient *>();
qRegisterMetaType<KWin::InternalClient *>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
// change some options
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
@ -137,20 +137,21 @@ void DecorationInputTest::initTestCase()
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(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
waylandServer()->initWorkspace();
}
void DecorationInputTest::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1));
using namespace KWayland::Client;
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration));
QVERIFY(Test::waitForWaylandPointer());
workspace()->setActiveOutput(QPoint(640, 512));
input()->pointer()->warp(QPoint(640, 512));
screens()->setCurrent(0);
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DecorationInputTest::cleanup()
@ -170,149 +171,158 @@ void DecorationInputTest::testAxis_data()
void DecorationInputTest::testAxis()
{
static constexpr double oneTick = 15;
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QCOMPARE(window->titlebarPosition(), Qt::TopEdge);
QVERIFY(!window->keepAbove());
QVERIFY(!window->keepBelow());
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
QCOMPARE(c->titlebarPosition(), AbstractClient::PositionTop);
QVERIFY(!c->keepAbove());
QVERIFY(!c->keepBelow());
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
QVERIFY(input()->pointer()->decoration());
MOTION(QPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2));
QVERIFY(!input()->pointer()->decoration().isNull());
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());
kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++);
QVERIFY(c->keepBelow());
QVERIFY(!c->keepAbove());
kwinApp()->platform()->pointerAxisVertical(-5.0, timestamp++);
QVERIFY(!c->keepBelow());
QVERIFY(!c->keepAbove());
kwinApp()->platform()->pointerAxisVertical(-5.0, timestamp++);
QVERIFY(!c->keepBelow());
QVERIFY(c->keepAbove());
// test top most deco pixel, BUG: 362860
window->move(QPoint(0, 0));
c->move(0, 0);
QFETCH(QPoint, decoPoint);
MOTION(decoPoint);
QVERIFY(input()->pointer()->decoration());
QCOMPARE(input()->pointer()->decoration()->window(), window);
QVERIFY(!input()->pointer()->decoration().isNull());
QCOMPARE(input()->pointer()->decoration()->client(), c);
QTEST(input()->pointer()->decoration()->decoration()->sectionUnderMouse(), "expectedSection");
Test::pointerAxisVertical(oneTick, timestamp++);
QVERIFY(!window->keepBelow());
QVERIFY(!window->keepAbove());
kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++);
QVERIFY(!c->keepBelow());
QVERIFY(!c->keepAbove());
}
void KWin::DecorationInputTest::testDoubleClickOnAllDesktops()
void DecorationInputTest::testDoubleClick_data()
{
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("Windows"));
group.writeEntry("TitlebarDoubleClickCommand", QStringLiteral("OnAllDesktops"));
group.sync();
workspace()->slotReconfigure();
QTest::addColumn<QPoint>("decoPoint");
QTest::addColumn<Qt::WindowFrameSection>("expectedSection");
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QVERIFY(!window->isOnAllDesktops());
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()
{
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
QVERIFY(!c->isOnAllDesktops());
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
MOTION(QPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2));
// double click
PRESS;
RELEASE;
PRESS;
RELEASE;
QVERIFY(window->isOnAllDesktops());
QVERIFY(c->isOnAllDesktops());
// double click again
PRESS;
RELEASE;
QVERIFY(window->isOnAllDesktops());
QVERIFY(c->isOnAllDesktops());
PRESS;
RELEASE;
QVERIFY(!window->isOnAllDesktops());
QVERIFY(!c->isOnAllDesktops());
// test top most deco pixel, BUG: 362860
c->move(0, 0);
QFETCH(QPoint, decoPoint);
MOTION(decoPoint);
QVERIFY(!input()->pointer()->decoration().isNull());
QCOMPARE(input()->pointer()->decoration()->client(), c);
QTEST(input()->pointer()->decoration()->decoration()->sectionUnderMouse(), "expectedSection");
// double click
PRESS;
RELEASE;
QVERIFY(!c->isOnAllDesktops());
PRESS;
RELEASE;
QVERIFY(c->isOnAllDesktops());
}
void DecorationInputTest::testDoubleClickClose()
void DecorationInputTest::testDoubleTap_data()
{
// this test verifies that no crash occurs when double click is configured to close action
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("Windows"));
group.writeEntry("TitlebarDoubleClickCommand", QStringLiteral("Close"));
group.sync();
workspace()->slotReconfigure();
QTest::addColumn<QPoint>("decoPoint");
QTest::addColumn<Qt::WindowFrameSection>("expectedSection");
auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
connect(shellSurface.get(), &Test::XdgToplevel::closeRequested, this, [&surface = surface]() {
surface.reset();
});
// double click
QSignalSpy closedSpy(window, &Window::closed);
window->ref();
PRESS;
RELEASE;
PRESS;
QVERIFY(closedSpy.wait());
RELEASE;
QVERIFY(window->isDeleted());
window->unref();
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()
{
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("Windows"));
group.writeEntry("TitlebarDoubleClickCommand", QStringLiteral("OnAllDesktops"));
group.sync();
workspace()->slotReconfigure();
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QVERIFY(!window->isOnAllDesktops());
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
QVERIFY(!c->isOnAllDesktops());
quint32 timestamp = 1;
const QPoint tapPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0);
const QPoint tapPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2);
// double tap
Test::touchDown(0, tapPoint, timestamp++);
Test::touchUp(0, timestamp++);
Test::touchDown(0, tapPoint, timestamp++);
Test::touchUp(0, timestamp++);
QVERIFY(window->isOnAllDesktops());
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QVERIFY(c->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());
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QVERIFY(c->isOnAllDesktops());
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QVERIFY(!c->isOnAllDesktops());
// test top most deco pixel, BUG: 362860
//
// Not directly at (0, 0), otherwise ScreenEdgeInputFilter catches
// event before DecorationEventFilter.
c->move(10, 10);
QFETCH(QPoint, decoPoint);
// double click
kwinApp()->platform()->touchDown(0, decoPoint, timestamp++);
QVERIFY(!input()->touch()->decoration().isNull());
QCOMPARE(input()->touch()->decoration()->client(), c);
QTEST(input()->touch()->decoration()->decoration()->sectionUnderMouse(), "expectedSection");
kwinApp()->platform()->touchUp(0, timestamp++);
QVERIFY(!c->isOnAllDesktops());
kwinApp()->platform()->touchDown(0, decoPoint, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QVERIFY(c->isOnAllDesktops());
}
void DecorationInputTest::testHover()
{
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
// our left border is moved out of the visible area, so move the window to a better place
window->move(QPoint(20, 0));
c->move(QPoint(20, 0));
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0));
QCOMPARE(window->cursor(), CursorShape(Qt::ArrowCursor));
MOTION(QPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2));
QCOMPARE(c->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
@ -320,31 +330,31 @@ void DecorationInputTest::testHover()
//
// 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;
const bool hasBorders = Decoration::DecorationBridge::self()->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(QPoint(c->frameGeometry().x(), 0));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorthWest));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() / 2, 0));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorth));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() - 1, 0));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeNorthEast));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() + deviation(), c->height() / 2));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeEast));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() + deviation(), c->height() - 1));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouthEast));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() / 2, c->height() + deviation()));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouth));
MOTION(QPoint(c->frameGeometry().x(), c->height() + deviation()));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeSouthWest));
MOTION(QPoint(c->frameGeometry().x() - 1, c->height() / 2));
QCOMPARE(c->cursor(), CursorShape(KWin::ExtendedCursor::SizeWest));
MOTION(window->frameGeometry().center());
MOTION(c->frameGeometry().center());
QEXPECT_FAIL("", "Cursor not set back on leave", Continue);
QCOMPARE(window->cursor(), CursorShape(Qt::ArrowCursor));
QCOMPARE(c->cursor(), CursorShape(Qt::ArrowCursor));
}
void DecorationInputTest::testPressToMove_data()
@ -361,47 +371,49 @@ void DecorationInputTest::testPressToMove_data()
void DecorationInputTest::testPressToMove()
{
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized);
QVERIFY(startMoveResizedSpy.isValid());
QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized);
QVERIFY(clientFinishUserMovedResizedSpy.isValid());
quint32 timestamp = 1;
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0));
QCOMPARE(window->cursor(), CursorShape(Qt::ArrowCursor));
MOTION(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
QCOMPARE(c->cursor(), CursorShape(Qt::ArrowCursor));
PRESS;
QVERIFY(!window->isInteractiveMove());
QVERIFY(!c->isMove());
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(interactiveMoveResizeStartedSpy.count(), 1);
MOTION(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2) + offset);
const QPoint oldPos = c->pos();
QVERIFY(c->isMove());
QCOMPARE(startMoveResizedSpy.count(), 1);
RELEASE;
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
QTRY_VERIFY(!c->isMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1);
QEXPECT_FAIL("", "Just trigger move doesn't move the window", Continue);
QCOMPARE(window->pos(), oldPos + offset);
QCOMPARE(c->pos(), oldPos + offset);
// again
PRESS;
QVERIFY(!window->isInteractiveMove());
QVERIFY(!c->isMove());
QFETCH(QPoint, offset2);
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset2);
QVERIFY(window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 2);
MOTION(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2) + offset2);
QVERIFY(c->isMove());
QCOMPARE(startMoveResizedSpy.count(), 2);
QFETCH(QPoint, offset3);
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset3);
MOTION(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2) + offset3);
RELEASE;
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 2);
QTRY_VERIFY(!c->isMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2);
// TODO: the offset should also be included
QCOMPARE(window->pos(), oldPos + offset2 + offset3);
QCOMPARE(c->pos(), oldPos + offset2 + offset3);
}
void DecorationInputTest::testTapToMove_data()
@ -418,48 +430,50 @@ void DecorationInputTest::testTapToMove_data()
void DecorationInputTest::testTapToMove()
{
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
QSignalSpy interactiveMoveResizeFinishedSpy(window, &Window::interactiveMoveResizeFinished);
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized);
QVERIFY(startMoveResizedSpy.isValid());
QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized);
QVERIFY(clientFinishUserMovedResizedSpy.isValid());
quint32 timestamp = 1;
QPoint p = QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0);
QPoint p = QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2);
Test::touchDown(0, p, timestamp++);
QVERIFY(!window->isInteractiveMove());
kwinApp()->platform()->touchDown(0, p, timestamp++);
QVERIFY(!c->isMove());
QFETCH(QPoint, offset);
QCOMPARE(input()->touch()->decorationPressId(), 0);
Test::touchMotion(0, p + offset, timestamp++);
const QPointF oldPos = window->pos();
QVERIFY(window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 1);
kwinApp()->platform()->touchMotion(0, p + offset, timestamp++);
const QPoint oldPos = c->pos();
QVERIFY(c->isMove());
QCOMPARE(startMoveResizedSpy.count(), 1);
Test::touchUp(0, timestamp++);
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 1);
kwinApp()->platform()->touchUp(0, timestamp++);
QTRY_VERIFY(!c->isMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 1);
QEXPECT_FAIL("", "Just trigger move doesn't move the window", Continue);
QCOMPARE(window->pos(), oldPos + offset);
QCOMPARE(c->pos(), oldPos + offset);
// again
Test::touchDown(1, p + offset, timestamp++);
kwinApp()->platform()->touchDown(1, p + offset, timestamp++);
QCOMPARE(input()->touch()->decorationPressId(), 1);
QVERIFY(!window->isInteractiveMove());
QVERIFY(!c->isMove());
QFETCH(QPoint, offset2);
Test::touchMotion(1, QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset2, timestamp++);
QVERIFY(window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeStartedSpy.count(), 2);
kwinApp()->platform()->touchMotion(1, QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2) + offset2, timestamp++);
QVERIFY(c->isMove());
QCOMPARE(startMoveResizedSpy.count(), 2);
QFETCH(QPoint, offset3);
Test::touchMotion(1, QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0) + offset3, timestamp++);
kwinApp()->platform()->touchMotion(1, QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2) + offset3, timestamp++);
Test::touchUp(1, timestamp++);
QTRY_VERIFY(!window->isInteractiveMove());
QCOMPARE(interactiveMoveResizeFinishedSpy.count(), 2);
kwinApp()->platform()->touchUp(1, timestamp++);
QTRY_VERIFY(!c->isMove());
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 2);
// TODO: the offset should also be included
QCOMPARE(window->pos(), oldPos + offset2 + offset3);
QCOMPARE(c->pos(), oldPos + offset2 + offset3);
}
void DecorationInputTest::testResizeOutsideWindow_data()
@ -477,44 +491,47 @@ void DecorationInputTest::testResizeOutsideWindow()
// this test verifies that one can resize the window outside the decoration with NoSideBorder
// first adjust config
kwinApp()->config()->group(QStringLiteral("org.kde.kdecoration2")).writeEntry("BorderSize", QStringLiteral("None"));
kwinApp()->config()->group("org.kde.kdecoration2").writeEntry("BorderSize", QStringLiteral("None"));
kwinApp()->config()->sync();
workspace()->slotReconfigure();
// now create window
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
QSignalSpy interactiveMoveResizeStartedSpy(window, &Window::interactiveMoveResizeStarted);
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
QVERIFY(c->frameGeometry() != c->inputGeometry());
QVERIFY(c->inputGeometry().contains(c->frameGeometry()));
QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized);
QVERIFY(startMoveResizedSpy.isValid());
// 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()));
MOTION(QPoint(c->frameGeometry().x() -1, c->frameGeometry().center().y()));
break;
case Qt::RightEdge:
MOTION(QPoint(window->frameGeometry().x() + window->frameGeometry().width() + 1, window->frameGeometry().center().y()));
MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() +1, c->frameGeometry().center().y()));
break;
case Qt::BottomEdge:
MOTION(QPoint(window->frameGeometry().center().x(), window->frameGeometry().y() + window->frameGeometry().height() + 1));
MOTION(QPoint(c->frameGeometry().center().x(), c->frameGeometry().y() + c->frameGeometry().height() + 1));
break;
default:
break;
}
QVERIFY(!exclusiveContains(window->frameGeometry(), KWin::Cursors::self()->mouse()->pos()));
QVERIFY(!c->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos()));
// pressing should trigger resize
PRESS;
QVERIFY(!window->isInteractiveResize());
QVERIFY(interactiveMoveResizeStartedSpy.wait());
QVERIFY(window->isInteractiveResize());
QVERIFY(!c->isResize());
QVERIFY(startMoveResizedSpy.wait());
QVERIFY(c->isResize());
RELEASE;
QVERIFY(!window->isInteractiveResize());
QVERIFY(!c->isResize());
}
void DecorationInputTest::testModifierClickUnrestrictedMove_data()
@ -563,7 +580,7 @@ void DecorationInputTest::testModifierClickUnrestrictedMove()
// first modify the config for this run
QFETCH(QString, modKey);
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("MouseBindings"));
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", modKey);
group.writeEntry("CommandAll1", "Move");
group.writeEntry("CommandAll2", "Move");
@ -576,34 +593,34 @@ void DecorationInputTest::testModifierClickUnrestrictedMove()
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
// create a window
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
// move cursor on window
input()->pointer()->warp(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0));
Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
// simulate modifier+click
quint32 timestamp = 1;
QFETCH(bool, capsLock);
if (capsLock) {
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
}
QFETCH(int, modifierKey);
QFETCH(int, mouseButton);
Test::keyboardKeyPressed(modifierKey, timestamp++);
QVERIFY(!window->isInteractiveMove());
Test::pointerButtonPressed(mouseButton, timestamp++);
QVERIFY(window->isInteractiveMove());
kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++);
QVERIFY(!c->isMove());
kwinApp()->platform()->pointerButtonPressed(mouseButton, timestamp++);
QVERIFY(c->isMove());
// release modifier should not change it
Test::keyboardKeyReleased(modifierKey, timestamp++);
QVERIFY(window->isInteractiveMove());
kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++);
QVERIFY(c->isMove());
// but releasing the key should end move/resize
Test::pointerButtonReleased(mouseButton, timestamp++);
QVERIFY(!window->isInteractiveMove());
kwinApp()->platform()->pointerButtonReleased(mouseButton, timestamp++);
QVERIFY(!c->isMove());
if (capsLock) {
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
}
}
@ -632,38 +649,38 @@ void DecorationInputTest::testModifierScrollOpacity()
// first modify the config for this run
QFETCH(QString, modKey);
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("MouseBindings"));
KConfigGroup group = kwinApp()->config()->group("MouseBindings");
group.writeEntry("CommandAllKey", modKey);
group.writeEntry("CommandAllWheel", "change opacity");
group.sync();
workspace()->slotReconfigure();
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
window->move(workspace()->activeOutput()->geometry().center() - QPoint(window->width() / 2, window->height() / 2));
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
// move cursor on window
input()->pointer()->warp(QPoint(window->frameGeometry().center().x(), window->y() + window->frameMargins().top() / 2.0));
Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
// set the opacity to 0.5
window->setOpacity(0.5);
QCOMPARE(window->opacity(), 0.5);
c->setOpacity(0.5);
QCOMPARE(c->opacity(), 0.5);
// simulate modifier+wheel
quint32 timestamp = 1;
QFETCH(bool, capsLock);
if (capsLock) {
Test::keyboardKeyPressed(KEY_CAPSLOCK, timestamp++);
kwinApp()->platform()->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++);
kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++);
kwinApp()->platform()->pointerAxisVertical(-5, timestamp++);
QCOMPARE(c->opacity(), 0.6);
kwinApp()->platform()->pointerAxisVertical(5, timestamp++);
QCOMPARE(c->opacity(), 0.5);
kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++);
if (capsLock) {
Test::keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++);
}
}
@ -671,18 +688,16 @@ class EventHelper : public QObject
{
Q_OBJECT
public:
EventHelper()
: QObject()
{
}
EventHelper() : QObject() {}
~EventHelper() override = default;
bool eventFilter(QObject *watched, QEvent *event) override
{
Q_UNUSED(watched)
if (event->type() == QEvent::HoverMove) {
Q_EMIT hoverMove();
emit hoverMove();
} else if (event->type() == QEvent::HoverLeave) {
Q_EMIT hoverLeave();
emit hoverLeave();
}
return false;
}
@ -696,38 +711,40 @@ void DecorationInputTest::testTouchEvents()
{
// this test verifies that the decoration gets a hover leave event on touch release
// see BUG 386231
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
EventHelper helper;
window->decoration()->installEventFilter(&helper);
c->decoration()->installEventFilter(&helper);
QSignalSpy hoverMoveSpy(&helper, &EventHelper::hoverMove);
QVERIFY(hoverMoveSpy.isValid());
QSignalSpy hoverLeaveSpy(&helper, &EventHelper::hoverLeave);
QVERIFY(hoverLeaveSpy.isValid());
quint32 timestamp = 1;
const QPoint tapPoint(window->frameGeometry().center().x(), window->frameMargins().top() / 2.0);
const QPoint tapPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2);
QVERIFY(!input()->touch()->decoration());
Test::touchDown(0, tapPoint, timestamp++);
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
QVERIFY(input()->touch()->decoration());
QCOMPARE(input()->touch()->decoration()->decoration(), window->decoration());
QCOMPARE(input()->touch()->decoration()->decoration(), c->decoration());
QCOMPARE(hoverMoveSpy.count(), 1);
QCOMPARE(hoverLeaveSpy.count(), 0);
Test::touchUp(0, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 1);
QCOMPARE(hoverLeaveSpy.count(), 1);
QCOMPARE(window->isInteractiveMove(), false);
QCOMPARE(c->isMove(), false);
// let's check that a hover motion is sent if the pointer is on deco, when touch release
input()->pointer()->warp(tapPoint);
Cursors::self()->mouse()->setPos(tapPoint);
QCOMPARE(hoverMoveSpy.count(), 2);
Test::touchDown(0, tapPoint, timestamp++);
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 3);
QCOMPARE(hoverLeaveSpy.count(), 1);
Test::touchUp(0, timestamp++);
kwinApp()->platform()->touchUp(0, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 3);
QCOMPARE(hoverLeaveSpy.count(), 2);
}
@ -741,33 +758,35 @@ void DecorationInputTest::testTooltipDoesntEatKeyEvents()
auto keyboard = Test::waylandSeat()->createKeyboard(Test::waylandSeat());
QVERIFY(keyboard);
QSignalSpy enteredSpy(keyboard, &KWayland::Client::Keyboard::entered);
QVERIFY(enteredSpy.isValid());
const auto [window, surface, shellSurface, decoration] = showWindow();
QVERIFY(window);
QVERIFY(window->isDecorated());
QVERIFY(!window->noBorder());
QVERIFY(enteredSpy.wait());
AbstractClient *c = showWindow();
QVERIFY(c);
QVERIFY(c->isDecorated());
QVERIFY(!c->noBorder());
QTRY_COMPARE(enteredSpy.count(), 1);
QSignalSpy keyEvent(keyboard, &KWayland::Client::Keyboard::keyChanged);
QVERIFY(keyEvent.isValid());
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
window->decoratedClient()->requestShowToolTip(QStringLiteral("test"));
QSignalSpy clientAddedSpy(workspace(), &Workspace::internalClientAdded);
QVERIFY(clientAddedSpy.isValid());
c->decoratedClient()->requestShowToolTip(QStringLiteral("test"));
// now we should get an internal window
QVERIFY(windowAddedSpy.wait());
InternalWindow *internal = windowAddedSpy.first().first().value<InternalWindow *>();
QVERIFY(clientAddedSpy.wait());
InternalClient *internal = clientAddedSpy.first().first().value<InternalClient *>();
QVERIFY(internal->isInternal());
QVERIFY(internal->handle()->flags().testFlag(Qt::ToolTip));
QVERIFY(internal->internalWindow()->flags().testFlag(Qt::ToolTip));
// now send a key
quint32 timestamp = 0;
Test::keyboardKeyPressed(KEY_A, timestamp++);
kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++);
QVERIFY(keyEvent.wait());
Test::keyboardKeyReleased(KEY_A, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++);
QVERIFY(keyEvent.wait());
window->decoratedClient()->requestHideToolTip();
Test::waitForWindowClosed(internal);
c->decoratedClient()->requestHideToolTip();
Test::waitForWindowDestroyed(internal);
}
}

View File

@ -7,14 +7,17 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "pointer_input.h"
#include "utils/xcbutils.h"
#include "abstract_client.h"
#include "platform.h"
#include "x11client.h"
#include "cursor.h"
#include "deleted.h"
#include "screenedge.h"
#include "screens.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include "xcbutils.h"
#include <kwineffects.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
@ -38,49 +41,57 @@ private:
void X11DesktopWindowTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::AbstractClient*>();
qRegisterMetaType<KWin::Deleted*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
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(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
waylandServer()->initWorkspace();
}
void X11DesktopWindowTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
input()->pointer()->warp(QPoint(640, 512));
screens()->setCurrent(0);
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void X11DesktopWindowTest::cleanup()
{
}
struct XcbConnectionDeleter
{
static inline void cleanup(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
Test::XcbConnectionPtr c = Test::createX11Connection();
QVERIFY(!xcb_connection_has_error(c.get()));
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
QVERIFY(!xcb_connection_has_error(c.data()));
xcb_window_t windowId = xcb_generate_id(c.get());
xcb_window_t w = xcb_generate_id(c.data());
const QRect windowGeometry(0, 0, 1280, 1024);
// helper to find the visual
auto findDepth = [&c]() -> xcb_visualid_t {
auto findDepth = [&c] () -> xcb_visualid_t {
// find a visual with 32 depth
const xcb_setup_t *setup = xcb_get_setup(c.get());
const xcb_setup_t *setup = xcb_get_setup(c.data());
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)) {
@ -98,52 +109,54 @@ void X11DesktopWindowTest::testDesktopWindow()
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));
auto colormapId = xcb_generate_id(c.data());
auto cmCookie = xcb_create_colormap_checked(c.data(), XCB_COLORMAP_ALLOC_NONE, colormapId, rootWindow(), visualId);
QVERIFY(!xcb_request_check(c.data(), cmCookie));
const uint32_t values[] = {XCB_PIXMAP_NONE, Xcb::defaultScreen()->black_pixel, colormapId};
auto cookie = xcb_create_window_checked(c.get(), 32, windowId, rootWindow(),
const uint32_t values[] = {XCB_PIXMAP_NONE, kwinApp()->x11DefaultScreen()->black_pixel, colormapId};
auto cookie = xcb_create_window_checked(c.data(), 32, w, 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));
QVERIFY(!xcb_request_check(c.data(), 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);
xcb_icccm_set_wm_normal_hints(c.data(), w, &hints);
NETWinInfo info(c.data(), w, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties);
info.setWindowType(NET::Desktop);
xcb_map_window(c.get(), windowId);
xcb_flush(c.get());
xcb_map_window(c.data(), w);
xcb_flush(c.data());
// verify through a geometry request that it's depth 32
Xcb::WindowGeometry geo(windowId);
Xcb::WindowGeometry geo(w);
QCOMPARE(geo->depth, uint8_t(32));
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
// we should get a client for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(windowCreatedSpy.isValid());
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(!window->isDecorated());
QCOMPARE(window->windowType(), WindowType::Desktop);
QCOMPARE(window->frameGeometry(), windowGeometry);
QVERIFY(window->isDesktop());
QCOMPARE(window->depth(), 24);
QVERIFY(!window->hasAlpha());
X11Client *client = windowCreatedSpy.first().first().value<X11Client *>();
QVERIFY(client);
QCOMPARE(client->window(), w);
QVERIFY(!client->isDecorated());
QCOMPARE(client->windowType(), NET::Desktop);
QCOMPARE(client->frameGeometry(), windowGeometry);
QVERIFY(client->isDesktop());
QCOMPARE(client->depth(), 24);
QVERIFY(!client->hasAlpha());
// and destroy the window again
xcb_unmap_window(c.get(), windowId);
xcb_destroy_window(c.get(), windowId);
xcb_flush(c.get());
xcb_unmap_window(c.data(), w);
xcb_destroy_window(c.data(), w);
xcb_flush(c.data());
c.reset();
QSignalSpy windowClosedSpy(window, &X11Window::closed);
QSignalSpy windowClosedSpy(client, &X11Client::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
}

View File

@ -7,12 +7,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "pointer_input.h"
#include "platform.h"
#include "x11client.h"
#include "composite.h"
#include "cursor.h"
#include "screenedge.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include "scene.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
@ -32,25 +36,21 @@ private Q_SLOTS:
void initTestCase();
void init();
void testBorderlessMaximizedWindows();
};
void DontCrashAuroraeDestroyDecoTest::initTestCase()
{
if (!Test::renderNodeAvailable()) {
QSKIP("no render node available");
return;
}
qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8());
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::AbstractClient*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
config->group(QStringLiteral("org.kde.kdecoration2")).writeEntry("library", "org.kde.kwin.aurorae");
config->group("org.kde.kdecoration2").writeEntry("library", "org.kde.kwin.aurorae");
config->sync();
kwinApp()->setConfig(config);
@ -58,17 +58,21 @@ void DontCrashAuroraeDestroyDecoTest::initTestCase()
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));
QCOMPARE(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
waylandServer()->initWorkspace();
auto scene = KWin::Compositor::self()->scene();
QVERIFY(scene);
QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing);
}
void DontCrashAuroraeDestroyDecoTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
input()->pointer()->warp(QPoint(640, 512));
screens()->setCurrent(0);
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows()
@ -78,58 +82,61 @@ void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows()
// see BUG 362772
// first adjust the config
KConfigGroup group = kwinApp()->config()->group(QStringLiteral("Windows"));
KConfigGroup group = kwinApp()->config()->group("Windows");
group.writeEntry("BorderlessMaximizedWindows", true);
group.sync();
workspace()->slotReconfigure();
QCOMPARE(options->borderlessMaximizedWindows(), true);
// create an xcb window
Test::XcbConnectionPtr connection = Test::createX11Connection();
auto c = connection.get();
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_window_t w = xcb_generate_id(c);
xcb_create_window(c, XCB_COPY_FROM_PARENT, w, rootWindow(), 0, 0, 100, 200, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_map_window(c, w);
xcb_flush(c);
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
// we should get a client for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(windowCreatedSpy.isValid());
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);
X11Client *client = windowCreatedSpy.first().first().value<X11Client *>();
QVERIFY(client);
QCOMPARE(client->window(), w);
QVERIFY(client->isDecorated());
QCOMPARE(client->maximizeMode(), MaximizeRestore);
QCOMPARE(client->noBorder(), false);
// verify that the deco is Aurorae
QCOMPARE(qstrcmp(window->decoration()->metaObject()->className(), "Aurorae::Decoration"), 0);
QCOMPARE(qstrcmp(client->decoration()->metaObject()->className(), "Aurorae::Decoration"), 0);
// find the maximize button
QQuickItem *item = window->decoration()->property("item").value<QQuickItem *>()->findChild<QQuickItem *>("maximizeButton");
QQuickItem *item = client->decoration()->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());
QMetaObject::invokeMethod(client, "setReadyForPainting");
QVERIFY(client->readyForPainting());
// simulate click on maximize button
QSignalSpy maximizedStateChangedSpy(window, &Window::maximizedChanged);
QSignalSpy maximizedStateChangedSpy(client, static_cast<void (AbstractClient::*)(KWin::AbstractClient*, MaximizeMode)>(&AbstractClient::clientMaximizedStateChanged));
QVERIFY(maximizedStateChangedSpy.isValid());
quint32 timestamp = 1;
Test::pointerMotion(window->frameGeometry().topLeft() + scenePoint.toPoint(), timestamp++);
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
Test::pointerButtonReleased(BTN_LEFT, timestamp++);
kwinApp()->platform()->pointerMotion(client->frameGeometry().topLeft() + scenePoint.toPoint(), timestamp++);
kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++);
kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++);
QVERIFY(maximizedStateChangedSpy.wait());
QCOMPARE(window->maximizeMode(), MaximizeFull);
QCOMPARE(window->noBorder(), true);
QCOMPARE(client->maximizeMode(), MaximizeFull);
QCOMPARE(client->noBorder(), true);
// and destroy the window again
xcb_unmap_window(c, windowId);
xcb_destroy_window(c, windowId);
xcb_unmap_window(c, w);
xcb_destroy_window(c, w);
xcb_flush(c);
xcb_disconnect(c);
QSignalSpy windowClosedSpy(window, &X11Window::closed);
QSignalSpy windowClosedSpy(client, &X11Client::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
}

View File

@ -7,27 +7,25 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "compositor.h"
#include "effect/effecthandler.h"
#include "effect/effectloader.h"
#include "scripting/scriptedeffect.h"
#include "platform.h"
#include "abstract_client.h"
#include "x11client.h"
#include "composite.h"
#include "deleted.h"
#include "effects.h"
#include "effectloader.h"
#include "screens.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#if KWIN_BUILD_X11
#include "x11window.h"
#endif
#include "scripting/scriptedeffect.h"
#include <KDecoration2/Decoration>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/compositor.h>
#include <KWayland/Client/shm_pool.h>
#include <KWayland/Client/surface.h>
#include <QSignalSpy>
namespace KWin
{
@ -45,15 +43,14 @@ private Q_SLOTS:
void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
qRegisterMetaType<KWin::Deleted*>();
qRegisterMetaType<KWin::AbstractClient*>();
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
kwinApp()->start();
QVERIFY(Compositor::self());
QSignalSpy compositorToggledSpy(Compositor::self(), &Compositor::compositingToggled);
QVERIFY(compositorToggledSpy.isValid());
QVERIFY(compositorToggledSpy.wait());
QVERIFY(effects);
}
@ -71,7 +68,7 @@ void DontCrashCancelAnimationFromAnimationEndedTest::cleanup()
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());
ScriptedEffect *effect = ScriptedEffect::create(QStringLiteral("crashy"), QFINDTESTDATA("data/anim-data-delete-effect/effect.js"), 10);
QVERIFY(effect);
const auto children = effects->children();
@ -79,28 +76,30 @@ void DontCrashCancelAnimationFromAnimationEndedTest::testScript()
if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) {
continue;
}
QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, effect), Q_ARG(QString, QStringLiteral("crashy"))));
QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect*, effect), Q_ARG(QString, QStringLiteral("crashy"))));
break;
}
QVERIFY(effects->isEffectLoaded(QStringLiteral("crashy")));
QVERIFY(static_cast<EffectsHandlerImpl*>(effects)->isEffectLoaded(QStringLiteral("crashy")));
using namespace KWayland::Client;
// create a window
std::unique_ptr<KWayland::Client::Surface> surface{Test::createSurface()};
Surface *surface = Test::createSurface(Test::waylandCompositor());
QVERIFY(surface);
std::unique_ptr<Test::XdgToplevel> shellSurface = Test::createXdgToplevelSurface(surface.get());
XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface);
QVERIFY(shellSurface);
// let's render
Window *window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
QVERIFY(window);
QCOMPARE(workspace()->activeWindow(), window);
auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue);
QVERIFY(c);
QCOMPARE(workspace()->activeClient(), c);
// make sure we animate
QTest::qWait(200);
// wait for the window to be passed to Deleted
QSignalSpy windowDeletedSpy(window, &Window::closed);
QSignalSpy windowDeletedSpy(c, &AbstractClient::windowClosed);
QVERIFY(windowDeletedSpy.isValid());
surface.reset();
surface->deleteLater();
QVERIFY(windowDeletedSpy.wait());
// make sure we animate

View File

@ -0,0 +1,99 @@
/*
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 "effectloader.h"
#include "x11client.h"
#include "cursor.h"
#include "effects.h"
#include "platform.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include <KConfigGroup>
#include <KWayland/Client/seat.h>
#include <KWayland/Client/server_decoration.h>
#include <KWayland/Client/surface.h>
#include <KWaylandServer/display.h>
#include <KWaylandServer/output_interface.h>
using namespace KWin;
using namespace KWayland::Client;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_crash_cursor_physical_size_empty-0");
class DontCrashCursorPhysicalSizeEmpty : public QObject
{
Q_OBJECT
private Q_SLOTS:
void init();
void initTestCase();
void cleanup();
void testMoveCursorOverDeco();
};
void DontCrashCursorPhysicalSizeEmpty::init()
{
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
screens()->setCurrent(0);
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashCursorPhysicalSizeEmpty::cleanup()
{
Test::destroyWaylandConnection();
}
void DontCrashCursorPhysicalSizeEmpty::initTestCase()
{
qRegisterMetaType<KWin::AbstractClient*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
if (!QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("icons/DMZ-White/index.theme")).isEmpty()) {
qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White"));
} else {
// might be vanilla-dmz (e.g. Arch, FreeBSD)
qputenv("XCURSOR_THEME", QByteArrayLiteral("Vanilla-DMZ"));
}
qputenv("XCURSOR_SIZE", QByteArrayLiteral("0"));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
void DontCrashCursorPhysicalSizeEmpty::testMoveCursorOverDeco()
{
// This test ensures that there is no endless recursion if the cursor theme cannot be created
// a reason for creation failure could be physical size not existing
// see BUG: 390314
QScopedPointer<Surface> surface(Test::createSurface());
Test::waylandServerSideDecoration()->create(surface.data(), surface.data());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QVERIFY(c->isDecorated());
// destroy physical size
KWaylandServer::Display *display = waylandServer()->display();
auto output = display->outputs().first();
output->setPhysicalSize(QSize(0, 0));
// and fake a cursor theme change, so that the theme gets recreated
emit KWin::Cursors::self()->mouse()->themeChanged();
KWin::Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2));
}
WAYLANDTEST_MAIN(DontCrashCursorPhysicalSizeEmpty)
#include "dont_crash_cursor_physical_size_empty.moc"

View File

@ -7,12 +7,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "core/output.h"
#include "pointer_input.h"
#include "platform.h"
#include "x11client.h"
#include "composite.h"
#include "cursor.h"
#include "scene.h"
#include "screenedge.h"
#include "screens.h"
#include "wayland_server.h"
#include "workspace.h"
#include "x11window.h"
#include <kwineffects.h>
#include <KDecoration2/Decoration>
@ -34,33 +38,32 @@ private Q_SLOTS:
void DontCrashEmptyDecorationTest::initTestCase()
{
if (!Test::renderNodeAvailable()) {
QSKIP("no render node available");
return;
}
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::AbstractClient*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
// 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));
QCOMPARE(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024));
QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024));
setenv("QT_QPA_PLATFORM", "wayland", true);
waylandServer()->initWorkspace();
auto scene = KWin::Compositor::self()->scene();
QVERIFY(scene);
QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing);
}
void DontCrashEmptyDecorationTest::init()
{
workspace()->setActiveOutput(QPoint(640, 512));
input()->pointer()->warp(QPoint(640, 512));
screens()->setCurrent(0);
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashEmptyDecorationTest::testBug361551()
@ -70,35 +73,35 @@ void DontCrashEmptyDecorationTest::testBug361551()
// there a repaint is scheduled and the resulting texture is invalid if the window size is invalid
// create an xcb window
Test::XcbConnectionPtr connection = Test::createX11Connection();
auto c = connection.get();
QVERIFY(c);
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_window_t w = xcb_generate_id(c);
xcb_create_window(c, XCB_COPY_FROM_PARENT, w, rootWindow(), 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
xcb_map_window(c, w);
xcb_flush(c);
// we should get a window for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::windowAdded);
// we should get a client for it
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(windowCreatedSpy.isValid());
QVERIFY(windowCreatedSpy.wait());
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
QVERIFY(window->isDecorated());
X11Client *client = windowCreatedSpy.first().first().value<X11Client *>();
QVERIFY(client);
QCOMPARE(client->window(), w);
QVERIFY(client->isDecorated());
// let's set a stupid geometry
window->moveResize({0, 0, 0, 0});
QCOMPARE(window->frameGeometry(), QRect(0, 0, 0, 0));
client->setFrameGeometry({0, 0, 0, 0});
QCOMPARE(client->frameGeometry(), QRect(0, 0, 0, 0));
// and destroy the window again
xcb_unmap_window(c, windowId);
xcb_destroy_window(c, windowId);
xcb_unmap_window(c, w);
xcb_destroy_window(c, w);
xcb_flush(c);
xcb_disconnect(c);
QSignalSpy windowClosedSpy(window, &X11Window::closed);
QSignalSpy windowClosedSpy(client, &X11Client::windowClosed);
QVERIFY(windowClosedSpy.isValid());
QVERIFY(windowClosedSpy.wait());
}

View File

@ -7,16 +7,16 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "abstract_client.h"
#include "x11client.h"
#include "deleted.h"
#include "screens.h"
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include "x11window.h"
#include <KDecoration2/Decoration>
#include <QSignalSpy>
namespace KWin
{
@ -32,13 +32,11 @@ private Q_SLOTS:
void DontCrashGlxgearsTest::initTestCase()
{
qRegisterMetaType<KWin::Window *>();
qRegisterMetaType<KWin::Deleted*>();
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
QVERIFY(waylandServer()->init(s_socketName));
Test::setOutputConfig({
QRect(0, 0, 1280, 1024),
QRect(1280, 0, 1280, 1024),
});
QVERIFY(applicationStartedSpy.isValid());
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
kwinApp()->start();
QVERIFY(applicationStartedSpy.wait());
}
@ -48,20 +46,22 @@ 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);
QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
QVERIFY(clientAddedSpy.isValid());
QProcess glxgears;
glxgears.setProgram(QStringLiteral("glxgears"));
glxgears.start();
QVERIFY(glxgears.waitForStarted());
QVERIFY(windowAddedSpy.wait());
QCOMPARE(windowAddedSpy.count(), 1);
QCOMPARE(workspace()->windows().count(), 1);
Window *glxgearsWindow = workspace()->windows().first();
QVERIFY(glxgearsWindow->isDecorated());
QSignalSpy closedSpy(glxgearsWindow, &X11Window::closed);
KDecoration2::Decoration *decoration = glxgearsWindow->decoration();
QVERIFY(clientAddedSpy.wait());
QCOMPARE(clientAddedSpy.count(), 1);
QCOMPARE(workspace()->clientList().count(), 1);
X11Client *glxgearsClient = workspace()->clientList().first();
QVERIFY(glxgearsClient->isDecorated());
QSignalSpy closedSpy(glxgearsClient, &X11Client::windowClosed);
QVERIFY(closedSpy.isValid());
KDecoration2::Decoration *decoration = glxgearsClient->decoration();
QVERIFY(decoration);
// send a mouse event to the position of the close button

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