diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-09-09 21:47:03 +0200 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-09-10 20:39:08 +0200 |
commit | 428b2e4d86c920d17f98541ffd7304e1a4da7211 (patch) | |
tree | 276db8210e56337ed3f22d1a48afa89211e1b59e | |
parent | 37f456278eb569f55ccba70d6846b250cac4a01c (diff) |
gtkui: ctrl+click and cmd+click handling on osx
-rw-r--r-- | plugins/gtkui/ddblistview.c | 19 | ||||
-rw-r--r-- | plugins/gtkui/ddbtabstrip.c | 5 | ||||
-rw-r--r-- | plugins/gtkui/support.h | 8 |
3 files changed, 22 insertions, 10 deletions
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c index 6dc96a5c..3cecefd4 100644 --- a/plugins/gtkui/ddblistview.c +++ b/plugins/gtkui/ddblistview.c @@ -1503,11 +1503,16 @@ ddb_listview_list_mouse1_pressed (DdbListview *ps, int state, int ex, int ey, Gd ps->shift_sel_anchor = ps->binding->cursor (); } // handle multiple selection - if (!(state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK))) +#ifndef __APPLE__ + int selmask = GDK_CONTROL_MASK; +#else + int selmask = GDK_MOD2_MASK; +#endif + if (!(state & (selmask|GDK_SHIFT_MASK))) { ddb_listview_click_selection (ps, ex, ey, grp, grp_index, sel, 1, 1); } - else if (state & GDK_CONTROL_MASK) { + else if (state & selmask) { // toggle selection if (sel != -1) { DdbListviewIter it = ps->binding->get_for_idx (sel); @@ -1880,7 +1885,7 @@ ddb_listview_handle_keypress (DdbListview *ps, int keyval, int state) { GtkWidget *range = ps->scrollbar; GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (range)); - state &= (GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_MOD4_MASK); + state &= (GDK_SHIFT_MASK|GDK_CONTROL_MASK|GDK_MOD1_MASK|GDK_MOD2_MASK|GDK_MOD4_MASK); if (state & ~GDK_SHIFT_MASK) { return 0; @@ -2488,7 +2493,7 @@ ddb_listview_header_button_press_event (GtkWidget *widget, { DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); // ps->active_column = ddb_listview_header_get_column_for_coord (ps, event->x); - if (event->button == 1) { + if (TEST_LEFT_CLICK (event)) { // start sizing/dragging ps->header_dragging = -1; ps->header_sizing = -1; @@ -2516,7 +2521,7 @@ ddb_listview_header_button_press_event (GtkWidget *widget, x += w; } } - else if (event->button == 3) { + else if (TEST_RIGHT_CLICK (event)) { int idx = ddb_listview_header_get_column_idx_for_coord (ps, event->x); ps->binding->header_context_menu (ps, idx); } @@ -2674,10 +2679,10 @@ ddb_listview_list_button_press_event (GtkWidget *widget, { gtk_widget_grab_focus (widget); DdbListview *ps = DDB_LISTVIEW (g_object_get_data (G_OBJECT (widget), "owner")); - if (event->button == 1) { + if (TEST_LEFT_CLICK (event)) { ddb_listview_list_mouse1_pressed (ps, event->state, event->x, event->y, event->type); } - else if (event->button == 3) { + else if (TEST_RIGHT_CLICK(event)) { // get item under cursor DdbListviewGroup *grp; int grp_index; diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index bc180dc2..a6002265 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -890,8 +890,7 @@ on_tabstrip_button_press_event(GtkWidget *widget, { DdbTabStrip *ts = DDB_TABSTRIP (widget); tab_clicked = get_tab_under_cursor (ts, event->x); - if (event->button == 1) - { + if (TEST_LEFT_CLICK(event)) { int need_arrows = tabstrip_need_arrows (ts); if (need_arrows) { GtkAllocation a; @@ -950,7 +949,7 @@ on_tabstrip_button_press_event(GtkWidget *widget, ts->prev_x = event->x; tab_moved = 0; } - else if (event->button == 3) { + else if (TEST_RIGHT_CLICK(event)) { GtkWidget *menu = gtkui_create_pltmenu (tab_clicked); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, widget, 0, gtk_get_current_event_time()); } diff --git a/plugins/gtkui/support.h b/plugins/gtkui/support.h index 4fa7c0c5..a4e8088e 100644 --- a/plugins/gtkui/support.h +++ b/plugins/gtkui/support.h @@ -181,3 +181,11 @@ void gtk_widget_get_allocation (GtkWidget *widget, #define gtk_hscrollbar_new(adj) gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL,adj) #define gtk_vscrollbar_new(adj) gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL,adj) #endif + +#ifdef __APPLE__ +#define TEST_LEFT_CLICK(ev) (ev->button==1 && !TEST_RIGHT_CLICK(ev)) +#define TEST_RIGHT_CLICK(ev) (ev->button==3 || (ev->button==1 && (ev->state&(GDK_CONTROL_MASK|GDK_BUTTON3_MASK)))) +#else +#define TEST_LEFT_CLICK(ev) (ev->button==1) +#define TEST_RIGHT_CLICK(ev) (ev->button==3) +#endif |