Commit Graph

141 Commits (7e8facc3fde853a93683554e5fc9bfd4985e4760)

Author SHA1 Message Date
Roman Gilg ddb44b4383 Small code style improvement 2018-06-14 15:48:52 +02:00
Martin Flöser 7ef8409157 Move X11-only specific part of EffectsHandlerImpl to x11 platform plugin
Summary:
The Platform API is extended by a call to create the EffectsHandler. In
X11 standalone Platform a new EffectsHandlerImplX11 is added which
contains the X11 only parts of the EffectsHandler, such as grabbing the
X keyboard and the X11 mouse interception window.

The EffectsHandlerImpl gains some virtual methods for the parts which
are now done in the X11 specific implementation. In return we get rid of
lots of if-else structures checking for the operation mode.

Test Plan: Only compile tested.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7955
2017-10-16 16:54:17 +02:00
Martin Flöser a264c2b5cf Change default argument of grabXKeyboard to XCB_WINDOW_NONE
Summary:
The implementation of grabXKeyboard checks whether the passed in arg
is XCB_WINDOW_NONE and sets the arg to rootWindow. Thus we don't need
to have rootWindow as the default argument, but can have none as the
default arg.

Test Plan: Compiles, test which uses the default arg still passes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7857
2017-09-25 20:37:56 +02:00
Martin Flöser e6ca321317 Drop ENABLE_TRANSIENCY_CHECK related code as it doesn't compile
Summary:
The code ifdefed by ENABLE_TRANSIENCY_CHECK does no longer compile and
has not compiled since the switch to Qt 5 and KF5 as it still uses
kDebug and (worse) kDBacktrace. There are several other changes which
broke the code and I failed trying to get it to compile again. It's a
classic example of bitrot happening to code which is never getting
compiled.

As this has not been in a state which could compile for at least several
years, I think it's best to completely remove it.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7958
2017-09-24 08:17:30 +02:00
Martin Flöser 9ce651fc30 Drop unused functions from utils
Summary: Not used anywhere in KWin -> can go.

Test Plan: Still compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7956
2017-09-23 21:15:00 +02:00
Martin Flöser 349618c214 Move bitCount from utils to GlxBackend
Only used in GlxBackend.

Differential Revision: https://phabricator.kde.org/D6784
2017-07-29 17:52:44 +02:00
Martin Flöser 64da6c8d1e Replace Workspace::slotWindowQuickTileFoo by a quickTileWindow with argument
Summary:
Thanks to std::bind we don't need that many different slots to setup the
global shortcut connections. Instead we can have one shared
implementation which takes the argument and passes it to the window.

To support std::bind arguments in kwinbindings the initShortcut method
and dependencies are adjusted as well as a new macro is added.

As I don't want to include abstract_client.h in workspace.h a new enum
is created for the quick tiling flags used in Workspace. This caused a
larger refactoring as the change to an enum class also caused quite some
changes.

Test Plan: Affected test cases still pass

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6783
2017-07-29 17:40:03 +02:00
Martin Gräßlin cacfdf3676 Merge branch 'Plasma/5.8' into Plasma/5.9 2017-05-05 19:14:10 +02:00
Martin Gräßlin 0bec9ad733 Improve the x11 timestamp handling
Summary:
So far KWin only updated the x11 timestamp if the new timestamp is larger
than the existing one. While this is a useful thing it creates problems
when the 32 bit msec based time stamp wraps around which happens after
running an X server for 49 days. After the timestamp wrapped around KWin
would not update the timestamp any more and thus some calls might fail.
Most prominent victims are keyboard and pointer grab which fails as the
timestamp is either larger than the server timestamp or smaller than the
last grab timestamp.

Another problem related to timestamp handling is KWin getting broken by
wrong timestamps sent by applications. A prominent example is clusterssh
which used to send a timestamp as unix time which is larger than the
x timestamp and thus our timestamp gets too large.

This change addresses these problems by allowing to reset the timestamp.
This is only used from updateXTime (which is normally invoked before we
do things like grabKeyboard). Thus we make QX11Info::getTimestamp the
ultimate trusted source for timestamps.

BUG: 377901
BUG: 348569
FIXED-IN: 5.8.7

Test Plan: As I cannot wait 50 days: unit tests for the two conditions added.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5704
2017-05-03 21:36:34 +02:00
Martin Gräßlin 7b464cf284 Support interactive window selection through the Platform
Summary:
A new virtual method is added to Platform:
startInteractiveWindowSelection

