Beispiel #1
0
void wxTopLevelWindowGTK::RequestUserAttention(int flags)
{
    bool new_hint_value = false;

    // FIXME: This is a workaround to focus handling problem
    // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle hasn't
    // yet been processed, and the internal focus system is not up to date yet.
    // wxYieldIfNeeded ensures the processing of it, but can have unwanted side effects - MR
    ::wxYieldIfNeeded();

    if(m_urgency_hint >= 0)
        gtk_timeout_remove(m_urgency_hint);

    m_urgency_hint = -2;

    if( GTK_WIDGET_REALIZED(m_widget) && !IsActive() )
    {
        new_hint_value = true;

        if (flags & wxUSER_ATTENTION_INFO)
        {
            m_urgency_hint = gtk_timeout_add(5000, (GtkFunction)gtk_frame_urgency_timer_callback, this);
        } else {
            m_urgency_hint = -1;
        }
    }

    wxgtk_window_set_urgency_hint(GTK_WINDOW( m_widget ), new_hint_value);
}
Beispiel #2
0
static gint gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win )
{
    wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE);

    win->m_urgency_hint = -2;
    return FALSE;
}
Beispiel #3
0
    static gboolean gtk_frame_focus_in_callback( GtkWidget *widget,
            GdkEvent *WXUNUSED(event),
            wxTopLevelWindowGTK *win )
    {
        // don't need to install idle handler, its done from "event" signal

        switch ( g_sendActivateEvent )
        {
        case -1:
            // we've got focus from outside, synthetize wxActivateEvent
            g_sendActivateEvent = 1;
            break;

        case 0:
            // another our window just lost focus, it was already ours before
            // - don't send any wxActivateEvent
            g_sendActivateEvent = -1;
            break;
        }

        g_activeFrame = win;
        g_lastActiveFrame = g_activeFrame;

        // wxPrintf( wxT("active: %s\n"), win->GetTitle().c_str() );

        // MR: wxRequestUserAttention related block
        switch( win->m_urgency_hint )
        {
        default:
            g_source_remove( win->m_urgency_hint );
        // no break, fallthrough to remove hint too
        case -1:
#if GTK_CHECK_VERSION(2,7,0)
            if(!gtk_check_version(2,7,0))
                gtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE);
            else
#endif
            {
                wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE);
            }

            win->m_urgency_hint = -2;
            break;

        case -2:
            break;
        }

        wxLogTrace(wxT("activate"), wxT("Activating frame %p (from focus_in)"), g_activeFrame);
        wxActivateEvent event(wxEVT_ACTIVATE, true, g_activeFrame->GetId());
        event.SetEventObject(g_activeFrame);
        g_activeFrame->GetEventHandler()->ProcessEvent(event);

        return FALSE;
    }
Beispiel #4
0
    static gboolean gtk_frame_urgency_timer_callback( wxTopLevelWindowGTK *win )
    {
#if GTK_CHECK_VERSION(2,7,0)
        if(!gtk_check_version(2,7,0))
            gtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE);
        else
#endif
            wxgtk_window_set_urgency_hint(GTK_WINDOW( win->m_widget ), FALSE);

        win->m_urgency_hint = -2;
        return FALSE;
    }
Beispiel #5
0
static gint gtk_frame_focus_in_callback( GtkWidget *widget,
                                         GdkEvent *WXUNUSED(event),
                                         wxTopLevelWindowGTK *win )
{
    if (g_isIdle)
        wxapp_install_idle_handler();

    switch ( g_sendActivateEvent )
    {
        case -1:
            // we've got focus from outside, synthetize wxActivateEvent
            g_sendActivateEvent = 1;
            break;

        case 0:
            // another our window just lost focus, it was already ours before
            // - don't send any wxActivateEvent
            g_sendActivateEvent = -1;
            break;
    }

    g_activeFrame = win;
    g_lastActiveFrame = g_activeFrame;

    // wxPrintf( wxT("active: %s\n"), win->GetTitle().c_str() );

    // MR: wxRequestUserAttention related block
    switch( win->m_urgency_hint )
    {
        default:
            gtk_timeout_remove( win->m_urgency_hint );
            // no break, fallthrough to remove hint too
        case -1:
            wxgtk_window_set_urgency_hint(GTK_WINDOW( widget ), FALSE);

            win->m_urgency_hint = -2;
            break;

        case -2: break;
    }

    wxLogTrace(wxT("activate"), wxT("Activating frame %p (from focus_in)"), g_activeFrame);
    wxActivateEvent event(wxEVT_ACTIVATE, true, g_activeFrame->GetId());
    event.SetEventObject(g_activeFrame);
    g_activeFrame->HandleWindowEvent(event);

    return FALSE;
}