The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Reset modifiers when key up is sent to another window

These changes was commited to the Birdfont repository Tue, 28 Apr 2015 06:11:53 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 28 Apr 2015 06:11:53 +0000 (08:11 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Tue, 28 Apr 2015 06:42:29 +0000 (08:42 +0200)
commit d03d2eb8a0fc65525558a07a36ce475fa6d6d371
tree b826db474288aedf785351e2a0d4290f1266e27b
parent 64695ef5a09ec4bb3afb8952cd2cad46923fa274
Reset modifiers when key up is sent to another window

birdfont/GtkWindow.vala
libbirdfont/DrawingTools.vala
libbirdfont/StrokeTool.vala
--- a/birdfont/GtkWindow.vala +++ b/birdfont/GtkWindow.vala @@ -71,7 +71,9 @@ description = new DescriptionForm (); clipboard = Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); - + + Signal.connect(this, "notify::is-active", (GLib.Callback) window_focus, null); + scrollbar.value_changed.connect (() => { double p; @@ -184,6 +186,7 @@ key_press_event.connect ((t, event) => { if (!GtkWindow.text_input_is_active) { + GtkWindow.reset_modifier (event.state); TabContent.key_press (event.keyval); } @@ -208,6 +211,32 @@ MainWindow.open_recent_files_tab (); } + public void window_focus (void* data) { + TabContent.key_release ((uint) ' '); + } + + public static void reset_modifier (ModifierType flags) { + if ((flags & ModifierType.CONTROL_MASK) == 0) { + TabContent.key_release (Key.CTRL_RIGHT); + TabContent.key_release (Key.CTRL_LEFT); + } + + if ((flags & ModifierType.SHIFT_MASK) == 0) { + TabContent.key_release (Key.SHIFT_LEFT); + TabContent.key_release (Key.SHIFT_RIGHT); + } + + if ((flags & ModifierType.MOD1_MASK) == 0) { + TabContent.key_release (Key.ALT_LEFT); + TabContent.key_release (Key.ALT_RIGHT); + } + + if ((flags & ModifierType.MOD5_MASK) == 0) { + TabContent.key_release (Key.LOGO_LEFT); + TabContent.key_release (Key.LOGO_RIGHT); + } + } + public void font_loaded () { Font f = BirdFont.get_current_font (); set_title (@"$(f.full_name)"); @@ -663,6 +692,7 @@ button_press_event.connect ((t, e)=> { Gtk.Allocation alloc; get_allocation (out alloc); + GtkWindow.reset_modifier (e.state); tabbar.select_tab_click (e.x, e.y, alloc.width, alloc.height); queue_draw_area (0, 0, alloc.width, alloc.height); return true; @@ -820,12 +850,14 @@ }); button_press_event.connect ((t, e)=> { + GtkWindow.reset_modifier (e.state); + if (e.type == EventType.BUTTON_PRESS) { TabContent.button_press (e.button, e.x, e.y); } else if (e.type == EventType.2BUTTON_PRESS) { TabContent.double_click (e.button, e.x, e.y); } - + return true; });
--- a/libbirdfont/DrawingTools.vala +++ b/libbirdfont/DrawingTools.vala @@ -756,6 +756,7 @@ object_stroke = new SpinButton ("object_stroke", t_("Stroke width")); object_stroke.set_value_round (2); object_stroke.set_int_step (0.015); + object_stroke.set_big_number (true); object_stroke.new_value_action.connect((self) => { Font f;
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -1776,7 +1776,7 @@ l = p2.get_left_handle (); r = p2.get_right_handle (); - if (fabs (l.angle - r.angle - PI) % 2 * PI > 0.0001) { + if (fabs (l.angle + r.angle - PI) % 2 * PI > 0.0001) { if (!path.is_open () || i < size - 1) { get_segment (thickness, 0, 0.001, p2, p3, out start); add_corner (side1, previous, start, p2.copy (), thickness);