diff options
-rw-r--r-- | callbacks.c | 17 | ||||
-rw-r--r-- | events.c | 3 | ||||
-rw-r--r-- | events.h | 2 | ||||
-rw-r--r-- | examples/config/uzbl/config | 3 | ||||
-rw-r--r-- | uzbl-core.c | 15 | ||||
-rw-r--r-- | uzbl-core.h | 3 |
6 files changed, 37 insertions, 6 deletions
diff --git a/callbacks.c b/callbacks.c index 622d71a..dd3008c 100644 --- a/callbacks.c +++ b/callbacks.c @@ -482,11 +482,20 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) { gboolean button_press_cb (GtkWidget* window, GdkEventButton* event) { (void) window; + gint context; if(event->type == GDK_BUTTON_PRESS) { if(uzbl.state.last_button) gdk_event_free((GdkEvent *)uzbl.state.last_button); uzbl.state.last_button = (GdkEventButton *)gdk_event_copy((GdkEvent *)event); + + /* left click */ + if(event->button == 1) { + context = get_click_context(); + + if((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) + send_event(FORM_ACTIVE, "", NULL); + } } return FALSE; @@ -619,15 +628,15 @@ populate_popup_cb(WebKitWebView *v, GtkMenu *m, void *c) { GtkWidget *item; MenuItem *mi; guint i=0; - WebKitHitTestResult *ht; - guint context, hit=0; + gint context, hit=0; if(!g->menu_items) return; /* check context */ - ht = webkit_web_view_get_hit_test_result(g->web_view, uzbl.state.last_button); - g_object_get(ht, "context", &context, NULL); + if((context = get_click_context()) == -1) + return; + for(i=0; i < uzbl.gui.menu_items->len; i++) { hit = 0; @@ -35,7 +35,8 @@ const char *event_table[LAST_EVENT] = { "INSTANCE_START" , "INSTANCE_EXIT" , "LOAD_PROGRESS" , - "LINK_UNHOVER" + "LINK_UNHOVER" , + "FORM_ACTIVE" }; void @@ -11,7 +11,7 @@ enum event_type { WEBINSPECTOR, NEW_WINDOW, SELECTION_CHANGED, VARIABLE_SET, FIFO_SET, SOCKET_SET, INSTANCE_START, INSTANCE_EXIT, LOAD_PROGRESS, - LINK_UNHOVER, + LINK_UNHOVER, FORM_ACTIVE, /* must be last entry */ LAST_EVENT diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 126c7e2..60c816d 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -42,6 +42,9 @@ set new_window = sh 'uzbl-browser -u $8' # equivalent to the default beh @on_event LOAD_FINISH @set_status <span foreground="gold">done</span> @on_event LOAD_FINISH spawn @scripts_dir/history.sh +# Switch to insert mode if clicked on a html form +@on_event FORM_ACTIVE @set_mode insert + # Misc on_event handlers #@on_event CONFIG_CHANGED print Config changed: %1 = %2 diff --git a/uzbl-core.c b/uzbl-core.c index 5d4447b..c2d0f90 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -488,6 +488,21 @@ clean_up(void) { unlink (uzbl.comm.socket_path); } +gint +get_click_context() { + GUI *g = &uzbl.gui; + WebKitHitTestResult *ht; + guint context; + + if(!uzbl.state.last_button) + return -1; + + ht = webkit_web_view_get_hit_test_result(g->web_view, uzbl.state.last_button); + g_object_get(ht, "context", &context, NULL); + + return (gint)context; +} + /* --- SIGNALS --- */ sigfunc* setup_signal(int signr, sigfunc *shandler) { diff --git a/uzbl-core.h b/uzbl-core.h index a6f34e4..104248a 100644 --- a/uzbl-core.h +++ b/uzbl-core.h @@ -459,6 +459,9 @@ menu_remove_link(WebKitWebView *page, GArray *argv, GString *result); void menu_remove_image(WebKitWebView *page, GArray *argv, GString *result); +gint +get_click_context(); + typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result); typedef struct { Command function; |