Example #1
0
void wayfire_core::init(wayfire_config *conf)
{
    configure(conf);
    wf_input_device::config.load(conf);

    protocols.data_device = wlr_data_device_manager_create(display);
    protocols.data_control = wlr_data_control_manager_v1_create(display);
    wlr_renderer_init_wl_display(renderer, display);

    output_layout = wlr_output_layout_create();
    output_layout_changed.notify = handle_output_layout_changed;
    wl_signal_add(&output_layout->events.change, &output_layout_changed);

    core->compositor = wlr_compositor_create(display, wlr_backend_get_renderer(backend));
    init_desktop_apis();
    input = new input_manager();

    protocols.screenshooter = wlr_screenshooter_create(display);
    protocols.screencopy = wlr_screencopy_manager_v1_create(display);
    protocols.gamma = wlr_gamma_control_manager_create(display);
    protocols.gamma_v1 = wlr_gamma_control_manager_v1_create(display);
    protocols.linux_dmabuf = wlr_linux_dmabuf_v1_create(display, renderer);
    protocols.export_dmabuf = wlr_export_dmabuf_manager_v1_create(display);

    protocols.decorator_manager = wlr_server_decoration_manager_create(display);
    wlr_server_decoration_manager_set_default_mode(protocols.decorator_manager,
                                                   WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT);

    input_inhibit_activated.notify = handle_input_inhibit_activated;
    input_inhibit_deactivated.notify = handle_input_inhibit_deactivated;
    protocols.input_inhibit = wlr_input_inhibit_manager_create(display);
    wl_signal_add(&protocols.input_inhibit->events.activate, &input_inhibit_activated);
    wl_signal_add(&protocols.input_inhibit->events.deactivate, &input_inhibit_deactivated);

    decoration_created.notify = handle_decoration_created;
    wl_signal_add(&protocols.decorator_manager->events.new_decoration, &decoration_created);

    protocols.output_manager = wlr_xdg_output_manager_v1_create(display, output_layout);

    protocols.vkbd_manager = wlr_virtual_keyboard_manager_v1_create(display);
    vkbd_created.notify = handle_virtual_keyboard;
    wl_signal_add(&protocols.vkbd_manager->events.new_virtual_keyboard, &vkbd_created);

    protocols.idle = wlr_idle_create(display);
    protocols.idle_inhibit = wlr_idle_inhibit_v1_create(display);

    protocols.wf_shell = wayfire_shell_create(display);
    protocols.gtk_shell = wf_gtk_shell_create(display);
    protocols.toplevel_manager = wlr_foreign_toplevel_manager_v1_create(display);

    protocols.pointer_gestures = wlr_pointer_gestures_v1_create(display);

    image_io::init();
    OpenGL::init();
}
Example #2
0
void update_debug_tree(void) {
	if (!debug.render_tree) {
		return;
	}

	int width = 640, height = 480;
	for (int i = 0; i < root->outputs->length; ++i) {
		struct sway_output *output = root->outputs->items[i];
		if (output->width > width) {
			width = output->width;
		}
		if (output->height > height) {
			height = output->height;
		}
	}
	cairo_surface_t *surface =
		cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
	cairo_t *cairo = cairo_create(surface);
	PangoContext *pango = pango_cairo_create_context(cairo);

	struct sway_seat *seat = input_manager_current_seat();
	struct sway_node *focus = seat_get_focus(seat);

	cairo_set_source_u32(cairo, 0x000000FF);
	draw_node(cairo, &root->node, focus, 0, 0);

	cairo_surface_flush(surface);
	struct wlr_renderer *renderer = wlr_backend_get_renderer(server.backend);
	if (root->debug_tree) {
		wlr_texture_destroy(root->debug_tree);
	}
	unsigned char *data = cairo_image_surface_get_data(surface);
	int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
	struct wlr_texture *texture = wlr_texture_from_pixels(renderer,
		WL_SHM_FORMAT_ARGB8888, stride, width, height, data);
	root->debug_tree = texture;
	cairo_surface_destroy(surface);
	g_object_unref(pango);
	cairo_destroy(cairo);
}