Bug 721498 - Use remote timestamp when available for focus requests. r=karlt

This commit is contained in:
Owen Taylor 2012-02-16 11:23:34 +01:00
Родитель 5e505cd07f
Коммит 0253ae1472
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -164,19 +164,20 @@ nsGTKRemoteService::Shutdown()
// Set desktop startup ID to the passed ID, if there is one, so that any created
// windows get created with the right window manager metadata, and any windows
// that get new tabs and are activated also get the right WM metadata.
// If there is no desktop startup ID, then use the X event's timestamp
// for _NET_ACTIVE_WINDOW when the window gets focused or shown.
// The timestamp will be used if there is no desktop startup ID, or if we're
// raising an existing window rather than showing a new window for the first time.
void
nsGTKRemoteService::SetDesktopStartupIDOrTimestamp(const nsACString& aDesktopStartupID,
PRUint32 aTimestamp) {
nsGTKToolkit* toolkit = nsGTKToolkit::GetToolkit();
if (!toolkit)
return;
if (!aDesktopStartupID.IsEmpty()) {
toolkit->SetDesktopStartupID(aDesktopStartupID);
} else {
toolkit->SetFocusTimestamp(aTimestamp);
}
toolkit->SetFocusTimestamp(aTimestamp);
}

Просмотреть файл

@ -1438,6 +1438,9 @@ SetUserTimeAndStartupIDForActivatedWindow(GtkWidget* aWindow)
sn_display_unref(snd);
#endif
// If we used the startup ID, that already contains the focus timestamp;
// we don't want to reuse the timestamp next time we raise the window
GTKToolkit->SetFocusTimestamp(0);
GTKToolkit->SetDesktopStartupID(EmptyCString());
}
@ -1501,11 +1504,20 @@ nsWindow::SetFocus(bool aRaise)
if (gRaiseWindows && owningWindow->mIsShown && owningWindow->mShell &&
!gtk_window_is_active(GTK_WINDOW(owningWindow->mShell))) {
PRUint32 timestamp = GDK_CURRENT_TIME;
nsGTKToolkit* GTKToolkit = nsGTKToolkit::GetToolkit();
if (GTKToolkit)
timestamp = GTKToolkit->GetFocusTimestamp();
LOGFOCUS((" requesting toplevel activation [%p]\n", (void *)this));
NS_ASSERTION(owningWindow->mWindowType != eWindowType_popup
|| mParent,
"Presenting an override-redirect window");
gtk_window_present(GTK_WINDOW(owningWindow->mShell));
gtk_window_present_with_time(GTK_WINDOW(owningWindow->mShell), timestamp);
if (GTKToolkit)
GTKToolkit->SetFocusTimestamp(0);
}
return NS_OK;