]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/win_gtk.c
stop usign a deprecated method, and ensure that the imagelist
[wxWidgets.git] / src / gtk1 / win_gtk.c
CommitLineData
c67daf87 1/* ///////////////////////////////////////////////////////////////////////////
c67d8618 2// Name: win_gtk.c
ed673c6a
RR
3// Purpose: Native GTK+ widget for wxWindows, based on GtkLayout and
4// GtkFixed. It makes use of the gravity window property and
5// therefore does not work with GTK 1.0.
c801d85f 6// Author: Robert Roebling
c67d8618 7// Id: $Id$
01111366 8// Copyright: (c) 1998 Robert Roebling
bf3dab48 9// Licence: wxWindows licence
c67daf87 10/////////////////////////////////////////////////////////////////////////// */
c801d85f 11
d02af7bb
JJ
12#ifdef VMS
13#define XCheckIfEvent XCHECKIFEVENT
3fa056ab 14#endif
27df579a 15
d02af7bb 16#include "wx/setup.h"
27df579a 17#include "wx/gtk/win_gtk.h"
034be888 18#include "gtk/gtksignal.h"
ed673c6a
RR
19#include "gtk/gtkprivate.h"
20#include "gdk/gdkx.h"
38c7b3d3 21
c801d85f
KB
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
67d78217
RR
26#ifndef __WXGTK20__
27
c916e13b
RR
28#include <X11/Xlib.h>
29#include <X11/Xutil.h>
30#include <X11/Xatom.h>
31
ed673c6a
RR
32#define IS_ONSCREEN(x,y) ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && \
33 (y >= G_MINSHORT) && (y <= G_MAXSHORT))
34
67d78217
RR
35#endif
36
da048e3d 37typedef struct _GtkPizzaAdjData GtkPizzaAdjData;
ed673c6a 38
bf3dab48 39struct _GtkPizzaAdjData
ed673c6a
RR
40{
41 gint dx;
42 gint dy;
43};
44
b6fa52db
RR
45static void gtk_pizza_class_init (GtkPizzaClass *klass);
46static void gtk_pizza_init (GtkPizza *pizza);
ed673c6a 47
b6fa52db
RR
48static void gtk_pizza_realize (GtkWidget *widget);
49static void gtk_pizza_unrealize (GtkWidget *widget);
ed673c6a 50
b6fa52db 51static void gtk_pizza_map (GtkWidget *widget);
ed673c6a 52
da048e3d 53static void gtk_pizza_size_request (GtkWidget *widget,
bf3dab48 54 GtkRequisition *requisition);
da048e3d 55static void gtk_pizza_size_allocate (GtkWidget *widget,
bf3dab48 56 GtkAllocation *allocation);
9e691f46 57#ifndef __WXGTK20__
da048e3d 58static void gtk_pizza_draw (GtkWidget *widget,
bf3dab48 59 GdkRectangle *area);
9e691f46 60#endif /* __WXGTK20__ */
da048e3d 61static gint gtk_pizza_expose (GtkWidget *widget,
bf3dab48 62 GdkEventExpose *event);
da048e3d 63static void gtk_pizza_add (GtkContainer *container,
bf3dab48 64 GtkWidget *widget);
da048e3d 65static void gtk_pizza_remove (GtkContainer *container,
bf3dab48 66 GtkWidget *widget);
b6fa52db
RR
67static void gtk_pizza_forall (GtkContainer *container,
68 gboolean include_internals,
69 GtkCallback callback,
70 gpointer callback_data);
3fc6e5fa 71
67d78217
RR
72static void gtk_pizza_allocate_child (GtkPizza *pizza,
73 GtkPizzaChild *child);
3fc6e5fa
RR
74static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
75 gpointer cb_data);
ed673c6a 76
3fc6e5fa 77#ifndef __WXGTK20__
da048e3d 78static void gtk_pizza_position_child (GtkPizza *pizza,
b6fa52db 79 GtkPizzaChild *child);
da048e3d 80static void gtk_pizza_position_children (GtkPizza *pizza);
ed673c6a 81
da048e3d 82static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent,
b6fa52db
RR
83 GdkEvent *event,
84 gpointer data);
da048e3d 85static GdkFilterReturn gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
b6fa52db
RR
86 GdkEvent *event,
87 gpointer data);
67d78217 88#endif /* __WXGTK20__ */
ed673c6a 89
da048e3d 90static GtkType gtk_pizza_child_type (GtkContainer *container);
c801d85f 91
b6fa52db 92static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
bf3dab48
VZ
93 GtkAdjustment *hadj,
94 GtkAdjustment *vadj);
c801d85f
KB
95
96
67d78217
RR
97#ifdef __WXGTK20__
98 GtkContainerClass *pizza_parent_class = NULL;
99#else
100static GtkContainerClass *pizza_parent_class = NULL;
101#endif
102
ed673c6a 103static gboolean gravity_works;
034be888 104
c801d85f 105guint
da048e3d 106gtk_pizza_get_type ()
c801d85f 107{
da048e3d 108 static guint pizza_type = 0;
c801d85f 109
da048e3d 110 if (!pizza_type)
c801d85f 111 {
67d78217
RR
112
113#ifdef __WXGTK20__
114 static const GTypeInfo pizza_info =
115 {
116 sizeof (GtkPizzaClass),
117 NULL, /* base_init */
118 NULL, /* base_finalize */
119 (GClassInitFunc) gtk_pizza_class_init,
120 NULL, /* class_finalize */
121 NULL, /* class_data */
122 sizeof (GtkPizza),
123 16, /* n_preallocs */
124 (GInstanceInitFunc) gtk_pizza_init,
125 };
126 pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, 0);
127#else
da048e3d 128 GtkTypeInfo pizza_info =
053f9cc1 129 {
67d78217
RR
130 "GtkPizza",
131 sizeof (GtkPizza),
132 sizeof (GtkPizzaClass),
133 (GtkClassInitFunc) gtk_pizza_class_init,
134 (GtkObjectInitFunc) gtk_pizza_init,
135 /* reserved_1 */ NULL,
136 /* reserved_2 */ NULL,
137 (GtkClassInitFunc) NULL,
053f9cc1 138 };
da048e3d 139 pizza_type = gtk_type_unique (gtk_container_get_type (), &pizza_info);
67d78217 140#endif
c801d85f 141 }
bf3dab48 142
da048e3d 143 return pizza_type;
c801d85f
KB
144}
145
146static void
da048e3d 147gtk_pizza_class_init (GtkPizzaClass *klass)
c801d85f 148{
053f9cc1
RR
149 GtkObjectClass *object_class;
150 GtkWidgetClass *widget_class;
151 GtkContainerClass *container_class;
c801d85f 152
053f9cc1
RR
153 object_class = (GtkObjectClass*) klass;
154 widget_class = (GtkWidgetClass*) klass;
155 container_class = (GtkContainerClass*) klass;
67d78217 156 pizza_parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
c801d85f 157
da048e3d
RR
158 widget_class->map = gtk_pizza_map;
159 widget_class->realize = gtk_pizza_realize;
160 widget_class->unrealize = gtk_pizza_unrealize;
161 widget_class->size_request = gtk_pizza_size_request;
162 widget_class->size_allocate = gtk_pizza_size_allocate;
9e691f46 163#ifndef __WXGTK20__
da048e3d 164 widget_class->draw = gtk_pizza_draw;
9e691f46 165#endif
da048e3d 166 widget_class->expose_event = gtk_pizza_expose;
053f9cc1 167
da048e3d
RR
168 container_class->add = gtk_pizza_add;
169 container_class->remove = gtk_pizza_remove;
170 container_class->forall = gtk_pizza_forall;
38c7b3d3 171
da048e3d 172 container_class->child_type = gtk_pizza_child_type;
034be888 173
da048e3d 174 klass->set_scroll_adjustments = gtk_pizza_scroll_set_adjustments;
034be888 175
053f9cc1 176 widget_class->set_scroll_adjustments_signal =
034be888 177 gtk_signal_new ("set_scroll_adjustments",
bf3dab48 178 GTK_RUN_LAST,
31124903 179#ifdef __WXGTK20__
a2d8ce85 180 GTK_CLASS_TYPE(object_class),
31124903
VS
181#else
182 object_class->type,
183#endif
bf3dab48
VZ
184 GTK_SIGNAL_OFFSET (GtkPizzaClass, set_scroll_adjustments),
185 gtk_marshal_NONE__POINTER_POINTER,
186 GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
38c7b3d3
RR
187}
188
38c7b3d3 189static GtkType
da048e3d 190gtk_pizza_child_type (GtkContainer *container)
38c7b3d3 191{
053f9cc1 192 return GTK_TYPE_WIDGET;
c801d85f
KB
193}
194
195static void
da048e3d 196gtk_pizza_init (GtkPizza *pizza)
c801d85f 197{
da048e3d 198 GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
bf3dab48 199
da048e3d 200 pizza->shadow_type = GTK_MYSHADOW_NONE;
034be888 201
da048e3d 202 pizza->children = NULL;
bf3dab48 203
da048e3d
RR
204 pizza->width = 20;
205 pizza->height = 20;
ed673c6a 206
da048e3d 207 pizza->bin_window = NULL;
3dd9b88a 208
8e217128
RR
209 pizza->xoffset = 0;
210 pizza->yoffset = 0;
ed673c6a 211
da048e3d
RR
212 pizza->configure_serial = 0;
213 pizza->scroll_x = 0;
214 pizza->scroll_y = 0;
215 pizza->visibility = GDK_VISIBILITY_PARTIAL;
bf3dab48 216
da048e3d 217 pizza->clear_on_draw = TRUE;
b6fa52db 218 pizza->use_filter = TRUE;
b420fb6a 219 pizza->external_expose = FALSE;
c801d85f
KB
220}
221
222GtkWidget*
da048e3d 223gtk_pizza_new ()
c801d85f 224{
da048e3d 225 GtkPizza *pizza;
c801d85f 226
da048e3d 227 pizza = gtk_type_new (gtk_pizza_get_type ());
bf3dab48 228
da048e3d 229 return GTK_WIDGET (pizza);
c801d85f
KB
230}
231
bf3dab48 232static void
da048e3d 233gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
bf3dab48
VZ
234 GtkAdjustment *hadj,
235 GtkAdjustment *vadj)
034be888 236{
ed673c6a 237 /* We handle scrolling in the wxScrolledWindow, not here. */
034be888
RR
238}
239
bf3dab48 240void
b6fa52db 241gtk_pizza_set_shadow_type (GtkPizza *pizza,
0e09f76e 242 GtkMyShadowType type)
034be888 243{
da048e3d
RR
244 g_return_if_fail (pizza != NULL);
245 g_return_if_fail (GTK_IS_PIZZA (pizza));
034be888 246
da048e3d 247 if ((GtkMyShadowType) pizza->shadow_type != type)
034be888 248 {
da048e3d 249 pizza->shadow_type = type;
034be888 250
da048e3d 251 if (GTK_WIDGET_VISIBLE (pizza))
bf3dab48
VZ
252 {
253 gtk_widget_size_allocate (GTK_WIDGET (pizza), &(GTK_WIDGET (pizza)->allocation));
254 gtk_widget_queue_draw (GTK_WIDGET (pizza));
255 }
034be888
RR
256 }
257}
034be888 258
bf3dab48 259void
b6fa52db
RR
260gtk_pizza_set_clear (GtkPizza *pizza,
261 gboolean clear)
147bc491 262{
da048e3d
RR
263 g_return_if_fail (pizza != NULL);
264 g_return_if_fail (GTK_IS_PIZZA (pizza));
bf3dab48 265
da048e3d 266 pizza->clear_on_draw = clear;
bf3dab48
VZ
267}
268
3dd9b88a 269void
b6fa52db
RR
270gtk_pizza_set_filter (GtkPizza *pizza,
271 gboolean use)
0e09f76e
RR
272{
273 g_return_if_fail (pizza != NULL);
274 g_return_if_fail (GTK_IS_PIZZA (pizza));
275
276 pizza->use_filter = use;
3dd9b88a
VZ
277}
278
279void
b420fb6a
RR
280gtk_pizza_set_external (GtkPizza *pizza,
281 gboolean expose)
282{
283 g_return_if_fail (pizza != NULL);
284 g_return_if_fail (GTK_IS_PIZZA (pizza));
285
286 pizza->external_expose = expose;
287}
288
c801d85f 289void
b6fa52db
RR
290gtk_pizza_put (GtkPizza *pizza,
291 GtkWidget *widget,
292 gint x,
293 gint y,
294 gint width,
295 gint height)
c801d85f 296{
da048e3d 297 GtkPizzaChild *child_info;
053f9cc1 298
da048e3d
RR
299 g_return_if_fail (pizza != NULL);
300 g_return_if_fail (GTK_IS_PIZZA (pizza));
053f9cc1
RR
301 g_return_if_fail (widget != NULL);
302
da048e3d 303 child_info = g_new (GtkPizzaChild, 1);
bf3dab48 304
053f9cc1
RR
305 child_info->widget = widget;
306 child_info->x = x;
307 child_info->y = y;
308 child_info->width = width;
309 child_info->height = height;
bf3dab48
VZ
310
311 pizza->children = g_list_append (pizza->children, child_info);
ed673c6a 312
da048e3d
RR
313 if (GTK_WIDGET_REALIZED (pizza))
314 gtk_widget_set_parent_window (widget, pizza->bin_window);
bf3dab48 315
2b5f62a0
VZ
316 gtk_widget_set_parent (widget, GTK_WIDGET (pizza));
317
a2d8ce85 318#ifndef __WXGTK20__ /* FIXME? */
ed673c6a
RR
319 if (!IS_ONSCREEN (x, y))
320 GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN);
a2d8ce85 321#endif
c801d85f 322
ed673c6a 323 gtk_widget_set_usize (widget, width, height);
c801d85f
KB
324}
325
326void
b6fa52db
RR
327gtk_pizza_move (GtkPizza *pizza,
328 GtkWidget *widget,
329 gint x,
330 gint y)
c801d85f 331{
da048e3d 332 GtkPizzaChild *child;
053f9cc1 333 GList *children;
c801d85f 334
da048e3d
RR
335 g_return_if_fail (pizza != NULL);
336 g_return_if_fail (GTK_IS_PIZZA (pizza));
053f9cc1 337 g_return_if_fail (widget != NULL);
c801d85f 338
da048e3d 339 children = pizza->children;
053f9cc1 340 while (children)
fdd3ed7a 341 {
053f9cc1
RR
342 child = children->data;
343 children = children->next;
bf3dab48 344
053f9cc1 345 if (child->widget == widget)
fdd3ed7a 346 {
bf3dab48
VZ
347 if ((child->x == x) && (child->y == y))
348 break;
349
ed673c6a
RR
350 child->x = x;
351 child->y = y;
3fc6e5fa 352
bf3dab48
VZ
353 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza))
354 gtk_widget_queue_resize (widget);
355 break;
356 }
fdd3ed7a
RR
357 }
358}
359
360void
b6fa52db
RR
361gtk_pizza_resize (GtkPizza *pizza,
362 GtkWidget *widget,
363 gint width,
364 gint height)
fdd3ed7a 365{
da048e3d 366 GtkPizzaChild *child;
053f9cc1 367 GList *children;
fdd3ed7a 368
da048e3d
RR
369 g_return_if_fail (pizza != NULL);
370 g_return_if_fail (GTK_IS_PIZZA (pizza));
053f9cc1 371 g_return_if_fail (widget != NULL);
fdd3ed7a 372
da048e3d 373 children = pizza->children;
053f9cc1 374 while (children)
fdd3ed7a 375 {
053f9cc1
RR
376 child = children->data;
377 children = children->next;
bf3dab48 378
053f9cc1 379 if (child->widget == widget)
fdd3ed7a 380 {
bf3dab48
VZ
381 if ((child->width == width) && (child->height == height))
382 break;
383
ed673c6a
RR
384 child->width = width;
385 child->height = height;
bf3dab48
VZ
386
387 gtk_widget_set_usize (widget, width, height);
388
da048e3d 389 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza))
bf3dab48
VZ
390 gtk_widget_queue_resize (widget);
391 break;
392 }
fdd3ed7a
RR
393 }
394}
395
396void
b6fa52db
RR
397gtk_pizza_set_size (GtkPizza *pizza,
398 GtkWidget *widget,
399 gint x,
400 gint y,
401 gint width,
402 gint height)
fdd3ed7a 403{
da048e3d 404 GtkPizzaChild *child;
053f9cc1 405 GList *children;
fdd3ed7a 406
da048e3d
RR
407 g_return_if_fail (pizza != NULL);
408 g_return_if_fail (GTK_IS_PIZZA (pizza));
053f9cc1 409 g_return_if_fail (widget != NULL);
fdd3ed7a 410
da048e3d 411 children = pizza->children;
053f9cc1 412 while (children)
c801d85f 413 {
053f9cc1
RR
414 child = children->data;
415 children = children->next;
c801d85f 416
053f9cc1 417 if (child->widget == widget)
c801d85f 418 {
bf3dab48
VZ
419 if ((child->x == x) &&
420 (child->y == y) &&
421 (child->width == width) &&
422 (child->height == height)) return;
423
053f9cc1
RR
424 child->x = x;
425 child->y = y;
426 child->width = width;
427 child->height = height;
bf3dab48
VZ
428
429 gtk_widget_set_usize (widget, width, height);
430
da048e3d 431 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza))
bf3dab48
VZ
432 gtk_widget_queue_resize (widget);
433
6d693bb4 434 return;
c801d85f
KB
435 }
436 }
437}
438
3dd9b88a 439gint
8cb9f0d0
RR
440gtk_pizza_child_resized (GtkPizza *pizza,
441 GtkWidget *widget)
442{
443 GtkPizzaChild *child;
444 GList *children;
445
446 g_return_val_if_fail (pizza != NULL, FALSE);
447 g_return_val_if_fail (GTK_IS_PIZZA (pizza), FALSE);
448 g_return_val_if_fail (widget != NULL, FALSE);
449
450 children = pizza->children;
451 while (children)
452 {
453 child = children->data;
454 children = children->next;
455
456 if (child->widget == widget)
457 {
458 return ((child->width == widget->allocation.width) &&
459 (child->height == widget->allocation.height));
460 }
461 }
3dd9b88a 462
8cb9f0d0
RR
463 return FALSE;
464}
3dd9b88a 465
c801d85f 466static void
da048e3d 467gtk_pizza_map (GtkWidget *widget)
c801d85f 468{
da048e3d
RR
469 GtkPizza *pizza;
470 GtkPizzaChild *child;
053f9cc1 471 GList *children;
c801d85f 472
053f9cc1 473 g_return_if_fail (widget != NULL);
da048e3d 474 g_return_if_fail (GTK_IS_PIZZA (widget));
c801d85f 475
053f9cc1 476 GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
da048e3d 477 pizza = GTK_PIZZA (widget);
c801d85f 478
da048e3d 479 children = pizza->children;
053f9cc1 480 while (children)
c801d85f 481 {
053f9cc1
RR
482 child = children->data;
483 children = children->next;
c801d85f 484
bf3dab48
VZ
485 if ( GTK_WIDGET_VISIBLE (child->widget) &&
486 !GTK_WIDGET_MAPPED (child->widget) &&
a2d8ce85
OK
487#ifdef __WXGTK20__
488 TRUE)
489#else
bf3dab48 490 !GTK_WIDGET_IS_OFFSCREEN (child->widget))
a2d8ce85 491#endif
bf3dab48
VZ
492 {
493 gtk_widget_map (child->widget);
494 }
c801d85f 495 }
bf3dab48 496
053f9cc1 497 gdk_window_show (widget->window);
da048e3d 498 gdk_window_show (pizza->bin_window);
c801d85f
KB
499}
500
c801d85f 501static void
da048e3d 502gtk_pizza_realize (GtkWidget *widget)
c801d85f 503{
da048e3d 504 GtkPizza *pizza;
053f9cc1
RR
505 GdkWindowAttr attributes;
506 gint attributes_mask;
da048e3d 507 GtkPizzaChild *child;
ed673c6a 508 GList *children;
c801d85f 509
053f9cc1 510 g_return_if_fail (widget != NULL);
da048e3d 511 g_return_if_fail (GTK_IS_PIZZA (widget));
c801d85f 512
da048e3d 513 pizza = GTK_PIZZA (widget);
053f9cc1 514 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
c801d85f 515
053f9cc1 516 attributes.window_type = GDK_WINDOW_CHILD;
bf3dab48 517
053f9cc1
RR
518 attributes.x = widget->allocation.x;
519 attributes.y = widget->allocation.y;
520 attributes.width = widget->allocation.width;
521 attributes.height = widget->allocation.height;
522
1e6feb95 523#ifndef __WXUNIVERSAL__
da048e3d 524 if (pizza->shadow_type == GTK_MYSHADOW_NONE)
053f9cc1 525 {
5e014a0c 526 /* no border, no changes to sizes */
1e6feb95
VZ
527 }
528 else if (pizza->shadow_type == GTK_MYSHADOW_THIN)
5e014a0c
RR
529 {
530 /* GTK_MYSHADOW_THIN == wxSIMPLE_BORDER */
531 attributes.x += 1;
532 attributes.y += 1;
533 attributes.width -= 2;
534 attributes.height -= 2;
1e6feb95
VZ
535 }
536 else
5e014a0c
RR
537 {
538 /* GTK_MYSHADOW_IN == wxSUNKEN_BORDER */
539 /* GTK_MYSHADOW_OUT == wxRAISED_BORDER */
053f9cc1
RR
540 attributes.x += 2;
541 attributes.y += 2;
542 attributes.width -= 4;
543 attributes.height -= 4;
544 }
1e6feb95 545#endif /* __WXUNIVERSAL__ */
bf3dab48 546
ed673c6a 547 /* minimal size */
053f9cc1
RR
548 if (attributes.width < 2) attributes.width = 2;
549 if (attributes.height < 2) attributes.height = 2;
bf3dab48 550
053f9cc1
RR
551 attributes.wclass = GDK_INPUT_OUTPUT;
552 attributes.visual = gtk_widget_get_visual (widget);
553 attributes.colormap = gtk_widget_get_colormap (widget);
3dd9b88a 554 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
ed673c6a 555 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
bf3dab48 556
c916e13b 557 widget->window = gdk_window_new(gtk_widget_get_parent_window (widget),
bf3dab48 558 &attributes, attributes_mask);
ed673c6a
RR
559 gdk_window_set_user_data (widget->window, widget);
560
561 attributes.x = 0;
562 attributes.y = 0;
bf3dab48 563
053f9cc1 564 attributes.event_mask = gtk_widget_get_events (widget);
3dd9b88a 565 attributes.event_mask |= GDK_EXPOSURE_MASK |
67d78217
RR
566#ifdef __WXGTK20__
567 GDK_SCROLL_MASK |
568#endif
3dd9b88a
VZ
569 GDK_POINTER_MOTION_MASK |
570 GDK_POINTER_MOTION_HINT_MASK |
571 GDK_BUTTON_MOTION_MASK |
572 GDK_BUTTON1_MOTION_MASK |
573 GDK_BUTTON2_MOTION_MASK |
574 GDK_BUTTON3_MOTION_MASK |
575 GDK_BUTTON_PRESS_MASK |
576 GDK_BUTTON_RELEASE_MASK |
577 GDK_KEY_PRESS_MASK |
578 GDK_KEY_RELEASE_MASK |
579 GDK_ENTER_NOTIFY_MASK |
580 GDK_LEAVE_NOTIFY_MASK |
581 GDK_FOCUS_CHANGE_MASK;
053f9cc1 582
c916e13b 583 pizza->bin_window = gdk_window_new(widget->window,
bf3dab48 584 &attributes, attributes_mask);
da048e3d 585 gdk_window_set_user_data (pizza->bin_window, widget);
bf3dab48 586
053f9cc1
RR
587 widget->style = gtk_style_attach (widget->style, widget->window);
588 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
b6fa52db 589 gtk_style_set_background (widget->style, pizza->bin_window, GTK_STATE_NORMAL );
33611ebb
RR
590
591/*
592 gdk_window_set_back_pixmap( widget->window, NULL, FALSE );
593 gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE );
594*/
bf3dab48 595
67d78217 596#ifndef __WXGTK20__
ed673c6a 597 /* add filters for intercepting visibility and expose events */
da048e3d
RR
598 gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza);
599 gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza);
67d78217 600#endif
ed673c6a
RR
601
602 /* we NEED gravity or we'll give up */
da048e3d 603 gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE);
ed673c6a
RR
604
605 /* cannot be done before realisation */
da048e3d 606 children = pizza->children;
ed673c6a
RR
607 while (children)
608 {
609 child = children->data;
610 children = children->next;
611
da048e3d 612 gtk_widget_set_parent_window (child->widget, pizza->bin_window);
ed673c6a
RR
613 }
614}
615
bf3dab48 616static void
da048e3d 617gtk_pizza_unrealize (GtkWidget *widget)
ed673c6a 618{
d5ab387d 619 GtkPizza *pizza;
ed673c6a 620
d5ab387d
RR
621 g_return_if_fail (widget != NULL);
622 g_return_if_fail (GTK_IS_PIZZA (widget));
ed673c6a 623
d5ab387d 624 pizza = GTK_PIZZA (widget);
ed673c6a 625
d5ab387d
RR
626 gdk_window_set_user_data (pizza->bin_window, NULL);
627 gdk_window_destroy (pizza->bin_window);
628 pizza->bin_window = NULL;
ed673c6a 629
67d78217
RR
630 if (GTK_WIDGET_CLASS (pizza_parent_class)->unrealize)
631 (* GTK_WIDGET_CLASS (pizza_parent_class)->unrealize) (widget);
c801d85f
KB
632}
633
634static void
da048e3d 635gtk_pizza_size_request (GtkWidget *widget,
b6fa52db 636 GtkRequisition *requisition)
c801d85f 637{
da048e3d
RR
638 GtkPizza *pizza;
639 GtkPizzaChild *child;
053f9cc1
RR
640 GList *children;
641 GtkRequisition child_requisition;
bf3dab48 642
053f9cc1 643 g_return_if_fail (widget != NULL);
da048e3d 644 g_return_if_fail (GTK_IS_PIZZA (widget));
053f9cc1 645 g_return_if_fail (requisition != NULL);
c801d85f 646
da048e3d 647 pizza = GTK_PIZZA (widget);
bf3dab48 648
da048e3d 649 children = pizza->children;
053f9cc1 650 while (children)
c801d85f 651 {
053f9cc1
RR
652 child = children->data;
653 children = children->next;
c801d85f 654
053f9cc1 655 if (GTK_WIDGET_VISIBLE (child->widget))
bf3dab48 656 {
053f9cc1 657 gtk_widget_size_request (child->widget, &child_requisition);
bf3dab48 658 }
c801d85f 659 }
bf3dab48 660
053f9cc1
RR
661 /* request very little, I'm not sure if requesting nothing
662 will always have positive effects on stability... */
663 requisition->width = 2;
664 requisition->height = 2;
c801d85f
KB
665}
666
667static void
da048e3d 668gtk_pizza_size_allocate (GtkWidget *widget,
b6fa52db 669 GtkAllocation *allocation)
c801d85f 670{
da048e3d 671 GtkPizza *pizza;
053f9cc1 672 gint border;
ed673c6a 673 gint x,y,w,h;
da048e3d 674 GtkPizzaChild *child;
ed673c6a 675 GList *children;
c801d85f 676
053f9cc1 677 g_return_if_fail (widget != NULL);
da048e3d 678 g_return_if_fail (GTK_IS_PIZZA(widget));
053f9cc1 679 g_return_if_fail (allocation != NULL);
c801d85f 680
da048e3d 681 pizza = GTK_PIZZA (widget);
bf3dab48 682
227e5e99 683 widget->allocation = *allocation;
bf3dab48 684
da048e3d 685 if (pizza->shadow_type == GTK_MYSHADOW_NONE)
053f9cc1 686 border = 0;
5e014a0c 687 else
da048e3d 688 if (pizza->shadow_type == GTK_MYSHADOW_THIN)
5e014a0c 689 border = 1;
053f9cc1
RR
690 else
691 border = 2;
bf3dab48 692
ed673c6a
RR
693 x = allocation->x + border;
694 y = allocation->y + border;
695 w = allocation->width - border*2;
696 h = allocation->height - border*2;
034be888 697
053f9cc1
RR
698 if (GTK_WIDGET_REALIZED (widget))
699 {
ed673c6a 700 gdk_window_move_resize( widget->window, x, y, w, h );
da048e3d 701 gdk_window_move_resize( pizza->bin_window, 0, 0, w, h );
053f9cc1 702 }
bf3dab48 703
da048e3d 704 children = pizza->children;
6d693bb4
RR
705 while (children)
706 {
707 child = children->data;
708 children = children->next;
bf3dab48 709
3fc6e5fa 710#ifndef __WXGTK20__
da048e3d 711 gtk_pizza_position_child (pizza, child);
3fc6e5fa 712#endif
da048e3d 713 gtk_pizza_allocate_child (pizza, child);
6d693bb4 714 }
c801d85f
KB
715}
716
9e691f46
VZ
717#ifndef __WXGTK20__
718
c801d85f 719static void
da048e3d 720gtk_pizza_draw (GtkWidget *widget,
b6fa52db 721 GdkRectangle *area)
c801d85f 722{
b420fb6a
RR
723 GtkPizza *pizza;
724 GtkPizzaChild *child;
725 GdkRectangle child_area;
726 GList *children;
727
728 g_return_if_fail (widget != NULL);
729 g_return_if_fail (GTK_IS_PIZZA (widget));
730
731 pizza = GTK_PIZZA (widget);
732
733 /* Sometimes, We handle all expose events in window.cpp now. */
734 if (pizza->external_expose)
735 return;
736
737 children = pizza->children;
738 if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) &&
739 (pizza->clear_on_draw))
740 {
741 gdk_window_clear_area( pizza->bin_window,
742 area->x, area->y, area->width, area->height);
743 }
744
745 while (children)
746 {
747 child = children->data;
748 children = children->next;
749
750 if (gtk_widget_intersect (child->widget, area, &child_area))
751 gtk_widget_draw (child->widget, &child_area);
752 }
c801d85f
KB
753}
754
9e691f46
VZ
755#endif /* __WXGTK20__ */
756
c801d85f 757static gint
da048e3d 758gtk_pizza_expose (GtkWidget *widget,
b6fa52db 759 GdkEventExpose *event)
c801d85f 760{
b420fb6a 761 GtkPizza *pizza;
3fc6e5fa 762#ifndef __WXGTK20__
b420fb6a
RR
763 GtkPizzaChild *child;
764 GdkEventExpose child_event;
765 GList *children;
3fc6e5fa 766#endif
b420fb6a
RR
767
768 g_return_val_if_fail (widget != NULL, FALSE);
769 g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE);
770 g_return_val_if_fail (event != NULL, FALSE);
771
772 pizza = GTK_PIZZA (widget);
773
67d78217
RR
774 if (event->window != pizza->bin_window)
775 return FALSE;
4e5a4c69 776
67d78217 777 /* We handle all expose events in window.cpp now. */
b420fb6a 778 if (pizza->external_expose)
d5ab387d 779 return FALSE;
b420fb6a 780
67d78217
RR
781#ifdef __WXGTK20__
782
783 (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event);
784
785 return FALSE;
786
787#else
b420fb6a
RR
788
789 children = pizza->children;
790 while (children)
791 {
792 child = children->data;
793 children = children->next;
794
795 child_event = *event;
796
797 if (GTK_WIDGET_NO_WINDOW (child->widget) &&
798 GTK_WIDGET_DRAWABLE (child->widget) &&
799 gtk_widget_intersect (child->widget, &event->area, &child_event.area))
800 {
801 gtk_widget_event (child->widget, (GdkEvent*) &child_event);
802 }
803 }
67d78217 804
b420fb6a 805 return TRUE;
67d78217
RR
806
807#endif
c801d85f
KB
808}
809
810static void
da048e3d 811gtk_pizza_add (GtkContainer *container,
bf3dab48 812 GtkWidget *widget)
c801d85f 813{
ed673c6a 814 g_return_if_fail (container != NULL);
da048e3d 815 g_return_if_fail (GTK_IS_PIZZA (container));
ed673c6a 816 g_return_if_fail (widget != NULL);
c801d85f 817
da048e3d 818 gtk_pizza_put (GTK_PIZZA (container), widget, 0, 0, 20, 20 );
c801d85f
KB
819}
820
821static void
da048e3d 822gtk_pizza_remove (GtkContainer *container,
b6fa52db 823 GtkWidget *widget)
c801d85f 824{
da048e3d
RR
825 GtkPizza *pizza;
826 GtkPizzaChild *child;
ed673c6a 827 GList *children;
c801d85f 828
ed673c6a 829 g_return_if_fail (container != NULL);
da048e3d 830 g_return_if_fail (GTK_IS_PIZZA (container));
ed673c6a 831 g_return_if_fail (widget != NULL);
c801d85f 832
da048e3d 833 pizza = GTK_PIZZA (container);
c801d85f 834
da048e3d 835 children = pizza->children;
ed673c6a 836 while (children)
c801d85f 837 {
ed673c6a 838 child = children->data;
c801d85f 839
ed673c6a 840 if (child->widget == widget)
bf3dab48
VZ
841 {
842 gtk_widget_unparent (widget);
c801d85f 843
ed673c6a
RR
844 /* security checks */
845 g_return_if_fail (GTK_IS_WIDGET (widget));
bf3dab48
VZ
846
847 pizza->children = g_list_remove_link (pizza->children, children);
848 g_list_free (children);
849 g_free (child);
c801d85f 850
ed673c6a 851 /* security checks */
bf3dab48
VZ
852 g_return_if_fail (GTK_IS_WIDGET (widget));
853
a2d8ce85 854#ifndef __WXGTK20__
ed673c6a 855 GTK_PRIVATE_UNSET_FLAG (widget, GTK_IS_OFFSCREEN);
a2d8ce85 856#endif
bf3dab48
VZ
857
858 break;
859 }
c801d85f 860
ed673c6a 861 children = children->next;
c801d85f
KB
862 }
863}
864
865static void
da048e3d 866gtk_pizza_forall (GtkContainer *container,
b6fa52db
RR
867 gboolean include_internals,
868 GtkCallback callback,
869 gpointer callback_data)
c801d85f 870{
da048e3d
RR
871 GtkPizza *pizza;
872 GtkPizzaChild *child;
6d693bb4 873 GList *children;
c801d85f 874
6d693bb4 875 g_return_if_fail (container != NULL);
da048e3d 876 g_return_if_fail (GTK_IS_PIZZA (container));
90350682 877 g_return_if_fail (callback != (GtkCallback)NULL);
c801d85f 878
da048e3d 879 pizza = GTK_PIZZA (container);
c801d85f 880
da048e3d 881 children = pizza->children;
6d693bb4 882 while (children)
c801d85f 883 {
6d693bb4
RR
884 child = children->data;
885 children = children->next;
c801d85f 886
6d693bb4 887 (* callback) (child->widget, callback_data);
c801d85f
KB
888 }
889}
890
67d78217
RR
891static void
892gtk_pizza_allocate_child (GtkPizza *pizza,
893 GtkPizzaChild *child)
894{
895 GtkAllocation allocation;
896 GtkRequisition requisition;
c801d85f 897
67d78217
RR
898 allocation.x = child->x - pizza->xoffset;
899 allocation.y = child->y - pizza->yoffset;
900 gtk_widget_get_child_requisition (child->widget, &requisition);
901 allocation.width = requisition.width;
902 allocation.height = requisition.height;
903
904 gtk_widget_size_allocate (child->widget, &allocation);
905}
ed673c6a 906
ed673c6a 907static void
da048e3d 908gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
bf3dab48 909 gpointer cb_data)
ed673c6a 910{
da048e3d 911 GtkPizzaAdjData *data = cb_data;
ed673c6a 912
6d693bb4
RR
913 widget->allocation.x += data->dx;
914 widget->allocation.y += data->dy;
ed673c6a 915
6d693bb4
RR
916 if (GTK_WIDGET_NO_WINDOW (widget) && GTK_IS_CONTAINER (widget))
917 {
bf3dab48
VZ
918 gtk_container_forall (GTK_CONTAINER (widget),
919 gtk_pizza_adjust_allocations_recurse,
920 cb_data);
6d693bb4 921 }
ed673c6a
RR
922}
923
924static void
da048e3d 925gtk_pizza_adjust_allocations (GtkPizza *pizza,
bf3dab48
VZ
926 gint dx,
927 gint dy)
ed673c6a 928{
0e09f76e
RR
929 GList *tmp_list;
930 GtkPizzaAdjData data;
ed673c6a 931
0e09f76e
RR
932 data.dx = dx;
933 data.dy = dy;
ed673c6a 934
0e09f76e
RR
935 tmp_list = pizza->children;
936 while (tmp_list)
ed673c6a 937 {
0e09f76e
RR
938 GtkPizzaChild *child = tmp_list->data;
939 tmp_list = tmp_list->next;
bf3dab48 940
0e09f76e
RR
941 child->widget->allocation.x += dx;
942 child->widget->allocation.y += dy;
ed673c6a 943
0e09f76e
RR
944 if (GTK_WIDGET_NO_WINDOW (child->widget) &&
945 GTK_IS_CONTAINER (child->widget))
946 {
947 gtk_container_forall (GTK_CONTAINER (child->widget),
948 gtk_pizza_adjust_allocations_recurse,
949 &data);
950 }
ed673c6a
RR
951 }
952}
bf3dab48 953
3fc6e5fa
RR
954#ifndef __WXGTK20__
955static void
956gtk_pizza_position_child (GtkPizza *pizza,
957 GtkPizzaChild *child)
958{
959 gint x;
960 gint y;
ed673c6a 961
3fc6e5fa
RR
962 x = child->x - pizza->xoffset;
963 y = child->y - pizza->yoffset;
964
965 if (IS_ONSCREEN (x,y))
966 {
967 if (GTK_WIDGET_MAPPED (pizza) &&
968 GTK_WIDGET_VISIBLE (child->widget))
969 {
970 if (!GTK_WIDGET_MAPPED (child->widget))
971 gtk_widget_map (child->widget);
972 }
973
974 if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
975 GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
976 }
977 else
978 {
979 if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
980 GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
981
982 if (GTK_WIDGET_MAPPED (child->widget))
983 gtk_widget_unmap (child->widget);
984 }
985}
986
987static void
988gtk_pizza_position_children (GtkPizza *pizza)
989{
990 GList *tmp_list;
991
992 tmp_list = pizza->children;
993 while (tmp_list)
994 {
995 GtkPizzaChild *child = tmp_list->data;
996 tmp_list = tmp_list->next;
997
998 gtk_pizza_position_child (pizza, child);
999 }
1000}
1001
1002/* This function is used to find events to process while scrolling */
bf3dab48
VZ
1003static Bool
1004gtk_pizza_expose_predicate (Display *display,
1005 XEvent *xevent,
1006 XPointer arg)
ed673c6a 1007{
f6bcfd97
BP
1008 if ((xevent->type == Expose) ||
1009 ((xevent->xany.window == *(Window *)arg) &&
ed673c6a 1010 (xevent->type == ConfigureNotify)))
f6bcfd97
BP
1011 return True;
1012 else
1013 return False;
ed673c6a 1014}
3fc6e5fa 1015#endif /* __WXGTK20__ */
ed673c6a
RR
1016
1017/* This is the main routine to do the scrolling. Scrolling is
1018 * done by "Guffaw" scrolling, as in the Mozilla XFE, with
1019 * a few modifications.
bf3dab48 1020 *
ed673c6a
RR
1021 * The main improvement is that we keep track of whether we
1022 * are obscured or not. If not, we ignore the generated expose
1023 * events and instead do the exposes ourself, without having
1024 * to wait for a roundtrip to the server. This also provides
1025 * a limited form of expose-event compression, since we do
1026 * the affected area as one big chunk.
1027 */
1028
1029void
da048e3d 1030gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
ed673c6a 1031{
3fc6e5fa
RR
1032#ifdef __WXGTK20__
1033 pizza->xoffset += dx;
1034 pizza->yoffset += dy;
1035
1036 gtk_pizza_adjust_allocations (pizza, -dx, -dy);
1037
1038 if (pizza->bin_window)
1039 gdk_window_scroll( pizza->bin_window, -dx, -dy );
1040#else
f6bcfd97
BP
1041 GtkWidget *widget;
1042 XEvent xevent;
9e691f46 1043 XID win;
ed673c6a 1044
f6bcfd97 1045 gint x,y,w,h,border;
bf3dab48 1046
f6bcfd97 1047 widget = GTK_WIDGET (pizza);
ed673c6a 1048
f6bcfd97
BP
1049 pizza->xoffset += dx;
1050 pizza->yoffset += dy;
ed673c6a 1051
f6bcfd97 1052 if (!GTK_WIDGET_MAPPED (pizza))
ed673c6a 1053 {
f6bcfd97
BP
1054 gtk_pizza_position_children (pizza);
1055 return;
ed673c6a
RR
1056 }
1057
f6bcfd97 1058 gtk_pizza_adjust_allocations (pizza, -dx, -dy);
ed673c6a 1059
f6bcfd97
BP
1060 if (pizza->shadow_type == GTK_MYSHADOW_NONE)
1061 border = 0;
1062 else
1063 if (pizza->shadow_type == GTK_MYSHADOW_THIN)
1064 border = 1;
1065 else
1066 border = 2;
bf3dab48 1067
f6bcfd97
BP
1068 x = 0;
1069 y = 0;
1070 w = widget->allocation.width - 2*border;
1071 h = widget->allocation.height - 2*border;
bf3dab48 1072
f6bcfd97 1073 if (dx > 0)
ed673c6a 1074 {
f6bcfd97 1075 if (gravity_works)
bf3dab48
VZ
1076 {
1077 gdk_window_resize (pizza->bin_window,
1078 w + dx,
1079 h);
1080 gdk_window_move (pizza->bin_window, x-dx, y);
1081 gdk_window_move_resize (pizza->bin_window, x, y, w, h );
1082 }
f6bcfd97 1083 else
bf3dab48
VZ
1084 {
1085 /* FIXME */
1086 }
ed673c6a 1087 }
f6bcfd97 1088 else if (dx < 0)
ed673c6a 1089 {
f6bcfd97 1090 if (gravity_works)
bf3dab48
VZ
1091 {
1092 gdk_window_move_resize (pizza->bin_window,
1093 x + dx,
1094 y,
1095 w - dx,
1096 h);
1097 gdk_window_move (pizza->bin_window, x, y);
1098 gdk_window_resize (pizza->bin_window, w, h );
1099 }
f6bcfd97 1100 else
bf3dab48
VZ
1101 {
1102 /* FIXME */
1103 }
ed673c6a
RR
1104 }
1105
f6bcfd97 1106 if (dy > 0)
ed673c6a 1107 {
f6bcfd97 1108 if (gravity_works)
bf3dab48
VZ
1109 {
1110 gdk_window_resize (pizza->bin_window, w, h + dy);
1111 gdk_window_move (pizza->bin_window, x, y-dy);
1112 gdk_window_move_resize (pizza->bin_window,
1113 x, y, w, h );
1114 }
f6bcfd97 1115 else
bf3dab48
VZ
1116 {
1117 /* FIXME */
1118 }
ed673c6a 1119 }
f6bcfd97 1120 else if (dy < 0)
ed673c6a 1121 {
f6bcfd97 1122 if (gravity_works)
bf3dab48
VZ
1123 {
1124 gdk_window_move_resize (pizza->bin_window,
1125 x, y+dy, w, h - dy );
1126 gdk_window_move (pizza->bin_window, x, y);
1127 gdk_window_resize (pizza->bin_window, w, h );
1128 }
f6bcfd97 1129 else
bf3dab48
VZ
1130 {
1131 /* FIXME */
1132 }
ed673c6a
RR
1133 }
1134
f6bcfd97
BP
1135 gtk_pizza_position_children (pizza);
1136
1137 gdk_flush();
9e691f46
VZ
1138
1139 win = GDK_WINDOW_XWINDOW (pizza->bin_window);
f6bcfd97
BP
1140 while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window),
1141 &xevent,
1142 gtk_pizza_expose_predicate,
9e691f46 1143 (XPointer)&win))
ed673c6a 1144 {
f6bcfd97
BP
1145 GdkEvent event;
1146 GtkWidget *event_widget;
ed673c6a 1147
f6bcfd97
BP
1148 if ((xevent.xany.window == GDK_WINDOW_XWINDOW (pizza->bin_window)) )
1149 gtk_pizza_filter (&xevent, &event, pizza);
bf3dab48 1150
f6bcfd97 1151 if (xevent.type == Expose)
bf3dab48 1152 {
f6bcfd97
BP
1153 event.expose.window = gdk_window_lookup (xevent.xany.window);
1154 gdk_window_get_user_data (event.expose.window,
bf3dab48
VZ
1155 (gpointer *)&event_widget);
1156
f6bcfd97 1157 if (event_widget)
bf3dab48 1158 {
f6bcfd97
BP
1159 event.expose.type = GDK_EXPOSE;
1160 event.expose.area.x = xevent.xexpose.x;
1161 event.expose.area.y = xevent.xexpose.y;
1162 event.expose.area.width = xevent.xexpose.width;
1163 event.expose.area.height = xevent.xexpose.height;
1164 event.expose.count = xevent.xexpose.count;
1165
1166 gdk_window_ref (event.expose.window);
1167 gtk_widget_event (event_widget, &event);
1168 gdk_window_unref (event.expose.window);
bf3dab48
VZ
1169 }
1170 }
ed673c6a 1171 }
3fc6e5fa 1172#endif /* __WXGTK20__ */
ed673c6a
RR
1173}
1174
3fc6e5fa
RR
1175
1176#ifndef __WXGTK20__
ed673c6a
RR
1177/* The main event filter. Actually, we probably don't really need
1178 * to install this as a filter at all, since we are calling it
1179 * directly above in the expose-handling hack. But in case scrollbars
1180 * are fixed up in some manner...
1181 *
1182 * This routine identifies expose events that are generated when
1183 * we've temporarily moved the bin_window_origin, and translates
1184 * them or discards them, depending on whether we are obscured
1185 * or not.
1186 */
bf3dab48 1187static GdkFilterReturn
da048e3d 1188gtk_pizza_filter (GdkXEvent *gdk_xevent,
bf3dab48
VZ
1189 GdkEvent *event,
1190 gpointer data)
ed673c6a 1191{
0e09f76e
RR
1192 XEvent *xevent;
1193 GtkPizza *pizza;
ed673c6a 1194
0e09f76e 1195 xevent = (XEvent *)gdk_xevent;
3dd9b88a 1196
0e09f76e 1197 pizza = GTK_PIZZA (data);
3dd9b88a 1198
b6fa52db
RR
1199 if (!pizza->use_filter)
1200 return GDK_FILTER_CONTINUE;
1201
f6bcfd97 1202 switch (xevent->type)
ed673c6a 1203 {
3dd9b88a
VZ
1204 case Expose:
1205 if (xevent->xexpose.serial == pizza->configure_serial)
1206 {
1207 xevent->xexpose.x += pizza->scroll_x;
1208 xevent->xexpose.y += pizza->scroll_y;
1209 }
1210 break;
bf3dab48 1211
3dd9b88a
VZ
1212 case ConfigureNotify:
1213 {
1214 pizza->configure_serial = xevent->xconfigure.serial;
1215 pizza->scroll_x = xevent->xconfigure.x;
1216 pizza->scroll_y = xevent->xconfigure.y;
1217 }
1218 break;
ed673c6a 1219 }
bf3dab48 1220
0e09f76e 1221 return GDK_FILTER_CONTINUE;
ed673c6a
RR
1222}
1223
1224/* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
1225 * there is no corresponding event in GTK, so we have
1226 * to get the events from a filter
1227 */
bf3dab48 1228static GdkFilterReturn
da048e3d 1229gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
bf3dab48
VZ
1230 GdkEvent *event,
1231 gpointer data)
ed673c6a 1232{
0e09f76e
RR
1233 XEvent *xevent;
1234 GtkPizza *pizza;
ed673c6a 1235
0e09f76e
RR
1236 xevent = (XEvent *)gdk_xevent;
1237 pizza = GTK_PIZZA (data);
3dd9b88a 1238
b6fa52db
RR
1239 if (!pizza->use_filter)
1240 return GDK_FILTER_CONTINUE;
ed673c6a 1241
0e09f76e 1242 if (xevent->type == VisibilityNotify)
ed673c6a 1243 {
0e09f76e 1244 switch (xevent->xvisibility.state)
bf3dab48 1245 {
0e09f76e
RR
1246 case VisibilityFullyObscured:
1247 pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
1248 break;
ed673c6a 1249
0e09f76e
RR
1250 case VisibilityPartiallyObscured:
1251 pizza->visibility = GDK_VISIBILITY_PARTIAL;
1252 break;
ed673c6a 1253
0e09f76e
RR
1254 case VisibilityUnobscured:
1255 pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
1256 break;
bf3dab48 1257 }
3dd9b88a 1258
0e09f76e 1259 return GDK_FILTER_REMOVE;
ed673c6a
RR
1260 }
1261
0e09f76e 1262 return GDK_FILTER_CONTINUE;
ed673c6a 1263}
67d78217
RR
1264#endif /* __WXGTK20__ */
1265
ed673c6a 1266
c801d85f
KB
1267#ifdef __cplusplus
1268}
1269#endif /* __cplusplus */
1270