Commit Graph

45 Commits (master)

Author SHA1 Message Date
Vlad Zahorodnii 4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii 1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Aleix Pol e28e4cb189 Move inputConfig away from KWin::Application
We were calling it from tests that were not running a KWin::Application
and not even including the symbols from main.cpp and main.h. The only
reason they linked was that it was static_casting up the QCoreApplication.
2020-07-13 12:54:34 +02:00
Vlad Zahorodnii cb7a9456c0 [wayland] Rework Xcursor theme loading code
Currently in order to load an Xcursor theme, kwin uses libwayland api,
which looks really awkward because of the way how the compositor talks
to itself via the internal connection.

The main motivation behind this change is to limit the usage of kwayland
client api in kwin.
2020-06-18 07:14:58 +00:00
Benjamin Port 864f355870 Set cursor size default to 24 to align with KCM
Reviewers: #plasma, meven, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T12040

Differential Revision: https://phabricator.kde.org/D28654
2020-04-17 14:43:51 +02:00
Aleix Pol 6abd23ed02 Make it possible to have a separate cursor for the tablet
Summary:
As is KWin only had 1 Cursor which was a singleton. This made it impossible for
us to properly implement the tablet (as in drawing tablets) support and show where
we're drawing.
This patch makes it possible to have different Cursors in KWin, it makes all the
current code still follow the mouse but the tablet can still render a cursor.

Test Plan: Tests pass, been using it and works as well as before but with beautiful tablet cursors.

Reviewers: #kwin, cblack, davidedmundson

Reviewed By: #kwin, cblack, davidedmundson

Subscribers: davidedmundson, cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28155
2020-04-03 01:16:45 +02:00
Vlad Zahorodnii 62a7db7028 Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.

This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, davidedmundson, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 17:48:21 +03:00
Vlad Zagorodniy fbe219172a Drop XFixes include in cursor.cpp
Summary:
We no longer need to include xcb/xfixes.h in cursor.cpp because
X11Cursor moved to its own file.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18133
2019-01-09 22:29:45 +02:00
David Edmundson 5b4eb80c8f Set specific edge cursor shape when resizing
Summary:
Instead of seeing the cursor <--> on the left edge you now see an icon
that looks like |<-  .

This brings kwin decorations in line with GTK CSD icons.

In theory this is also useful to tell which window will resize in the
case of side-by-side windows (regardless of whether borders are on or
not). In practice with the adwaita icon theme I tested with it's not
very intuitive to realise which is which till you learn the icon.

Change is more involved than it should be as Qt::CursorShape doesn't
have these entries, and I don't want to shadow that enum internally or
have
to change kwin effect code.

Specifics depend on cursor icon theme if they are not present it will
fallback to the <--> icon. (Breeze does not have them currently)

Test Plan:
Resized some windows (on X and on Wayland)
Correct icon appeared on Adwaita
Existing icon appeared on Breeze

Reviewers: #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13396
2018-06-11 10:05:07 +01:00
Aleix Pol ebfc713936 Improve cursor size setup
Centralise resolution-dependent computation into the leaf cursor class.
Listen to scale changes and update the cursor when it happens

Reviewed by David Edmundson
2018-04-26 16:42:32 +02:00
Aleix Pol 6e84645e35 Reparse the input configuration when we are notified that it changed
Otherwise we'd process again the kconfig information in memory and
discard it because it's the same as last time.
2018-04-24 16:40:30 +02:00
Martin Flöser 6f99b57736 Move XFixes cursor change tracking into the x11 standalone platform
Summary:
A dedicated X11EventFilter is added and created from the X11Cursor in
case we have XFixes. This means some more X11 specific code is now only
on X11.

Test Plan: Only compile tested.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7843
2017-09-30 12:58:17 +02:00
Martin Gräßlin 857d8a9c37 Add a KSharedConfigPtr for kcminputrc to KWin::Application
Summary:
There are a few places where KWin needs to read values from kcminputrc.
As I need to add yet another one it makes more sense to properly
structure it like in other cases and have only one kcminputrc hold in
the application. This also allows to better mock the config values in
the integration tests.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5540
2017-04-24 21:01:03 +02:00
Martin Gräßlin 5b9da55e75 Implement cursor shape tracking on Wayland
Summary:
So far the tracking for cursor shape was done incorrectly on Wayland by
only listening to X11 cursor changes. That's from a time when
KWin/Wayland was still run on top of an X server.

