-
-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement new Input Capture protocol #7919
Draft
3l0w
wants to merge
10
commits into
hyprwm:main
Choose a base branch
from
3l0w:feat/input-capture-impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+214
−15
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
057f00b
WIP: input capture
3l0w 9a22c90
input-capture: impl keyboard, mouse button & mouse wheel
3l0w 98ecfe5
input-capture: inhibit inputs
3l0w 36328f3
input-capture: code cleanup
3l0w 6c211d4
input-capture: fix build
3l0w 124582b
input-capture: Init active property & upstream protocol changes
3l0w ad6cbb0
input-capture: fixes
3l0w e0321f7
input-capture: impl keymap
3l0w 255db25
input-capture: impl force release
3l0w 189f615
input-capture: fix rebase issues
3l0w File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include "InputCapture.hpp" | ||
|
||
#include "../devices/IKeyboard.hpp" | ||
#include "managers/SeatManager.hpp" | ||
#include <fcntl.h> | ||
|
||
CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { | ||
; | ||
} | ||
|
||
void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { | ||
const auto& RESOURCE = m_vManagers.emplace_back(std::make_unique<CHyprlandInputCaptureManagerV1>(client, ver, id)); | ||
|
||
RESOURCE->setOnDestroy([this](CHyprlandInputCaptureManagerV1* p) { std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == p->resource(); }); }); | ||
|
||
RESOURCE->setCapture([this](CHyprlandInputCaptureManagerV1* p) { | ||
Debug::log(LOG, "[input-capture] Input captured"); | ||
active = true; | ||
}); | ||
RESOURCE->setRelease([this](CHyprlandInputCaptureManagerV1* p) { | ||
Debug::log(LOG, "[input-capture] Input released"); | ||
active = false; | ||
}); | ||
|
||
sendKeymap(g_pSeatManager->keyboard.lock(), RESOURCE); | ||
} | ||
|
||
bool CInputCaptureProtocol::isCaptured() { | ||
return active; | ||
} | ||
|
||
void CInputCaptureProtocol::updateKeymap() { | ||
for (const auto& manager : m_vManagers) | ||
sendKeymap(g_pSeatManager->keyboard.lock(), manager); | ||
} | ||
|
||
void CInputCaptureProtocol::sendMotion(const Vector2D& absolutePosition, const Vector2D& delta) { | ||
for (const auto& manager : m_vManagers) { | ||
manager->sendMotion(wl_fixed_from_double(absolutePosition.x), wl_fixed_from_double(absolutePosition.y), wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y)); | ||
} | ||
} | ||
|
||
void CInputCaptureProtocol::sendKeymap(SP<IKeyboard> keyboard, const std::unique_ptr<CHyprlandInputCaptureManagerV1>& manager) { | ||
if (!keyboard) | ||
return; | ||
|
||
hyprlandInputCaptureManagerV1KeymapFormat format; | ||
int fd; | ||
uint32_t size; | ||
if (keyboard) { | ||
format = HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_XKB_V1; | ||
fd = keyboard->xkbKeymapFD; | ||
size = keyboard->xkbKeymapString.length() + 1; | ||
} else { | ||
format = HYPRLAND_INPUT_CAPTURE_MANAGER_V1_KEYMAP_FORMAT_NO_KEYMAP; | ||
fd = open("/dev/null", O_RDONLY | O_CLOEXEC); | ||
if (fd < 0) { | ||
LOGM(ERR, "Failed to open /dev/null"); | ||
return; | ||
} | ||
size = 0; | ||
} | ||
|
||
manager->sendKeymap(format, fd, size); | ||
|
||
if (!keyboard) | ||
close(fd); | ||
} | ||
|
||
void CInputCaptureProtocol::forceRelease() { | ||
Debug::log(LOG, "[input-capture] Force Input released"); | ||
active = false; | ||
|
||
for (const auto& manager : m_vManagers) | ||
manager->sendForceRelease(); | ||
} | ||
|
||
void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendKey(keyCode, state); | ||
} | ||
|
||
void CInputCaptureProtocol::sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendButton(button, state); | ||
} | ||
|
||
void CInputCaptureProtocol::sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value) { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendAxis(axis, value); | ||
} | ||
|
||
void CInputCaptureProtocol::sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120) { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendAxisValue120(axis, value120); | ||
} | ||
|
||
void CInputCaptureProtocol::sendAxisStop(hyprlandInputCaptureManagerV1Axis axis) { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendAxisStop(axis); | ||
} | ||
|
||
void CInputCaptureProtocol::sendFrame() { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendFrame(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include "hyprland-input-capture-v1.hpp" | ||
#include "../protocols/WaylandProtocol.hpp" | ||
#include <hyprutils/math/Vector2D.hpp> | ||
|
||
class CInputCaptureProtocol : public IWaylandProtocol { | ||
public: | ||
CInputCaptureProtocol(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); | ||
|
||
// | ||
bool isCaptured(); | ||
|
||
void updateKeymap(); | ||
void forceRelease(); | ||
|
||
void sendMotion(const Vector2D& absolutePosition, const Vector2D& delta); | ||
void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state); | ||
void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state); | ||
void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value); | ||
void sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120); | ||
void sendAxisStop(hyprlandInputCaptureManagerV1Axis axis); | ||
|
||
void sendFrame(); | ||
|
||
private: | ||
void sendKeymap(SP<IKeyboard> keyboard, const std::unique_ptr<CHyprlandInputCaptureManagerV1>& manager); | ||
|
||
bool active = false; | ||
// | ||
std::vector<UP<CHyprlandInputCaptureManagerV1>> m_vManagers; | ||
}; | ||
|
||
namespace PROTO { | ||
inline UP<CInputCaptureProtocol> inputCapture; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule hyprland-protocols
updated
3 files
+1 −0 | README.md | |
+1 −0 | meson.build | |
+247 −0 | protocols/hyprland-input-capture-v1.xml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marking this one as a blocker until this is removed so we dont forget (don't resolve)