]> Pileus Git - ~andy/gtk/blob - tests/gtkoffscreenbox.c
Use gtk_size_request_get_size() instead deprecated gtk_widget_get_child_requisition()
[~andy/gtk] / tests / gtkoffscreenbox.c
1 /*
2  * gtkoffscreenbox.c
3  */
4
5 #include "config.h"
6
7 #include <math.h>
8 #include <gtk/gtk.h>
9
10 #include "gtkoffscreenbox.h"
11
12 static void        gtk_offscreen_box_realize       (GtkWidget       *widget);
13 static void        gtk_offscreen_box_unrealize     (GtkWidget       *widget);
14 static void        gtk_offscreen_box_size_request  (GtkWidget       *widget,
15                                                     GtkRequisition  *requisition);
16 static void        gtk_offscreen_box_size_allocate (GtkWidget       *widget,
17                                                     GtkAllocation   *allocation);
18 static gboolean    gtk_offscreen_box_damage        (GtkWidget       *widget,
19                                                     GdkEventExpose  *event);
20 static gboolean    gtk_offscreen_box_expose        (GtkWidget       *widget,
21                                                     GdkEventExpose  *offscreen);
22
23 static void        gtk_offscreen_box_add           (GtkContainer    *container,
24                                                     GtkWidget       *child);
25 static void        gtk_offscreen_box_remove        (GtkContainer    *container,
26                                                     GtkWidget       *widget);
27 static void        gtk_offscreen_box_forall        (GtkContainer    *container,
28                                                     gboolean         include_internals,
29                                                     GtkCallback      callback,
30                                                     gpointer         callback_data);
31 static GType       gtk_offscreen_box_child_type    (GtkContainer    *container);
32
33 #define CHILD1_SIZE_SCALE 1.0
34 #define CHILD2_SIZE_SCALE 1.0
35
36 G_DEFINE_TYPE (GtkOffscreenBox, gtk_offscreen_box, GTK_TYPE_CONTAINER);
37
38 static void
39 to_child_2 (GtkOffscreenBox *offscreen_box,
40             double widget_x, double widget_y,
41             double *x_out, double *y_out)
42 {
43   GtkAllocation child_area;
44   double x, y, xr, yr;
45   double cos_angle, sin_angle;
46
47   x = widget_x;
48   y = widget_y;
49
50   gtk_widget_get_allocation (offscreen_box->child1, &child_area);
51   if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
52     y -= child_area.height;
53
54   gtk_widget_get_allocation (offscreen_box->child2, &child_area);
55
56   x -= child_area.width / 2;
57   y -= child_area.height / 2;
58
59   cos_angle = cos (-offscreen_box->angle);
60   sin_angle = sin (-offscreen_box->angle);
61
62   xr = x * cos_angle - y * sin_angle;
63   yr = x * sin_angle + y * cos_angle;
64   x = xr;
65   y = yr;
66
67   x += child_area.width / 2;
68   y += child_area.height / 2;
69
70   *x_out = x;
71   *y_out = y;
72 }
73
74 static void
75 to_parent_2 (GtkOffscreenBox *offscreen_box,
76              double offscreen_x, double offscreen_y,
77              double *x_out, double *y_out)
78 {
79   GtkAllocation child_area;
80   double x, y, xr, yr;
81   double cos_angle, sin_angle;
82
83   gtk_widget_get_allocation (offscreen_box->child2, &child_area);
84
85   x = offscreen_x;
86   y = offscreen_y;
87
88   x -= child_area.width / 2;
89   y -= child_area.height / 2;
90
91   cos_angle = cos (offscreen_box->angle);
92   sin_angle = sin (offscreen_box->angle);
93
94   xr = x * cos_angle - y * sin_angle;
95   yr = x * sin_angle + y * cos_angle;
96   x = xr;
97   y = yr;
98
99   x += child_area.width / 2;
100   y += child_area.height / 2;
101
102   gtk_widget_get_allocation (offscreen_box->child1, &child_area);
103   if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
104     y += child_area.height;
105
106   *x_out = x;
107   *y_out = y;
108 }
109
110 static void
111 gtk_offscreen_box_class_init (GtkOffscreenBoxClass *klass)
112 {
113   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
114   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
115
116   widget_class->realize = gtk_offscreen_box_realize;
117   widget_class->unrealize = gtk_offscreen_box_unrealize;
118   widget_class->size_request = gtk_offscreen_box_size_request;
119   widget_class->size_allocate = gtk_offscreen_box_size_allocate;
120   widget_class->expose_event = gtk_offscreen_box_expose;
121
122   g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET),
123                                    GTK_TYPE_OFFSCREEN_BOX,
124                                    g_cclosure_new (G_CALLBACK (gtk_offscreen_box_damage),
125                                                    NULL, NULL));
126
127   container_class->add = gtk_offscreen_box_add;
128   container_class->remove = gtk_offscreen_box_remove;
129   container_class->forall = gtk_offscreen_box_forall;
130   container_class->child_type = gtk_offscreen_box_child_type;
131 }
132
133 static void
134 gtk_offscreen_box_init (GtkOffscreenBox *offscreen_box)
135 {
136   gtk_widget_set_has_window (GTK_WIDGET (offscreen_box), TRUE);
137 }
138
139 GtkWidget *
140 gtk_offscreen_box_new (void)
141 {
142   return g_object_new (GTK_TYPE_OFFSCREEN_BOX, NULL);
143 }
144
145 static GdkWindow *
146 pick_offscreen_child (GdkWindow *offscreen_window,
147                       double widget_x, double widget_y,
148                       GtkOffscreenBox *offscreen_box)
149 {
150  GtkAllocation child_area;
151  double x, y;
152
153  /* First check for child 2 */
154  if (offscreen_box->child2 &&
155      gtk_widget_get_visible (offscreen_box->child2))
156     {
157       to_child_2 (offscreen_box,
158                   widget_x, widget_y,
159                   &x, &y);
160
161       gtk_widget_get_allocation (offscreen_box->child2, &child_area);
162
163       if (x >= 0 && x < child_area.width &&
164           y >= 0 && y < child_area.height)
165         return offscreen_box->offscreen_window2;
166     }
167
168  if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
169    {
170      x = widget_x;
171      y = widget_y;
172
173      gtk_widget_get_allocation (offscreen_box->child1, &child_area);
174
175      if (x >= 0 && x < child_area.width &&
176          y >= 0 && y < child_area.height)
177        return offscreen_box->offscreen_window1;
178    }
179
180   return NULL;
181 }
182
183 static void
184 offscreen_window_to_parent1 (GdkWindow       *offscreen_window,
185                              double           offscreen_x,
186                              double           offscreen_y,
187                              double          *parent_x,
188                              double          *parent_y,
189                              GtkOffscreenBox *offscreen_box)
190 {
191   *parent_x = offscreen_x;
192   *parent_y = offscreen_y;
193 }
194
195 static void
196 offscreen_window_from_parent1 (GdkWindow       *window,
197                                double           parent_x,
198                                double           parent_y,
199                                double          *offscreen_x,
200                                double          *offscreen_y,
201                                GtkOffscreenBox *offscreen_box)
202 {
203   *offscreen_x = parent_x;
204   *offscreen_y = parent_y;
205 }
206
207 static void
208 offscreen_window_to_parent2 (GdkWindow       *offscreen_window,
209                              double           offscreen_x,
210                              double           offscreen_y,
211                              double          *parent_x,
212                              double          *parent_y,
213                              GtkOffscreenBox *offscreen_box)
214 {
215   to_parent_2 (offscreen_box,
216               offscreen_x, offscreen_y,
217               parent_x, parent_y);
218 }
219
220 static void
221 offscreen_window_from_parent2 (GdkWindow       *window,
222                                double           parent_x,
223                                double           parent_y,
224                                double          *offscreen_x,
225                                double          *offscreen_y,
226                                GtkOffscreenBox *offscreen_box)
227 {
228   to_child_2 (offscreen_box,
229               parent_x, parent_y,
230               offscreen_x, offscreen_y);
231 }
232
233 static void
234 gtk_offscreen_box_realize (GtkWidget *widget)
235 {
236   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
237   GtkAllocation allocation, child_area;
238   GtkStyle *style;
239   GdkWindow *window;
240   GdkWindowAttr attributes;
241   gint attributes_mask;
242   guint border_width;
243   GtkRequisition child_requisition;
244   int start_y = 0;
245
246   gtk_widget_set_realized (widget, TRUE);
247
248   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
249
250   gtk_widget_get_allocation (widget, &allocation);
251
252   attributes.x = allocation.x + border_width;
253   attributes.y = allocation.y + border_width;
254   attributes.width = allocation.width - 2 * border_width;
255   attributes.height = allocation.height - 2 * border_width;
256   attributes.window_type = GDK_WINDOW_CHILD;
257   attributes.event_mask = gtk_widget_get_events (widget)
258                         | GDK_EXPOSURE_MASK
259                         | GDK_POINTER_MOTION_MASK
260                         | GDK_BUTTON_PRESS_MASK
261                         | GDK_BUTTON_RELEASE_MASK
262                         | GDK_SCROLL_MASK
263                         | GDK_ENTER_NOTIFY_MASK
264                         | GDK_LEAVE_NOTIFY_MASK;
265
266   attributes.visual = gtk_widget_get_visual (widget);
267   attributes.colormap = gtk_widget_get_colormap (widget);
268   attributes.wclass = GDK_INPUT_OUTPUT;
269
270   attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
271
272   window = gdk_window_new (gtk_widget_get_parent_window (widget),
273                            &attributes, attributes_mask);
274   gtk_widget_set_window (widget, window);
275   gdk_window_set_user_data (window, widget);
276
277   g_signal_connect (window, "pick-embedded-child",
278                     G_CALLBACK (pick_offscreen_child), offscreen_box);
279
280   attributes.window_type = GDK_WINDOW_OFFSCREEN;
281
282   /* Child 1 */
283   attributes.x = attributes.y = 0;
284   if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
285     {
286       gtk_widget_get_allocation (offscreen_box->child1, &child_area);
287
288       attributes.width = child_area.width;
289       attributes.height = child_area.height;
290       start_y += child_area.height;
291     }
292   offscreen_box->offscreen_window1 = gdk_window_new (gtk_widget_get_root_window (widget),
293                                                      &attributes, attributes_mask);
294   gdk_window_set_user_data (offscreen_box->offscreen_window1, widget);
295   if (offscreen_box->child1)
296     gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1);
297
298   gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1,
299                                      window);
300
301   g_signal_connect (offscreen_box->offscreen_window1, "to-embedder",
302                     G_CALLBACK (offscreen_window_to_parent1), offscreen_box);
303   g_signal_connect (offscreen_box->offscreen_window1, "from-embedder",
304                     G_CALLBACK (offscreen_window_from_parent1), offscreen_box);
305
306   /* Child 2 */
307   attributes.y = start_y;
308   child_requisition.width = child_requisition.height = 0;
309   if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
310     {
311       gtk_widget_get_allocation (offscreen_box->child2, &child_area);
312
313       attributes.width = child_area.width;
314       attributes.height = child_area.height;
315     }
316   offscreen_box->offscreen_window2 = gdk_window_new (gtk_widget_get_root_window (widget),
317                                                      &attributes, attributes_mask);
318   gdk_window_set_user_data (offscreen_box->offscreen_window2, widget);
319   if (offscreen_box->child2)
320     gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2);
321   gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2,
322                                      window);
323   g_signal_connect (offscreen_box->offscreen_window2, "to-embedder",
324                     G_CALLBACK (offscreen_window_to_parent2), offscreen_box);
325   g_signal_connect (offscreen_box->offscreen_window2, "from-embedder",
326                     G_CALLBACK (offscreen_window_from_parent2), offscreen_box);
327
328   gtk_widget_style_attach (widget);
329   style = gtk_widget_get_style (widget);
330   gtk_style_set_background (style, window, GTK_STATE_NORMAL);
331   gtk_style_set_background (style, offscreen_box->offscreen_window1, GTK_STATE_NORMAL);
332   gtk_style_set_background (style, offscreen_box->offscreen_window2, GTK_STATE_NORMAL);
333
334   gdk_window_show (offscreen_box->offscreen_window1);
335   gdk_window_show (offscreen_box->offscreen_window2);
336 }
337
338 static void
339 gtk_offscreen_box_unrealize (GtkWidget *widget)
340 {
341   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
342
343   gdk_window_set_user_data (offscreen_box->offscreen_window1, NULL);
344   gdk_window_destroy (offscreen_box->offscreen_window1);
345   offscreen_box->offscreen_window1 = NULL;
346
347   gdk_window_set_user_data (offscreen_box->offscreen_window2, NULL);
348   gdk_window_destroy (offscreen_box->offscreen_window2);
349   offscreen_box->offscreen_window2 = NULL;
350
351   GTK_WIDGET_CLASS (gtk_offscreen_box_parent_class)->unrealize (widget);
352 }
353
354 static GType
355 gtk_offscreen_box_child_type (GtkContainer *container)
356 {
357   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
358
359   if (offscreen_box->child1 && offscreen_box->child2)
360     return G_TYPE_NONE;
361
362   return GTK_TYPE_WIDGET;
363 }
364
365 static void
366 gtk_offscreen_box_add (GtkContainer *container,
367                        GtkWidget    *widget)
368 {
369   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
370
371   if (!offscreen_box->child1)
372     gtk_offscreen_box_add1 (offscreen_box, widget);
373   else if (!offscreen_box->child2)
374     gtk_offscreen_box_add2 (offscreen_box, widget);
375   else
376     g_warning ("GtkOffscreenBox cannot have more than 2 children\n");
377 }
378
379 void
380 gtk_offscreen_box_add1 (GtkOffscreenBox *offscreen_box,
381                         GtkWidget       *child)
382 {
383   g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box));
384   g_return_if_fail (GTK_IS_WIDGET (child));
385
386   if (offscreen_box->child1 == NULL)
387     {
388       gtk_widget_set_parent_window (child, offscreen_box->offscreen_window1);
389       gtk_widget_set_parent (child, GTK_WIDGET (offscreen_box));
390       offscreen_box->child1 = child;
391     }
392 }
393
394 void
395 gtk_offscreen_box_add2 (GtkOffscreenBox  *offscreen_box,
396                         GtkWidget    *child)
397 {
398   g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box));
399   g_return_if_fail (GTK_IS_WIDGET (child));
400
401   if (offscreen_box->child2 == NULL)
402     {
403       gtk_widget_set_parent_window (child, offscreen_box->offscreen_window2);
404       gtk_widget_set_parent (child, GTK_WIDGET (offscreen_box));
405       offscreen_box->child2 = child;
406     }
407 }
408
409 static void
410 gtk_offscreen_box_remove (GtkContainer *container,
411                           GtkWidget    *widget)
412 {
413   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
414   gboolean was_visible;
415
416   was_visible = gtk_widget_get_visible (widget);
417
418   if (offscreen_box->child1 == widget)
419     {
420       gtk_widget_unparent (widget);
421
422       offscreen_box->child1 = NULL;
423
424       if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
425         gtk_widget_queue_resize (GTK_WIDGET (container));
426     }
427   else if (offscreen_box->child2 == widget)
428     {
429       gtk_widget_unparent (widget);
430
431       offscreen_box->child2 = NULL;
432
433       if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
434         gtk_widget_queue_resize (GTK_WIDGET (container));
435     }
436 }
437
438 static void
439 gtk_offscreen_box_forall (GtkContainer *container,
440                           gboolean      include_internals,
441                           GtkCallback   callback,
442                           gpointer      callback_data)
443 {
444   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (container);
445
446   g_return_if_fail (callback != NULL);
447
448   if (offscreen_box->child1)
449     (*callback) (offscreen_box->child1, callback_data);
450   if (offscreen_box->child2)
451     (*callback) (offscreen_box->child2, callback_data);
452 }
453
454 void
455 gtk_offscreen_box_set_angle (GtkOffscreenBox  *offscreen_box,
456                              gdouble           angle)
457 {
458   g_return_if_fail (GTK_IS_OFFSCREEN_BOX (offscreen_box));
459
460   offscreen_box->angle = angle;
461   gtk_widget_queue_draw (GTK_WIDGET (offscreen_box));
462
463   /* TODO: Really needs to resent pointer events if over the rotated window */
464 }
465
466
467 static void
468 gtk_offscreen_box_size_request (GtkWidget      *widget,
469                                 GtkRequisition *requisition)
470 {
471   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
472   int w, h;
473   guint border_width;
474
475   w = 0;
476   h = 0;
477
478   if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
479     {
480       GtkRequisition child_requisition;
481
482       gtk_widget_size_request (offscreen_box->child1, &child_requisition);
483
484       w = MAX (w, CHILD1_SIZE_SCALE * child_requisition.width);
485       h += CHILD1_SIZE_SCALE * child_requisition.height;
486     }
487
488   if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
489     {
490       GtkRequisition child_requisition;
491
492       gtk_widget_size_request (offscreen_box->child2, &child_requisition);
493
494       w = MAX (w, CHILD2_SIZE_SCALE * child_requisition.width);
495       h += CHILD2_SIZE_SCALE * child_requisition.height;
496     }
497
498   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
499   requisition->width = border_width * 2 + w;
500   requisition->height = border_width * 2 + h;
501 }
502
503 static void
504 gtk_offscreen_box_size_allocate (GtkWidget     *widget,
505                                  GtkAllocation *allocation)
506 {
507   GtkOffscreenBox *offscreen_box;
508   gint start_y;
509   guint border_width;
510
511   offscreen_box = GTK_OFFSCREEN_BOX (widget);
512
513   gtk_widget_set_allocation (widget, allocation);
514
515   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
516
517   if (gtk_widget_get_realized (widget))
518     gdk_window_move_resize (gtk_widget_get_window (widget),
519                             allocation->x + border_width,
520                             allocation->y + border_width,
521                             allocation->width - border_width * 2,
522                             allocation->height - border_width * 2);
523
524   start_y = 0;
525
526   if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
527     {
528       GtkRequisition child_requisition;
529       GtkAllocation child_allocation;
530
531       gtk_size_request_get_size (GTK_SIZE_REQUEST (offscreen_box->child1),
532                                  &child_requisition, NULL);
533       child_allocation.x = child_requisition.width * (CHILD1_SIZE_SCALE - 1.0) / 2;
534       child_allocation.y = start_y + child_requisition.height * (CHILD1_SIZE_SCALE - 1.0) / 2;
535       child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
536       child_allocation.height = child_requisition.height;
537
538       start_y += CHILD1_SIZE_SCALE * child_requisition.height;
539
540       if (gtk_widget_get_realized (widget))
541         gdk_window_move_resize (offscreen_box->offscreen_window1,
542                                 child_allocation.x,
543                                 child_allocation.y,
544                                 child_allocation.width,
545                                 child_allocation.height);
546
547       child_allocation.x = child_allocation.y = 0;
548       gtk_widget_size_allocate (offscreen_box->child1, &child_allocation);
549     }
550
551   if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
552     {
553       GtkRequisition child_requisition;
554       GtkAllocation child_allocation;
555
556       gtk_size_request_get_size (GTK_SIZE_REQUEST (offscreen_box->child2),
557                                  &child_requisition, NULL);
558       child_allocation.x = child_requisition.width * (CHILD2_SIZE_SCALE - 1.0) / 2;
559       child_allocation.y = start_y + child_requisition.height * (CHILD2_SIZE_SCALE - 1.0) / 2;
560       child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
561       child_allocation.height = child_requisition.height;
562
563       start_y += CHILD2_SIZE_SCALE * child_requisition.height;
564
565       if (gtk_widget_get_realized (widget))
566         gdk_window_move_resize (offscreen_box->offscreen_window2,
567                                 child_allocation.x,
568                                 child_allocation.y,
569                                 child_allocation.width,
570                                 child_allocation.height);
571
572       child_allocation.x = child_allocation.y = 0;
573       gtk_widget_size_allocate (offscreen_box->child2, &child_allocation);
574     }
575 }
576
577 static gboolean
578 gtk_offscreen_box_damage (GtkWidget      *widget,
579                           GdkEventExpose *event)
580 {
581   gdk_window_invalidate_rect (gtk_widget_get_window (widget),
582                               NULL, FALSE);
583
584   return TRUE;
585 }
586
587 static gboolean
588 gtk_offscreen_box_expose (GtkWidget      *widget,
589                           GdkEventExpose *event)
590 {
591   GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget);
592   GdkWindow *window;
593
594   if (gtk_widget_is_drawable (widget))
595     {
596       window = gtk_widget_get_window (widget);
597       if (event->window == window)
598         {
599           GdkPixmap *pixmap;
600           GtkAllocation child_area;
601           cairo_t *cr;
602           int start_y = 0;
603
604           if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
605             {
606               pixmap = gdk_offscreen_window_get_pixmap (offscreen_box->offscreen_window1);
607               gtk_widget_get_allocation (offscreen_box->child1, &child_area);
608
609               cr = gdk_cairo_create (window);
610
611               gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
612               cairo_paint (cr);
613
614               cairo_destroy (cr);
615
616               start_y += child_area.height;
617             }
618
619           if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2))
620             {
621               gint w, h;
622
623               pixmap = gdk_offscreen_window_get_pixmap (offscreen_box->offscreen_window2);
624               gtk_widget_get_allocation (offscreen_box->child2, &child_area);
625
626               cr = gdk_cairo_create (window);
627
628               /* transform */
629               cairo_translate (cr, 0, start_y);
630               cairo_translate (cr, child_area.width / 2, child_area.height / 2);
631               cairo_rotate (cr, offscreen_box->angle);
632               cairo_translate (cr, -child_area.width / 2, -child_area.height / 2);
633
634               /* clip */
635               gdk_drawable_get_size (pixmap, &w, &h);
636               cairo_rectangle (cr, 0, 0, w, h);
637               cairo_clip (cr);
638
639               /* paint */
640               gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
641               cairo_paint (cr);
642
643               cairo_destroy (cr);
644             }
645         }
646       else if (event->window == offscreen_box->offscreen_window1)
647         {
648           gtk_paint_flat_box (gtk_widget_get_style (widget), event->window,
649                               GTK_STATE_NORMAL, GTK_SHADOW_NONE,
650                               &event->area, widget, "blah",
651                               0, 0, -1, -1);
652
653           if (offscreen_box->child1)
654             gtk_container_propagate_expose (GTK_CONTAINER (widget),
655                                             offscreen_box->child1,
656                                             event);
657         }
658       else if (event->window == offscreen_box->offscreen_window2)
659         {
660           gtk_paint_flat_box (gtk_widget_get_style (widget), event->window,
661                               GTK_STATE_NORMAL, GTK_SHADOW_NONE,
662                               &event->area, widget, "blah",
663                               0, 0, -1, -1);
664
665           if (offscreen_box->child2)
666             gtk_container_propagate_expose (GTK_CONTAINER (widget),
667                                             offscreen_box->child2,
668                                             event);
669         }
670     }
671
672   return FALSE;
673 }