示例#1
0
文件: cogland.c 项目: 3v1n0/cogl
static void
cogland_compositor_create_surface (struct wl_client *wayland_client,
                                   struct wl_resource *wayland_compositor_resource,
                                   uint32_t id)
{
  CoglandCompositor *compositor =
    wl_resource_get_user_data (wayland_compositor_resource);
  CoglandSurface *surface = g_slice_new0 (CoglandSurface);

  surface->compositor = compositor;

  wl_signal_init (&surface->destroy_signal);

  surface->resource = wl_client_add_object (wayland_client,
                                            &wl_surface_interface,
                                            &cogland_surface_interface,
                                            id,
                                            surface);
  wl_resource_set_destructor (surface->resource,
                              cogland_surface_resource_destroy_cb);

  surface->pending.buffer_destroy_listener.notify =
    surface_handle_pending_buffer_destroy;
  wl_list_init (&surface->pending.frame_callback_list);
  region_init (&surface->pending.damage);

  compositor->surfaces = g_list_prepend (compositor->surfaces,
                                         surface);
}
示例#2
0
文件: cogland.c 项目: 3v1n0/cogl
static void
get_shell_surface (struct wl_client *client,
                   struct wl_resource *resource,
                   uint32_t id,
                   struct wl_resource *surface_resource)
{
  CoglandSurface *surface = wl_resource_get_user_data (surface_resource);
  CoglandShellSurface *shell_surface;

  if (surface->has_shell_surface)
    {
      wl_resource_post_error (surface_resource,
                              WL_DISPLAY_ERROR_INVALID_OBJECT,
                              "wl_shell::get_shell_surface already requested");
      return;
    }

  shell_surface = g_new0 (CoglandShellSurface, 1);

  shell_surface->surface = surface;
  shell_surface->surface_destroy_listener.notify =
    shell_handle_surface_destroy;
  wl_signal_add (&surface->destroy_signal,
                 &shell_surface->surface_destroy_listener);

  surface->has_shell_surface = TRUE;

