+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
+Mon Mar 23 18:19:42 1998 Owen Taylor <owt1@cornell.edu>
+
+ * gtk/gtkmenu.c gtk/gtkmenushell.c: Instead of making
+ an X grab when the button is released, grab immediately.
+ This solves a problem where menus wouldn't pop down
+ if the caller didn't have the BUTTON_RELEASE mask on
+ their window, and and another where the X grab would
+ be released prematurely.
+
+ * gtk/gtklist.c gtk/gtktree.c: Do sanity checking on
+ button presses to make sure they occurred in a child item.
+ (From: "Damon Chaplin" <DAChaplin@email.msn.com>)
+
+ * gtk/gtkmenushell.c: Do sanity checking on button
+ press/releases. Handle button events on window widget
+ descendents of menu items correctly.
+
+ * gtk/gtkclist.c gtk/gtkbutton.c gtk/gtkviewport.c
+ gtk/gtkeventbox.c:
+
+ Make the window size allocated in _realize() match that
+ in _size_allocate(). Take into account the border width
+ in the draw() handler.
+
Mon Mar 23 15:26:25 1998 Tim Janik <timj@gtk.org>
* gtk/gtkentry.c (gtk_entry_append_text): check for text!=NULL.
GtkButton *button;
GdkWindowAttr attributes;
gint attributes_mask;
+ gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
button = GTK_BUTTON (widget);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ border_width = GTK_CONTAINER (widget)->border_width;
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = widget->allocation.x + border_width;
+ attributes.y = widget->allocation.y + border_width;
+ attributes.width = widget->allocation.width - border_width * 2;
+ attributes.height = widget->allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
{
GtkButton *button;
GdkRectangle child_area;
+ GdkRectangle tmp_area;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
{
button = GTK_BUTTON (widget);
- gtk_button_paint (widget, area);
+ tmp_area = *area;
+ tmp_area.x -= GTK_CONTAINER (button)->border_width;
+ tmp_area.y -= GTK_CONTAINER (button)->border_width;
+
+ gtk_button_paint (widget, &tmp_area);
- if (button->child && gtk_widget_intersect (button->child, area, &child_area))
+ if (button->child && gtk_widget_intersect (button->child, &tmp_area, &child_area))
gtk_widget_draw (button->child, &child_area);
gtk_widget_draw_default (widget);
GdkWindowAttr attributes;
gint attributes_mask;
GdkGCValues values;
+ gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ border_width = GTK_CONTAINER (widget)->border_width;
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = widget->allocation.x + border_width;
+ attributes.y = widget->allocation.y + border_width;
+ attributes.width = widget->allocation.width - border_width * 2;
+ attributes.height = widget->allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
GdkRectangle * area)
{
GtkCList *clist;
+ gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
if (GTK_WIDGET_DRAWABLE (widget))
{
clist = GTK_CLIST (widget);
+ border_width = GTK_CONTAINER (widget)->border_width;
gdk_window_clear_area (widget->window,
- area->x, area->y,
+ area->x - border_width,
+ area->y - border_width,
area->width, area->height);
/* draw list shadow/border */
{
GdkWindowAttr attributes;
gint attributes_mask;
+ gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_EVENT_BOX (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ border_width = GTK_CONTAINER (widget)->border_width;
+
+ attributes.x = widget->allocation.x + border_width;
+ attributes.y = widget->allocation.y + border_width;
+ attributes.width = widget->allocation.width - 2*border_width;
+ attributes.height = widget->allocation.height - 2*border_width;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
GdkRectangle *area)
{
GtkBin *bin;
+ GdkRectangle tmp_area;
GdkRectangle child_area;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_EVENT_BOX (widget));
- g_return_if_fail (area != NULL);
if (GTK_WIDGET_DRAWABLE (widget))
{
bin = GTK_BIN (widget);
-
+ tmp_area = *area;
+ tmp_area.x -= GTK_CONTAINER (widget)->border_width;
+ tmp_area.y -= GTK_CONTAINER (widget)->border_width;
+
if (bin->child)
{
- if (gtk_widget_intersect (bin->child, area, &child_area))
+ if (gtk_widget_intersect (bin->child, &tmp_area, &child_area))
gtk_widget_draw (bin->child, &child_area);
}
}
{
possible_count += 1;
- filename = g_strdup (cmpl_this_completion (poss));
+ filename = cmpl_this_completion (poss);
text[0] = filename;
list = GTK_LIST (widget);
item = gtk_get_event_widget ((GdkEvent*) event);
- if (!item)
- return FALSE;
-
- while (!gtk_type_is_a (GTK_WIDGET_TYPE (item), gtk_list_item_get_type ()))
+ while (item && !GTK_IS_LIST_ITEM (item))
item = item->parent;
+ if (!item || (item->parent != widget))
+ return FALSE;
+
gtk_list_select_child (list, item);
return FALSE;
guint button,
guint32 activate_time)
{
+ GtkWidget *xgrab_shell;
+ GtkWidget *parent;
+
g_return_if_fail (menu != NULL);
g_return_if_fail (GTK_IS_MENU (menu));
GTK_MENU_SHELL (menu)->activate_time = activate_time;
gtk_widget_show (GTK_WIDGET (menu));
+
+ /* Find the last viewable ancestor, and make an X grab on it
+ */
+ parent = GTK_WIDGET (menu);
+ xgrab_shell = NULL;
+ while (parent)
+ {
+ gboolean viewable = TRUE;
+ GtkWidget *tmp = parent;
+
+ while (tmp)
+ {
+ if (!GTK_WIDGET_MAPPED (tmp))
+ {
+ viewable = FALSE;
+ break;
+ }
+ tmp = tmp->parent;
+ }
+
+ if (viewable)
+ xgrab_shell = parent;
+
+ parent = GTK_MENU_SHELL (parent)->parent_menu_shell;
+ }
+
+ if (xgrab_shell && (!GTK_MENU_SHELL (xgrab_shell)->have_xgrab))
+ {
+ GTK_MENU_SHELL (xgrab_shell)->have_xgrab =
+ (gdk_pointer_grab (xgrab_shell->window, TRUE,
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
+ NULL, NULL, activate_time) == 0);
+ }
+
gtk_grab_add (GTK_WIDGET (menu));
}
menu_shell->active_menu_item = NULL;
}
+ /* The X Grab, if present, will automatically be removed when we hide
+ * the window */
gtk_widget_hide (GTK_WIDGET (menu));
+ menu_shell->have_xgrab = FALSE;
+
gtk_grab_remove (GTK_WIDGET (menu));
}
static void gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell);
static gint gtk_menu_shell_is_item (GtkMenuShell *menu_shell,
GtkWidget *child);
+static GtkWidget *gtk_menu_shell_get_item (GtkMenuShell *menu_shell,
+ GdkEvent *event);
static GtkContainerClass *parent_class = NULL;
menu_shell->active = TRUE;
}
menu_shell->button = event->button;
-
- menu_item = gtk_get_event_widget ((GdkEvent*) event);
- if (!GTK_WIDGET_IS_SENSITIVE (menu_item))
- return TRUE;
+ menu_item = gtk_menu_shell_get_item (menu_shell, (GdkEvent *)event);
- if (menu_item && GTK_IS_MENU_ITEM (menu_item) &&
- gtk_menu_shell_is_item (menu_shell, menu_item))
+ if (menu_item &&
+ GTK_WIDGET_IS_SENSITIVE (menu_item))
{
if ((menu_item->parent == widget) &&
(menu_item != menu_shell->active_menu_item))
}
menu_shell->button = 0;
- menu_item = gtk_get_event_widget ((GdkEvent*) event);
-
- if (!GTK_WIDGET_IS_SENSITIVE (menu_item))
- return TRUE;
+ menu_item = gtk_menu_shell_get_item (menu_shell, (GdkEvent*) event);
deactivate = TRUE;
if ((event->time - menu_shell->activate_time) > MENU_SHELL_TIMEOUT)
{
- if (menu_shell->active_menu_item == menu_item)
+ if (menu_item && (menu_shell->active_menu_item == menu_item))
{
if (GTK_MENU_ITEM (menu_item)->submenu == NULL)
{
}
else
deactivate = FALSE;
-
- if ((!deactivate || (menu_shell->active_menu_item == menu_item)) &&
- (gdk_pointer_grab (widget->window, TRUE,
- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
- NULL, NULL, event->time) == 0))
+
+ /* If the button click was very fast, or we ended up on a submenu,
+ * leave the menu up
+ */
+ if (!deactivate ||
+ (menu_item && (menu_shell->active_menu_item == menu_item)))
{
deactivate = FALSE;
- menu_shell->have_xgrab = TRUE;
menu_shell->ignore_leave = TRUE;
}
else
return FALSE;
}
+
+static GtkWidget *
+gtk_menu_shell_get_item (GtkMenuShell *menu_shell,
+ GdkEvent *event)
+{
+ GtkWidget *menu_item;
+
+ menu_item = gtk_get_event_widget ((GdkEvent*) event);
+
+ while (menu_item && !GTK_IS_MENU_ITEM (menu_item))
+ menu_item = menu_item->parent;
+
+ if (menu_item && gtk_menu_shell_is_item (menu_shell, menu_item))
+ return menu_item;
+ else
+ return NULL;
+}
+
text->tab_stops = g_list_prepend (text->tab_stops, (void*)8);
text->line_wrap = TRUE;
+ text->word_wrap = FALSE;
text->timer = 0;
text->button = 0;
tree = GTK_TREE (widget);
item = gtk_get_event_widget ((GdkEvent*) event);
- while (!gtk_type_is_a (GTK_WIDGET_TYPE (item), gtk_tree_item_get_type ()))
+ while (item && !GTK_IS_TREE_ITEM (item))
item = item->parent;
+ if (!item || (item->parent != widget))
+ return FALSE;
+
switch(event->button)
{
case 1:
GtkBin *bin;
GdkRectangle tmp_area;
GdkRectangle child_area;
+ gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VIEWPORT (widget));
viewport = GTK_VIEWPORT (widget);
bin = GTK_BIN (widget);
- gtk_viewport_paint (widget, area);
+ border_width = GTK_CONTAINER (widget)->border_width;
+
+ tmp_area = *area;
+ tmp_area.x -= border_width;
+ tmp_area.y -= border_width;
+
+ gtk_viewport_paint (widget, &tmp_area);
if (bin->child)
{
- tmp_area = *area;
- tmp_area.x += viewport->hadjustment->value;
- tmp_area.y += viewport->vadjustment->value;
+ tmp_area.x += viewport->hadjustment->value - widget->style->klass->xthickness;
+ tmp_area.y += viewport->vadjustment->value - widget->style->klass->ythickness;
if (gtk_widget_intersect (bin->child, &tmp_area, &child_area))
gtk_widget_draw (bin->child, &child_area);
GtkBin *bin;
GtkAllocation child_allocation;
gint hval, vval;
+ gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VIEWPORT (widget));
viewport = GTK_VIEWPORT (widget);
bin = GTK_BIN (widget);
+ border_width = GTK_CONTAINER (widget)->border_width;
+
child_allocation.x = 0;
child_allocation.y = 0;
child_allocation.y = GTK_WIDGET (viewport)->style->klass->ythickness;
}
- child_allocation.width = allocation->width - child_allocation.x * 2;
- child_allocation.height = allocation->height - child_allocation.y * 2;
+ child_allocation.width = allocation->width - child_allocation.x * 2 - border_width * 2;
+ child_allocation.height = allocation->height - child_allocation.y * 2 - border_width * 2;
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_move_resize (widget->window,
- allocation->x + GTK_CONTAINER (viewport)->border_width,
- allocation->y + GTK_CONTAINER (viewport)->border_width,
- allocation->width - GTK_CONTAINER (viewport)->border_width * 2,
- allocation->height - GTK_CONTAINER (viewport)->border_width * 2);
+ allocation->x + border_width,
+ allocation->y + border_width,
+ allocation->width - border_width * 2,
+ allocation->height - border_width * 2);
gdk_window_move_resize (viewport->view_window,
child_allocation.x,