static void detach_pixmap (MetaSurfaceActorX11 *self) { MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self); MetaDisplay *display = priv->display; Display *xdisplay = meta_display_get_xdisplay (display); MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self)); if (priv->pixmap == None) return; /* Get rid of all references to the pixmap before freeing it; it's unclear whether * you are supposed to be able to free a GLXPixmap after freeing the underlying * pixmap, but it certainly doesn't work with current DRI/Mesa */ meta_shaped_texture_set_texture (stex, NULL); cogl_flush (); meta_error_trap_push (display); XFreePixmap (xdisplay, priv->pixmap); priv->pixmap = None; meta_error_trap_pop (display); cogl_object_unref (priv->texture); priv->texture = NULL; }
gboolean meta_surface_actor_is_argb32 (MetaSurfaceActor *self) { MetaShapedTexture *stex = meta_surface_actor_get_texture (self); CoglTexture *texture = meta_shaped_texture_get_texture (stex); /* If we don't have a texture, like during initialization, assume * that we're ARGB32. * * If we are unredirected and we have no texture assume that we are * not ARGB32 otherwise we wouldn't be unredirected in the first * place. This prevents us from continually redirecting and * unredirecting on every paint. */ if (!texture) return !meta_surface_actor_is_unredirected (self); switch (cogl_texture_get_components (texture)) { case COGL_TEXTURE_COMPONENTS_A: case COGL_TEXTURE_COMPONENTS_RGBA: return TRUE; case COGL_TEXTURE_COMPONENTS_RG: case COGL_TEXTURE_COMPONENTS_RGB: case COGL_TEXTURE_COMPONENTS_DEPTH: return FALSE; default: g_assert_not_reached (); } }
void meta_surface_actor_x11_set_size (MetaSurfaceActorX11 *self, int width, int height) { MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self); MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self)); if (priv->last_width == width && priv->last_height == height) return; priv->size_changed = TRUE; priv->last_width = width; priv->last_height = height; meta_shaped_texture_set_fallback_size (stex, width, height); }
static void set_pixmap (MetaSurfaceActorX11 *self, Pixmap pixmap) { MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (self); CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self)); CoglTexture *texture; g_assert (priv->pixmap == None); priv->pixmap = pixmap; texture = COGL_TEXTURE (cogl_texture_pixmap_x11_new (ctx, priv->pixmap, FALSE, NULL)); if (G_UNLIKELY (!cogl_texture_pixmap_x11_is_using_tfp_extension (COGL_TEXTURE_PIXMAP_X11 (texture)))) g_warning ("NOTE: Not using GLX TFP!\n"); priv->texture = texture; meta_shaped_texture_set_texture (stex, texture); }
gboolean meta_surface_actor_is_argb32 (MetaSurfaceActor *self) { MetaShapedTexture *stex = meta_surface_actor_get_texture (self); CoglTexture *texture = meta_shaped_texture_get_texture (stex); /* If we don't have a texture, like during initialization, assume * that we're ARGB32. */ if (!texture) return TRUE; switch (cogl_texture_get_components (texture)) { case COGL_TEXTURE_COMPONENTS_A: case COGL_TEXTURE_COMPONENTS_RGBA: return TRUE; case COGL_TEXTURE_COMPONENTS_RG: case COGL_TEXTURE_COMPONENTS_RGB: case COGL_TEXTURE_COMPONENTS_DEPTH: return FALSE; default: g_assert_not_reached (); } }
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, guint32 serial) { MetaWaylandDataDevice *data_device = wl_resource_get_user_data (resource); MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device); MetaWaylandSurface *surface = NULL; MetaWaylandDragGrab *drag_grab; ClutterPoint pos; if (origin_resource) surface = wl_resource_get_user_data (origin_resource); if (!surface) return; if (seat->pointer.button_count == 0 || seat->pointer.grab_serial != serial || !seat->pointer.focus_surface || seat->pointer.focus_surface != surface) return; /* FIXME: Check that the data source type array isn't empty. */ if (data_device->current_grab || seat->pointer.grab != &seat->pointer.default_grab) return; data_device->current_grab = drag_grab = g_slice_new0 (MetaWaylandDragGrab); drag_grab->generic.interface = &drag_grab_interface; drag_grab->generic.pointer = &seat->pointer; drag_grab->drag_client = client; drag_grab->seat = seat; drag_grab->drag_origin = surface; drag_grab->drag_origin_listener.notify = destroy_data_device_origin; wl_resource_add_destroy_listener (origin_resource, &drag_grab->drag_origin_listener); clutter_input_device_get_coords (seat->pointer.device, NULL, &pos); clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor)), pos.x, pos.y, &pos.x, &pos.y); drag_grab->drag_start_x = pos.x; drag_grab->drag_start_y = pos.y; if (source_resource) { drag_grab->drag_data_source = wl_resource_get_user_data (source_resource); drag_grab->drag_data_source_listener.notify = destroy_data_device_source; wl_resource_add_destroy_listener (source_resource, &drag_grab->drag_data_source_listener); } if (icon_resource) { drag_grab->drag_surface = wl_resource_get_user_data (icon_resource); drag_grab->drag_icon_listener.notify = destroy_data_device_icon; wl_resource_add_destroy_listener (icon_resource, &drag_grab->drag_icon_listener); drag_grab->feedback_actor = meta_dnd_actor_new (CLUTTER_ACTOR (drag_grab->drag_origin->surface_actor), drag_grab->drag_start_x, drag_grab->drag_start_y); meta_feedback_actor_set_anchor (META_FEEDBACK_ACTOR (drag_grab->feedback_actor), -drag_grab->drag_surface->offset_x, -drag_grab->drag_surface->offset_y); clutter_actor_add_child (drag_grab->feedback_actor, CLUTTER_ACTOR (drag_grab->drag_surface->surface_actor)); clutter_input_device_get_coords (seat->pointer.device, NULL, &pos); meta_feedback_actor_set_position (META_FEEDBACK_ACTOR (drag_grab->feedback_actor), pos.x, pos.y); } meta_wayland_pointer_set_focus (&seat->pointer, NULL); meta_wayland_pointer_start_grab (&seat->pointer, (MetaWaylandPointerGrab*)drag_grab); }