[Sugar-devel] Hacking onto the "appearing" and "hiding" of OSK

Gary Martin garycmartin at googlemail.com
Tue Jan 29 05:45:38 EST 2013


Hi Ajay,

On 29 Jan 2013, at 05:17, Ajay Garg <ajay at activitycentral.com> wrote:

> I agree with Gonzalo and Gary; this is just a makeshift solution for the time-being, so that activities like Speak, Chat, Terminal are not rendered completely unusable in ebook-mode.
> 
> Ideally, the best solution would be to have the OSK-appearance-and window-shrinkage on "automatic" and "tied-together" basis (without needing any manual intervention).

FWIW, I'm still -1 on the window-shrinkage approach.

Most activities will handle this badly, some not at all. Solutions: Allowing the view to auto scroll to the input area (mainly a GTK3 and Sugar task, significant amount of work already completed in 13.1.0); making sure the OSK is hidden when not needed (e.g. Activity should make sure to defocus input widgets when not essential, with auto refocus if physical keyboard is used and only one text input widget target as in Speak/Chat); Some Activity layout re-designs to optimise canvas for when OSK is visible (Speak/Chat are a good specific Activity cases for this).

Regards,
--Gary

> On Tue, Jan 29, 2013 at 9:17 AM, Gary Martin <garycmartin at googlemail.com> wrote:
> On 28 Jan 2013, at 18:33, Gonzalo Odiard <gonzalo at laptop.org> wrote:
> 
> >
> >
> > On Mon, Jan 28, 2013 at 2:50 PM, Ajay Garg <ajay at activitycentral.com> wrote:
> >
> >
> > On Mon, Jan 28, 2013 at 11:01 PM, Paul Fox <pgf at laptop.org> wrote:
> > ajay wrote:
> >  > Hi all.
> >  >
> >  > A simple solution was found :)
> >  >
> >  > I hacked the "KP_Prior" and "KP_Next" keys, and now they are used for
> >  > making-window-smaller and restoring-original-window-size respectively :)
> >
> > so sugar takes over those keys?  aren't those keys used by activities?
> > they're certainly useful in a terminal -- page up and page down.
> >
> > Hmm.. Well a simple "grepping" showed that the "Read" activity is the only activity that explicitly makes use of the "KP_Home" and "KP_End" keys; but none seemed to make use of "KP_Prior" and "KP_Next".
> >
> >
> > A simple grep is not good enough. Gtk already uses these keys, for example in a textview.
> >
> > I can't understand what you are trying to do. The user should press the key to enlarge/shrink the activity window? Does not look like a good solution.
> 
> +1
> 
> OSK behaviour should be automatic, no user intervention (other than perhaps some manual view scrolling when there is no active focus to get into view). If we are missing cases (and we are currently), then these are bugs to be fixed and/or features to be landed (often GTK3 related upstream targets, but occasionally Sugar/Activity related patches). We made great progress in 13.1.0, hopefully we can finish off this effort ready for 13.2.0.
> 
> Regards,
> --Gary
> 
> > Gonzalo
> >
> >
> >
> >
> > paul
> >
> >  >
> >  > All thanks to
> >  >        * /usr/share/X11/xkb/keycodes/evdev
> >  >        * sugar/src/jarabe/view/keyhandler.py
> >  >
> >  >
> >  >
> >  > Just one thing I noticed when  I tried to have the above keys take effect
> >  > ONLY in ebook-mode (via the "evtest --query" test), that when I ran this
> >  > again and again via the "suprocess" module, the XO-4 behaved very
> >  > erratically. However, when I made the keys take effect irrespective of the
> >  > test of ebook-mode, things worked cool. However, I will keep on looking
> >  > into the reason.
> >  >
> >  >
> >  > Thanks a ton to all :)
> >  >
> >  >
> >  > On Thu, Jan 24, 2013 at 10:45 PM, Paul Fox <pgf at laptop.org> wrote:
> >  >
> >  > > gonzalo wrote:
> >  > >  > Write does not know what is the ebook switch state, that logic is in the
> >  > >  > osk.
> >  > >  >
> >  > >  > Looking in the wiki and sugar code, I could not find information about
> >  > > how
> >  > >  > read the switch,
> >  > >  > but in ticket http://dev.laptop.org/ticket/12326 found this:
> >  > >  >
> >  > >  > If you do:
> >  > >  >
> >  > >  > evtest --query /dev/input/event4 EV_SW SW_TABLET_MODE; echo $?
> >  > >  >
> >  > >  >
> >  > >  > If the xo is in ebook mode returns 10, if not, returns 0.
> >  > >  >
> >  > >  > There are any official doc about the switches I am missing? There are a
> >  > > way
> >  > >  > to catch a event when the switch is activated, using dbus or something
> >  > >  > similar?
> >  > >
> >  > > if you open the device and read it, you'll get a stream of "struct
> >  > > input_event" structures (/usr/include/linux/input.h) representing
> >  > > opening and closing of the SW_TABLET_MODE switch.  here's a C code
> >  > > snippet from olpc-switchd (part of powerd):
> >  > >
> >  > >     void ebook_event()
> >  > >     {
> >  > >         struct input_event ev[1];
> >  > >
> >  > >         if (read(ebk_fd, ev, sizeof(ev)) != sizeof(ev))
> >  > >             die("bad read from ebook switch");
> >  > >
> >  > >         dbg(3, "ebk: ev sec %d usec %d type %d code %d value %d",
> >  > >             ev->time.tv_sec, ev->time.tv_usec,
> >  > >             ev->type, ev->code, ev->value);
> >  > >
> >  > >         if (ev->type == EV_SW && ev->code == SW_TABLET_MODE) {
> >  > >             if (ev->value)
> >  > >                 send_event("ebookclose", round_secs(ev), ebk_device);
> >  > >             else
> >  > >                 send_event("ebookopen", round_secs(ev), ebk_device);
> >  > >         }
> >  > >     }
> >  > >
> >  > >
> >  > > perhaps there's an evdev to dbus gateway of some sort, but i don't know
> >  > > about it, if so.
> >  > >
> >  > > the "evtest" commandline example, above, uses an ioctl on the input
> >  > > device to determine current state.  here's snippet from the evtest source:
> >  > > (full source:  git://anongit.freedesktop.org/evtest)
> >  > >
> >  > >     static int query_device(const char *device, const struct query_mode
> >  > > *query_mode>
> >  > >     {
> >  > >             int fd;
> >  > >             int r;
> >  > >             unsigned long state[NBITS(query_mode->max)];
> >  > >
> >  > >             fd = open(device, O_RDONLY);
> >  > >             if (fd < 0) {
> >  > >                     perror("open");
> >  > >                     return EXIT_FAILURE;
> >  > >             }
> >  > >             memset(state, 0, sizeof(state));
> >  > >             r = ioctl(fd, query_mode->rq, state);
> >  > >             close(fd);
> >  > >
> >  > >             if (r == -1) {
> >  > >                     perror("ioctl");
> >  > >                     return EXIT_FAILURE;
> >  > >             }
> >  > >
> >  > >             if (test_bit(keycode, state))
> >  > >                     return 10; /* different from EXIT_FAILURE */
> >  > >             else
> >  > >                     return 0;
> >  > >     }
> >  > >
> >  > >
> >  > >
> >  > > paul
> >  > >
> >  > >
> >  > >  >
> >  > >  > Gonzalo
> >  > >  >
> >  > >  >
> >  > >  > On Thu, Jan 24, 2013 at 12:16 PM, Martin Langhoff <
> >  > > martin.langhoff at gmail.com
> >  > >  > > wrote:
> >  > >  >
> >  > >  > > On Thu, Jan 24, 2013 at 10:13 AM, Paul Fox <pgf at laptop.org> wrote:
> >  > >  > > > i believe sugar already has code to detect the two modes, since
> >  > >  > > > that's how it knows whether to present the OSK or not.
> >  > >  > >
> >  > >  > > Yep. Ajay, I think Write shows you the way :-)
> >  > >  > >
> >  > >  > >
> >  > >  > >
> >  > >  > >
> >  > >  > > m
> >  > >  > > --
> >  > >  > >  martin.langhoff at gmail.com
> >  > >  > >  martin at laptop.org -- Software Architect - OLPC
> >  > >  > >  - ask interesting questions
> >  > >  > >  - don't get distracted with shiny stuff  - working code first
> >  > >  > >  - http://wiki.laptop.org/go/User:Martinlanghoff
> >  > >  > >
> >  > >
> >  > > =---------------------
> >  > >  paul fox, pgf at laptop.org
> >  > > _______________________________________________
> >  > > Devel mailing list
> >  > > Devel at lists.laptop.org
> >  > > http://lists.laptop.org/listinfo/devel
> >  > >
> >  >
> >  >
> >  >
> >  > --
> >  > Regards,
> >  >
> >  > Ajay Garg
> >  > Dextrose Developer
> >  > Activity Central: http://activitycentral.com
> >
> > =---------------------
> >  paul fox, pgf at laptop.org
> > _______________________________________________
> > Devel mailing list
> > Devel at lists.laptop.org
> > http://lists.laptop.org/listinfo/devel
> >
> >
> >
> > --
> > Regards,
> >
> > Ajay Garg
> > Dextrose Developer
> > Activity Central: http://activitycentral.com
> >
> 
> _______________________________________________
> Devel mailing list
> Devel at lists.laptop.org
> http://lists.laptop.org/listinfo/devel
> 
> 
> 
> -- 
> Regards,
> 
> Ajay Garg
> Dextrose Developer
> Activity Central: http://activitycentral.com




More information about the Devel mailing list