~ubuntu-branches/ubuntu/trusty/gnome-shell/trusty-proposed

« back to all changes in this revision

Viewing changes to js/ui/windowManager.js

Tags: upstream-2.29.0
ImportĀ upstreamĀ versionĀ 2.29.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
const Shell = imports.gi.Shell;
8
8
 
9
9
const AltTab = imports.ui.altTab;
 
10
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
10
11
const Main = imports.ui.main;
11
12
const Tweener = imports.ui.tweener;
12
13
 
42
43
 
43
44
        shellwm.takeover_keybinding('switch_windows');
44
45
        shellwm.connect('keybinding::switch_windows', Lang.bind(this, this._startAppSwitcher));
 
46
 
 
47
        this._workspaceSwitcherPopup = null;
 
48
        shellwm.takeover_keybinding('switch_to_workspace_left');
 
49
        shellwm.takeover_keybinding('switch_to_workspace_right');
 
50
        shellwm.takeover_keybinding('switch_to_workspace_up');
 
51
        shellwm.takeover_keybinding('switch_to_workspace_down');
 
52
        shellwm.connect('keybinding::switch_to_workspace_left', Lang.bind(this, this._showWorkspaceSwitcher));
 
53
        shellwm.connect('keybinding::switch_to_workspace_right', Lang.bind(this, this._showWorkspaceSwitcher));
 
54
        shellwm.connect('keybinding::switch_to_workspace_up', Lang.bind(this, this._showWorkspaceSwitcher));
 
55
        shellwm.connect('keybinding::switch_to_workspace_down', Lang.bind(this, this._showWorkspaceSwitcher));
 
56
 
45
57
    },
46
58
 
47
59
    _shouldAnimate : function(actor) {
74
86
         * maybe TODO: get icon geometry passed through and move the window towards it?
75
87
         */
76
88
        this._minimizing.push(actor);
 
89
 
 
90
        let primary = global.get_primary_monitor();
 
91
 
77
92
        Tweener.addTween(actor,
78
93
                         { scale_x: 0.0,
79
94
                           scale_y: 0.0,
 
95
                           x: primary.x,
 
96
                           y: 0,
80
97
                           time: WINDOW_ANIMATION_TIME,
81
98
                           transition: "easeOutQuad",
82
99
                           onComplete: this._minimizeWindowDone,
272
289
    },
273
290
 
274
291
    _startAppSwitcher : function(shellwm, binding, window, backwards) {
 
292
        /* prevent a corner case where both popups show up at once */
 
293
        if (this._workspaceSwitcherPopup != null)
 
294
            this._workspaceSwitcherPopup.actor.hide();
 
295
 
275
296
        let tabPopup = new AltTab.AltTabPopup();
276
297
 
277
298
        if (!tabPopup.show(backwards))
278
299
            tabPopup.destroy();
 
300
    },
 
301
 
 
302
    _showWorkspaceSwitcher : function(shellwm, binding, window, backwards) {
 
303
        /* We don't support this kind of layout */
 
304
        if (binding == "switch_to_workspace_up" || binding == "switch_to_workspace_down")
 
305
            return;
 
306
 
 
307
        if (global.screen.n_workspaces == 1)
 
308
            return;
 
309
 
 
310
        if (this._workspaceSwitcherPopup == null)
 
311
            this._workspaceSwitcherPopup = new WorkspaceSwitcherPopup.WorkspaceSwitcherPopup();
 
312
 
 
313
        let activeWorkspaceIndex = global.screen.get_active_workspace_index();
 
314
 
 
315
        if (binding == "switch_to_workspace_left") {
 
316
            if (activeWorkspaceIndex > 0) {
 
317
                global.screen.get_workspace_by_index(activeWorkspaceIndex - 1).activate(global.get_current_time());
 
318
                this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex - 1);
 
319
            }
 
320
            else
 
321
                this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.LEFT, activeWorkspaceIndex);
 
322
        }
 
323
 
 
324
        if (binding == "switch_to_workspace_right") {
 
325
            if (activeWorkspaceIndex <  global.screen.n_workspaces - 1) {
 
326
                global.screen.get_workspace_by_index(activeWorkspaceIndex + 1).activate(global.get_current_time());
 
327
                this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex + 1);
 
328
            }
 
329
            else
 
330
                this._workspaceSwitcherPopup.display(WorkspaceSwitcherPopup.RIGHT, activeWorkspaceIndex);
 
331
        }
279
332
    }
280
333
};