Move map requests to shell

dev
Kristian Høgsberg 14 years ago
parent 83eeacb489
commit 7a5c979f4c
  1. 5
      clients/simple-client.c
  2. 6
      clients/window.c
  3. 106
      compositor/compositor.c
  4. 80
      compositor/shell.c

@ -37,6 +37,7 @@ struct display {
struct wl_display *display; struct wl_display *display;
struct wl_visual *premultiplied_argb_visual; struct wl_visual *premultiplied_argb_visual;
struct wl_compositor *compositor; struct wl_compositor *compositor;
struct wl_shell *shell;
struct { struct {
EGLDisplay dpy; EGLDisplay dpy;
EGLContext ctx; EGLContext ctx;
@ -227,7 +228,7 @@ create_surface(struct window *window)
window->native, window->native,
NULL); NULL);
wl_surface_map_toplevel(window->surface); wl_shell_set_toplevel(display->shell, window->surface);
ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface, ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
window->egl_surface, window->display->egl.ctx); window->egl_surface, window->display->egl.ctx);
@ -320,6 +321,8 @@ display_handle_global(struct wl_display *display, uint32_t id,
d->compositor = wl_compositor_create(display, id, 1); d->compositor = wl_compositor_create(display, id, 1);
wl_compositor_add_listener(d->compositor, wl_compositor_add_listener(d->compositor,
&compositor_listener, d); &compositor_listener, d);
} else if (strcmp(interface, "wl_shell") == 0) {
d->shell = wl_shell_create(display, id, 1);
} }
} }

@ -733,11 +733,11 @@ window_attach_surface(struct window *window)
} }
if (window->fullscreen) if (window->fullscreen)
wl_surface_map_fullscreen(window->surface); wl_shell_set_fullscreen(display->shell, window->surface);
else if (!window->parent) else if (!window->parent)
wl_surface_map_toplevel(window->surface); wl_shell_set_toplevel(display->shell, window->surface);
else else
wl_surface_map_transient(window->surface, wl_shell_set_transient(display->shell, window->surface,
window->parent->surface, window->parent->surface,
window->x, window->y, 0); window->x, window->y, 0);

@ -862,119 +862,20 @@ surface_attach(struct wl_client *client,
* damaged by the client. */ * damaged by the client. */
wlsc_surface_damage(es); wlsc_surface_damage(es);
switch (es->map_type) {
case WLSC_SURFACE_MAP_FULLSCREEN:
es->x = (es->fullscreen_output->width - es->width) / 2;
es->y = (es->fullscreen_output->height - es->height) / 2;
break;
default:
es->x += x; es->x += x;
es->y += y; es->y += y;
break;
}
es->width = buffer->width; es->width = buffer->width;
es->height = buffer->height; es->height = buffer->height;
if (x != 0 || y != 0) if (x != 0 || y != 0)
wlsc_surface_assign_output(es); wlsc_surface_assign_output(es);
if (es->visual == NULL)
wl_list_insert(&es->compositor->surface_list, &es->link);
wlsc_buffer_attach(buffer, surface); wlsc_buffer_attach(buffer, surface);
es->compositor->shell->attach(es->compositor->shell, es); es->compositor->shell->attach(es->compositor->shell, es);
} }
static void
surface_map_toplevel(struct wl_client *client,
struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_compositor *ec = es->compositor;
switch (es->map_type) {
case WLSC_SURFACE_MAP_UNMAPPED:
es->x = 10 + random() % 400;
es->y = 10 + random() % 400;
/* assign to first output */
es->output = container_of(ec->output_list.next,
struct wlsc_output, link);
wl_list_insert(&es->compositor->surface_list, &es->link);
break;
case WLSC_SURFACE_MAP_TOPLEVEL:
return;
case WLSC_SURFACE_MAP_FULLSCREEN:
es->fullscreen_output = NULL;
es->x = es->saved_x;
es->y = es->saved_y;
break;
default:
break;
}
wlsc_surface_damage(es);
es->map_type = WLSC_SURFACE_MAP_TOPLEVEL;
}
static void
surface_map_transient(struct wl_client *client,
struct wl_surface *surface, struct wl_surface *parent,
int x, int y, uint32_t flags)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_surface *pes = (struct wlsc_surface *) parent;
switch (es->map_type) {
case WLSC_SURFACE_MAP_UNMAPPED:
wl_list_insert(&es->compositor->surface_list, &es->link);
/* assign to parents output */
es->output = pes->output;
break;
case WLSC_SURFACE_MAP_FULLSCREEN:
es->fullscreen_output = NULL;
break;
default:
break;
}
es->x = pes->x + x;
es->y = pes->y + y;
wlsc_surface_damage(es);
es->map_type = WLSC_SURFACE_MAP_TRANSIENT;
}
static void
surface_map_fullscreen(struct wl_client *client, struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_output *output;
/* FIXME: Fullscreen on first output */
/* FIXME: Handle output going away */
output = container_of(es->compositor->output_list.next,
struct wlsc_output, link);
switch (es->map_type) {
case WLSC_SURFACE_MAP_UNMAPPED:
es->x = 10 + random() % 400;
es->y = 10 + random() % 400;
/* assign to first output */
es->output = output;
wl_list_insert(&es->compositor->surface_list, &es->link);
break;
case WLSC_SURFACE_MAP_FULLSCREEN:
return;
default:
break;
}
es->saved_x = es->x;
es->saved_y = es->y;
es->x = (output->width - es->width) / 2;
es->y = (output->height - es->height) / 2;
es->fullscreen_output = output;
wlsc_surface_damage(es);
es->map_type = WLSC_SURFACE_MAP_FULLSCREEN;
}
static void static void
surface_damage(struct wl_client *client, surface_damage(struct wl_client *client,
struct wl_surface *surface, struct wl_surface *surface,
@ -988,9 +889,6 @@ surface_damage(struct wl_client *client,
const static struct wl_surface_interface surface_interface = { const static struct wl_surface_interface surface_interface = {
surface_destroy, surface_destroy,
surface_attach, surface_attach,
surface_map_toplevel,
surface_map_transient,
surface_map_fullscreen,
surface_damage surface_damage
}; };

@ -239,6 +239,75 @@ shell_resize(struct wl_client *client, struct wl_shell *shell,
wl_input_device_set_pointer_focus(device, NULL, time, 0, 0, 0, 0); wl_input_device_set_pointer_focus(device, NULL, time, 0, 0, 0, 0);
} }
static void
shell_set_toplevel(struct wl_client *client,
struct wl_shell *wl_shell,
struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_compositor *ec = es->compositor;
if (es->map_type == WLSC_SURFACE_MAP_FULLSCREEN) {
es->x = es->saved_x;
es->y = es->saved_y;
} else if (es->map_type == WLSC_SURFACE_MAP_UNMAPPED) {
es->x = 10 + random() % 400;
es->y = 10 + random() % 400;
/* assign to first output */
es->output = container_of(ec->output_list.next,
struct wlsc_output, link);
}
wlsc_surface_damage(es);
es->map_type = WLSC_SURFACE_MAP_TOPLEVEL;
es->fullscreen_output = NULL;
}
static void
shell_set_transient(struct wl_client *client,
struct wl_shell *wl_shell,
struct wl_surface *surface,
struct wl_surface *parent,
int x, int y, uint32_t flags)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_surface *pes = (struct wlsc_surface *) parent;
/* assign to parents output */
es->output = pes->output;
es->x = pes->x + x;
es->y = pes->y + y;
wlsc_surface_damage(es);
es->map_type = WLSC_SURFACE_MAP_TRANSIENT;
}
static void
shell_set_fullscreen(struct wl_client *client,
struct wl_shell *wl_shell,
struct wl_surface *surface)
{
struct wlsc_surface *es = (struct wlsc_surface *) surface;
struct wlsc_output *output;
/* FIXME: Fullscreen on first output */
/* FIXME: Handle output going away */
output = container_of(es->compositor->output_list.next,
struct wlsc_output, link);
es->output = output;
es->saved_x = es->x;
es->saved_y = es->y;
es->x = (output->width - es->width) / 2;
es->y = (output->height - es->height) / 2;
es->fullscreen_output = output;
wlsc_surface_damage(es);
es->map_type = WLSC_SURFACE_MAP_FULLSCREEN;
}
static void static void
destroy_drag(struct wl_resource *resource, struct wl_client *client) destroy_drag(struct wl_resource *resource, struct wl_client *client)
{ {
@ -676,7 +745,10 @@ const static struct wl_shell_interface shell_interface = {
shell_move, shell_move,
shell_resize, shell_resize,
shell_create_drag, shell_create_drag,
shell_create_selection shell_create_selection,
shell_set_toplevel,
shell_set_transient,
shell_set_fullscreen
}; };
static void static void
@ -732,8 +804,12 @@ lock(struct wlsc_shell *shell)
} }
static void static void
attach(struct wlsc_shell *shell, struct wlsc_surface *surface) attach(struct wlsc_shell *shell, struct wlsc_surface *es)
{ {
if (es->map_type == WLSC_SURFACE_MAP_FULLSCREEN) {
es->x = (es->fullscreen_output->width - es->width) / 2;
es->y = (es->fullscreen_output->height - es->height) / 2;
}
} }
int int

Loading…
Cancel
Save