The interactive window selection enters a mode where the user can select
a window through the pointer or keyboard device. The cursor is turned
into a crosshair cursor, unless another cursor name is provided (e.g.
pirate for kill window).

Once a window is selected the provided callback method is invoked with
the selected Toplevel as argument. In case the user cancelled the
selection a nullptr argument is passed in.

Currently it's only implemented by the X11 standalone platform using the
logic from KillWindow. Just instead of killing the window the callback
is invoked.

KillWindow loses the X11 implementation and interacts with the new
functionality in Platform by providing a lambda function for the
killing.

Test Plan: Killing of X11 windows is still possible

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3363
2016-11-17 08:08:56 +01: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 14b9046ad2 Unblock signals in child processes
We need to unblock the signals blocked with pthread_sigmask.
This caused kdeinit to block, because it relies on SIGUSR1.

BUG: 356580
FIXED-IN: 5.5.1
REVIEW: 126361
2015-12-15 13:03:30 +01:00
Martin Gräßlin 89a4df651d [wayland] Sync resizes
Similar to X11 world: we send a sync request on each size change and
block till we get the next damage with the proper size.

Testing seems to show a very smooth resize experience. We automatically
sync to the resize speed of the client.

Maybe we need a timeout in case the client isn't able to resize to the
requested size.
2015-10-28 11:16:48 +01:00
David Edmundson 9791978d53 enable wayland clients to go fullscreen
REVIEW: 123853
2015-05-28 10:58:40 +01:00
Kai Uwe Broulik 2153174dc0 Add OnScreenDisplayLayer which is placed even ontop of the active fullscreen window
It is to be used for volume change feedback and similar confirmation popups

REVIEW: 121300
2015-01-02 12:11:54 +01:00
Daniel Pastushchak 0d997b1093 Introduce categorized logging for kwin core
Done by Daniel Pastushchak for KDE during GCI-2014.
2014-12-05 14:27:15 +01:00
Martin Gräßlin 3d9a035312 Move MaximizeMode from KDecorationDefines to utils.h
Unfortunately it cannot be a enum defined in Client as client.h
depends on rules.h and with it in Client rules.h would depend on
client.h.
2014-12-02 13:49:08 +01:00
Fredrik Höglund cf62fe51dc Add a bitCount() util function
This function returns the number of bits set in an unsigned integer.
2014-09-01 17:45:58 +02:00
Martin Gräßlin b36b242f12 Port Unmanaged::track to XCB
Uses Xcb::WindowAttributes and Xcb::WindowGeometry instead of XLib
variant. In addition it uses the XServerGrabber to ensure that the
xserver grab is removed in all code paths.

A new macro is added to utils.h to make the grabbing of XServer in
current context more obvious.
2014-05-05 08:09:10 +02:00
Martin Gräßlin b45eeae352 [Xcb::Wrapper] Introduce a Property and StringProperty Wrapper subclass
The Xcb::Property can wrap the xcb_get_property call and provides
convenient access methods to read the value of the reply with checks
applied. For this it provides a templated ::value method for reading a
single value or reading an array. There's also a ::toBool and
::toByteArray which performs the conversion directly with default values
for the type and format checks.

Xcb::TransientFor is changed to be derived from Property instead of
Wrapper directly, so that the reading of the property value can be
shared.

Xcb::StringProperty is a convenient wrapper derived from Property to
handle the reading of a string property providing a cast to QByteArray
operator. This replaces the ::getStringProperty from utils. Though the
separator functionality from ::getStringProperty is not provided as that
is only used in one function and handled there.

All the custom usages of xcb_get_property or getStringProperty are
replaced to use this new wrapper. That simplifies the code and ensures
that all properties are read in the same way.

REVIEW: 117574
2014-04-17 07:41:33 +02:00
Martin Gräßlin a9c69519cd [kwin] Use alias template for ScopedCPointer
Supported in gcc since 4.7 and in clang since 3.0.

REVIEW: 116917
2014-03-26 10:50:30 +01:00
Martin Gräßlin 9075b5e2d6 [kwin] Remove cursorPos() from utils.h
Only delegated to Cursor::pos() anyway, so let's just use that directly.
Fixes the annoyances of having to mock it in the unit tests which include
utils.cpp.

REVIEW: 116900
2014-03-25 15:25:40 +01:00
Martin Gräßlin bc0a9cb53a [kwin] Use std::find_if and lambda functions for Workspace::findClient
Instead of passing the macro based Predicate to findClient it now
expects a function which can be passed to std::find_if.

