shell: Make input_panel just a regular wl_surface

dev
Kristian Høgsberg 13 years ago
parent 1a73a6335d
commit 0636ac307e
  1. 5
      clients/keyboard.c
  2. 2
      protocol/desktop-shell.xml
  3. 151
      src/shell.c

@ -156,11 +156,10 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
memset(keyboard, 0, sizeof *keyboard); memset(keyboard, 0, sizeof *keyboard);
keyboard->keyboard = virtual_keyboard; keyboard->keyboard = virtual_keyboard;
keyboard->window = window_create(virtual_keyboard->display); keyboard->window = window_create_custom(virtual_keyboard->display);
keyboard->widget = window_add_widget(keyboard->window, keyboard); keyboard->widget = window_add_widget(keyboard->window, keyboard);
window_set_title(keyboard->window, "Virtual keyboard"); window_set_title(keyboard->window, "Virtual keyboard");
window_set_custom(keyboard->window);
window_set_user_data(keyboard->window, keyboard); window_set_user_data(keyboard->window, keyboard);
keyboard->cx = 40; keyboard->cx = 40;
@ -173,7 +172,7 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
window_schedule_resize(keyboard->window, keyboard->cx * 10, keyboard->cy * 5); window_schedule_resize(keyboard->window, keyboard->cx * 10, keyboard->cy * 5);
input_panel_set_surface(virtual_keyboard->input_panel, input_panel_set_surface(virtual_keyboard->input_panel,
window_get_wl_shell_surface(keyboard->window), window_get_wl_surface(keyboard->window),
output_get_wl_output(output)); output_get_wl_output(output));
} }

@ -74,7 +74,7 @@
A keybaord surface is only shown, when a text model is active A keybaord surface is only shown, when a text model is active
</description> </description>
<arg name="surface" type="object" interface="wl_shell_surface"/> <arg name="surface" type="object" interface="wl_surface"/>
<arg name="output" type="object" interface="wl_output"/> <arg name="output" type="object" interface="wl_output"/>
</request> </request>

