Add a proxy for the server side output object.
This commit is contained in:
parent
0395f30e65
commit
12ea62e211
@ -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,
|
||||||
|
@ -86,7 +86,7 @@ WL_EXPORT const struct wl_interface wl_input_device_interface = {
|
|||||||
|
|
||||||
|
|
||||||
static const struct wl_message output_events[] = {
|
static const struct wl_message output_events[] = {
|
||||||
{ "presence", "uu" },
|
{ "geometry", "uu" },
|
||||||
};
|
};
|
||||||
|
|
||||||
WL_EXPORT const struct wl_interface wl_output_interface = {
|
WL_EXPORT const struct wl_interface wl_output_interface = {
|
||||||
@ -94,3 +94,9 @@ WL_EXPORT const struct wl_interface wl_output_interface = {
|
|||||||
0, NULL,
|
0, NULL,
|
||||||
ARRAY_LENGTH(output_events), output_events,
|
ARRAY_LENGTH(output_events), output_events,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WL_EXPORT const struct wl_interface wl_visual_interface = {
|
||||||
|
"visual", 1,
|
||||||
|
0, NULL,
|
||||||
|
0, NULL,
|
||||||
|
};
|
||||||
|
@ -79,8 +79,11 @@ extern const struct wl_interface wl_surface_interface;
|
|||||||
extern const struct wl_interface wl_input_device_interface;
|
extern const struct wl_interface wl_input_device_interface;
|
||||||
|
|
||||||
|
|
||||||
#define WL_OUTPUT_PRESENCE 0
|
#define WL_OUTPUT_GEOMETRY 0
|
||||||
|
|
||||||
extern const struct wl_interface wl_output_interface;
|
extern const struct wl_interface wl_output_interface;
|
||||||
|
|
||||||
|
|
||||||
|
extern const struct wl_interface wl_visual_interface;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -846,13 +846,13 @@ add_visuals(struct egl_compositor *ec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
post_output_presence(struct wl_client *client, struct wl_object *global)
|
post_output_geometry(struct wl_client *client, struct wl_object *global)
|
||||||
{
|
{
|
||||||
struct egl_compositor *ec =
|
struct egl_compositor *ec =
|
||||||
container_of(global, struct egl_compositor, output.base);
|
container_of(global, struct egl_compositor, output.base);
|
||||||
|
|
||||||
wl_client_post_event(client, global,
|
wl_client_post_event(client, global,
|
||||||
WL_OUTPUT_PRESENCE, ec->width, ec->height);
|
WL_OUTPUT_GEOMETRY, ec->width, ec->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char gem_device[] = "/dev/dri/card0";
|
static const char gem_device[] = "/dev/dri/card0";
|
||||||
@ -1040,7 +1040,7 @@ egl_compositor_create(struct wl_display *display)
|
|||||||
/* FIXME: This needs to be much more expressive... something like randr 1.2. */
|
/* FIXME: This needs to be much more expressive... something like randr 1.2. */
|
||||||
ec->output.base.interface = &wl_output_interface;
|
ec->output.base.interface = &wl_output_interface;
|
||||||
wl_display_add_object(display, &ec->output.base);
|
wl_display_add_object(display, &ec->output.base);
|
||||||
wl_display_add_global(display, &ec->output.base, post_output_presence);
|
wl_display_add_global(display, &ec->output.base, post_output_geometry);
|
||||||
|
|
||||||
add_visuals(ec);
|
add_visuals(ec);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user