Commit 1431d765 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Make Menu items NO_WINDOW widgets.

Fri Nov 16 00:16:40 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
	gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
	NO_WINDOW widgets.

	* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
	cleanup.

	* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
	we are drawing in a window when drawing the paned handle.
parent e8eb7a40
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
Fri Nov 16 00:16:40 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkmenuitem.[ch],gtkcheckmenuitem.c,gtkimagemenuitem.c,
gtkradiomenuitem.c,gtktearoffmenuitem.c}: Make Menu items
NO_WINDOW widgets.
* gtk/gtk{h,v,}paned.[ch]: Make NO_WINDOW widgets, some
cleanup.
* gtk/gtkstyle.c (gtk_default_draw_handle): Don't assume
we are drawing in a window when drawing the paned handle.
2001-11-16 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/appwindow.c
......
......@@ -365,9 +365,9 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
width = 8;
height = 8;
x = (GTK_CONTAINER (check_menu_item)->border_width +
widget->style->xthickness + 2);
y = (widget->allocation.height - height) / 2;
x = widget->allocation.x + (GTK_CONTAINER (check_menu_item)->border_width +
widget->style->xthickness + 2);
y = widget->allocation.y + (widget->allocation.height - height) / 2;
if (check_menu_item->active ||
check_menu_item->always_show_toggle ||
......
......@@ -32,8 +32,6 @@ static void gtk_hpaned_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_hpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_hpaned_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_hpaned_xor_line (GtkPaned *paned);
static gboolean gtk_hpaned_button_press (GtkWidget *widget,
GdkEventButton *event);
......@@ -80,7 +78,6 @@ gtk_hpaned_class_init (GtkHPanedClass *class)
widget_class->size_request = gtk_hpaned_size_request;
widget_class->size_allocate = gtk_hpaned_size_allocate;
widget_class->expose_event = gtk_hpaned_expose;
widget_class->button_press_event = gtk_hpaned_button_press;
widget_class->button_release_event = gtk_hpaned_button_release;
widget_class->motion_notify_event = gtk_hpaned_motion;
......@@ -96,6 +93,7 @@ gtk_hpaned_init (GtkHPaned *hpaned)
paned = GTK_PANED (hpaned);
paned->cursor_type = GDK_SB_H_DOUBLE_ARROW;
paned->orientation = GTK_ORIENTATION_VERTICAL;
}
GtkWidget *
......@@ -155,11 +153,6 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
gint border_width = GTK_CONTAINER (paned)->border_width;
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
allocation->x, allocation->y,
allocation->width,
allocation->height);
if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
......@@ -182,29 +175,27 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
child1_requisition.width,
child2_requisition.width);
/* Move the handle before the children so we don't get extra expose events */
paned->handle_xpos = paned->child1_size + border_width;
paned->handle_ypos = border_width;
paned->handle_width = handle_size;
paned->handle_height = MAX (1, widget->allocation.height - 2 * border_width);
paned->handle_pos.x = widget->allocation.x + paned->child1_size + border_width;
paned->handle_pos.y = widget->allocation.y + border_width;
paned->handle_pos.width = handle_size;
paned->handle_pos.height = MAX (1, widget->allocation.height - 2 * border_width);
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_show (paned->handle);
gdk_window_move_resize (paned->handle,
paned->handle_xpos,
paned->handle_ypos,
paned->handle_pos.x,
paned->handle_pos.y,
handle_size,
paned->handle_height);
paned->handle_pos.height);
}
child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
child1_allocation.width = paned->child1_size;
child1_allocation.x = border_width;
child1_allocation.y = child2_allocation.y = border_width;
child1_allocation.x = widget->allocation.x + border_width;
child1_allocation.y = child2_allocation.y = widget->allocation.y + border_width;
child2_allocation.x = child1_allocation.x + child1_allocation.width + paned->handle_width;
child2_allocation.x = child1_allocation.x + child1_allocation.width + paned->handle_pos.width;
child2_allocation.width = MAX (1, (gint) allocation->width - child2_allocation.x - border_width);
/* Now allocate the childen, making sure, when resizing not to
......@@ -240,47 +231,6 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
}
}
static gint
gtk_hpaned_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkPaned *paned;
guint16 border_width;
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
{
paned = GTK_PANED (widget);
border_width = GTK_CONTAINER (paned)->border_width;
if (event->window == widget->window)
{
gdk_window_clear_area (widget->window,
event->area.x, event->area.y,
event->area.width,
event->area.height);
/* Chain up to draw children */
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
else if (event->window == paned->handle)
{
gtk_paint_handle (widget->style,
paned->handle,
GTK_STATE_NORMAL,
GTK_SHADOW_NONE,
&event->area,
widget,
"paned",
0, 0, -1, -1,
GTK_ORIENTATION_VERTICAL);
}
}
return FALSE;
}
static void
gtk_hpaned_xor_line (GtkPaned *paned)
{
......@@ -305,14 +255,14 @@ gtk_hpaned_xor_line (GtkPaned *paned)
gdk_gc_set_line_attributes (paned->xor_gc, 2, GDK_LINE_SOLID,
GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
xpos = paned->child1_size
xpos = widget->allocation.x + paned->child1_size
+ GTK_CONTAINER (paned)->border_width + handle_size / 2;
gdk_draw_line (widget->window, paned->xor_gc,
xpos,
0,
widget->allocation.y,
xpos,
widget->allocation.height - 1);
widget->allocation.y + widget->allocation.height - 1);
}
static gboolean
......@@ -383,10 +333,7 @@ gtk_hpaned_motion (GtkWidget *widget,
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (event->is_hint || event->window != widget->window)
gtk_widget_get_pointer(widget, &x, NULL);
else
x = event->x;
gtk_widget_get_pointer (widget, &x, NULL);
if (paned->in_drag)
{
......
......@@ -256,8 +256,8 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
child_allocation.width = width;
child_allocation.height = height;
child_allocation.x = MAX (x, 0);
child_allocation.y = MAX (y, 0);
child_allocation.x = widget->allocation.x + MAX (x, 0);
child_allocation.y = widget->allocation.y + MAX (y, 0);
gtk_widget_size_allocate (image_menu_item->image, &child_allocation);
}
......
......@@ -56,6 +56,10 @@ static void gtk_menu_item_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_menu_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_menu_item_realize (GtkWidget *widget);
static void gtk_menu_item_unrealize (GtkWidget *widget);
static void gtk_menu_item_map (GtkWidget *widget);
static void gtk_menu_item_unmap (GtkWidget *widget);
static void gtk_menu_item_paint (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_menu_item_expose (GtkWidget *widget,
......@@ -137,6 +141,10 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
widget_class->size_request = gtk_menu_item_size_request;
widget_class->size_allocate = gtk_menu_item_size_allocate;
widget_class->expose_event = gtk_menu_item_expose;
widget_class->realize = gtk_menu_item_realize;
widget_class->unrealize = gtk_menu_item_unrealize;
widget_class->map = gtk_menu_item_map;
widget_class->unmap = gtk_menu_item_unmap;
widget_class->show_all = gtk_menu_item_show_all;
widget_class->hide_all = gtk_menu_item_hide_all;
widget_class->mnemonic_activate = gtk_menu_item_mnemonic_activate;
......@@ -192,6 +200,8 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
static void
gtk_menu_item_init (GtkMenuItem *menu_item)
{
GTK_WIDGET_SET_FLAGS (menu_item, GTK_NO_WINDOW);
menu_item->submenu = NULL;
menu_item->toggle_size = 0;
menu_item->accelerator_width = 0;
......@@ -477,6 +487,9 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
child_allocation.x += GTK_MENU_ITEM (widget)->toggle_size;
child_allocation.width -= GTK_MENU_ITEM (widget)->toggle_size;
child_allocation.x += widget->allocation.x;
child_allocation.y += widget->allocation.y;
if (menu_item->submenu && menu_item->show_submenu_indicator)
child_allocation.width -= 21;
......@@ -484,7 +497,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
}
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
gdk_window_move_resize (menu_item->event_window,
allocation->x, allocation->y,
allocation->width, allocation->height);
......@@ -492,6 +505,72 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
gtk_menu_reposition (GTK_MENU (menu_item->submenu));
}
static void
gtk_menu_item_realize (GtkWidget *widget)
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
GdkWindowAttr attributes;
gint attributes_mask;
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = (gtk_widget_get_events (widget) |
GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
menu_item->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_set_user_data (menu_item->event_window, widget);
widget->style = gtk_style_attach (widget->style, widget->window);
}
static void
gtk_menu_item_unrealize (GtkWidget *widget)
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
gdk_window_set_user_data (menu_item->event_window, NULL);
gdk_window_destroy (menu_item->event_window);
menu_item->event_window = NULL;
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
static void
gtk_menu_item_map (GtkWidget *widget)
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
gdk_window_show (menu_item->event_window);
GTK_WIDGET_CLASS (parent_class)->map (widget);
}
static void
gtk_menu_item_unmap (GtkWidget *widget)
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
gdk_window_hide (menu_item->event_window);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static void
gtk_menu_item_paint (GtkWidget *widget,
GdkRectangle *area)
......@@ -501,8 +580,7 @@ gtk_menu_item_paint (GtkWidget *widget,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
gint border_width = GTK_CONTAINER (menu_item)->border_width;
if (GTK_WIDGET_DRAWABLE (widget))
{
......@@ -510,10 +588,10 @@ gtk_menu_item_paint (GtkWidget *widget,
state_type = widget->state;
x = GTK_CONTAINER (menu_item)->border_width;
y = GTK_CONTAINER (menu_item)->border_width;
width = widget->allocation.width - x * 2;
height = widget->allocation.height - y * 2;
x = widget->allocation.x + border_width;
y = widget->allocation.y + border_width;
width = widget->allocation.width - border_width * 2;
height = widget->allocation.height - border_width * 2;
if ((state_type == GTK_STATE_PRELIGHT) &&
(GTK_BIN (menu_item)->child))
......@@ -523,11 +601,6 @@ gtk_menu_item_paint (GtkWidget *widget,
GTK_SHADOW_OUT,
area, widget, "menuitem",
x, y, width, height);
else
{
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
}
if (menu_item->submenu && menu_item->show_submenu_indicator)
{
......@@ -545,7 +618,8 @@ gtk_menu_item_paint (GtkWidget *widget,
{
gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
area, widget, "menuitem",
0, widget->allocation.width, 0);
widget->allocation.x, widget->allocation.width,
widget->allocation.y);
}
}
}
......@@ -744,6 +818,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
gpointer user_data)
{
GtkMenuItem *menu_item;
GtkWidget *widget;
GtkWidget *parent_menu_item;
gint screen_width;
gint screen_height;
......@@ -755,6 +830,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
g_return_if_fail (y != NULL);
menu_item = GTK_MENU_ITEM (user_data);
widget = GTK_WIDGET (user_data);
twidth = GTK_WIDGET (menu)->requisition.width;
theight = GTK_WIDGET (menu)->requisition.height;
......@@ -762,28 +838,31 @@ gtk_menu_item_position_menu (GtkMenu *menu,
screen_width = gdk_screen_width ();
screen_height = gdk_screen_height ();
if (!gdk_window_get_origin (GTK_WIDGET (menu_item)->window, &tx, &ty))
if (!gdk_window_get_origin (widget->window, &tx, &ty))
{
g_warning ("Menu not on screen");
return;
}
tx += widget->allocation.x;
ty += widget->allocation.y;
switch (menu_item->submenu_placement)
{
case GTK_TOP_BOTTOM:
if ((ty + GTK_WIDGET (menu_item)->allocation.height + theight) <= screen_height)
ty += GTK_WIDGET (menu_item)->allocation.height;
if ((ty + widget->allocation.height + theight) <= screen_height)
ty += widget->allocation.height;
else if ((ty - theight) >= 0)
ty -= theight;
else if (screen_height - (ty + GTK_WIDGET (menu_item)->allocation.height) > ty)
ty += GTK_WIDGET (menu_item)->allocation.height;
else if (screen_height - (ty + widget->allocation.height) > ty)
ty += widget->allocation.height;
else
ty -= theight;
break;
case GTK_LEFT_RIGHT:
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
parent_menu_item = GTK_MENU (GTK_WIDGET (menu_item)->parent)->parent_menu_item;
parent_menu_item = GTK_MENU (widget->parent)->parent_menu_item;
if (parent_menu_item)
menu_item->submenu_direction = GTK_MENU_ITEM (parent_menu_item)->submenu_direction;
......@@ -795,13 +874,13 @@ gtk_menu_item_position_menu (GtkMenu *menu,
else
{
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
tx += GTK_WIDGET (menu_item)->allocation.width - 5;
tx += widget->allocation.width - 5;
}
break;
case GTK_DIRECTION_RIGHT:
if ((tx + GTK_WIDGET (menu_item)->allocation.width + twidth - 5) <= screen_width)
tx += GTK_WIDGET (menu_item)->allocation.width - 5;
if ((tx + widget->allocation.width + twidth - 5) <= screen_width)
tx += widget->allocation.width - 5;
else
{
menu_item->submenu_direction = GTK_DIRECTION_LEFT;
......@@ -810,7 +889,7 @@ gtk_menu_item_position_menu (GtkMenu *menu,
break;
}
ty += GTK_WIDGET (menu_item)->allocation.height / 4;
ty += widget->allocation.height / 4;
/* If the height of the menu doesn't fit we move it upward. */
ty = CLAMP (ty, 0, MAX (0, screen_height - theight));
......
......@@ -53,6 +53,7 @@ struct _GtkMenuItem
GtkItem item;
GtkWidget *submenu;
GdkWindow *event_window;
guint16 toggle_size;
guint16 accelerator_width;
......
......@@ -45,6 +45,8 @@ static void gtk_paned_get_property (GObject *object,
GParamSpec *pspec);
static void gtk_paned_realize (GtkWidget *widget);
static void gtk_paned_unrealize (GtkWidget *widget);
static void gtk_paned_map (GtkWidget *widget);
static void gtk_paned_unmap (GtkWidget *widget);
static gint gtk_paned_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_paned_add (GtkContainer *container,
......@@ -103,6 +105,8 @@ gtk_paned_class_init (GtkPanedClass *class)
widget_class->realize = gtk_paned_realize;
widget_class->unrealize = gtk_paned_unrealize;
widget_class->map = gtk_paned_map;
widget_class->unmap = gtk_paned_unmap;
widget_class->expose_event = gtk_paned_expose;
container_class->add = gtk_paned_add;
......@@ -149,7 +153,7 @@ gtk_paned_child_type (GtkContainer *container)
static void
gtk_paned_init (GtkPaned *paned)
{
GTK_WIDGET_UNSET_FLAGS (paned, GTK_NO_WINDOW);
GTK_WIDGET_SET_FLAGS (paned, GTK_NO_WINDOW);
paned->child1 = NULL;
paned->child2 = NULL;
......@@ -157,14 +161,14 @@ gtk_paned_init (GtkPaned *paned)
paned->xor_gc = NULL;
paned->cursor_type = GDK_CROSS;
paned->handle_width = 5;
paned->handle_height = 5;
paned->handle_pos.width = 5;
paned->handle_pos.height = 5;
paned->position_set = FALSE;
paned->last_allocation = -1;
paned->in_drag = FALSE;
paned->handle_xpos = -1;
paned->handle_ypos = -1;
paned->handle_pos.x = -1;
paned->handle_pos.y = -1;
}
static void
......@@ -224,31 +228,21 @@ gtk_paned_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
paned = GTK_PANED (widget);
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (gtk_widget_get_parent_window(widget),
&attributes, attributes_mask);
gdk_window_set_user_data (widget->window, paned);
attributes.x = paned->handle_xpos;
attributes.y = paned->handle_ypos;
attributes.width = paned->handle_width;
attributes.height = paned->handle_height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.x = paned->handle_pos.x;
attributes.y = paned->handle_pos.y;
attributes.width = paned->handle_pos.width;
attributes.height = paned->handle_pos.height;
attributes.cursor = gdk_cursor_new (paned->cursor_type);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
attributes_mask |= GDK_WA_CURSOR;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_CURSOR;
paned->handle = gdk_window_new (widget->window,
&attributes, attributes_mask);
......@@ -257,11 +251,6 @@ gtk_paned_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
gtk_style_set_background (widget->style, paned->handle, GTK_STATE_NORMAL);
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
gdk_window_show (paned->handle);
......@@ -293,7 +282,29 @@ gtk_paned_unrealize (GtkWidget *widget)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
static void
gtk_paned_map (GtkWidget *widget)
{
GtkPaned *paned = GTK_PANED (widget);
g_return_if_fail (GTK_IS_PANED (widget));
gdk_window_show (paned->handle);
GTK_WIDGET_CLASS (parent_class)->map (widget);
}
static void
gtk_paned_unmap (GtkWidget *widget)
{
GtkPaned *paned = GTK_PANED (widget);
g_return_if_fail (GTK_IS_PANED (widget));
gdk_window_hide (paned->handle);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
static gint
gtk_paned_expose (GtkWidget *widget,
......@@ -302,14 +313,34 @@ gtk_paned_expose (GtkWidget *widget,
GtkPaned *paned;
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_WIDGET_DRAWABLE (widget))
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
{
GdkRegion *region;
paned = GTK_PANED (widget);
region = gdk_region_rectangle (&paned->handle_pos);
gdk_region_intersect (region, event->region);
if (!gdk_region_empty (region))
{
GdkRectangle clip;