Beispiel #1
0
/* Hide the bar from sight. */
int
hide_bar (rp_screen *s)
{
  if (s->bar_is_raised)
    {
      if (defaults.bar_sticky)
	{
	  /* Something just wanted the current message gone. */
	  s->bar_is_raised = BAR_IS_WINDOW_LIST;
	  show_bar(s, defaults.window_fmt);
	}
      else
        {
          s->bar_is_raised = 0;
          XUnmapWindow (dpy, s->bar_window);

          /* Possibly restore colormap. */
          if (current_window())
	    {
	      XUninstallColormap (dpy, s->def_cmap);
	      XInstallColormap (dpy, current_window()->colormap);
	    }
	}
      return 1;
    }

  return 0;
}
Beispiel #2
0
/* Raise the bar and put it in the right spot */
static void
prepare_bar (rp_screen *s, int width, int height, int multiline)
{
  width = width < s->width ? width : s->width;
  height = height < s->height ? height : s->height;
  XMoveResizeWindow (dpy, s->bar_window,
                     bar_x (s, width), bar_y (s, height),
                     width, height);

  /* Map the bar if needed */
  if (!s->bar_is_raised)
    {
      s->bar_is_raised = BAR_IS_MESSAGE;
      if (defaults.bar_sticky && !multiline)
        XMapWindow (dpy, s->bar_window);
      else
        XMapRaised (dpy, s->bar_window);

      /* Switch to the default colormap */
      if (current_window())
	XUninstallColormap (dpy, current_window()->colormap);
      XInstallColormap (dpy, s->def_cmap);
    }

  if (multiline || !defaults.bar_sticky)
    XRaiseWindow (dpy, s->bar_window);
  XClearWindow (dpy, s->bar_window);
  XSync (dpy, False);
}
Beispiel #3
0
/* Show window listing in bar. */
int
show_bar (rp_screen *s, char *fmt)
{
  if (!s->bar_is_raised)
    {
      s->bar_is_raised = BAR_IS_WINDOW_LIST;
      if (defaults.bar_sticky)
        XMapWindow (dpy, s->bar_window);
      else
        XMapRaised (dpy, s->bar_window);

      update_window_names (s, fmt);

      /* Switch to the default colormap */
      if (current_window())
	XUninstallColormap (dpy, current_window()->colormap);
      XInstallColormap (dpy, s->def_cmap);

      reset_alarm();
      return 1;
    }

  /* If the bar is raised we still need to display the window
     names. */
  update_window_names (s, fmt);
  return 0;
}
Beispiel #4
0
/* Get the average value
 *
 * @ta:  the TimedAverage structure
 * @ret: the average value
 */
uint64_t timed_average_avg(TimedAverage *ta)
{
    TimedAverageWindow *w;
    check_expirations(ta, NULL);
    w = current_window(ta);
    return w->count > 0 ? w->sum / w->count : 0;
}
Beispiel #5
0
/* Get the sum of all accounted values
 * @ta:      the TimedAverage structure
 * @elapsed: if non-NULL, the elapsed time (in ns) will be stored here
 * @ret:     the sum of all accounted values
 */
uint64_t timed_average_sum(TimedAverage *ta, uint64_t *elapsed)
{
    TimedAverageWindow *w;
    check_expirations(ta, elapsed);
    w = current_window(ta);
    return w->sum;
}
Beispiel #6
0
/* Get the minimum value
 *
 * @ta:  the TimedAverage structure
 * @ret: the minimum value
 */
