[PATCH 1/6] editor: deactivate old text model before activating the new one

Kristian Høgsberg hoegsberg at gmail.com
Sun Jul 22 11:17:35 PDT 2012


On Wed, Jul 18, 2012 at 08:07:46PM +0200, Philipp Brüschweiler wrote:
> Ping.
> 
> With these patches (and some others) I managed to get a basic ibus
> client working.
> (https://github.com/Blei/ibus/tree/ibus-wayland/client/wayland)

That is cool... I would recommend not using toytoolkit for this
though.  It looks like it doesn't buy you much, and if you're already
linking to glib there, just use the glib mainloop directly.

Kristian

> Cheers,
> Philipp
> 
> On Wed, Jul 11, 2012 at 10:25 PM, Philipp Brüschweiler <blei42 at gmail.com> wrote:
> > ---
> >  clients/editor.c | 36 ++++++++++++++++++++++--------------
> >  1 Datei geändert, 22 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-)
> >
> > diff --git a/clients/editor.c b/clients/editor.c
> > index 145ba20..9498d53 100644
> > --- a/clients/editor.c
> > +++ b/clients/editor.c
> > @@ -20,6 +20,7 @@
> >   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> >   */
> >
> > +#include <assert.h>
> >  #include <stdio.h>
> >  #include <stdlib.h>
> >  #include <string.h>
> > @@ -233,22 +234,29 @@ button_handler(struct widget *widget,
> >         x -= allocation.x;
> >         y -= allocation.y;
> >
> > -       editor->entry->active = 0;
> > -       editor->editor->active = 0;
> > -
> > -       editor->entry->active = rectangle_contains(&editor->entry->allocation, x, y);
> > -       editor->editor->active = rectangle_contains(&editor->editor->allocation, x, y);
> > -
> > -       if (editor->entry->active) {
> > -               text_entry_activate(editor->entry);
> > -       } else {
> > -               text_entry_deactivate(editor->entry);
> > -       }
> > -       if (editor->editor->active) {
> > -               text_entry_activate(editor->editor);
> > +       int32_t activate_entry = rectangle_contains(&editor->entry->allocation, x, y);
> > +       int32_t activate_editor = rectangle_contains(&editor->editor->allocation, x, y);
> > +       assert(!(activate_entry && activate_editor));
> > +
> > +       if (activate_entry) {
> > +               if (editor->editor->active)
> > +                       text_entry_deactivate(editor->editor);
> > +               if (!editor->entry->active)
> > +                       text_entry_activate(editor->entry);
> > +       } else if (activate_editor) {
> > +               if (editor->entry->active)
> > +                       text_entry_deactivate(editor->entry);
> > +               if (!editor->editor->active)
> > +                       text_entry_activate(editor->editor);
> >         } else {
> > -               text_entry_deactivate(editor->editor);
> > +               if (editor->entry->active)
> > +                       text_entry_deactivate(editor->entry);
> > +               if (editor->editor->active)
> > +                       text_entry_deactivate(editor->editor);
> >         }
> > +       editor->entry->active = activate_entry;
> > +       editor->editor->active = activate_editor;
> > +       assert(!(editor->entry->active && editor->editor->active));
> >
> >         widget_schedule_redraw(widget);
> >  }
> > --
> > 1.7.11.1
> >
> _______________________________________________
> 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