Skip to content

Commit

Permalink
[autotests/integration] Add test case for global shortcuts with Fx
Browse files Browse the repository at this point in the history
New test which tries to trigger Alt+F3 which does not work due to the
behavior how xkbcommon calculates consumed modifers. The combination
Ctrl+Alt+F3 generates a keysym (vt switching) so just pressing F3
already consumes ctrl and alt modifier.

For more information see:
 * xkbcommon/libxkbcommon#17
 * https://bugs.freedesktop.org/show_bug.cgi?id=92818

CCBUG: 368989
  • Loading branch information
mgraesslin committed Oct 5, 2016
1 parent 03b8477 commit 974abbf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions autotests/integration/globalshortcuts_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "platform.h"
#include "screens.h"
#include "shell_client.h"
#include "useractions.h"
#include "wayland_server.h"
#include "workspace.h"

#include <KWayland/Client/shell.h>
#include <KWayland/Client/surface.h>
#include <KWayland/Server/seat_interface.h>

#include <KGlobalAccel>
Expand All @@ -46,6 +49,7 @@ private Q_SLOTS:

void testConsumedShift();
void testRepeatedTrigger();
void testUserActionsMenu();
};

void GlobalShortcutsTest::initTestCase()
Expand All @@ -67,12 +71,14 @@ void GlobalShortcutsTest::initTestCase()

void GlobalShortcutsTest::init()
{
QVERIFY(Test::setupWaylandConnection(s_socketName));
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(640, 512));
}

void GlobalShortcutsTest::cleanup()
{
Test::destroyWaylandConnection();
}

void GlobalShortcutsTest::testConsumedShift()
Expand Down Expand Up @@ -137,5 +143,32 @@ void GlobalShortcutsTest::testRepeatedTrigger()
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++);
}

void GlobalShortcutsTest::testUserActionsMenu()
{
// this test tries to trigger the user actions menu with Alt+F3
// the problem here is that pressing F3 consumes modifiers as it's part of the
// Ctrl+alt+F3 keysym for vt switching. xkbcommon considers all modifiers as consumed
// which a transformation to any keysym would cause
// for more information see:
// https://bugs.freedesktop.org/show_bug.cgi?id=92818
// https://github.com/xkbcommon/libxkbcommon/issues/17

// first create a window
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
QVERIFY(c);
QVERIFY(c->isActive());

quint32 timestamp = 0;
QVERIFY(!workspace()->userActionsMenu()->isShown());
kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++);
kwinApp()->platform()->keyboardKeyPressed(KEY_F3, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_F3, timestamp++);
QEXPECT_FAIL("", "BUG 368989", Continue);
QTRY_VERIFY(workspace()->userActionsMenu()->isShown());
kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++);
}

WAYLANDTEST_MAIN(GlobalShortcutsTest)
#include "globalshortcuts_test.moc"
4 changes: 3 additions & 1 deletion useractions.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KWIN_USERACTIONS_H
#include "ui_shortcutdialog.h"

#include <kwinglobals.h>

// Qt
#include <QDialog>
#include <QObject>
Expand Down Expand Up @@ -52,7 +54,7 @@ class Client;
*
* @author Martin Gräßlin <[email protected]>
**/
class UserActionsMenu : public QObject
class KWIN_EXPORT UserActionsMenu : public QObject
{
Q_OBJECT
public:
Expand Down

0 comments on commit 974abbf

Please sign in to comment.