Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions misc/dconfig/org.deepin.dde.treeland.user.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,17 @@
"permissions": "readonly",
"visibility": "private"
},
"inputAccelProfile": {
"value": 2,
"serial": 0,
"flags": ["global"],
"name": "Libinput Accel Profile",
"name[zh_CN]": "Libinput 加速曲线",
"description": "Pointer acceleration profile, enum value of libinput_config_accel_profile",
"description[zh_CN]": "指针加速曲线,对应 libinput_config_accel_profile 枚举值",
"permissions": "readwrite",
"visibility": "public"
},
"wallpaperConfig": {
"value": "",
"serial": 0,
Expand Down
3 changes: 3 additions & 0 deletions src/core/shellhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

#include <xcb/xcb.h>

#include <winputmethodhelper.h>

Check warning on line 24 in src/core/shellhandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <winputmethodhelper.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <winputpopupsurface.h>

Check warning on line 25 in src/core/shellhandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <winputpopupsurface.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wvirtualinputhelper.h>

Check warning on line 26 in src/core/shellhandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wvirtualinputhelper.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wlayershell.h>

Check warning on line 27 in src/core/shellhandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wlayershell.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wlayersurface.h>

Check warning on line 28 in src/core/shellhandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <wlayersurface.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <woutputrenderwindow.h>

Check warning on line 29 in src/core/shellhandler.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <woutputrenderwindow.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <wserver.h>
#include <wxdgpopupsurface.h>
#include <wxdgshell.h>
Expand Down Expand Up @@ -336,6 +337,8 @@
void ShellHandler::initInputMethodHelper(WServer *server, WSeat *seat)
{
Q_ASSERT_X(!m_inputMethodHelper, Q_FUNC_INFO, "Only init once!");
Q_ASSERT_X(!m_virtualInputHelper, Q_FUNC_INFO, "Only init once!");
m_virtualInputHelper = new WVirtualInputHelper(server, seat);
m_inputMethodHelper = new WInputMethodHelper(server, seat);

connect(m_inputMethodHelper,
Expand Down
2 changes: 2 additions & 0 deletions src/core/shellhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class WInputMethodHelper;
class WInputPopupSurface;
class WSeat;
class WSurface;
class WVirtualInputHelper;
class WXWaylandSurface;
WAYLIB_SERVER_END_NAMESPACE

Expand Down Expand Up @@ -161,6 +162,7 @@ private Q_SLOTS:
WAYLIB_SERVER_NAMESPACE::WLayerShell *m_layerShell = nullptr;
TreelandWallpaperShellInterfaceV1 *m_wallpaperShell = nullptr;
WAYLIB_SERVER_NAMESPACE::WInputMethodHelper *m_inputMethodHelper = nullptr;
WAYLIB_SERVER_NAMESPACE::WVirtualInputHelper *m_virtualInputHelper = nullptr;
QList<WAYLIB_SERVER_NAMESPACE::WXWayland *> m_xwaylands;
ForeignToplevelV1 *m_treelandForeignToplevel = nullptr;

Expand Down
33 changes: 25 additions & 8 deletions src/input/inputdevice.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (C) 2024-2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "helper.h"

Check warning on line 4 in src/input/inputdevice.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "helper.h" not found.
#include "inputdevice.h"
#include "common/treelandlogging.h"

Check warning on line 6 in src/input/inputdevice.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "common/treelandlogging.h" not found.
#include "treelanduserconfig.hpp"

Check warning on line 7 in src/input/inputdevice.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "treelanduserconfig.hpp" not found.

#include <winputdevice.h>

Check warning on line 9 in src/input/inputdevice.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <winputdevice.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <qwbackend.h>
#include <qwinputdevice.h>
Expand All @@ -13,6 +15,7 @@
#include <QLoggingCategory>
#include <QPointer>


QW_USE_NAMESPACE

#define MIN_SWIPE_FINGERS 3
Expand Down Expand Up @@ -351,24 +354,38 @@
return m_instance;
}

bool InputDevice::initTouchPad(WInputDevice *device)
void InputDevice::initDevice(WInputDevice *device)
{
if (!device) {
qCCritical(treelandInput) << "Cannot initialize touchpad for null device";
return false;
return;
}

if (!device->qtDevice()) {
if (!device->qtDevice() || !device->handle()->is_libinput()) {
qCCritical(treelandInput) << "Cannot initialize touchpad: device has no qtDevice";
return false;
return;
}

if (device->handle()->is_libinput()
&& device->qtDevice()->type() == QInputDevice::DeviceType::TouchPad) {
auto deviceType = device->qtDevice()->type();
if (deviceType == QInputDevice::DeviceType::TouchPad) {
configTapEnabled(libinput_device_handle(device->handle()), LIBINPUT_CONFIG_TAP_ENABLED);
return true;
}
return false;

if (deviceType == QInputDevice::DeviceType::TouchPad
|| deviceType == QInputDevice::DeviceType::Mouse) {
return;
}

auto config = Helper::instance()->config();
auto applyAccelProfile = [device, config]() {
configAccelProfile(libinput_device_handle(device->handle()),
static_cast<libinput_config_accel_profile>(config->inputAccelProfile()));
};

connect(config, &TreelandUserConfig::inputAccelProfileChanged, device, applyAccelProfile);
connect(config, &TreelandUserConfig::configInitializeSucceed, device, applyAccelProfile);

applyAccelProfile();
}

[[maybe_unused]] SwipeGesture* InputDevice::registerTouchpadSwipe(const SwipeFeedBack &feed_back)
Expand Down
7 changes: 5 additions & 2 deletions src/input/inputdevice.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024-2025 UnionTech Software Technology Co., Ltd.
// Copyright (C) 2024-2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#pragma once
Expand All @@ -9,7 +9,9 @@

#include <wglobal.h>

#include <QHash>
#include <QInputDevice>
#include <QVector>

WAYLIB_SERVER_BEGIN_NAMESPACE
class WInputDevice;
Expand Down Expand Up @@ -40,7 +42,7 @@ class InputDevice : public QObject
InputDevice(const InputDevice &) = delete;
InputDevice &operator=(const InputDevice &) = delete;

bool initTouchPad(WInputDevice *device);
void initDevice(WInputDevice *device);

SwipeGesture* registerTouchpadSwipe(const SwipeFeedBack &feed_back);
HoldGesture* registerTouchpadHold(const HoldFeedBack &feed);
Expand All @@ -62,5 +64,6 @@ class InputDevice : public QObject

static InputDevice *m_instance;
std::unique_ptr<GestureRecognizer> m_touchpadRecognizer;
QHash<WInputDevice *, QVector<QMetaObject::Connection>> m_deviceConnections;
uint m_touchpadFingerCount = 0;
};
4 changes: 3 additions & 1 deletion src/seat/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#include <qwrenderer.h>
#include <qwscreencopyv1.h>
#include <qwsession.h>
#include <qwsinglepixelbufferv1.h>
#include <qwsubcompositor.h>
#include <qwviewporter.h>
#include <qwxwayland.h>
Expand Down Expand Up @@ -1440,7 +1441,7 @@ void Helper::init(Treeland::Treeland *treeland)
connect(m_seatManager, &SeatsManager::deviceAdded, this, [this](WInputDevice *device) {
m_seatManager->assignDevice(device, m_renderWindow,
m_rootSurfaceContainer->outputLayout(), m_seat);
InputDevice::instance()->initTouchPad(device);
InputDevice::instance()->initDevice(device);
});

// Setup drag request handling for all seats
Expand Down Expand Up @@ -1476,6 +1477,7 @@ void Helper::init(Treeland::Treeland *treeland)
// free follow display
m_compositor = qw_compositor::create(*m_server->handle(), 6, *m_renderer);
qw_subcompositor::create(*m_server->handle());
qw_single_pixel_buffer_manager_v1::create(m_server->handle()->handle());
qw_screencopy_manager_v1::create(*m_server->handle());
qw_ext_image_copy_capture_manager_v1::create(*m_server->handle(), 1);
qw_ext_output_image_capture_source_manager_v1::create(*m_server->handle(), 1);
Expand Down
4 changes: 3 additions & 1 deletion waylib/examples/tinywl/helper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 JiDe Zhang <zhangjide@deepin.org>.
// Copyright (C) 2024-2026 JiDe Zhang <zhangjide@deepin.org>.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "helper.h"
Expand Down Expand Up @@ -28,6 +28,7 @@
#include <woutputrenderwindow.h>
#include <wqmlcreator.h>
#include <winputmethodhelper.h>
#include <wvirtualinputhelper.h>
#include <WForeignToplevel>
#include <WXdgOutput>
#include <wxwaylandsurface.h>
Expand Down Expand Up @@ -414,6 +415,7 @@ void Helper::init()
});
});

