Exemplo n.º 1
0
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
	struct wlr_xdg_surface_v6 *xdg_surface = data;

	if (xdg_surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
		sway_log(SWAY_DEBUG, "New xdg_shell_v6 popup");
		return;
	}

	sway_log(SWAY_DEBUG, "New xdg_shell_v6 toplevel title='%s' app_id='%s'",
		xdg_surface->toplevel->title, xdg_surface->toplevel->app_id);
	wlr_xdg_surface_v6_ping(xdg_surface);

	struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
		calloc(1, sizeof(struct sway_xdg_shell_v6_view));
	if (!sway_assert(xdg_shell_v6_view, "Failed to allocate view")) {
		return;
	}

	view_init(&xdg_shell_v6_view->view, SWAY_VIEW_XDG_SHELL_V6, &view_impl);
	xdg_shell_v6_view->view.wlr_xdg_surface_v6 = xdg_surface;

	xdg_shell_v6_view->map.notify = handle_map;
	wl_signal_add(&xdg_surface->events.map, &xdg_shell_v6_view->map);

	xdg_shell_v6_view->unmap.notify = handle_unmap;
	wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_v6_view->unmap);

	xdg_shell_v6_view->destroy.notify = handle_destroy;
	wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_v6_view->destroy);

	xdg_surface->data = xdg_shell_v6_view;
}
Exemplo n.º 2
0
WL_EXPORT int
module_init(struct weston_compositor *ec,
	    int *argc, char *argv[])
{
	struct cms_static *cms;
	struct weston_output *output;

	weston_log("cms-static: initialized\n");

	/* create local state object */
	cms = malloc(sizeof *cms);
	if (cms == NULL)
		return -1;
	memset(cms, 0, sizeof *cms);

	cms->ec = ec;
	cms->destroy_listener.notify = cms_notifier_destroy;
	wl_signal_add(&ec->destroy_signal, &cms->destroy_listener);

	cms->output_created_listener.notify = cms_notifier_output_created;
	wl_signal_add(&ec->output_created_signal, &cms->output_created_listener);

	/* discover outputs */
	wl_list_for_each(output, &ec->output_list, link)
		cms_output_created(cms, output);

	return 0;
}
Exemplo n.º 3
0
static int
pixman_renderer_create_surface(struct weston_surface *surface)
{
	struct pixman_surface_state *ps;
	struct pixman_renderer *pr = get_renderer(surface->compositor);

	ps = calloc(1, sizeof *ps);
	if (!ps)
		return -1;

	surface->renderer_state = ps;

	ps->surface = surface;

	ps->surface_destroy_listener.notify =
		surface_state_handle_surface_destroy;
	wl_signal_add(&surface->destroy_signal,
		      &ps->surface_destroy_listener);

	ps->renderer_destroy_listener.notify =
		surface_state_handle_renderer_destroy;
	wl_signal_add(&pr->destroy_signal,
		      &ps->renderer_destroy_listener);

	return 0;
}
Exemplo n.º 4
0
void wayfire_core::init(wayfire_config *conf)
{
    configure(conf);
    wf_input_device::config.load(conf);

    protocols.data_device = wlr_data_device_manager_create(display);
    protocols.data_control = wlr_data_control_manager_v1_create(display);
    wlr_renderer_init_wl_display(renderer, display);

    output_layout = wlr_output_layout_create();
    output_layout_changed.notify = handle_output_layout_changed;
    wl_signal_add(&output_layout->events.change, &output_layout_changed);

    core->compositor = wlr_compositor_create(display, wlr_backend_get_renderer(backend));
    init_desktop_apis();
    input = new input_manager();

    protocols.screenshooter = wlr_screenshooter_create(display);
    protocols.screencopy = wlr_screencopy_manager_v1_create(display);
    protocols.gamma = wlr_gamma_control_manager_create(display);
    protocols.gamma_v1 = wlr_gamma_control_manager_v1_create(display);
    protocols.linux_dmabuf = wlr_linux_dmabuf_v1_create(display, renderer);
    protocols.export_dmabuf = wlr_export_dmabuf_manager_v1_create(display);

    protocols.decorator_manager = wlr_server_decoration_manager_create(display);
    wlr_server_decoration_manager_set_default_mode(protocols.decorator_manager,
                                                   WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT);

    input_inhibit_activated.notify = handle_input_inhibit_activated;
    input_inhibit_deactivated.notify = handle_input_inhibit_deactivated;
    protocols.input_inhibit = wlr_input_inhibit_manager_create(display);
    wl_signal_add(&protocols.input_inhibit->events.activate, &input_inhibit_activated);
    wl_signal_add(&protocols.input_inhibit->events.deactivate, &input_inhibit_deactivated);

    decoration_created.notify = handle_decoration_created;
    wl_signal_add(&protocols.decorator_manager->events.new_decoration, &decoration_created);

    protocols.output_manager = wlr_xdg_output_manager_v1_create(display, output_layout);

    protocols.vkbd_manager = wlr_virtual_keyboard_manager_v1_create(display);
    vkbd_created.notify = handle_virtual_keyboard;
    wl_signal_add(&protocols.vkbd_manager->events.new_virtual_keyboard, &vkbd_created);

    protocols.idle = wlr_idle_create(display);
    protocols.idle_inhibit = wlr_idle_inhibit_v1_create(display);

    protocols.wf_shell = wayfire_shell_create(display);
    protocols.gtk_shell = wf_gtk_shell_create(display);
    protocols.toplevel_manager = wlr_foreign_toplevel_manager_v1_create(display);

    protocols.pointer_gestures = wlr_pointer_gestures_v1_create(display);

    image_io::init();
    OpenGL::init();
}
Exemplo n.º 5
0
wf_touch::wf_touch(wlr_cursor *cursor)
{
    down.notify   = handle_touch_down;
    up.notify     = handle_touch_up;
    motion.notify = handle_touch_motion;

    wl_signal_add(&cursor->events.touch_up, &up);
    wl_signal_add(&cursor->events.touch_down, &down);
    wl_signal_add(&cursor->events.touch_motion, &motion);

    this->cursor = cursor;
}
Exemplo n.º 6
0
struct wb_cursor *wb_cursor_create() {
	struct wb_cursor *cursor = malloc(sizeof(struct wb_cursor));
	cursor->cursor = wlr_cursor_create();
	cursor->xcursor_manager = wlr_xcursor_manager_create("default", 24);

