Fix rich text being pasted by Ctrl+V in plain text embedded composers

This restores normal key handling MainWindow:key_press_event when a
keyboard modifier (Ctrl, Shift, etc) is down, keeping the ordering hack
only for plain key presses, so that we can handle Ctrl+V before
WebKitGTK does, and hence letting us paste plain text default when rich
text is not enabled.

Fixes Bug 730495.
This commit is contained in:
Michael James Gratton 2018-07-26 11:15:51 +10:00
parent c9b25e25ec
commit ae6aed8ae6
2 changed files with 26 additions and 13 deletions

View file

@ -248,6 +248,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
return scrollbar != null && scrollbar.get_visible();
}
/** {@inheritDoc} */
public override bool key_press_event(Gdk.EventKey event) {
check_shift_event(event);
@ -286,16 +287,35 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
* [0] - <https://bugs.webkit.org/show_bug.cgi?id=136430>
*/
bool handled = propagate_key_event(event);
if (!handled) {
handled = activate_key(event);
}
if (!handled) {
handled = Gtk.bindings_activate_event(this, event);
bool handled = false;
if (event.state != 0 &&
event.state != Gdk.ModifierType.SHIFT_MASK) {
// Have a modifier (Ctrl, Alt, etc) so we don't need to
// worry about SKCs, so handle normally. Can't do this
// with Shift though since that will stop chars being
// typed in the composer that conflict with accells, like
// `!`.
handled = base.key_press_event(event);
} else {
// A modifier we don't care about is down is down, so
// kluge input handling to make SKCs per the above.
handled = propagate_key_event(event);
if (!handled) {
handled = activate_key(event);
}
if (!handled) {
handled = Gtk.bindings_activate_event(this, event);
}
}
return handled;
}
/** {@inheritDoc} */
public override bool key_release_event(Gdk.EventKey event) {
check_shift_event(event);
return base.key_release_event(event);
}
private void on_conversation_monitor_changed() {
ConversationListStore? old_model = this.conversation_list_view.get_model();
if (old_model != null) {
@ -432,12 +452,6 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
}
}
[GtkCallback]
private bool on_key_release_event(Gdk.EventKey event) {
check_shift_event(event);
return Gdk.EVENT_PROPAGATE;
}
[GtkCallback]
private bool on_focus_event() {
on_shift_key(false);

View file

@ -9,7 +9,6 @@
<property name="show_menubar">False</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
<signal name="focus-in-event" handler="on_focus_event" swapped="no"/>
<signal name="key-release-event" handler="on_key_release_event" swapped="no"/>
<child>
<object class="GtkOverlay" id="overlay">
<property name="visible">True</property>