Skip to content

Commit

Permalink
Allow Wayland to paste using middlemouse button
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterkepley committed Sep 3, 2024
1 parent e2dd56b commit ddf7fbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scene/gui/line_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
if (is_middle_mouse_paste_enabled() && b->is_pressed() && b->get_button_index() == MouseButton::MIDDLE && is_editable() && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CLIPBOARD_PRIMARY)) {
String paste_buffer = DisplayServer::get_singleton()->clipboard_get_primary().strip_escapes();

if (DisplayServer::get_singleton()->get_name() == "Wayland") {
paste_buffer = DisplayServer::get_singleton()->clipboard_get();
}

deselect();
set_caret_at_pixel_pos(b->get_position().x);
if (!paste_buffer.is_empty()) {
Expand Down
4 changes: 4 additions & 0 deletions scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7227,6 +7227,10 @@ void TextEdit::_paste_primary_clipboard_internal(int p_caret) {

String paste_buffer = DisplayServer::get_singleton()->clipboard_get_primary();

if (DisplayServer::get_singleton()->get_name() == "Wayland") {
paste_buffer = DisplayServer::get_singleton()->clipboard_get();
}

if (get_caret_count() == 1) {
Point2i pos = get_line_column_at_pos(get_local_mouse_pos());
deselect();
Expand Down

0 comments on commit ddf7fbe

Please sign in to comment.