Bug 1434565 - Put some meanigful timestamp to nsRemoteService::HandleCommandLine(), r?jhorak draft
authorMartin Stransky <stransky@redhat.com>
Thu, 01 Feb 2018 13:56:15 +0100
changeset 750088 c8b0466bc1d0f3c2ed42a71ce127c36c9185477f
parent 749226 c1154ebbe3fa43176dffcb0782809c648a027bcd
push id97540
push userstransky@redhat.com
push dateThu, 01 Feb 2018 13:02:14 +0000
reviewersjhorak
bugs1434565
milestone60.0a1
Bug 1434565 - Put some meanigful timestamp to nsRemoteService::HandleCommandLine(), r?jhorak We need to put a timestamp to nsRemoteService::HandleCommandLine() to allow Gtk+ focus opened Firefox window. Unfortunately we don't have much choice how to get the timestamp at DBUS remote service so ask for gtk_get_current_event_time() and when GDK_CURRENT_TIME is returned (it means we don't have the timestamp) use g_get_monotonic_time() as well as at nsWindow::GetEventTimeStamp(). MozReview-Commit-ID: 9ilVZ0kPe3x
toolkit/components/remote/nsDBusRemoteService.cpp
--- a/toolkit/components/remote/nsDBusRemoteService.cpp
+++ b/toolkit/components/remote/nsDBusRemoteService.cpp
@@ -84,17 +84,21 @@ nsDBusRemoteService::OpenURL(DBusMessage
   int          length;
 
   if (!dbus_message_get_args(msg, nullptr, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
       &commandLine, &length, DBUS_TYPE_INVALID) || length == 0) {
     nsAutoCString errorMsg;
     errorMsg = nsPrintfCString("org.mozilla.%s.Error", mAppName.get());
     reply = dbus_message_new_error(msg, errorMsg.get(), "Wrong argument");
   } else {
-    nsRemoteService::HandleCommandLine(commandLine, nullptr, 0);
+    guint32 timestamp = gtk_get_current_event_time();
+    if (timestamp == GDK_CURRENT_TIME) {
+        timestamp = guint32(g_get_monotonic_time() / 1000);
+    }
+    nsRemoteService::HandleCommandLine(commandLine, nullptr, timestamp);
     reply = dbus_message_new_method_return(msg);
   }
 
   dbus_connection_send(mConnection, reply, nullptr);
   dbus_message_unref(reply);
 
   return DBUS_HANDLER_RESULT_HANDLED;
 }