smoke: fix the segment fault error
authorJuan Zhao <juan.j.zhao@linux.intel.com>
Fri, 3 Feb 2012 00:02:06 +0000 (16:02 -0800)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 8 Feb 2012 19:17:32 +0000 (14:17 -0500)
Add widget_set_size in the initiate time to allow smoke get the
correct surface later. Or it will report segment fault error because
of the null surface.

Also add resize_handler to not allow resizing just like flower.

Signed-off-by: Juan Zhao <juan.j.zhao@linux.intel.com>
clients/smoke.c

index c1665ce..69a1ac7 100644 (file)
@@ -249,6 +249,16 @@ smoke_motion_handler(struct widget *widget, struct input *input,
        return POINTER_HAND1;
 }
 
+static void
+resize_handler(struct widget *widget,
+              int32_t width, int32_t height, void *data)
+{
+       struct smoke *smoke = data;
+
+       /* Dont resize me */
+       widget_set_size(smoke->widget, smoke->width, smoke->height);
+}
+
 int main(int argc, char *argv[])
 {
        struct timespec ts;
@@ -270,6 +280,7 @@ int main(int argc, char *argv[])
        smoke.window = window_create(d);
        smoke.widget = window_add_widget(smoke.window, &smoke);
        window_set_title(smoke.window, "smoke");
+       widget_set_size(smoke.widget, smoke.width, smoke.height);
 
        window_set_buffer_type(smoke.window, WINDOW_BUFFER_TYPE_SHM);
        clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -291,6 +302,7 @@ int main(int argc, char *argv[])
        window_flush(smoke.window);
 
        widget_set_motion_handler(smoke.widget, smoke_motion_handler);
+       widget_set_resize_handler(smoke.widget, resize_handler);
 
        window_set_user_data(smoke.window, &smoke);
        frame_callback(&smoke, NULL, 0);