Nowadays the Platform tracks cursor shape changes and emits changes to
it. Xwayland cursor changes go through the normal Wayland way so it's
just one way to get it on Wayland.

This change adds the required connect and changes the signal signature
in Cursor by dropping the serial argument. No user of the signal uses
the argument and on Wayland we don't have a serial for the cursor. So it
can be dropped.

Test Plan: Zoom effect updates cursor shape correctly on Wayland

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3095
2016-10-20 07:52:26 +02:00
Martin Gräßlin 2a8ab547e1 Move X11Cursor into the x11standalone platform plugin
At the same time the xinput2 integration is split out of X11Cursor
and made a standalone part of the platform plugin. XInput integration
is nowadays not only used by the cursor position polling, but also
for modifier only shortcuts.

By splitting it out the modifier shortcuts start to work also when
one doesn't have anything requesting a mouse position polling.

This also simplifies the conditional builds: xinput integration is
only included if we have support for it at compile time without having
to have many ifdefs in the cursor implementation. For the inclusion of
cursor in the kcmkwin this also removes all the ifdefs.

The key events are only requested if we have xinput 2.1. Otherwise we
would not get all raw events if the input device gets grabbed.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2473
2016-08-19 10:57:09 +02:00
Martin Gräßlin 03700500be Create Cursor instance through Platform
By default the InputRedirectionCursor is created and only the X11
standalone platform creates the X11 specific cursor.

This is a preparation step for moving the X11 specific cursor
implementation into the x11standalone platform plugin.
2016-08-19 10:57:09 +02:00
Martin Gräßlin 2c333417fa Support modifier only shortcuts on X11
Summary:
With this change KWin/X11 reuses Wayland's modifier only shortcut
architecture. The XInput2 event filter also listens for
 * XI_RawKeyPress
 * XI_RawKeyRelease

Those events are also reported if another X11 client grabs keyboard
input. Thus KWin gets all key events, just like on Wayland.

All key events are then sent through the Xkb class which performs the
mapping from key codes to key syms and is able to detect whether the
modifier got pressed/released without another key being pressed.

This change will require a few follow up changes, which are required
also for Wayland:
 * ignore if another input device got interacted (e.g. mouse press,
   touch screen, scroll, etc)
 * use the layout from XServer instead of using our own (needed on
   Wayland in nested setup)

The biggest disadvantage of the change is that it triggers a wake
up of KWin on every key event. But as KWin already listens to all
pointer events that's not a big difference and normally a key event
will wake up the compositor any way.

Reviewers: #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2425
2016-08-16 12:56:06 +02:00
Martin Gräßlin 71c996fe33 Select also raw button press/release in XInput2 based polling
Summary:
The mouse polling is also used to detect mouse button press/release
events. This is used e.g. by the MouseClickEffect. The XInput2 filter
only selected for Raw Motion events which means mouse button events
are missed in case it's not combined with a motion.

This change makes the input filter also select for raw button press
and release events. To support this the X11EventFilter needed to
be adjusted to support multiple generic event types to filter for.

BUG: 366612
FIXED-IN: 5.7.4

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2406
2016-08-15 16:06:30 +02:00
Martin Gräßlin 72a25aa9ff Add Cursor::cursorAlternativeNames
Make the internal hash of cursor names available.
2016-02-22 13:33:21 +01:00
Thomas Lübking f918bc3367 fix build of rules kcm
REVIEW: 126733
2016-01-14 23:40:44 +01:00
Martin Gräßlin 5a31618461 Use XInput for "polling" the mouse positing
Replaces the timer based polling approach. If XInput is available we
listen for the RawMotion event on the root window and use this to
trigger a mouse pointer position.

BUG: 357692
FIXED-IN: 5.6.0
REVIEW: 126733
2016-01-14 17:25:04 +01:00
Martin Gräßlin 7dcd69fdcc Fix mouseChanged signal arguments in InputRedirectionCursor
The button state was not represented correctly which was very visible
when using the MouseClickEffect. Now MouseClickEffect on Wayland works
as expected.
2015-10-28 09:18:26 +01:00
Martin Gräßlin 74c111ef88 [wayland] Add support for pointer warping in InputRedirectionCursor
With libinput we do can support warping pointers, let's do it.
2015-06-06 17:43:13 +02:00
Martin Gräßlin 8a9bbf7ca3 XCB::CURSOR becomes a required dependency
It was only optional because build.kde.org did not provide it when the
dependency got introduced.
2015-06-04 17:50:29 +02:00
Martin Gräßlin 3aa4c8d635 Add cursor resolving alternatives
The alternative names are taken from the xcursortheme kcm in
plasma-desktop. An example theme where they are needed is "dmz".
2015-03-20 10:39:11 +01:00
Martin Gräßlin 820af0ce4a Guard X11 usage in InputRedirectionCursor
In kwin_wayland the InputRedirectionCursor is created before the X11
connection is established. Because of that possible usage needs to
be guarded. This is only in cursorTracking so far. The parent class
exposes whether the cursor is tracked and the doStartCursorTracking
gets invoked again when the x11Connection becomes available.
2015-03-17 10:20:19 +01:00
Martin Gräßlin d95ab94f0a Migrate away from QX11Info::appTime
The porting to Qt5 broke the timestamp handling in many areas. A deeper
look into Qt's xcb plugin shows that the appTime handling is not
sufficient for KWin's need. E.g. the time is only updated in response to
a property notify event if it's for a Qt created window, which is hardly
ever the case in KWin. Another example is that key press/release events
never updated the appTime.

As the functionality in Qt is rather trivial we can do the timestamp
handling ourselves. We filter all events anyway and it is slightly faster
as we don't have to go through the QPA interface any more.

REVIEW: 122636
2015-02-23 11:02:59 +01:00
Martin Gräßlin 0faf2fbcf8 Use xcb_cursor library instead of Xlib based one in Cursor
Straight forward port from XLib based XCursor library to the
xcb variant which is considerably new. The xcb variant only allows
to create xcb_cursor_t for the default theme and size. Which suits
the needs in Cursor quite well, but means it's not a replacement for
the usage in zoom effect.

REVIEW: 122290
2015-02-06 13:41:18 +01:00
Martin Gräßlin e5d0e1a339 Support getting XCursor by name
So far all cursors were only resolved through Qt::CursorShape, but
Qt::CursorShape is not a complete mapping of all cursors used inside
KWin. E.g. killwindow uses the "pirate" cursor.

This change keeps the cursors by name instead of Qt::CursorShape and
thus allows us to use Cursor for resolving XCursors everywhere.
2015-01-29 09:02:23 +01:00
Martin Gräßlin 6e67badfab Handle case that XCURSOR_SIZE environment variable is not set
In a default startup startkde does not set XCURSOR_SIZE environment
variable. Only XCURSOR_THEME is set. The size should be DPI dependent.
With this patch Cursor is able to handle this situation and does not
fall back to loading the config from file. Logic is taken from
KHintsSettings in frameworkintegration which in turn is from
KApplication.

REVIEW: 122139
2015-01-21 09:24:01 +01:00
Martin Gräßlin 7dc2baf74d Update cursor theme when it changes at runtime
Connecting to the DBus signal emitted on KGlobalAccels by the
cursor kcm and forcing a reload of all cursors. For runtime
config change we need to take the config value and need to ignore
the now outdated environment variables.

REVIEW: 121928
BUG: 325763
FIXED-IN: 5.2.0
2015-01-14 08:45:22 +01:00
Martin Gräßlin ab4b1ba25a First try getting cursor theme from environment variable
If XCURSOR_THEME and XCURSOR_SIZE are set they are preferred over
reading the values from kcminputrc.

REVIEW: 121923
BUG: 334954
FIXED-IN: 5.2.0
2015-01-14 08:33:33 +01:00
Martin Gräßlin 3204342809 Port XQueryPointer usage to XCB
Introduces new XCB::Pointer wrapper and is used in
Client::leaveNotifyEvent and in Cursor and KillWindow to simplify
the usage.

CCBUG: 333836
2014-05-05 08:09:09 +02:00
Martin Gräßlin c64ad6b640 [kwin] KWinrules needs the X11Cursor
Fixes crash when trying to detect the window properties.
2014-03-29 10:49:14 +01:00
Martin Gräßlin b274fb9297 InputRedirection emits a signal when the modifiers change
Used by Cursor to properly emit the mouseChanged signal which for
historic reasons includes the keyboard modifiers.

Again some fiddling around with the autotests and kcmrules needed to
make it compile. This needs improvement!
2014-03-19 14:14:56 +01:00
Martin Gräßlin 7ca25ac703 [kwin] Suppress unused variable warning when building KCMRULES
This really needs to be improved. It cannot be that the kcm rules
includes more and more parts of KWin core!
2014-03-19 08:04:20 +01:00
Martin Gräßlin 18a37d7ee8 [kwin] Fix includes of kde4support headers
* drop unused headers
* use QExplicitlySharedDataPointer instead of KSharedPointer
* drop KDE/ from includes
2014-03-18 14:34:36 +01:00
Martin Gräßlin e18bb1006a Make mapping between Qt::CursorShape and theme name public
It's of general interest as Wayland cursor uses the same theme name.
2014-03-18 09:00:49 +01:00
Martin Gräßlin d3c4a46c59 Track used cursor theme and size in Cursor
Reads the settings from kcminputrc. Unfortunately there is no update when
the settings change. This needs fixing in the cursors KCM first.
2014-03-18 09:00:49 +01:00
Martin Gräßlin 7523c1e7d7 Integrate KWin::Cursor with InputRedirection
New inheriting class which uses the InputRedirection to track the cursor
position. It doesn't support warping of cursor.

This introduces a slight dependency loop in the startup. Cursor needs to
be created after the WaylandBackend to ensure that the operation mode is
set correctly. But the WaylandBackend itself is accessing Cursor. It
should be safe as inside the WaylandBackend it's only accessed after
callbacks.
2014-03-18 09:00:49 +01:00
Michael Chang f62162eb41 Correctly detect mouseChanged between polls.
REVIEW: 112392
BUG: 323979
FIXED-IN: 4.11.2
2013-09-04 14:39:44 +02:00
Thomas Lübking 5c207e9a15 poll mouse at 20Hz
required until there's a dynamic poll rate, because 10Hz is too
low for magnifiers (lag), mousemark (paints too edgy), mouseclick
(often fails because it's easy to cycle the button state within 100ms)
- and the bouncing icon lags behind the mouse as well ;-)

REVIEW: 111909
2013-08-06 23:26:51 +02:00
Martin Gräßlin 8b2a5f9936 Support for cursor change tracking in KWin::Cursor
KWin::Cursor can track changes to the cursor image. It supports a
start/stop tracking to not handle these events if nobody is interested in
them. When enabled and the cursor image changes a signal is emitted with
the serial number of the new cursor image.

To track cursor image changes xcb_xfixes_select_cursor_input is used (see
XFixes Version 5.0 protocol, section 7).

This could be useful for the zoom effect when it replaces the cursor.

REVIEW: 110519
2013-05-28 08:02:59 +02:00
Martin Gräßlin 0fb27fd12e Defines to create the boilerplate code for KWin's singleton classes
The define KWIN_SINGLETON adds to a class definition:

public:
    static Foo *create(QObject *parent = 0);
    static Foo *self() { return s_self; }
protected:
    explicit Foo(QObject *parent = 0);
private:
    static Foo *s_self;

There is an additional define KWIN_SINGLETON_VARIABLE to set a different
name than s_self.

The define KWIN_SINGLETON_FACTORY can be used to generate the create
method. It expands to:

Foo *Foo::s_self = 0;
Foo *Foo::create(QObject *parent)
{
    Q_ASSERT(!s_self);
    s_self = new Foo(parent);
    return s_self;
}

In addition there are defines to again set a different variable name and
to create an object of another inheriting class.

All the classes currently using this pattern are adjusted to use these
new defines. In a few places the name was adjusted. E.g. in Compositor
the factory method was called createCompositor instead of create.

REVIEW: 109865
2013-04-15 09:57:25 +02:00
Martin Gräßlin f12cf0efba Replacement class for QCursor
With Qt5 QCursor does no longer provide ::handle() which was used to
set a cursor on a native XWindow for which we do not have a QWidget.

Also KWin has had for quite some time an optimized version to get the
cursor position without doing XQueryPointer each time ::pos() is called.

These two features are merged into a new class Cursor providing more or
less the same API as QCursor.

In addition the new class provides a facility to perform mouse polling
replacing the implementations in Compositor and ScreenEdges.

For more information about the new class see the documentation for the
new class in cursor.h.
2013-02-25 13:35:14 +01:00