Skip to content

Conversation

@CMurtagh-LGTM
Copy link
Contributor

@CMurtagh-LGTM CMurtagh-LGTM commented Aug 22, 2025

  • Popup surface This PR is already large, will add in future PR.
  • Handle surrounding_text, text_change_cause and content_type events somehow.
  • Key repeat
  • Documentation

Do we want to also expose the virtual keyboard so people can create their own clients?

Popup surface and qml virtual keyboard will be in future PRs.

@outfoxxed
Copy link
Member

outfoxxed commented Sep 3, 2025

Exposing virtual keyboard would be a good idea, but as a separate PR.
Oh I see it was added. Is this ready for review?

@CMurtagh-LGTM
Copy link
Contributor Author

CMurtagh-LGTM commented Sep 3, 2025

I still need to do a couple things - especially documentation. I'll add the popup screen and exposing virtual keyboard in future prs since this one is already quite large.

@CMurtagh-LGTM CMurtagh-LGTM force-pushed the cmurtagh/inputmethod branch 2 times, most recently from b265756 to 7054e2d Compare September 5, 2025 05:18
@CMurtagh-LGTM CMurtagh-LGTM marked this pull request as ready for review September 5, 2025 05:36
@outfoxxed outfoxxed force-pushed the master branch 3 times, most recently from a92879d to 9bb2c04 Compare October 4, 2025 20:00
@CMurtagh-LGTM
Copy link
Contributor Author

Sorry I haven't updated in a while.
This pull request is good to go.

I have a separate branch that I have been working on the adding the popup surface functionality however it looks like I need to use the private qt headers, which I have not yet been able to work out.

@outfoxxed
Copy link
Member

Looks like CI is broken here, can you rebase on master? For private qt headers you should just be able to import them if you add a dependency on the private qt module.

Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed most of it that didn't seem likely to greatly change. It would also be useful if you included a couple tests. They dont have to be complex or automatic, just some QML files we can run to make sure its still working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this protocol included directly instead of from w-p?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of confusing as there are three versions of input-method floating around.

  • zwp_input_method_v1 - unstable
  • xx_input_method_v1 - experimental
  • zwp_input_method_v2 - external
    Hyprland uses zwp_input_method_v2 so I went with that one.
    zwp_input_method_v2 is not included in Wayland protocols.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Might be better to split this
  2. Include from w-p instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm unsure what you mean by "split this".
  2. This protocol is not inside Wayland protocols unfortunately.

Copy link
Contributor Author

@CMurtagh-LGTM CMurtagh-LGTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to have a look at adding qml test files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of confusing as there are three versions of input-method floating around.

  • zwp_input_method_v1 - unstable
  • xx_input_method_v1 - experimental
  • zwp_input_method_v2 - external
    Hyprland uses zwp_input_method_v2 so I went with that one.
    zwp_input_method_v2 is not included in Wayland protocols.

Comment on lines +116 to +122
void InputMethodHandle::zwp_input_method_v2_unavailable() {
if (!this->mAvailable) return;
this->mAvailable = false;
InputMethodManager::instance()->releaseInput();
qDebug()
<< "Compositor denied input method request, likely due to one already existing elsewhere";
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of a better way to report it than a log message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm unsure what you mean by "split this".
  2. This protocol is not inside Wayland protocols unfortunately.

Comment on lines +51 to +81
void InputMethodKeyboardGrab::zwp_input_method_keyboard_grab_v2_keymap(
uint32_t format [[maybe_unused]],
int32_t fd,
uint32_t size
) {
// https://wayland-book.com/seat/example.html
assert(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1);

char* mapShm = static_cast<char*>(mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0));
assert(mapShm != MAP_FAILED);

this->mKeyMapState = KeyMapState(mapShm);

munmap(mapShm, size);
close(fd);

this->mVirturalKeyboard =
VirtualKeyboardManager::instance()->createVirtualKeyboard(this->mKeyMapState);
this->mKeyState = std::vector<KeyState>(
this->mKeyMapState.maxKeycode() - this->mKeyMapState.minKeycode() - WAYLAND_KEY_OFFSET,
KeyState::RELEASED
);

// Tell the text input to release all the keys
for (xkb_keycode_t key = 0; key < this->mKeyState.size(); ++key) {
this->mVirturalKeyboard->sendKey(
key + this->mKeyMapState.minKeycode(),
WL_KEYBOARD_KEY_STATE_RELEASED
);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at the private header QXkbCommon, it doesn't have any functions that would be useful here.

If you think there is a particular function I should be using then please tell me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants