diff --git a/README.md b/README.md index 8eb7998..65b800c 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,13 @@ Install : 5. Enable the extension in Gnome-tweak-tool 6. `Super + Alt + D` to test 7. [https://framagit.org/abakkk/DrawOnYourScreen/issues](https://framagit.org/abakkk/DrawOnYourScreen/issues) to say it doesn't work + + +Details : +--------- + + * Screenshot Tool extension: + + + [Screenshot Tool](https://extensions.gnome.org/extension/1112/screenshot-tool/) is a convenient extension to “create, copy, store and upload screenshots”. To use it while drawing mode is active, toggle the area selection mode thanks to the Screenshot Tool shortcut (`Super + F11` by default, see its preferences) and **hold** the `space` key when selecting the area with pointer to avoid drawing. + diff --git a/draw.js b/draw.js index e3f283b..7a4cfe1 100644 --- a/draw.js +++ b/draw.js @@ -213,6 +213,9 @@ var DrawingArea = new Lang.Class({ }, _onButtonPressed: function(actor, event) { + if (this.spaceKeyPressed) + return Clutter.EVENT_PROPAGATE; + let button = event.get_button(); let [x, y] = event.get_coords(); let shiftPressed = event.has_shift_modifier(); @@ -250,6 +253,20 @@ var DrawingArea = new Lang.Class({ return Clutter.EVENT_STOP; }, + _onStageKeyPressed: function(actor, event) { + if (event.get_key_symbol() == Clutter.KEY_space) + this.spaceKeyPressed = true; + + return Clutter.EVENT_PROPAGATE; + }, + + _onStageKeyReleased: function(actor, event) { + if (event.get_key_symbol() == Clutter.KEY_space) + this.spaceKeyPressed = false; + + return Clutter.EVENT_PROPAGATE; + }, + _onKeyPressed: function(actor, event) { if (event.get_key_symbol() == Clutter.Escape) { this.emit('stop-drawing'); @@ -332,6 +349,9 @@ var DrawingArea = new Lang.Class({ } this.motionHandler = this.connect('motion-event', (actor, event) => { + if (this.spaceKeyPressed) + return; + let coords = event.get_coords(); let [s, x, y] = this.transform_stage_point(coords[0], coords[1]); if (!s) @@ -579,7 +599,9 @@ var DrawingArea = new Lang.Class({ }, enterDrawingMode: function() { - this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this)); + this.stageKeyPressedHandler = global.stage.connect('key-press-event', this._onStageKeyPressed.bind(this)); + this.stageKeyReleasedHandler = global.stage.connect('key-release-event', this._onStageKeyReleased.bind(this)); + this.keyPressedHandler = this.connect('key-press-event', this._onKeyPressed.bind(this)); this.buttonPressedHandler = this.connect('button-press-event', this._onButtonPressed.bind(this)); this._onKeyboardPopupMenuHandler = this.connect('popup-menu', this._onKeyboardPopupMenu.bind(this)); this.scrollHandler = this.connect('scroll-event', this._onScroll.bind(this)); @@ -588,6 +610,14 @@ var DrawingArea = new Lang.Class({ }, leaveDrawingMode: function(save) { + if (this.stageKeyPressedHandler) { + global.stage.disconnect(this.stageKeyPressedHandler); + this.stageKeyPressedHandler = null; + } + if (this.stageKeyReleasedHandler) { + global.stage.disconnect(this.stageKeyReleasedHandler); + this.stageKeyReleasedHandler = null; + } if (this.keyPressedHandler) { this.disconnect(this.keyPressedHandler); this.keyPressedHandler = null; diff --git a/locale/draw-on-your-screen.pot b/locale/draw-on-your-screen.pot index 7b0092f..f41e436 100644 --- a/locale/draw-on-your-screen.pot +++ b/locale/draw-on-your-screen.pot @@ -262,6 +262,12 @@ msgstr "" msgid "Shift key held" msgstr "" +msgid "Ignore pointer movement" +msgstr "" + +msgid "Space key held" +msgstr "" + msgid "Leave" msgstr "" diff --git a/prefs.js b/prefs.js index 7b13a52..6f534cd 100644 --- a/prefs.js +++ b/prefs.js @@ -83,6 +83,7 @@ var OTHER_SHORTCUTS = [ { desc: "Increment/decrement line width", shortcut: "Scroll" }, { desc: "Select color", shortcut: "Ctrl+1...9" }, { desc: "Select eraser", shortcut: "Shift key held" }, + { desc: "Ignore pointer movement", shortcut: "Space key held" }, { desc: "Leave", shortcut: "Escape key" } ];