summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandcursor.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix GCC 9 warning about redundant std::move useThiago Macieira2020-04-221-1/+1
| | | | | | | qwaylandcursor.cpp:254:21: warning: redundant move in return statement [-Wredundant-move] Change-Id: I9709abb1c3734e10a7defffd1607e1b3ed279d32 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Avoid animating single frame cursorsDavid Edmundson2019-11-281-10/+2
| | | | | | | | | | | | | | | | | | | | | | Currently to determine if a cursor is animated or not we check the cursor theme delay. This doesn't work in practice as by default many cursor themes have a delay of 50 set even if they don't animate. This comes from xcursorgen which specifies a delay of 50ms if there isn't anything set in the config. (https://github.com/freedesktop/xcursorgen/blob/master/xcursorgen.c#L92) Given many themes will have a delay we should also check the number of images in a given cursor. In order to do that without a double lookup QWaylandCursor needed to return the native wl_cursor, not wl_cursor_image and move the relevant logic. Change-Id: Ie782ace8054910ae76e61cab33ceca0377194929 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* QWaylandCursor: replace a static QMap with a C arrayMarc Mutz2019-07-231-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The content of the QMultiMap cursorNameMaps is static, so using a dynamic container is overkill. Replace the map by a (sorted) C array of struct {Key, Value}, and use std::equal_range to find matching cursors. This also avoids the creation of a QList on each call (due to the use of QMap:values() instead of QMap::equal_range), as well as the creation of QByteArrays, which the underlying wayland C API doesn't know about, anyway. The entries were already sorted, so the initializer_list stays the same. Add an assert that the list is ordered. Since this is library code, don't use the attractive struct { WaylandCursor, const char *name }, as that causes relocations that delay the loading of the shared object, and make sharing of the data between processes impossible. This wastes some memory, due to all the NUL padding up to the common maximum, and the next alignment step, but can be optimized later when someone writes a C++-only version of Q_STRINGTABLE. Even so, this saves 10.5KiB in text size on optimized AMD64 Linux GCC 9.1 builds. Change-Id: I19fa1742e2fcaf9de74af1e5908e796b0588d507 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Client: Add support for animated cursorsJohan Klokkhammer Helsing2019-05-021-3/+4
| | | | | | | | | | [ChangeLog][QPA plugin] Added support for animated cursors. Previously we would just show the first frame of the animation. Fixes: QTBUG-48181 Change-Id: Ie06bff8950678b5ff7b7e2e50915c85905a1200b Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client: Refactor cursors and fix various bugsJohan Klokkhammer Helsing2019-02-151-49/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is mostly a cleanup to prepare for implementations of xcursor-configuration, but also fixes a couple of issues. Most of the logic has now been moved out of QWaylandDisplay and QWaylandCursor and into QWaylandInputDevice and QWaylandInputDevice::Pointer. QWaylandDisplay now only contains mechanisms for avoiding loading the same theme multiple times. There is now only one setCursor method on QWaylandInputDevice, accepting a QCursor and storing its values so changing scale factor doesn't require calling setCursor again. QWaylandInputDevice::Pointer::updateCursor() is called instead. Cursor buffer scale is now set according to enter/leave events of the cursor surface itself instead of the current window, this fixes incorrect buffer scales for cursors on windows that span multiple outputs. The window buffer scale can still be passed into the seat as a fallback until the first enter event is received. This also fixes a bug where the QWaylandBuffer of a bitmap cursor could be deleted while it was being used as a cursor. [ChangeLog][QPA plugin] Fixed a bug where the DPI of bitmap cursors were not sent to the compositor, leading to the compositor incorrectly scaling the cursor up or down. [ChangeLog][QPA plugin] Fixed a bug where bitmap cursor hotspots were off when the screen scale factor was different from the bitmap cursor device pixel ratio. Task-number: QTBUG-68571 Change-Id: I747a47ffff01b7b5f6a0ede3552ab37884c4fa60 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client: Move cursor theme logic into its own class, QWaylandCursorThemeJohan Klokkhammer Helsing2018-05-281-169/+193
| | | | | | | | | | | | | ...and out of QWaylandCursor. Encapsulates the ugly details of wayland cursor themes, and presents a simple interface. A theme is created with a given size and theme name. wl_cursor_images for a theme can be acquired through: wl_cursor_image *QWaylandCursorTheme::cursorImage(Qt::CursorShape shape); Change-Id: Ia6fc6f2997133ca25c1610ecdf075ecb5c4edbfa Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client: Only load cursor theme onceJohan Klokkhammer Helsing2018-05-281-21/+1
| | | | | | | | Now cursor themes load once per device pixel ratio, and not once per screen. Task-number: QTBUG-67796 Change-Id: I4c253e65a791d69e7d510c4228989390a4343110 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Adapt the cursor size per screenAleix Pol2018-05-151-9/+10
| | | | | | | | | | 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>
* Use nullptr instead of 0 or NULLJohan Klokkhammer Helsing2018-02-201-6/+6
| | | | | | | | Applied automatic fixes using clang-tidy's modernize-use-nullptr, and some manual cleanup to prevent QFlag macros to be affected. Change-Id: I88f94390185bc6e6f23693b68723cd5710815ae6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use QImage::sizeInBytes() instead of deprecated QImage::byteCount()Johan Klokkhammer Helsing2017-10-191-1/+1
| | | | | Change-Id: If3f21fc43d0118c1819d354c8ef43f1b79617c7b Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace Q_NULLPTR with nullptrKevin Funk2017-09-261-1/+1
| | | | | | | Change-Id: I9699a957430b8d3574ce29acb91b7ada9ea6209b Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com> Reviewed-by: Johan Helsing <johan.helsing@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Code cleanup (fixing -no-feature-cursor)Paul Olav Tvete2017-03-081-25/+0
| | | | | | | | Move QWaylandDisplay member functions into the correct .cpp file. Change-Id: Ie3915d2bd0d191900ad2fd306564bb732e40221a Reviewed-by: Johan Helsing <johan.helsing@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-221-1/+28
|\ | | | | | | | | | | | | | | | | | | 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
| * Add support for bitmap cursorsMartin Gräßlin2016-03-171-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Updated license headersAntti Kokko2016-01-201-14/+20
| | | | | | | | | | | | | | | | | | | | 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>
* | Add QWayland::shm object to clientMikko Levonmaa2015-09-251-1/+1
|/ | | | | | | | | | Allows more flexibility for the client to determine additional shm formats supported by the compositor in addition to the standard types. For example YUV formats. Change-Id: Ib4a47c1d5bbeed9314d5ad5f5f8e1551c1dd71e4 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com> Reviewed-by: Mikko Levonmaa <mikko.levonmaa@bitfactor.fi>
* Use by-ref in foreach where T is non-trivialSergio Martins2015-07-041-1/+1
| | | | | Change-Id: Iac40929aebc1e0f507b729b0c01a2ccb18516c37 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
* Update copyright headersJani Heikkinen2015-02-171-22/+14
| | | | | | | | | 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>
* Namespace the platform pluginsGiulio Camuffo2015-01-291-0/+4
| | | | | | | | | | | | There currently is a QWaylandInputDevice class both in the wayland QPA plugin and in the QtCompositor API. This causes the qwindow-compositor example to crash when running nested in a wayland session due to a mismatch between the two classes. By namespacing all the plugin code we make sure that name clashes will not happen anymore. Change-Id: I17497cff697599200bea68bf01dfde474526390f Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
* Fix crash when cursor theme can not be loadedOlivier Blin2014-10-211-1/+7
| | | | | | | | | | Also add a debug message about theme loading failure. This is not necessarily fatal, some embedded applications could still function properly without a cursor. Change-Id: Ib3e2ee43b00630ee77997c7472a95ac5a22c2cc2 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Make classes in client privateJorgen Lind2013-12-271-5/+5
| | | | | Change-Id: Ibf400b32f78a6a0fcf0991914d2d9ad684483979 Reviewed-by: Andy Nichols <andy.nichols@digia.com>
* Move wayland into a client directory not under the plugins src folderJorgen Lind2013-12-271-0/+302
And make wayland common files into a library, exporting all classes. Now there is no need to do bulild hacks to make your own version of the wayland plugin. Change-Id: Ib4872863dfb5ab3f2bc0f4a94ae16fc1e7b63b88 Reviewed-by: Andy Nichols <andy.nichols@digia.com>