mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
Animate overlay on/off.
This commit is contained in:
parent
cddc0ad502
commit
9af92b380c
2 changed files with 38 additions and 3 deletions
|
|
@ -36,6 +36,7 @@ struct egl_compositor {
|
||||||
struct egl_surface *pointer;
|
struct egl_surface *pointer;
|
||||||
struct egl_surface *background;
|
struct egl_surface *background;
|
||||||
struct egl_surface *overlay;
|
struct egl_surface *overlay;
|
||||||
|
int32_t overlay_target, overlay_previous;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct egl_surface {
|
struct egl_surface {
|
||||||
|
|
@ -468,6 +469,9 @@ draw_surface(struct egl_surface *es)
|
||||||
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
|
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
schedule_repaint(struct egl_compositor *ec);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
repaint(void *data)
|
repaint(void *data)
|
||||||
{
|
{
|
||||||
|
|
@ -475,6 +479,8 @@ repaint(void *data)
|
||||||
struct wl_surface_iterator *iterator;
|
struct wl_surface_iterator *iterator;
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct egl_surface *es;
|
struct egl_surface *es;
|
||||||
|
double force;
|
||||||
|
int32_t y;
|
||||||
|
|
||||||
draw_surface(ec->background);
|
draw_surface(ec->background);
|
||||||
|
|
||||||
|
|
@ -493,6 +499,26 @@ repaint(void *data)
|
||||||
draw_surface(ec->pointer);
|
draw_surface(ec->pointer);
|
||||||
|
|
||||||
eglSwapBuffers(ec->display, ec->surface);
|
eglSwapBuffers(ec->display, ec->surface);
|
||||||
|
|
||||||
|
y = ec->overlay->map.y;
|
||||||
|
force = (ec->overlay_target - ec->overlay->map.y) / 25.0 +
|
||||||
|
(ec->overlay_previous - y) / 25.0;
|
||||||
|
|
||||||
|
ec->overlay->map.y = y + (y - ec->overlay_previous) + force;
|
||||||
|
ec->overlay_previous = y;
|
||||||
|
|
||||||
|
if (ec->overlay->map.y >= 800) {
|
||||||
|
ec->overlay->map.y = 800;
|
||||||
|
ec->overlay_previous = 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ec->overlay->map.y <= 600) {
|
||||||
|
ec->overlay->map.y = 600;
|
||||||
|
ec->overlay_previous = 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ec->overlay->map.y != y)
|
||||||
|
schedule_repaint(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -637,8 +663,13 @@ notify_key(struct wl_compositor *compositor,
|
||||||
{
|
{
|
||||||
struct egl_compositor *ec = (struct egl_compositor *) compositor;
|
struct egl_compositor *ec = (struct egl_compositor *) compositor;
|
||||||
|
|
||||||
if (key == KEY_ESC)
|
if (key == KEY_ESC && state == 1) {
|
||||||
|
if (ec->overlay_target == ec->height)
|
||||||
|
ec->overlay_target -= 200;
|
||||||
|
else
|
||||||
|
ec->overlay_target += 200;
|
||||||
schedule_repaint(ec);
|
schedule_repaint(ec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_compositor_interface interface = {
|
static const struct wl_compositor_interface interface = {
|
||||||
|
|
@ -749,7 +780,9 @@ wl_compositor_create(struct wl_display *display)
|
||||||
filename = "background.jpg";
|
filename = "background.jpg";
|
||||||
ec->background = background_create(filename, 1280, 800);
|
ec->background = background_create(filename, 1280, 800);
|
||||||
ec->pointer = pointer_create(100, 100, 64, 64);
|
ec->pointer = pointer_create(100, 100, 64, 64);
|
||||||
ec->overlay = overlay_create(0, ec->height - 200, ec->width, 200);
|
ec->overlay = overlay_create(0, ec->height, ec->width, 200);
|
||||||
|
ec->overlay_target = ec->height;
|
||||||
|
ec->overlay_previous = ec->height;
|
||||||
|
|
||||||
ec->gem_fd = open(gem_device, O_RDWR);
|
ec->gem_fd = open(gem_device, O_RDWR);
|
||||||
if (ec->gem_fd < 0) {
|
if (ec->gem_fd < 0) {
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ wl_event_loop_wait(struct wl_event_loop *loop)
|
||||||
{
|
{
|
||||||
struct epoll_event ep[32];
|
struct epoll_event ep[32];
|
||||||
struct wl_event_source *source;
|
struct wl_event_source *source;
|
||||||
|
wl_event_loop_idle_func_t idle_func;
|
||||||
int i, count, timeout;
|
int i, count, timeout;
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
|
|
||||||
|
|
@ -157,8 +158,9 @@ wl_event_loop_wait(struct wl_event_loop *loop)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0 && loop->idle_func != NULL) {
|
if (count == 0 && loop->idle_func != NULL) {
|
||||||
loop->idle_func(loop->idle_data);
|
idle_func = loop->idle_func;
|
||||||
loop->idle_func = NULL;
|
loop->idle_func = NULL;
|
||||||
|
idle_func(loop->idle_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue