summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-06-05 22:59:35 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-06-05 22:59:35 +0000
commit4d5b395f2c8b8ad765727114397f1291c13195dd (patch)
tree232d2451228a622160f2b3e2310f962f37076023 /gtk
parentde425c5d0fe4dd3cdbd1e53553cf689dfd23cab5 (diff)
downloadgtk+-4d5b395f2c8b8ad765727114397f1291c13195dd.tar.gz
Never scroll on focus in (#81893, Patch from Paolo Maggi)
Thu Jun 5 16:52:54 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtktextview.[ch]: Never scroll on focus in (#81893, Patch from Paolo Maggi) * gtk/gtktextview.c (gtk_text_view_scroll_[h]pages): Scroll to the current cursor location before handling the action, in case the user just tabbed in and the cursor is offscreen.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktextview.c35
-rw-r--r--gtk/gtktextview.h8
2 files changed, 18 insertions, 25 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 5d3c1fd317..d28c2a78c6 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -185,7 +185,6 @@ static gint gtk_text_view_motion_event (GtkWidget *widget,
static gint gtk_text_view_expose_event (GtkWidget *widget,
GdkEventExpose *expose);
static void gtk_text_view_draw_focus (GtkWidget *widget);
-static void gtk_text_view_grab_focus (GtkWidget *widget);
static gboolean gtk_text_view_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_text_view_select_all (GtkWidget *widget,
@@ -506,7 +505,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->focus_out_event = gtk_text_view_focus_out_event;
widget_class->motion_notify_event = gtk_text_view_motion_event;
widget_class->expose_event = gtk_text_view_expose_event;
- widget_class->grab_focus = gtk_text_view_grab_focus;
widget_class->focus = gtk_text_view_focus;
widget_class->drag_begin = gtk_text_view_drag_begin;
@@ -3814,9 +3812,7 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
text_view = GTK_TEXT_VIEW (widget);
- text_view->disable_scroll_on_focus = TRUE;
gtk_widget_grab_focus (widget);
- text_view->disable_scroll_on_focus = FALSE;
if (event->window != text_view->text_window->bin_window)
{
@@ -4188,21 +4184,6 @@ gtk_text_view_draw_focus (GtkWidget *widget)
}
}
-static void
-gtk_text_view_grab_focus (GtkWidget *widget)
-{
- GtkTextView *text_view;
-
- text_view = GTK_TEXT_VIEW (widget);
-
- GTK_WIDGET_CLASS (parent_class)->grab_focus (widget);
-
- if (!text_view->disable_scroll_on_focus)
- gtk_text_view_scroll_mark_onscreen (text_view,
- gtk_text_buffer_get_mark (get_buffer (text_view),
- "insert"));
-}
-
static gboolean
gtk_text_view_focus (GtkWidget *widget,
GtkDirectionType direction)
@@ -4667,7 +4648,14 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
adj = text_view->vadjustment;
- /* Validate the region that will be brought into view by the cursor motion
+ /* Make sure we start from the current cursor position, even
+ * if it was offscreen.
+ */
+ gtk_text_view_scroll_mark_onscreen (text_view,
+ gtk_text_buffer_get_mark (get_buffer (text_view),
+ "insert"));
+
+/* Validate the region that will be brought into view by the cursor motion
*/
if (count < 0)
{
@@ -4743,6 +4731,13 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
adj = text_view->hadjustment;
+ /* Make sure we start from the current cursor position, even
+ * if it was offscreen.
+ */
+ gtk_text_view_scroll_mark_onscreen (text_view,
+ gtk_text_buffer_get_mark (get_buffer (text_view),
+ "insert"));
+
/* Validate the line that we're moving within.
*/
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 0233f20839..3dd8d8d7eb 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -93,11 +93,9 @@ struct _GtkTextView
/* if we have reset the IM since the last character entered */
guint need_im_reset : 1;
- /* this flag is no longer used */
- guint just_selected_element : 1;
-
- /* disable scrolling to cursor on focus */
- guint disable_scroll_on_focus : 1;
+ /* these flags are no longer used */
+ guint reserved1 : 1;
+ guint reserved2 : 1;
/* debug flag - means that we've validated onscreen since the
* last "invalidate" signal from the layout