1
1
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
3
3
const Clutter = imports.gi.Clutter;
4
const DBus = imports.dbus;
4
5
const Gdk = imports.gi.Gdk;
5
6
const Gio = imports.gi.Gio;
6
7
const GLib = imports.gi.GLib;
9
10
const Meta = imports.gi.Meta;
10
11
const Shell = imports.gi.Shell;
11
12
const Signals = imports.signals;
13
const St = imports.gi.St;
13
15
const Chrome = imports.ui.chrome;
16
const Environment = imports.ui.environment;
14
17
const Overview = imports.ui.overview;
15
18
const Panel = imports.ui.panel;
16
19
const RunDialog = imports.ui.runDialog;
17
20
const LookingGlass = imports.ui.lookingGlass;
21
const ShellDBus = imports.ui.shellDBus;
18
22
const Sidebar = imports.ui.sidebar;
19
const Tweener = imports.ui.tweener;
20
23
const WindowManager = imports.ui.windowManager;
22
25
const DEFAULT_BACKGROUND_COLOR = new Clutter.Color();
42
46
Gio.DesktopAppInfo.set_desktop_env("GNOME");
44
48
global.grab_dbus_service();
49
shellDBusService = new ShellDBus.GnomeShell();
50
// Force a connection now; dbus.js will do this internally
51
// if we use its name acquisition stuff but we aren't right
52
// now; to do so we'd need to convert from its async calls
53
// back into sync ones.
48
58
// Ensure ShellAppMonitor is initialized; this will
49
59
// also initialize ShellAppSystem first. ShellAppSystem
66
76
for (let i = 0; i < children.length; i++)
67
77
children[i].destroy();
79
let themeContext = St.ThemeContext.get_for_stage (global.stage);
80
let stylesheetPath = global.datadir + "/theme/gnome-shell.css";
81
let theme = new St.Theme ({ application_stylesheet: stylesheetPath });
82
themeContext.set_theme (theme);
69
84
global.connect('panel-run-dialog', function(panel) {
70
85
// Make sure not more than one run dialog is shown.
71
86
getRunDialog().open();
88
let shellwm = global.window_manager;
89
shellwm.takeover_keybinding("panel_main_menu");
90
shellwm.connect("keybinding::panel_main_menu", function () {
93
shellwm.takeover_keybinding("panel_run_dialog");
94
shellwm.connect("keybinding::panel_run_dialog", function () {
95
getRunDialog().open();
74
98
overview = new Overview.Overview();
75
99
chrome = new Chrome.Chrome();
105
129
function _relayout() {
106
panel.actor.set_size(global.screen_width, Panel.PANEL_HEIGHT);
130
let primary = global.get_primary_monitor();
131
panel.actor.set_position(primary.x, primary.y);
132
panel.actor.set_size(primary.width, Panel.PANEL_HEIGHT);
107
133
overview.relayout();
205
231
* Next, record the current Clutter keyboard focus on a stack. If the modal stack
206
232
* returns to this actor, reset the focus to the actor which was focused
207
233
* at the time pushModal() was invoked.
235
* Returns: true iff we successfully acquired a grab or already had one
209
237
function pushModal(actor) {
210
let timestamp = global.screen.get_display().get_current_time();
238
if (modalCount == 0) {
239
if (!global.begin_modal(currentTime())) {
240
log("pushModal: invocation of begin_modal failed");
245
global.set_stage_input_mode(Shell.StageInputMode.FULLSCREEN);
213
248
actor.connect('destroy', function() {
285
311
function createAppLaunchContext() {
286
let screen = global.screen;
287
let display = screen.get_display();
289
312
let context = new Gdk.AppLaunchContext();
290
context.set_timestamp(display.get_current_time());
313
context.set_timestamp(currentTime());
292
315
// Make sure that the app is opened on the current workspace even if
293
316
// the user switches before it starts
294
context.set_desktop(screen.get_active_workspace_index());
317
context.set_desktop(global.screen.get_active_workspace_index());
325
* Gets the current X server time from the current Clutter, Gdk, or X
326
* event. If called from outside an event handler, this may return
327
* %Clutter.CURRENT_TIME (aka 0), or it may return a slightly
328
* out-of-date timestamp.
330
function currentTime() {
331
// meta_display_get_current_time() will return the correct time
332
// when handling an X or Gdk event, but will return CurrentTime
333
// from some Clutter event callbacks.
335
// clutter_get_current_event_time() will return the correct time
336
// from a Clutter event callback, but may return an out-of-date
337
// timestamp if called at other times.
339
// So we try meta_display_get_current_time() first, since we
340
// can recognize a "wrong" answer from that, and then fall back
341
// to clutter_get_current_event_time().
343
let time = global.screen.get_display().get_current_time();
344
if (time != Clutter.CURRENT_TIME)
347
return Clutter.get_current_event_time();
352
* @window: the Meta.Window to activate
353
* @time: (optional) current event time
355
* Activates @window, switching to its workspace first if necessary
357
function activateWindow(window, time) {
358
let activeWorkspaceNum = global.screen.get_active_workspace_index();
359
let windowWorkspaceNum = window.get_workspace().index();
362
time = currentTime();
364
if (windowWorkspaceNum != activeWorkspaceNum) {
365
let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
366
workspace.activate_with_focus(window, time);
368
window.activate(time);