	cursor->cursor_motion.notify = handle_cursor_motion;
	wl_signal_add(&cursor->cursor->events.motion, &cursor->cursor_motion);

	cursor->cursor_motion_absolute.notify = handle_cursor_motion_absolute;
	wl_signal_add(&cursor->cursor->events.motion_absolute, &cursor->cursor_motion_absolute);

	return cursor;
}
Exemplo n.º 7
0
Arquivo: cogland.c Projeto: 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);
}
Exemplo n.º 8
0
static struct wl_resource *
weston_data_source_send_offer(struct weston_data_source *source,
			      struct wl_resource *target)
{
	struct weston_data_offer *offer;
	char **p;

	offer = malloc(sizeof *offer);
	if (offer == NULL)
		return NULL;

	offer->resource =
		wl_resource_create(wl_resource_get_client(target),
				   &wl_data_offer_interface, 1, 0);
	if (offer->resource == NULL) {
		free(offer);
		return NULL;
	}

	wl_resource_set_implementation(offer->resource, &data_offer_interface,
				       offer, destroy_data_offer);

	offer->source = source;
	offer->source_destroy_listener.notify = destroy_offer_data_source;
	wl_signal_add(&source->destroy_signal,
		      &offer->source_destroy_listener);

	wl_data_device_send_data_offer(target, offer->resource);

	wl_array_for_each(p, &source->mime_types)
		wl_data_offer_send_offer(offer->resource, *p);

