diff options
-rw-r--r-- | inputfocus.c | 36 | ||||
-rw-r--r-- | xombrero.c | 24 |
2 files changed, 44 insertions, 16 deletions
diff --git a/inputfocus.c b/inputfocus.c index 08ecaa0..fc6f259 100644 --- a/inputfocus.c +++ b/inputfocus.c @@ -19,6 +19,25 @@ #if WEBKIT_CHECK_VERSION(1, 5, 0) /* we got the DOM API we need */ + +void +focus_body(WebKitDOMDocument *doc) +{ + WebKitDOMNodeList *body = NULL; + WebKitDOMNode *n; + int i; + + body = webkit_dom_document_get_elements_by_tag_name(doc, "body"); + for (i = 0; i < webkit_dom_node_list_get_length(body); ++i) { + n = webkit_dom_node_list_item(body, i); + webkit_dom_element_focus((WebKitDOMElement *)n); +#if WEBKIT_CHECK_VERSION(1, 8, 0) + webkit_dom_html_element_click((WebKitDOMHTMLElement *)n); +#endif + break; + } +} + int node_is_valid_entry(WebKitDOMNode *n) { @@ -315,11 +334,15 @@ command_mode(struct tab *t, struct karg *args) doc = webkit_web_view_get_dom_document(t->wv); a = webkit_dom_html_document_get_active_element( (WebKitDOMHTMLDocument *)doc); - if (a) + if (a) { webkit_dom_element_blur(a); + focus_body(doc); + } t->mode = XT_MODE_COMMAND; - } else if (focus_input(t)) + } else if (args->i == XT_MODE_INSERT && focus_input(t)) t->mode = XT_MODE_INSERT; + else if (args->i == XT_MODE_HINT || args->i == XT_MODE_PASSTHROUGH) + t->mode = args->i; if (!node_is_valid_entry((WebKitDOMNode *)t->active)) { t->active = NULL; @@ -347,13 +370,12 @@ input_autofocus(struct tab *t) } else { if (dom_is_input(t, &text)) { if (text != NULL && g_strcmp0(text, t->active_text)) - t->mode = XT_MODE_INSERT; - else { + args.i = XT_MODE_INSERT; + else args.i = XT_MODE_COMMAND; - command_mode(t, &args); - } } else - t->mode = XT_MODE_COMMAND; + args.i = XT_MODE_COMMAND; + command_mode(t, &args); } if (text) diff --git a/xombrero.c b/xombrero.c index b215e32..e6c50e0 100644 --- a/xombrero.c +++ b/xombrero.c @@ -475,6 +475,7 @@ hide_cmd(struct tab *t) history_at = NULL; /* just in case */ search_at = NULL; /* just in case */ + gtk_widget_set_can_focus(t->cmd, FALSE); gtk_widget_hide(t->cmd); } @@ -486,6 +487,7 @@ show_cmd(struct tab *t) history_at = NULL; search_at = NULL; gtk_widget_hide(t->oops); + gtk_widget_set_can_focus(t->cmd, TRUE); gtk_widget_show(t->cmd); } @@ -493,6 +495,7 @@ void hide_buffers(struct tab *t) { gtk_widget_hide(t->buffers); + gtk_widget_set_can_focus(t->buffers, FALSE); gtk_list_store_clear(buffers_store); } @@ -566,6 +569,7 @@ show_buffers(struct tab *t) gtk_tree_path_free(path); gtk_widget_show(t->buffers); + gtk_widget_set_can_focus(t->buffers, TRUE); gtk_widget_grab_focus(GTK_WIDGET(t->buffers)); } @@ -2798,7 +2802,7 @@ struct prompt_sub { int command(struct tab *t, struct karg *args) { - struct karg a; + struct karg a = {0}; int i; char *s = NULL, *sp = NULL, *sl = NULL; gchar **sv; @@ -2844,14 +2848,12 @@ command(struct tab *t, struct karg *args) break; case '.': t->mode = XT_MODE_HINT; - bzero(&a, sizeof a); a.i = 0; hint(t, &a); s = "."; break; case ',': t->mode = XT_MODE_HINT; - bzero(&a, sizeof a); a.i = XT_HINT_NEWTAB; hint(t, &a); s = ","; @@ -6886,6 +6888,7 @@ create_browser(struct tab *t) } w = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_set_can_focus(w, FALSE); t->adjust_h = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW(w)); t->adjust_v = gtk_scrolled_window_get_vadjustment( @@ -6999,16 +7002,13 @@ create_toolbar(struct tab *t) gtk_widget_set_sensitive(t->forward, FALSE); g_signal_connect(G_OBJECT(t->forward), "clicked", G_CALLBACK(forward_cb), t); - gtk_box_pack_start(GTK_BOX(b), t->forward, FALSE, - FALSE, 0); + gtk_box_pack_start(GTK_BOX(b), t->forward, FALSE, FALSE, 0); /* stop button */ t->stop = create_button("Stop", GTK_STOCK_STOP, 0); gtk_widget_set_sensitive(t->stop, FALSE); - g_signal_connect(G_OBJECT(t->stop), "clicked", - G_CALLBACK(stop_cb), t); - gtk_box_pack_start(GTK_BOX(b), t->stop, FALSE, - FALSE, 0); + g_signal_connect(G_OBJECT(t->stop), "clicked", G_CALLBACK(stop_cb), t); + gtk_box_pack_start(GTK_BOX(b), t->stop, FALSE, FALSE, 0); /* JS button */ t->js_toggle = create_button("JS-Toggle", enable_scripts ? @@ -7529,9 +7529,11 @@ create_new_tab(char *title, struct undo *u, int focus, int position) t->vbox = gtk_vbox_new(FALSE, 0); b = gtk_hbox_new(FALSE, 0); #endif + gtk_widget_set_can_focus(t->vbox, FALSE); /* label + button for tab */ t->tab_content = b; + gtk_widget_set_can_focus(t->tab_content, FALSE); t->user_agent_id = 0; t->http_accept_id = 0; @@ -7945,6 +7947,7 @@ create_button(char *name, char *stockid, int size) g_free(newstyle); #endif button = gtk_button_new(); + gtk_widget_set_can_focus(button, FALSE); gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE); gtk_icon_size = icon_size_map(size ? size : icon_size); @@ -7984,7 +7987,9 @@ create_canvas(void) vbox = gtk_vbox_new(FALSE, 0); #endif gtk_box_set_spacing(GTK_BOX(vbox), 0); + gtk_widget_set_can_focus(vbox, FALSE); notebook = GTK_NOTEBOOK(gtk_notebook_new()); + gtk_widget_set_name(notebook, "notebook"); #if !GTK_CHECK_VERSION(3, 0, 0) /* XXX seems to be needed with gtk+2 */ g_object_set(G_OBJECT(notebook), "tab-border", 0, NULL); @@ -7994,6 +7999,7 @@ create_canvas(void) gtk_widget_set_can_focus(GTK_WIDGET(notebook), FALSE); abtn = gtk_button_new(); + gtk_widget_set_can_focus(abtn, FALSE); arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); gtk_widget_set_name(abtn, "Arrow"); gtk_container_add(GTK_CONTAINER(abtn), arrow); |