#include "pepper-internal.h"
static void
-output_update_mode(pepper_output_t *output)
+output_send_modes(pepper_output_t *output, struct wl_resource *resource)
{
- int i;
- struct wl_resource *resource;
- pepper_output_mode_t *preferred_mode = NULL;
-
- output->current_mode = NULL;
-
- if (output->modes)
- pepper_free(output->modes);
-
- output->mode_count = output->backend->get_mode_count(output->data);
- PEPPER_ASSERT(output->mode_count > 0);
+ int i;
+ int mode_count = output->backend->get_mode_count(output->data);
- output->modes = pepper_calloc(output->mode_count, sizeof(pepper_output_mode_t));
- if (!output->modes)
+ for (i = 0; i < mode_count; i++)
{
- pepper_output_destroy(output);
- return;
+ pepper_output_mode_t mode;
+
+ output->backend->get_mode(output->data, i, &mode);
+ wl_output_send_mode(resource, mode.flags, mode.w, mode.h, mode.refresh);
}
- for (i = 0; i < output->mode_count; i++)
- {
- output->backend->get_mode(output->data, i, &output->modes[i]);
+ wl_output_send_done(resource);
+}
- if (output->modes[i].flags & WL_OUTPUT_MODE_CURRENT)
- output->current_mode = &output->modes[i];
+static void
+output_update_mode(pepper_output_t *output)
+{
+ struct wl_resource *resource;
+ int i;
+ int mode_count = output->backend->get_mode_count(output->data);
- if (output->modes[i].flags & WL_OUTPUT_MODE_PREFERRED)
- preferred_mode = &output->modes[i];
- }
+ for (i = 0; i < mode_count; i++)
+ {
+ pepper_output_mode_t mode;
- if (!output->current_mode)
- output->current_mode = preferred_mode;
+ output->backend->get_mode(output->data, i, &mode);
- wl_resource_for_each(resource, &output->resources)
- {
- for (i = 0; i < output->mode_count; i++)
+ if (mode.flags & WL_OUTPUT_MODE_CURRENT)
{
- wl_output_send_mode(resource, output->modes[i].flags,
- output->modes[i].w, output->modes[i].h,
- output->modes[i].refresh);
- }
+ output->current_mode = mode;
- wl_output_send_done(resource);
+ wl_resource_for_each(resource, &output->resources)
+ {
+ wl_output_send_mode(resource, mode.flags, mode.w, mode.h, mode.refresh);
+ wl_output_send_done(resource);
+ }
+ }
}
}
{
struct wl_resource *resource;
pepper_output_t *output = (pepper_output_t *)data;
- int i;
resource = wl_resource_create(client, &wl_output_interface, 2, id);
output->geometry.transform);
wl_output_send_scale(resource, output->scale);
-
- for (i = 0; i < output->mode_count; i++)
- {
- wl_output_send_mode(resource, output->modes[i].flags,
- output->modes[i].w, output->modes[i].h,
- output->modes[i].refresh);
- }
-
- wl_output_send_done(resource);
+ output_send_modes(output, resource);
}
static void
output->geometry.model = backend->get_model_name(data);
output->geometry.x = 0;
output->geometry.y = 0;
- output->geometry.w = output->current_mode->w;
- output->geometry.h = output->current_mode->h;
+ output->geometry.w = output->current_mode.w;
+ output->geometry.h = output->current_mode.h;
pepper_list_insert(&compositor->output_list, &output->link);
output->link.item = output;
PEPPER_API int
pepper_output_get_mode_count(pepper_output_t *output)
{
- return output->mode_count;
+ return output->backend->get_mode_count(output->data);
}
-PEPPER_API const pepper_output_mode_t *
-pepper_output_get_mode(pepper_output_t *output, int index)
+PEPPER_API void
+pepper_output_get_mode(pepper_output_t *output, int index, pepper_output_mode_t *mode)
{
- if (index < 0 || index >= output->mode_count)
- return NULL;
-
- return &output->modes[index];
+ return output->backend->get_mode(output->data, index, mode);
}
PEPPER_API pepper_bool_t
pepper_output_set_mode(pepper_output_t *output, const pepper_output_mode_t *mode)
{
- if (output->current_mode == mode)
+ if (output->current_mode.w == mode->w && output->current_mode.h == mode->h &&
+ output->current_mode.refresh == mode->refresh)
return PEPPER_TRUE;
if (output->backend->set_mode(output->data, mode))
int32_t refresh;
};
+enum pepper_output_mode_flag
+{
+ PEPPER_OUTPUT_MODE_INVALID = (1 << 0),
+ PEPPER_OUTPUT_MODE_CURRENT = (1 << 1),
+ PEPPER_OUTPUT_MODE_PREFERRED = (1 << 2),
+};
+
typedef enum pepper_object_type
{
PEPPER_OBJECT_COMPOSITOR,
PEPPER_API pepper_view_t *
pepper_compositor_pick_view(pepper_compositor_t *compositor, int32_t x, int32_t y);
+/* Output. */
PEPPER_API void
pepper_output_destroy(pepper_output_t *output);
PEPPER_API int
pepper_output_get_mode_count(pepper_output_t *output);
-PEPPER_API const pepper_output_mode_t *
-pepper_output_get_mode(pepper_output_t *output, int index);
+PEPPER_API void
+pepper_output_get_mode(pepper_output_t *output, int index, pepper_output_mode_t *mode);
PEPPER_API pepper_bool_t
pepper_output_set_mode(pepper_output_t *output, const pepper_output_mode_t *mode);