gdk/gdkgc.c: If gdk_gc_set_clip_rectangle is called with

rectangle = NULL, remove clip mask, instead of segfaulting.
gtk/gtknotebook.c: Set clip mask before redrawing, so that
  we don't overwrite things outside of exposed areas when
  drawing the shadows. (Based on a patch from
  Lars Hamann <hamann@braunschweig.netsurf.de> and Stefan Jeske)

                                        -owt
This commit is contained in:
Owen Taylor 1997-12-12 20:03:48 +00:00
parent 30e8968f3b
commit d30343b9d9
2 changed files with 37 additions and 8 deletions

View File

@ -535,13 +535,18 @@ gdk_gc_set_clip_rectangle (GdkGC *gc,
private = (GdkGCPrivate*) gc; private = (GdkGCPrivate*) gc;
xrectangle.x = rectangle->x; if (rectangle)
xrectangle.y = rectangle->y; {
xrectangle.width = rectangle->width; xrectangle.x = rectangle->x;
xrectangle.height = rectangle->height; xrectangle.y = rectangle->y;
xrectangle.width = rectangle->width;
XSetClipRectangles (private->xdisplay, private->xgc, 0, 0, xrectangle.height = rectangle->height;
&xrectangle, 1, Unsorted);
XSetClipRectangles (private->xdisplay, private->xgc, 0, 0,
&xrectangle, 1, Unsorted);
}
else
XSetClipMask (private->xdisplay, private->xgc, None);
} }
void void

View File

@ -51,6 +51,9 @@ static void gtk_notebook_foreach (GtkContainer *container,
gpointer callback_data); gpointer callback_data);
static void gtk_notebook_switch_page (GtkNotebook *notebook, static void gtk_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page); GtkNotebookPage *page);
static void gtk_notebook_set_clip_rect (GtkNotebook *notebook,
GtkStateType state_type,
GdkRectangle *area);
static void gtk_notebook_draw_tab (GtkNotebook *notebook, static void gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page, GtkNotebookPage *page,
GdkRectangle *area); GdkRectangle *area);
@ -735,6 +738,11 @@ gtk_notebook_paint (GtkWidget *widget,
{ {
notebook = GTK_NOTEBOOK (widget); notebook = GTK_NOTEBOOK (widget);
/* Set the clip rectangle here, so we don't overwrite things
* outside of exposed area when drawing shadows */
gtk_notebook_set_clip_rect (notebook, GTK_STATE_ACTIVE, area);
gtk_notebook_set_clip_rect (notebook, GTK_STATE_NORMAL, area);
gdk_window_clear_area (widget->window, gdk_window_clear_area (widget->window,
area->x, area->y, area->x, area->y,
area->width, area->height); area->width, area->height);
@ -866,6 +874,9 @@ gtk_notebook_paint (GtkWidget *widget,
x, y, width, height); x, y, width, height);
} }
} }
gtk_notebook_set_clip_rect (notebook, GTK_STATE_ACTIVE, NULL);
gtk_notebook_set_clip_rect (notebook, GTK_STATE_NORMAL, NULL);
} }
} }
@ -940,7 +951,6 @@ gtk_notebook_button_press (GtkWidget *widget,
while (children) while (children)
{ {
page = children->data; page = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (page->child) && if (GTK_WIDGET_VISIBLE (page->child) &&
(event->x >= page->allocation.x) && (event->x >= page->allocation.x) &&
@ -951,6 +961,7 @@ gtk_notebook_button_press (GtkWidget *widget,
gtk_notebook_switch_page (notebook, page); gtk_notebook_switch_page (notebook, page);
break; break;
} }
children = children->next;
} }
return FALSE; return FALSE;
@ -1060,6 +1071,19 @@ gtk_notebook_switch_page (GtkNotebook *notebook,
} }
} }
static void
gtk_notebook_set_clip_rect (GtkNotebook *notebook,
GtkStateType state_type,
GdkRectangle *area)
{
GtkWidget *widget = GTK_WIDGET (notebook);
gdk_gc_set_clip_rectangle (widget->style->bg_gc[state_type], area);
gdk_gc_set_clip_rectangle (widget->style->light_gc[state_type], area);
gdk_gc_set_clip_rectangle (widget->style->dark_gc[state_type], area);
gdk_gc_set_clip_rectangle (widget->style->black_gc, area);
}
static void static void
gtk_notebook_draw_tab (GtkNotebook *notebook, gtk_notebook_draw_tab (GtkNotebook *notebook,
GtkNotebookPage *page, GtkNotebookPage *page,