toggle modeless / modal
Keybinding to ungrab keyboard and mouse while drawing remains at the top. To be aware that this create some problems with the shell (DnD #1 and maybe more ?). related to #6, #9, #20, #24, #33
This commit is contained in:
parent
3c14f72f56
commit
98832cec72
5
draw.js
5
draw.js
|
|
@ -691,6 +691,11 @@ var DrawingArea = new Lang.Class({
|
||||||
this.setPointerCursor('MOVE_OR_RESIZE_WINDOW');
|
this.setPointerCursor('MOVE_OR_RESIZE_WINDOW');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initPointerCursor: function() {
|
||||||
|
this.currentPointerCursorName = null;
|
||||||
|
this.updatePointerCursor();
|
||||||
|
},
|
||||||
|
|
||||||
_stopTextCursorTimeout: function() {
|
_stopTextCursorTimeout: function() {
|
||||||
if (this.textCursorTimeoutId) {
|
if (this.textCursorTimeoutId) {
|
||||||
GLib.source_remove(this.textCursorTimeoutId);
|
GLib.source_remove(this.textCursorTimeoutId);
|
||||||
|
|
|
||||||
96
extension.js
96
extension.js
|
|
@ -86,6 +86,12 @@ var AreaManager = new Lang.Class({
|
||||||
Shell.ActionMode.ALL,
|
Shell.ActionMode.ALL,
|
||||||
this.eraseDrawing.bind(this));
|
this.eraseDrawing.bind(this));
|
||||||
|
|
||||||
|
Main.wm.addKeybinding('toggle-modal',
|
||||||
|
this.settings,
|
||||||
|
Meta.KeyBindingFlags.NONE,
|
||||||
|
Shell.ActionMode.ALL,
|
||||||
|
this.toggleModal.bind(this));
|
||||||
|
|
||||||
this.updateAreas();
|
this.updateAreas();
|
||||||
this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this));
|
this.monitorChangedHandler = Main.layoutManager.connect('monitors-changed', this.updateAreas.bind(this));
|
||||||
|
|
||||||
|
|
@ -306,53 +312,78 @@ var AreaManager = new Lang.Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleDrawing: function() {
|
toggleContainer: function() {
|
||||||
if (this.activeArea) {
|
if (!this.activeArea)
|
||||||
let activeIndex = this.areas.indexOf(this.activeArea);
|
return;
|
||||||
let activeContainer = this.activeArea.get_parent();
|
|
||||||
let save = activeIndex == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
|
let activeContainer = this.activeArea.get_parent();
|
||||||
|
let activeIndex = this.areas.indexOf(this.activeArea);
|
||||||
if (this.hiddenList)
|
|
||||||
this.togglePanelAndDockOpacity();
|
if (activeContainer.get_parent() == Main.uiGroup) {
|
||||||
|
Main.uiGroup.remove_actor(activeContainer);
|
||||||
setCursor('DEFAULT');
|
|
||||||
if (!this.osdDisabled)
|
|
||||||
this.showOsd(null, this.leaveGicon, _("Leaving drawing mode"));
|
|
||||||
|
|
||||||
Main.popModal(this.activeArea);
|
|
||||||
this.removeInternalKeybindings();
|
|
||||||
this.activeArea.reactive = false;
|
|
||||||
this.activeArea.leaveDrawingMode(save);
|
|
||||||
this.activeArea = null;
|
|
||||||
|
|
||||||
activeContainer.get_parent().remove_actor(activeContainer);
|
|
||||||
Main.layoutManager._backgroundGroup.insert_child_above(activeContainer, Main.layoutManager._bgManagers[activeIndex].backgroundActor);
|
Main.layoutManager._backgroundGroup.insert_child_above(activeContainer, Main.layoutManager._bgManagers[activeIndex].backgroundActor);
|
||||||
if (!this.settings.get_boolean("drawing-on-desktop"))
|
if (!this.settings.get_boolean("drawing-on-desktop"))
|
||||||
activeContainer.hide();
|
activeContainer.hide();
|
||||||
} else {
|
} else {
|
||||||
// avoid to deal with Meta changes (global.display/global.screen)
|
Main.layoutManager._backgroundGroup.remove_actor(activeContainer);
|
||||||
let currentIndex = Main.layoutManager.monitors.indexOf(Main.layoutManager.currentMonitor);
|
|
||||||
let activeContainer = this.areas[currentIndex].get_parent();
|
|
||||||
|
|
||||||
activeContainer.get_parent().remove_actor(activeContainer);
|
|
||||||
Main.uiGroup.add_child(activeContainer);
|
Main.uiGroup.add_child(activeContainer);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleModal: function() {
|
||||||
|
if (!this.activeArea)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Main.actionMode & DRAWING_ACTION_MODE) {
|
||||||
|
Main.popModal(this.activeArea);
|
||||||
|
setCursor('DEFAULT');
|
||||||
|
this.activeArea.reactive = false;
|
||||||
|
this.removeInternalKeybindings();
|
||||||
|
} else {
|
||||||
// add Shell.ActionMode.NORMAL to keep system keybindings enabled (e.g. Alt + F2 ...)
|
// add Shell.ActionMode.NORMAL to keep system keybindings enabled (e.g. Alt + F2 ...)
|
||||||
if (!Main.pushModal(this.areas[currentIndex], { actionMode: DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL }))
|
if (!Main.pushModal(this.activeArea, { actionMode: DRAWING_ACTION_MODE | Shell.ActionMode.NORMAL }))
|
||||||
return;
|
return false;
|
||||||
this.activeArea = this.areas[currentIndex];
|
|
||||||
this.addInternalKeybindings();
|
this.addInternalKeybindings();
|
||||||
this.activeArea.reactive = true;
|
this.activeArea.reactive = true;
|
||||||
this.activeArea.enterDrawingMode();
|
this.activeArea.initPointerCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleDrawing: function() {
|
||||||
|
if (this.activeArea) {
|
||||||
|
let activeIndex = this.areas.indexOf(this.activeArea);
|
||||||
|
let save = activeIndex == Main.layoutManager.primaryIndex && this.settings.get_boolean('persistent-drawing');
|
||||||
|
|
||||||
setCursor('POINTING_HAND');
|
this.showOsd(null, this.leaveGicon, _("Leaving drawing mode"));
|
||||||
|
this.activeArea.leaveDrawingMode(save);
|
||||||
|
if (this.hiddenList)
|
||||||
|
this.togglePanelAndDockOpacity();
|
||||||
|
|
||||||
|
if (Main.actionMode & DRAWING_ACTION_MODE)
|
||||||
|
this.toggleModal();
|
||||||
|
this.toggleContainer();
|
||||||
|
this.activeArea = null;
|
||||||
|
} else {
|
||||||
|
// avoid to deal with Meta changes (global.display/global.screen)
|
||||||
|
let currentIndex = Main.layoutManager.monitors.indexOf(Main.layoutManager.currentMonitor);
|
||||||
|
this.activeArea = this.areas[currentIndex];
|
||||||
|
this.toggleContainer();
|
||||||
|
if (!this.toggleModal()) {
|
||||||
|
this.toggleContainer();
|
||||||
|
this.activeArea = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activeArea.enterDrawingMode();
|
||||||
this.osdDisabled = this.settings.get_boolean('osd-disabled');
|
this.osdDisabled = this.settings.get_boolean('osd-disabled');
|
||||||
let label = _("<small>Press <i>%s</i> for help</small>").format(this.activeArea.helper.helpKeyLabel) + "\n\n" + _("Entering drawing mode");
|
let label = _("<small>Press <i>%s</i> for help</small>").format(this.activeArea.helper.helpKeyLabel) + "\n\n" + _("Entering drawing mode");
|
||||||
this.showOsd(null, this.enterGicon, label, null, null, true);
|
this.showOsd(null, this.enterGicon, label, null, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.indicator)
|
if (this.indicator)
|
||||||
this.indicator.sync(this.activeArea != null);
|
this.indicator.sync(Boolean(this.activeArea));
|
||||||
},
|
},
|
||||||
|
|
||||||
// Use level -1 to set no level through a signal.
|
// Use level -1 to set no level through a signal.
|
||||||
|
|
@ -482,6 +513,7 @@ var AreaManager = new Lang.Class({
|
||||||
this.toggleDrawing();
|
this.toggleDrawing();
|
||||||
Main.wm.removeKeybinding('toggle-drawing');
|
Main.wm.removeKeybinding('toggle-drawing');
|
||||||
Main.wm.removeKeybinding('erase-drawing');
|
Main.wm.removeKeybinding('erase-drawing');
|
||||||
|
Main.wm.removeKeybinding('toggle-modal');
|
||||||
this.removeAreas();
|
this.removeAreas();
|
||||||
if (this.indicator)
|
if (this.indicator)
|
||||||
this.indicator.disable();
|
this.indicator.disable();
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,9 @@ msgstr ""
|
||||||
msgid "Erase all drawings"
|
msgid "Erase all drawings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Toggle modeless/modal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: INTERNAL_KEYBINDINGS
|
#: INTERNAL_KEYBINDINGS
|
||||||
|
|
||||||
msgid "Undo last brushstroke"
|
msgid "Undo last brushstroke"
|
||||||
|
|
|
||||||
3
prefs.js
3
prefs.js
|
|
@ -37,7 +37,8 @@ const MARGIN = 10;
|
||||||
|
|
||||||
var GLOBAL_KEYBINDINGS = {
|
var GLOBAL_KEYBINDINGS = {
|
||||||
'toggle-drawing': "Enter/leave drawing mode",
|
'toggle-drawing': "Enter/leave drawing mode",
|
||||||
'erase-drawing': "Erase all drawings"
|
'erase-drawing': "Erase all drawings",
|
||||||
|
'toggle-modal': "Toggle modeless/modal"
|
||||||
};
|
};
|
||||||
|
|
||||||
var INTERNAL_KEYBINDINGS = {
|
var INTERNAL_KEYBINDINGS = {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -31,6 +31,11 @@
|
||||||
<summary>erase drawing</summary>
|
<summary>erase drawing</summary>
|
||||||
<description>erase drawing</description>
|
<description>erase drawing</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key type="as" name="toggle-modal">
|
||||||
|
<default>["<Primary><Alt><Super>d"]</default>
|
||||||
|
<summary>toggle modeless/modal</summary>
|
||||||
|
<description>toggle modeless/modal</description>
|
||||||
|
</key>
|
||||||
<key type="as" name="undo">
|
<key type="as" name="undo">
|
||||||
<default>["<Primary>z"]</default>
|
<default>["<Primary>z"]</default>
|
||||||
<summary>undo</summary>
|
<summary>undo</summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue