aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-06-20 15:29:27 -0400
committerDrew DeVault <sir@cmpwn.com>2017-06-20 15:29:27 -0400
commitc9d5a0b2fb5686627344922138c3c603cae364bc (patch)
tree93806ad5b5745eb63c29fe1a7a211571f0038591 /example
parent51f35e7af0f7f01381b702b7630763fb9354701a (diff)
Clean up Wayland backend GL context and such
Diffstat (limited to 'example')
-rw-r--r--example/pointer.c18
-rw-r--r--example/rotation.c14
-rw-r--r--example/shared.c6
-rw-r--r--example/simple.c10
-rw-r--r--example/tablet.c18
-rw-r--r--example/touch.c16
6 files changed, 41 insertions, 41 deletions
diff --git a/example/pointer.c b/example/pointer.c
index ddb665a1..1da77b85 100644
--- a/example/pointer.c
+++ b/example/pointer.c
@@ -110,22 +110,22 @@ int main(int argc, char *argv[]) {
.default_color = { 0.25f, 0.25f, 0.25f, 1 },
.clear_color = { 0.25f, 0.25f, 0.25f, 1 }
};
- struct compositor_state compositor;
-
+ struct compositor_state compositor = { 0,
+ .data = &state,
+ .output_add_cb = handle_output_add,
+ .output_frame_cb = handle_output_frame,
+ .keyboard_key_cb = handle_keyboard_key,
+ .pointer_motion_cb = handle_pointer_motion,
+ .pointer_button_cb = handle_pointer_button,
+ .pointer_axis_cb = handle_pointer_axis,
+ };
compositor_init(&compositor);
- compositor.output_add_cb = handle_output_add;
- compositor.output_frame_cb = handle_output_frame;
- compositor.keyboard_key_cb = handle_keyboard_key;
- compositor.pointer_motion_cb = handle_pointer_motion;
- compositor.pointer_button_cb = handle_pointer_button;
- compositor.pointer_axis_cb = handle_pointer_axis;
state.renderer = wlr_gles3_renderer_init();
state.cat_texture = wlr_render_surface_init(state.renderer);
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
- compositor.data = &state;
compositor_run(&compositor);
wlr_surface_destroy(state.cat_texture);
diff --git a/example/rotation.c b/example/rotation.c
index f4b7625e..a1c77013 100644
--- a/example/rotation.c
+++ b/example/rotation.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include <wayland-server.h>
#include <wayland-server-protocol.h>
@@ -193,22 +194,23 @@ static void parse_args(int argc, char *argv[], struct wl_list *config) {
int main(int argc, char *argv[]) {
struct sample_state state = { 0 };
- struct compositor_state compositor;
wl_list_init(&state.config);
parse_args(argc, argv, &state.config);
+ struct compositor_state compositor = { 0,
+ .data = &state,
+ .output_add_cb = handle_output_add,
+ .output_remove_cb = handle_output_remove,
+ .output_frame_cb = handle_output_frame,
+ .keyboard_key_cb = handle_keyboard_key,
+ };
compositor_init(&compositor);
- compositor.output_add_cb = handle_output_add;
- compositor.output_remove_cb = handle_output_remove;
- compositor.output_frame_cb = handle_output_frame;
- compositor.keyboard_key_cb = handle_keyboard_key;
state.renderer = wlr_gles3_renderer_init();
state.cat_texture = wlr_render_surface_init(state.renderer);
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
- compositor.data = &state;
compositor_run(&compositor);
wlr_surface_destroy(state.cat_texture);
diff --git a/example/shared.c b/example/shared.c
index be1bdee7..0fe7270f 100644
--- a/example/shared.c
+++ b/example/shared.c
@@ -418,8 +418,6 @@ static void output_remove_notify(struct wl_listener *listener, void *data) {
}
void compositor_init(struct compositor_state *state) {
- memset(state, 0, sizeof(struct compositor_state));
-
state->display = wl_display_create();
state->event_loop = wl_display_get_event_loop(state->display);
state->session = wlr_session_start(state->display);
@@ -457,14 +455,14 @@ void compositor_init(struct compositor_state *state) {
state->backend = wlr;
clock_gettime(CLOCK_MONOTONIC, &state->last_frame);
-}
-void compositor_run(struct compositor_state *state) {
if (!wlr_backend_init(state->backend)) {
fprintf(stderr, "Failed to initialize backend\n");
exit(1);
}
+}
+void compositor_run(struct compositor_state *state) {
while (!state->exit) {
wl_event_loop_dispatch(state->event_loop, 0);
}
diff --git a/example/simple.c b/example/simple.c
index 5a5a1300..f3a66db9 100644
--- a/example/simple.c
+++ b/example/simple.c
@@ -50,11 +50,11 @@ int main() {
.color = { 1.0, 0.0, 0.0 },
.dec = 0,
};
- struct compositor_state compositor;
-
+ struct compositor_state compositor = { 0,
+ .data = &state,
+ .output_frame_cb = handle_output_frame,
+ .keyboard_key_cb = handle_keyboard_key,
+ };
compositor_init(&compositor);
- compositor.output_frame_cb = handle_output_frame;
- compositor.keyboard_key_cb = handle_keyboard_key;
- compositor.data = &state;
compositor_run(&compositor);
}
diff --git a/example/tablet.c b/example/tablet.c
index 3c5b583e..6be006f0 100644
--- a/example/tablet.c
+++ b/example/tablet.c
@@ -145,19 +145,19 @@ int main(int argc, char *argv[]) {
.tool_color = { 1, 1, 1, 1 },
.pad_color = { 0.75, 0.75, 0.75, 1.0 }
};
- struct compositor_state compositor;
-
+ struct compositor_state compositor = { 0,
+ .data = &state,
+ .output_frame_cb = handle_output_frame,
+ .keyboard_key_cb = handle_keyboard_key,
+ .tool_axis_cb = handle_tool_axis,
+ .tool_proximity_cb = handle_tool_proximity,
+ .tool_button_cb = handle_tool_button,
+ .pad_button_cb = handle_pad_button,
+ };
compositor_init(&compositor);
- compositor.output_frame_cb = handle_output_frame;
- compositor.keyboard_key_cb = handle_keyboard_key;
- compositor.tool_axis_cb = handle_tool_axis;
- compositor.tool_proximity_cb = handle_tool_proximity;
- compositor.tool_button_cb = handle_tool_button;
- compositor.pad_button_cb = handle_pad_button;
state.renderer = wlr_gles3_renderer_init();
- compositor.data = &state;
compositor_run(&compositor);
wlr_renderer_destroy(state.renderer);
diff --git a/example/touch.c b/example/touch.c
index 46eddf62..1b4233bb 100644
--- a/example/touch.c
+++ b/example/touch.c
@@ -100,21 +100,21 @@ int main(int argc, char *argv[]) {
struct sample_state state = {
.touch_points = list_create()
};
- struct compositor_state compositor;
-
+ struct compositor_state compositor = { 0,
+ .data = &state,
+ .output_frame_cb = handle_output_frame,
+ .keyboard_key_cb = handle_keyboard_key,
+ .touch_down_cb = handle_touch_down,
+ .touch_up_cb = handle_touch_up,
+ .touch_motion_cb = handle_touch_motion,
+ };
compositor_init(&compositor);
- compositor.output_frame_cb = handle_output_frame;
- compositor.keyboard_key_cb = handle_keyboard_key;
- compositor.touch_down_cb = handle_touch_down;
- compositor.touch_up_cb = handle_touch_up;
- compositor.touch_motion_cb = handle_touch_motion;
state.renderer = wlr_gles3_renderer_init();
state.cat_texture = wlr_render_surface_init(state.renderer);
wlr_surface_attach_pixels(state.cat_texture, GL_RGBA,
cat_tex.width, cat_tex.height, cat_tex.pixel_data);
- compositor.data = &state;
compositor_run(&compositor);
wlr_surface_destroy(state.cat_texture);