ctrlAltTab: misc improvements
Fix the "panel" icon to be symbolic. Make the overview parts only show up when in the overview, and the non-overview parts (eg, the Desktop window, if there is one) only show up when not in the overview. Sort the different items consistently with their locations on the screen. https://bugzilla.gnome.org/show_bug.cgi?id=618887
This commit is contained in:
parent
868bf5838d
commit
af4fcc831e
@ -10,11 +10,18 @@ const St = imports.gi.St;
|
|||||||
|
|
||||||
const AltTab = imports.ui.altTab;
|
const AltTab = imports.ui.altTab;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
|
const Params = imports.misc.params;
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
|
|
||||||
const POPUP_APPICON_SIZE = 96;
|
const POPUP_APPICON_SIZE = 96;
|
||||||
const POPUP_FADE_TIME = 0.1; // seconds
|
const POPUP_FADE_TIME = 0.1; // seconds
|
||||||
|
|
||||||
|
const SortGroup = {
|
||||||
|
TOP: 0,
|
||||||
|
MIDDLE: 1,
|
||||||
|
BOTTOM: 2
|
||||||
|
};
|
||||||
|
|
||||||
function CtrlAltTabManager() {
|
function CtrlAltTabManager() {
|
||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
@ -23,14 +30,18 @@ CtrlAltTabManager.prototype = {
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this._items = [];
|
this._items = [];
|
||||||
this._focusManager = St.FocusManager.get_for_stage(global.stage);
|
this._focusManager = St.FocusManager.get_for_stage(global.stage);
|
||||||
Main.wm.setKeybindingHandler('switch_panels', Lang.bind(this,
|
|
||||||
function (shellwm, binding, window, backwards) {
|
|
||||||
this.popup(backwards);
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addGroup: function(root, name, icon) {
|
addGroup: function(root, name, icon, params) {
|
||||||
this._items.push({ root: root, name: name, iconName: icon });
|
let item = Params.parse(params, { sortGroup: SortGroup.MIDDLE,
|
||||||
|
proxy: root,
|
||||||
|
focusCallback: null });
|
||||||
|
|
||||||
|
item.root = root;
|
||||||
|
item.name = name;
|
||||||
|
item.iconName = icon;
|
||||||
|
|
||||||
|
this._items.push(item);
|
||||||
root.connect('destroy', Lang.bind(this, function() { this.removeGroup(root); }));
|
root.connect('destroy', Lang.bind(this, function() { this.removeGroup(root); }));
|
||||||
this._focusManager.add_group(root);
|
this._focusManager.add_group(root);
|
||||||
},
|
},
|
||||||
@ -45,38 +56,73 @@ CtrlAltTabManager.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
focusGroup: function(root) {
|
focusGroup: function(item) {
|
||||||
if (global.stage_input_mode == Shell.StageInputMode.NONREACTIVE ||
|
if (global.stage_input_mode == Shell.StageInputMode.NONREACTIVE ||
|
||||||
global.stage_input_mode == Shell.StageInputMode.NORMAL)
|
global.stage_input_mode == Shell.StageInputMode.NORMAL)
|
||||||
global.set_stage_input_mode(Shell.StageInputMode.FOCUSED);
|
global.set_stage_input_mode(Shell.StageInputMode.FOCUSED);
|
||||||
root.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
|
||||||
|
if (item.window)
|
||||||
|
Main.activateWindow(item.window);
|
||||||
|
else if (item.focusCallback)
|
||||||
|
item.focusCallback();
|
||||||
|
else
|
||||||
|
item.root.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Sort the items into a consistent order; panel first, tray last,
|
||||||
|
// and everything else in between, sorted by X coordinate, so that
|
||||||
|
// they will have the same left-to-right ordering in the
|
||||||
|
// Ctrl-Alt-Tab dialog as they do onscreen.
|
||||||
|
_sortItems: function(a, b) {
|
||||||
|
if (a.sortGroup != b.sortGroup)
|
||||||
|
return a.sortGroup - b.sortGroup;
|
||||||
|
|
||||||
|
let y;
|
||||||
|
if (a.x == undefined) {
|
||||||
|
if (a.window)
|
||||||
|
a.x = a.window.get_compositor_private().x;
|
||||||
|
else
|
||||||
|
[a.x, y] = a.proxy.get_transformed_position();
|
||||||
|
}
|
||||||
|
if (b.x == undefined) {
|
||||||
|
if (b.window)
|
||||||
|
b.x = b.window.get_compositor_private().x;
|
||||||
|
else
|
||||||
|
[b.x, y] = b.proxy.get_transformed_position();
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.x - b.x;
|
||||||
},
|
},
|
||||||
|
|
||||||
popup: function(backwards) {
|
popup: function(backwards) {
|
||||||
// Start with the set of focus groups that are currently mapped
|
// Start with the set of focus groups that are currently mapped
|
||||||
let items = this._items.filter(function (item) { return item.root.mapped; });
|
let items = this._items.filter(function (item) { return item.proxy.mapped; });
|
||||||
|
|
||||||
// And add the windows metacity would show in its Ctrl-Alt-Tab list
|
// And add the windows metacity would show in its Ctrl-Alt-Tab list
|
||||||
let screen = global.screen;
|
if (!Main.overview.visible) {
|
||||||
let display = screen.get_display();
|
let screen = global.screen;
|
||||||
let windows = display.get_tab_list(Meta.TabList.DOCKS, screen, screen.get_active_workspace ());
|
let display = screen.get_display();
|
||||||
let windowTracker = Shell.WindowTracker.get_default();
|
let windows = display.get_tab_list(Meta.TabList.DOCKS, screen, screen.get_active_workspace ());
|
||||||
let textureCache = St.TextureCache.get_default();
|
let windowTracker = Shell.WindowTracker.get_default();
|
||||||
for (let i = 0; i < windows.length; i++) {
|
let textureCache = St.TextureCache.get_default();
|
||||||
let icon;
|
for (let i = 0; i < windows.length; i++) {
|
||||||
let app = windowTracker.get_window_app(windows[i]);
|
let icon;
|
||||||
if (app)
|
let app = windowTracker.get_window_app(windows[i]);
|
||||||
icon = app.create_icon_texture(POPUP_APPICON_SIZE);
|
if (app)
|
||||||
else
|
icon = app.create_icon_texture(POPUP_APPICON_SIZE);
|
||||||
icon = textureCache.bind_pixbuf_property(windows[i], 'icon');
|
else
|
||||||
items.push({ window: windows[i],
|
icon = textureCache.bind_pixbuf_property(windows[i], 'icon');
|
||||||
name: windows[i].title,
|
items.push({ window: windows[i],
|
||||||
iconActor: icon });
|
name: windows[i].title,
|
||||||
|
iconActor: icon,
|
||||||
|
sortGroup: SortGroup.MIDDLE });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!items.length)
|
if (!items.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
items.sort(Lang.bind(this, this._sortItems));
|
||||||
new CtrlAltTabPopup().show(items, backwards);
|
new CtrlAltTabPopup().show(items, backwards);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -211,11 +257,7 @@ CtrlAltTabPopup.prototype = {
|
|||||||
_finish : function() {
|
_finish : function() {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
|
|
||||||
let item = this._items[this._selection];
|
Main.ctrlAltTabManager.focusGroup(this._items[this._selection]);
|
||||||
if (item.root)
|
|
||||||
Main.ctrlAltTabManager.focusGroup(item.root);
|
|
||||||
else
|
|
||||||
Main.activateWindow(item.window);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_popModal: function() {
|
_popModal: function() {
|
||||||
|
@ -139,6 +139,7 @@ function start() {
|
|||||||
|
|
||||||
placesManager = new PlaceDisplay.PlacesManager();
|
placesManager = new PlaceDisplay.PlacesManager();
|
||||||
xdndHandler = new XdndHandler.XdndHandler();
|
xdndHandler = new XdndHandler.XdndHandler();
|
||||||
|
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
|
||||||
overview = new Overview.Overview();
|
overview = new Overview.Overview();
|
||||||
chrome = new Chrome.Chrome();
|
chrome = new Chrome.Chrome();
|
||||||
magnifier = new Magnifier.Magnifier();
|
magnifier = new Magnifier.Magnifier();
|
||||||
@ -153,9 +154,6 @@ function start() {
|
|||||||
overview.init();
|
overview.init();
|
||||||
statusIconDispatcher.start(messageTray.actor);
|
statusIconDispatcher.start(messageTray.actor);
|
||||||
|
|
||||||
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
|
|
||||||
ctrlAltTabManager.addGroup(panel.actor, _("Panel"), 'gnome-panel');
|
|
||||||
|
|
||||||
_startDate = new Date();
|
_startDate = new Date();
|
||||||
|
|
||||||
let recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' });
|
let recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' });
|
||||||
|
@ -13,6 +13,7 @@ const Gettext = imports.gettext.domain('gnome-shell');
|
|||||||
const _ = Gettext.gettext;
|
const _ = Gettext.gettext;
|
||||||
|
|
||||||
const Config = imports.misc.config;
|
const Config = imports.misc.config;
|
||||||
|
const CtrlAltTab = imports.ui.ctrlAltTab;
|
||||||
const Overview = imports.ui.overview;
|
const Overview = imports.ui.overview;
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
const PanelMenu = imports.ui.panelMenu;
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
@ -989,6 +990,9 @@ Panel.prototype = {
|
|||||||
Main.chrome.addActor(this._rightCorner.actor, { visibleInOverview: true,
|
Main.chrome.addActor(this._rightCorner.actor, { visibleInOverview: true,
|
||||||
affectsStruts: false,
|
affectsStruts: false,
|
||||||
affectsInputRegion: false });
|
affectsInputRegion: false });
|
||||||
|
|
||||||
|
Main.ctrlAltTabManager.addGroup(this.actor, _("Panel"), 'start-here',
|
||||||
|
{ sortGroup: CtrlAltTab.SortGroup.TOP });
|
||||||
},
|
},
|
||||||
|
|
||||||
_xdndShowOverview: function (actor) {
|
_xdndShowOverview: function (actor) {
|
||||||
|
@ -117,6 +117,7 @@ WindowManager.prototype = {
|
|||||||
this.setKeybindingHandler('switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher));
|
this.setKeybindingHandler('switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher));
|
||||||
this.setKeybindingHandler('switch_windows', Lang.bind(this, this._startAppSwitcher));
|
this.setKeybindingHandler('switch_windows', Lang.bind(this, this._startAppSwitcher));
|
||||||
this.setKeybindingHandler('switch_group', Lang.bind(this, this._startAppSwitcher));
|
this.setKeybindingHandler('switch_group', Lang.bind(this, this._startAppSwitcher));
|
||||||
|
this.setKeybindingHandler('switch_panels', Lang.bind(this, this._startA11ySwitcher));
|
||||||
|
|
||||||
Main.overview.connect('showing', Lang.bind(this, function() {
|
Main.overview.connect('showing', Lang.bind(this, function() {
|
||||||
for (let i = 0; i < this._dimmedWindows.length; i++)
|
for (let i = 0; i < this._dimmedWindows.length; i++)
|
||||||
@ -525,6 +526,10 @@ WindowManager.prototype = {
|
|||||||
tabPopup.destroy();
|
tabPopup.destroy();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_startA11ySwitcher : function(shellwm, binding, window, backwards) {
|
||||||
|
Main.ctrlAltTabManager.popup(backwards);
|
||||||
|
},
|
||||||
|
|
||||||
_showWorkspaceSwitcher : function(shellwm, binding, window, backwards) {
|
_showWorkspaceSwitcher : function(shellwm, binding, window, backwards) {
|
||||||
if (global.screen.n_workspaces == 1)
|
if (global.screen.n_workspaces == 1)
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user