mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-05 13:29:50 -05:00
Drop surface iterator API, just track surfaces in the compositor.
This commit is contained in:
parent
eac149ad06
commit
201a904889
4 changed files with 40 additions and 85 deletions
|
|
@ -28,7 +28,8 @@ $(compositors) $(clients) : CFLAGS += @LIBDRM_CFLAGS@
|
||||||
egl-compositor : \
|
egl-compositor : \
|
||||||
egl-compositor.o \
|
egl-compositor.o \
|
||||||
evdev.o \
|
evdev.o \
|
||||||
cairo-util.o
|
cairo-util.o \
|
||||||
|
wayland-util.o
|
||||||
|
|
||||||
egl-compositor : CFLAGS += @EGL_COMPOSITOR_CFLAGS@
|
egl-compositor : CFLAGS += @EGL_COMPOSITOR_CFLAGS@
|
||||||
egl-compositor : LDLIBS += @EGL_COMPOSITOR_LIBS@ -L. -lwayland-server -rdynamic -lrt
|
egl-compositor : LDLIBS += @EGL_COMPOSITOR_LIBS@ -L. -lwayland-server -rdynamic -lrt
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ struct egl_compositor {
|
||||||
struct egl_surface *overlay;
|
struct egl_surface *overlay;
|
||||||
double overlay_y, overlay_target, overlay_previous;
|
double overlay_y, overlay_target, overlay_previous;
|
||||||
|
|
||||||
|
struct wl_list surface_list;
|
||||||
|
|
||||||
/* Repaint state. */
|
/* Repaint state. */
|
||||||
struct wl_event_source *timer_source;
|
struct wl_event_source *timer_source;
|
||||||
int repaint_needed;
|
int repaint_needed;
|
||||||
|
|
@ -75,6 +77,8 @@ struct egl_surface {
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
struct wl_map map;
|
struct wl_map map;
|
||||||
EGLSurface surface;
|
EGLSurface surface;
|
||||||
|
|
||||||
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -550,8 +554,6 @@ static void
|
||||||
repaint(void *data)
|
repaint(void *data)
|
||||||
{
|
{
|
||||||
struct egl_compositor *ec = data;
|
struct egl_compositor *ec = data;
|
||||||
struct wl_surface_iterator *iterator;
|
|
||||||
struct wl_surface *surface;
|
|
||||||
struct egl_surface *es;
|
struct egl_surface *es;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
uint32_t msecs;
|
uint32_t msecs;
|
||||||
|
|
@ -563,15 +565,14 @@ repaint(void *data)
|
||||||
|
|
||||||
draw_surface(ec->background);
|
draw_surface(ec->background);
|
||||||
|
|
||||||
iterator = wl_surface_iterator_create(ec->wl_display, 0);
|
es = container_of(ec->surface_list.next,
|
||||||
while (wl_surface_iterator_next(iterator, &surface)) {
|
struct egl_surface, link);
|
||||||
es = wl_surface_get_data(surface);
|
while (&es->link != &ec->surface_list) {
|
||||||
if (es == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
draw_surface(es);
|
draw_surface(es);
|
||||||
|
|
||||||
|
es = container_of(es->link.next,
|
||||||
|
struct egl_surface, link);
|
||||||
}
|
}
|
||||||
wl_surface_iterator_destroy(iterator);
|
|
||||||
|
|
||||||
draw_surface(ec->overlay);
|
draw_surface(ec->overlay);
|
||||||
|
|
||||||
|
|
@ -607,6 +608,7 @@ static void
|
||||||
notify_surface_create(struct wl_compositor *compositor,
|
notify_surface_create(struct wl_compositor *compositor,
|
||||||
struct wl_surface *surface)
|
struct wl_surface *surface)
|
||||||
{
|
{
|
||||||
|
struct egl_compositor *ec = (struct egl_compositor *) compositor;
|
||||||
struct egl_surface *es;
|
struct egl_surface *es;
|
||||||
|
|
||||||
es = malloc(sizeof *es);
|
es = malloc(sizeof *es);
|
||||||
|
|
@ -615,6 +617,7 @@ notify_surface_create(struct wl_compositor *compositor,
|
||||||
|
|
||||||
es->surface = EGL_NO_SURFACE;
|
es->surface = EGL_NO_SURFACE;
|
||||||
wl_surface_set_data(surface, es);
|
wl_surface_set_data(surface, es);
|
||||||
|
wl_list_insert(ec->surface_list.prev, &es->link);
|
||||||
|
|
||||||
glGenTextures(1, &es->texture);
|
glGenTextures(1, &es->texture);
|
||||||
}
|
}
|
||||||
|
|
@ -630,6 +633,7 @@ notify_surface_destroy(struct wl_compositor *compositor,
|
||||||
if (es == NULL)
|
if (es == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wl_list_remove(&es->link);
|
||||||
egl_surface_destroy(es, ec);
|
egl_surface_destroy(es, ec);
|
||||||
|
|
||||||
schedule_repaint(ec);
|
schedule_repaint(ec);
|
||||||
|
|
@ -730,6 +734,25 @@ notify_pointer_motion(struct wl_compositor *compositor,
|
||||||
schedule_repaint(ec);
|
schedule_repaint(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct egl_surface *
|
||||||
|
pick_surface(struct egl_compositor *ec, int32_t x, int32_t y)
|
||||||
|
{
|
||||||
|
struct egl_surface *es;
|
||||||
|
|
||||||
|
es = container_of(ec->surface_list.prev,
|
||||||
|
struct egl_surface, link);
|
||||||
|
while (&es->link != &ec->surface_list) {
|
||||||
|
if (es->map.x <= x && x < es->map.x + es->map.width &&
|
||||||
|
es->map.y <= y && y < es->map.y + es->map.height)
|
||||||
|
return es;
|
||||||
|
|
||||||
|
es = container_of(es->link.prev,
|
||||||
|
struct egl_surface, link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_pointer_button(struct wl_compositor *compositor,
|
notify_pointer_button(struct wl_compositor *compositor,
|
||||||
struct wl_object *source,
|
struct wl_object *source,
|
||||||
|
|
@ -737,29 +760,19 @@ notify_pointer_button(struct wl_compositor *compositor,
|
||||||
{
|
{
|
||||||
struct egl_compositor *ec = (struct egl_compositor *) compositor;
|
struct egl_compositor *ec = (struct egl_compositor *) compositor;
|
||||||
struct egl_surface *es;
|
struct egl_surface *es;
|
||||||
struct wl_surface_iterator *iterator;
|
|
||||||
struct wl_surface *surface, *target;
|
|
||||||
const int hotspot_x = 16, hotspot_y = 16;
|
const int hotspot_x = 16, hotspot_y = 16;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
x = ec->pointer->map.x + hotspot_x;
|
x = ec->pointer->map.x + hotspot_x;
|
||||||
y = ec->pointer->map.y + hotspot_y;
|
y = ec->pointer->map.y + hotspot_y;
|
||||||
|
|
||||||
target = NULL;
|
es = pick_surface(ec, x, y);
|
||||||
iterator = wl_surface_iterator_create(ec->wl_display, 0);
|
if (es) {
|
||||||
while (wl_surface_iterator_next(iterator, &surface)) {
|
wl_list_remove(&es->link);
|
||||||
es = wl_surface_get_data(surface);
|
wl_list_insert(ec->surface_list.prev, &es->link);
|
||||||
if (es == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (es->map.x <= x && x < es->map.x + es->map.width &&
|
|
||||||
es->map.y <= y && y < es->map.y + es->map.height)
|
|
||||||
target = surface;
|
|
||||||
}
|
}
|
||||||
wl_surface_iterator_destroy(iterator);
|
|
||||||
|
|
||||||
if (target)
|
schedule_repaint(ec);
|
||||||
wl_display_raise_surface(ec->wl_display, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -1026,6 +1039,7 @@ egl_compositor_create(struct wl_display *display)
|
||||||
|
|
||||||
create_input_devices(display);
|
create_input_devices(display);
|
||||||
|
|
||||||
|
wl_list_init(&ec->surface_list);
|
||||||
filename = getenv("WAYLAND_BACKGROUND");
|
filename = getenv("WAYLAND_BACKGROUND");
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = "background.jpg";
|
filename = "background.jpg";
|
||||||
|
|
|
||||||
51
wayland.c
51
wayland.c
|
|
@ -794,54 +794,3 @@ wl_display_add_socket(struct wl_display *display,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct wl_surface_iterator {
|
|
||||||
struct wl_list *head;
|
|
||||||
struct wl_surface *surface;
|
|
||||||
uint32_t mask;
|
|
||||||
};
|
|
||||||
|
|
||||||
WL_EXPORT struct wl_surface_iterator *
|
|
||||||
wl_surface_iterator_create(struct wl_display *display, uint32_t mask)
|
|
||||||
{
|
|
||||||
struct wl_surface_iterator *iterator;
|
|
||||||
|
|
||||||
iterator = malloc(sizeof *iterator);
|
|
||||||
if (iterator == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
iterator->head = &display->surface_list;
|
|
||||||
iterator->surface = container_of(display->surface_list.next,
|
|
||||||
struct wl_surface, link);
|
|
||||||
iterator->mask = mask;
|
|
||||||
|
|
||||||
return iterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
WL_EXPORT int
|
|
||||||
wl_surface_iterator_next(struct wl_surface_iterator *iterator,
|
|
||||||
struct wl_surface **surface)
|
|
||||||
{
|
|
||||||
if (&iterator->surface->link == iterator->head)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
*surface = iterator->surface;
|
|
||||||
iterator->surface = container_of(iterator->surface->link.next,
|
|
||||||
struct wl_surface, link);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
WL_EXPORT void
|
|
||||||
wl_surface_iterator_destroy(struct wl_surface_iterator *iterator)
|
|
||||||
{
|
|
||||||
free(iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
WL_EXPORT void
|
|
||||||
wl_display_raise_surface(struct wl_display *display, struct wl_surface *surface)
|
|
||||||
{
|
|
||||||
wl_list_remove(&surface->link);
|
|
||||||
wl_list_insert(display->surface_list.prev, &surface->link);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -107,13 +107,6 @@ struct wl_map {
|
||||||
void wl_surface_set_data(struct wl_surface *surface, void *data);
|
void wl_surface_set_data(struct wl_surface *surface, void *data);
|
||||||
void *wl_surface_get_data(struct wl_surface *surface);
|
void *wl_surface_get_data(struct wl_surface *surface);
|
||||||
|
|
||||||
struct wl_surface_iterator;
|
|
||||||
struct wl_surface_iterator *
|
|
||||||
wl_surface_iterator_create(struct wl_display *display, uint32_t mask);
|
|
||||||
int wl_surface_iterator_next(struct wl_surface_iterator *iterator,
|
|
||||||
struct wl_surface **surface);
|
|
||||||
void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator);
|
|
||||||
|
|
||||||
struct wl_object *
|
struct wl_object *
|
||||||
wl_input_device_create(struct wl_display *display, const char *path);
|
wl_input_device_create(struct wl_display *display, const char *path);
|
||||||
|
|
||||||
|
|
@ -142,8 +135,6 @@ wl_display_post_key_event(struct wl_display *display,
|
||||||
void
|
void
|
||||||
wl_display_post_frame(struct wl_display *display,
|
wl_display_post_frame(struct wl_display *display,
|
||||||
uint32_t frame, uint32_t msecs);
|
uint32_t frame, uint32_t msecs);
|
||||||
void
|
|
||||||
wl_display_raise_surface(struct wl_display *display, struct wl_surface *surface);
|
|
||||||
|
|
||||||
struct wl_compositor {
|
struct wl_compositor {
|
||||||
const struct wl_compositor_interface *interface;
|
const struct wl_compositor_interface *interface;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue