KWin
Loading...
Searching...
No Matches
autotests
integration
helper
copy.cpp
Go to the documentation of this file.
1
/*
2
KWin - the KDE window manager
3
This file is part of the KDE project.
4
5
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
6
7
SPDX-License-Identifier: GPL-2.0-or-later
8
*/
9
#include <QClipboard>
10
#include <QGuiApplication>
11
#include <QPainter>
12
#include <QRasterWindow>
13
#include <QTimer>
14
15
class
Window
:
public
QRasterWindow
16
{
17
Q_OBJECT
18
public
:
19
explicit
Window
();
20
~Window
()
override
;
21
22
protected
:
23
void
paintEvent
(QPaintEvent *event)
override
;
24
void
focusInEvent
(QFocusEvent *event)
override
;
25
};
26
27
Window::Window
()
28
: QRasterWindow()
29
{
30
}
31
32
Window::~Window
() =
default
;
33
34
void
Window::paintEvent
(QPaintEvent *event)
35
{
36
QPainter p(
this
);
37
p.fillRect(0, 0, width(), height(), Qt::red);
38
}
39
40
void
Window::focusInEvent
(QFocusEvent *event)
41
{
42
QRasterWindow::focusInEvent(event);
43
// TODO: make it work without singleshot
44
QTimer::singleShot(100, [] {
45
qApp->clipboard()->setText(QStringLiteral(
"test"
));
46
});
47
}
48
49
int
main
(
int
argc,
char
*argv[])
50
{
51
QGuiApplication app(argc, argv);
52
std::unique_ptr<Window> w(
new
Window
);
53
w->setGeometry(QRect(0, 0, 100, 200));
54
w->show();
55
56
return
app.exec();
57
}
58
59
#include "copy.moc"
Window
Definition
copy.cpp:16
Window::~Window
~Window() override
Window::Window
Window()
Definition
copy.cpp:27
Window::focusInEvent
void focusInEvent(QFocusEvent *event) override
Definition
copy.cpp:40
Window::paintEvent
void paintEvent(QPaintEvent *event) override
Definition
copy.cpp:34
main
int main()
Definition
kwin-6.0-reset-active-mouse-screen.cpp:10
Generated on Sat Feb 17 2024 01:42:09 for KWin by
1.10.0