wayland: Add an actor for the cursor

When running Mutter under Cogl's KMS backend no cursor will be
provided so instead this makes it so the cursor will be painted as a
CoglTexture that gets moved in response to mouse motion events. The
painting is done in a subclass of ClutterStage so that we can
guarantee that the cursor will be painted on top of everything else.

This patch adds support for the set_cursor method on the pointer
interface so that clients can change the cursor image.

The set_pointer method sets a surface and a hotspot position to use
for the cursor image. The surface's buffer is converted to a
CoglTexture and attached to a pipeline to paint directly via Cogl. If
a new buffer is attached to the surface the image will be updated. The
cursor reverts back to the default image whenever to the pointer focus
is moved off of any surface.

The image for the pointer is taken from X. It gets installed into
a fixed data location for mutter.
This commit is contained in:
Neil Roberts
2012-01-18 23:03:23 +00:00
committed by Jasper St. Pierre
parent 268ebb1b18
commit a5585327dc
10 changed files with 426 additions and 23 deletions

View File

@@ -39,6 +39,7 @@
#include "meta-wayland-private.h"
#include "meta-xwayland-private.h"
#include "meta-wayland-stage.h"
#include "meta-window-actor-private.h"
#include "meta-wayland-seat.h"
#include "meta-wayland-keyboard.h"
@@ -368,6 +369,8 @@ meta_wayland_surface_commit (struct wl_client *client,
(buffer->width != rect.width || buffer->height != rect.height))
meta_window_resize (surface->window, FALSE, buffer->width, buffer->height);
}
else if (surface == compositor->seat->sprite)
meta_wayland_seat_update_sprite (compositor->seat);
}
}
@@ -1200,6 +1203,13 @@ event_cb (ClutterActor *stage,
}
}
meta_wayland_stage_set_cursor_position (META_WAYLAND_STAGE (stage),
wl_fixed_to_int (pointer->x),
wl_fixed_to_int (pointer->y));
if (pointer->current == NULL)
meta_wayland_stage_set_default_cursor (META_WAYLAND_STAGE (stage));
display = meta_get_display ();
if (!display)
return FALSE;
@@ -1326,7 +1336,7 @@ meta_wayland_init (void)
if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
g_error ("Failed to initialize Clutter");
compositor->stage = clutter_stage_new ();
compositor->stage = meta_wayland_stage_new ();
clutter_stage_set_user_resizable (CLUTTER_STAGE (compositor->stage), FALSE);
g_signal_connect_after (compositor->stage, "paint",
G_CALLBACK (paint_finished_cb), compositor);