  shell_surface->resource = wl_client_add_object (client,
                                                  &wl_shell_surface_interface,
                                                  &cogl_shell_surface_interface,
                                                  id,
                                                  shell_surface);
  wl_resource_set_destructor (shell_surface->resource,
                              destroy_shell_surface_cb);
}
示例#3
0
static void
bind_output (struct wl_client *client,
             void *data,
             guint32 version,
             guint32 id)
{
  MetaWaylandOutput *wayland_output = data;
  MetaMonitorInfo *monitor_info = wayland_output->monitor_info;
  struct wl_resource *resource;
  MetaOutput *output = monitor_info->outputs[0];

  resource = wl_resource_create (client, &wl_output_interface, version, id);
  wayland_output->resources = g_list_prepend (wayland_output->resources, resource);

  wl_resource_set_user_data (resource, wayland_output);
  wl_resource_set_destructor (resource, output_resource_destroy);

  meta_verbose ("Binding monitor %p/%s (%u, %u, %u, %u) x %f\n",
                monitor_info, output->name,
                monitor_info->rect.x, monitor_info->rect.y,
                monitor_info->rect.width, monitor_info->rect.height,
                monitor_info->refresh_rate);

  send_output_events (resource, wayland_output, monitor_info, TRUE);
}
示例#4
0
static void
bind_output (struct wl_client *client,
             void *data,
             guint32 version,
             guint32 id)
{
  MetaWaylandOutput *wayland_output = data;
  MetaOutput *output = wayland_output->output;
  struct wl_resource *resource;
  guint mode_flags;

  resource = wl_resource_create (client, &wl_output_interface,
				 MIN (META_WL_OUTPUT_VERSION, version), id);
  wayland_output->resources = g_list_prepend (wayland_output->resources, resource);

  wl_resource_set_user_data (resource, wayland_output);
  wl_resource_set_destructor (resource, output_resource_destroy);

  meta_verbose ("Binding output %p/%s (%u, %u, %u, %u) x %f\n",
                output, output->name,
                output->crtc->rect.x, output->crtc->rect.y,
                output->crtc->rect.width, output->crtc->rect.height,
                output->crtc->current_mode->refresh_rate);

  wl_resource_post_event (resource,
                          WL_OUTPUT_GEOMETRY,
                          (int)output->crtc->rect.x,
                          (int)output->crtc->rect.y,
                          output->width_mm,
                          output->height_mm,
                          /* Cogl values reflect XRandR values,
                             and so does wayland */
                          output->subpixel_order,
                          output->vendor,
                          output->product,
                          output->crtc->transform);

  g_assert (output->crtc->current_mode != NULL);

  mode_flags = WL_OUTPUT_MODE_CURRENT;
  if (output->crtc->current_mode == output->preferred_mode)
    mode_flags |= WL_OUTPUT_MODE_PREFERRED;

  wl_resource_post_event (resource,
                          WL_OUTPUT_MODE,
                          mode_flags,
                          (int)output->crtc->current_mode->width,
                          (int)output->crtc->current_mode->height,
                          (int)output->crtc->current_mode->refresh_rate);

  output->scale = compute_scale (output);
  if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
    wl_resource_post_event (resource,
                            WL_OUTPUT_SCALE,
                            output->scale);

  if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
    wl_resource_post_event (resource,
                            WL_OUTPUT_DONE);
}
示例#5
0
XdgBaseSurface::~XdgBaseSurface()
{
    if (m_resource && wl_resource_get_client(m_resource)) {
        wl_resource_set_destructor(m_resource, nullptr);
        wl_resource_destroy(m_resource);
    }
}
示例#6
0
static void
seat_get_keyboard (struct wl_client *client,
                   struct wl_resource *resource,
                   uint32_t id)
{
  ClaylandSeat *seat = wl_resource_get_user_data (resource);
  struct wl_resource *cr;

  cr = wl_client_add_object (client, &wl_keyboard_interface, NULL, id, seat);
  wl_list_insert (&seat->keyboard.resource_list, wl_resource_get_link (cr));
  wl_resource_set_destructor (cr, unbind_resource);

  wl_keyboard_send_keymap (cr,
                           WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
                           seat->keyboard.xkb_info.keymap_fd,
                           seat->keyboard.xkb_info.keymap_size);

  if (seat->keyboard.focus &&
      wl_resource_get_client (seat->keyboard.focus->resource) == client)
    {
      clayland_keyboard_set_focus (&seat->keyboard,
                                   seat->keyboard.focus);
      clayland_data_device_set_keyboard_focus (seat);
    }
}
示例#7
0
static void
seat_get_pointer (struct wl_client *client,
                  struct wl_resource *resource,
                  uint32_t id)
{
  ClaylandSeat *seat = wl_resource_get_user_data (resource);
  struct wl_resource *cr;

  cr = wl_client_add_object (client, &wl_pointer_interface,
                             &pointer_interface, id, seat);
  wl_list_insert (&seat->pointer.resource_list, wl_resource_get_link (cr));
  wl_resource_set_destructor (cr, unbind_resource);

  if (seat->pointer.focus &&
      wl_resource_get_client (seat->pointer.focus->resource) == client)
    {
      ClaylandSurface *surface;
      wl_fixed_t sx, sy;

      surface = (ClaylandSurface *) seat->pointer.focus;
      transform_stage_point_fixed (surface,
                                   seat->pointer.x,
                                   seat->pointer.y,
                                   &sx, &sy);
      clayland_pointer_set_focus (&seat->pointer,
                                  seat->pointer.focus,
                                  sx, sy);
    }
}
示例#8
0
文件: extensions.c 项目: hhw/sway
static void set_background(struct wl_client *client, struct wl_resource *resource,
                           struct wl_resource *_output, struct wl_resource *surface) {
    wlc_handle output = wlc_handle_from_wl_output_resource(_output);
    if (!output) {
        return;
    }
    sway_log(L_DEBUG, "Setting surface %p as background for output %d", surface, (int)output);
    struct background_config *config = malloc(sizeof(struct background_config));
    config->output = output;
    config->surface = wlc_resource_from_wl_surface_resource(surface);
    config->wl_surface_res = surface;
    list_add(desktop_shell.backgrounds, config);
    wl_resource_set_destructor(surface, background_surface_destructor);
}
示例#9
0
文件: extensions.c 项目: hhw/sway
static void set_panel(struct wl_client *client, struct wl_resource *resource,
                      struct wl_resource *_output, struct wl_resource *surface) {
    wlc_handle output = wlc_handle_from_wl_output_resource(_output);
    if (!output) {
        return;
    }
    sway_log(L_DEBUG, "Setting surface %p as panel for output %d (wl_resource: %p)", surface, (int)output, resource);
    struct panel_config *config = find_or_create_panel_config(resource);
    config->output = output;
    config->surface = wlc_resource_from_wl_surface_resource(surface);
    config->wl_surface_res = surface;
    wl_resource_set_destructor(surface, panel_surface_destructor);
    desktop_shell.panel_size = *wlc_surface_get_size(config->surface);
    arrange_windows(&root_container, -1, -1);
}
示例#10
0
文件: cogland.c 项目: 3v1n0/cogl
static void
cogland_compositor_create_region (struct wl_client *wayland_client,
                                  struct wl_resource *compositor_resource,
                                  uint32_t id)
{
  CoglandSharedRegion *region = g_slice_new0 (CoglandSharedRegion);

  region->resource = wl_client_add_object (wayland_client,
                                           &wl_region_interface,
                                           &cogland_region_interface,
                                           id,
                                           region);
  wl_resource_set_destructor (region->resource,
                              cogland_region_resource_destroy_cb);

  region_init (&region->region);
}
示例#11
0
文件: cogland.c 项目: 3v1n0/cogl
static void
cogland_surface_frame (struct wl_client *client,
                       struct wl_resource *surface_resource,
                       uint32_t callback_id)
{
  CoglandFrameCallback *callback;
  CoglandSurface *surface = wl_resource_get_user_data (surface_resource);

  callback = g_slice_new0 (CoglandFrameCallback);
  callback->compositor = surface->compositor;
  callback->resource = wl_client_add_object (client,
                                             &wl_callback_interface,
                                             NULL, /* no implementation */
                                             callback_id,
                                             callback);
  wl_resource_set_destructor (callback->resource, destroy_frame_callback);

  wl_list_insert (surface->pending.frame_callback_list.prev, &callback->link);
}
示例#12
0
文件: extensions.c 项目: hhw/sway
static void set_lock_surface(struct wl_client *client, struct wl_resource *resource,
                             struct wl_resource *_output, struct wl_resource *surface) {
    swayc_t *output = swayc_by_handle(wlc_handle_from_wl_output_resource(_output));
    swayc_t *view = swayc_by_handle(wlc_handle_from_wl_surface_resource(surface));
    sway_log(L_DEBUG, "Setting lock surface to %p", view);
    if (view && output) {
        swayc_t *workspace = output->focused;
        if (!swayc_is_child_of(view, workspace)) {
            move_container_to(view, workspace);
        }
        wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
        workspace->fullscreen = view;
        desktop_shell.is_locked = true;
        set_focused_container(view);
        arrange_windows(view, -1, -1);
        list_add(desktop_shell.lock_surfaces, surface);
        wl_resource_set_destructor(surface, lock_surface_destructor);
    } else {
        sway_log(L_ERROR, "Attempted to set lock surface to non-view");
    }
}
示例#13
0
文件: tag.c 项目: Kinokoio/velox
static void bind_tag(struct wl_client * client, void * data,
                     uint32_t version, uint32_t id)
{
    struct tag * tag = data;
    struct wl_resource * resource;

    if (version >= 1)
        version = 1;

    resource = wl_resource_create(client, &velox_tag_interface, version, id);

    if (!resource)
    {
        wl_client_post_no_memory(client);
        return;
    }

    wl_resource_set_destructor(resource, &remove_resource);
    wl_list_insert(&tag->resources, wl_resource_get_link(resource));
    velox_tag_send_name(resource, tag->name);
    tag_send_screen(tag, client, resource, NULL);
}
示例#14
0
static void
bind_seat (struct wl_client *client,
           void *data,
           guint32 version,
           guint32 id)
{
  ClaylandSeat *seat = data;
  struct wl_resource *resource;

  resource = wl_client_add_object (client,
                                   &wl_seat_interface,
                                   &seat_interface,
                                   id,
                                   data);
  wl_list_insert (&seat->base_resource_list,
                  wl_resource_get_link (resource));
  wl_resource_set_destructor (resource, unbind_resource);

  wl_seat_send_capabilities (resource,
                             WL_SEAT_CAPABILITY_POINTER |
                             WL_SEAT_CAPABILITY_KEYBOARD);
}
示例#15
0
 virtual ~WaylandResource() {
     // TODO: There should better way to fix sigsegv in hookDestroy
     wl_resource_set_destructor(mResource, nullptr);
 }