Commit a9d2bad0 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[x11] Enable synchronized resizing for Xwayland clients

Given that we now query the current X11 time stamp on Wayland, we can
enable synchronized resizing for Xwayland clients.

Differential Revision: https://phabricator.kde.org/D29250
parent 0323825f
......@@ -485,6 +485,7 @@ set(kwin_SRCS
scripting/workspace_wrapper.cpp
shadow.cpp
sm.cpp
syncalarmx11filter.cpp
thumbnailitem.cpp
toplevel.cpp
touch_hide_cursor_spy.cpp
......
......@@ -7,7 +7,6 @@ set(X11PLATFORM_SOURCES
overlaywindow_x11.cpp
screenedges_filter.cpp
screens_xrandr.cpp
sync_filter.cpp
windowselector.cpp
x11_decoration_renderer.cpp
x11_output.cpp
......
......@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "x11_platform.h"
#include "x11cursor.h"
#include "edge.h"
#include "sync_filter.h"
#include "windowselector.h"
#include <config-kwin.h>
#include <kwinconfig.h>
......@@ -74,13 +73,6 @@ X11StandalonePlatform::X11StandalonePlatform(QObject *parent)
}
}
#endif
connect(kwinApp(), &Application::workspaceCreated, this,
[this] {
if (Xcb::Extensions::self()->isSyncAvailable()) {
m_syncFilter = std::make_unique<SyncFilter>();
}
}
);
setSupportsGammaControl(true);
}
......
......@@ -29,7 +29,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
class SyncFilter;
class XInputIntegration;
class WindowSelector;
class X11EventFilter;
......@@ -101,7 +100,6 @@ private:
Display *m_x11Display;
QScopedPointer<WindowSelector> m_windowSelector;
QScopedPointer<X11EventFilter> m_screenEdgesFilter;
std::unique_ptr<SyncFilter> m_syncFilter;
QVector<X11Output*> m_outputs;
};
......
......@@ -17,32 +17,31 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "sync_filter.h"
#include "x11client.h"
#include "syncalarmx11filter.h"
#include "workspace.h"
#include "x11client.h"
#include "xcbutils.h"
namespace KWin
{
SyncFilter::SyncFilter()
SyncAlarmX11Filter::SyncAlarmX11Filter()
: X11EventFilter(QVector<int>{Xcb::Extensions::self()->syncAlarmNotifyEvent()})
{
}
bool SyncFilter::event(xcb_generic_event_t *event)
bool SyncAlarmX11Filter::event(xcb_generic_event_t *event)
{
auto e = reinterpret_cast< xcb_sync_alarm_notify_event_t* >(event);
auto client = workspace()->findClient(
[e] (const X11Client *c) {
const auto syncRequest = c->syncRequest();
return e->alarm == syncRequest.alarm && e->counter_value.hi == syncRequest.value.hi && e->counter_value.lo == syncRequest.value.lo;
}
);
auto alarmEvent = reinterpret_cast<xcb_sync_alarm_notify_event_t *>(event);
auto client = workspace()->findClient([alarmEvent](const X11Client *client) {
const auto syncRequest = client->syncRequest();
return alarmEvent->alarm == syncRequest.alarm && alarmEvent->counter_value.hi == syncRequest.value.hi && alarmEvent->counter_value.lo == syncRequest.value.lo;
});
if (client) {
client->handleSync();
}
return false;
}
}
} // namespace KWin
......@@ -17,22 +17,20 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_SYNC_FILTER_H
#define KWIN_SYNC_FILTER_H
#pragma once
#include "x11eventfilter.h"
namespace KWin
{
class X11Cursor;
class SyncFilter : public X11EventFilter
class SyncAlarmX11Filter : public X11EventFilter
{
public:
explicit SyncFilter();
SyncAlarmX11Filter();
bool event(xcb_generic_event_t *event) override;
};
}
#endif
} // namespace KWin
......@@ -50,6 +50,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "screens.h"
#include "platform.h"
#include "scripting/scripting.h"
#include "syncalarmx11filter.h"
#ifdef KWIN_BUILD_TABBOX
#include "tabbox.h"
#endif
......@@ -340,6 +341,9 @@ void Workspace::initWithX11()
m_wasUserInteractionFilter.reset(new WasUserInteractionX11Filter);
m_movingClientFilter.reset(new MovingClientX11Filter);
}
if (Xcb::Extensions::self()->isSyncAvailable()) {
m_syncAlarmFilter.reset(new SyncAlarmX11Filter);
}
updateXTime(); // Needed for proper initialization of user_time in Client ctor
const uint32_t nullFocusValues[] = {true};
......
......@@ -668,6 +668,7 @@ private:
QList<X11EventFilter *> m_eventFilters;
QList<X11EventFilter *> m_genericEventFilters;
QScopedPointer<X11EventFilter> m_movingClientFilter;
QScopedPointer<X11EventFilter> m_syncAlarmFilter;
SessionManager *m_sessionManager;
private:
......
......@@ -2344,9 +2344,7 @@ void X11Client::getIcons()
void X11Client::getSyncCounter()
{
// TODO: make sync working on XWayland
static const bool isX11 = kwinApp()->operationMode() == Application::OperationModeX11;
if (!Xcb::Extensions::self()->isSyncAvailable() || !isX11)
if (!Xcb::Extensions::self()->isSyncAvailable())
return;
Xcb::Property syncProp(false, window(), atoms->net_wm_sync_request_counter, XCB_ATOM_CARDINAL, 0, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment