76 Commits

Author SHA1 Message Date
Johan Klokkhammer Helsing
3b4dd0f24b Client: Set key repeat rate and delay from the repeat_info event
[ChangeLog][QPA plugin] Clients now follow the keyboard key repeat delay and
interval configured by the compositor.

Change-Id: I8a88d341a2bb648d70f95494fe19e941273ae31b
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-10-17 14:24:46 +00:00
Johan Klokkhammer Helsing
f086d96035 Client: Remove failing assert on compositors without wl_data_device
Some compositors don't advertise wl_data_device_manager support, and the client
has no control over this, so the assertion doesn't make sense. Returning
nullptr in that case should be fine.

Change-Id: If0b145326d074ea4ebf8f5a12654962d56012a2d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-10-03 06:32:49 +00:00
Johan Klokkhammer Helsing
3e66edd846 Client: Fix cursor hotspot on high-dpi
QWaylandInputDevice::setCursor(wl_buffer, QPoint, QSize, bufferscale) assumes a
hotspot and a size in surface coordinates, while wl_cursor_image uses pixel
coordinates.

Divide by bufferScale to get the correct values.

This breaks hidpi cursors on kwin 5.13.1 and earlier, where buffer scale for
cursor surfaces are ignored.

Change-Id: I7c86bc541ccf5fb878facebbe93d2b1f842dfc5c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-27 11:20:00 +00:00
Aleix Pol
c683571411 Adapt the cursor size per screen
Adapt the cursor size to the screen's devicePixelRatio, so we are not
forced to have a tiny cursor on a high dpi screen or a huge cursor on
external low-dpi displays.

Change-Id: I3712dc64e5c5e2e05d0dc5943bd49ba5c1335cd3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-05-15 09:43:58 +00:00
Johan Klokkhammer Helsing
9147c0e688 Init variables where they are declared when possible (clang-tidy)
clang-tidy -p compile_commands.json $file \
    -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' \
    -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' \
    -header-filter='qtwayland' \
    -fix

Afterwards I ran search and replace on the diff to clean up some whitespace errors:

- Replaced '(\n\+[^:\n]*)(:\s+\+\s+)' with '$1: '
- Replaced '(\n\+[^,\n]*)(,\s+\+\s+)' with '$1, '
- Replaced '\n\+\s*\n' with '\n'

I also had to do some manual edits, because for some reason, this particular
clang-tidy check doesn't trigger for some files.

Change-Id: I3b3909bac4bf20108bbe8ad1e01bcc54236dae1b
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-02-27 17:03:41 +00:00
Johan Klokkhammer Helsing
7b40685ad2 Simplify and modernize QWaylandInputDevice
Use enum values and nullptr instead of using magic ints directly. Also get rid
of ifdefs in constructors by using in-class member initializers.

Change-Id: I037bec7070296a4a8cb46ebe85104caf5a08fb77
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-12-05 13:43:42 +00:00
Giulio Camuffo
dd13698a73 Implement basic key composition support
Use xkbcommon-compose to handle basic compose key support. We should expand on
it in the future to handle things like resetting the compose state on text
field switching.

Task-number: QTBUG-54792
Task-number: QTBUG-64572
Change-Id: I9d1d5ca4c9991928e12979f69eaa477e0cb28ada
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-12-04 13:47:25 +00:00
Johan Klokkhammer Helsing
a6257efe0c Client: Use QPointer for focus members of input device capabilities
Change-Id: I2824269f89fddb7e276cf0e35df3f7c063b6d8b3
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-11-17 13:07:06 +00:00
Giulio Camuffo
c9a156f29e Set the cursor when the pointer enters the window
Change-Id: I1ff9928bc5d9d1d80ce07561243eeec89c406e36
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-05-12 15:53:34 +00:00
David Edmundson
6698deaa46 Pass modifiers with wheel events
Change-Id: I345cdeea1357a8f9201a74b2d5e80350b6c42f24
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-05-12 15:15:19 +00:00
Paul Olav Tvete
086b0a9a26 Clean up draganddrop and clipboard features
Don't assume that no-draganddrop implies no-clipboard. Introduce
a new private feature wayland-datadevice which contains the
common functionality. This feature cannot be controlled independently,
but is automatically disabled when both clipboard and draganddrop are
disabled.

Change-Id: I6aac09c7ee524e3b11f0a1caa4a6c62fc3f1d10f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-03-23 13:37:00 +00:00
Tasuku Suzuki
cfcc462166 Fix build without feature.cursor
Change-Id: If244e7ac58133ae6fbefacfa243d47fa210140be
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-13 14:25:20 +00:00
Lars Knoll
f6912982eb Use new feature system, part 2
Convert all uses of QT_NO_FOO to proper QT_CONFIG(foo) checks.

