Move updateXTime into the X11 standalone platform

Summary:
KWin::updateXTime only delegates into the platform API where the method
is a no-op. The actual implementation is moved into the X11 standalone
platform as it uses QX11Info which is non functional except on the X11
standalone platform.

This change exposes a problem with timestamp handling: on Wayland the
X11 timestamp does not get updated at all, causing e.g. window sync not
work correctly (c.f. bug 374881). We cannot implement the updating in the
same way as QX11Info/Qt xcb platform does it as that would introduce a
blocking roundtrip to XWayland which is dangerous.

As a side-effect this change removes linking to Qt5::X11Extras in kwin
core as it's no longer needed.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7515
This commit is contained in:
Martin Flöser 2017-08-24 16:53:40 +02:00
parent 95c983e6d8
commit 1cc38c929a
6 changed files with 35 additions and 15 deletions

View file

@ -532,7 +532,6 @@ set(kwin_QT_LIBS
Qt5::DBus
Qt5::Quick
Qt5::Script
Qt5::X11Extras
)
set(kwin_KDE_LIBS
@ -614,7 +613,7 @@ generate_export_header(kwin EXPORT_FILE_NAME kwin_export.h)
target_link_libraries(kwin kwinglutils ${epoxy_LIBRARY})
kf5_add_kdeinit_executable(kwin_x11 main_x11.cpp)
target_link_libraries(kdeinit_kwin_x11 kwin KF5::Crash)
target_link_libraries(kdeinit_kwin_x11 kwin KF5::Crash Qt5::X11Extras)
install(TARGETS kwin ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP )
install(TARGETS kdeinit_kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} )

View file

@ -466,4 +466,8 @@ OverlayWindow *Platform::createOverlayWindow()
return nullptr;
}
void Platform::updateXTime()
{
}
}

View file

@ -308,6 +308,15 @@ public:
**/
virtual OverlayWindow *createOverlayWindow();
/**
* Allows a platform to update the X11 timestamp.
* Mostly for the X11 standalone platform to interact with QX11Info.
*
* Default implementation does nothing. This means code relying on the X timestamp being up to date,
* might not be working. E.g. synced X11 window resizing
**/
virtual void updateXTime();
public Q_SLOTS:
void pointerMotion(const QPointF &position, quint32 time);
void pointerButtonPressed(quint32 button, quint32 time);

View file

@ -315,4 +315,21 @@ OverlayWindow *X11StandalonePlatform::createOverlayWindow()
return new OverlayWindowX11();
}
/*
Updates xTime(). This used to simply fetch current timestamp from the server,
but that can cause xTime() to be newer than timestamp of events that are
still in our events queue, thus e.g. making XSetInputFocus() caused by such
event to be ignored. Therefore events queue is searched for first
event with timestamp, and extra PropertyNotify is generated in order to make
sure such event is found.
*/
void X11StandalonePlatform::updateXTime()
{
// NOTE: QX11Info::getTimestamp does not yet search the event queue as the old
// solution did. This means there might be regressions currently. See the
// documentation above on how it should be done properly.
kwinApp()->setX11Time(QX11Info::getTimestamp(), Application::TimestampUpdate::Always);
}
}

View file

@ -57,6 +57,8 @@ public:
OverlayWindow *createOverlayWindow() override;
void updateXTime() override;
protected:
void doHideCursor() override;
void doShowCursor() override;

View file

@ -35,12 +35,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QApplication>
#include <QDebug>
#include <QX11Info>
#include <X11/Xlib.h>
#include <stdio.h>
#include "atoms.h"
#include "platform.h"
#include "workspace.h"
#include <signal.h>
@ -72,20 +72,9 @@ StrutRect::StrutRect(const StrutRect& other)
#endif
#ifndef KCMRULES
/*
Updates xTime(). This used to simply fetch current timestamp from the server,
but that can cause xTime() to be newer than timestamp of events that are
still in our events queue, thus e.g. making XSetInputFocus() caused by such
event to be ignored. Therefore events queue is searched for first
event with timestamp, and extra PropertyNotify is generated in order to make
sure such event is found.
*/
void updateXTime()
{
// NOTE: QX11Info::getTimestamp does not yet search the event queue as the old
// solution did. This means there might be regressions currently. See the
// documentation above on how it should be done properly.
kwinApp()->setX11Time(QX11Info::getTimestamp(), Application::TimestampUpdate::Always);
kwinApp()->platform()->updateXTime();
}
static int server_grab_count = 0;