altTab: use keybinding actions instead of clutter keysym comparison

Use keybinding actions instead of clutter keysym comparisons to select
next/prev application and next/prev window.

https://bugzilla.gnome.org/show_bug.cgi?id=639341
This commit is contained in:
Rui Matos 2011-01-29 22:01:46 +00:00 committed by Dan Winship
parent a047132a2f
commit 1bc805206b

View File

@ -4,6 +4,7 @@ const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk; const Gdk = imports.gi.Gdk;
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals; const Signals = imports.signals;
const St = imports.gi.St; const St = imports.gi.St;
@ -226,41 +227,38 @@ AltTabPopup.prototype = {
_keyPressEvent : function(actor, event) { _keyPressEvent : function(actor, event) {
let keysym = event.get_key_symbol(); let keysym = event.get_key_symbol();
let shift = (Shell.get_event_state(event) & Clutter.ModifierType.SHIFT_MASK); let event_state = Shell.get_event_state(event);
// X allows servers to represent Shift+Tab in two different ways let backwards = event_state & Clutter.ModifierType.SHIFT_MASK;
if (shift && keysym == Clutter.Tab) let action = global.screen.get_display().get_keybinding_action(event.get_key_code(), event_state);
keysym = Clutter.ISO_Left_Tab;
this._disableHover(); this._disableHover();
if (keysym == Clutter.grave) if (action == Meta.KeyBindingAction.SWITCH_GROUP)
this._select(this._currentApp, this._nextWindow()); this._select(this._currentApp, backwards ? this._previousWindow() : this._nextWindow());
else if (keysym == Clutter.asciitilde)
this._select(this._currentApp, this._previousWindow());
else if (keysym == Clutter.Escape) else if (keysym == Clutter.Escape)
this.destroy(); this.destroy();
else if (this._thumbnailsFocused) { else if (this._thumbnailsFocused) {
if (keysym == Clutter.Tab) { if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)
if (this._currentWindow == this._appIcons[this._currentApp].cachedWindows.length - 1) if (backwards) {
this._select(this._nextApp());
else
this._select(this._currentApp, this._nextWindow());
} else if (keysym == Clutter.ISO_Left_Tab) {
if (this._currentWindow == 0 || this._currentWindow == -1) if (this._currentWindow == 0 || this._currentWindow == -1)
this._select(this._previousApp()); this._select(this._previousApp());
else else
this._select(this._currentApp, this._previousWindow()); this._select(this._currentApp, this._previousWindow());
} else if (keysym == Clutter.Left) } else {
if (this._currentWindow == this._appIcons[this._currentApp].cachedWindows.length - 1)
this._select(this._nextApp());
else
this._select(this._currentApp, this._nextWindow());
}
else if (keysym == Clutter.Left)
this._select(this._currentApp, this._previousWindow()); this._select(this._currentApp, this._previousWindow());
else if (keysym == Clutter.Right) else if (keysym == Clutter.Right)
this._select(this._currentApp, this._nextWindow()); this._select(this._currentApp, this._nextWindow());
else if (keysym == Clutter.Up) else if (keysym == Clutter.Up)
this._select(this._currentApp, null, true); this._select(this._currentApp, null, true);
} else { } else {
if (keysym == Clutter.Tab) if (action == Meta.KeyBindingAction.SWITCH_WINDOWS)
this._select(this._nextApp()); this._select(backwards ? this._previousApp() : this._nextApp());
else if (keysym == Clutter.ISO_Left_Tab)
this._select(this._previousApp());
else if (keysym == Clutter.Left) else if (keysym == Clutter.Left)
this._select(this._previousApp()); this._select(this._previousApp());
else if (keysym == Clutter.Right) else if (keysym == Clutter.Right)