Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KWin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
17
Issues
17
List
Boards
Labels
Service Desk
Milestones
Merge Requests
39
Merge Requests
39
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Plasma
KWin
Commits
c9fa43e9
Commit
c9fa43e9
authored
Jul 20, 2017
by
Martin Flöser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[autotests] Add test case for Client window shortcut
Registers a shortcut on a window and triggers it.
parent
81c59a86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
1 deletion
+83
-1
autotests/integration/CMakeLists.txt
autotests/integration/CMakeLists.txt
+1
-1
autotests/integration/globalshortcuts_test.cpp
autotests/integration/globalshortcuts_test.cpp
+82
-0
No files found.
autotests/integration/CMakeLists.txt
View file @
c9fa43e9
...
...
@@ -40,7 +40,6 @@ integrationTest(NAME testNoXdgRuntimeDir SRCS no_xdg_runtime_dir_test.cpp)
integrationTest
(
NAME testScreenChanges SRCS screen_changes_test.cpp
)
integrationTest
(
NAME testModiferOnlyShortcut SRCS modifier_only_shortcut_test.cpp
)
integrationTest
(
NAME testTabBox SRCS tabbox_test.cpp
)
integrationTest
(
NAME testGlobalShortcuts SRCS globalshortcuts_test.cpp
)
integrationTest
(
NAME testWindowSelection SRCS window_selection_test.cpp
)
integrationTest
(
NAME testPointerConstraints SRCS pointer_constraints_test.cpp
)
integrationTest
(
NAME testKeyboardLayout SRCS keyboard_layout_test.cpp
)
...
...
@@ -60,6 +59,7 @@ if (XCB_ICCCM_FOUND)
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
)
if
(
KWIN_BUILD_ACTIVITIES
)
integrationTest
(
NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM
)
...
...
autotests/integration/globalshortcuts_test.cpp
View file @
c9fa43e9
...
...
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "kwin_wayland_test.h"
#include "client.h"
#include "cursor.h"
#include "input.h"
#include "platform.h"
...
...
@@ -34,6 +35,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KGlobalAccel>
#include <linux/input.h>
#include <netwm.h>
#include <xcb/xcb_icccm.h>
using
namespace
KWin
;
using
namespace
KWayland
::
Client
;
...
...
@@ -51,6 +55,7 @@ private Q_SLOTS:
void
testRepeatedTrigger
();
void
testUserActionsMenu
();
void
testMetaShiftW
();
void
testX11ClientShortcut
();
};
void
GlobalShortcutsTest
::
initTestCase
()
...
...
@@ -195,5 +200,82 @@ void GlobalShortcutsTest::testMetaShiftW()
kwinApp
()
->
platform
()
->
keyboardKeyReleased
(
KEY_LEFTMETA
,
timestamp
++
);
}
struct
XcbConnectionDeleter
{
static
inline
void
cleanup
(
xcb_connection_t
*
pointer
)
{
xcb_disconnect
(
pointer
);
}
};
void
GlobalShortcutsTest
::
testX11ClientShortcut
()
{
// create an X11 window
QScopedPointer
<
xcb_connection_t
,
XcbConnectionDeleter
>
c
(
xcb_connect
(
nullptr
,
nullptr
));
QVERIFY
(
!
xcb_connection_has_error
(
c
.
data
()));
xcb_window_t
w
=
xcb_generate_id
(
c
.
data
());
const
QRect
windowGeometry
=
QRect
(
0
,
0
,
10
,
20
);
const
uint32_t
values
[]
=
{
XCB_EVENT_MASK_ENTER_WINDOW
|
XCB_EVENT_MASK_LEAVE_WINDOW
};
xcb_create_window
(
c
.
data
(),
XCB_COPY_FROM_PARENT
,
w
,
rootWindow
(),
windowGeometry
.
x
(),
windowGeometry
.
y
(),
windowGeometry
.
width
(),
windowGeometry
.
height
(),
0
,
XCB_WINDOW_CLASS_INPUT_OUTPUT
,
XCB_COPY_FROM_PARENT
,
XCB_CW_EVENT_MASK
,
values
);
xcb_size_hints_t
hints
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
xcb_icccm_size_hints_set_position
(
&
hints
,
1
,
windowGeometry
.
x
(),
windowGeometry
.
y
());
xcb_icccm_size_hints_set_size
(
&
hints
,
1
,
windowGeometry
.
width
(),
windowGeometry
.
height
());
xcb_icccm_set_wm_normal_hints
(
c
.
data
(),
w
,
&
hints
);
NETWinInfo
info
(
c
.
data
(),
w
,
rootWindow
(),
NET
::
WMAllProperties
,
NET
::
WM2AllProperties
);
info
.
setWindowType
(
NET
::
Normal
);
xcb_map_window
(
c
.
data
(),
w
);
xcb_flush
(
c
.
data
());
QSignalSpy
windowCreatedSpy
(
workspace
(),
&
Workspace
::
clientAdded
);
QVERIFY
(
windowCreatedSpy
.
isValid
());
QVERIFY
(
windowCreatedSpy
.
wait
());
Client
*
client
=
windowCreatedSpy
.
last
().
first
().
value
<
Client
*>
();
QVERIFY
(
client
);
QCOMPARE
(
workspace
()
->
activeClient
(),
client
);
QVERIFY
(
client
->
isActive
());
QCOMPARE
(
client
->
shortcut
(),
QKeySequence
());
const
QKeySequence
seq
(
Qt
::
META
+
Qt
::
SHIFT
+
Qt
::
Key_Y
);
QVERIFY
(
workspace
()
->
shortcutAvailable
(
seq
));
client
->
setShortcut
(
seq
.
toString
());
QCOMPARE
(
client
->
shortcut
(),
seq
);
QVERIFY
(
!
workspace
()
->
shortcutAvailable
(
seq
));
QCOMPARE
(
client
->
caption
(),
QStringLiteral
(
" {Meta+Shift+Y}"
));
// it's delayed
QCoreApplication
::
processEvents
();
workspace
()
->
activateClient
(
nullptr
);
QVERIFY
(
!
workspace
()
->
activeClient
());
QVERIFY
(
!
client
->
isActive
());
// now let's trigger the shortcut
quint32
timestamp
=
0
;
kwinApp
()
->
platform
()
->
keyboardKeyPressed
(
KEY_LEFTMETA
,
timestamp
++
);
kwinApp
()
->
platform
()
->
keyboardKeyPressed
(
KEY_LEFTSHIFT
,
timestamp
++
);
kwinApp
()
->
platform
()
->
keyboardKeyPressed
(
KEY_Y
,
timestamp
++
);
QTRY_COMPARE
(
workspace
()
->
activeClient
(),
client
);
kwinApp
()
->
platform
()
->
keyboardKeyReleased
(
KEY_Y
,
timestamp
++
);
kwinApp
()
->
platform
()
->
keyboardKeyReleased
(
KEY_LEFTSHIFT
,
timestamp
++
);
kwinApp
()
->
platform
()
->
keyboardKeyReleased
(
KEY_LEFTMETA
,
timestamp
++
);
// destroy window again
QSignalSpy
windowClosedSpy
(
client
,
&
Client
::
windowClosed
);
QVERIFY
(
windowClosedSpy
.
isValid
());
xcb_unmap_window
(
c
.
data
(),
w
);
xcb_destroy_window
(
c
.
data
(),
w
);
xcb_flush
(
c
.
data
());
QVERIFY
(
windowClosedSpy
.
wait
());
}
WAYLANDTEST_MAIN
(
GlobalShortcutsTest
)
#include "globalshortcuts_test.moc"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment