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