workspace: Use AppIcon.app to check action-support by the drag source
`AppIcon.shellWorkspaceLaunch()` can easily be replaced by checking for `AppIcon.app` and calling `AppIcon.app.open_new_window()` directly. For compatibility and to prevent breaking extensions implementing the function, keep supporting the `shellWorkspaceLaunch` API in AppIcon while logging a deprecation warning. Also keep supporting the API on drag sources (without deprecating it) to allow extensions to define custom actions on their drag sources. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/121
This commit is contained in:

committed by
Florian Müllner

parent
e0947b01bd
commit
942758bb30
@ -572,7 +572,9 @@ var WorkspaceThumbnail = GObject.registerClass({
|
||||
|
||||
if (source.realWindow && !this._isMyWindow(source.realWindow))
|
||||
return DND.DragMotionResult.MOVE_DROP;
|
||||
if (source.shellWorkspaceLaunch)
|
||||
if (source.app)
|
||||
return DND.DragMotionResult.COPY_DROP;
|
||||
if (!source.app && source.shellWorkspaceLaunch)
|
||||
return DND.DragMotionResult.COPY_DROP;
|
||||
|
||||
return DND.DragMotionResult.CONTINUE;
|
||||
@ -597,8 +599,13 @@ var WorkspaceThumbnail = GObject.registerClass({
|
||||
|
||||
metaWindow.change_workspace_by_index(this.metaWorkspace.index(), false);
|
||||
return true;
|
||||
} else if (source.shellWorkspaceLaunch) {
|
||||
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace ? this.metaWorkspace.index() : -1,
|
||||
} else if (source.app) {
|
||||
source.app.open_new_window(this.metaWorkspace.index());
|
||||
return true;
|
||||
} else if (!source.app && source.shellWorkspaceLaunch) {
|
||||
// While unused in our own drag sources, shellWorkspaceLaunch allows
|
||||
// extensions to define custom actions for their drag sources.
|
||||
source.shellWorkspaceLaunch({ workspace: this.metaWorkspace.index(),
|
||||
timestamp: time });
|
||||
return true;
|
||||
}
|
||||
@ -779,7 +786,10 @@ var ThumbnailsBox = GObject.registerClass({
|
||||
|
||||
// Draggable target interface
|
||||
handleDragOver(source, actor, x, y, time) {
|
||||
if (!source.realWindow && !source.shellWorkspaceLaunch && source != Main.xdndHandler)
|
||||
if (!source.realWindow &&
|
||||
!source.app &&
|
||||
(source.app || !source.shellWorkspaceLaunch) &&
|
||||
source != Main.xdndHandler)
|
||||
return DND.DragMotionResult.CONTINUE;
|
||||
|
||||
let canCreateWorkspaces = Meta.prefs_get_dynamic_workspaces();
|
||||
@ -836,7 +846,9 @@ var ThumbnailsBox = GObject.registerClass({
|
||||
if (this._dropWorkspace != -1) {
|
||||
return this._thumbnails[this._dropWorkspace].acceptDropInternal(source, time);
|
||||
} else if (this._dropPlaceholderPos != -1) {
|
||||
if (!source.realWindow && !source.shellWorkspaceLaunch)
|
||||
if (!source.realWindow &&
|
||||
!source.app &&
|
||||
(source.app || !source.shellWorkspaceLaunch))
|
||||
return false;
|
||||
|
||||
let isWindow = !!source.realWindow;
|
||||
@ -853,9 +865,16 @@ var ThumbnailsBox = GObject.registerClass({
|
||||
if (source.metaWindow.get_monitor() != thumbMonitor)
|
||||
source.metaWindow.move_to_monitor(thumbMonitor);
|
||||
source.metaWindow.change_workspace_by_index(newWorkspaceIndex, true);
|
||||
} else if (source.shellWorkspaceLaunch) {
|
||||
} else if (source.app) {
|
||||
source.app.open_new_window(newWorkspaceIndex);
|
||||
} else if (!source.app && source.shellWorkspaceLaunch) {
|
||||
// While unused in our own drag sources, shellWorkspaceLaunch allows
|
||||
// extensions to define custom actions for their drag sources.
|
||||
source.shellWorkspaceLaunch({ workspace: newWorkspaceIndex,
|
||||
timestamp: time });
|
||||
}
|
||||
|
||||
if (source.app || (!source.app && source.shellWorkspaceLaunch)) {
|
||||
// This new workspace will be automatically removed if the application fails
|
||||
// to open its first window within some time, as tracked by Shell.WindowTracker.
|
||||
// Here, we only add a very brief timeout to avoid the _immediate_ removal of the
|
||||
|
Reference in New Issue
Block a user