From 83cda922f28dfff9c5b0dd8946d1d378afc3a26b Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Wed, 13 Nov 2002 17:20:33 +0000 Subject: [PATCH] When clicking on a non-active tab, focus the first widget in the tab, not Wed Nov 13 11:55:25 2002 Owen Taylor * gtk/gtknotebook.c (gtk_notebook_button_press): When clicking on a non-active tab, focus the first widget in the tab, not the tab itself. (#98322) * gtk/gtknotebook.c (gtk_notebook_focus_changed): Eliminate synchronous drawing, just call redraw_tabs. * gtk/gtknotebook.c (gtk_notebook_init): Don't set the RECEIVES_DEFAULT flag, we no longer do anything with Return/Enter key. --- ChangeLog | 13 +++++++++ ChangeLog.pre-2-10 | 13 +++++++++ ChangeLog.pre-2-2 | 13 +++++++++ ChangeLog.pre-2-4 | 13 +++++++++ ChangeLog.pre-2-6 | 13 +++++++++ ChangeLog.pre-2-8 | 13 +++++++++ gtk/gtknotebook.c | 73 +++++++--------------------------------------- 7 files changed, 89 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cc77b39ab..19f84a210a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Wed Nov 13 11:55:25 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_button_press): + When clicking on a non-active tab, focus the first + widget in the tab, not the tab itself. (#98322) + + * gtk/gtknotebook.c (gtk_notebook_focus_changed): + Eliminate synchronous drawing, just call redraw_tabs. + + * gtk/gtknotebook.c (gtk_notebook_init): Don't set + the RECEIVES_DEFAULT flag, we no longer do anything + with Return/Enter key. + Tue Nov 12 17:10:10 2002 Owen Taylor * gtk/gtkcombo.c: Fix up grabs to be robust; grab diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0cc77b39ab..19f84a210a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +Wed Nov 13 11:55:25 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_button_press): + When clicking on a non-active tab, focus the first + widget in the tab, not the tab itself. (#98322) + + * gtk/gtknotebook.c (gtk_notebook_focus_changed): + Eliminate synchronous drawing, just call redraw_tabs. + + * gtk/gtknotebook.c (gtk_notebook_init): Don't set + the RECEIVES_DEFAULT flag, we no longer do anything + with Return/Enter key. + Tue Nov 12 17:10:10 2002 Owen Taylor * gtk/gtkcombo.c: Fix up grabs to be robust; grab diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 0cc77b39ab..19f84a210a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,16 @@ +Wed Nov 13 11:55:25 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_button_press): + When clicking on a non-active tab, focus the first + widget in the tab, not the tab itself. (#98322) + + * gtk/gtknotebook.c (gtk_notebook_focus_changed): + Eliminate synchronous drawing, just call redraw_tabs. + + * gtk/gtknotebook.c (gtk_notebook_init): Don't set + the RECEIVES_DEFAULT flag, we no longer do anything + with Return/Enter key. + Tue Nov 12 17:10:10 2002 Owen Taylor * gtk/gtkcombo.c: Fix up grabs to be robust; grab diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0cc77b39ab..19f84a210a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +Wed Nov 13 11:55:25 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_button_press): + When clicking on a non-active tab, focus the first + widget in the tab, not the tab itself. (#98322) + + * gtk/gtknotebook.c (gtk_notebook_focus_changed): + Eliminate synchronous drawing, just call redraw_tabs. + + * gtk/gtknotebook.c (gtk_notebook_init): Don't set + the RECEIVES_DEFAULT flag, we no longer do anything + with Return/Enter key. + Tue Nov 12 17:10:10 2002 Owen Taylor * gtk/gtkcombo.c: Fix up grabs to be robust; grab diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0cc77b39ab..19f84a210a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +Wed Nov 13 11:55:25 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_button_press): + When clicking on a non-active tab, focus the first + widget in the tab, not the tab itself. (#98322) + + * gtk/gtknotebook.c (gtk_notebook_focus_changed): + Eliminate synchronous drawing, just call redraw_tabs. + + * gtk/gtknotebook.c (gtk_notebook_init): Don't set + the RECEIVES_DEFAULT flag, we no longer do anything + with Return/Enter key. + Tue Nov 12 17:10:10 2002 Owen Taylor * gtk/gtkcombo.c: Fix up grabs to be robust; grab diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0cc77b39ab..19f84a210a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +Wed Nov 13 11:55:25 2002 Owen Taylor + + * gtk/gtknotebook.c (gtk_notebook_button_press): + When clicking on a non-active tab, focus the first + widget in the tab, not the tab itself. (#98322) + + * gtk/gtknotebook.c (gtk_notebook_focus_changed): + Eliminate synchronous drawing, just call redraw_tabs. + + * gtk/gtknotebook.c (gtk_notebook_init): Don't set + the RECEIVES_DEFAULT flag, we no longer do anything + with Return/Enter key. + Tue Nov 12 17:10:10 2002 Owen Taylor * gtk/gtkcombo.c: Fix up grabs to be robust; grab diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 27567ecc88..572d3bc5c0 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -188,8 +188,6 @@ static void gtk_notebook_forall (GtkContainer *container, /*** GtkNotebook Private Functions ***/ static void gtk_notebook_redraw_tabs (GtkNotebook *notebook); static void gtk_notebook_redraw_arrows (GtkNotebook *notebook); -static void gtk_notebook_focus_changed (GtkNotebook *notebook, - GtkNotebookPage *old_page); static void gtk_notebook_real_remove (GtkNotebook *notebook, GList *list); static void gtk_notebook_update_labels (GtkNotebook *notebook); @@ -576,7 +574,7 @@ gtk_notebook_class_init (GtkNotebookClass *class) static void gtk_notebook_init (GtkNotebook *notebook) { - GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS | GTK_RECEIVES_DEFAULT); + GTK_WIDGET_SET_FLAGS (notebook, GTK_CAN_FOCUS); GTK_WIDGET_SET_FLAGS (notebook, GTK_NO_WINDOW); notebook->cur_page = NULL; @@ -1611,24 +1609,15 @@ gtk_notebook_button_press (GtkWidget *widget, (x <= (page->allocation.x + page->allocation.width)) && (y <= (page->allocation.y + page->allocation.height))) { - if (page == notebook->cur_page && notebook->focus_tab && - notebook->focus_tab != children && - GTK_WIDGET_HAS_FOCUS (notebook)) - { - GtkNotebookPage *old_page; - - notebook->child_has_focus = FALSE; - old_page = (GtkNotebookPage *) - (notebook->focus_tab->data); - gtk_notebook_switch_focus_tab (notebook, children); - gtk_notebook_focus_changed (notebook, old_page); - } - else - { - gtk_notebook_switch_focus_tab (notebook, children); - gtk_widget_grab_focus (widget); - gtk_notebook_switch_page (notebook, page, num); - } + gboolean page_changed = page != notebook->cur_page; + gboolean was_focus = gtk_widget_is_focus (notebook); + + gtk_notebook_switch_focus_tab (notebook, children); + gtk_widget_grab_focus (widget); + + if (page_changed && !was_focus) + gtk_widget_child_focus (page->child, GTK_DIR_TAB_FORWARD); + break; } children = children->next; @@ -2207,7 +2196,6 @@ gtk_notebook_child_type (GtkContainer *container) /* Private GtkNotebook Functions: * * gtk_notebook_redraw_tabs - * gtk_notebook_focus_changed * gtk_notebook_real_remove * gtk_notebook_update_labels * gtk_notebook_timer @@ -2284,45 +2272,6 @@ gtk_notebook_redraw_arrows (GtkNotebook *notebook) } } -static void -gtk_notebook_focus_changed (GtkNotebook *notebook, - GtkNotebookPage *old_page) -{ - g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); - - if (GTK_WIDGET_DRAWABLE (notebook) && notebook->show_tabs) - { - GdkRectangle area; - gint focus_width; - - gtk_widget_style_get (GTK_WIDGET (notebook), "focus-line-width", &focus_width, NULL); - - if (notebook->focus_tab) - { - GtkNotebookPage *page; - - page = notebook->focus_tab->data; - - area.x = page->tab_label->allocation.x - focus_width; - area.y = page->tab_label->allocation.y - focus_width; - area.width = page->tab_label->allocation.width + 2 * focus_width; - area.height = page->tab_label->allocation.height + 2 * focus_width; - - gtk_notebook_draw_tab (notebook, page, &area); - } - - if (old_page) - { - area.x = old_page->tab_label->allocation.x - focus_width; - area.y = old_page->tab_label->allocation.y - focus_width; - area.width = old_page->tab_label->allocation.width + 2 * focus_width; - area.height = old_page->tab_label->allocation.height + 2 * focus_width; - - gtk_notebook_draw_tab (notebook, old_page, &area); - } - } -} - static gint gtk_notebook_timer (GtkNotebook *notebook) { @@ -3678,7 +3627,7 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook, page = notebook->focus_tab->data; if (GTK_WIDGET_MAPPED (page->tab_label)) - gtk_notebook_focus_changed (notebook, old_page); + gtk_notebook_redraw_tabs (notebook); else gtk_notebook_pages_allocate (notebook);