Move Main.currentTime() and Main.createAppLaunchContext() into ShellGlobal
Primarily motivated by wanting these functions accessible from C. https://bugzilla.gnome.org/show_bug.cgi?id=603522
This commit is contained in:
@ -293,7 +293,7 @@ function _findModal(actor) {
|
||||
*/
|
||||
function pushModal(actor) {
|
||||
if (modalCount == 0) {
|
||||
if (!global.begin_modal(currentTime())) {
|
||||
if (!global.begin_modal(global.get_current_time())) {
|
||||
log("pushModal: invocation of begin_modal failed");
|
||||
return false;
|
||||
}
|
||||
@ -346,7 +346,7 @@ function popModal(actor) {
|
||||
if (modalCount > 0)
|
||||
return;
|
||||
|
||||
global.end_modal(currentTime());
|
||||
global.end_modal(global.get_current_time());
|
||||
global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
|
||||
}
|
||||
|
||||
@ -365,45 +365,6 @@ function getRunDialog() {
|
||||
return runDialog;
|
||||
}
|
||||
|
||||
function createAppLaunchContext() {
|
||||
let context = new Gdk.AppLaunchContext();
|
||||
context.set_timestamp(currentTime());
|
||||
|
||||
// Make sure that the app is opened on the current workspace even if
|
||||
// the user switches before it starts
|
||||
context.set_desktop(global.screen.get_active_workspace_index());
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* currentTime:
|
||||
*
|
||||
* Gets the current X server time from the current Clutter, Gdk, or X
|
||||
* event. If called from outside an event handler, this may return
|
||||
* %Clutter.CURRENT_TIME (aka 0), or it may return a slightly
|
||||
* out-of-date timestamp.
|
||||
*/
|
||||
function currentTime() {
|
||||
// meta_display_get_current_time() will return the correct time
|
||||
// when handling an X or Gdk event, but will return CurrentTime
|
||||
// from some Clutter event callbacks.
|
||||
//
|
||||
// clutter_get_current_event_time() will return the correct time
|
||||
// from a Clutter event callback, but may return an out-of-date
|
||||
// timestamp if called at other times.
|
||||
//
|
||||
// So we try meta_display_get_current_time() first, since we
|
||||
// can recognize a "wrong" answer from that, and then fall back
|
||||
// to clutter_get_current_event_time().
|
||||
|
||||
let time = global.screen.get_display().get_current_time();
|
||||
if (time != Clutter.CURRENT_TIME)
|
||||
return time;
|
||||
|
||||
return Clutter.get_current_event_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* activateWindow:
|
||||
* @window: the Meta.Window to activate
|
||||
@ -416,7 +377,7 @@ function activateWindow(window, time) {
|
||||
let windowWorkspaceNum = window.get_workspace().index();
|
||||
|
||||
if (!time)
|
||||
time = currentTime();
|
||||
time = global.get_current_time();
|
||||
|
||||
if (windowWorkspaceNum != activeWorkspaceNum) {
|
||||
let workspace = global.screen.get_workspace_by_index(windowWorkspaceNum);
|
||||
|
Reference in New Issue
Block a user