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