diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 0a833cfcae..8e2c2b2f34 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -3696,7 +3696,7 @@ gtk_entry_button_press (GtkWidget *widget, entry->select_words = FALSE; entry->select_lines = FALSE; - if (event->state & GDK_SHIFT_MASK) + if (event->state & GTK_EXTEND_SELECTION_MOD_MASK) { _gtk_entry_reset_im_context (entry); diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 8ce402f1e4..54b3f3be84 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -183,8 +183,8 @@ struct _GtkIconViewPrivate guint reorderable : 1; guint empty_view_drop :1; - guint ctrl_pressed : 1; - guint shift_pressed : 1; + guint modify_selection_pressed : 1; + guint extend_selection_pressed : 1; guint draw_focus : 1; }; @@ -2177,7 +2177,7 @@ gtk_icon_view_button_press (GtkWidget *widget, gtk_icon_view_set_cursor_item (icon_view, item, cursor_cell); } else if (icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE && - (event->state & GDK_SHIFT_MASK)) + (event->state & GTK_EXTEND_SELECTION_MOD_MASK)) { gtk_icon_view_unselect_all_internal (icon_view); @@ -2194,7 +2194,7 @@ gtk_icon_view_button_press (GtkWidget *widget, { if ((icon_view->priv->selection_mode == GTK_SELECTION_MULTIPLE || ((icon_view->priv->selection_mode == GTK_SELECTION_SINGLE) && item->selected)) && - (event->state & GDK_CONTROL_MASK)) + (event->state & GTK_MODIFY_SELECTION_MOD_MASK)) { item->selected = !item->selected; gtk_icon_view_queue_draw_item (icon_view, item); @@ -2239,7 +2239,7 @@ gtk_icon_view_button_press (GtkWidget *widget, else { if (icon_view->priv->selection_mode != GTK_SELECTION_BROWSE && - !(event->state & GDK_CONTROL_MASK)) + !(event->state & GTK_MODIFY_SELECTION_MOD_MASK)) { dirty = gtk_icon_view_unselect_all_internal (icon_view); } @@ -3856,10 +3856,10 @@ gtk_icon_view_real_move_cursor (GtkIconView *icon_view, if (gtk_get_current_event_state (&state)) { - if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) - icon_view->priv->ctrl_pressed = TRUE; - if ((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) - icon_view->priv->shift_pressed = TRUE; + if ((state & GTK_MODIFY_SELECTION_MOD_MASK) == GTK_MODIFY_SELECTION_MOD_MASK) + icon_view->priv->modify_selection_pressed = TRUE; + if ((state & GTK_EXTEND_SELECTION_MOD_MASK) == GTK_EXTEND_SELECTION_MOD_MASK) + icon_view->priv->extend_selection_pressed = TRUE; } /* else we assume not pressed */ @@ -3882,8 +3882,8 @@ gtk_icon_view_real_move_cursor (GtkIconView *icon_view, g_assert_not_reached (); } - icon_view->priv->ctrl_pressed = FALSE; - icon_view->priv->shift_pressed = FALSE; + icon_view->priv->modify_selection_pressed = FALSE; + icon_view->priv->extend_selection_pressed = FALSE; icon_view->priv->draw_focus = TRUE; @@ -4154,15 +4154,15 @@ gtk_icon_view_move_cursor_up_down (GtkIconView *icon_view, return; } - if (icon_view->priv->ctrl_pressed || - !icon_view->priv->shift_pressed || + if (icon_view->priv->modify_selection_pressed || + !icon_view->priv->extend_selection_pressed || !icon_view->priv->anchor_item || icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) icon_view->priv->anchor_item = item; gtk_icon_view_set_cursor_item (icon_view, item, cell); - if (!icon_view->priv->ctrl_pressed && + if (!icon_view->priv->modify_selection_pressed && icon_view->priv->selection_mode != GTK_SELECTION_NONE) { dirty = gtk_icon_view_unselect_all_internal (icon_view); @@ -4209,15 +4209,15 @@ gtk_icon_view_move_cursor_page_up_down (GtkIconView *icon_view, if (!item) return; - if (icon_view->priv->ctrl_pressed || - !icon_view->priv->shift_pressed || + if (icon_view->priv->modify_selection_pressed || + !icon_view->priv->extend_selection_pressed || !icon_view->priv->anchor_item || icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) icon_view->priv->anchor_item = item; gtk_icon_view_set_cursor_item (icon_view, item, -1); - if (!icon_view->priv->ctrl_pressed && + if (!icon_view->priv->modify_selection_pressed && icon_view->priv->selection_mode != GTK_SELECTION_NONE) { dirty = gtk_icon_view_unselect_all_internal (icon_view); @@ -4291,15 +4291,15 @@ gtk_icon_view_move_cursor_left_right (GtkIconView *icon_view, return; } - if (icon_view->priv->ctrl_pressed || - !icon_view->priv->shift_pressed || + if (icon_view->priv->modify_selection_pressed || + !icon_view->priv->extend_selection_pressed || !icon_view->priv->anchor_item || icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) icon_view->priv->anchor_item = item; gtk_icon_view_set_cursor_item (icon_view, item, cell); - if (!icon_view->priv->ctrl_pressed && + if (!icon_view->priv->modify_selection_pressed && icon_view->priv->selection_mode != GTK_SELECTION_NONE) { dirty = gtk_icon_view_unselect_all_internal (icon_view); @@ -4338,15 +4338,15 @@ gtk_icon_view_move_cursor_start_end (GtkIconView *icon_view, if (!item) return; - if (icon_view->priv->ctrl_pressed || - !icon_view->priv->shift_pressed || + if (icon_view->priv->modify_selection_pressed || + !icon_view->priv->extend_selection_pressed || !icon_view->priv->anchor_item || icon_view->priv->selection_mode != GTK_SELECTION_MULTIPLE) icon_view->priv->anchor_item = item; gtk_icon_view_set_cursor_item (icon_view, item, -1); - if (!icon_view->priv->ctrl_pressed && + if (!icon_view->priv->modify_selection_pressed && icon_view->priv->selection_mode != GTK_SELECTION_NONE) { dirty = gtk_icon_view_unselect_all_internal (icon_view); diff --git a/gtk/gtkprivate.h b/gtk/gtkprivate.h index 9e1feb9032..8a80490fab 100644 --- a/gtk/gtkprivate.h +++ b/gtk/gtkprivate.h @@ -122,6 +122,14 @@ gboolean _gtk_fnmatch (const char *pattern, #define GTK_NO_TEXT_INPUT_MOD_MASK (GDK_MOD2_MASK | GDK_CONTROL_MASK) #endif +#ifndef GDK_WINDOWING_QUARTZ +#define GTK_EXTEND_SELECTION_MOD_MASK GDK_SHIFT_MASK +#define GTK_MODIFY_SELECTION_MOD_MASK GDK_CONTROL_MASK +#else +#define GTK_EXTEND_SELECTION_MOD_MASK GDK_SHIFT_MASK +#define GTK_MODIFY_SELECTION_MOD_MASK GDK_MOD2_MASK +#endif + G_END_DECLS #endif /* __GTK_PRIVATE_H__ */ diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 57316f632e..2061b5b7cd 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -4368,7 +4368,7 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event) if (gtk_text_buffer_get_selection_bounds (get_buffer (text_view), &start, &end) && gtk_text_iter_in_range (&iter, &start, &end) && - !(event->state & GDK_SHIFT_MASK)) + !(event->state & GTK_EXTEND_SELECTION_MOD_MASK)) { text_view->drag_start_x = event->x; text_view->drag_start_y = event->y; @@ -6295,7 +6295,7 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view, orig_start = ins; orig_end = bound; - if (button->state & GDK_SHIFT_MASK) + if (button->state & GTK_EXTEND_SELECTION_MOD_MASK) { /* Extend selection */ GtkTextIter old_ins, old_bound; diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h index acd6d6996d..82c52da3e7 100644 --- a/gtk/gtktreeprivate.h +++ b/gtk/gtktreeprivate.h @@ -211,8 +211,8 @@ struct _GtkTreeViewPrivate gint rubber_band_status; gint rubber_band_x; gint rubber_band_y; - gint rubber_band_shift; - gint rubber_band_ctrl; + gint rubber_band_extend; + gint rubber_band_modify; GtkRBNode *rubber_band_start_node; GtkRBTree *rubber_band_start_tree; @@ -276,8 +276,8 @@ struct _GtkTreeViewPrivate /* for DnD */ guint empty_view_drop : 1; - guint ctrl_pressed : 1; - guint shift_pressed : 1; + guint modify_selection_pressed : 1; + guint extend_selection_pressed : 1; guint init_hadjust_value : 1; diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index d66db75c90..6d6c46d3ce 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -2773,21 +2773,21 @@ gtk_tree_view_button_press (GtkWidget *widget, */ if (event->type == GDK_BUTTON_PRESS) { - if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) - tree_view->priv->ctrl_pressed = TRUE; - if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) - tree_view->priv->shift_pressed = TRUE; + if ((event->state & GTK_MODIFY_SELECTION_MOD_MASK) == GTK_MODIFY_SELECTION_MOD_MASK) + tree_view->priv->modify_selection_pressed = TRUE; + if ((event->state & GTK_EXTEND_SELECTION_MOD_MASK) == GTK_EXTEND_SELECTION_MOD_MASK) + tree_view->priv->extend_selection_pressed = TRUE; focus_cell = _gtk_tree_view_column_get_cell_at_pos (column, event->x - background_area.x); if (focus_cell) gtk_tree_view_column_focus_cell (column, focus_cell); - if (event->state & GDK_CONTROL_MASK) + if (event->state & GTK_MODIFY_SELECTION_MOD_MASK) { gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE); gtk_tree_view_real_toggle_cursor_row (tree_view); } - else if (event->state & GDK_SHIFT_MASK) + else if (event->state & GTK_EXTEND_SELECTION_MOD_MASK) { gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE); gtk_tree_view_real_select_cursor_row (tree_view, FALSE); @@ -2797,8 +2797,8 @@ gtk_tree_view_button_press (GtkWidget *widget, gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE); } - tree_view->priv->ctrl_pressed = FALSE; - tree_view->priv->shift_pressed = FALSE; + tree_view->priv->modify_selection_pressed = FALSE; + tree_view->priv->extend_selection_pressed = FALSE; } /* the treeview may have been scrolled because of _set_cursor, @@ -2830,10 +2830,10 @@ gtk_tree_view_button_press (GtkWidget *widget, tree_view->priv->rubber_band_y = event->y + tree_view->priv->dy; tree_view->priv->rubber_band_status = RUBBER_BAND_MAYBE_START; - if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) - tree_view->priv->rubber_band_ctrl = TRUE; - if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) - tree_view->priv->rubber_band_shift = TRUE; + if ((event->state & GTK_MODIFY_SELECTION_MOD_MASK) == GTK_MODIFY_SELECTION_MOD_MASK) + tree_view->priv->rubber_band_modify = TRUE; + if ((event->state & GTK_EXTEND_SELECTION_MOD_MASK) == GTK_EXTEND_SELECTION_MOD_MASK) + tree_view->priv->rubber_band_extend = TRUE; } } @@ -3791,8 +3791,8 @@ gtk_tree_view_stop_rubber_band (GtkTreeView *tree_view) /* Clear status variables */ tree_view->priv->rubber_band_status = RUBBER_BAND_OFF; - tree_view->priv->rubber_band_shift = 0; - tree_view->priv->rubber_band_ctrl = 0; + tree_view->priv->rubber_band_extend = FALSE; + tree_view->priv->rubber_band_modify = FALSE; tree_view->priv->rubber_band_start_node = NULL; tree_view->priv->rubber_band_start_tree = NULL; @@ -3837,9 +3837,9 @@ gtk_tree_view_update_rubber_band_selection_range (GtkTreeView *tree_view, if (select) { - if (tree_view->priv->rubber_band_shift) - GTK_RBNODE_SET_FLAG (start_node, GTK_RBNODE_IS_SELECTED); - else if (tree_view->priv->rubber_band_ctrl) + if (tree_view->priv->rubber_band_extend) + GTK_RBNODE_SET_FLAG (start_node, GTK_RBNODE_IS_SELECTED); + else if (tree_view->priv->rubber_band_modify) { /* Toggle the selection state */ if (GTK_RBNODE_FLAG_SET (start_node, GTK_RBNODE_IS_SELECTED)) @@ -3853,9 +3853,9 @@ gtk_tree_view_update_rubber_band_selection_range (GtkTreeView *tree_view, else { /* Mirror the above */ - if (tree_view->priv->rubber_band_shift) + if (tree_view->priv->rubber_band_extend) GTK_RBNODE_UNSET_FLAG (start_node, GTK_RBNODE_IS_SELECTED); - else if (tree_view->priv->rubber_band_ctrl) + else if (tree_view->priv->rubber_band_modify) { /* Toggle the selection state */ if (GTK_RBNODE_FLAG_SET (start_node, GTK_RBNODE_IS_SELECTED)) @@ -8203,10 +8203,10 @@ gtk_tree_view_real_move_cursor (GtkTreeView *tree_view, if (gtk_get_current_event_state (&state)) { - if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) - tree_view->priv->ctrl_pressed = TRUE; - if ((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) - tree_view->priv->shift_pressed = TRUE; + if ((state & GTK_MODIFY_SELECTION_MOD_MASK) == GTK_MODIFY_SELECTION_MOD_MASK) + tree_view->priv->modify_selection_pressed = TRUE; + if ((state & GTK_EXTEND_SELECTION_MOD_MASK) == GTK_EXTEND_SELECTION_MOD_MASK) + tree_view->priv->extend_selection_pressed = TRUE; } /* else we assume not pressed */ @@ -8230,8 +8230,8 @@ gtk_tree_view_real_move_cursor (GtkTreeView *tree_view, g_assert_not_reached (); } - tree_view->priv->ctrl_pressed = FALSE; - tree_view->priv->shift_pressed = FALSE; + tree_view->priv->modify_selection_pressed = FALSE; + tree_view->priv->extend_selection_pressed = FALSE; return TRUE; } @@ -9690,7 +9690,7 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view, if (selection_count == 0 && tree_view->priv->selection->type != GTK_SELECTION_NONE - && !tree_view->priv->ctrl_pressed + && !tree_view->priv->modify_selection_pressed && selectable) { /* Don't move the cursor, but just select the current node */ @@ -9759,7 +9759,7 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view, { gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node); - if (!tree_view->priv->shift_pressed) + if (!tree_view->priv->extend_selection_pressed) { if (! gtk_widget_keynav_failed (GTK_WIDGET (tree_view), count < 0 ? @@ -10111,7 +10111,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, return FALSE; } - if (!tree_view->priv->shift_pressed && start_editing && + if (!tree_view->priv->extend_selection_pressed && start_editing && tree_view->priv->focus_column) { if (gtk_tree_view_start_editing (tree_view, cursor_path)) @@ -10121,9 +10121,9 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, } } - if (tree_view->priv->ctrl_pressed) + if (tree_view->priv->modify_selection_pressed) mode |= GTK_TREE_SELECT_MODE_TOGGLE; - if (tree_view->priv->shift_pressed) + if (tree_view->priv->extend_selection_pressed) mode |= GTK_TREE_SELECT_MODE_EXTEND; _gtk_tree_selection_internal_select_node (tree_view->priv->selection, @@ -10147,7 +10147,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, gtk_widget_grab_focus (GTK_WIDGET (tree_view)); _gtk_tree_view_queue_draw_node (tree_view, cursor_tree, cursor_node, NULL); - if (!tree_view->priv->shift_pressed) + if (!tree_view->priv->extend_selection_pressed) gtk_tree_view_row_activated (tree_view, cursor_path, tree_view->priv->focus_column); @@ -10285,8 +10285,8 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view) if (gtk_get_current_event_state (&state)) { - if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) - tree_view->priv->ctrl_pressed = TRUE; + if ((state & GTK_MODIFY_SELECTION_MOD_MASK) == GTK_MODIFY_SELECTION_MOD_MASK) + tree_view->priv->modify_selection_pressed = TRUE; } gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, FALSE); @@ -10296,7 +10296,7 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view) gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); gtk_tree_path_free (cursor_path); - tree_view->priv->ctrl_pressed = FALSE; + tree_view->priv->modify_selection_pressed = FALSE; return TRUE; } @@ -12579,13 +12579,13 @@ gtk_tree_view_real_set_cursor (GtkTreeView *tree_view, GtkRBTree *new_tree = NULL; GtkRBNode *new_node = NULL; - if (clear_and_select && !tree_view->priv->ctrl_pressed) + if (clear_and_select && !tree_view->priv->modify_selection_pressed) { GtkTreeSelectMode mode = 0; - if (tree_view->priv->ctrl_pressed) + if (tree_view->priv->modify_selection_pressed) mode |= GTK_TREE_SELECT_MODE_TOGGLE; - if (tree_view->priv->shift_pressed) + if (tree_view->priv->extend_selection_pressed) mode |= GTK_TREE_SELECT_MODE_EXTEND; _gtk_tree_selection_internal_select_node (tree_view->priv->selection,