appDisplay: Simplify event blocking while folder is opened

There's no need for a `inhibitEventBlocker` interface. Since we connect
to "open-state-changed" of our folders in the AllView anyway, we can
just make the event blocker visible while a folder is opened, and hide
the event blocker during DnD.

This allows keeping the eventBlocker reactive at all times and fixes an
issue where DnD to create a new folder is impossible if no folders are
present because the eventBlocker would not get inhibited.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1652
This commit is contained in:
Jonas Dreßler 2019-11-23 21:11:14 +01:00 committed by Florian Müllner
parent 7800bd2158
commit 40b2fbf465

View File

@ -312,7 +312,12 @@ var AllView = class AllView extends BaseAppView {
this._grid.currentPage = 0;
this._stack.add_actor(this._grid);
this._eventBlocker = new St.Widget({ x_expand: true, y_expand: true });
this._eventBlocker = new St.Widget({
x_expand: true,
y_expand: true,
reactive: true,
visible: false,
});
this._stack.add_actor(this._eventBlocker);
box.add_actor(this._stack);
@ -339,6 +344,7 @@ var AllView = class AllView extends BaseAppView {
});
this._eventBlocker.add_action(this._clickAction);
this._currentPopup = null;
this._displayingPopup = false;
this._currentPopupDestroyId = 0;
@ -381,8 +387,6 @@ var AllView = class AllView extends BaseAppView {
Main.overview.connect('item-drag-begin', this._onDragBegin.bind(this));
Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
this._nEventBlockerInhibits = 0;
}
_redisplay() {
@ -657,7 +661,7 @@ var AllView = class AllView extends BaseAppView {
addFolderPopup(popup) {
this._stack.add_actor(popup.actor);
popup.connect('open-state-changed', (popup, isOpen) => {
this._eventBlocker.reactive = isOpen;
this._eventBlocker.visible = isOpen;
if (this._currentPopup) {
this._currentPopup.actor.disconnect(this._currentPopupDestroyId);
@ -671,7 +675,7 @@ var AllView = class AllView extends BaseAppView {
this._currentPopupDestroyId = popup.actor.connect('destroy', () => {
this._currentPopup = null;
this._currentPopupDestroyId = 0;
this._eventBlocker.reactive = false;
this._eventBlocker.visible = false;
});
}
this._updateIconOpacities(isOpen);
@ -769,6 +773,8 @@ var AllView = class AllView extends BaseAppView {
dragMotion: this._onDragMotion.bind(this)
};
DND.addDragMonitor(this._dragMonitor);
this._eventBlocker.visible = false;
}
_onDragMotion(dragEvent) {
@ -791,6 +797,8 @@ var AllView = class AllView extends BaseAppView {
DND.removeDragMonitor(this._dragMonitor);
this._dragMonitor = null;
}
this._eventBlocker.visible = this._currentPopup !== null;
}
_canAccept(source) {
@ -824,19 +832,6 @@ var AllView = class AllView extends BaseAppView {
return true;
}
inhibitEventBlocker() {
this._nEventBlockerInhibits++;
this._eventBlocker.visible = this._nEventBlockerInhibits == 0;
}
uninhibitEventBlocker() {
if (this._nEventBlockerInhibits === 0)
throw new Error('Not inhibited');
this._nEventBlockerInhibits--;
this._eventBlocker.visible = this._nEventBlockerInhibits == 0;
}
createFolder(apps) {
let newFolderId = GLib.uuid_string_random();
@ -1503,8 +1498,6 @@ var FolderIcon = class FolderIcon {
dragMotion: this._onDragMotion.bind(this),
};
DND.addDragMonitor(this._dragMonitor);
this._parentView.inhibitEventBlocker();
}
_onDragMotion(dragEvent) {
@ -1520,7 +1513,6 @@ var FolderIcon = class FolderIcon {
_onDragEnd() {
this.actor.remove_style_pseudo_class('drop');
this._parentView.uninhibitEventBlocker();
DND.removeDragMonitor(this._dragMonitor);
}