summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorChristian Neumair <cneumair@gnome.org>2008-07-12 15:42:10 +0000
committerChristian Neumair <cneumair@src.gnome.org>2008-07-12 15:42:10 +0000
commitb6685a5b265eefa22e073a2cd8df4669bd89e7b8 (patch)
treeb9b726ea6d110c1d60278506d66731fcf4b415e8 /libnautilus-private
parent4eabe43b461884d68439b2018851c22926d8050b (diff)
downloadnautilus-b6685a5b265eefa22e073a2cd8df4669bd89e7b8.tar.gz
Completely rewrite button press detection. Finally fixes #542269 without
2008-07-12 Christian Neumair <cneumair@gnome.org> * libnautilus-private/nautilus-icon-container.c (button_press_event): * libnautilus-private/nautilus-icon-private.h: Completely rewrite button press detection. Finally fixes #542269 without any side effects. svn path=/trunk/; revision=14350
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/nautilus-icon-container.c81
-rw-r--r--libnautilus-private/nautilus-icon-private.h4
2 files changed, 46 insertions, 39 deletions
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index fd3c899e4..0307f5cb7 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -3667,7 +3667,12 @@ button_press_event (GtkWidget *widget,
/* Forget about where we began with the arrow keys now that we're mousing. */
container->details->arrow_key_axis = AXIS_NONE;
-
+
+ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) {
+ /* We use our own double-click detection. */
+ return TRUE;
+ }
+
/* Invoke the canvas event handler and see if an item picks up the event. */
clicked_on_icon = GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
@@ -3682,13 +3687,6 @@ button_press_event (GtkWidget *widget,
return TRUE;
}
- /* An item didn't take the press, so it's a background press.
- * We ignore double clicks on the desktop for now.
- */
- if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) {
- return TRUE;
- }
-
if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) &&
event->type == GDK_BUTTON_PRESS) {
/* Clear the last click icon for double click */
@@ -5555,6 +5553,38 @@ typedef struct {
GdkEventButton *event;
} ContextMenuParameters;
+static gboolean
+handle_icon_double_click (NautilusIconContainer *container,
+ NautilusIcon *icon,
+ GdkEventButton *event)
+{
+ NautilusIconContainerDetails *details;
+
+ details = container->details;
+
+ if (!details->single_click_mode &&
+ clicked_within_double_click_interval (container) &&
+ details->double_click_icon[0] == details->double_click_icon[1] &&
+ details->double_click_button[0] == details->double_click_button[1]) {
+ if (!button_event_modifies_selection (event)) {
+ if (event->button == MIDDLE_BUTTON) {
+ activate_selected_items_alternate (container, NULL);
+ return TRUE;
+ else if (event->button == DRAG_BUTTON) {
+ activate_selected_items (container);
+ return TRUE;
+ }
+ } else if (event->button == DRAG_BUTTON &&
+ (event->state & GDK_CONTROL_MASK) == 0 &&
+ (event->state & GDK_SHIFT_MASK) != 0) {
+ activate_selected_items_alternate (container, icon);
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
/* NautilusIcon event handling. */
/* Conceptually, pressing button 1 together with CTRL or SHIFT toggles
@@ -5575,13 +5605,7 @@ handle_icon_button_press (NautilusIconContainer *container,
details = container->details;
- if (event->type == GDK_3BUTTON_PRESS) {
- return TRUE;
- }
-
- if (details->single_click_mode &&
- event->type == GDK_2BUTTON_PRESS) {
- /* Don't care about double clicks in single click mode */
+ if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) {
return TRUE;
}
@@ -5596,32 +5620,21 @@ handle_icon_button_press (NautilusIconContainer *container,
/* The next double click has to be on this icon */
details->double_click_icon[1] = details->double_click_icon[0];
details->double_click_icon[0] = icon;
+
+ details->double_click_button[1] = details->double_click_button[0];
+ details->double_click_button[0] = event->button;
}
- if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON)
- && (!details->single_click_mode && clicked_within_double_click_interval(container) && details->icon_revealed)) {
+ if (handle_icon_double_click (container, icon, event)) {
/* Double clicking does not trigger a D&D action. */
details->drag_button = 0;
details->drag_icon = NULL;
-
- if (icon == details->double_click_icon[1]) {
- if (!button_event_modifies_selection (event)) {
- if (event->button == MIDDLE_BUTTON) {
- activate_selected_items_alternate (container, NULL);
- } else {
- activate_selected_items (container);
- }
- } else if (event->button == DRAG_BUTTON &&
- (event->state & GDK_SHIFT_MASK) != 0) {
- activate_selected_items_alternate (container, icon);
- }
- }
- details->icon_revealed = FALSE;
return TRUE;
}
+
if (event->button == DRAG_BUTTON
|| event->button == DRAG_MENU_BUTTON) {
- details->drag_button = event->button;
+ details->drag_button = event->button;
details->drag_icon = icon;
details->drag_x = event->x;
details->drag_y = event->y;
@@ -5665,12 +5678,9 @@ handle_icon_button_press (NautilusIconContainer *container,
signals[SELECTION_CHANGED], 0);
} else {
select_one_unselect_others (container, icon);
- details->icon_revealed = TRUE;
g_signal_emit (container,
signals[SELECTION_CHANGED], 0);
}
- } else {
- details->icon_revealed = TRUE;
}
if (event->button == CONTEXTUAL_MENU_BUTTON) {
@@ -5700,7 +5710,6 @@ item_event_callback (EelCanvasItem *item,
switch (event->type) {
case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
if (handle_icon_button_press (container, icon, &event->button)) {
/* Stop the event from being passed along further. Returning
* TRUE ain't enough.
diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h
index e843381a8..a110b74ef 100644
--- a/libnautilus-private/nautilus-icon-private.h
+++ b/libnautilus-private/nautilus-icon-private.h
@@ -170,6 +170,7 @@ struct NautilusIconContainerDetails {
gboolean icon_selected_on_button_down;
NautilusIcon *double_click_icon[2]; /* Both clicks in a double click need to be on the same icon */
+ guint double_click_button[2];
NautilusIcon *range_selection_base_icon;
@@ -281,9 +282,6 @@ struct NautilusIconContainerDetails {
GtkWidget *search_entry;
guint search_entry_changed_id;
guint typeselect_flush_timeout;
-
- /* Needed for dblclicking activation of partially shown icons, see bug #347423 */
- gboolean icon_revealed;
};
/* Private functions shared by mutiple files. */