	return offer->resource;
}
Exemplo n.º 9
0
Arquivo: cogland.c Projeto: 3v1n0/cogl
static void
cogland_buffer_reference (CoglandBufferReference *ref,
                          CoglandBuffer *buffer)
{
  if (ref->buffer && buffer != ref->buffer)
    {
      ref->buffer->busy_count--;

      if (ref->buffer->busy_count == 0)
        {
          g_assert (wl_resource_get_client (ref->buffer->resource));
          wl_resource_queue_event (ref->buffer->resource, WL_BUFFER_RELEASE);
        }

      wl_list_remove (&ref->destroy_listener.link);
    }

  if (buffer && buffer != ref->buffer)
    {
      buffer->busy_count++;
      wl_signal_add (&buffer->destroy_signal, &ref->destroy_listener);
    }

  ref->buffer = buffer;
  ref->destroy_listener.notify = cogland_buffer_reference_handle_destroy;
}
Exemplo n.º 10
0
struct weston_desktop_seat *
weston_desktop_seat_from_seat(struct weston_seat *wseat)
{
	struct wl_listener *listener;
	struct weston_desktop_seat *seat;

	listener = wl_signal_get(&wseat->destroy_signal,
				 weston_desktop_seat_destroy);
	if (listener != NULL)
		return wl_container_of(listener, seat, seat_destroy_listener);

	seat = zalloc(sizeof(struct weston_desktop_seat));
	if (seat == NULL)
		return NULL;

	seat->seat = wseat;

	seat->seat_destroy_listener.notify = weston_desktop_seat_destroy;
	wl_signal_add(&wseat->destroy_signal, &seat->seat_destroy_listener);

	seat->popup_grab.keyboard.interface =
		&weston_desktop_seat_keyboard_popup_grab_interface;
	seat->popup_grab.pointer.interface =
		&weston_desktop_seat_pointer_popup_grab_interface;
	seat->popup_grab.touch.interface =
		&weston_desktop_seat_touch_popup_grab_interface;
	wl_list_init(&seat->popup_grab.surfaces);

	return seat;
}
Exemplo n.º 11
0
Arquivo: cogland.c Projeto: 3v1n0/cogl
static void
cogland_surface_attach (struct wl_client *wayland_client,
                        struct wl_resource *wayland_surface_resource,
                        struct wl_resource *wayland_buffer_resource,
                        int32_t sx, int32_t sy)
{
  CoglandSurface *surface =
    wl_resource_get_user_data (wayland_surface_resource);
  CoglandBuffer *buffer;

  if (wayland_buffer_resource)
    buffer = cogland_buffer_from_resource (wayland_buffer_resource);
  else
    buffer = NULL;

  /* Attach without commit in between does not went wl_buffer.release */
  if (surface->pending.buffer)
    wl_list_remove (&surface->pending.buffer_destroy_listener.link);

  surface->pending.sx = sx;
  surface->pending.sy = sy;
  surface->pending.buffer = buffer;
  surface->pending.newly_attached = TRUE;

  if (buffer)
    wl_signal_add (&buffer->destroy_signal,
                   &surface->pending.buffer_destroy_listener);
}
Exemplo n.º 12
0
static struct wl_resource *
wl_data_source_send_offer(struct wl_data_source *source,
			  struct wl_resource *target)
{
	struct wl_data_offer *offer;
	char **p;

	offer = malloc(sizeof *offer);
	if (offer == NULL)
		return NULL;

	offer->resource.destroy = destroy_data_offer;
	offer->resource.object.id = 0;
	offer->resource.object.interface = &wl_data_offer_interface;
	offer->resource.object.implementation =
		(void (**)(void)) &data_offer_interface;
	offer->resource.data = offer;
	wl_signal_init(&offer->resource.destroy_signal);

	offer->source = source;
	offer->source_destroy_listener.notify = destroy_offer_data_source;
	wl_signal_add(&source->resource.destroy_signal,
		      &offer->source_destroy_listener);

	wl_client_add_resource(target->client, &offer->resource);

	wl_data_device_send_data_offer(target, &offer->resource);

	wl_array_for_each(p, &source->mime_types)
		wl_data_offer_send_offer(&offer->resource, *p);

	return &offer->resource;
}
Exemplo n.º 13
0
ShellSeat::ShellSeat(struct weston_seat *seat)
         : m_seat(seat)
{
    m_popupGrab.client = nullptr;
    m_popupGrab.seat = this;
    m_listeners.seat = this;

    m_listeners.seatDestroy.notify = seatDestroyed;
    wl_signal_add(&seat->destroy_signal, &m_listeners.seatDestroy);

    if (seat->pointer) {
        m_listeners.focus.notify = pointerFocus;
        wl_signal_add(&seat->pointer->focus_signal, &m_listeners.focus);
    } else {
        wl_list_init(&m_listeners.focus.link);
    }
}
Exemplo n.º 14
0
WL_EXPORT int
weston_touch_start_drag(struct weston_touch *touch,
		       struct weston_data_source *source,
		       struct weston_surface *icon,
		       struct wl_client *client)
{
	struct weston_touch_drag *drag;

