Updated Files
birdfont/GtkWindow.vala |
libbirdfont/Renderer/TextArea.vala |
libbirdfont/TableLayout.vala |
libbirdfont/Widget.vala |
--- a/birdfont/GtkWindow.vala
+++ b/birdfont/GtkWindow.vala
@@ -689,9 +689,7 @@
event_flags |= EventMask.SCROLL_MASK;
add_events (event_flags);
-
- bool button_down = false;
-
+
glyph_canvas.signal_redraw_area.connect ((x, y, w, h) => {
queue_draw_area ((int)x, (int)y, (int)w, (int)h);
});
@@ -725,10 +723,6 @@
button_press_event.connect ((t, e)=> {
GtkWindow.reset_modifier (e.state);
- if (button_down) {
- warning (@"Button already is down. $(e.button)");
- }
-
if (e.time < last_press) {
warning ("Discarding event.");
return true;
@@ -738,7 +732,6 @@
if (e.type == EventType.BUTTON_PRESS) {
TabContent.button_press (e.button, e.x, e.y);
- button_down = true;
} else if (e.type == EventType.2BUTTON_PRESS) {
TabContent.double_click (e.button, e.x, e.y);
}
@@ -747,10 +740,6 @@
});
button_release_event.connect ((t, e)=> {
- if (!button_down) {
- warning (@"Button is not down $(e.button)");
- }
-
if (e.time < last_release) {
warning ("Discarding event.");
return true;
@@ -758,9 +747,9 @@
if (e.type == EventType.BUTTON_RELEASE) {
TabContent.button_release ((int) e.button, e.x, e.y);
- last_release = e.time;
- button_down = false;
}
+
+ last_release = e.time;
return true;
});
--- a/libbirdfont/Renderer/TextArea.vala
+++ b/libbirdfont/Renderer/TextArea.vala
@@ -1658,9 +1658,47 @@
c.desired_y = desired_y;
return c;
+ }
+ }
+
+ public override void double_click (uint button, double x, double y) {
+ if (is_over (x, y)) {
+ carret = get_carret_at (x, y);
+
+ Paragraph paragraph = paragraphs.get (carret.paragraph);
+
+ int index = carret.character_index;
+ int prev_index = index;
+ unichar c;
+
+ while (paragraph.text.get_prev_char (ref index, out c)) {
+ if (c == '\t' || c == ' ' || c == '\n') {
+ break;
+ }
+
+ prev_index = index;
+ }
+
+ carret.character_index = prev_index;
+
+ selection_end = carret.copy ();
+ index = selection_end.character_index;
+
+ while (paragraph.text.get_next_char (ref index, out c)) {
+ if (c == '\t' || c == ' ' || c == '\n') {
+ break;
+ }
+
+ prev_index = index;
+ }
+
+ selection_end.character_index = prev_index;
+ show_selection = selection_is_visible ();
+
+ update_selection = true;
}
}
}
}
--- a/libbirdfont/TableLayout.vala
+++ b/libbirdfont/TableLayout.vala
@@ -25,7 +25,8 @@
public Gee.ArrayList<Widget> widgets = new Gee.ArrayList<Widget> ();
public Gee.ArrayList<Widget> focus_ring = new Gee.ArrayList<Widget> ();
public int focus_index = 0;
-
+ bool ignore_input = true;
+
public Widget? keyboard_focus = null;
public TableLayout () {
@@ -125,6 +126,11 @@
Widget t;
Widget old;
CheckBox c;
+
+ if (ignore_input) {
+ printd (@"Ignoring extra clicks.");
+ return;
+ }
foreach (Widget w in widgets) {
if (w.is_over (x, y)) {
@@ -172,6 +178,11 @@
public override void button_release (int button, double x, double y) {
Widget t;
+
+ if (ignore_input) {
+ printd (@"Ignoring extra clicks.");
+ return;
+ }
if (keyboard_focus != null) {
t = (!) keyboard_focus;
@@ -231,6 +242,15 @@
}
public override void selected_canvas () {
+ ignore_input = true;
+
+ TimeoutSource input_delay = new TimeoutSource (250);
+ input_delay.set_callback(() => {
+ ignore_input = false;
+ return false;
+ });
+ input_delay.attach (null);
+
KeyBindings.set_require_modifier (true);
update_scrollbar ();
GlyphCanvas.redraw ();
@@ -250,8 +270,31 @@
public override bool needs_modifier () {
return true;
+ }
+
+ public override void double_click (uint button, double x, double y) {
+ Widget t;
+
+ if (ignore_input) {
+ printd (@"Ignoring extra clicks.");
+ return;
+ }
+
+ if (keyboard_focus != null) {
+ t = (!) keyboard_focus;
+ set_focus (t);
+ t.double_click (button, x, y);
+ }
+
+ foreach (Widget w in widgets) {
+ if (w.is_over (x, y)) {
+ w.double_click (button, x, y);
+ }
+ }
+
+ GlyphCanvas.redraw ();
}
}
}
--- a/libbirdfont/Widget.vala
+++ b/libbirdfont/Widget.vala
@@ -68,6 +68,9 @@
public virtual void button_release (uint button, double x, double y) {
}
+
+ public virtual void double_click (uint button, double x, double y) {
+ }
public virtual bool motion (double x, double y) {
return false;