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.
This commit is contained in:
parent
10f4b80ef0
commit
b32adf7cd9
3 changed files with 15 additions and 18 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue