Allow to cancel screenshot when pressing ESC (#463)

This commit is contained in:
Peter Uithoven 2019-02-07 17:02:37 +01:00 committed by Rico Tzschichholz
parent bbd5963da5
commit df0022c4b8
2 changed files with 10 additions and 2 deletions

View File

@ -139,6 +139,10 @@ namespace Gala
yield;
selection_area.destroy ();
if (selection_area.cancelled) {
throw new GLib.IOError.CANCELLED ("Operation was cancelled");
}
yield wait_stage_repaint ();
selection_area.get_selection_rectangle (out x, out y, out width, out height);
}

View File

@ -16,13 +16,15 @@
//
namespace Gala
{
{
public class SelectionArea : Clutter.Actor
{
public signal void closed ();
public WindowManager wm { get; construct; }
public bool cancelled { get; private set; }
private ModalProxy? modal_proxy;
private Gdk.Point start_point;
private Gdk.Point end_point;
@ -58,6 +60,7 @@ namespace Gala
{
if (e.keyval == Clutter.Key.Escape) {
close ();
cancelled = true;
closed ();
return true;
}
@ -87,6 +90,7 @@ namespace Gala
if (!dragging) {
close ();
cancelled = true;
closed ();
return true;
}
@ -167,4 +171,4 @@ namespace Gala
return true;
}
}
}
}