summaryrefslogtreecommitdiff
path: root/gtk/gtkmain.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-10-06 21:19:42 +0200
committerBenjamin Otte <otte@redhat.com>2017-10-06 21:23:39 +0200
commit43c212ac28f5f80e10c49590e569b6450098743f (patch)
treeae5210d90f79d313d3b4c88c88f5e00b87405e0e /gtk/gtkmain.c
parent2ac66328a3edc0838c19b49fcb9468c473936c9c (diff)
downloadgtk+-43c212ac28f5f80e10c49590e569b6450098743f.tar.gz
build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options: 1. Add all missing enums to the switch statement or 2. Cast the switch argument to a uint to avoid having to do that (mostly for GdkEventType). I even found a bug while doing that: clearing a GtkImage with a surface did not notify thae surface property. The reason for enabling this flag even though it is tedious at times is that it is very useful when adding values to an enum, because it makes GTK immediately warn about all the switch statements where this enum is relevant. And I expect changes to enums to be frequent during the GTK4 development cycle.
Diffstat (limited to 'gtk/gtkmain.c')
-rw-r--r--gtk/gtkmain.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 40b939f4b3..e9894a5815 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1140,7 +1140,7 @@ rewrite_event_for_window (GdkEvent *event,
{
event = gdk_event_copy (event);
- switch (event->type)
+ switch ((guint) event->type)
{
case GDK_SCROLL:
rewrite_events_translate (event->any.window,
@@ -1211,7 +1211,7 @@ rewrite_event_for_grabs (GdkEvent *event)
GdkDisplay *display;
GdkDevice *device;
- switch (event->type)
+ switch ((guint) event->type)
{
case GDK_SCROLL:
case GDK_BUTTON_PRESS:
@@ -1307,6 +1307,9 @@ get_virtual_notify_type (GdkNotifyType notify_type)
return GDK_NOTIFY_VIRTUAL;
case GDK_NOTIFY_NONLINEAR:
return GDK_NOTIFY_NONLINEAR_VIRTUAL;
+ case GDK_NOTIFY_VIRTUAL:
+ case GDK_NOTIFY_NONLINEAR_VIRTUAL:
+ case GDK_NOTIFY_UNKNOWN:
default:
g_assert_not_reached ();
return GDK_NOTIFY_UNKNOWN;
@@ -1441,7 +1444,7 @@ gtk_synthesize_crossing_events (GtkWindow *toplevel,
static gboolean
is_pointing_event (GdkEvent *event)
{
- switch (event->type)
+ switch ((guint) event->type)
{
case GDK_MOTION_NOTIFY:
case GDK_ENTER_NOTIFY:
@@ -1485,7 +1488,7 @@ handle_pointing_event (GdkEvent *event)
sequence = gdk_event_get_event_sequence (event);
- switch (event->type)
+ switch ((guint) event->type)
{
case GDK_LEAVE_NOTIFY:
if (event->crossing.mode == GDK_CROSSING_GRAB ||
@@ -1842,6 +1845,9 @@ gtk_main_do_event (GdkEvent *event)
case GDK_DROP_START:
_gtk_drag_dest_handle_event (event_widget, event);
break;
+ case GDK_SETTING:
+ case GDK_OWNER_CHANGE:
+ case GDK_EVENT_LAST:
default:
g_assert_not_reached ();
break;