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