mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-02 09:01:39 -05:00
Add hook to allow globals to send cold-plug events to new clients.
This lets us boot strap the client side state cache. This commit also adds the first user of this feature, an output object that represents the current output. Very simple at this point, but will grow to something more like RandR 1.2.
This commit is contained in:
parent
8049cbb88a
commit
ee02ca6fa4
7 changed files with 124 additions and 22 deletions
|
|
@ -67,6 +67,9 @@ struct wl_display {
|
|||
|
||||
wl_display_event_func_t event_handler;
|
||||
void *event_handler_data;
|
||||
|
||||
uint32_t output_id;
|
||||
int32_t width, height;
|
||||
};
|
||||
|
||||
struct wl_compositor {
|
||||
|
|
@ -96,6 +99,13 @@ connection_update(struct wl_connection *connection,
|
|||
return 0;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
wl_display_get_geometry(struct wl_display *display, int32_t *width, int32_t *height)
|
||||
{
|
||||
*width = display->width;
|
||||
*height = display->height;
|
||||
}
|
||||
|
||||
static void
|
||||
add_visual(struct wl_display *display, struct wl_global *global)
|
||||
{
|
||||
|
|
@ -258,6 +268,9 @@ handle_display_event(struct wl_display *display,
|
|||
|
||||
if (strcmp(global->interface, "visual") == 0)
|
||||
add_visual(display, global);
|
||||
else if (strcmp(global->interface, "output") == 0) {
|
||||
display->output_id = p[0];
|
||||
}
|
||||
break;
|
||||
|
||||
case WL_DISPLAY_RANGE:
|
||||
|
|
@ -266,6 +279,18 @@ handle_display_event(struct wl_display *display,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_output_event(struct wl_display *display,
|
||||
uint32_t opcode, uint32_t *p, uint32_t size)
|
||||
{
|
||||
switch (opcode) {
|
||||
case WL_OUTPUT_PRESENCE:
|
||||
display->width = p[0];
|
||||
display->height = p[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_event(struct wl_display *display,
|
||||
uint32_t object, uint32_t opcode, uint32_t size)
|
||||
|
|
@ -275,6 +300,8 @@ handle_event(struct wl_display *display,
|
|||
wl_connection_copy(display->connection, p, size);
|
||||
if (object == 1) {
|
||||
handle_display_event(display, opcode, p + 2, size);
|
||||
} if (object == display->output_id) {
|
||||
handle_output_event(display, opcode, p + 2, size);
|
||||
} else if (display->event_handler != NULL)
|
||||
display->event_handler(display, object, opcode, size, p + 2,
|
||||
display->event_handler_data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue