Skip to content

Commit 99a6e8d

Browse files
committed
patch 8.0.0521: GtkForm handling is outdated
Problem: GtkForm handling is outdated. Solution: Get rid of event filter functions. Get rid of GtkForm.width and .height. Eliminate gtk_widget_size_request() calls. (Kazunobu Kuriyama)
1 parent ace9598 commit 99a6e8d

3 files changed

Lines changed: 6 additions & 165 deletions

File tree

src/gui_gtk_f.c

Lines changed: 4 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,6 @@ static void gtk_form_position_child(GtkForm *form,
9292
gboolean force_allocate);
9393
static void gtk_form_position_children(GtkForm *form);
9494

95-
#if !GTK_CHECK_VERSION(3,0,0)
96-
static GdkFilterReturn gtk_form_filter(GdkXEvent *gdk_xevent,
97-
GdkEvent *event,
98-
gpointer data);
99-
static GdkFilterReturn gtk_form_main_filter(GdkXEvent *gdk_xevent,
100-
GdkEvent *event,
101-
gpointer data);
102-
#endif
10395
#if !GTK_CHECK_VERSION(3,16,0)
10496
static void gtk_form_set_static_gravity(GdkWindow *window,
10597
gboolean use_static);
@@ -171,9 +163,6 @@ gtk_form_put(GtkForm *form,
171163
gtk_form_attach_child_window(form, child);
172164

173165
gtk_widget_set_parent(child_widget, GTK_WIDGET(form));
174-
#if !GTK_CHECK_VERSION(3,0,0)
175-
gtk_widget_size_request(child->widget, NULL);
176-
#endif
177166

178167
#if GTK_CHECK_VERSION(3,0,0)
179168
if (gtk_widget_get_realized(GTK_WIDGET(form))
@@ -301,19 +290,7 @@ gtk_form_init(GtkForm *form)
301290
gtk_widget_set_has_window(GTK_WIDGET(form), TRUE);
302291
#endif
303292
form->children = NULL;
304-
305-
#if !GTK_CHECK_VERSION(3,0,0)
306-
form->width = 1;
307-
form->height = 1;
308-
#endif
309-
310293
form->bin_window = NULL;
311-
312-
#if !GTK_CHECK_VERSION(3,0,0)
313-
form->configure_serial = 0;
314-
form->visibility = GDK_VISIBILITY_PARTIAL;
315-
#endif
316-
317294
form->freeze_count = 0;
318295
}
319296

@@ -414,11 +391,6 @@ gtk_form_realize(GtkWidget *widget)
414391
gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL);
415392
#endif
416393

417-
#if !GTK_CHECK_VERSION(3,0,0)
418-
gdk_window_add_filter(widget->window, gtk_form_main_filter, form);
419-
gdk_window_add_filter(form->bin_window, gtk_form_filter, form);
420-
#endif
421-
422394
for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
423395
{
424396
GtkFormChild *child = tmp_list->data;
@@ -540,33 +512,11 @@ gtk_form_unrealize(GtkWidget *widget)
540512
static void
541513
gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition)
542514
{
543-
#if !GTK_CHECK_VERSION(3,0,0)
544-
GList *tmp_list;
545-
GtkForm *form;
546-
#endif
547-
548515
g_return_if_fail(GTK_IS_FORM(widget));
516+
g_return_if_fail(requisition != NULL);
549517

550-
#if !GTK_CHECK_VERSION(3,0,0)
551-
form = GTK_FORM(widget);
552-
#endif
553-
554-
#if GTK_CHECK_VERSION(3,0,0)
555518
requisition->width = 1;
556519
requisition->height = 1;
557-
#else
558-
requisition->width = form->width;
559-
requisition->height = form->height;
560-
561-
tmp_list = form->children;
562-
563-
while (tmp_list)
564-
{
565-
GtkFormChild *child = tmp_list->data;
566-
gtk_widget_size_request(child->widget, NULL);
567-
tmp_list = tmp_list->next;
568-
}
569-
#endif
570520
}
571521

572522
#if GTK_CHECK_VERSION(3,0,0)
@@ -735,28 +685,9 @@ gtk_form_expose(GtkWidget *widget, GdkEventExpose *event)
735685
return FALSE;
736686