@ -128,9 +128,6 @@ struct desktop_shell {
enum shell_surface_type { enum shell_surface_type {
SHELL_SURFACE_NONE, SHELL_SURFACE_NONE,
SHELL_SURFACE_INPUT_PANEL,
SHELL_SURFACE_TOPLEVEL, SHELL_SURFACE_TOPLEVEL,
SHELL_SURFACE_TRANSIENT, SHELL_SURFACE_TRANSIENT,
SHELL_SURFACE_FULLSCREEN, SHELL_SURFACE_FULLSCREEN,
@ -1221,10 +1218,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_INPUT_PANEL:
wl_list_remove(&surface->link);
wl_list_init(&surface->link);
break;
case SHELL_SURFACE_NONE: case SHELL_SURFACE_NONE:
case SHELL_SURFACE_TOPLEVEL: case SHELL_SURFACE_TOPLEVEL:
case SHELL_SURFACE_TRANSIENT: case SHELL_SURFACE_TRANSIENT:
@ -1844,33 +1837,6 @@ terminate_screensaver(struct desktop_shell *shell)
kill(shell->screensaver.process.pid, SIGTERM); kill(shell->screensaver.process.pid, SIGTERM);
} }
static void
show_input_panel(struct desktop_shell *shell, struct shell_surface *surface)
{
if (weston_surface_is_mapped(surface->surface))
return;
wl_list_remove(&surface->surface->layer_link);
wl_list_insert(&shell->panel_layer.surface_list, &surface->surface->layer_link);
surface->surface->output = surface->output;
weston_surface_damage(surface->surface);
weston_slide_run(surface->surface,
surface->surface->geometry.height, 0,
NULL, NULL);
}
static void
hide_input_panel(struct desktop_shell *shell, struct shell_surface *surface)
{
weston_surface_damage_below(surface->surface);
wl_list_remove(&surface->surface->layer_link);
wl_list_init(&surface->surface->layer_link);
surface->surface->output = NULL;
weston_compositor_schedule_repaint(surface->surface->compositor);
}
static void static void
configure_static_surface(struct weston_surface *es, struct weston_layer *layer) configure_static_surface(struct weston_surface *es, struct weston_layer *layer)
{ {
@ -2084,17 +2050,9 @@ move_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
return; return;
shsurf = get_shell_surface(surface); shsurf = get_shell_surface(surface);
if (shsurf == NULL) if (shsurf == NULL || shsurf->type == SHELL_SURFACE_FULLSCREEN)
return; return;
switch (shsurf->type) {
case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_INPUT_PANEL:
return;
default:
break;
}
surface_move(shsurf, (struct weston_seat *) seat); surface_move(shsurf, (struct weston_seat *) seat);
} }
@ -2111,17 +2069,9 @@ resize_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
return; return;
shsurf = get_shell_surface(surface); shsurf = get_shell_surface(surface);
if (!shsurf) if (!shsurf || shsurf->type == SHELL_SURFACE_FULLSCREEN)
return; return;
switch (shsurf->type) {
case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_INPUT_PANEL:
return;
default:
break;
}
weston_surface_from_global(surface, weston_surface_from_global(surface,
wl_fixed_to_int(seat->pointer->grab_x), wl_fixed_to_int(seat->pointer->grab_x),
wl_fixed_to_int(seat->pointer->grab_y), wl_fixed_to_int(seat->pointer->grab_y),
@ -2345,17 +2295,9 @@ rotate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
return; return;
surface = get_shell_surface(base_surface); surface = get_shell_surface(base_surface);
if (!surface) if (!surface || surface->type == SHELL_SURFACE_FULLSCREEN)
return; return;
switch (surface->type) {
case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_INPUT_PANEL:
return;
default:
break;
}
rotate = malloc(sizeof *rotate); rotate = malloc(sizeof *rotate);
if (!rotate) if (!rotate)
return; return;
@ -2419,9 +2361,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_INPUT_PANEL:
break;
case SHELL_SURFACE_FULLSCREEN: case SHELL_SURFACE_FULLSCREEN:
/* should on top of panels */ /* should on top of panels */
shell_stack_fullscreen(get_shell_surface(es)); shell_stack_fullscreen(get_shell_surface(es));
@ -2468,13 +2407,8 @@ click_to_activate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
if (is_black_surface(focus, &upper)) if (is_black_surface(focus, &upper))
focus = upper; focus = upper;
switch (get_shell_surface_type(focus)) { if (get_shell_surface_type(focus) == SHELL_SURFACE_NONE)
case SHELL_SURFACE_INPUT_PANEL: return;
case SHELL_SURFACE_NONE:
return;
default:
break;
}
if (seat->pointer->grab == &seat->pointer->default_grab) if (seat->pointer->grab == &seat->pointer->default_grab)
activate(shell, focus, ws); activate(shell, focus, ws);
@ -2547,23 +2481,37 @@ show_input_panels(struct wl_listener *listener, void *data)
{ {
struct desktop_shell *shell = struct desktop_shell *shell =
container_of(listener, struct desktop_shell, show_input_panel_listener); container_of(listener, struct desktop_shell, show_input_panel_listener);
struct shell_surface *priv; struct weston_surface *surface, *next;
wl_list_for_each(priv, &shell->input_panel.surfaces, link) { wl_list_for_each_safe(surface, next,
show_input_panel(shell, priv); &shell->input_panel.surfaces, layer_link) {
wl_list_remove(&surface->layer_link);
wl_list_insert(&shell->panel_layer.surface_list,
&surface->layer_link);
weston_surface_assign_output(surface);
weston_surface_damage(surface);
weston_slide_run(surface,
surface->geometry.height, 0, NULL, NULL);
} }
} }
static void
input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy);
static void static void
hide_input_panels(struct wl_listener *listener, void *data) hide_input_panels(struct wl_listener *listener, void *data)
{ {
struct desktop_shell *shell = struct desktop_shell *shell =
container_of(listener, struct desktop_shell, hide_input_panel_listener); container_of(listener, struct desktop_shell, hide_input_panel_listener);
struct shell_surface *priv; struct weston_surface *surface, *next;
wl_list_for_each(priv, &shell->input_panel.surfaces, link) { wl_list_for_each_safe(surface, next,
hide_input_panel(shell, priv); &shell->panel_layer.surface_list, layer_link)
} if (surface->configure == input_panel_configure) {
weston_surface_unmap(surface);
wl_list_insert(&shell->input_panel.surfaces,
&surface->layer_link);
}
} }
static void static void
@ -2578,17 +2526,6 @@ center_on_output(struct weston_surface *surface, struct weston_output *output)
surface->buffer->height); surface->buffer->height);
} }
static void
bottom_center_on_output(struct weston_surface *surface, struct weston_output *output)
{
struct weston_mode *mode = output->current;
GLfloat x = (mode->width - surface->geometry.width) / 2;
GLfloat y = mode->height - surface->geometry.height;
weston_surface_set_position(surface, output->x + x, output->y + y);
}
static void static void
map(struct desktop_shell *shell, struct weston_surface *surface, map(struct desktop_shell *shell, struct weston_surface *surface,
int32_t width, int32_t height, int32_t sx, int32_t sy) int32_t width, int32_t height, int32_t sx, int32_t sy)
@ -2620,11 +2557,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
weston_surface_set_position(surface, surface->output->x, weston_surface_set_position(surface, surface->output->x,
surface->output->y + panel_height); surface->output->y + panel_height);
break; break;
case SHELL_SURFACE_INPUT_PANEL:
bottom_center_on_output(surface, get_default_output(compositor));
/* Don't map the input panel here, wait for
* show_input_panels signal. */
return;
case SHELL_SURFACE_POPUP: case SHELL_SURFACE_POPUP:
shell_map_popup(shsurf); shell_map_popup(shsurf);
case SHELL_SURFACE_NONE: case SHELL_SURFACE_NONE:
@ -2645,7 +2577,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
break; break;
case SHELL_SURFACE_FULLSCREEN: case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_NONE: case SHELL_SURFACE_NONE:
case SHELL_SURFACE_INPUT_PANEL:
break; break;
default: default:
ws = get_current_workspace(shell); ws = get_current_workspace(shell);
@ -2922,21 +2853,37 @@ bind_screensaver(struct wl_client *client,
wl_resource_destroy(resource); wl_resource_destroy(resource);
} }
static void
input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
{
struct weston_mode *mode = surface->output->current;
GLfloat x = (mode->width - surface->buffer->width) / 2;
GLfloat y = mode->height - surface->buffer->height;
/* Don't map the input panel here, wait for
* show_input_panels signal. */
weston_surface_configure(surface,
surface->output->x + x,
surface->output->y + y,
surface->buffer->width,
surface->buffer->height);
}
static void static void
input_panel_set_surface(struct wl_client *client, input_panel_set_surface(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *resource,
struct wl_resource *shell_surface_resource, struct wl_resource *surface_resource,
struct wl_resource *output_resource) struct wl_resource *output_resource)
{ {
struct desktop_shell *shell = resource->data; struct desktop_shell *shell = resource->data;
struct shell_surface *surface = shell_surface_resource->data; struct weston_surface *surface = surface_resource->data;
struct weston_output *output = output_resource->data; struct weston_output *output = output_resource->data;
surface->next_type = SHELL_SURFACE_INPUT_PANEL; surface->configure = input_panel_configure;
surface->private = shell;
surface->fullscreen_output = output;
surface->output = output; surface->output = output;
wl_list_insert(shell->input_panel.surfaces.prev, &surface->link); wl_list_insert(shell->input_panel.surfaces.prev, &surface->layer_link);
} }
static const struct input_panel_interface input_panel_implementation = { static const struct input_panel_interface input_panel_implementation = {

Loading…
Cancel
Save