Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Sebastian Urban <surban@surban.net>
Athaariq Ardhiansyah <foss@athaariq.my.id>
Anton Sakhon <kofhein@gmail.com>
Bari Rao <bari.rao@gmail.com>
Jón Bjarni Bjarnason <jon@centroid.is>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <functional>
#include <string>
#include <cstdint>
Copy link
Author

Choose a reason for hiding this comment

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

clang 20 was complaining of missing type name uint8_t


namespace flutter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <memory>
#include <string>
#include <vector>
#include <cstdint>

namespace flutter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ void TextInputPlugin::HandleMethodCall(
const std::string& method = method_call.method_name();

if (method.compare(kShowMethod) == 0) {
delegate_->UpdateVirtualKeyboardStatus(true);
delegate_->UpdateVirtualKeyboardStatus(true, input_type_);
} else if (method.compare(kHideMethod) == 0) {
delegate_->UpdateVirtualKeyboardStatus(false);
delegate_->UpdateVirtualKeyboardStatus(false, input_type_);
} else if (method.compare(kClearClientMethod) == 0) {
active_model_ = nullptr;
} else if (method.compare(kSetClientMethod) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ class ELinuxWindowDrm : public ELinuxWindow, public WindowBindingHandler {
}

// |FlutterWindowBindingHandler|
void UpdateVirtualKeyboardStatus(const bool show) override {
void UpdateVirtualKeyboardStatus(const bool show,
const std::string& input_type = "") override {
// currently not supported.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ ELinuxWindowWayland::ELinuxWindowWayland(
wl_data_offer_(nullptr),
wl_data_source_(nullptr),
serial_(0),
text_input_serial_(0),
zwp_text_input_manager_v1_(nullptr),
zwp_text_input_manager_v3_(nullptr),
zwp_text_input_v1_(nullptr),
Expand Down Expand Up @@ -1505,12 +1506,15 @@ void ELinuxWindowWayland::DestroyRenderSurface() {
}
}

void ELinuxWindowWayland::UpdateVirtualKeyboardStatus(const bool show) {
void ELinuxWindowWayland::UpdateVirtualKeyboardStatus(
const bool show,
const std::string& input_type) {
// Not supported virtual keyboard.
if (!(zwp_text_input_v1_ || zwp_text_input_v3_) || seat_inputs_map_.empty()) {
return;
}

text_input_type_ = input_type;
is_requested_show_virtual_keyboard_ = show;
if (is_requested_show_virtual_keyboard_) {
ShowVirtualKeyboard();
Expand Down Expand Up @@ -1869,16 +1873,52 @@ void ELinuxWindowWayland::ShowVirtualKeyboard() {
zwp_text_input_v3_enable(zwp_text_input_v3_);
zwp_text_input_v3_commit(zwp_text_input_v3_);

zwp_text_input_v3_set_content_type(
zwp_text_input_v3_, ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE,
ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL);
// Map Flutter input types to Wayland content purposes.
uint32_t hint = ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE;
uint32_t purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL;

if (text_input_type_ == "TextInputType.number") {
purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER;
} else if (text_input_type_ == "TextInputType.phone") {
purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE;
} else if (text_input_type_ == "TextInputType.emailAddress") {
purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_EMAIL;
} else if (text_input_type_ == "TextInputType.url") {
purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_URL;
} else if (text_input_type_ == "TextInputType.visiblePassword") {
purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PASSWORD;
} else if (text_input_type_ == "TextInputType.multiline") {
hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_MULTILINE;
}

zwp_text_input_v3_set_content_type(zwp_text_input_v3_, hint, purpose); // Untested code path
zwp_text_input_v3_commit(zwp_text_input_v3_);
} else {
if (native_window_) {
zwp_text_input_v1_show_input_panel(zwp_text_input_v1_);
// Map Flutter input types to Wayland v1 content purposes.
uint32_t hint = ZWP_TEXT_INPUT_V1_CONTENT_HINT_NONE;
uint32_t purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NORMAL;

if (text_input_type_ == "TextInputType.number") {
purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NUMBER;
} else if (text_input_type_ == "TextInputType.phone") {
purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PHONE;
} else if (text_input_type_ == "TextInputType.emailAddress") {
purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_EMAIL;
} else if (text_input_type_ == "TextInputType.url") {
purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_URL;
} else if (text_input_type_ == "TextInputType.visiblePassword") {
purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PASSWORD;
} else if (text_input_type_ == "TextInputType.multiline") {
hint |= ZWP_TEXT_INPUT_V1_CONTENT_HINT_MULTILINE;
}

zwp_text_input_v1_activate(zwp_text_input_v1_,
seat_inputs_map_.begin()->first,
native_window_->Surface());
zwp_text_input_v1_set_content_type(zwp_text_input_v1_, hint, purpose);
zwp_text_input_v1_commit_state(zwp_text_input_v1_, ++text_input_serial_);
zwp_text_input_v1_show_input_panel(zwp_text_input_v1_);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class ELinuxWindowWayland : public ELinuxWindow, public WindowBindingHandler {
void UpdateFlutterCursor(const std::string& cursor_name) override;

// |FlutterWindowBindingHandler|
void UpdateVirtualKeyboardStatus(const bool show) override;
void UpdateVirtualKeyboardStatus(const bool show,
const std::string& input_type = "") override;

// |FlutterWindowBindingHandler|
std::string GetClipboardData() override;
Expand Down Expand Up @@ -215,6 +216,11 @@ class ELinuxWindowWayland : public ELinuxWindow, public WindowBindingHandler {
wl_data_source* wl_data_source_;
uint32_t wl_data_device_manager_version_;
uint32_t serial_;

// The current text input type (e.g., "TextInputType.number").
std::string text_input_type_;

uint32_t text_input_serial_;
};

} // namespace flutter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ void ELinuxWindowX11::UpdateFlutterCursor(const std::string& cursor_name) {
// TODO: implement here
}

void ELinuxWindowX11::UpdateVirtualKeyboardStatus(const bool show) {
void ELinuxWindowX11::UpdateVirtualKeyboardStatus(
const bool show,
const std::string& input_type) {
// currently not supported.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class ELinuxWindowX11 : public ELinuxWindow, public WindowBindingHandler {
void UpdateFlutterCursor(const std::string& cursor_name) override;

// |FlutterWindowBindingHandler|
void UpdateVirtualKeyboardStatus(const bool show) override;
void UpdateVirtualKeyboardStatus(const bool show,
const std::string& input_type = "") override;

// |FlutterWindowBindingHandler|
std::string GetClipboardData() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ class WindowBindingHandler {

// Sets the virtual keyboard status when the virtual keyboard needs to be
// shown by Flutter events.
virtual void UpdateVirtualKeyboardStatus(const bool show) = 0;
// @param[in] show Whether to show or hide the virtual keyboard.
// @param[in] input_type The Flutter input type (e.g., "TextInputType.number").
virtual void UpdateVirtualKeyboardStatus(const bool show,
const std::string& input_type = "") = 0;

// Returns the clipboard data.
virtual std::string GetClipboardData() = 0;
Expand Down