Existing code like:
xcb_window_t window; // our test window
Client *c = findClient(WindowMatchPredicated(window));

becomes:
Client *c = findClient([window](const Client *c) {
    return c->window() == window;
});

The advantage is that it is way more flexible and has the logic what
to check for directly with the code and not hidden in the macro
definition.

In addition there is a simplified overload for the very common case of
matching a window id against one of Client's windows. This overloaded
method takes a Predicate and the window id.

Above example becomes:
Client *c = findClient(Predicate::WindowMatch, w);

Existing code is migrated to use the simplified method taking
MatchPredicate and window id. The very few cases where a more complex
condition is tested the lambda function is used. As these are very
local tests only used in one function it's not worthwhile to add further
overloads to the findClient method in Workspace.

With this change all the Predicate macro definitions are removed from
utils.h as they are now completely unused.

REVIEW: 116916
2014-03-25 15:17:11 +01:00
Martin Gräßlin 12a4923959 [kwin] Use std::find_if and lambda functions for Workspace::findUnmanaged
Instead of passing the macro based Predicate to findUnmanaged it now
expects a function which can be passed to std::find_if.

Existing code like:
xcb_window_t window; // our test window
Unmanaged *u = findUnmanaged(WindowMatchPredicated(window));

becomes:
Unmanaged *u = findUnmanaged([window](const Unmanaged *u) {
    return u->window() == window;
});

In addition an overload is added which takes the window id to cover
the common case to search for an Unmanaged by its ID. The above example
becomes:
Unmanaged *u = findUnmanaged(window);

The advantage is that it is way more flexible and has the logic what
to check for directly with the code and not hidden in the macro
definition.
2014-03-25 15:17:10 +01:00
Martin Gräßlin 970e8765f0 [kwin] Remove support for _NET_WM_TAKE_ACTIVITY protocol
As can be seen in [1] the patches to KWin were in CVS HEAD before the
protocol got standardized and it never got any adoption. It's neither in
the NETWM spec, nor implemented in Qt4 nor in Qt5. KWin did not even add
the protocol to the NET::Supported property.

Thus it doesn't make much sense to keep a protocol which nobody speaks.

Still the code around the protocol is kept and also the names are kept.
Only difference is that Client::takeActivity got removed and the code
moved to the only calling place in Workspace. Motivated by that change
the enum defined in utils.h is moved into Workspace, it's turned into
a proper QFlags class and used as a type in the method argument instead
of a generic long.

[1] https://mail.gnome.org/archives/wm-spec-list/2004-April/msg00013.html

REVIEW: 116922
2014-03-25 15:03:21 +01:00
Martin Gräßlin 46cb75c33f [kwin] Drop timestampDiff and timestampCompare from utils.h
They just delegate to same method from NET:: and those were used already
quite a lot in KWin already as classes inherit from NET and thus get it
directly.

REVIEW: 116918
2014-03-21 08:08:49 +01:00
Martin Gräßlin d6b346df92 [kwin] Remove TemporaryAssign from utils.h
Only used in geometry.cpp for MaximizationState and that's no
longer needed.

REVIEW: 116902
2014-03-20 07:05:41 +01:00
Martin Gräßlin 1bc624f9f7 [kwin] Move Client specific code from utils.h to client.(h|cpp)
* Motif to client.cpp
* ClientWinMask to client.cpp
* ForceGeometry_t to Client

REVIEW: 116901
2014-03-19 18:54:00 +01:00
Martin Gräßlin ca6f3e329d [kwin] Fix includes of NETWM
Used kde4support variant.
2014-03-18 14:32:53 +01:00
Martin Gräßlin 3346e04769 [kwin] Remove config-X11.h includes
None of the defines is used.
2014-03-18 10:00:49 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin fdee4ea8c8 Adjust kde-workspace to introduction of flags in NET classes 2014-02-05 17:40:19 +01:00
Martin Gräßlin 1576c55cd2 [kwin] Add better support for Notification windows
KWin starts to support the Notification window type and has an own
layer for all notification windows. They are kept above the above
layer but do not go over active fullscreen windows.