	drag = zalloc(sizeof *drag);
	if (drag == NULL)
		return -1;

	drag->grab.interface = &touch_drag_grab_interface;
	drag->base.client = client;
	drag->base.data_source = source;

	if (icon) {
		drag->base.icon = weston_view_create(icon);
		if (drag->base.icon == NULL) {
			free(drag);
			return -1;
		}

		drag->base.icon_destroy_listener.notify = handle_drag_icon_destroy;
		wl_signal_add(&icon->destroy_signal,
			      &drag->base.icon_destroy_listener);

		icon->configure = touch_drag_surface_configure;
		icon->configure_private = drag;
	} else {
		drag->base.icon = NULL;
	}

	if (source) {
		drag->base.data_source_listener.notify = destroy_touch_data_device_source;
		wl_signal_add(&source->destroy_signal,
			      &drag->base.data_source_listener);
	}

	weston_touch_start_grab(touch, &drag->grab);

	drag_grab_touch_focus(drag);

	return 0;
}
Exemplo n.º 15
0
void registerResource(wl_list *list, wl_resource *resource)
{
    wl_list_insert(list, &resource->link);

    wl_listener *listener = new wl_listener;
    listener->notify = unregisterResourceCallback;

    wl_signal_add(&resource->destroy_signal, listener);
}
Exemplo n.º 16
0
WL_EXPORT int
wet_shell_init(struct weston_compositor *ec,
	       int *argc, char *argv[])
{
	struct desktest_shell *dts;

	dts = zalloc(sizeof *dts);
	if (!dts)
		return -1;

	dts->compositor_destroy_listener.notify = shell_destroy;
	wl_signal_add(&ec->destroy_signal, &dts->compositor_destroy_listener);

	weston_layer_init(&dts->layer, ec);
	weston_layer_init(&dts->background_layer, ec);

	weston_layer_set_position(&dts->layer,
				  WESTON_LAYER_POSITION_NORMAL);
	weston_layer_set_position(&dts->background_layer,
				  WESTON_LAYER_POSITION_BACKGROUND);

	dts->background_surface = weston_surface_create(ec);
	if (dts->background_surface == NULL)
		goto out_free;

	dts->background_view = weston_view_create(dts->background_surface);
	if (dts->background_view == NULL)
		goto out_surface;

	weston_surface_set_color(dts->background_surface, 0.16, 0.32, 0.48, 1.);
	pixman_region32_fini(&dts->background_surface->opaque);
	pixman_region32_init_rect(&dts->background_surface->opaque, 0, 0, 2000, 2000);
	pixman_region32_fini(&dts->background_surface->input);
	pixman_region32_init_rect(&dts->background_surface->input, 0, 0, 2000, 2000);

	weston_surface_set_size(dts->background_surface, 2000, 2000);
	weston_view_set_position(dts->background_view, 0, 0);
	weston_layer_entry_insert(&dts->background_layer.view_list, &dts->background_view->layer_link);
	weston_view_update_transform(dts->background_view);

	dts->desktop = weston_desktop_create(ec, &shell_desktop_api, dts);
	if (dts->desktop == NULL)
		goto out_view;

	return 0;

out_view:
	weston_view_destroy(dts->background_view);

out_surface:
	weston_surface_destroy(dts->background_surface);

out_free:
	free(dts);

	return -1;
}
Exemplo n.º 17
0
void Touch::setFocus(Surface *surface)
{
    wl_list_remove(&m_focusDestroyListener.listener.link);
    wl_list_init(&m_focusDestroyListener.listener.link);
    if (surface)
        wl_signal_add(&surface->resource()->handle->destroy_signal, &m_focusDestroyListener.listener);

    m_focus = surface;
    m_focusResource = surface ? resourceMap().value(surface->resource()->client()) : 0;
}
Exemplo n.º 18
0
struct clipboard *
clipboard_create(struct weston_seat *seat)
{
	struct clipboard *clipboard;

	clipboard = zalloc(sizeof *clipboard);
	if (clipboard == NULL)
		return NULL;

	clipboard->seat = seat;
	clipboard->selection_listener.notify = clipboard_set_selection;
	clipboard->destroy_listener.notify = clipboard_destroy;

	wl_signal_add(&seat->selection_signal,
		      &clipboard->selection_listener);
	wl_signal_add(&seat->destroy_signal,
		      &clipboard->destroy_listener);

	return clipboard;
}
Exemplo n.º 19
0
bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc,
                             const struct swc_rectangle * origin)
{
    plane->origin = origin;
    plane->crtc = crtc;
    plane->swc_listener.notify = &handle_swc_event;
    wl_signal_add(&swc.event_signal, &plane->swc_listener);
    view_initialize(&plane->view, &view_impl);

    return true;
}
Exemplo n.º 20
0
WL_EXPORT void
weston_output_activate_zoom(struct weston_output *output)
{
	struct weston_seat *seat = weston_zoom_pick_seat(output->compositor);

	if (output->zoom.active)
		return;

	output->zoom.active = 1;
	output->disable_planes++;
	wl_signal_add(&seat->pointer->motion_signal,
		      &output->zoom.motion_listener);
}
Exemplo n.º 21
0
static void
data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
		       struct wl_resource *source_resource,
		       struct wl_resource *origin_resource,
		       struct wl_resource *icon_resource, uint32_t serial)
{
	struct wl_seat *seat = resource->data;

