[PATCH] editor: Malloc check, flush stuck keyboard
Kristian Høgsberg
hoegsberg at gmail.com
Fri Jun 22 08:02:18 PDT 2012
On Fri, Jun 22, 2012 at 04:59:00AM +0200, Martin Minarik wrote:
> The on screen keyboard stays displayed when the editor is closed.
>
> We need to flush the display once more.
>
> This patch adds the display_flush() method to window.c, to execute
> wl_display_flush() once, not in a loop like in display_run().
I think we need feedback from Jan here. The way it should work is
that the text_model should be tied to a surface, and if that surface
goes away, we deactivate the text_model as well. Also, if the text
model is destroyed, the input panel should go away, so there's plenty
of options for hiding the panel without requiring flushing the display.
Kristian
> It also adds the NULL checks in constructor and destructor.
> ---
> clients/editor.c | 23 +++++++++++++++--------
> clients/window.c | 6 ++++++
> clients/window.h | 3 +++
> 3 files changed, 24 insertions(+), 8 deletions(-)
>
> diff --git a/clients/editor.c b/clients/editor.c
> index 145ba20..d6aa62a 100644
> --- a/clients/editor.c
> +++ b/clients/editor.c
> @@ -79,6 +79,8 @@ text_entry_create(struct editor *editor, const char *text)
> struct wl_surface *surface;
>
> entry = malloc(sizeof *entry);
> + if (entry == NULL)
> + return NULL;
>
> surface = window_get_wl_surface(editor->window);
>
> @@ -92,14 +94,6 @@ text_entry_create(struct editor *editor, const char *text)
> }
>
> static void
> -text_entry_destroy(struct text_entry *entry)
> -{
> - text_model_destroy(entry->model);
> - free(entry->text);
> - free(entry);
> -}
> -
> -static void
> text_entry_draw(struct text_entry *entry, cairo_t *cr)
> {
> cairo_save(cr);
> @@ -214,6 +208,17 @@ text_entry_deactivate(struct text_entry *entry)
> }
>
> static void
> +text_entry_destroy(struct text_entry *entry)
> +{
> + if (entry != NULL) {
> + text_entry_deactivate(entry);
> + text_model_destroy(entry->model);
> + free(entry->text);
> + }
> + free(entry);
> +}
> +
> +static void
> button_handler(struct widget *widget,
> struct input *input, uint32_t time,
> uint32_t button,
> @@ -297,5 +302,7 @@ main(int argc, char *argv[])
> text_entry_destroy(editor.entry);
> text_entry_destroy(editor.editor);
>
> + display_flush(editor.display);
> +
> return 0;
> }
> diff --git a/clients/window.c b/clients/window.c
> index f41812a..7330a7a 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -3732,6 +3732,12 @@ display_watch_fd(struct display *display,
> }
>
> void
> +display_flush(struct display *display)
> +{
> + wl_display_flush(display->display);
> +}
> +
> +void
> display_run(struct display *display)
> {
> struct task *task;
> diff --git a/clients/window.h b/clients/window.h
> index 12e4352..b6ef194 100644
> --- a/clients/window.h
> +++ b/clients/window.h
> @@ -135,6 +135,9 @@ display_watch_fd(struct display *display,
> int fd, uint32_t events, struct task *task);
>
> void
> +display_flush(struct display *d);
> +
> +void
> display_run(struct display *d);
>
> void
> --
> 1.7.5.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list