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
parent 2894085c45
commit 0897915b05

View File

@ -337,7 +337,12 @@ var AllView = GObject.registerClass({
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);
@ -364,6 +369,7 @@ var AllView = GObject.registerClass({
});
this._eventBlocker.add_action(this._clickAction);
this._currentPopup = null;
this._displayingPopup = false;
this._currentPopupDestroyId = 0;
@ -394,8 +400,6 @@ var AllView = GObject.registerClass({
Main.overview.connect('item-drag-begin', this._onDragBegin.bind(this));
Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
this._nEventBlockerInhibits = 0;
}
vfunc_map() {
@ -610,7 +614,6 @@ var AllView = GObject.registerClass({
openSpaceForPopup(item, side, nRows) {
this._updateIconOpacities(true);
this._displayingPopup = true;
this._eventBlocker.reactive = true;
this._grid.openExtraSpace(item, side, nRows);
}
@ -685,7 +688,7 @@ var AllView = GObject.registerClass({
addFolderPopup(popup) {
this._stack.add_actor(popup);
popup.connect('open-state-changed', (o, isOpen) => {
this._eventBlocker.reactive = isOpen;
this._eventBlocker.visible = isOpen;
if (this._currentPopup) {
this._currentPopup.disconnect(this._currentPopupDestroyId);
@ -699,7 +702,7 @@ var AllView = GObject.registerClass({
this._currentPopupDestroyId = popup.connect('destroy', () => {
this._currentPopup = null;
this._currentPopupDestroyId = 0;
this._eventBlocker.reactive = false;
this._eventBlocker.visible = false;
});
}
this._updateIconOpacities(isOpen);
@ -795,6 +798,8 @@ var AllView = GObject.registerClass({
dragMotion: this._onDragMotion.bind(this),
};
DND.addDragMonitor(this._dragMonitor);
this._eventBlocker.visible = false;
}
_onDragMotion(dragEvent) {
@ -817,6 +822,8 @@ var AllView = GObject.registerClass({
DND.removeDragMonitor(this._dragMonitor);
this._dragMonitor = null;
}
this._eventBlocker.visible = this._currentPopup !== null;
}
_canAccept(source) {
@ -850,19 +857,6 @@ var AllView = GObject.registerClass({
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();
@ -1566,8 +1560,6 @@ var FolderIcon = GObject.registerClass({
dragMotion: this._onDragMotion.bind(this),
};
DND.addDragMonitor(this._dragMonitor);
this._parentView.inhibitEventBlocker();
}
_onDragMotion(dragEvent) {
@ -1583,7 +1575,6 @@ var FolderIcon = GObject.registerClass({
_onDragEnd() {
this.remove_style_pseudo_class('drop');
this._parentView.uninhibitEventBlocker();
DND.removeDragMonitor(this._dragMonitor);
}