[geary/gnumdk/stable: 11/21] Fix touch input in composer
- From: Cédric Bellegarde <cbellegarde src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/gnumdk/stable: 11/21] Fix touch input in composer
- Date: Mon, 1 Aug 2022 12:45:46 +0000 (UTC)
commit d1f893cc017430a4677023a950d8b9ee2d23b8e6
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Mar 29 21:36:07 2022 +0400
Fix touch input in composer
- button_*_event signals don't handle touch and are pointer-only; use a
GtkGesture. Remove the button_release_event hack in ComposerWebView.
- The row's focus-on-click steals clicks and uses them to focus the row,
stop doing that. Reimplement it for the webview manually.
src/client/composer/composer-editor.vala | 19 +++++++++++++------
src/client/composer/composer-web-view.vala | 12 ------------
.../conversation-viewer/conversation-list-box.vala | 2 ++
3 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/src/client/composer/composer-editor.vala b/src/client/composer/composer-editor.vala
index 9e56f070c..8ae0ec8b1 100644
--- a/src/client/composer/composer-editor.vala
+++ b/src/client/composer/composer-editor.vala
@@ -147,6 +147,8 @@ public class Composer.Editor : Gtk.Grid, Geary.BaseInterface {
[GtkChild] private unowned Gtk.Image font_color_icon;
[GtkChild] private unowned Gtk.MenuButton more_options_button;
+ private Gtk.GestureMultiPress click_gesture;
+
internal signal void insert_image(bool from_clipboard);
@@ -168,7 +170,6 @@ public class Composer.Editor : Gtk.Grid, Geary.BaseInterface {
this.body = new WebView(config);
this.body.command_stack_changed.connect(on_command_state_changed);
- this.body.button_release_event_done.connect(on_button_release);
this.body.context_menu.connect(on_context_menu);
this.body.cursor_context_changed.connect(on_cursor_context_changed);
this.body.get_editor_state().notify["typing-attributes"].connect(on_typing_attributes_changed);
@@ -179,6 +180,10 @@ public class Composer.Editor : Gtk.Grid, Geary.BaseInterface {
this.body.show();
this.body_container.add(this.body);
+ this.click_gesture = new Gtk.GestureMultiPress(this.body);
+ this.click_gesture.pressed.connect(this.on_button_press);
+ this.click_gesture.released.connect(this.on_button_release);
+
this.actions.add_action_entries(ACTIONS, this);
this.actions.change_action_state(
ACTION_TEXT_FORMAT,
@@ -318,17 +323,20 @@ public class Composer.Editor : Gtk.Grid, Geary.BaseInterface {
return this.actions.lookup_action(action_name) as GLib.SimpleAction;
}
- private bool on_button_release(Gdk.Event event) {
+ private void on_button_press(int n_press, double x, double y) {
+ this.body.grab_focus();
+ }
+
+ private void on_button_release(int n_press, double x, double y) {
// Show the link popover on mouse release (instead of press)
// so the user can still select text with a link in it,
// without the popover immediately appearing and raining on
// their text selection parade.
if (this.pointer_url != null &&
this.config.compose_as_html) {
- Gdk.EventButton? button = (Gdk.EventButton) event;
Gdk.Rectangle location = Gdk.Rectangle();
- location.x = (int) button.x;
- location.y = (int) button.y;
+ location.x = (int) x;
+ location.y = (int) y;
this.new_link_popover.begin(
LinkPopover.Type.EXISTING_LINK, this.pointer_url,
@@ -339,7 +347,6 @@ public class Composer.Editor : Gtk.Grid, Geary.BaseInterface {
popover.popup();
});
}
- return Gdk.EVENT_PROPAGATE;
}
private bool on_context_menu(WebKit.WebView view,
diff --git a/src/client/composer/composer-web-view.vala b/src/client/composer/composer-web-view.vala
index 57b7e1e41..8ef501b01 100644
--- a/src/client/composer/composer-web-view.vala
+++ b/src/client/composer/composer-web-view.vala
@@ -140,9 +140,6 @@ public class Composer.WebView : Components.WebView {
/** Emitted when an image file has been dropped on the composer */
public signal void image_file_dropped(string filename, string type, uint8[] contents);
- /** Workaround for WebView eating the button event */
- internal signal bool button_release_event_done(Gdk.Event event);
-
public WebView(Application.Configuration config) {
base(config);
@@ -521,15 +518,6 @@ public class Composer.WebView : Components.WebView {
return flowed.str;
}
- public override bool button_release_event(Gdk.EventButton event) {
- // WebView seems to unconditionally consume button events, so
- // to show a link popopver after the view has processed one,
- // we need to emit our own.
- bool ret = base.button_release_event(event);
- button_release_event_done(event);
- return ret;
- }
-
private void on_cursor_context_changed(GLib.Variant? parameters) {
if (parameters != null && parameters.classify() == STRING) {
cursor_context_changed(new EditContext(parameters as string));
diff --git a/src/client/conversation-viewer/conversation-list-box.vala
b/src/client/conversation-viewer/conversation-list-box.vala
index d23654163..b8a7c0643 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -471,6 +471,8 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
this.view = view;
this.is_expanded = true;
add(this.view);
+
+ this.focus_on_click = false;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]