diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 22:30:22 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 22:30:22 +0000 |
commit | 17887ce2fc1df2d657009aa41cd195d82d5b1f89 (patch) | |
tree | 81c2f1a0447789642b1cea010c944359046e592a | |
parent | 0b13387221dc34d31a7f4526bb80c894a8f9a053 (diff) | |
download | chromium_src-17887ce2fc1df2d657009aa41cd195d82d5b1f89.zip chromium_src-17887ce2fc1df2d657009aa41cd195d82d5b1f89.tar.gz chromium_src-17887ce2fc1df2d657009aa41cd195d82d5b1f89.tar.bz2 |
linux: don't override mouse selection behavior in omnibox
This means we now don't match Windows Chrome (which selects all on single
click) nor Firefox (which selects all on double click).
Patch by Dan Erat; I'm submitting it on his behalf.
This is an EXPERIMENT. I may revert it at my own discretion.
If you don't like it, please complain at
http://code.google.com/p/chromium/issues/detail?id=26140
so your feedback can be tallied.
BUG=11614,12713,19508,others.
TEST=single click in omnibox does not select all
Review URL: http://codereview.chromium.org/340024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30400 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 79 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.h | 13 |
2 files changed, 2 insertions, 90 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index e46e377..fd13ee1 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -103,9 +103,6 @@ AutocompleteEditViewGtk::AutocompleteEditViewGtk( popup_window_mode_(popup_window_mode), scheme_security_level_(ToolbarModel::NORMAL), mark_set_handler_id_(0), - button_1_pressed_(false), - text_selected_during_click_(false), - text_view_focused_before_button_press_(false), #if !defined(TOOLKIT_VIEWS) theme_provider_(GtkThemeProvider::GetFrom(profile)), #endif @@ -192,10 +189,6 @@ void AutocompleteEditViewGtk::Init() { G_CALLBACK(&HandleKeyPressThunk), this); g_signal_connect(text_view_, "key-release-event", G_CALLBACK(&HandleKeyReleaseThunk), this); - g_signal_connect(text_view_, "button-press-event", - G_CALLBACK(&HandleViewButtonPressThunk), this); - g_signal_connect(text_view_, "button-release-event", - G_CALLBACK(&HandleViewButtonReleaseThunk), this); g_signal_connect(text_view_, "focus-in-event", G_CALLBACK(&HandleViewFocusInThunk), this); g_signal_connect(text_view_, "focus-out-event", @@ -390,8 +383,6 @@ void AutocompleteEditViewGtk::SelectAll(bool reversed) { // SelectAll() is invoked as a side effect of other actions (e.g. switching // tabs or hitting Escape) in autocomplete_edit.cc, so we don't update the // PRIMARY selection here. - // TODO(derat): But this is also called by LocationBarView::FocusLocation() -- - // should the X selection be updated when the user hits Ctrl-L? SelectAllInternal(reversed, false); } @@ -724,63 +715,6 @@ gboolean AutocompleteEditViewGtk::HandleKeyRelease(GtkWidget* widget, return FALSE; // Propagate into GtkTextView. } -gboolean AutocompleteEditViewGtk::HandleViewButtonPress(GdkEventButton* event) { - // We don't need to care about double and triple clicks. - if (event->type != GDK_BUTTON_PRESS) - return FALSE; - - if (event->button == 1) { - // When the first button is pressed, track some stuff that will help us - // determine whether we should select all of the text when the button is - // released. - button_1_pressed_ = true; - text_view_focused_before_button_press_ = GTK_WIDGET_HAS_FOCUS(text_view_); - text_selected_during_click_ = false; - - // Button press event may change the selection, we need to record the change - // and report it to |model_| later when button is released. - OnBeforePossibleChange(); - } else if (event->button == 2) { - // GtkTextView pastes PRIMARY selection with middle click. - // We can't call model_->on_paste_replacing_all() here, because the actual - // paste clipboard action may not be performed if the clipboard is empty. - paste_clipboard_requested_ = true; - } - return FALSE; -} - -gboolean AutocompleteEditViewGtk::HandleViewButtonRelease( - GdkEventButton* event) { - if (event->button != 1) - return FALSE; - - button_1_pressed_ = false; - - // Call the GtkTextView default handler, ignoring the fact that it will - // likely have told us to stop propagating. We want to handle selection. - GtkWidgetClass* klass = GTK_WIDGET_GET_CLASS(text_view_); - klass->button_release_event(text_view_, event); - - if (!text_view_focused_before_button_press_ && !text_selected_during_click_) { - // If this was a focusing click and the user didn't drag to highlight any - // text, select the full input and update the PRIMARY selection. - SelectAllInternal(false, true); - - // So we told the buffer where the cursor should be, but make sure to tell - // the view so it can scroll it to be visible if needed. - // NOTE: This function doesn't seem to like a count of 0, looking at the - // code it will skip an important loop. Use -1 to achieve the same. - GtkTextIter start, end; - gtk_text_buffer_get_bounds(text_buffer_, &start, &end); - gtk_text_view_move_visually(GTK_TEXT_VIEW(text_view_), &start, -1); - } - - // Inform |model_| about possible text selection change. - OnAfterPossibleChange(); - - return TRUE; // Don't continue, we called the default handler already. -} - gboolean AutocompleteEditViewGtk::HandleViewFocusIn() { GdkModifierType modifiers; gdk_window_get_pointer(text_view_->window, NULL, NULL, &modifiers); @@ -913,19 +847,11 @@ void AutocompleteEditViewGtk::HandleMarkSet(GtkTextBuffer* buffer, if (gtk_text_buffer_get_selection_bounds(text_buffer_, &start, &end)) { gchar* text = gtk_text_iter_get_text(&start, &end); size_t text_len = strlen(text); - if (text_len) { + if (text_len) new_selected_text = std::string(text, text_len); - } g_free(text); } - // If the user just selected some text with the mouse (or at least while the - // mouse button was down), make sure that we won't blow their selection away - // later by selecting all of the text when the button is released. - if (button_1_pressed_ && !new_selected_text.empty()) { - text_selected_during_click_ = true; - } - // If we had some text selected earlier but it's no longer highlighted, we // might need to save it now... if (!selected_text_.empty() && new_selected_text.empty()) { @@ -937,9 +863,8 @@ void AutocompleteEditViewGtk::HandleMarkSet(GtkTextBuffer* buffer, // selection, the text buffer still owns it even if GTK is about to take it // away in the default handler.) GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); - if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(text_buffer_)) { + if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(text_buffer_)) SavePrimarySelection(selected_text_); - } } selected_text_ = new_selected_text; diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h index 3c16392..adef44c 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h @@ -383,19 +383,6 @@ class AutocompleteEditViewGtk : public AutocompleteEditView, // ID of the signal handler for "mark-set" on |text_buffer_|. gulong mark_set_handler_id_; - // Is the first mouse button currently down? - bool button_1_pressed_; - - // Did the user change the selected text in the middle of the current click? - // If so, we don't select all of the text when the button is released -- we - // don't want to blow away their selection. - bool text_selected_during_click_; - - // Was the text view already focused before the user clicked in it? We use - // this to figure out whether we should select all of the text when the button - // is released (we only do so if the view was initially unfocused). - bool text_view_focused_before_button_press_; - #if !defined(TOOLKIT_VIEWS) // Supplies colors, et cetera. GtkThemeProvider* theme_provider_; |