uint64_t timed_average_min(TimedAverage *ta)
{
    TimedAverageWindow *w;
    check_expirations(ta, NULL);
    w = current_window(ta);
    return w->min < UINT64_MAX ? w->min : 0;
}
Beispiel #7
0
static at *current_window_handler(void)
{
   struct window *win = current_window();
   (*win->gdriver->begin) (win);
   (*win->gdriver->end) (win);
   if (!win->eventhandler)
      RAISEF("no event handler for current window", NIL);
   return win->eventhandler;
}
Beispiel #8
0
static at *
current_window_handler(void)
{
  struct window *win = current_window();
  (*win->gdriver->begin) (win);
  (*win->gdriver->end) (win);
  if (!win->eventhandler)
    error(NIL,"No event handler for the current window",NIL);
  LOCK(win->eventhandler);
  return win->eventhandler;
}
Beispiel #9
0
/* Hide the bar from sight. */
int
hide_bar (rp_screen *s)
{
  if (s->bar_is_raised)
    {
      s->bar_is_raised = 0;
      XUnmapWindow (dpy, s->bar_window);

      /* Possibly restore colormap. */
      if (current_window())
	{
	  XUninstallColormap (dpy, s->def_cmap);
	  XInstallColormap (dpy, current_window()->colormap);
	}

      return 1;
    }

  return 0;
}
void GlutViewer::keyboard__(unsigned char key, int x, int y) {
    current_window()->keyboard((int)key, x, y);
}
void GlutViewer::processmenu__(int id) {
    current_window()->processmenu(id);
}
void GlutViewer::visibility__(int visible) {
    current_window()->visibility(visible);
}
void GlutViewer::special__(int key, int x, int y) {
    current_window()->keyboard(key, x, y);
}   
void GlutViewer::reshape__(int w, int h) {
    current_window()->reshape(w, h);
}
void GlutViewer::passivemotion__(int x, int y) {
    current_window()->passivemotion(x, y);
}
Beispiel #16
0
void GLUT_viewer::idle__(void) {
    current_window()->idle();
}
Beispiel #17
0
/* Get the maximum value
 *
 * @ta:  the TimedAverage structure
 * @ret: the maximum value
 */
uint64_t timed_average_max(TimedAverage *ta)
{
    check_expirations(ta, NULL);
    return current_window(ta)->max;
}
void GlutViewer::idle__(void) {
    current_window()->idle();
} 
void GlutViewer::display__(void) {
    current_window()->display();
}
Beispiel #20
0
void GLUT_viewer::special__(int key, int x, int y) {
    current_window()->special(key, x, y);
}
void GlutViewer::motion__(int x, int y) {
    current_window()->motion(x, y);
}
void GlutViewer::mouse__(int button, int state, int x, int y) {
    current_window()->mouse(button, state, x, y);
}
Beispiel #23
0
char *
get_more_input (char *prompt, char *preinput, int history_id,
                completion_fn compl_fn)
{
  /* Emacs 21 uses a 513 byte string to store the keysym name. */
  char keysym_buf[513];
  rp_screen *s = current_screen ();
  KeySym ch;
  unsigned int modifier;
  rp_input_line *line;
  char *final_input;
  edit_status status;
  Window focus;
  int revert, done = 0;

  history_reset();

  /* Create our line structure */
  line = input_line_new (prompt, preinput, history_id, compl_fn);

  /* We don't want to draw overtop of the program bar. */
  hide_bar (s);

  /* Switch to the default colormap. */
  if (current_window())
    XUninstallColormap (dpy, current_window()->colormap);
  XInstallColormap (dpy, s->def_cmap);

  XMapWindow (dpy, s->input_window);
  XRaiseWindow (dpy, s->input_window);
  XClearWindow (dpy, s->input_window);
  /* Switch focus to our input window to read the next key events. */
  XGetInputFocus (dpy, &focus, &revert);
  set_window_focus (s->input_window);
  XSync (dpy, False);

  update_input_window (s, line);

  while (!done)
    {
      read_key (&ch, &modifier, keysym_buf, sizeof (keysym_buf));
      modifier = x11_mask_to_rp_mask (modifier);
      PRINT_DEBUG (("ch = %ld, modifier = %d, keysym_buf = %s",
                    ch, modifier, keysym_buf));
      status = execute_edit_action (line, ch, modifier, keysym_buf);

      switch (status)
        {
        case EDIT_COMPLETE:
        case EDIT_DELETE:
        case EDIT_INSERT:
        case EDIT_MOVE:
          /* If the text changed (and we didn't just complete
             something) then set the virgin bit. */
          if (status != EDIT_COMPLETE)
            line->compl->virgin = 1;
          /* In all cases, we need to redisplay the input string. */
          update_input_window (s, line);
          break;
        case EDIT_NO_OP:
          ring_bell ();
          break;
        case EDIT_ABORT:
          final_input = NULL;
          done = 1;
          break;
        case EDIT_DONE:
          final_input = xstrdup (line->buffer);
          done = 1;
          break;
        default:
          PRINT_ERROR (("Unhandled status %d; this is a *BUG*\n", status));
          exit (EXIT_FAILURE);
        }
    }

  /* Clean up our line structure */
  input_line_free (line);

  /* Revert focus. */
  set_window_focus (focus);
  XUnmapWindow (dpy, s->input_window);

  /* Possibly restore colormap. */
  if (current_window())
    {
      XUninstallColormap (dpy, s->def_cmap);
      XInstallColormap (dpy, current_window()->colormap);
    }

  return final_input;
}
Beispiel #24
0
void GLUT_viewer::display__(void) {
    current_window()->display();
}