REVIEW: 115298
2014-01-28 07:40:34 +01:00
Martin Gräßlin 40588e05ea Clean up the includes in kwin/options.(h/cpp)
Used to include quite a bit no longer needed. In order to get rid of
the utils.h inclusion one enum is moved to options (where it actually
belongs to).
2013-09-09 06:03:35 +02:00
Martin Gräßlin 37334f400a Drop no longer needed XLib includes from KWin 2013-08-20 10:29:20 +02:00
Martin Gräßlin 64e464afe5 Use xcb_window_t in Motif::readFlags
Actual method is not ported to XCB yet.

REVIEW: 110269
2013-05-13 09:33:29 +02:00
Martin Gräßlin dfec59c60e Port getStringProperty to XCB 2013-05-13 08:48:19 +02:00
Martin Gräßlin cefaa756e7 Port ClientWinMask to XCB
Enum values are nicer than defines.
2013-05-13 08:48:19 +02:00
Martin Gräßlin 5018c35313 Port timestampCompare/Diff to xcb
basically: s/Time/xcb_timestamp_t/g
2013-05-13 08:48:19 +02:00
Martin Gräßlin 7e9d7f3959 Port (un)grabXKeyboard to XCB 2013-05-13 08:48:19 +02:00
Martin Gräßlin ce9ce6f94c Remove unused typedefs in utils.h
There is no Const(Toplevel|Unmanaged|Deleted|Group)List used anywhere.
For ConstToplevelList there was a debug helper which was also unused.

REVIEW: 110196
2013-05-02 09:21:02 +02:00
Martin Gräßlin 1276eb044f Move KWinSelectionOwner to main.(h|cpp)
KWinSelectionOwner is only used in KWin::Application which means that
utils is the wrong place for it.

REVIEW: 110245
2013-05-01 19:15:19 +02:00
Martin Gräßlin 89c2fd5598 Remove YesIKnowWhatImDoing from internal API
No need to have Allowed everywhere.

REVIEW: 110197
2013-04-26 12:29:42 +02:00
Martin Gräßlin 4a28d000cf Move ShortcutDialog to useractions
It's only used from useractions.cpp which means that it's not the best
fit in utils. We can see the problems with it given that it was in an
ifdef and it included quite some headers into everything.

REVIEW: 110189
2013-04-26 08:53:13 +02:00
Martin Gräßlin 22ecba3b7d Cleanup of includes in utils.h
* removed unneeded includes
* reordered
* camel case

REVIEW: 110188
2013-04-26 08:50:24 +02:00
Martin Gräßlin 03656a2abe Remove ShapeInput define from utils.h
It's nowhere used inside KWin.

REVIEW: 110190
2013-04-26 08:39:01 +02:00
Martin Gräßlin ee537050dd Remove extern initing from utils.h
It's only used in main.cpp where the static variable is defined.

REVIEW: 110191
2013-04-26 08:38:00 +02:00
Martin Gräßlin 544b772e42 Use non obsoleted ctor for KXMessages 2013-03-07 13:59:16 +01:00
Martin Gräßlin 4f536c7f3d Extend ScopedCPointer from QScopedPointer with QScopedPointerPodDeleter
REVIEW: 108242
2013-01-25 08:56:33 +01:00
Martin Gräßlin 5cd223f051 Improved resolving whether a window is on local machine
Most windows use the hostname in WM_CLIENT_MACHINE, but there are windows
using the FQDN (for example libreoffice). So instead of "foo" it is
"foo.local.net" or similar. The logic so far has been unable to properly
determine whether windows with FQDN are on the local system.

In order to solve this problem the handling is split out into an own
class which stores the information of hostname and whether it is a local
machine. This is to not query multiple times. To determine whether the
Client is on the local system getaddrinfo is used for the own hostname
and the FQDN provided in WM_CLIENT_MACHINE. If one of the queried
names matches, we know that it is on the local machine. The old logic to
compare the hostname is still used and getaddrinfo is only a fallback in
case hostname does not match.

The problem with getaddrinfo is, that it accesses the network and by that
could block. To circumvent this problem the calls are moved into threads
by using QtConcurrent::run.

Obviously this brings disadvantages. When trying to resolve whether a
Client is on the local machine and a FQDN is used, the information is
initially wrong. The new ClientMachine class emits a signal when the
information that the system is local becomes available, but for some
things this is just too late:
* window rules are already gathered
* Session Management has already taken place

In both cases this is an acceptable loss. For window rules it just needs
a proper matching of the machine in case of localhost (remote hosts are
not affected). And the case of session management is very academic as it
is unlikely that a restoring session contains remote windows.

BUG: 308391
FIXED-IN: 4.11
REVIEW: 108235
2013-01-21 16:00:49 +01:00