737687
for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
738-
{
739-
GtkFormChild *formchild = tmp_list->data;
740-
GtkWidget *child = formchild->widget;
741-
/*
742-
* The following chunk of code is taken from gtkcontainer.c. The
743-
* gtk1.x code synthesized expose events directly on the child widgets,
744-
* which can't be done in gtk2
745-
*/
746-
if (GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child)
747-
&& child->window == event->window)
748-
{
749-
GdkEventExpose child_event;
750-
child_event = *event;
751-
752-
child_event.region = gtk_widget_region_intersect(child, event->region);
753-
if (!gdk_region_empty(child_event.region))
754-
{
755-
gdk_region_get_clipbox(child_event.region, &child_event.area);
756-
gtk_widget_send_expose(child, (GdkEvent *)&child_event);
757-
}
758-
}
759-
}
688+
gtk_container_propagate_expose(GTK_CONTAINER(widget),
689+
GTK_WIDGET(((GtkFormChild *)tmp_list->data)->widget),
690+
event);
760691

761692
return FALSE;
762693
}
@@ -1068,86 +999,6 @@ gtk_form_position_children(GtkForm *form)
1068999
gtk_form_position_child(form, tmp_list->data, FALSE);
10691000
}
10701001

1071-
/* Callbacks */
1072-
1073-
/* The main event filter. Actually, we probably don't really need
1074-
* to install this as a filter at all, since we are calling it
1075-
* directly above in the expose-handling hack.
1076-
*
1077-
* This routine identifies expose events that are generated when
1078-
* we've temporarily moved the bin_window_origin, and translates
1079-
* them or discards them, depending on whether we are obscured
1080-
* or not.
1081-
*/
1082-
#if !GTK_CHECK_VERSION(3,0,0)
1083-
static GdkFilterReturn
1084-
gtk_form_filter(GdkXEvent *gdk_xevent, GdkEvent *event UNUSED, gpointer data)
1085-
{
1086-
XEvent *xevent;
1087-
GtkForm *form;
1088-
1089-
xevent = (XEvent *) gdk_xevent;
1090-
form = GTK_FORM(data);
1091-
1092-
switch (xevent->type)
1093-
{
1094-
case Expose:
1095-
if (xevent->xexpose.serial == form->configure_serial)
1096-
{
1097-
if (form->visibility == GDK_VISIBILITY_UNOBSCURED)
1098-
return GDK_FILTER_REMOVE;
1099-
else
1100-
break;
1101-
}
1102-
break;
1103-
1104-
case ConfigureNotify:
1105-
if ((xevent->xconfigure.x != 0) || (xevent->xconfigure.y != 0))
1106-
form->configure_serial = xevent->xconfigure.serial;
1107-
break;
1108-
}
1109-
1110-
return GDK_FILTER_CONTINUE;
1111-
}
1112-
1113-
/* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
1114-
* there is no corresponding event in GTK, so we have
1115-
* to get the events from a filter
1116-
*/
1117-
static GdkFilterReturn
1118-
gtk_form_main_filter(GdkXEvent *gdk_xevent,
1119-
GdkEvent *event UNUSED,
1120-
gpointer data)
1121-
{
1122-
XEvent *xevent;
1123-
GtkForm *form;
1124-
1125-
xevent = (XEvent *) gdk_xevent;
1126-
form = GTK_FORM(data);
1127-
1128-
if (xevent->type == VisibilityNotify)
1129-
{
1130-
switch (xevent->xvisibility.state)
1131-
{
1132-
case VisibilityFullyObscured:
1133-
form->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
1134-
break;
1135-
1136-
case VisibilityPartiallyObscured:
1137-
form->visibility = GDK_VISIBILITY_PARTIAL;
1138-
break;
1139-
1140-
case VisibilityUnobscured:
1141-
form->visibility = GDK_VISIBILITY_UNOBSCURED;
1142-
break;
1143-
}
1144-
1145-
return GDK_FILTER_REMOVE;
1146-
}
1147-
return GDK_FILTER_CONTINUE;
1148-
}
1149-
#endif /* !GTK_CHECK_VERSION(3,0,0) */
1150-
11511002
#if !GTK_CHECK_VERSION(3,16,0)
11521003
static void
11531004
gtk_form_set_static_gravity(GdkWindow *window, gboolean use_static)

src/gui_gtk_f.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,7 @@ struct _GtkForm
4343
GtkContainer container;
4444

4545
GList *children;
46-
47-
#ifndef USE_GTK3
48-
guint width;
49-
guint height;
50-
#endif
51-
5246
GdkWindow *bin_window;
53-
54-
#ifndef USE_GTK3
55-
GdkVisibilityState visibility;
56-
gulong configure_serial;
57-
#endif
58-
5947
gint freeze_count;
6048
};
6149

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
521,
767769
/**/
768770
520,
769771
/**/

0 commit comments

Comments
 (0)