Split weston_compositor_init into base and _gl
weston_compositor_init is always called late because most implementations can't initialise GL until fairly late in the game. Split it into a base version with the same name, followed by weston_compositor_init_gl which can be called later on. This simplifies compositor-wayland, which no longer needs a separate global handler just for wl_seat. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
5069280d29
commit
725c2c3d68
@@ -417,6 +417,10 @@ android_compositor_create(struct wl_display *display, int argc, char *argv[],
|
|||||||
if (compositor == NULL)
|
if (compositor == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (weston_compositor_init(&compositor->base, display, argc, argv,
|
||||||
|
config_file) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
compositor->base.destroy = android_compositor_destroy;
|
compositor->base.destroy = android_compositor_destroy;
|
||||||
|
|
||||||
compositor->base.focus = 1;
|
compositor->base.focus = 1;
|
||||||
@@ -430,8 +434,7 @@ android_compositor_create(struct wl_display *display, int argc, char *argv[],
|
|||||||
if (android_init_egl(compositor, output) < 0)
|
if (android_init_egl(compositor, output) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (weston_compositor_init(&compositor->base, display, argc, argv,
|
if (weston_compositor_init_gl(&compositor->base) < 0)
|
||||||
config_file) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
android_compositor_add_output(compositor, output);
|
android_compositor_add_output(compositor, output);
|
||||||
|
|||||||
@@ -1774,8 +1774,12 @@ drm_compositor_create(struct wl_display *display,
|
|||||||
ec = malloc(sizeof *ec);
|
ec = malloc(sizeof *ec);
|
||||||
if (ec == NULL)
|
if (ec == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memset(ec, 0, sizeof *ec);
|
memset(ec, 0, sizeof *ec);
|
||||||
|
|
||||||
|
if (weston_compositor_init(&ec->base, display, argc, argv,
|
||||||
|
config_file) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
ec->udev = udev_new();
|
ec->udev = udev_new();
|
||||||
if (ec->udev == NULL) {
|
if (ec->udev == NULL) {
|
||||||
weston_log("failed to initialize udev context\n");
|
weston_log("failed to initialize udev context\n");
|
||||||
@@ -1826,9 +1830,7 @@ drm_compositor_create(struct wl_display *display,
|
|||||||
|
|
||||||
ec->prev_state = WESTON_COMPOSITOR_ACTIVE;
|
ec->prev_state = WESTON_COMPOSITOR_ACTIVE;
|
||||||
|
|
||||||
/* Can't init base class until we have a current egl context */
|
if (weston_compositor_init_gl(&ec->base) < 0)
|
||||||
if (weston_compositor_init(&ec->base, display, argc, argv,
|
|
||||||
config_file) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (key = KEY_F1; key < KEY_F9; key++)
|
for (key = KEY_F1; key < KEY_F9; key++)
|
||||||
|
|||||||
@@ -612,6 +612,10 @@ wfd_compositor_create(struct wl_display *display,
|
|||||||
|
|
||||||
memset(ec, 0, sizeof *ec);
|
memset(ec, 0, sizeof *ec);
|
||||||
|
|
||||||
|
/* XXX: This is totally broken and doesn't even compile. */
|
||||||
|
if (weston_compositor_init(&ec->base, display) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
ec->start_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
ec->start_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||||
|
|
||||||
@@ -645,8 +649,7 @@ wfd_compositor_create(struct wl_display *display,
|
|||||||
glGenFramebuffers(1, &ec->base.fbo);
|
glGenFramebuffers(1, &ec->base.fbo);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo);
|
||||||
|
|
||||||
/* Can't init base class until we have a current egl context */
|
if (weston_compositor_init_gl(&ec->base) < 0)
|
||||||
if (weston_compositor_init(&ec->base, display) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (create_outputs(ec, connector) < 0) {
|
if (create_outputs(ec, connector) < 0) {
|
||||||
|
|||||||
+10
-26
@@ -759,22 +759,6 @@ display_add_seat(struct wayland_compositor *c, uint32_t id)
|
|||||||
wl_seat_set_user_data(input->seat, input);
|
wl_seat_set_user_data(input->seat, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can't start adding input devices until weston_compositor_init, but
|
|
||||||
* also can't call weston_compositor_init until we've handled some of the
|
|
||||||
* base display code first. So, we have a separate global handler for
|
|
||||||
* seats. */
|
|
||||||
static void
|
|
||||||
display_handle_global_input(struct wl_display *display, uint32_t id,
|
|
||||||
const char *interface, uint32_t version,
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
struct wayland_compositor *c = data;
|
|
||||||
|
|
||||||
if (strcmp(interface, "wl_seat") == 0)
|
|
||||||
display_add_seat(c, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_handle_global(struct wl_display *display, uint32_t id,
|
display_handle_global(struct wl_display *display, uint32_t id,
|
||||||
const char *interface, uint32_t version, void *data)
|
const char *interface, uint32_t version, void *data)
|
||||||
@@ -791,6 +775,8 @@ display_handle_global(struct wl_display *display, uint32_t id,
|
|||||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||||
c->parent.shell =
|
c->parent.shell =
|
||||||
wl_display_bind(display, id, &wl_shell_interface);
|
wl_display_bind(display, id, &wl_shell_interface);
|
||||||
|
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||||
|
display_add_seat(c, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,10 +819,6 @@ wayland_input_create(struct wayland_compositor *c)
|
|||||||
|
|
||||||
c->base.seat = seat;
|
c->base.seat = seat;
|
||||||
|
|
||||||
wl_display_add_global_listener(c->parent.wl_display,
|
|
||||||
display_handle_global_input,
|
|
||||||
c);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -863,6 +845,13 @@ wayland_compositor_create(struct wl_display *display,
|
|||||||
|
|
||||||
memset(c, 0, sizeof *c);
|
memset(c, 0, sizeof *c);
|
||||||
|
|
||||||
|
if (weston_compositor_init(&c->base, display, argc, argv,
|
||||||
|
config_file) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (wayland_input_create(c) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
c->parent.wl_display = wl_display_connect(display_name);
|
c->parent.wl_display = wl_display_connect(display_name);
|
||||||
|
|
||||||
if (c->parent.wl_display == NULL) {
|
if (c->parent.wl_display == NULL) {
|
||||||
@@ -882,18 +871,13 @@ wayland_compositor_create(struct wl_display *display,
|
|||||||
|
|
||||||
c->base.destroy = wayland_destroy;
|
c->base.destroy = wayland_destroy;
|
||||||
|
|
||||||
/* Can't init base class until we have a current egl context */
|
if (weston_compositor_init_gl(&c->base) < 0)
|
||||||
if (weston_compositor_init(&c->base, display, argc, argv,
|
|
||||||
config_file) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
create_border(c);
|
create_border(c);
|
||||||
if (wayland_compositor_create_output(c, width, height) < 0)
|
if (wayland_compositor_create_output(c, width, height) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (wayland_input_create(c) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
loop = wl_display_get_event_loop(c->base.wl_display);
|
loop = wl_display_get_event_loop(c->base.wl_display);
|
||||||
|
|
||||||
fd = wl_display_get_fd(c->parent.wl_display, update_event_mask, c);
|
fd = wl_display_get_fd(c->parent.wl_display, update_event_mask, c);
|
||||||
|
|||||||
@@ -1060,6 +1060,10 @@ x11_compositor_create(struct wl_display *display,
|
|||||||
|
|
||||||
memset(c, 0, sizeof *c);
|
memset(c, 0, sizeof *c);
|
||||||
|
|
||||||
|
if (weston_compositor_init(&c->base, display, argc, argv,
|
||||||
|
config_file) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
c->dpy = XOpenDisplay(NULL);
|
c->dpy = XOpenDisplay(NULL);
|
||||||
if (c->dpy == NULL)
|
if (c->dpy == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1082,9 +1086,7 @@ x11_compositor_create(struct wl_display *display,
|
|||||||
|
|
||||||
c->base.destroy = x11_destroy;
|
c->base.destroy = x11_destroy;
|
||||||
|
|
||||||
/* Can't init base class until we have a current egl context */
|
if (weston_compositor_init_gl(&c->base) < 0)
|
||||||
if (weston_compositor_init(&c->base, display, argc, argv,
|
|
||||||
config_file) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (x11_input_create(c, no_input) < 0)
|
if (x11_input_create(c, no_input) < 0)
|
||||||
|
|||||||
+33
-25
@@ -2988,7 +2988,6 @@ weston_compositor_init(struct weston_compositor *ec,
|
|||||||
const char *config_file)
|
const char *config_file)
|
||||||
{
|
{
|
||||||
struct wl_event_loop *loop;
|
struct wl_event_loop *loop;
|
||||||
const char *extensions;
|
|
||||||
struct xkb_rule_names xkb_names;
|
struct xkb_rule_names xkb_names;
|
||||||
const struct config_key keyboard_config_keys[] = {
|
const struct config_key keyboard_config_keys[] = {
|
||||||
{ "keymap_rules", CONFIG_KEY_STRING, &xkb_names.rules },
|
{ "keymap_rules", CONFIG_KEY_STRING, &xkb_names.rules },
|
||||||
@@ -3020,8 +3019,41 @@ weston_compositor_init(struct weston_compositor *ec,
|
|||||||
ec, compositor_bind))
|
ec, compositor_bind))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
wl_list_init(&ec->surface_list);
|
||||||
|
wl_list_init(&ec->layer_list);
|
||||||
|
wl_list_init(&ec->seat_list);
|
||||||
|
wl_list_init(&ec->output_list);
|
||||||
|
wl_list_init(&ec->key_binding_list);
|
||||||
|
wl_list_init(&ec->button_binding_list);
|
||||||
|
wl_list_init(&ec->axis_binding_list);
|
||||||
|
wl_list_init(&ec->fade.animation.link);
|
||||||
|
|
||||||
|
weston_compositor_xkb_init(ec, &xkb_names);
|
||||||
|
|
||||||
|
ec->ping_handler = NULL;
|
||||||
|
|
||||||
|
screenshooter_create(ec);
|
||||||
|
text_cursor_position_notifier_create(ec);
|
||||||
|
input_method_create(ec);
|
||||||
|
|
||||||
|
wl_data_device_manager_init(ec->wl_display);
|
||||||
|
|
||||||
wl_display_init_shm(display);
|
wl_display_init_shm(display);
|
||||||
|
|
||||||
|
loop = wl_display_get_event_loop(ec->wl_display);
|
||||||
|
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
|
||||||
|
wl_event_source_timer_update(ec->idle_source, ec->idle_time * 1000);
|
||||||
|
|
||||||
|
ec->input_loop = wl_event_loop_create();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT int
|
||||||
|
weston_compositor_init_gl(struct weston_compositor *ec)
|
||||||
|
{
|
||||||
|
const char *extensions;
|
||||||
|
|
||||||
log_egl_gl_info(ec->egl_display);
|
log_egl_gl_info(ec->egl_display);
|
||||||
|
|
||||||
ec->image_target_texture_2d =
|
ec->image_target_texture_2d =
|
||||||
@@ -3066,28 +3098,12 @@ weston_compositor_init(struct weston_compositor *ec,
|
|||||||
if (ec->has_bind_display)
|
if (ec->has_bind_display)
|
||||||
ec->bind_display(ec->egl_display, ec->wl_display);
|
ec->bind_display(ec->egl_display, ec->wl_display);
|
||||||
|
|
||||||
wl_list_init(&ec->surface_list);
|
|
||||||
wl_list_init(&ec->layer_list);
|
|
||||||
wl_list_init(&ec->seat_list);
|
|
||||||
wl_list_init(&ec->output_list);
|
|
||||||
wl_list_init(&ec->key_binding_list);
|
|
||||||
wl_list_init(&ec->button_binding_list);
|
|
||||||
wl_list_init(&ec->axis_binding_list);
|
|
||||||
weston_spring_init(&ec->fade.spring, 30.0, 1.0, 1.0);
|
weston_spring_init(&ec->fade.spring, 30.0, 1.0, 1.0);
|
||||||
ec->fade.animation.frame = fade_frame;
|
ec->fade.animation.frame = fade_frame;
|
||||||
wl_list_init(&ec->fade.animation.link);
|
|
||||||
|
|
||||||
weston_layer_init(&ec->fade_layer, &ec->layer_list);
|
weston_layer_init(&ec->fade_layer, &ec->layer_list);
|
||||||
weston_layer_init(&ec->cursor_layer, &ec->fade_layer.link);
|
weston_layer_init(&ec->cursor_layer, &ec->fade_layer.link);
|
||||||
|
|
||||||
screenshooter_create(ec);
|
|
||||||
text_cursor_position_notifier_create(ec);
|
|
||||||
input_method_create(ec);
|
|
||||||
|
|
||||||
ec->ping_handler = NULL;
|
|
||||||
|
|
||||||
wl_data_device_manager_init(ec->wl_display);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
if (weston_shader_init(&ec->texture_shader,
|
if (weston_shader_init(&ec->texture_shader,
|
||||||
@@ -3097,14 +3113,6 @@ weston_compositor_init(struct weston_compositor *ec,
|
|||||||
vertex_shader, solid_fragment_shader) < 0)
|
vertex_shader, solid_fragment_shader) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
weston_compositor_xkb_init(ec, &xkb_names);
|
|
||||||
|
|
||||||
loop = wl_display_get_event_loop(ec->wl_display);
|
|
||||||
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
|
|
||||||
wl_event_source_timer_update(ec->idle_source, ec->idle_time * 1000);
|
|
||||||
|
|
||||||
ec->input_loop = wl_event_loop_create();
|
|
||||||
|
|
||||||
weston_compositor_schedule_repaint(ec);
|
weston_compositor_schedule_repaint(ec);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -645,6 +645,8 @@ weston_compositor_get_time(void);
|
|||||||
int
|
int
|
||||||
weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
|
weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,
|
||||||
int argc, char *argv[], const char *config_file);
|
int argc, char *argv[], const char *config_file);
|
||||||
|
int
|
||||||
|
weston_compositor_init_gl(struct weston_compositor *ec);
|
||||||
void
|
void
|
||||||
weston_compositor_shutdown(struct weston_compositor *ec);
|
weston_compositor_shutdown(struct weston_compositor *ec);
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user