char *ret = pepper_string_alloc(len);
if (ret)
- memcpy(ret, str, (len + 1) * sizeof (char));
+ memcpy(ret, str, (len + 1) * sizeof (char));
return ret;
}
/* compositor interface */
static void
compositor_create_surface(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id)
+ struct wl_resource *resource,
+ uint32_t id)
{
pepper_compositor_t *compositor = wl_resource_get_user_data(resource);
pepper_surface_t *surface;
surface = (pepper_surface_t *)pepper_calloc(1, sizeof(pepper_surface_t));
if (!surface)
{
- PEPPER_ERROR("%s Surface memory allocation failed\n", __FUNCTION__);
- wl_resource_post_no_memory(resource);
+ PEPPER_ERROR("%s Surface memory allocation failed\n", __FUNCTION__);
+ wl_resource_post_no_memory(resource);
}
surface->resource = wl_resource_create(client, &wl_surface_interface,
- wl_resource_get_version(resource), id);
+ wl_resource_get_version(resource), id);
if (!surface->resource)
{
- PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
- pepper_free(surface);
- wl_resource_post_no_memory(resource);
- return ;
+ PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
+ pepper_free(surface);
+ wl_resource_post_no_memory(resource);
+ return ;
}
wl_resource_set_implementation(surface->resource, &surface_implementation, surface, NULL);
static void
compositor_create_region(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id)
+ struct wl_resource *resource,
+ uint32_t id)
{
PEPPER_TRACE("%s\n", __FUNCTION__);
}
static void
bind_compositor(struct wl_client *client,
- void *data,
- uint32_t version,
- uint32_t id)
+ void *data,
+ uint32_t version,
+ uint32_t id)
{
pepper_compositor_t *compositor = (pepper_compositor_t *)data;
struct wl_resource *resource;
resource = wl_resource_create(client, &wl_compositor_interface, version, id);
if (!resource)
{
- PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
+ PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
- wl_client_post_no_memory(client);
- return;
+ wl_client_post_no_memory(client);
+ return;
}
PEPPER_TRACE("%s wl_resource_create success\n", __FUNCTION__);
pepper_compositor_t *
pepper_compositor_create(const char *socket_name,
- const char *backend_name,
- const char *input_name,
- const char *shell_name,
- const char *renderer_name)
+ const char *backend_name,
+ const char *input_name,
+ const char *shell_name,
+ const char *renderer_name)
{
- pepper_compositor_t *compositor = NULL;
+ pepper_compositor_t *compositor = NULL;
compositor = (pepper_compositor_t *)pepper_calloc(1, sizeof (pepper_compositor_t));
if (!compositor)
- goto error;
+ goto error;
compositor->display = wl_display_create();
if (!compositor->display)
{
- PEPPER_ERROR("Failed to create wayland display object.\n");
- goto error;
+ PEPPER_ERROR("Failed to create wayland display object.\n");
+ goto error;
}
if (wl_display_add_socket(compositor->display, socket_name) != 0)
{
- PEPPER_ERROR("Failed to add socket display = %p socket_name = %s\n",
- compositor->display, socket_name);
- goto error;
+ PEPPER_ERROR("Failed to add socket display = %p socket_name = %s\n",
+ compositor->display, socket_name);
+ goto error;
}
wl_global_create(compositor->display, &wl_compositor_interface, 3, compositor,
- bind_compositor);
+ bind_compositor);
/* TODO: Load modules. */
wl_global_create(compositor->display, &wl_shell_interface, 1, compositor,
- bind_shell);
+ bind_shell);
wl_display_init_shm(compositor->display);
error:
if (compositor)
- pepper_compositor_destroy(compositor);
+ pepper_compositor_destroy(compositor);
return NULL;
}
pepper_compositor_destroy(pepper_compositor_t *compositor)
{
if (compositor->display)
- wl_display_destroy(compositor->display);
+ wl_display_destroy(compositor->display);
pepper_free(compositor);
}
pepper_output_t *
pepper_compositor_add_output(pepper_compositor_t *compositor,
- pepper_output_info_t *info)
+ pepper_output_info_t *info)
{
pepper_output_t *output = NULL;
output = (pepper_output_t *)pepper_calloc(1, sizeof (pepper_output_t));
if (!output)
- return NULL;
+ return NULL;
/* TODO: Backend-side output initialization. */
{
if (compositor)
{
- wl_display_flush_clients(compositor->display);
- wl_event_loop_dispatch(wl_display_get_event_loop(compositor->display), -1);
+ wl_display_flush_clients(compositor->display);
+ wl_event_loop_dispatch(wl_display_get_event_loop(compositor->display), -1);
}
}
pepper_output_get_geometry(pepper_output_t *output, int *x, int *y, int *w, int *h)
{
if (x)
- *x = output->x;
+ *x = output->x;
if (y)
- *y = output->y;
+ *y = output->y;
if (w)
- *w = output->w;
+ *w = output->w;
if (h)
- *h = output->h;
+ *h = output->h;
}
pepper_compositor_t *
#include <stdint.h>
-#define PEPPER_FALSE 0
-#define PEPPER_TRUE 1
+#define PEPPER_FALSE 0
+#define PEPPER_TRUE 1
-typedef uint32_t pepper_bool_t;
+typedef uint32_t pepper_bool_t;
typedef struct pepper_compositor pepper_compositor_t;
-typedef struct pepper_output pepper_output_t;
+typedef struct pepper_output pepper_output_t;
typedef struct pepper_output_info pepper_output_info_t;
-typedef struct pepper_client pepper_client_t;
-typedef struct pepper_surface pepper_surface_t;
+typedef struct pepper_client pepper_client_t;
+typedef struct pepper_surface pepper_surface_t;
typedef struct pepper_shell_surface pepper_shell_surface_t;
struct pepper_output_info
/* Compositor functions. */
pepper_compositor_t *
pepper_compositor_create(const char *socket_name,
- const char *backend_name,
- const char *input_name,
- const char *shell_name,
- const char *renderer_name);
+ const char *backend_name,
+ const char *input_name,
+ const char *shell_name,
+ const char *renderer_name);
void
pepper_compositor_destroy(pepper_compositor_t *compositor);
pepper_output_t *
pepper_compositor_add_output(pepper_compositor_t *compositor,
- pepper_output_info_t *info);
+ pepper_output_info_t *info);
int
pepper_compositor_get_output_count(pepper_compositor_t *compositor);
struct pepper_compositor
{
- char *socket_name;
- struct wl_display *display;
+ char *socket_name;
+ struct wl_display *display;
};
struct pepper_output
{
- pepper_compositor_t *compositor;
+ pepper_compositor_t *compositor;
- int x;
+ int x;
int y;
int w;
int h;
int
main(int argc, char **argv)
{
- pepper_compositor_t *compositor;
+ pepper_compositor_t *compositor;
compositor = pepper_compositor_create("wayland-0", NULL, NULL, NULL, NULL);
while (1)
{
- pepper_compositor_frame(compositor);
+ pepper_compositor_frame(compositor);
}
pepper_compositor_destroy(compositor);
/* shell surface interface */
static void
shell_surface_pong(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t serial)
+ struct wl_resource *resource,
+ uint32_t serial)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_move(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *seat,
- uint32_t serial)
+ struct wl_resource *resource,
+ struct wl_resource *seat,
+ uint32_t serial)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_resize(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *seat,
- uint32_t serial,
- uint32_t edges)
+ struct wl_resource *resource,
+ struct wl_resource *seat,
+ uint32_t serial,
+ uint32_t edges)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_set_toplevel(struct wl_client *client,
- struct wl_resource *resource)
+ struct wl_resource *resource)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_set_transient(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *parent_resource,
- int x,
- int y,
- uint32_t flags)
+ struct wl_resource *resource,
+ struct wl_resource *parent_resource,
+ int x,
+ int y,
+ uint32_t flags)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_set_fullscreen(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t method,
- uint32_t framerate,
- struct wl_resource *output_resource)
+ struct wl_resource *resource,
+ uint32_t method,
+ uint32_t framerate,
+ struct wl_resource *output_resource)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_set_popup(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *seat_resource,
- uint32_t serial,
- struct wl_resource *parent_resource,
- int32_t x,
- int32_t y,
- uint32_t flags)
+ struct wl_resource *resource,
+ struct wl_resource *seat_resource,
+ uint32_t serial,
+ struct wl_resource *parent_resource,
+ int32_t x,
+ int32_t y,
+ uint32_t flags)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_set_title(struct wl_client *client,
- struct wl_resource *resource,
- const char *title)
+ struct wl_resource *resource,
+ const char *title)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
static void
shell_surface_set_class(struct wl_client *client,
- struct wl_resource *resource,
- const char *class)
+ struct wl_resource *resource,
+ const char *class)
{
pepper_shell_surface_t *shsurface = wl_resource_get_user_data(resource);
/* shell interface */
static void
shell_get_shell_surface(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id,
- struct wl_resource *surface_resource)
+ struct wl_resource *resource,
+ uint32_t id,
+ struct wl_resource *surface_resource)
{
pepper_compositor_t *compositor = wl_resource_get_user_data(resource);
pepper_surface_t *surface = wl_resource_get_user_data(surface_resource);
if (!shsurface)
{
- PEPPER_ERROR("%s Shell surface memory allocation failed\n", __FUNCTION__);
- wl_client_post_no_memory(client);
- return ;
+ PEPPER_ERROR("%s Shell surface memory allocation failed\n", __FUNCTION__);
+ wl_client_post_no_memory(client);
+ return ;
}
shsurface->resource = wl_resource_create(client, &wl_shell_surface_interface,
- wl_resource_get_version(resource), id);
+ wl_resource_get_version(resource), id);
if (!shsurface->resource)
{
- PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
- pepper_free(shsurface);
- wl_client_post_no_memory(client);
- return ;
+ PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
+ pepper_free(shsurface);
+ wl_client_post_no_memory(client);
+ return ;
}
wl_resource_set_implementation(shsurface->resource, &pepper_shell_surface_implementation,
- shsurface, NULL);
+ shsurface, NULL);
}
resource = wl_resource_create(client, &wl_shell_interface, version, id);
if (!resource)
{
- PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
+ PEPPER_ERROR("%s wl_resource_create failed\n", __FUNCTION__);
- wl_client_post_no_memory(client);
- return;
+ wl_client_post_no_memory(client);
+ return;
}
wl_resource_set_implementation(resource, &shell_implementation, compositor, NULL);
#include "pepper_internal.h"
-
void *
pepper_surface_get_buffer(pepper_surface_t *surface)
{
return surface->buffer;
}
-
-
/* surface interface */
static void
surface_destroy(struct wl_client *client, struct wl_resource *resource)
static void
surface_attach(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *buffer,
- int32_t x,
- int32_t y)
+ struct wl_resource *resource,
+ struct wl_resource *buffer,
+ int32_t x,
+ int32_t y)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
static void
surface_damage(struct wl_client *client,
- struct wl_resource *resource,
- int32_t x,
- int32_t y,
- int32_t width,
- int32_t height)
+ struct wl_resource *resource,
+ int32_t x,
+ int32_t y,
+ int32_t width,
+ int32_t height)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
PEPPER_TRACE("%s\n", __FUNCTION__);
}
-
static void
surface_frame(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t callback)
+ struct wl_resource *resource,
+ uint32_t callback)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
static void
surface_set_opaque_region(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *region)
+ struct wl_resource *resource,
+ struct wl_resource *region)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
static void
surface_set_input_region(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *region)
+ struct wl_resource *resource,
+ struct wl_resource *region)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
PEPPER_TRACE("%s\n", __FUNCTION__);
}
-
static void
surface_commit(struct wl_client *client, struct wl_resource *resource)
{
static void
surface_set_buffer_transform(struct wl_client *client,
- struct wl_resource *resource,
- int transform)
+ struct wl_resource *resource,
+ int transform)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
static void
surface_set_buffer_scale(struct wl_client *client,
- struct wl_resource *resource,
- int32_t scale)
+ struct wl_resource *resource,
+ int32_t scale)
{
pepper_surface_t *surface = wl_resource_get_user_data(resource);
surface_set_buffer_transform,
surface_set_buffer_scale
};
-
-
-