	/* FIXME: Check that client has implicit grab on the origin
	 * surface that matches the given time. */

	/* FIXME: Check that the data source type array isn't empty. */

	seat->drag_grab.interface = &drag_grab_interface;

	seat->drag_client = client;
	seat->drag_data_source = NULL;

	if (source_resource) {
		seat->drag_data_source = source_resource->data;
		seat->drag_data_source_listener.notify =
			destroy_data_device_source;
		wl_signal_add(&source_resource->destroy_signal,
			      &seat->drag_data_source_listener);
	}

	if (icon_resource) {
		seat->drag_surface = icon_resource->data;
		seat->drag_icon_listener.notify = destroy_data_device_icon;
		wl_signal_add(&icon_resource->destroy_signal,
			      &seat->drag_icon_listener);
		wl_signal_emit(&seat->drag_icon_signal, icon_resource);
	}

	wl_pointer_set_focus(seat->pointer, NULL,
			     wl_fixed_from_int(0), wl_fixed_from_int(0));
	wl_pointer_start_grab(seat->pointer, &seat->drag_grab);
}
Exemplo n.º 22
0
bool cursor_plane_initialize(struct cursor_plane * plane, uint32_t crtc,
                             const struct swc_rectangle * origin)
{
    if (drmModeSetCursor(swc.drm->fd, crtc, 0, 0, 0) != 0)
        return false;

    plane->origin = origin;
    plane->crtc = crtc;
    plane->launch_listener.notify = &handle_launch_event;
    wl_signal_add(&swc.launch->event_signal, &plane->launch_listener);
    view_initialize(&plane->view, &view_impl);

    return true;
}
Exemplo n.º 23
0
WL_EXPORT int
module_init(struct weston_compositor *compositor,
	    int *argc, char *argv[])
{
	char *watchdog_time_env;
	struct wl_event_loop *loop;
	long watchdog_time_conv;
	struct systemd_notifier *notifier;

	notifier = zalloc(sizeof *notifier);
	if (notifier == NULL)
		return -1;

	notifier->compositor_destroy_listener.notify =
		weston_compositor_destroy_listener;
	wl_signal_add(&compositor->destroy_signal,
		      &notifier->compositor_destroy_listener);

	if (add_systemd_sockets(compositor) < 0)
		return -1;

	sd_notify(0, "READY=1");

	/* 'WATCHDOG_USEC' is environment variable that is set
	 * by systemd to transfer 'WatchdogSec' watchdog timeout
	 * setting from service file.*/
	watchdog_time_env = getenv("WATCHDOG_USEC");
	if (!watchdog_time_env)
		return 0;

	if (!safe_strtoint(watchdog_time_env, &watchdog_time_conv))
		return 0;

	/* Convert 'WATCHDOG_USEC' to milliseconds and notify
	 * systemd every half of that time.*/
	watchdog_time_conv /= 1000 * 2;
	if (watchdog_time_conv <= 0)
		return 0;

	notifier->watchdog_time = watchdog_time_conv;

	loop = wl_display_get_event_loop(compositor->wl_display);
	notifier->watchdog_source =
		wl_event_loop_add_timer(loop, watchdog_handler, notifier);
	wl_event_source_timer_update(notifier->watchdog_source,
				     notifier->watchdog_time);

	return 0;
}
Exemplo n.º 24
0
WL_EXPORT void
weston_output_activate_zoom(struct weston_output *output,
			    struct weston_seat *seat)
{
	struct weston_pointer *pointer = weston_seat_get_pointer(seat);