Change-Id: Id0f0b3325c246567a43d6b2d71b0d69e5535e648
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2016-11-23 08:42:11 +00:00
Lars Knoll
1d51cabc54 Use the feature system internally
Get rid of almost all DEFINES += ... in the pro files,
instead use the proper QT_CONFIG() macro to determine
whether a feature is available.

Change-Id: I867769be2085c6ba93b6815e223e2b89edcb245d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-23 08:42:05 +00:00
Giulio Camuffo
999fe98f66 Don't reset the cursor at every mouse move
Change-Id: I67f9a0d171da403ebb124ab584c2510891da80fc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-22 09:09:17 +00:00
Paul Olav Tvete
27490e8dde Merge remote-tracking branch 'qt/5.6' into 5.7
Change-Id: I1efd16d6c5f939d61001376c3b010eae1927595b
2016-11-10 10:40:10 +01:00
Johan Klokkhammer Helsing
8d291193ab Client: Cleanup mouse state after drag
Fixes an issue where dragging with the mouse would cause the next touch event
to not generate a synthesized mouse press event.

The touchDrag test can now be run directly after the mouseDrag test without
failing.

Task-number: QTBUG-56187
Change-Id: I53cc5f90fc8d8672936b23f54a017687d41c31fc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-10 08:07:35 +00:00
Johan Klokkhammer Helsing
c8e2e7d102 Client: Fix touch getting stuck after drag-and-drop
wl_touch.up is not sent by compositors when dragging, so release all touch
points when the drag ends.

Task-number: QTBUG-56187
Change-Id: I1c3d03c72e75a551355c50bb5d82433f5e2e35f0
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-09 15:17:58 +00:00
Paul Olav Tvete
c1444d272e Fix build when some features are disabled
Make QtWaylandClient compile when Qt is configured with:

-no-opengl -no-accessibility -D QT_NO_CLIPBOARD -D QT_NO_DRAGANDDROP -D QT_NO_SESSIONMANAGER

Task-number: QTBUG-56192
Change-Id: Idc6aae6b36a35515109a27bed31a22e3e909ef27
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-11-07 09:07:48 +00:00
Liang Qi
d04de01e80 Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I75a8ddc0652f3c6f438ef98e940c9357450d29c6
2016-08-01 11:03:38 +02:00
Johan Klokkhammer Helsing
d4d47f2a04 Use xdg_shell configure events to determine active window
According to the xdg_shell protocol, the compositor is allowed to set multiple
active windows. Qt's model, however, allows only a single active window.

In order to map between the models, a list of the compositor's active windows
is kept in QWaylandDisplay in the order they were activated. Hence, the front
of this list will always be the most recently activated window, and it will be
mapped as Qt's active window.

Previously keyboard focus was used to determine the active window, this method
has been disabled for xdg_shell.

Functionality for delaying the call to
QWindowSystemInterface::handleWindowActivated has been moved from
QWaylandInputDevice::Keyboard to QWaylandDisplay so the implementations can
share the workaround.

Task-number: QTBUG-53702
Change-Id: I878151f9c52ed09a8d6571c6208920436c3ca8fc
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-07-04 14:05:30 +00:00
Giulio Camuffo
f213a7d54e Fix the key code of key events when control is pressed
Change-Id: I51a57a32d8263e663a48dac15881d685359bc91d
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-07-04 08:34:00 +00:00
Liang Qi
c32b30362d Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/client/qwaylandinputcontext_p.h
	src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h
	src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
	src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h

Change-Id: Iac517e1985e4e67d7ca00ca4c10dcda9dd9079f9
2016-06-30 10:20:40 +02:00
Johan Klokkhammer Helsing
261f31eacb Remove unused method QWaylandDisplay::lastKeyboardFocusInputDevice
Change-Id: Iee19b36ae2032112e0097dc6eb2e4592697c2a1c
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-06-29 13:39:26 +00:00
Paul Olav Tvete
7efc23b8fb Rename private headers to _p.h
Change-Id: I0f0d1bd8efabc39325eec7dba4166ae0bccbf6ff
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-05-19 07:33:26 +00:00
Jan Arne Petersen
853f8f6b67 Fix text-input support for new API
Update text input support to upstream text-input protocol v2 from
wayland-protocols. Remove support for input-method protocol for now.

