main: add timestamp parameter to push/popModal
Right now popModal() passes global.get_current_time() for its begin_modal() call. global.get_current_time() is the timestamp of the last gdk or clutter event processed by the shell's mutter process. These values could potentially be be too stale to use if pushModal() were to get called in response to an event by another process. This commit changes pushModal() to have an optional timestamp argument, which can be used to associate the call with the event that initiated it. https://bugzilla.gnome.org/show_bug.cgi?id=637187
This commit is contained in:
parent
bed063eea1
commit
dc020628b5
@ -369,6 +369,7 @@ function _findModal(actor) {
|
|||||||
/**
|
/**
|
||||||
* pushModal:
|
* pushModal:
|
||||||
* @actor: #ClutterActor which will be given keyboard focus
|
* @actor: #ClutterActor which will be given keyboard focus
|
||||||
|
* @timestamp: optional timestamp
|
||||||
*
|
*
|
||||||
* Ensure we are in a mode where all keyboard and mouse input goes to
|
* Ensure we are in a mode where all keyboard and mouse input goes to
|
||||||
* the stage, and focus @actor. Multiple calls to this function act in
|
* the stage, and focus @actor. Multiple calls to this function act in
|
||||||
@ -379,11 +380,19 @@ function _findModal(actor) {
|
|||||||
* modal stack returns to this actor, reset the focus to the actor
|
* modal stack returns to this actor, reset the focus to the actor
|
||||||
* which was focused at the time pushModal() was invoked.
|
* which was focused at the time pushModal() was invoked.
|
||||||
*
|
*
|
||||||
|
* @timestamp is optionally used to associate the call with a specific user
|
||||||
|
* initiated event. If not provided then the value of
|
||||||
|
* global.get_current_time() is assumed.
|
||||||
|
*
|
||||||
* Returns: true iff we successfully acquired a grab or already had one
|
* Returns: true iff we successfully acquired a grab or already had one
|
||||||
*/
|
*/
|
||||||
function pushModal(actor) {
|
function pushModal(actor, timestamp) {
|
||||||
|
|
||||||
|
if (timestamp == undefined)
|
||||||
|
timestamp = global.get_current_time();
|
||||||
|
|
||||||
if (modalCount == 0) {
|
if (modalCount == 0) {
|
||||||
if (!global.begin_modal(global.get_current_time())) {
|
if (!global.begin_modal(timestamp)) {
|
||||||
log('pushModal: invocation of begin_modal failed');
|
log('pushModal: invocation of begin_modal failed');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -414,12 +423,21 @@ function pushModal(actor) {
|
|||||||
/**
|
/**
|
||||||
* popModal:
|
* popModal:
|
||||||
* @actor: #ClutterActor passed to original invocation of pushModal().
|
* @actor: #ClutterActor passed to original invocation of pushModal().
|
||||||
|
* @timestamp: optional timestamp
|
||||||
*
|
*
|
||||||
* Reverse the effect of pushModal(). If this invocation is undoing
|
* Reverse the effect of pushModal(). If this invocation is undoing
|
||||||
* the topmost invocation, then the focus will be restored to the
|
* the topmost invocation, then the focus will be restored to the
|
||||||
* previous focus at the time when pushModal() was invoked.
|
* previous focus at the time when pushModal() was invoked.
|
||||||
|
*
|
||||||
|
* @timestamp is optionally used to associate the call with a specific user
|
||||||
|
* initiated event. If not provided then the value of
|
||||||
|
* global.get_current_time() is assumed.
|
||||||
*/
|
*/
|
||||||
function popModal(actor) {
|
function popModal(actor, timestamp) {
|
||||||
|
|
||||||
|
if (timestamp == undefined)
|
||||||
|
timestamp = global.get_current_time();
|
||||||
|
|
||||||
modalCount -= 1;
|
modalCount -= 1;
|
||||||
let focusIndex = _findModal(actor);
|
let focusIndex = _findModal(actor);
|
||||||
if (focusIndex >= 0) {
|
if (focusIndex >= 0) {
|
||||||
@ -438,7 +456,7 @@ function popModal(actor) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
global.stage.set_key_focus(null);
|
global.stage.set_key_focus(null);
|
||||||
global.end_modal(global.get_current_time());
|
global.end_modal(timestamp);
|
||||||
global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
|
global.set_stage_input_mode(Shell.StageInputMode.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user