2 * Copyright © 2008-2012 Kristian Høgsberg
3 * Copyright © 2010-2012 Intel Corporation
4 * Copyright © 2011 Benjamin Franzke
5 * Copyright © 2012 Collabora, Ltd.
6 * Copyright © 2015 S-Core Corporation
7 * Copyright © 2015-2016 Samsung Electronics co., Ltd. All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice (including the next
17 * paragraph) shall be included in all copies or substantial portions of the
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
37 #include <pepper-libinput.h>
38 #include <pepper-tdm.h>
39 #include <pepper-desktop-shell.h>
42 handle_signals(int s, siginfo_t *siginfo, void *context)
50 struct sigaction action;
52 action.sa_flags = SA_SIGINFO | SA_RESETHAND;
53 action.sa_sigaction = handle_signals;
54 sigemptyset(&action.sa_mask);
56 sigaction(SIGSEGV, &action, NULL);
57 sigaction(SIGABRT, &action, NULL);
61 handle_sigint(int signal_number, void *data)
63 struct wl_display *display = (struct wl_display *)data;
64 wl_display_terminate(display);
70 main(int argc, char **argv)
72 pepper_compositor_t *compositor = NULL;
73 pepper_tdm_t *tdm = NULL;
74 pepper_tdm_output_t *tdm_output = NULL;
75 pepper_tdm_renderer_t *tdm_renderer[3]; // assume that maximum outputs is 3
76 pepper_libinput_t *input = NULL;
78 struct udev *udev = NULL;
80 struct wl_display *display = NULL;
81 struct wl_event_loop *loop = NULL;
82 struct wl_event_source *sigint = NULL;
85 uint32_t num_outputs = 0;
86 const char *render_env = getenv("PEPPER_TDM_RENDERER");
90 compositor = pepper_compositor_create("wayland-0", NULL);
98 input = pepper_libinput_create(compositor, udev);
102 tdm = pepper_tdm_create(compositor);
106 num_outputs = pepper_tdm_count_outputs(tdm);
108 for (i = 0; i < num_outputs; i++) {
109 tdm_output = pepper_tdm_get_output(tdm, i);
111 if (render_env && !strcmp(render_env, "gl"))
112 tdm_renderer[i] = pepper_tdm_output_create_gl_renderer(tdm_output);
114 tdm_renderer[i] = pepper_tdm_output_create_pixman_renderer(tdm_output);
116 if (!tdm_renderer[i])
120 if (!pepper_desktop_shell_init(compositor))
123 display = pepper_compositor_get_display(compositor);
127 loop = wl_display_get_event_loop(display);
128 sigint = wl_event_loop_add_signal(loop, SIGINT, handle_sigint, display);
132 wl_display_run(display);
137 wl_event_source_remove(sigint);
139 for (i = 0; i < num_outputs; i++) {
141 pepper_tdm_renderer_destroy(tdm_renderer[i]);
145 pepper_tdm_destroy(tdm);
148 pepper_libinput_destroy(input);
154 pepper_compositor_destroy(compositor);