Bug 361781 - nsIDomInternalWindow::GetAttention on GTK2 doesn't behave "right" in all cases. (Second try)

r+sr=roc@ocallahan.org (Robert O'Callahan)
This commit is contained in:
gijskruitbosch%gmail.com 2006-12-20 09:05:19 +00:00
Родитель a46aded4d9
Коммит 5cb6806ff0
2 изменённых файлов: 51 добавлений и 4 удалений

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

@ -280,6 +280,11 @@ static _gdk_display_get_default_fn _gdk_display_get_default;
static _gdk_cursor_new_from_pixbuf_fn _gdk_cursor_new_from_pixbuf;
static PRBool sPixbufCursorChecked;
// needed for GetAttention calls
// gdk_window_set_urgency_hint was added in 2.8
typedef void (*_gdk_window_set_urgency_hint_fn)(GdkWindow *window,
gboolean urgency);
#define kWindowPositionSlop 20
// cursor cache
@ -714,8 +719,16 @@ nsWindow::SetFocus(PRBool aRaise)
if (gRaiseWindows && aRaise && toplevelWidget &&
!GTK_WIDGET_HAS_FOCUS(owningWidget) &&
!GTK_WIDGET_HAS_FOCUS(toplevelWidget))
GetAttention(-1);
!GTK_WIDGET_HAS_FOCUS(toplevelWidget)) {
GtkWidget* top_window = nsnull;
GetToplevelWidget(&top_window);
if (top_window && (GTK_WIDGET_VISIBLE(top_window)))
{
gdk_window_show_unraised(top_window->window);
// Unset the urgency hint if possible.
SetUrgencyHint(top_window, PR_FALSE);
}
}
nsWindow *owningWindow = get_window_for_gtk_widget(owningWidget);
if (!owningWindow)
@ -1406,9 +1419,15 @@ nsWindow::GetAttention(PRInt32 aCycleCount)
LOG(("nsWindow::GetAttention [%p]\n", (void *)this));
GtkWidget* top_window = nsnull;
GtkWidget* top_focused_window = nsnull;
GetToplevelWidget(&top_window);
if (top_window && GTK_WIDGET_VISIBLE(top_window)) {
gdk_window_show_unraised(top_window->window);
if (gFocusWindow)
gFocusWindow->GetToplevelWidget(&top_focused_window);
// Don't get attention if the window is focused anyway.
if (top_window && (GTK_WIDGET_VISIBLE(top_window)) &&
top_window != top_focused_window) {
SetUrgencyHint(top_window, PR_TRUE);
}
return NS_OK;
@ -1967,6 +1986,12 @@ nsWindow::OnContainerFocusInEvent(GtkWidget *aWidget, GdkEventFocus *aEvent)
if (mIsTopLevel)
mActivatePending = PR_TRUE;
// Unset the urgency hint, if possible
GtkWidget* top_window = nsnull;
GetToplevelWidget(&top_window);
if (top_window && (GTK_WIDGET_VISIBLE(top_window)))
SetUrgencyHint(top_window, PR_FALSE);
// dispatch a got focus event
DispatchGotFocusEvent();
@ -3539,6 +3564,27 @@ nsWindow::GetContainerWindow(nsWindow **aWindow)
*aWindow = get_window_for_gtk_widget(owningWidget);
}
void
nsWindow::SetUrgencyHint(GtkWidget *top_window, PRBool state)
{
if (!top_window)
return;
// Try to get a pointer to gdk_window_set_urgency_hint
PRLibrary* lib;
_gdk_window_set_urgency_hint_fn _gdk_window_set_urgency_hint = nsnull;
_gdk_window_set_urgency_hint = (_gdk_window_set_urgency_hint_fn)
PR_FindFunctionSymbolAndLibrary("gdk_window_set_urgency_hint", &lib);
if (_gdk_window_set_urgency_hint) {
_gdk_window_set_urgency_hint(top_window->window, state);
PR_UnloadLibrary(lib);
}
else if (state) {
gdk_window_show_unraised(top_window->window);
}
}
void *
nsWindow::SetupPluginPort(void)
{

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

@ -360,6 +360,7 @@ public:
private:
void GetToplevelWidget(GtkWidget **aWidget);
void GetContainerWindow(nsWindow **aWindow);
void SetUrgencyHint(GtkWidget *top_window, PRBool state);
void *SetupPluginPort(void);
nsresult SetWindowIconList(const nsCStringArray &aIconList);
void SetDefaultIcon(void);