	if (output->zoom.active)
		return;

	output->zoom.active = true;
	output->zoom.seat = seat;
	output->disable_planes++;
	wl_signal_add(&pointer->motion_signal,
		      &output->zoom.motion_listener);
}
Exemplo n.º 25
0
static void handle_map(struct wl_listener *listener, void *data) {
	struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
		wl_container_of(listener, xdg_shell_v6_view, map);
	struct sway_view *view = &xdg_shell_v6_view->view;
	struct wlr_xdg_surface_v6 *xdg_surface = view->wlr_xdg_surface_v6;

	view->natural_width = view->wlr_xdg_surface_v6->geometry.width;
	view->natural_height = view->wlr_xdg_surface_v6->geometry.height;
	if (!view->natural_width && !view->natural_height) {
		view->natural_width = view->wlr_xdg_surface_v6->surface->current.width;
		view->natural_height = view->wlr_xdg_surface_v6->surface->current.height;
	}
	struct sway_server_decoration *deco =
			decoration_from_surface(xdg_surface->surface);
	bool csd = !deco || deco->wlr_server_decoration->mode
		== WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;

	view_map(view, view->wlr_xdg_surface_v6->surface,
		xdg_surface->toplevel->client_pending.fullscreen, csd);

	transaction_commit_dirty();

	xdg_shell_v6_view->commit.notify = handle_commit;
	wl_signal_add(&xdg_surface->surface->events.commit,
		&xdg_shell_v6_view->commit);

	xdg_shell_v6_view->new_popup.notify = handle_new_popup;
	wl_signal_add(&xdg_surface->events.new_popup,
		&xdg_shell_v6_view->new_popup);

	xdg_shell_v6_view->request_fullscreen.notify = handle_request_fullscreen;
	wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen,
			&xdg_shell_v6_view->request_fullscreen);

	xdg_shell_v6_view->request_move.notify = handle_request_move;
	wl_signal_add(&xdg_surface->toplevel->events.request_move,
			&xdg_shell_v6_view->request_move);

	xdg_shell_v6_view->request_resize.notify = handle_request_resize;
	wl_signal_add(&xdg_surface->toplevel->events.request_resize,
			&xdg_shell_v6_view->request_resize);

	xdg_shell_v6_view->set_title.notify = handle_set_title;
	wl_signal_add(&xdg_surface->toplevel->events.set_title,
			&xdg_shell_v6_view->set_title);

	xdg_shell_v6_view->set_app_id.notify = handle_set_app_id;
	wl_signal_add(&xdg_surface->toplevel->events.set_app_id,
			&xdg_shell_v6_view->set_app_id);
}
Exemplo n.º 26
0
static void
drag_grab_focus(struct wl_pointer_grab *grab,
		struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y)
{
	struct wl_seat *seat = container_of(grab, struct wl_seat, drag_grab);
	struct wl_resource *resource, *offer = NULL;
	struct wl_display *display;
	uint32_t serial;

	if (seat->drag_focus_resource) {
		wl_data_device_send_leave(seat->drag_focus_resource);
		wl_list_remove(&seat->drag_focus_listener.link);
		seat->drag_focus_resource = NULL;
		seat->drag_focus = NULL;
	}

	if (!surface)
		return;

	if (!seat->drag_data_source &&
	    surface->resource.client != seat->drag_client)
		return;

	resource = find_resource(&seat->drag_resource_list,
				 surface->resource.client);
	if (!resource)
		return;

	display = wl_client_get_display(resource->client);
	serial = wl_display_next_serial(display);

	if (seat->drag_data_source)
		offer = wl_data_source_send_offer(seat->drag_data_source,
						  resource);

	wl_data_device_send_enter(resource, serial, &surface->resource,
				  x, y, offer);

	seat->drag_focus = surface;
	seat->drag_focus_listener.notify = destroy_drag_focus;
	wl_signal_add(&resource->destroy_signal,
		      &seat->drag_focus_listener);
	seat->drag_focus_resource = resource;
	grab->focus = surface;
}
Exemplo n.º 27
0
void
weston_timeline_open(struct weston_compositor *compositor)
{
	if (weston_timeline_enabled_)
		return;

	if (weston_timeline_do_open() < 0)
		return;

	timeline_.compositor_destroy_listener.notify = timeline_notify_destroy;
	wl_signal_add(&compositor->destroy_signal,
		      &timeline_.compositor_destroy_listener);

	if (++timeline_.series == 0)
		++timeline_.series;

	weston_timeline_enabled_ = 1;
}
Exemplo n.º 28
0
void SurfaceBuffer::initialize(struct ::wl_resource *buffer)
{
    m_buffer = buffer;
    m_committed = false;
    m_is_registered_for_buffer = true;
    m_surface_has_buffer = true;
    m_is_displayed = false;
    m_destroyed = false;
    m_destroy_listener.surfaceBuffer = this;
    m_destroy_listener.listener.notify = destroy_listener_callback;
    if (buffer) {
#ifdef QT_WAYLAND_COMPOSITOR_GL
        if (ClientBufferIntegration *integration = QWaylandCompositorPrivate::get(m_compositor)->clientBufferIntegration())
            integration->initializeBuffer(buffer);
#endif
        wl_signal_add(&buffer->destroy_signal, &m_destroy_listener.listener);
    }
}
Exemplo n.º 29
0
WL_EXPORT void
wl_seat_set_selection(struct wl_seat *seat, struct wl_data_source *source,
		      uint32_t serial)
{
	struct wl_resource *data_device, *offer;
	struct wl_resource *focus = NULL;

	if (seat->selection_data_source &&
	    seat->selection_serial - serial < UINT32_MAX / 2)
		return;

	if (seat->selection_data_source) {
		seat->selection_data_source->cancel(seat->selection_data_source);
		wl_list_remove(&seat->selection_data_source_listener.link);
		seat->selection_data_source = NULL;
	}

	seat->selection_data_source = source;
	seat->selection_serial = serial;

	if (seat->keyboard)
		focus = seat->keyboard->focus_resource;
	if (focus) {
		data_device = find_resource(&seat->drag_resource_list,
					    focus->client);
		if (data_device && source) {
			offer = wl_data_source_send_offer(seat->selection_data_source,
							  data_device);
			wl_data_device_send_selection(data_device, offer);
		} else if (data_device) {
			wl_data_device_send_selection(data_device, NULL);
		}
	}

	wl_signal_emit(&seat->selection_signal, seat);

	if (source) {
		seat->selection_data_source_listener.notify =
			destroy_selection_data_source;
		wl_signal_add(&source->resource.destroy_signal,
			      &seat->selection_data_source_listener);
	}
}
Exemplo n.º 30
0
void SurfaceBuffer::initialize(struct ::wl_resource *buffer)
{
    m_buffer = buffer;
    m_texture = 0;
    m_committed = false;
    m_is_registered_for_buffer = true;
    m_surface_has_buffer = true;
    m_is_displayed = false;
    m_destroyed = false;
    m_handle = 0;
    m_is_shm_resolved = false;
    m_shmBuffer = 0;
    m_isSizeResolved = false;
    m_size = QSize();
    m_destroy_listener.surfaceBuffer = this;
    m_destroy_listener.listener.notify = destroy_listener_callback;
    if (buffer)
        wl_signal_add(&buffer->destroy_signal, &m_destroy_listener.listener);
    m_damageRect = QRect();
}