|
|
@ -68,8 +68,7 @@ struct wl_display { |
|
|
|
wl_display_event_func_t event_handler; |
|
|
|
wl_display_event_func_t event_handler; |
|
|
|
void *event_handler_data; |
|
|
|
void *event_handler_data; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t output_id; |
|
|
|
struct wl_output *output; |
|
|
|
int32_t width, height; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct wl_compositor { |
|
|
|
struct wl_compositor { |
|
|
@ -85,6 +84,11 @@ struct wl_visual { |
|
|
|
struct wl_list link; |
|
|
|
struct wl_list link; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wl_output { |
|
|
|
|
|
|
|
struct wl_proxy proxy; |
|
|
|
|
|
|
|
int32_t width, height; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
connection_update(struct wl_connection *connection, |
|
|
|
connection_update(struct wl_connection *connection, |
|
|
|
uint32_t mask, void *data) |
|
|
|
uint32_t mask, void *data) |
|
|
@ -102,8 +106,8 @@ connection_update(struct wl_connection *connection, |
|
|
|
WL_EXPORT void |
|
|
|
WL_EXPORT void |
|
|
|
wl_display_get_geometry(struct wl_display *display, int32_t *width, int32_t *height) |
|
|
|
wl_display_get_geometry(struct wl_display *display, int32_t *width, int32_t *height) |
|
|
|
{ |
|
|
|
{ |
|
|
|
*width = display->width; |
|
|
|
*width = display->output->width; |
|
|
|
*height = display->height; |
|
|
|
*height = display->output->height; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
@ -115,8 +119,9 @@ add_visual(struct wl_display *display, struct wl_global *global) |
|
|
|
if (visual == NULL) |
|
|
|
if (visual == NULL) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
visual->proxy.display = display; |
|
|
|
visual->proxy.interface = &wl_visual_interface; |
|
|
|
visual->proxy.id = global->id; |
|
|
|
visual->proxy.id = global->id; |
|
|
|
|
|
|
|
visual->proxy.display = display; |
|
|
|
wl_list_insert(display->visual_list.prev, &visual->link); |
|
|
|
wl_list_insert(display->visual_list.prev, &visual->link); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -229,6 +234,21 @@ wl_display_get_fd(struct wl_display *display, |
|
|
|
return display->fd; |
|
|
|
return display->fd; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
add_output(struct wl_display *display, struct wl_global *global) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct wl_output *output; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output = malloc(sizeof *output); |
|
|
|
|
|
|
|
if (output == NULL) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output->proxy.interface = &wl_output_interface; |
|
|
|
|
|
|
|
output->proxy.id = global->id; |
|
|
|
|
|
|
|
output->proxy.display = display; |
|
|
|
|
|
|
|
display->output = output; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
handle_display_event(struct wl_display *display, |
|
|
|
handle_display_event(struct wl_display *display, |
|
|
|
uint32_t opcode, uint32_t *p, uint32_t size) |
|
|
|
uint32_t opcode, uint32_t *p, uint32_t size) |
|
|
@ -265,12 +285,10 @@ handle_display_event(struct wl_display *display, |
|
|
|
global->interface[length] = '\0'; |
|
|
|
global->interface[length] = '\0'; |
|
|
|
global->version = p[2 + DIV_ROUNDUP(length, sizeof *p)]; |
|
|
|
global->version = p[2 + DIV_ROUNDUP(length, sizeof *p)]; |
|
|
|
wl_list_insert(display->global_list.prev, &global->link); |
|
|
|
wl_list_insert(display->global_list.prev, &global->link); |
|
|
|
|
|
|
|
|
|
|
|
if (strcmp(global->interface, "visual") == 0) |
|
|
|
if (strcmp(global->interface, "visual") == 0) |
|
|
|
add_visual(display, global); |
|
|
|
add_visual(display, global); |
|
|
|
else if (strcmp(global->interface, "output") == 0) { |
|
|
|
else if (strcmp(global->interface, "output") == 0) |
|
|
|
display->output_id = p[0]; |
|
|
|
add_output(display, global); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WL_DISPLAY_RANGE: |
|
|
|
case WL_DISPLAY_RANGE: |
|
|
@ -284,9 +302,9 @@ handle_output_event(struct wl_display *display, |
|
|
|
uint32_t opcode, uint32_t *p, uint32_t size) |
|
|
|
uint32_t opcode, uint32_t *p, uint32_t size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (opcode) { |
|
|
|
switch (opcode) { |
|
|
|
case WL_OUTPUT_PRESENCE: |
|
|
|
case WL_OUTPUT_GEOMETRY: |
|
|
|
display->width = p[0]; |
|
|
|
display->output->width = p[0]; |
|
|
|
display->height = p[1]; |
|
|
|
display->output->height = p[1]; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -300,7 +318,7 @@ handle_event(struct wl_display *display, |
|
|
|
wl_connection_copy(display->connection, p, size); |
|
|
|
wl_connection_copy(display->connection, p, size); |
|
|
|
if (object == 1) { |
|
|
|
if (object == 1) { |
|
|
|
handle_display_event(display, opcode, p + 2, size); |
|
|
|
handle_display_event(display, opcode, p + 2, size); |
|
|
|
} if (object == display->output_id) { |
|
|
|
} else if (object == display->output->proxy.id) { |
|
|
|
handle_output_event(display, opcode, p + 2, size); |
|
|
|
handle_output_event(display, opcode, p + 2, size); |
|
|
|
} else if (display->event_handler != NULL) |
|
|
|
} else if (display->event_handler != NULL) |
|
|
|
display->event_handler(display, object, opcode, size, p + 2, |
|
|
|
display->event_handler(display, object, opcode, size, p + 2, |
|
|
|