Logo Search packages:      
Sourcecode: wayland-demos version File versions  Download package

static struct eventdemo* eventdemo_create ( struct display d ) [static, read]

Create and initialise a new eventdemo window.

Parameters:
dassociated display

Definition at line 274 of file eventdemo.c.

References button_handler(), eventdemo_draw(), height, key_handler(), keyboard_focus_handler(), motion_handler(), noborder, redraw_handler(), resize_handler(), title, and width.

Referenced by main().

{
      struct eventdemo *e;

      e = malloc(sizeof (struct eventdemo));
      if(e == NULL)
            return NULL;

      /* Creates a new window with the given title, width and height.
       * To set the size of the window for a given usable areas width
       * and height in a window decoration agnostic way use:
       *    window_set_child_size(struct window *window,
       *                      int32_t width, int32_t height);
       */
      e->window = window_create(d, width, height);
      window_set_title(e->window, title);
      e->display = d;

      /* The eventdemo window draws a red rectangle as a demonstration
       * of per-window data. The dimensions of that rectangle are set
       * here.
       */
      e->x = width * 1.0 / 4.0;
      e->w = width * 2.0 / 4.0;
      e->y = height * 1.0 / 4.0;
      e->h = height * 2.0 / 4.0;

      /* Connect the user data to the window */
      window_set_user_data(e->window, e);

      /* Set the callback redraw handler for the window */
      window_set_redraw_handler(e->window, redraw_handler);

      /* Set the callback resize handler for the window */
      window_set_resize_handler(e->window, resize_handler);

      /* Set the callback focus handler for the window */
      window_set_keyboard_focus_handler(e->window,
                                keyboard_focus_handler);

      /* Set the callback key handler for the window */
      window_set_key_handler(e->window, key_handler);

      /* Set the callback button handler for the window */
      window_set_button_handler(e->window, button_handler);

      /* Set the callback motion handler for the window */
      window_set_motion_handler(e->window, motion_handler);

      /* Demonstrate how to create a borderless window.
         Move windows with META + left mouse button.
       */
      if(noborder) {
            window_set_decoration(e->window, 0);
      }

      /* Initial drawing of the window */
      eventdemo_draw(e);

      return e;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index