Commit graph

7 commits

Author SHA1 Message Date
Martin Gräßlin
9f4f713e52 Remove mocked getStringProperty for test_client_machine
Utils has an xcb variant nowadays, so let's use that and get it under
unit test at the same time.
2013-05-13 09:33:50 +02:00
Martin Gräßlin
dfec59c60e Port getStringProperty to XCB 2013-05-13 08:48:19 +02:00
Martin Gräßlin
f238cbc3f5 Light-weight wrapper class for an xcb_window_t
The idea behind this class is to relieve the developer from having to
call xcb_destroy_window once it is no longer needed. That is having a
RAII approach to windows.

In addition the class provides some simple method wrappers for the most
common use cases inside KWin:
* map
* unmap
* setGeometry - basically a moveResizeWindow
* ...
2013-02-04 08:47:46 +01:00
Raphael Kubo da Costa
d703adbdc1 Add a few more headers required by getaddrinfo(3).
Follow-up to cbb7f57; the code built on Linux despite the lack of required
includes most likely because netdb.h ends up indirectly including
sys/types.h and sys/socket.h.
2013-02-03 01:28:42 +02:00
Martin Gräßlin
2d4b67d361 Do not use a shared pointer for the Xcb::Wrapper
It's not really needed, the required functionality can be achieved in a
more implicit way. The reply pointer is managed by the Wrapper class as
long as the method take() is not invoked. This method follows the
semantics of QScopedPointer::take(). That is the pointer is set to null
and the responsibility to free the pointer is passed to the callee.

By this change we do not have the overhead of creating a QSharedPointer.

In addition the Wrapper provides a copy ctor and assignment operator also
using the semantics of take().
2013-01-25 08:51:38 +01:00
Martin Gräßlin
fdbf89dac8 Ensure we destroy our test windows 2013-01-23 11:47:55 +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