m_virtualInputHelper = new WVirtualInputHelper(m_server, m_seat);
m_inputMethodHelper = new WInputMethodHelper(m_server, m_seat);

connect(m_inputMethodHelper, &WInputMethodHelper::inputPopupSurfaceV2Added, this, [this](WInputPopupSurface *inputPopup) {
Expand Down
4 changes: 3 additions & 1 deletion waylib/examples/tinywl/helper.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2024 UnionTech Software Technology Co., Ltd.
// Copyright (C) 2024-2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#pragma once
Expand Down Expand Up @@ -34,6 +34,7 @@ class WOutputLayer;
class WOutput;
class WXWayland;
class WInputMethodHelper;
class WVirtualInputHelper;
class WXdgDecorationManager;
class WSocket;
class WSurface;
Expand Down Expand Up @@ -161,6 +162,7 @@ public Q_SLOTS:
qw_compositor *m_compositor = nullptr;
WXWayland *m_xwayland = nullptr;
WInputMethodHelper *m_inputMethodHelper = nullptr;
WVirtualInputHelper *m_virtualInputHelper = nullptr;
WXdgDecorationManager *m_xdgDecorationManager = nullptr;
WForeignToplevel *m_foreignToplevel = nullptr;
WExtForeignToplevelListV1 *m_extForeignToplevelListV1 = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions waylib/src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ set(SOURCES
protocols/wxdgdecorationmanager.cpp
protocols/wlayershell.cpp
protocols/winputmethodhelper.cpp
protocols/wvirtualinputhelper.cpp
protocols/winputpopupsurface.cpp
protocols/private/winputmethodv2.cpp
protocols/private/wtextinputv1.cpp
protocols/private/wtextinputv2.cpp
protocols/private/wtextinputv3.cpp
protocols/private/wvirtualkeyboardv1.cpp
protocols/private/wvirtualpointerv1.cpp
protocols/ext_foreign_toplevel_image_capture_source.c #TODO: Remove after wlroots 0.20
protocols/wcursorshapemanagerv1.cpp
protocols/woutputmanagerv1.cpp
Expand Down Expand Up @@ -263,6 +265,8 @@ set(HEADERS
protocols/WXdgOutput
protocols/WInputMethodHelper
protocols/winputmethodhelper.h
protocols/WVirtualInputHelper
protocols/wvirtualinputhelper.h
protocols/winputpopupsurface.h
protocols/WInputPopupSurface
protocols/wcursorshapemanagerv1.h
Expand Down
1 change: 1 addition & 0 deletions waylib/src/server/protocols/WVirtualInputHelper
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "wvirtualinputhelper.h"
48 changes: 48 additions & 0 deletions waylib/src/server/protocols/private/wvirtualpointerv1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (C) 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "wvirtualpointerv1_p.h"
#include "private/wglobal_p.h"

#include <qwdisplay.h>
#include <qwvirtualpointerv1.h>

QW_USE_NAMESPACE
WAYLIB_SERVER_BEGIN_NAMESPACE

class Q_DECL_HIDDEN WVirtualPointerManagerV1Private : public WObjectPrivate
{
W_DECLARE_PUBLIC(WVirtualPointerManagerV1)

public:
explicit WVirtualPointerManagerV1Private(WVirtualPointerManagerV1 *qq)
: WObjectPrivate(qq)
{
}
};

WVirtualPointerManagerV1::WVirtualPointerManagerV1([[maybe_unused]] QObject *parent)
: WObject(*new WVirtualPointerManagerV1Private(this))
{
}

QByteArrayView WVirtualPointerManagerV1::interfaceName() const
{
return "zwlr_virtual_pointer_manager_v1";
}

void WVirtualPointerManagerV1::create(WServer *server)
{
auto manager = qw_virtual_pointer_manager_v1::create(*server->handle());
Q_ASSERT(manager);
m_handle = manager;
connect(manager, &qw_virtual_pointer_manager_v1::notify_new_virtual_pointer,
this, &WVirtualPointerManagerV1::newVirtualPointer);
}

wl_global *WVirtualPointerManagerV1::global() const
{
return nativeInterface<qw_virtual_pointer_manager_v1>()->handle()->global;
}

WAYLIB_SERVER_END_NAMESPACE
34 changes: 34 additions & 0 deletions waylib/src/server/protocols/private/wvirtualpointerv1_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#pragma once

#include <wglobal.h>
#include <wserver.h>

#include <qwglobal.h>

struct wlr_virtual_pointer_v1_new_pointer_event;

WAYLIB_SERVER_BEGIN_NAMESPACE

class WVirtualPointerManagerV1Private;
class WAYLIB_SERVER_EXPORT WVirtualPointerManagerV1 : public QObject, public WObject, public WServerInterface
{
Q_OBJECT
W_DECLARE_PRIVATE(WVirtualPointerManagerV1)

public:
explicit WVirtualPointerManagerV1(QObject *parent = nullptr);

QByteArrayView interfaceName() const override;

Q_SIGNALS:
void newVirtualPointer(wlr_virtual_pointer_v1_new_pointer_event *event);

private:
void create(WServer *server) override;
wl_global *global() const override;
};

WAYLIB_SERVER_END_NAMESPACE
Loading
Loading