Merge branch 'dev' into 'master'
v10 Closes #52 See merge request abakkk/DrawOnYourScreen!21
This commit is contained in:
commit
0e6428404e
5
NEWS
5
NEWS
|
|
@ -1,3 +1,8 @@
|
||||||
|
v10 - October 2020
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fix multi-monitor support #52
|
||||||
|
|
||||||
v9 - October 2020
|
v9 - October 2020
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
|
||||||
16
area.js
16
area.js
|
|
@ -123,13 +123,15 @@ var DrawingArea = new Lang.Class({
|
||||||
Name: `${UUID}-DrawingArea`,
|
Name: `${UUID}-DrawingArea`,
|
||||||
Extends: St.Widget,
|
Extends: St.Widget,
|
||||||
Signals: { 'show-osd': { param_types: [Gio.Icon.$gtype, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE, GObject.TYPE_BOOLEAN] },
|
Signals: { 'show-osd': { param_types: [Gio.Icon.$gtype, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_DOUBLE, GObject.TYPE_BOOLEAN] },
|
||||||
|
'pointer-cursor-changed': { param_types: [GObject.TYPE_STRING] },
|
||||||
'update-action-mode': {},
|
'update-action-mode': {},
|
||||||
'leave-drawing-mode': {} },
|
'leave-drawing-mode': {} },
|
||||||
|
|
||||||
_init: function(params, monitor, helper, loadPersistent) {
|
_init: function(params, monitor, helper, areaManagerUtils, loadPersistent) {
|
||||||
this.parent({ style_class: 'draw-on-your-screen', name: params.name});
|
this.parent({ style_class: 'draw-on-your-screen', name: params.name});
|
||||||
this.monitor = monitor;
|
this.monitor = monitor;
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
|
this.areaManagerUtils = areaManagerUtils;
|
||||||
|
|
||||||
this.layerContainer = new St.Widget({ width: monitor.width, height: monitor.height });
|
this.layerContainer = new St.Widget({ width: monitor.width, height: monitor.height });
|
||||||
this.add_child(this.layerContainer);
|
this.add_child(this.layerContainer);
|
||||||
|
|
@ -174,7 +176,7 @@ var DrawingArea = new Lang.Class({
|
||||||
|
|
||||||
get menu() {
|
get menu() {
|
||||||
if (!this._menu)
|
if (!this._menu)
|
||||||
this._menu = new Menu.DrawingMenu(this, this.monitor, Tools);
|
this._menu = new Menu.DrawingMenu(this, this.monitor, Tools, this.areaManagerUtils);
|
||||||
return this._menu;
|
return this._menu;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -390,11 +392,12 @@ var DrawingArea = new Lang.Class({
|
||||||
this.gridLayer.queue_repaint();
|
this.gridLayer.queue_repaint();
|
||||||
},
|
},
|
||||||
|
|
||||||
_transformStagePoint: function(x, y) {
|
_transformStagePoint: function(stageX, stageY) {
|
||||||
if (!this.layerContainer.get_allocation_box().contains(x, y))
|
let [s, x, y] = this.transform_stage_point(stageX, stageY);
|
||||||
|
if (!s || !this.layerContainer.get_allocation_box().contains(x, y))
|
||||||
return [false, 0, 0];
|
return [false, 0, 0];
|
||||||
|
|
||||||
return this.layerContainer.transform_stage_point(x, y);
|
return this.layerContainer.transform_stage_point(stageX, stageY);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onButtonPressed: function(actor, event) {
|
_onButtonPressed: function(actor, event) {
|
||||||
|
|
@ -902,7 +905,7 @@ var DrawingArea = new Lang.Class({
|
||||||
setPointerCursor: function(pointerCursorName) {
|
setPointerCursor: function(pointerCursorName) {
|
||||||
if (!this.currentPointerCursorName || this.currentPointerCursorName != pointerCursorName) {
|
if (!this.currentPointerCursorName || this.currentPointerCursorName != pointerCursorName) {
|
||||||
this.currentPointerCursorName = pointerCursorName;
|
this.currentPointerCursorName = pointerCursorName;
|
||||||
Me.stateObj.areaManager.setCursor(pointerCursorName);
|
this.emit('pointer-cursor-changed', pointerCursorName);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1272,6 +1275,7 @@ var DrawingArea = new Lang.Class({
|
||||||
this.erase();
|
this.erase();
|
||||||
if (this._menu)
|
if (this._menu)
|
||||||
this._menu.disable();
|
this._menu.disable();
|
||||||
|
delete this.areaManagerUtils;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateActionMode: function() {
|
updateActionMode: function() {
|
||||||
|
|
|
||||||
13
extension.js
13
extension.js
|
|
@ -169,7 +169,13 @@ const AreaManager = new Lang.Class({
|
||||||
let monitor = this.monitors[i];
|
let monitor = this.monitors[i];
|
||||||
let helper = new Helper.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor);
|
let helper = new Helper.DrawingHelper({ name: 'drawOnYourSreenHelper' + i }, monitor);
|
||||||
let loadPersistent = i == Main.layoutManager.primaryIndex && this.persistentOverRestarts;
|
let loadPersistent = i == Main.layoutManager.primaryIndex && this.persistentOverRestarts;
|
||||||
let area = new Area.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, loadPersistent);
|
// Some utils for the drawing area menus.
|
||||||
|
let areaManagerUtils = {
|
||||||
|
getHiddenList: () => this.hiddenList,
|
||||||
|
togglePanelAndDockOpacity: this.togglePanelAndDockOpacity.bind(this),
|
||||||
|
openPreferences: this.openPreferences.bind(this)
|
||||||
|
};
|
||||||
|
let area = new Area.DrawingArea({ name: 'drawOnYourSreenArea' + i }, monitor, helper, areaManagerUtils, loadPersistent);
|
||||||
|
|
||||||
Main.layoutManager._backgroundGroup.insert_child_above(area, Main.layoutManager._bgManagers[i].backgroundActor);
|
Main.layoutManager._backgroundGroup.insert_child_above(area, Main.layoutManager._bgManagers[i].backgroundActor);
|
||||||
if (!this.onDesktop)
|
if (!this.onDesktop)
|
||||||
|
|
@ -179,6 +185,7 @@ const AreaManager = new Lang.Class({
|
||||||
area.set_size(monitor.width, monitor.height);
|
area.set_size(monitor.width, monitor.height);
|
||||||
area.leaveDrawingHandler = area.connect('leave-drawing-mode', this.toggleDrawing.bind(this));
|
area.leaveDrawingHandler = area.connect('leave-drawing-mode', this.toggleDrawing.bind(this));
|
||||||
area.updateActionModeHandler = area.connect('update-action-mode', this.updateActionMode.bind(this));
|
area.updateActionModeHandler = area.connect('update-action-mode', this.updateActionMode.bind(this));
|
||||||
|
area.pointerCursorChangedHandler = area.connect('pointer-cursor-changed', this.setCursor.bind(this));
|
||||||
area.showOsdHandler = area.connect('show-osd', this.showOsd.bind(this));
|
area.showOsdHandler = area.connect('show-osd', this.showOsd.bind(this));
|
||||||
this.areas.push(area);
|
this.areas.push(area);
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +368,7 @@ const AreaManager = new Lang.Class({
|
||||||
if (source && source == global.display)
|
if (source && source == global.display)
|
||||||
// Translators: "released" as the opposite of "grabbed"
|
// Translators: "released" as the opposite of "grabbed"
|
||||||
this.showOsd(null, Files.Icons.UNGRAB, _("Keyboard and pointer released"), null, null, false);
|
this.showOsd(null, Files.Icons.UNGRAB, _("Keyboard and pointer released"), null, null, false);
|
||||||
this.setCursor('DEFAULT');
|
this.setCursor(null, 'DEFAULT');
|
||||||
this.activeArea.reactive = false;
|
this.activeArea.reactive = false;
|
||||||
this.removeInternalKeybindings();
|
this.removeInternalKeybindings();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -499,7 +506,7 @@ const AreaManager = new Lang.Class({
|
||||||
OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
|
OsdWindow.HIDE_TIMEOUT = hideTimeoutSave;
|
||||||
},
|
},
|
||||||
|
|
||||||
setCursor: function(cursorName) {
|
setCursor: function(sourceActor_, cursorName) {
|
||||||
// check display or screen (API changes)
|
// check display or screen (API changes)
|
||||||
if (global.display.set_cursor)
|
if (global.display.set_cursor)
|
||||||
global.display.set_cursor(Meta.Cursor[cursorName]);
|
global.display.set_cursor(Meta.Cursor[cursorName]);
|
||||||
|
|
|
||||||
9
menu.js
9
menu.js
|
|
@ -142,10 +142,11 @@ var DisplayStrings = {
|
||||||
var DrawingMenu = new Lang.Class({
|
var DrawingMenu = new Lang.Class({
|
||||||
Name: `${UUID}-DrawingMenu`,
|
Name: `${UUID}-DrawingMenu`,
|
||||||
|
|
||||||
_init: function(area, monitor, drawingTools) {
|
_init: function(area, monitor, drawingTools, areaManagerUtils) {
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.monitor = monitor;
|
this.monitor = monitor;
|
||||||
this.drawingTools = drawingTools;
|
this.drawingTools = drawingTools;
|
||||||
|
this.areaManagerUtils = areaManagerUtils;
|
||||||
|
|
||||||
let side = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? St.Side.RIGHT : St.Side.LEFT;
|
let side = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL ? St.Side.RIGHT : St.Side.LEFT;
|
||||||
this.menu = new PopupMenu.PopupMenu(Main.layoutManager.dummyCursor, 0.25, side);
|
this.menu = new PopupMenu.PopupMenu(Main.layoutManager.dummyCursor, 0.25, side);
|
||||||
|
|
@ -178,6 +179,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
disable: function() {
|
disable: function() {
|
||||||
delete this.area;
|
delete this.area;
|
||||||
delete this.drawingTools;
|
delete this.drawingTools;
|
||||||
|
delete this.areaManagerUtils;
|
||||||
this.menuManager.removeMenu(this.menu);
|
this.menuManager.removeMenu(this.menu);
|
||||||
Main.layoutManager.uiGroup.remove_actor(this.menu.actor);
|
Main.layoutManager.uiGroup.remove_actor(this.menu.actor);
|
||||||
this.menu.destroy();
|
this.menu.destroy();
|
||||||
|
|
@ -279,8 +281,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
imageSection.itemActivated = () => {};
|
imageSection.itemActivated = () => {};
|
||||||
this.imageSection = imageSection;
|
this.imageSection = imageSection;
|
||||||
|
|
||||||
let areaManager = Me.stateObj.areaManager;
|
this._addSimpleSwitchItem(this.menu, getSummary('toggle-panel-and-dock-visibility'), !!this.areaManagerUtils.getHiddenList(), this.areaManagerUtils.togglePanelAndDockOpacity);
|
||||||
this._addSimpleSwitchItem(this.menu, getSummary('toggle-panel-and-dock-visibility'), !!areaManager.hiddenList, areaManager.togglePanelAndDockOpacity.bind(areaManager));
|
|
||||||
this._addSimpleSwitchItem(this.menu, getSummary('toggle-background'), this.area.hasBackground, this.area.toggleBackground.bind(this.area));
|
this._addSimpleSwitchItem(this.menu, getSummary('toggle-background'), this.area.hasBackground, this.area.toggleBackground.bind(this.area));
|
||||||
this._addSimpleSwitchItem(this.menu, getSummary('toggle-grid'), this.area.hasGrid, this.area.toggleGrid.bind(this.area));
|
this._addSimpleSwitchItem(this.menu, getSummary('toggle-grid'), this.area.hasGrid, this.area.toggleGrid.bind(this.area));
|
||||||
this._addSimpleSwitchItem(this.menu, getSummary('toggle-square-area'), this.area.isSquareArea, this.area.toggleSquareArea.bind(this.area));
|
this._addSimpleSwitchItem(this.menu, getSummary('toggle-square-area'), this.area.isSquareArea, this.area.toggleSquareArea.bind(this.area));
|
||||||
|
|
@ -294,7 +295,7 @@ var DrawingMenu = new Lang.Class({
|
||||||
groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: 'draw-on-your-screen-menu-group-item' });
|
groupItem = new PopupMenu.PopupBaseMenuItem({ reactive: false, can_focus: false, style_class: 'draw-on-your-screen-menu-group-item' });
|
||||||
this.saveButton = new ActionButton(getSummary('save-as-json'), 'document-save-symbolic', this.area.saveAsJson.bind(this.area, false, this._onDrawingSaved.bind(this)), null);
|
this.saveButton = new ActionButton(getSummary('save-as-json'), 'document-save-symbolic', this.area.saveAsJson.bind(this.area, false, this._onDrawingSaved.bind(this)), null);
|
||||||
this.svgButton = new ActionButton(getSummary('export-to-svg'), Files.Icons.DOCUMENT_EXPORT, this.area.exportToSvg.bind(this.area), null);
|
this.svgButton = new ActionButton(getSummary('export-to-svg'), Files.Icons.DOCUMENT_EXPORT, this.area.exportToSvg.bind(this.area), null);
|
||||||
this.prefsButton = new ActionButton(getSummary('open-preferences'), 'document-page-setup-symbolic', areaManager.openPreferences.bind(areaManager), null);
|
this.prefsButton = new ActionButton(getSummary('open-preferences'), 'document-page-setup-symbolic', this.areaManagerUtils.openPreferences, null);
|
||||||
this.helpButton = new ActionButton(getSummary('toggle-help'), 'preferences-desktop-keyboard-shortcuts-symbolic', () => { this.close(); this.area.toggleHelp(); }, null);
|
this.helpButton = new ActionButton(getSummary('toggle-help'), 'preferences-desktop-keyboard-shortcuts-symbolic', () => { this.close(); this.area.toggleHelp(); }, null);
|
||||||
getActor(groupItem).add_child(this.saveButton);
|
getActor(groupItem).add_child(this.saveButton);
|
||||||
getActor(groupItem).add_child(this.svgButton);
|
getActor(groupItem).add_child(this.svgButton);
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,5 @@
|
||||||
"3.36",
|
"3.36",
|
||||||
"3.38"
|
"3.38"
|
||||||
],
|
],
|
||||||
"version": 9
|
"version": 10
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
/* square area */
|
/* square area */
|
||||||
|
|
||||||
.draw-on-your-screen-square-area {
|
.draw-on-your-screen .draw-on-your-screen-square-area {
|
||||||
outline: 2px solid rgba(255, 0, 0, 0.7);
|
outline: 2px solid rgba(255, 0, 0, 0.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
.draw-on-your-screen-square-area:insensitive {
|
.draw-on-your-screen:insensitive .draw-on-your-screen-square-area {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue