shell: Make panel just a wl_surface too

dev
Kristian Høgsberg 13 years ago
parent 962342cb8e
commit af7b1ffaf4
  1. 9
      clients/desktop-shell.c
  2. 2
      protocol/desktop-shell.xml
  3. 2
      src/compositor.c
  4. 3
      src/compositor.h
  5. 93
      src/shell.c

@ -446,12 +446,11 @@ panel_create(struct display *display)
memset(panel, 0, sizeof *panel); memset(panel, 0, sizeof *panel);
panel->base.configure = panel_configure; panel->base.configure = panel_configure;
panel->window = window_create(display); panel->window = window_create_custom(display);
panel->widget = window_add_widget(panel->window, panel); panel->widget = window_add_widget(panel->window, panel);
wl_list_init(&panel->launcher_list); wl_list_init(&panel->launcher_list);
window_set_title(panel->window, "panel"); window_set_title(panel->window, "panel");
window_set_custom(panel->window);
window_set_user_data(panel->window, panel); window_set_user_data(panel->window, panel);
widget_set_redraw_handler(panel->widget, panel_redraw_handler); widget_set_redraw_handler(panel->widget, panel_redraw_handler);
@ -876,12 +875,12 @@ int main(int argc, char *argv[])
global_handler, &desktop); global_handler, &desktop);
wl_list_for_each(output, &desktop.outputs, link) { wl_list_for_each(output, &desktop.outputs, link) {
struct wl_shell_surface *shsurf;
struct wl_surface *surface; struct wl_surface *surface;
output->panel = panel_create(desktop.display); output->panel = panel_create(desktop.display);
shsurf = window_get_wl_shell_surface(output->panel->window); surface = window_get_wl_surface(output->panel->window);
desktop_shell_set_panel(desktop.shell, output->output, shsurf); desktop_shell_set_panel(desktop.shell,
output->output, surface);
output->background = background_create(&desktop); output->background = background_create(&desktop);
surface = window_get_wl_surface(output->background->window); surface = window_get_wl_surface(output->background->window);

@ -14,7 +14,7 @@
<request name="set_panel"> <request name="set_panel">
<arg name="output" type="object" interface="wl_output"/> <arg name="output" type="object" interface="wl_output"/>
<arg name="surface" type="object" interface="wl_shell_surface"/> <arg name="surface" type="object" interface="wl_surface"/>
</request> </request>
<request name="set_lock_surface"> <request name="set_lock_surface">

@ -634,7 +634,7 @@ weston_compositor_repick(struct weston_compositor *compositor)
weston_device_repick(&seat->seat); weston_device_repick(&seat->seat);
} }
static void WL_EXPORT void
weston_surface_unmap(struct weston_surface *surface) weston_surface_unmap(struct weston_surface *surface)
{ {
struct weston_seat *seat; struct weston_seat *seat;

@ -636,6 +636,9 @@ weston_surface_damage(struct weston_surface *surface);
void void
weston_surface_damage_below(struct weston_surface *surface); weston_surface_damage_below(struct weston_surface *surface);
void
weston_surface_unmap(struct weston_surface *surface);
void void
weston_buffer_post_release(struct wl_buffer *buffer); weston_buffer_post_release(struct wl_buffer *buffer);

@ -95,8 +95,6 @@ struct desktop_shell {
struct shell_surface *lock_surface; struct shell_surface *lock_surface;
struct wl_listener lock_surface_listener; struct wl_listener lock_surface_listener;
struct wl_list panels;
struct { struct {
struct wl_array array; struct wl_array array;
unsigned int current; unsigned int current;
@ -131,7 +129,6 @@ struct desktop_shell {
enum shell_surface_type { enum shell_surface_type {
SHELL_SURFACE_NONE, SHELL_SURFACE_NONE,
SHELL_SURFACE_PANEL,
SHELL_SURFACE_LOCK, SHELL_SURFACE_LOCK,
SHELL_SURFACE_SCREENSAVER, SHELL_SURFACE_SCREENSAVER,
SHELL_SURFACE_INPUT_PANEL, SHELL_SURFACE_INPUT_PANEL,
@ -1226,7 +1223,6 @@ reset_shell_surface_type(struct shell_surface *surface)
surface->saved_x, surface->saved_x,
surface->saved_y); surface->saved_y);
break; break;
case SHELL_SURFACE_PANEL:
case SHELL_SURFACE_INPUT_PANEL: case SHELL_SURFACE_INPUT_PANEL:
wl_list_remove(&surface->link); wl_list_remove(&surface->link);
wl_list_init(&surface->link); wl_list_init(&surface->link);
@ -1254,8 +1250,6 @@ set_surface_type(struct shell_surface *shsurf)
struct weston_surface *surface = shsurf->surface; struct weston_surface *surface = shsurf->surface;
struct shell_surface *pshsurf = shsurf->parent; struct shell_surface *pshsurf = shsurf->parent;
struct weston_surface *pes; struct weston_surface *pes;
struct shell_surface *priv;
struct desktop_shell *shell = shsurf->shell;
reset_shell_surface_type(shsurf); reset_shell_surface_type(shsurf);
@ -1291,22 +1285,6 @@ set_surface_type(struct shell_surface *shsurf)
} }
break; break;
case SHELL_SURFACE_PANEL:
wl_list_for_each(priv, &shell->panels, link) {
if (priv->output == shsurf->output) {
priv->surface->output = NULL;
wl_list_remove(&priv->surface->layer_link);
wl_list_remove(&priv->link);
break;
}
}
wl_list_insert(&shell->panels, &shsurf->link);
weston_surface_set_position(surface, shsurf->output->x,
shsurf->output->y);
break;
default: default:
break; break;
} }
@ -1361,18 +1339,19 @@ static int
get_output_panel_height(struct desktop_shell *shell, get_output_panel_height(struct desktop_shell *shell,
struct weston_output *output) struct weston_output *output)
{ {
struct shell_surface *priv; struct weston_surface *surface;
int panel_height = 0; int panel_height = 0;
if (!output) if (!output)
return 0; return 0;
wl_list_for_each(priv, &shell->panels, link) { wl_list_for_each(surface, &shell->panel_layer.surface_list, link) {
if (priv->output == output) { if (surface->output == output) {
panel_height = priv->surface->geometry.height; panel_height = surface->geometry.height;
break; break;
} }
} }
return panel_height; return panel_height;
} }
@ -1925,17 +1904,14 @@ hide_input_panel(struct desktop_shell *shell, struct shell_surface *surface)
} }
static void static void
background_configure(struct weston_surface *es, int32_t sx, int32_t sy) configure_static_surface(struct weston_surface *es, struct weston_layer *layer)
{ {
struct desktop_shell *shell = es->private; struct weston_surface *s, *next;
struct weston_surface *s;
wl_list_for_each(s, &shell->background_layer.surface_list, layer_link) { wl_list_for_each_safe(s, next, &layer->surface_list, layer_link) {
if (s->output == es->output) { if (s->output == es->output && s != es) {
s->output = NULL; weston_surface_unmap(s);
wl_list_remove(&s->layer_link);
s->configure = NULL; s->configure = NULL;
break;
} }
} }
@ -1943,12 +1919,19 @@ background_configure(struct weston_surface *es, int32_t sx, int32_t sy)
es->buffer->width, es->buffer->height); es->buffer->width, es->buffer->height);
if (wl_list_empty(&es->layer_link)) { if (wl_list_empty(&es->layer_link)) {
wl_list_insert(&shell->background_layer.surface_list, wl_list_insert(&layer->surface_list, &es->layer_link);
&es->layer_link);
weston_surface_assign_output(es); weston_surface_assign_output(es);
} }
} }
static void
background_configure(struct weston_surface *es, int32_t sx, int32_t sy)
{
struct desktop_shell *shell = es->private;
configure_static_surface(es, &shell->background_layer);
}
static void static void
desktop_shell_set_background(struct wl_client *client, desktop_shell_set_background(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
@ -1974,21 +1957,37 @@ desktop_shell_set_background(struct wl_client *client,
surface->output->current->height); surface->output->current->height);
} }
static void
panel_configure(struct weston_surface *es, int32_t sx, int32_t sy)
{
struct desktop_shell *shell = es->private;
configure_static_surface(es, &shell->panel_layer);
}
static void static void
desktop_shell_set_panel(struct wl_client *client, desktop_shell_set_panel(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
struct wl_resource *output_resource, struct wl_resource *output_resource,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
struct shell_surface *shsurf = surface_resource->data; struct desktop_shell *shell = resource->data;
struct weston_surface *surface = surface_resource->data;
shsurf->next_type = SHELL_SURFACE_PANEL; if (surface->configure) {
shsurf->output = output_resource->data; wl_resource_post_error(surface_resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"surface role already assigned");
return;
}
surface->configure = panel_configure;
surface->private = shell;
surface->output = output_resource->data;
desktop_shell_send_configure(resource, 0, desktop_shell_send_configure(resource, 0,
&shsurf->surface->surface.resource, surface_resource,
shsurf->output->current->width, surface->output->current->width,
shsurf->output->current->height); surface->output->current->height);
} }
static void static void
@ -2105,7 +2104,6 @@ move_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
return; return;
switch (shsurf->type) { switch (shsurf->type) {
case SHELL_SURFACE_PANEL:
case SHELL_SURFACE_FULLSCREEN: case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_SCREENSAVER: case SHELL_SURFACE_SCREENSAVER:
case SHELL_SURFACE_INPUT_PANEL: case SHELL_SURFACE_INPUT_PANEL:
@ -2134,7 +2132,6 @@ resize_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
return; return;
switch (shsurf->type) { switch (shsurf->type) {
case SHELL_SURFACE_PANEL:
case SHELL_SURFACE_FULLSCREEN: case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_SCREENSAVER: case SHELL_SURFACE_SCREENSAVER:
case SHELL_SURFACE_INPUT_PANEL: case SHELL_SURFACE_INPUT_PANEL:
@ -2377,7 +2374,6 @@ rotate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
return; return;
switch (surface->type) { switch (surface->type) {
case SHELL_SURFACE_PANEL:
case SHELL_SURFACE_FULLSCREEN: case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_SCREENSAVER: case SHELL_SURFACE_SCREENSAVER:
case SHELL_SURFACE_INPUT_PANEL: case SHELL_SURFACE_INPUT_PANEL:
@ -2449,7 +2445,6 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
weston_surface_activate(es, seat); weston_surface_activate(es, seat);
switch (get_shell_surface_type(es)) { switch (get_shell_surface_type(es)) {
case SHELL_SURFACE_PANEL:
case SHELL_SURFACE_LOCK: case SHELL_SURFACE_LOCK:
case SHELL_SURFACE_INPUT_PANEL: case SHELL_SURFACE_INPUT_PANEL:
break; break;
@ -2693,11 +2688,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
/* surface stacking order, see also activate() */ /* surface stacking order, see also activate() */
switch (surface_type) { switch (surface_type) {
case SHELL_SURFACE_PANEL:
/* panel always on top, hidden while locked */
wl_list_insert(&shell->panel_layer.surface_list,
&surface->layer_link);
break;
case SHELL_SURFACE_LOCK: case SHELL_SURFACE_LOCK:
/* lock surface always visible, on top */ /* lock surface always visible, on top */
wl_list_insert(&shell->lock_layer.surface_list, wl_list_insert(&shell->lock_layer.surface_list,
@ -3421,7 +3411,6 @@ shell_init(struct weston_compositor *ec)
ec->shell_interface.move = surface_move; ec->shell_interface.move = surface_move;
ec->shell_interface.resize = surface_resize; ec->shell_interface.resize = surface_resize;
wl_list_init(&shell->panels);
wl_list_init(&shell->screensaver.surfaces); wl_list_init(&shell->screensaver.surfaces);
wl_list_init(&shell->input_panel.surfaces); wl_list_init(&shell->input_panel.surfaces);

Loading…
Cancel
Save