Refactor: Merge KeyInputEvent and KeyEvent

Both structure are bascially the same and only used internally, no need
to have the two.

The only difference was that one had the modifiers and the other one
not. But we can just set the modifier at the point we were converting
between the two.
This commit is contained in:
Olivier Goffart 2023-11-01 13:59:59 +01:00
parent bebec49398
commit 1efd83621d
6 changed files with 28 additions and 57 deletions

View file

@ -177,12 +177,6 @@ public:
cbindgen_private::slint_windowrc_set_physical_size(&inner, &size);
}
void dispatch_key_event(const cbindgen_private::KeyInputEvent &event)
{
private_api::assert_main_thread();
cbindgen_private::slint_windowrc_dispatch_key_event(&inner, &event);
}
/// Send a pointer event to this window
void dispatch_pointer_event(const cbindgen_private::MouseEvent &event)
{
@ -333,9 +327,9 @@ public:
/// The \a text is the unicode representation of the key.
void dispatch_key_press_event(const SharedString &text)
{
cbindgen_private::KeyInputEvent event { text, cbindgen_private::KeyEventType::KeyPressed, 0,
0 };
inner.dispatch_key_event(event);
private_api::assert_main_thread();
cbindgen_private::slint_windowrc_dispatch_key_event(
&inner.handle(), cbindgen_private::KeyEventType::KeyPressed, &text);
}
/// Dispatch a key release event to the scene.
@ -345,9 +339,9 @@ public:
/// The \a text is the unicode representation of the key.
void dispatch_key_release_event(const SharedString &text)
{
cbindgen_private::KeyInputEvent event { text, cbindgen_private::KeyEventType::KeyReleased,
0, 0 };
inner.dispatch_key_event(event);
private_api::assert_main_thread();
cbindgen_private::slint_windowrc_dispatch_key_event(
&inner.handle(), cbindgen_private::KeyEventType::KeyReleased, &text);
}
/// Dispatches a pointer or mouse press event to the scene.