[gnome-shell-extensions] apps-menu: Only enable DND when there's a desktop
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] apps-menu: Only enable DND when there's a desktop
- Date: Wed, 22 Mar 2017 18:33:32 +0000 (UTC)
commit 09a60a27ba3c1dda954b6efe033326805d65f570
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Mar 15 05:23:57 2017 +0100
apps-menu: Only enable DND when there's a desktop
It's not very useful to allow dragging when there's no drop target,
so tie the functionality added in the previous commit to the presence
of a DESKTOP window.
https://bugzilla.gnome.org/show_bug.cgi?id=780371
extensions/apps-menu/extension.js | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 404548d..5b01411 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -77,6 +77,13 @@ const ApplicationMenuItem = new Lang.Class({
this.actor._delegate = this;
let draggable = DND.makeDraggable(this.actor);
+ let maybeStartDrag = draggable._maybeStartDrag;
+ draggable._maybeStartDrag = (event) => {
+ if (this._dragEnabled)
+ return maybeStartDrag.call(draggable, event);
+ return false;
+ };
+
draggable.connect('drag-begin', () => {
Shell.util_set_hidden_from_pick(Main.legacyTray.actor, true);
});
@@ -98,6 +105,10 @@ const ApplicationMenuItem = new Lang.Class({
this.parent(active, params);
},
+ setDragEnabled: function(enable) {
+ this._dragEnabled = enable;
+ },
+
getDragActor: function() {
return this._app.create_icon_texture(APPLICATION_ICON_SIZE);
},
@@ -283,6 +294,10 @@ const DesktopTarget = new Lang.Class({
});
},
+ get hasDesktop() {
+ return this._desktop != null;
+ },
+
_onWindowAdded: function(group, actor) {
if (!(actor instanceof Meta.WindowActor))
return;
@@ -300,6 +315,7 @@ const DesktopTarget = new Lang.Class({
}
this._desktop = desktop;
+ this.emit('desktop-changed');
if (this._desktop) {
this._desktopDestroyedId = this._desktop.connect('destroy', () => {
@@ -399,6 +415,11 @@ const ApplicationsButton = new Lang.Class({
this._desktopTarget.connect('app-dropped', () => {
this.menu.close();
});
+ this._desktopTarget.connect('desktop-changed', () => {
+ this._applicationsButtons.forEach(item => {
+ item.setDragEnabled(this._desktopTarget.hasDesktop);
+ });
+ });
this._applicationsButtons = new Map();
this.reloadFlag = false;
@@ -673,6 +694,7 @@ const ApplicationsButton = new Lang.Class({
let item = this._applicationsButtons.get(app);
if (!item) {
item = new ApplicationMenuItem(this, app);
+ item.setDragEnabled(this._desktopTarget.hasDesktop);
this._applicationsButtons.set(app, item);
}
if (!item.actor.get_parent())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]