diff options
author | Rob <rob.manea@gmail.com> | 2009-11-09 13:01:46 +0100 |
---|---|---|
committer | Rob <rob.manea@gmail.com> | 2009-11-09 13:01:46 +0100 |
commit | 30a7691ff43f9c97471ba3c36a3dcd75b5096ae3 (patch) | |
tree | f0d3d4a3d05ade325aa5d3bef5c6c78f5691a010 /callbacks.c | |
parent | c28aa99ebcf0df79b1015d9fd41a5f4382306c4c (diff) |
reworked mouse button events
Diffstat (limited to 'callbacks.c')
-rw-r--r-- | callbacks.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/callbacks.c b/callbacks.c index db738f7..cf7a867 100644 --- a/callbacks.c +++ b/callbacks.c @@ -40,7 +40,7 @@ void cmd_set_geometry() { int ret=0, x=0, y=0; unsigned int w=0, h=0; - /* we used to use gtk_window_parse_geometry() but that didn't work how it was supposed to */ + ret = XParseGeometry(uzbl.gui.geometry, &x, &y, &w, &h); if(ret & XValue) gtk_window_move((GtkWindow *)uzbl.gui.main_window, x, y); @@ -475,41 +475,68 @@ button_press_cb (GtkWidget* window, GdkEventButton* event) { (void) window; gint context; gchar *details; + gboolean propagate = FALSE, + sendev = FALSE; 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); + context = get_click_context(NULL); /* left click */ if(event->button == 1) { - context = get_click_context(); - if((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) send_event(FORM_ACTIVE, "button1", NULL); else if((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT)) send_event(ROOT_ACTIVE, "button1", NULL); } - details = g_strdup_printf("Button%d", event->button); - send_event(KEY_PRESS, details, NULL); - g_free(details); + else if(event->button == 2 && !(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) { + sendev = TRUE; + propagate = TRUE; + } + else if(event->button > 3) { + sendev = TRUE; + propagate = TRUE; + } + + if(sendev) { + details = g_strdup_printf("Button%d", event->button); + send_event(KEY_PRESS, details, NULL); + g_free(details); + } } - return FALSE; + return propagate; } gboolean button_release_cb (GtkWidget* window, GdkEventButton* event) { (void) window; + gint context; gchar *details; + gboolean propagate = FALSE, + sendev = FALSE; + context = get_click_context(NULL); if(event->type == GDK_BUTTON_RELEASE) { - details = g_strdup_printf("Button%d", event->button); - send_event(KEY_RELEASE, details, NULL); - g_free(details); + if(event->button == 2 && !(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) { + sendev = TRUE; + propagate = TRUE; + } + else if(event->button > 3) { + sendev = TRUE; + propagate = TRUE; + } + + if(sendev) { + details = g_strdup_printf("Button%d", event->button); + send_event(KEY_RELEASE, details, NULL); + g_free(details); + } } - return FALSE; + return propagate; } gboolean @@ -645,7 +672,7 @@ populate_popup_cb(WebKitWebView *v, GtkMenu *m, void *c) { return; /* check context */ - if((context = get_click_context()) == -1) + if((context = get_click_context(NULL)) == -1) return; |