8#define _POSIX_C_SOURCE 200112L
15static void output_handle_geometry(
void *data,
struct wl_output *wl_output,
16 int32_t x, int32_t y, int32_t phy_width, int32_t phy_height,
17 int32_t subpixel,
const char *make,
const char *model,
21 output->subpixel = subpixel;
23static void output_handle_mode(
void *data,
struct wl_output *wl_output, uint32_t flags,
24 int32_t width, int32_t height, int32_t refresh) {
30static void output_handle_scale(
void *data,
struct wl_output *wl_output,
38#ifdef WL_OUTPUT_NAME_SINCE_VERSION
39static void output_handle_name(
void *data,
struct wl_output *wl_output,
42 output->name = g_strdup(name);
43 LOG_D(
"Output global %" PRIu32
" name %s",
output->global_name, name);
46static void output_handle_description(
void *data,
struct wl_output *
output,
const char* description) {
51static void output_listener_done_handler(
void *data,
struct wl_output *
output) {
55static const struct wl_output_listener output_listener = {
56 .geometry = output_handle_geometry,
57 .mode = output_handle_mode,
58 .done = output_listener_done_handler,
59 .scale = output_handle_scale,
60#ifdef WL_OUTPUT_NAME_SINCE_VERSION
61 .name = output_handle_name,
62 .description = output_handle_description,
66void create_output(
struct wl_registry *registry, uint32_t global_name, uint32_t version) {
69 LOG_E(
"allocation failed");
73 uint32_t max_version = 3;
74#ifdef WL_OUTPUT_NAME_SINCE_VERSION
75 max_version = WL_OUTPUT_NAME_SINCE_VERSION;
77 bool recreate_surface =
false;
78 static int number = 0;
79 LOG_I(
"New output found - id %i", number);
80 output->global_name = global_name;
81 output->wl_output = wl_registry_bind(registry, global_name, &wl_output_interface,
82 CLAMP(version, 3, max_version));
84 output->fullscreen =
false;
86 recreate_surface = wl_list_empty(&ctx.outputs);
88 wl_list_insert(&ctx.outputs, &
output->link);
91 wl_output_add_listener(
output->wl_output, &output_listener,
output);
94 if (recreate_surface) {
101 if (ctx.surface_output ==
output) {
102 ctx.surface_output = NULL;
104 if (ctx.layer_surface_output ==
output) {
105 ctx.layer_surface_output = NULL;
107 wl_list_remove(&
output->link);
108 wl_output_destroy(
output->wl_output);
Logging subsystem and helpers.
#define LOG_E
Prefix message with "[<source path>:<function name>:<line number>] ".
Wayland context tracking.