Convert all JS style to be uniform, add Eclipse settings bits
Previous style was all over the place; this commit attempts to bring uniformity. Overall, the style is: * 4 spaces only, no tabs * Prototypes do not create a new block * Constructor property continuations only indent one block svn path=/trunk/; revision=87
This commit is contained in:
118
js/ui/main.js
118
js/ui/main.js
@ -1,4 +1,4 @@
|
||||
/* -*- mode: js2; js2-basic-offset: 4; -*- */
|
||||
/* -*- mode: js2; js2-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- */
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Shell = imports.gi.Shell;
|
||||
@ -18,67 +18,67 @@ let overlay = null;
|
||||
let run_dialog = null;
|
||||
let wm = null;
|
||||
|
||||
// The "FrameTicker" object is an object used to feed new frames to Tweener
|
||||
// so it can update values and redraw. The default frame ticker for
|
||||
// Tweener just uses a simple timeout at a fixed frame rate and has no idea
|
||||
// of "catching up" by dropping frames.
|
||||
//
|
||||
// We substitute it with custom frame ticker here that connects Tweener to
|
||||
// a Clutter.TimeLine. Now, Clutter.Timeline itself isn't a whole lot more
|
||||
// sophisticated than a simple timeout at a fixed frame rate, but at least
|
||||
// it knows how to drop frames. (See HippoAnimationManager for a more
|
||||
// sophisticated view of continous time updates; even better is to pay
|
||||
// attention to the vertical vblank and sync to that when possible.)
|
||||
//
|
||||
//The "FrameTicker" object is an object used to feed new frames to Tweener
|
||||
//so it can update values and redraw. The default frame ticker for
|
||||
//Tweener just uses a simple timeout at a fixed frame rate and has no idea
|
||||
//of "catching up" by dropping frames.
|
||||
|
||||
//We substitute it with custom frame ticker here that connects Tweener to
|
||||
//a Clutter.TimeLine. Now, Clutter.Timeline itself isn't a whole lot more
|
||||
//sophisticated than a simple timeout at a fixed frame rate, but at least
|
||||
//it knows how to drop frames. (See HippoAnimationManager for a more
|
||||
//sophisticated view of continous time updates; even better is to pay
|
||||
//attention to the vertical vblank and sync to that when possible.)
|
||||
|
||||
function ClutterFrameTicker() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
ClutterFrameTicker.prototype = {
|
||||
TARGET_FRAME_RATE : 60,
|
||||
TARGET_FRAME_RATE : 60,
|
||||
|
||||
_init : function() {
|
||||
// We don't have a finite duration; tweener will tell us to stop
|
||||
// when we need to stop, so use 1000 seconds as "infinity"
|
||||
this._timeline = new Clutter.Timeline({ fps: this.TARGET_FRAME_RATE,
|
||||
duration: 1000*1000 });
|
||||
this._frame = 0;
|
||||
_init : function() {
|
||||
// We don't have a finite duration; tweener will tell us to stop
|
||||
// when we need to stop, so use 1000 seconds as "infinity"
|
||||
this._timeline = new Clutter.Timeline({ fps: this.TARGET_FRAME_RATE,
|
||||
duration: 1000*1000 });
|
||||
this._frame = 0;
|
||||
|
||||
let me = this;
|
||||
this._timeline.connect('new-frame',
|
||||
function(timeline, frame) {
|
||||
me._onNewFrame(frame);
|
||||
});
|
||||
},
|
||||
let me = this;
|
||||
this._timeline.connect('new-frame',
|
||||
function(timeline, frame) {
|
||||
me._onNewFrame(frame);
|
||||
});
|
||||
},
|
||||
|
||||
_onNewFrame : function(frame) {
|
||||
// Unfortunately the interface to to send a new frame to tweener
|
||||
// is a simple "next frame" and there is no provision for signaling
|
||||
// that frames have been skipped or just telling it the new time.
|
||||
// But what it actually does internally is just:
|
||||
//
|
||||
// _currentTime += 1000/_ticker.FRAME_RATE;
|
||||
//
|
||||
// So by dynamically adjusting the value of FRAME_RATE we can trick
|
||||
// it into dealing with dropped frames.
|
||||
_onNewFrame : function(frame) {
|
||||
// Unfortunately the interface to to send a new frame to tweener
|
||||
// is a simple "next frame" and there is no provision for signaling
|
||||
// that frames have been skipped or just telling it the new time.
|
||||
// But what it actually does internally is just:
|
||||
//
|
||||
// _currentTime += 1000/_ticker.FRAME_RATE;
|
||||
//
|
||||
// So by dynamically adjusting the value of FRAME_RATE we can trick
|
||||
// it into dealing with dropped frames.
|
||||
|
||||
let delta = frame - this._frame;
|
||||
if (delta == 0)
|
||||
this.FRAME_RATE = this.TARGET_FRAME_RATE;
|
||||
else
|
||||
this.FRAME_RATE = this.TARGET_FRAME_RATE / delta;
|
||||
this._frame = frame;
|
||||
this.emit('prepare-frame');
|
||||
},
|
||||
let delta = frame - this._frame;
|
||||
if (delta == 0)
|
||||
this.FRAME_RATE = this.TARGET_FRAME_RATE;
|
||||
else
|
||||
this.FRAME_RATE = this.TARGET_FRAME_RATE / delta;
|
||||
this._frame = frame;
|
||||
this.emit('prepare-frame');
|
||||
},
|
||||
|
||||
start : function() {
|
||||
this._timeline.start();
|
||||
},
|
||||
start : function() {
|
||||
this._timeline.start();
|
||||
},
|
||||
|
||||
stop : function() {
|
||||
this._timeline.stop();
|
||||
this._frame = 0;
|
||||
}
|
||||
stop : function() {
|
||||
this._timeline.stop();
|
||||
this._frame = 0;
|
||||
}
|
||||
};
|
||||
|
||||
Signals.addSignalMethods(ClutterFrameTicker.prototype);
|
||||
@ -97,20 +97,20 @@ function start() {
|
||||
// in the overlay. Clear that out.
|
||||
let children = global.overlay_group.get_children();
|
||||
for (let i = 0; i < children.length; i++)
|
||||
children[i].destroy();
|
||||
children[i].destroy();
|
||||
|
||||
global.connect('panel-run-dialog', function(panel) {
|
||||
// Make sure not more than one run dialog is shown.
|
||||
if (!run_dialog) {
|
||||
run_dialog = new RunDialog.RunDialog();
|
||||
let end_handler = function() {
|
||||
let end_handler = function() {
|
||||
run_dialog.destroy();
|
||||
run_dialog = null;
|
||||
};
|
||||
run_dialog.connect('run', end_handler);
|
||||
run_dialog.connect('cancel', end_handler);
|
||||
if (!run_dialog.show())
|
||||
end_handler();
|
||||
end_handler();
|
||||
}
|
||||
});
|
||||
|
||||
@ -121,14 +121,14 @@ function start() {
|
||||
wm = new WindowManager.WindowManager();
|
||||
}
|
||||
|
||||
// Used to go into a mode where all keyboard and mouse input goes to
|
||||
// the stage. Returns true if we successfully grabbed the keyboard and
|
||||
// went modal, false otherwise
|
||||
//Used to go into a mode where all keyboard and mouse input goes to
|
||||
//the stage. Returns true if we successfully grabbed the keyboard and
|
||||
//went modal, false otherwise
|
||||
function startModal() {
|
||||
let global = Shell.Global.get();
|
||||
|
||||
if (!global.grab_keyboard())
|
||||
return false;
|
||||
return false;
|
||||
|
||||
global.set_stage_input_area(0, 0, global.screen_width, global.screen_height);
|
||||
|
||||
@ -144,7 +144,7 @@ function endModal() {
|
||||
|
||||
function show_overlay() {
|
||||
if (startModal())
|
||||
overlay.show();
|
||||
overlay.show();
|
||||
}
|
||||
|
||||
function hide_overlay() {
|
||||
|
Reference in New Issue
Block a user