mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 19:45:58 +01:00
pointer-gestures: move to new impl
This commit is contained in:
parent
d86eec332f
commit
3878f806ff
12 changed files with 347 additions and 24 deletions
|
@ -109,7 +109,7 @@ pkg_check_modules(deps REQUIRED IMPORTED_TARGET
|
|||
wayland-server wayland-client wayland-cursor wayland-protocols
|
||||
cairo pango pangocairo pixman-1
|
||||
libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm
|
||||
hyprwayland-scanner>=0.3.0 hyprlang>=0.3.2 hyprcursor>=0.1.7
|
||||
hyprwayland-scanner>=0.3.1 hyprlang>=0.3.2 hyprcursor>=0.1.7
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
|
||||
|
@ -272,6 +272,7 @@ protocolNew("unstable/relative-pointer/relative-pointer-unstable-v1.xml" "relati
|
|||
protocolNew("unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" "xdg-decoration-unstable-v1" false)
|
||||
protocolNew("staging/alpha-modifier/alpha-modifier-v1.xml" "alpha-modifier-v1" false)
|
||||
protocolNew("staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml" "ext-foreign-toplevel-list-v1" false)
|
||||
protocolNew("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml" "pointer-gestures-unstable-v1" false)
|
||||
|
||||
# tools
|
||||
add_subdirectory(hyprctl)
|
||||
|
|
|
@ -82,11 +82,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1713969974,
|
||||
"narHash": "sha256-Z+/EWuSYxEecupe2DRS6sidVKGr3GxzZDYiC5mpSxPE=",
|
||||
"lastModified": 1713989318,
|
||||
"narHash": "sha256-WSsEQQxZQ+bsAWRhi1iXvP8sxgRyNtY3X1V3CfFdP5Q=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "hyprwayland-scanner",
|
||||
"rev": "066c24549f28f97cfb2d821bf64f6ddd91da46c0",
|
||||
"rev": "1cfe2d26a82ce794fd33ec06fa022e68501c5a45",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -49,6 +49,7 @@ new_protocols = [
|
|||
[wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'],
|
||||
[wl_protocol_dir, 'staging/alpha-modifier/alpha-modifier-v1.xml'],
|
||||
[wl_protocol_dir, 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml'],
|
||||
[wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'],
|
||||
]
|
||||
|
||||
wl_protos_src = []
|
||||
|
|
|
@ -234,8 +234,6 @@ void CCompositor::initServer() {
|
|||
wlr_xdg_foreign_v1_create(m_sWLDisplay, m_sWLRForeignRegistry);
|
||||
wlr_xdg_foreign_v2_create(m_sWLDisplay, m_sWLRForeignRegistry);
|
||||
|
||||
m_sWLRPointerGestures = wlr_pointer_gestures_v1_create(m_sWLDisplay);
|
||||
|
||||
m_sWLRTextInputMgr = wlr_text_input_manager_v3_create(m_sWLDisplay);
|
||||
|
||||
m_sWLRIMEMgr = wlr_input_method_manager_v2_create(m_sWLDisplay);
|
||||
|
|
|
@ -69,7 +69,6 @@ class CCompositor {
|
|||
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
|
||||
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
||||
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
||||
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
|
||||
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
|
||||
wlr_input_method_manager_v2* m_sWLRIMEMgr;
|
||||
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "../helpers/WLClasses.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../protocols/PointerGestures.hpp"
|
||||
|
||||
// ---------------------------------------------------- //
|
||||
// _____ ________ _______ _____ ______ _____ //
|
||||
|
@ -141,17 +142,17 @@ void Events::listener_swipeEnd(wl_listener* listener, void* data) {
|
|||
|
||||
void Events::listener_pinchBegin(wl_listener* listener, void* data) {
|
||||
const auto EV = (wlr_pointer_pinch_begin_event*)data;
|
||||
wlr_pointer_gestures_v1_send_pinch_begin(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, EV->time_msec, EV->fingers);
|
||||
PROTO::pointerGestures->pinchBegin(EV->time_msec, EV->fingers);
|
||||
}
|
||||
|
||||
void Events::listener_pinchUpdate(wl_listener* listener, void* data) {
|
||||
const auto EV = (wlr_pointer_pinch_update_event*)data;
|
||||
wlr_pointer_gestures_v1_send_pinch_update(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, EV->time_msec, EV->dx, EV->dy, EV->scale, EV->rotation);
|
||||
PROTO::pointerGestures->pinchUpdate(EV->time_msec, {EV->dx, EV->dy}, EV->scale, EV->rotation);
|
||||
}
|
||||
|
||||
void Events::listener_pinchEnd(wl_listener* listener, void* data) {
|
||||
const auto EV = (wlr_pointer_pinch_end_event*)data;
|
||||
wlr_pointer_gestures_v1_send_pinch_end(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, EV->time_msec, EV->cancelled);
|
||||
PROTO::pointerGestures->pinchEnd(EV->time_msec, EV->cancelled);
|
||||
}
|
||||
|
||||
void Events::listener_newVirtualKeyboard(wl_listener* listener, void* data) {
|
||||
|
@ -177,9 +178,11 @@ void Events::listener_touchFrame(wl_listener* listener, void* data) {
|
|||
}
|
||||
|
||||
void Events::listener_holdBegin(wl_listener* listener, void* data) {
|
||||
g_pInputManager->onPointerHoldBegin((wlr_pointer_hold_begin_event*)data);
|
||||
const auto EV = (wlr_pointer_hold_begin_event*)data;
|
||||
PROTO::pointerGestures->holdBegin(EV->time_msec, EV->fingers);
|
||||
}
|
||||
|
||||
void Events::listener_holdEnd(wl_listener* listener, void* data) {
|
||||
g_pInputManager->onPointerHoldEnd((wlr_pointer_hold_end_event*)data);
|
||||
const auto EV = (wlr_pointer_hold_end_event*)data;
|
||||
PROTO::pointerGestures->holdEnd(EV->time_msec, EV->cancelled);
|
||||
}
|
|
@ -86,7 +86,6 @@ extern "C" {
|
|||
#include <wlr/types/wlr_xdg_foreign_registry.h>
|
||||
#include <wlr/types/wlr_xdg_foreign_v1.h>
|
||||
#include <wlr/types/wlr_xdg_foreign_v2.h>
|
||||
#include <wlr/types/wlr_pointer_gestures_v1.h>
|
||||
#include <wlr/types/wlr_output_power_management_v1.h>
|
||||
#include <wlr/types/wlr_input_method_v2.h>
|
||||
#include <wlr/types/wlr_text_input_v3.h>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "../protocols/AlphaModifier.hpp"
|
||||
#include "../protocols/GammaControl.hpp"
|
||||
#include "../protocols/ForeignToplevel.hpp"
|
||||
#include "../protocols/PointerGestures.hpp"
|
||||
|
||||
#include "tearing-control-v1.hpp"
|
||||
#include "fractional-scale-v1.hpp"
|
||||
|
@ -21,6 +22,7 @@
|
|||
#include "alpha-modifier-v1.hpp"
|
||||
#include "wlr-gamma-control-unstable-v1.hpp"
|
||||
#include "ext-foreign-toplevel-list-v1.hpp"
|
||||
#include "pointer-gestures-unstable-v1.hpp"
|
||||
|
||||
CProtocolManager::CProtocolManager() {
|
||||
|
||||
|
@ -34,6 +36,7 @@ CProtocolManager::CProtocolManager() {
|
|||
PROTO::alphaModifier = std::make_unique<CAlphaModifierProtocol>(&wp_alpha_modifier_v1_interface, 1, "AlphaModifier");
|
||||
PROTO::gamma = std::make_unique<CGammaControlProtocol>(&zwlr_gamma_control_manager_v1_interface, 1, "GammaControl");
|
||||
PROTO::foreignToplevel = std::make_unique<CForeignToplevelProtocol>(&ext_foreign_toplevel_list_v1_interface, 1, "ForeignToplevel");
|
||||
PROTO::pointerGestures = std::make_unique<CPointerGesturesProtocol>(&zwp_pointer_gestures_v1_interface, 3, "PointerGestures");
|
||||
|
||||
// Old protocol implementations.
|
||||
// TODO: rewrite them to use hyprwayland-scanner.
|
||||
|
|
|
@ -111,9 +111,6 @@ class CInputManager {
|
|||
void onTouchUp(wlr_touch_up_event*);
|
||||
void onTouchMove(wlr_touch_motion_event*);
|
||||
|
||||
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
|
||||
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
|
||||
|
||||
STouchData m_sTouchData;
|
||||
|
||||
// for dragging floating windows
|
||||
|
|
|
@ -147,11 +147,3 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e) {
|
|||
// wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, local.x, local.y);
|
||||
}
|
||||
}
|
||||
|
||||
void CInputManager::onPointerHoldBegin(wlr_pointer_hold_begin_event* e) {
|
||||
wlr_pointer_gestures_v1_send_hold_begin(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, e->time_msec, e->fingers);
|
||||
}
|
||||
|
||||
void CInputManager::onPointerHoldEnd(wlr_pointer_hold_end_event* e) {
|
||||
wlr_pointer_gestures_v1_send_hold_end(g_pCompositor->m_sWLRPointerGestures, g_pCompositor->m_sSeat.seat, e->time_msec, e->cancelled);
|
||||
}
|
||||
|
|
246
src/protocols/PointerGestures.cpp
Normal file
246
src/protocols/PointerGestures.cpp
Normal file
|
@ -0,0 +1,246 @@
|
|||
#include "PointerGestures.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
|
||||
#define LOGM PROTO::pointerGestures->protoLog
|
||||
|
||||
CPointerGestureSwipe::CPointerGestureSwipe(SP<CZwpPointerGestureSwipeV1> resource_) : resource(resource_) {
|
||||
if (!resource->resource())
|
||||
return;
|
||||
|
||||
resource->setOnDestroy([this](CZwpPointerGestureSwipeV1* p) { PROTO::pointerGestures->onGestureDestroy(this); });
|
||||
resource->setDestroy([this](CZwpPointerGestureSwipeV1* p) { PROTO::pointerGestures->onGestureDestroy(this); });
|
||||
}
|
||||
|
||||
bool CPointerGestureSwipe::good() {
|
||||
return resource->resource();
|
||||
}
|
||||
|
||||
CPointerGestureHold::CPointerGestureHold(SP<CZwpPointerGestureHoldV1> resource_) : resource(resource_) {
|
||||
if (!resource->resource())
|
||||
return;
|
||||
|
||||
resource->setOnDestroy([this](CZwpPointerGestureHoldV1* p) { PROTO::pointerGestures->onGestureDestroy(this); });
|
||||
resource->setDestroy([this](CZwpPointerGestureHoldV1* p) { PROTO::pointerGestures->onGestureDestroy(this); });
|
||||
}
|
||||
|
||||
bool CPointerGestureHold::good() {
|
||||
return resource->resource();
|
||||
}
|
||||
|
||||
CPointerGesturePinch::CPointerGesturePinch(SP<CZwpPointerGesturePinchV1> resource_) : resource(resource_) {
|
||||
if (!resource->resource())
|
||||
return;
|
||||
|
||||
resource->setOnDestroy([this](CZwpPointerGesturePinchV1* p) { PROTO::pointerGestures->onGestureDestroy(this); });
|
||||
resource->setDestroy([this](CZwpPointerGesturePinchV1* p) { PROTO::pointerGestures->onGestureDestroy(this); });
|
||||
}
|
||||
|
||||
bool CPointerGesturePinch::good() {
|
||||
return resource->resource();
|
||||
}
|
||||
|
||||
CPointerGesturesProtocol::CPointerGesturesProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
;
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(std::make_unique<CZwpPointerGesturesV1>(client, ver, id)).get();
|
||||
RESOURCE->setOnDestroy([this](CZwpPointerGesturesV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
RESOURCE->setRelease([this](CZwpPointerGesturesV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||
|
||||
RESOURCE->setGetHoldGesture([this](CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) { this->onGetHoldGesture(pMgr, id, pointer); });
|
||||
RESOURCE->setGetPinchGesture([this](CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) { this->onGetPinchGesture(pMgr, id, pointer); });
|
||||
RESOURCE->setGetSwipeGesture([this](CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) { this->onGetSwipeGesture(pMgr, id, pointer); });
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onGestureDestroy(CPointerGestureSwipe* gesture) {
|
||||
std::erase_if(m_vSwipes, [&](const auto& other) { return other.get() == gesture; });
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onGestureDestroy(CPointerGesturePinch* gesture) {
|
||||
std::erase_if(m_vPinches, [&](const auto& other) { return other.get() == gesture; });
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onGestureDestroy(CPointerGestureHold* gesture) {
|
||||
std::erase_if(m_vHolds, [&](const auto& other) { return other.get() == gesture; });
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onGetPinchGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) {
|
||||
const auto CLIENT = wl_resource_get_client(pMgr->resource());
|
||||
const auto RESOURCE =
|
||||
m_vPinches.emplace_back(std::make_unique<CPointerGesturePinch>(std::make_shared<CZwpPointerGesturePinchV1>(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get();
|
||||
|
||||
if (!RESOURCE->good()) {
|
||||
wl_resource_post_no_memory(pMgr->resource());
|
||||
LOGM(ERR, "Couldn't create gesture");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onGetSwipeGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) {
|
||||
const auto CLIENT = wl_resource_get_client(pMgr->resource());
|
||||
const auto RESOURCE =
|
||||
m_vSwipes.emplace_back(std::make_unique<CPointerGestureSwipe>(std::make_shared<CZwpPointerGestureSwipeV1>(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get();
|
||||
|
||||
if (!RESOURCE->good()) {
|
||||
wl_resource_post_no_memory(pMgr->resource());
|
||||
LOGM(ERR, "Couldn't create gesture");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::onGetHoldGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) {
|
||||
const auto CLIENT = wl_resource_get_client(pMgr->resource());
|
||||
const auto RESOURCE =
|
||||
m_vHolds.emplace_back(std::make_unique<CPointerGestureHold>(std::make_shared<CZwpPointerGestureHoldV1>(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get();
|
||||
|
||||
if (!RESOURCE->good()) {
|
||||
wl_resource_post_no_memory(pMgr->resource());
|
||||
LOGM(ERR, "Couldn't create gesture");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::swipeBegin(uint32_t timeMs, uint32_t fingers) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client);
|
||||
|
||||
for (auto& sw : m_vSwipes) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendBegin(SERIAL, timeMs, g_pCompositor->m_sSeat.seat->pointer_state.focused_surface->resource, fingers);
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::swipeUpdate(uint32_t timeMs, const Vector2D& delta) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
for (auto& sw : m_vSwipes) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendUpdate(timeMs, wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y));
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::swipeEnd(uint32_t timeMs, bool cancelled) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client);
|
||||
|
||||
for (auto& sw : m_vSwipes) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendEnd(SERIAL, timeMs, cancelled);
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::pinchBegin(uint32_t timeMs, uint32_t fingers) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client);
|
||||
|
||||
for (auto& sw : m_vPinches) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendBegin(SERIAL, timeMs, g_pCompositor->m_sSeat.seat->pointer_state.focused_surface->resource, fingers);
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::pinchUpdate(uint32_t timeMs, const Vector2D& delta, double scale, double rotation) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
for (auto& sw : m_vPinches) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendUpdate(timeMs, wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y), wl_fixed_from_double(scale), wl_fixed_from_double(rotation));
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::pinchEnd(uint32_t timeMs, bool cancelled) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client);
|
||||
|
||||
for (auto& sw : m_vPinches) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendEnd(SERIAL, timeMs, cancelled);
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::holdBegin(uint32_t timeMs, uint32_t fingers) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client);
|
||||
|
||||
for (auto& sw : m_vHolds) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendBegin(SERIAL, timeMs, g_pCompositor->m_sSeat.seat->pointer_state.focused_surface->resource, fingers);
|
||||
}
|
||||
}
|
||||
|
||||
void CPointerGesturesProtocol::holdEnd(uint32_t timeMs, bool cancelled) {
|
||||
if (!g_pCompositor->m_sSeat.seat->pointer_state.focused_client)
|
||||
return;
|
||||
|
||||
const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client;
|
||||
|
||||
const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client);
|
||||
|
||||
for (auto& sw : m_vHolds) {
|
||||
const auto CLIENT = wl_resource_get_client(sw->resource->resource());
|
||||
|
||||
if (CLIENT != FOCUSEDCLIENT)
|
||||
continue;
|
||||
|
||||
sw->resource->sendEnd(SERIAL, timeMs, cancelled);
|
||||
}
|
||||
}
|
84
src/protocols/PointerGestures.hpp
Normal file
84
src/protocols/PointerGestures.hpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "WaylandProtocol.hpp"
|
||||
#include "pointer-gestures-unstable-v1.hpp"
|
||||
#include "../helpers/Vector2D.hpp"
|
||||
|
||||
class CPointerGestureSwipe {
|
||||
public:
|
||||
CPointerGestureSwipe(SP<CZwpPointerGestureSwipeV1> resource_);
|
||||
|
||||
bool good();
|
||||
|
||||
private:
|
||||
SP<CZwpPointerGestureSwipeV1> resource;
|
||||
|
||||
friend class CPointerGesturesProtocol;
|
||||
};
|
||||
|
||||
class CPointerGesturePinch {
|
||||
public:
|
||||
CPointerGesturePinch(SP<CZwpPointerGesturePinchV1> resource_);
|
||||
|
||||
bool good();
|
||||
|
||||
private:
|
||||
SP<CZwpPointerGesturePinchV1> resource;
|
||||
|
||||
friend class CPointerGesturesProtocol;
|
||||
};
|
||||
|
||||
class CPointerGestureHold {
|
||||
public:
|
||||
CPointerGestureHold(SP<CZwpPointerGestureHoldV1> resource_);
|
||||
|
||||
bool good();
|
||||
|
||||
private:
|
||||
SP<CZwpPointerGestureHoldV1> resource;
|
||||
|
||||
friend class CPointerGesturesProtocol;
|
||||
};
|
||||
|
||||
class CPointerGesturesProtocol : public IWaylandProtocol {
|
||||
public:
|
||||
CPointerGesturesProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
||||
|
||||
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
||||
|
||||
void swipeBegin(uint32_t timeMs, uint32_t fingers);
|
||||
void swipeUpdate(uint32_t timeMs, const Vector2D& delta);
|
||||
void swipeEnd(uint32_t timeMs, bool cancelled);
|
||||
|
||||
void pinchBegin(uint32_t timeMs, uint32_t fingers);
|
||||
void pinchUpdate(uint32_t timeMs, const Vector2D& delta, double scale, double rotation);
|
||||
void pinchEnd(uint32_t timeMs, bool cancelled);
|
||||
|
||||
void holdBegin(uint32_t timeMs, uint32_t fingers);
|
||||
void holdEnd(uint32_t timeMs, bool cancelled);
|
||||
|
||||
private:
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
void onGestureDestroy(CPointerGestureSwipe* gesture);
|
||||
void onGestureDestroy(CPointerGesturePinch* gesture);
|
||||
void onGestureDestroy(CPointerGestureHold* gesture);
|
||||
void onGetPinchGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer);
|
||||
void onGetSwipeGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer);
|
||||
void onGetHoldGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer);
|
||||
|
||||
//
|
||||
std::vector<UP<CZwpPointerGesturesV1>> m_vManagers;
|
||||
std::vector<UP<CPointerGestureSwipe>> m_vSwipes;
|
||||
std::vector<UP<CPointerGesturePinch>> m_vPinches;
|
||||
std::vector<UP<CPointerGestureHold>> m_vHolds;
|
||||
|
||||
friend class CPointerGestureHold;
|
||||
friend class CPointerGesturePinch;
|
||||
friend class CPointerGestureSwipe;
|
||||
};
|
||||
|
||||
namespace PROTO {
|
||||
inline UP<CPointerGesturesProtocol> pointerGestures;
|
||||
};
|
Loading…
Reference in a new issue