[gnome-shell] main: add timestamp parameter to push/popModal



commit dc020628b5f869922fb0df0d49cd61ca280399e8
Author: Ray Strode <rstrode redhat com>
Date:   Wed Oct 20 15:08:14 2010 -0400

    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

 js/ui/main.js |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 1ee8065..1d068eb 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -369,6 +369,7 @@ function _findModal(actor) {
 /**
  * pushModal:
  * @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
  * 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
  * 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
  */
-function pushModal(actor) {
+function pushModal(actor, timestamp) {
+
+    if (timestamp == undefined)
+        timestamp = global.get_current_time();
+
     if (modalCount == 0) {
-        if (!global.begin_modal(global.get_current_time())) {
+        if (!global.begin_modal(timestamp)) {
             log('pushModal: invocation of begin_modal failed');
             return false;
         }
@@ -414,12 +423,21 @@ function pushModal(actor) {
 /**
  * popModal:
  * @actor: #ClutterActor passed to original invocation of pushModal().
+ * @timestamp: optional timestamp
  *
  * Reverse the effect of pushModal().  If this invocation is undoing
  * the topmost invocation, then the focus will be restored to the
  * 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;
     let focusIndex = _findModal(actor);
     if (focusIndex >= 0) {
@@ -438,7 +456,7 @@ function popModal(actor) {
         return;
 
     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);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]