Ejemplo n.º 1
0
Bool
textclient_putc (text_data *d, XKeyEvent *k)
{
  KeySym keysym;
  unsigned char c = 0;
  XLookupString (k, (char *) &c, 1, &keysym, &d->compose);
  if (c != 0 && d->pipe)
    {
      if (!d->swap_bs_del_p) ;
      else if (c == 127) c = 8;
      else if (c == 8)   c = 127;

      /* If meta was held down, send ESC, or turn on the high bit. */
      if (k->state & meta_modifier (d))
        {
          if (d->meta_sends_esc_p)
            fputc ('\033', d->pipe);
          else
            c |= 0x80;
        }

      fputc (c, d->pipe);
      fflush (d->pipe);
      k->type = 0;  /* don't interpret this event defaultly. */

# ifdef DEBUG
      fprintf (stderr, "%s: textclient: putc '%c'\n", progname, (char) c);
# endif

      return True;
    }
  return False;
}
Ejemplo n.º 2
0
static Bool
phosphor_event (Display *dpy, Window window, void *closure, XEvent *event)
{
  p_state *state = (p_state *) closure;

  if (event->xany.type == Expose)
    update_display (state, False);
  else if (event->xany.type == KeyPress)
    {
      KeySym keysym;
      unsigned char c = 0;
      XLookupString (&event->xkey, (char *) &c, 1, &keysym,
                     &state->compose);
      if (c != 0 && state->pipe)
        {
          if (!state->swap_bs_del_p) ;
          else if (c == 127) c = 8;
          else if (c == 8)   c = 127;

          /* If meta was held down, send ESC, or turn on the high bit. */
          if (event->xkey.state & meta_modifier (state))
            {
              if (state->meta_sends_esc_p)
                fputc ('\033', state->pipe);
              else
                c |= 0x80;
            }

          fputc (c, state->pipe);
          fflush (state->pipe);
          event->xany.type = 0;  /* don't interpret this event defaultly. */
        }
      return True;
    }

  return False;
}