-
-
Notifications
You must be signed in to change notification settings - Fork 943
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
16
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.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7dad916
WIP: input capture
3l0w 5fb4562
input-capture: impl keyboard, mouse button & mouse wheel
3l0w fbf1f88
input-capture: inhibit inputs
3l0w c92e592
input-capture: code cleanup
3l0w bc6b472
input-capture: fix build
3l0w 0c2c8f2
input-capture: Init active property & upstream protocol changes
3l0w 38bc5f5
input-capture: fixes
3l0w bc5f6cd
input-capture: impl keymap
3l0w c240846
input-capture: impl force release
3l0w e2fe005
input-capture: fix rebase issues
3l0w c8b8ec0
input-capture: add protocol to meson.build
3l0w 70a8353
input-capture: fix build
3l0w 56a9676
input-capture: send modifiers (highly experimental)
3l0w 981e19c
input-capture: don't send motion when the input is locked (like insid…
3l0w 54f356d
input-capture: hide cursor when the input is captured
3l0w 50fb494
change repo URL in plugin manager (#2)
alex-moon 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
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,111 @@ | ||
#include "InputCapture.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::sendModifiers(uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { | ||
for (const auto& manager : m_vManagers) | ||
manager->sendModifiers(mods_depressed, mods_locked, mods_locked, group); | ||
} | ||
|
||
|
||
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(); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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)