static gboolean
mail_shell_view_mail_display_needs_key (EMailDisplay *mail_display,
                                        gboolean with_input)
{
	gboolean needs_key = FALSE;

	if (gtk_widget_has_focus (GTK_WIDGET (mail_display))) {
		WebKitWebFrame *frame;
		WebKitDOMDocument *dom;
		WebKitDOMElement *element;
		gchar *name = NULL;

		frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (mail_display));
		if (!frame)
			return FALSE;
		dom = webkit_web_frame_get_dom_document (frame);
		element = webkit_dom_html_document_get_active_element (WEBKIT_DOM_HTML_DOCUMENT (dom));

		if (element)
			name = webkit_dom_node_get_node_name (WEBKIT_DOM_NODE (element));

		/* if INPUT or TEXTAREA has focus, then any key press should go there */
		if (name && ((with_input && g_ascii_strcasecmp (name, "INPUT") == 0) || g_ascii_strcasecmp (name, "TEXTAREA") == 0)) {
			needs_key = TRUE;
		}

		g_free (name);
	}

	return needs_key;
}
Example #2
0
File: dom.c Project: b80905/vimb
void dom_check_auto_insert(Document *doc)
{
    Element *active = webkit_dom_html_document_get_active_element(WEBKIT_DOM_HTML_DOCUMENT(doc));

    if (active) {
        if (!vb.config.strict_focus) {
            auto_insert(active);
        } else if (vb.mode->id != 'i') {
            /* If strict-focus is enabled and the editable element becomes
             * focus, we explicitely remove the focus. But only if vimb isn't
             * in input mode at the time. This prevents from leaving input
             * mode that was started by user interaction like click to
             * editable element, or the 'gi' normal mode command. */
            webkit_dom_element_blur(active);
        }
    }
    dom_install_focus_blur_callbacks(doc);
}