Map text-input protocol on compositor side to the Qt input method API,
this allows to use any qt platform input method on compositor side
(especially qtvirtualkeyboard). Add support for qtvirtualkeyboard to
pure-qml example.

Implement all missing functions of the text-input protocol.

Change-Id: I597451ff65454a63dff86026b6a8d1ffbe07ce02
Done-with: Zeno Endemann <zeno.endemann@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-04-18 11:39:14 +00:00
Liang Qi
ef5f1a82e3 Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7 2016-03-29 10:26:12 +00:00
Arnaud Vrac
e418dbc403 Filter key events through the input method context
This allows the input method to capture keys, for example to implement
the Compose key or to navigate in a virtual keyboard.

Change-Id: Ic0ab318e84401ac339881eadd5eb992a2d57f9e3
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-25 07:23:59 +00:00
Liang Qi
c334c5b58d Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/compositor/compositor_api/qwaylandcompositor.h
	src/compositor/compositor_api/qwaylandquickcompositor.h
	src/compositor/compositor_api/qwaylandsurfaceitem.h
	src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h

Change-Id: I094128be314d2c3d4fe350fa7a162e37da34ae10
2016-03-22 19:05:17 +01:00
Pier Luigi Fiorini
93ee329289 Send keyboard repeat information
Complete the API for keyboard rate and delay that was previously
implemented sending the information to clients.

Back then this wasn't possible for lack of Wayland >= 1.6 on
the CI system.

Change-Id: I95bab22bf4eea6549d2f8a762341c6485a24665c
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-22 14:10:59 +00:00
Martin Gräßlin
6474099684 Add support for bitmap cursors
So far QtWayland did not support custom bitmap/pixmap QCursors.
This change adds support for them by creating a QWaylandShmBuffer and
copying the pixmap data into that buffer. The internal API to set
cursors images is changed to not only rely on wl_cursor_image, but also
allow to just set the buffer with a specific size and a hot spot.

The created WaylandShmBuffer is passed around as a shared pointer, so
that it can be automatically cleaned up once the cursor image is no
longer used on any seat.

Task-number: QTBUG-51604
Change-Id: I1f1ee87f03186c3d564468d3e8ea2a3141d7e2fb
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
2016-03-17 06:40:40 +00:00
Paul Olav Tvete
29d74ed32e Merge remote-tracking branch 'qt/5.6' into 5.7
Change-Id: Iada0e076ee33e8d39ecc4f40edfd9764ba610c03
2016-03-08 14:45:49 +01:00
Elvis Lee
f52b53996c Fix crash for destroyed surface on touch event
Change-Id: Ia3dd8627c1b96a88d308dc7fa85d936f809c7856
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-02-25 14:22:41 +00:00
Liang Qi
f9510e1aff Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	.qmake.conf
	src/compositor/compositor_api/qwaylandquicksurface.cpp

Change-Id: Ic5e4217549c6c08740dba5ac1794d0a8e53f3a47
2016-02-19 16:05:24 +01:00
Antti Kokko
08a9a13b4a Updated license headers
From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new LGPL header instead of LGPL21 one
(in those files which will be under LGPL v3)

Change-Id: I76ae5d3e64f096eb3163d6163a38d68c7c1ca756
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-20 10:53:37 +00:00
Paul Olav Tvete
53326bfa3f Fix the control key
Let Ctrl+A cause a key event with text Ctrl+A (0x01), like we do on
the other platforms. Previously we would use 'A', which would confuse
some applications.

Task-number: QTBUG-50398
Change-Id: Ie3def4bd9c96e538b2572b88fae029d347e08814
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-01-11 15:44:23 +00:00
Giulio Camuffo
bd4a0928ab Use xkbcommon for internal key events too
To manage the keyboard state and send key events to clients we use
the xkbcommon library (unless disabled). That means that we currently
have a separation between key events outgoing to clients and key events
being used internally in the compositor, resulting in different keysyms
being produced in the two cases for the same hardware key.
Filter the key events coming from the underlying platform and modify
them according to the xkb state instead.

Change-Id: I4c6678be68e5b214b2b9cd0222dc9f425c580085
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-07-23 07:29:02 +00:00
Giulio Camuffo
7d54e5527e Fix wheel events when the decorations are enabled
We must offset the wheel events' position, as we do with the other
types of mouse events.

Change-Id: If85e93ffe95304c7dee4c2a3ff195a73243a8182
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-09 08:23:33 +00:00
Martin Gräßlin
022f452ed9 Add safety check in QWaylandInputDevice::Keyboard::modifiers()
::modifiers() might be invoked before being initialised. E.g. when
a pointer button event is emitted before the keymap is sent.

