text: Add output argument to set_toplevel

Allow to specify an output for a toplevel  input panel surface.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
This commit is contained in:
Jan Arne Petersen 2013-04-18 16:47:29 +02:00 committed by Kristian Høgsberg
parent 14da96bf81
commit 7cd29e199a
3 changed files with 27 additions and 28 deletions

View File

@ -39,6 +39,7 @@ struct virtual_keyboard {
struct input_method *input_method;
struct input_method_context *context;
struct display *display;
struct output *output;
char *preedit_string;
uint32_t preedit_style;
struct {
@ -768,7 +769,7 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
struct keyboard *keyboard;
const struct layout *layout;
struct input_panel_surface *ips;
layout = get_current_layout(virtual_keyboard);
keyboard = malloc(sizeof *keyboard);
@ -795,27 +796,18 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
ips = input_panel_get_input_panel_surface(virtual_keyboard->input_panel,
window_get_wl_surface(keyboard->window));
input_panel_surface_set_toplevel(ips, INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
}
input_panel_surface_set_toplevel(ips,
output_get_wl_output(output),
INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
static void
handle_output_configure(struct output *output, void *data)
{
struct virtual_keyboard *virtual_keyboard = data;
/* skip existing outputs */
if (output_get_user_data(output))
return;
output_set_user_data(output, virtual_keyboard);
keyboard_create(output, virtual_keyboard);
fprintf(stderr, "%s, %p\n", __FUNCTION__, output_get_wl_output(output));
}
int
main(int argc, char *argv[])
{
struct virtual_keyboard virtual_keyboard;
struct output *output;
memset(&virtual_keyboard, 0, sizeof virtual_keyboard);
@ -827,7 +819,9 @@ main(int argc, char *argv[])
display_set_user_data(virtual_keyboard.display, &virtual_keyboard);
display_set_global_handler(virtual_keyboard.display, global_handler);
display_set_output_configure_handler(virtual_keyboard.display, handle_output_configure);
output = display_get_output(virtual_keyboard.display);
keyboard_create(output, &virtual_keyboard);
display_run(virtual_keyboard.display);

View File

@ -208,6 +208,7 @@
<description summary="set the surface type as a keyboard">
A keybaord surface is only shown, when a text model is active
</description>
<arg name="output" type="object" interface="wl_output"/>
<arg name="position" type="uint"/>
</request>

View File

@ -79,6 +79,7 @@ struct input_panel_surface {
struct weston_surface *surface;
struct wl_listener surface_destroy_listener;
struct weston_output *output;
uint32_t panel;
};
@ -3056,9 +3057,8 @@ show_input_panels(struct wl_listener *listener, void *data)
wl_list_for_each_safe(surface, next,
&shell->input_panel.surfaces, link) {
ws = surface->surface;
if (!weston_surface_is_mapped(ws)) {
if (!ws->buffer_ref.buffer)
continue;
}
wl_list_insert(&shell->input_panel_layer.surface_list,
&ws->layer_link);
weston_surface_geometry_dirty(ws);
@ -3526,31 +3526,29 @@ input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, in
if (!shell->showing_input_panels)
return;
wl_list_insert(&shell->input_panel_layer.surface_list,
&surface->layer_link);
weston_surface_geometry_dirty(surface);
weston_surface_update_transform(surface);
show_surface = 1;
}
mode = surface->output->current;
fprintf(stderr, "%s panel: %d, output: %p\n", __FUNCTION__, ip_surface->panel, ip_surface->output);
if (ip_surface->panel) {
x = shell->text_input.surface->geometry.x + shell->text_input.cursor_rectangle.x2;
y = shell->text_input.surface->geometry.y + shell->text_input.cursor_rectangle.y2;
} else {
x = surface->output->x + (mode->width - width) / 2;
y = surface->output->y + mode->height - height;
}
mode = ip_surface->output->current;
/* Don't map the input panel here, wait for
* show_input_panels signal. */
x = ip_surface->output->x + (mode->width - width) / 2;
y = ip_surface->output->y + mode->height - height;
}
weston_surface_configure(surface,
x, y,
width, height);
if (show_surface) {
wl_list_insert(&shell->input_panel_layer.surface_list,
&surface->layer_link);
weston_surface_update_transform(surface);
weston_surface_damage(surface);
weston_slide_run(surface, surface->geometry.height, 0, NULL, NULL);
}
@ -3622,6 +3620,7 @@ create_input_panel_surface(struct desktop_shell *shell,
static void
input_panel_surface_set_toplevel(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output_resource,
uint32_t position)
{
struct input_panel_surface *input_panel_surface = resource->data;
@ -3630,7 +3629,12 @@ input_panel_surface_set_toplevel(struct wl_client *client,
wl_list_insert(&shell->input_panel.surfaces,
&input_panel_surface->link);
input_panel_surface->output = output_resource->data;
input_panel_surface->panel = 0;
fprintf(stderr, "%s panel: %d, output: %p\n", __FUNCTION__,
input_panel_surface->panel,
input_panel_surface->output);
}
static void