Kouhei Sutou
kou****@cozmi*****
2005年 10月 22日 (土) 18:56:38 JST
須藤です. 近くにSleipnirユーザがいて,「右クリックしながらスクロールす るとタブ移動できて便利なんだよねぇ」といっていたので,風博士 でもできるようにしてみました. コミットしていいですか? -------------- next part -------------- Index: src/kz-window.c =================================================================== RCS file: /cvsroot/kazehakase/kazehakase/src/kz-window.c,v retrieving revision 1.257 diff -u -p -r1.257 kz-window.c --- src/kz-window.c 18 Oct 2005 13:39:38 -0000 1.257 +++ src/kz-window.c 22 Oct 2005 09:56:18 -0000 @@ -88,6 +88,10 @@ struct _KzWindowPrivate gint start_x, start_y; gboolean is_gesture; + /* for scroll */ + gint is_button3_pressed; + gint is_button3_scrolled; + /* sidebar */ gboolean sidebar_was_shown; @@ -296,6 +300,9 @@ static gboolean cb_window_motion_notify_ static gboolean cb_window_button_release_event (GtkWidget *widget, GdkEventButton *event, KzEmbed *kzembed); +static gboolean cb_window_scroll_event (GtkWidget *widget, + GdkEventScroll *event, + KzEmbed *kzembed); /* notebook received dropped url */ static void cb_notebook_drag_data_received (GtkWidget *widget, @@ -444,6 +451,9 @@ kz_window_init (KzWindow *kz) priv->start_y = 0; priv->is_gesture = FALSE; + priv->is_button3_pressed = FALSE; + priv->is_button3_scrolled = FALSE; + priv->sidebar_was_shown = FALSE; priv->open_hist = NULL; @@ -1917,6 +1927,9 @@ kz_window_set_cur_embed_callbacks(KzWind g_signal_connect(kz, "button_release_event", G_CALLBACK(cb_window_button_release_event), kzembed); + g_signal_connect(kz, + "scroll_event", + G_CALLBACK(cb_window_scroll_event), kzembed); /* * key event signal @@ -1969,6 +1982,9 @@ kz_window_unset_cur_embed_callbacks(KzWi g_signal_handlers_disconnect_by_func (kz, G_CALLBACK(cb_window_button_release_event), kzembed); + g_signal_handlers_disconnect_by_func + (kz, + G_CALLBACK(cb_window_scroll_event), kzembed); /* * key event signal @@ -2643,14 +2659,13 @@ cb_gesture_stack_motion (KzGesture *gest static gboolean -cb_notebook_scroll_event (GtkWidget *widget, GdkEventScroll *event, - KzWindow *kz) +handle_scroll_event (KzWindow *kz, GdkScrollDirection direction) { GtkAction *action; g_return_val_if_fail(KZ_IS_WINDOW(kz), FALSE); - switch (event->direction) { + switch (direction) { case GDK_SCROLL_UP: case GDK_SCROLL_LEFT: action = gtk_action_group_get_action(kz->actions, "PrevTab"); @@ -2671,6 +2686,13 @@ cb_notebook_scroll_event (GtkWidget *wid return FALSE; } +static gboolean +cb_notebook_scroll_event (GtkWidget *widget, GdkEventScroll *event, + KzWindow *kz) +{ + return handle_scroll_event (kz, event->direction); +} + static void cb_sidebar_map (GtkWidget *widget, GtkToggleAction *action) @@ -3045,6 +3067,9 @@ cb_embed_dom_mouse_down (KzEmbed *kzembe gboolean use_gesture = TRUE; gint x, y, win_x, win_y, win_x_pos, win_y_pos; + priv->is_button3_pressed = TRUE; + priv->is_button3_scrolled = FALSE; + priv->is_gesture = FALSE; KZ_CONF_GET("Gesture", "use_gesture", use_gesture, BOOL); if (!use_gesture) @@ -3216,7 +3241,7 @@ cb_window_button_release_event (GtkWidge if (kz_gesture_is_started(priv->gesture)) { - if (event->button == 3) + if (event->button == 3 && !priv->is_button3_scrolled) kz_gesture_perform(priv->gesture); else kz_gesture_cancel(priv->gesture); @@ -3224,12 +3249,22 @@ cb_window_button_release_event (GtkWidge STATUS_GESTURE); } - if (!priv->is_gesture && event->button == 3) + if (!priv->is_gesture && + !priv->is_button3_scrolled && + event->button == 3) { kz_actions_popup_menu_modal (kz, event->button, event->time); retval = TRUE; } + if (event->button == 3) + { + if (priv->is_button3_scrolled) + retval = TRUE; + priv->is_button3_pressed = FALSE; + priv->is_button3_scrolled = FALSE; + } + priv->start_x = 0; priv->start_y = 0; priv->is_gesture = FALSE; @@ -3241,6 +3276,28 @@ cb_window_button_release_event (GtkWidge return retval; } +static gboolean +cb_window_scroll_event (GtkWidget *widget, + GdkEventScroll *event, + KzEmbed *kzembed) +{ + KzWindow *kz; + gboolean retval = FALSE; + KzWindowPrivate *priv; + + g_return_val_if_fail(KZ_IS_EMBED(kzembed), FALSE); + + kz = KZ_WINDOW(widget); + priv = KZ_WINDOW_GET_PRIVATE (kz); + + if (priv->is_button3_pressed) + { + retval = handle_scroll_event (kz, event->direction); + priv->is_button3_scrolled = retval; + } + + return retval; +} static void cb_notebook_drag_data_received (GtkWidget *widget,