Change-Id: Ib95f9866d808b2a32ddfaa0862cdb3226fab1938
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-15 08:01:01 +00:00
Arnaud Vrac
9b5376cce1 Map more XKB key codes
Change-Id: I0a2b56043235666bc57b46ae4ac78ca5e24e736d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-07 08:43:28 +00:00
Giulio Camuffo
d0740edb9c Fix crash on keyboard remove
If the compositor sent a wl_keyboard.leave and a new wl_seat.capabilities
without the keyboard bit we would end up deleting the Keyboard object
with a roundtrip in flight, ending up using freed memory later.
Destroy the callback when destroying the keyboard, and notify the
window system the active window is active no more.

Change-Id: Ie415ca62b46e0b8ef0fe4d09c8e7a8130928df90
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-05-04 09:22:39 +00:00
Giulio Camuffo
7efc7c3d4d Use defines instead of hardcoded strings
Change-Id: Id382a1e39f2c052fbfeb96caa9b01becb31e81c9
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-04-24 10:02:15 +00:00
Giulio Camuffo
1cee02688f Do not manually update the xkb state
xkb_state_update_key() is not supposed to be used in apps with a master
process, such as wayland clients, which use xkb_state_update_mask()
with the state serialized by the master.

Change-Id: Ie51a39ca0c567c54072b221d1ab8cf7b8ea15c55
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-04-24 09:58:32 +00:00
Giulio Camuffo
81395b87a3 Add client side support for media keys
Unfortunately we don't have a keysym in libxkbcommon for PlayPause,
we only have Play. We're going to pretend XKB_KEY_XF86AudioPlay is
really PlayPause since that is what is most common.

Change-Id: I1a75d8b5b0ea360e0f62eb7a93004ba3fababfa8
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2015-04-16 15:41:00 +00:00
Jani Heikkinen
b366677a7a Update copyright headers
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Change-Id: I5a74d32515c3f1fe7aa1916f4241c92832510f8c
Reviewed-by: Antti Kokko <antti.kokko@theqtcompany.com>
2015-02-17 13:28:27 +00:00
Frederik Gladhorn
d1de454093 Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
	src/client/qwaylanddataoffer.cpp
	src/client/qwaylanddisplay.cpp
	src/client/qwaylandinputdevice.cpp
	src/client/qwaylandwindow.cpp
	src/compositor/compositor_api/qwaylandsurfaceitem.cpp

Change-Id: I2eae0fd43a71fbfd7c907ca715707a26f3c134c5
2015-02-16 11:05:38 +01:00
Laszlo Agocs
520cb3e95e Sanitize popup behavior.
Popups are pretty important for widget apps. Menus, combobox dropdows
and such are all popups. Currently they are completely borked when
activated via keyboard or touch. This is because of the bizarre set_popup
request in the protocol, and Weston's current implementation, that ignore
the fact that a popup can be opened as a result of a keyboard event too
or may not originate from an input event at all.

Pass the last input device and serial we have seen, regardless of the type,
by tracking it globally in the QWaylandDisplay.

With this patch menus and such will not freeze the application anymore
when activated with keyboard or touch without sending a mouse event
to the window first. The behavior is still broken in some ways, especially
with keyboard due to immediately getting a popup_done, but at least
applications remain usable.

Task-number: QTBUG-41142
Task-number: QTBUG-41147
Change-Id: I18de501004ae8a62ff8667e72225d08c2d3ba491
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-02-13 11:18:50 +00:00
Giulio Camuffo
b52533db83 Fix copying text to non-qt clients
Like we do for pasting, set the mime type of text to "text/plain;charset=utf-8"
too besides "text/plain". This allows copying text to clients such as weston
example clients or Xwayland.

Change-Id: I8a24f32d93e438f16db662e7c09b09ddd7578768
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-02-07 17:48:07 +00:00
Giulio Camuffo
ccc23106b9 Do not send invisible key characters
xkb_keysym_to_utf32() will return 0 if the keysym does not have a
unicode representation.

Task-number: QTBUG-44012
Change-Id: I85a13b58c7f0b9765c7d67db6568a90629bcfbfa
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-02-05 07:42:11 +00:00
Giulio Camuffo
ce491e5dd0 Update the protocol to 1.4 and raise the required libwayland version
Wayland 1.4 introduces wl_subsurface which is quite an important
addition.

Change-Id: I48375f60adce556c9989872319f4d073e4a7b13b
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-02-03 13:32:33 +00:00