aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/drm/drm.c3
-rw-r--r--backend/drm/renderer.c2
-rw-r--r--backend/headless/backend.c2
-rw-r--r--backend/wayland/backend.c2
-rw-r--r--backend/x11/backend.c2
-rw-r--r--backend/x11/output.c1
-rw-r--r--examples/output-layout.c3
-rw-r--r--examples/rotation.c3
-rw-r--r--examples/tablet.c3
-rw-r--r--examples/touch.c3
-rw-r--r--include/wlr/render/egl.h20
-rw-r--r--include/wlr/render/gles2.h3
-rw-r--r--include/wlr/render/wlr_texture.h2
-rw-r--r--include/wlr/types/wlr_output_layout.h25
-rw-r--r--render/egl.c40
-rw-r--r--render/gles2/renderer.c5
-rw-r--r--render/gles2/texture.c49
-rw-r--r--types/wlr_output_layout.c62
18 files changed, 122 insertions, 108 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 94bfbc96..187db368 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -579,8 +579,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
return false;
}
- enum wl_output_transform transform =
- wlr_output_transform_invert(output->transform);
+ enum wl_output_transform transform = output->transform;
wlr_matrix_projection(plane->matrix, plane->surf.width,
plane->surf.height, transform);
}
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index c1531ce3..f06de1ee 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -31,7 +31,7 @@ bool wlr_drm_renderer_init(struct wlr_drm_backend *drm,
goto error_gbm;
}
- renderer->wlr_rend = wlr_gles2_renderer_create(&drm->backend);
+ renderer->wlr_rend = wlr_gles2_renderer_create(&renderer->egl);
if (!renderer->wlr_rend) {
wlr_log(L_ERROR, "Failed to create WLR renderer");
goto error_egl;
diff --git a/backend/headless/backend.c b/backend/headless/backend.c
index 663bc13b..5bc48240 100644
--- a/backend/headless/backend.c
+++ b/backend/headless/backend.c
@@ -114,7 +114,7 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) {
return NULL;
}
- backend->renderer = wlr_gles2_renderer_create(&backend->backend);
+ backend->renderer = wlr_gles2_renderer_create(&backend->egl);
if (backend->renderer == NULL) {
wlr_log(L_ERROR, "Failed to create renderer");
}
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index abb25df5..0135f7c5 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -212,7 +212,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, const char
backend->remote_display, NULL, WL_SHM_FORMAT_ARGB8888);
wlr_egl_bind_display(&backend->egl, backend->local_display);
- backend->renderer = wlr_gles2_renderer_create(&backend->backend);
+ backend->renderer = wlr_gles2_renderer_create(&backend->egl);
if (backend->renderer == NULL) {
wlr_log_errno(L_ERROR, "Could not create renderer");
}
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 225fc49d..59b75a03 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -326,7 +326,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
goto error_event;
}
- x11->renderer = wlr_gles2_renderer_create(&x11->backend);
+ x11->renderer = wlr_gles2_renderer_create(&x11->egl);
if (x11->renderer == NULL) {
wlr_log(L_ERROR, "Failed to create renderer");
goto error_egl;
diff --git a/backend/x11/output.c b/backend/x11/output.c
index 2220bc2e..4a8ac84c 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -52,6 +52,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
wl_event_source_remove(output->frame_timer);
eglDestroySurface(x11->egl.display, output->surf);
xcb_destroy_window(x11->xcb_conn, output->win);
+ xcb_flush(x11->xcb_conn);
free(output);
}
diff --git a/examples/output-layout.c b/examples/output-layout.c
index c1392a30..b04e86b7 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -13,7 +13,6 @@
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
-#include <wlr/render/gles2.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_matrix.h>
@@ -196,7 +195,7 @@ int main(int argc, char *argv[]) {
compositor.keyboard_key_cb = handle_keyboard_key;
compositor_init(&compositor);
- state.renderer = wlr_gles2_renderer_create(compositor.backend);
+ state.renderer = wlr_backend_get_renderer(compositor.backend);
state.cat_texture = wlr_texture_from_pixels(state.renderer,
WL_SHM_FORMAT_ABGR8888, cat_tex.width * 4, cat_tex.width, cat_tex.height,
cat_tex.pixel_data);
diff --git a/examples/rotation.c b/examples/rotation.c
index dfafeeca..c7bbc99a 100644
--- a/examples/rotation.c
+++ b/examples/rotation.c
@@ -13,7 +13,6 @@
#include <wlr/backend.h>
#include <wlr/backend/session.h>
#include <wlr/render/wlr_renderer.h>
-#include <wlr/render/gles2.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
@@ -137,7 +136,7 @@ int main(int argc, char *argv[]) {
compositor.keyboard_key_cb = handle_keyboard_key;
compositor_init(&compositor);
- state.renderer = wlr_gles2_renderer_create(compositor.backend);
+ state.renderer = wlr_backend_get_renderer(compositor.backend);
if (!state.renderer) {
wlr_log(L_ERROR, "Could not start compositor, OOM");
exit(EXIT_FAILURE);
diff --git a/examples/tablet.c b/examples/tablet.c
index be428f86..ca9d782c 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -11,7 +11,6 @@
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
-#include <wlr/render/gles2.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_matrix.h>
@@ -192,7 +191,7 @@ int main(int argc, char *argv[]) {
};
compositor_init(&compositor);
- state.renderer = wlr_gles2_renderer_create(compositor.backend);
+ state.renderer = wlr_backend_get_renderer(compositor.backend);
if (!state.renderer) {
wlr_log(L_ERROR, "Could not start compositor, OOM");
exit(EXIT_FAILURE);
diff --git a/examples/touch.c b/examples/touch.c
index e9dcf29c..949d209d 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -12,7 +12,6 @@
#include <wayland-server.h>
#include <wlr/backend.h>
#include <wlr/backend/session.h>
-#include <wlr/render/gles2.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_list.h>
#include <wlr/types/wlr_matrix.h>
@@ -108,7 +107,7 @@ int main(int argc, char *argv[]) {
};
compositor_init(&compositor);
- state.renderer = wlr_gles2_renderer_create(compositor.backend);
+ state.renderer = wlr_backend_get_renderer(compositor.backend);
if (!state.renderer) {
wlr_log(L_ERROR, "Could not start compositor, OOM");
exit(EXIT_FAILURE);
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h
index 20127e38..cca77870 100644
--- a/include/wlr/render/egl.h
+++ b/include/wlr/render/egl.h
@@ -28,21 +28,22 @@ struct wlr_egl {
// TODO: Allocate and return a wlr_egl
/**
- * Initializes an egl context for the given platform and remote display.
+ * Initializes an EGL context for the given platform and remote display.
* Will attempt to load all possibly required api functions.
*/
bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display,
EGLint *config_attribs, EGLint visual_id);
/**
- * Frees all related egl resources, makes the context not-current and
+ * Frees all related EGL resources, makes the context not-current and
* unbinds a bound wayland display.
*/
void wlr_egl_finish(struct wlr_egl *egl);
/**
- * Binds the given display to the egl instance.
- * This will allow clients to create egl surfaces from wayland ones and render to it.
+ * Binds the given display to the EGL instance.
+ * This will allow clients to create EGL surfaces from wayland ones and render
+ * to it.
*/
bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display);
@@ -53,7 +54,14 @@ bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display)
EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window);
/**
- * Creates an egl image from the given dmabuf attributes. Check usability
+ * Creates an EGL image from the given wl_drm buffer resource.
+ */
+EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl,
+ struct wl_resource *data, EGLint *fmt, int *width, int *height,
+ bool *inverted_y);
+
+/**
+ * Creates an EGL image from the given dmabuf attributes. Check usability
* of the dmabuf with wlr_egl_check_import_dmabuf once first.
*/
EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
@@ -78,7 +86,7 @@ int wlr_egl_get_dmabuf_modifiers(struct wlr_egl *egl, int format,
uint64_t **modifiers);
/**
- * Destroys an egl image created with the given wlr_egl.
+ * Destroys an EGL image created with the given wlr_egl.
*/
bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image);
diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h
index b3b43ab2..a59956bd 100644
--- a/include/wlr/render/gles2.h
+++ b/include/wlr/render/gles2.h
@@ -5,6 +5,7 @@
#include <wlr/render/wlr_renderer.h>
struct wlr_egl;
-struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend);
+
+struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl);
#endif
diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h
index ab361298..239fc51b 100644
--- a/include/wlr/render/wlr_texture.h
+++ b/include/wlr/render/wlr_texture.h
@@ -23,7 +23,7 @@ struct wlr_texture *wlr_texture_from_pixels(struct wlr_renderer *renderer,
const void *data);
/**
- * Create a new texture from a wayland DRM resource. The returned texture is
+ * Create a new texture from a wl_drm resource. The returned texture is
* immutable.
*/
struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer,
diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h
index 4d10720e..3c150fc0 100644
--- a/include/wlr/types/wlr_output_layout.h
+++ b/include/wlr/types/wlr_output_layout.h
@@ -40,41 +40,42 @@ struct wlr_output_layout_output *wlr_output_layout_get(
struct wlr_output_layout *layout, struct wlr_output *reference);
struct wlr_output *wlr_output_layout_output_at(struct wlr_output_layout *layout,
- double x, double y);
+ double lx, double ly);
void wlr_output_layout_add(struct wlr_output_layout *layout,
- struct wlr_output *output, int x, int y);
+ struct wlr_output *output, int lx, int ly);
void wlr_output_layout_move(struct wlr_output_layout *layout,
- struct wlr_output *output, int x, int y);
+ struct wlr_output *output, int lx, int ly);
void wlr_output_layout_remove(struct wlr_output_layout *layout,
struct wlr_output *output);
/**
- * Given x and y as pointers to global coordinates, adjusts them to local output
+ * Given x and y in layout coordinates, adjusts them to local output
* coordinates relative to the given reference output.
*/
void wlr_output_layout_output_coords(struct wlr_output_layout *layout,
- struct wlr_output *reference, double *x, double *y);
+ struct wlr_output *reference, double *lx, double *ly);
bool wlr_output_layout_contains_point(struct wlr_output_layout *layout,
- struct wlr_output *reference, int x, int y);
+ struct wlr_output *reference, int lx, int ly);
bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
- struct wlr_output *reference, const struct wlr_box *target_box);
+ struct wlr_output *reference, const struct wlr_box *target_lbox);
/**
* Get the closest point on this layout from the given point from the reference
* output. If reference is NULL, gets the closest point from the entire layout.
*/
void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
- struct wlr_output *reference, double x, double y, double *dest_x,
- double *dest_y);
+ struct wlr_output *reference, double lx, double ly, double *dest_lx,
+ double *dest_ly);
/**
- * Get the box of the layout for the given reference output. If `reference`
- * is NULL, the box will be for the extents of the entire layout.
+ * Get the box of the layout for the given reference output in layout
+ * coordinates. If `reference` is NULL, the box will be for the extents of the
+ * entire layout.
*/
struct wlr_box *wlr_output_layout_get_box(
struct wlr_output_layout *layout, struct wlr_output *reference);
@@ -109,6 +110,6 @@ enum wlr_direction {
*/
struct wlr_output *wlr_output_layout_adjacent_output(
struct wlr_output_layout *layout, enum wlr_direction direction,
- struct wlr_output *reference, double ref_x, double ref_y);
+ struct wlr_output *reference, double ref_lx, double ref_ly);
#endif
diff --git a/render/egl.c b/render/egl.c
index 3c005b24..a424e8e9 100644
--- a/render/egl.c
+++ b/render/egl.c
@@ -93,7 +93,8 @@ static void print_dmabuf_formats(struct wlr_egl *egl) {
char str_formats[num * 5 + 1];
for (int i = 0; i < num; i++) {
- snprintf(&str_formats[i*5], (num - i) * 5 + 1, "%.4s ", (char*)&formats[i]);
+ snprintf(&str_formats[i*5], (num - i) * 5 + 1, "%.4s ",
+ (char*)&formats[i]);
}
wlr_log(L_DEBUG, "Supported dmabuf buffer formats: %s", str_formats);
free(formats);
@@ -230,8 +231,9 @@ bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImage image) {
}
EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) {
- EGLSurface surf = eglCreatePlatformWindowSurfaceEXT(egl->display, egl->config,
- window, NULL);
+ assert(eglCreatePlatformWindowSurfaceEXT);
+ EGLSurface surf = eglCreatePlatformWindowSurfaceEXT(egl->display,
+ egl->config, window, NULL);
if (surf == EGL_NO_SURFACE) {
wlr_log(L_ERROR, "Failed to create EGL surface");
return EGL_NO_SURFACE;
@@ -302,7 +304,37 @@ bool wlr_egl_swap_buffers(struct wlr_egl *egl, EGLSurface surface,
return true;
}
-EGLImage wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
+EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl,
+ struct wl_resource *data, EGLint *fmt, int *width, int *height,
+ bool *inverted_y) {
+ if (!eglQueryWaylandBufferWL || !eglCreateImageKHR) {
+ return NULL;
+ }
+
+ if (!eglQueryWaylandBufferWL(egl->display, data, EGL_TEXTURE_FORMAT, fmt)) {
+ return NULL;
+ }
+
+ eglQueryWaylandBufferWL(egl->display, data, EGL_WIDTH, width);
+ eglQueryWaylandBufferWL(egl->display, data, EGL_HEIGHT, height);
+
+ EGLint _inverted_y;
+ if (eglQueryWaylandBufferWL(egl->display, data, EGL_WAYLAND_Y_INVERTED_WL,
+ &_inverted_y)) {
+ *inverted_y = !!_inverted_y;
+ } else {
+ *inverted_y = false;
+ }
+
+ const EGLint attribs[] = {
+ EGL_WAYLAND_PLANE_WL, 0,
+ EGL_NONE,
+ };
+ return eglCreateImageKHR(egl->display, egl->context, EGL_WAYLAND_BUFFER_WL,
+ data, attribs);
+}
+
+EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl,
struct wlr_dmabuf_buffer_attribs *attributes) {
bool has_modifier = false;
if (attributes->modifier[0] != DRM_FORMAT_MOD_INVALID) {
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index c8094847..77af0ab7 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <wayland-server-protocol.h>
#include <wayland-util.h>
-#include <wlr/backend.h>
#include <wlr/render/egl.h>
#include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h>
@@ -400,7 +399,7 @@ extern const GLchar tex_fragment_src_rgba[];
extern const GLchar tex_fragment_src_rgbx[];
extern const GLchar tex_fragment_src_external[];
-struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) {
+struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
struct wlr_gles2_renderer *renderer =
calloc(1, sizeof(struct wlr_gles2_renderer));
if (renderer == NULL) {
@@ -408,7 +407,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) {
}
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl);
- renderer->egl = wlr_backend_get_egl(backend);
+ renderer->egl = egl;
wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL);
renderer->exts_str = (const char*) glGetString(GL_EXTENSIONS);
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 82effd71..e4936d71 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -90,7 +90,7 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
}
if (texture->image) {
assert(eglDestroyImageKHR);
- eglDestroyImageKHR(texture->renderer->egl->display, texture->image);
+ wlr_egl_destroy_image(texture->renderer->egl, texture->image);
}
if (texture->type == WLR_GLES2_TEXTURE_GLTEX) {
@@ -144,34 +144,17 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer,
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0);
GLES2_DEBUG_POP;
- return (struct wlr_texture *)texture;
+ return &texture->wlr_texture;
}
struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
struct wl_resource *data) {
struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer);
- if (!eglQueryWaylandBufferWL || !eglCreateImageKHR ||
- !glEGLImageTargetTexture2DOES) {
- return NULL;
- }
-
- EGLint fmt;
- if (!eglQueryWaylandBufferWL(renderer->egl->display, data,
- EGL_TEXTURE_FORMAT, &fmt)) {
+ if (!glEGLImageTargetTexture2DOES) {
return NULL;
}
- EGLint width, height;
- eglQueryWaylandBufferWL(renderer->egl->display, data, EGL_WIDTH, &width);
- eglQueryWaylandBufferWL(renderer->egl->display, data, EGL_HEIGHT, &height);
-
- EGLint inverted_y;
- if (!eglQueryWaylandBufferWL(renderer->egl->display, data,
- EGL_WAYLAND_Y_INVERTED_WL, &inverted_y)) {
- inverted_y = 0;
- }
-
struct wlr_gles2_texture *texture =
calloc(1, sizeof(struct wlr_gles2_texture));
if (texture == NULL) {
@@ -180,10 +163,15 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
}
wlr_texture_init(&texture->wlr_texture, &texture_impl);
texture->renderer = renderer;
- texture->width = width;
- texture->height = height;
texture->wl_drm = data;
- texture->inverted_y = !!inverted_y;
+
+ EGLint fmt;
+ texture->image = wlr_egl_create_image_from_wl_drm(renderer->egl, data, &fmt,
+ &texture->width, &texture->height, &texture->inverted_y);
+ if (texture->image == NULL) {
+ free(texture);
+ return NULL;
+ }
GLenum target;
switch (fmt) {
@@ -204,17 +192,6 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
return NULL;
}
- EGLint attribs[] = {
- EGL_WAYLAND_PLANE_WL, 0,
- EGL_NONE,
- };
- texture->image = eglCreateImageKHR(renderer->egl->display,
- renderer->egl->context, EGL_WAYLAND_BUFFER_WL, data, attribs);
- if (texture->image == NULL) {
- free(texture);
- return NULL;
- }
-
GLES2_DEBUG_PUSH;
glGenTextures(1, &texture->image_tex);
@@ -222,7 +199,7 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
glEGLImageTargetTexture2DOES(target, texture->image);
GLES2_DEBUG_POP;
- return (struct wlr_texture *)texture;
+ return &texture->wlr_texture;
}
struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer,
@@ -267,5 +244,5 @@ struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer,
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, texture->image);
GLES2_DEBUG_POP;
- return (struct wlr_texture *)texture;
+ return &texture->wlr_texture;
}
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c
index fdeef387..1a06f71e 100644
--- a/types/wlr_output_layout.c
+++ b/types/wlr_output_layout.c
@@ -191,7 +191,7 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create(
}
void wlr_output_layout_add(struct wlr_output_layout *layout,
- struct wlr_output *output, int x, int y) {
+ struct wlr_output *output, int lx, int ly) {
struct wlr_output_layout_output *l_output =
wlr_output_layout_get(layout, output);
if (!l_output) {
@@ -201,8 +201,8 @@ void wlr_output_layout_add(struct wlr_output_layout *layout,
return;
}
}
- l_output->x = x;
- l_output->y = y;
+ l_output->x = lx;
+ l_output->y = ly;
l_output->state->auto_configured = false;
wlr_output_layout_reconfigure(layout);
wlr_output_create_global(output);
@@ -221,19 +221,19 @@ struct wlr_output_layout_output *wlr_output_layout_get(
}
bool wlr_output_layout_contains_point(struct wlr_output_layout *layout,
- struct wlr_output *reference, int x, int y) {
+ struct wlr_output *reference, int lx, int ly) {
if (reference) {
struct wlr_output_layout_output *l_output =
wlr_output_layout_get(layout, reference);
struct wlr_box *box = wlr_output_layout_output_get_box(l_output);
- return wlr_box_contains_point(box, x, y);
+ return wlr_box_contains_point(box, lx, ly);
} else {
- return !!wlr_output_layout_output_at(layout, x, y);
+ return !!wlr_output_layout_output_at(layout, lx, ly);
}
}
bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
- struct wlr_output *reference, const struct wlr_box *target_box) {
+ struct wlr_output *reference, const struct wlr_box *target_lbox) {
struct wlr_box out_box;
if (reference == NULL) {
@@ -241,7 +241,7 @@ bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
wl_list_for_each(l_output, &layout->outputs, link) {
struct wlr_box *output_box =
wlr_output_layout_output_get_box(l_output);
- if (wlr_box_intersection(output_box, target_box, &out_box)) {
+ if (wlr_box_intersection(output_box, target_lbox, &out_box)) {
return true;
}
}
@@ -254,16 +254,16 @@ bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
}
struct wlr_box *output_box = wlr_output_layout_output_get_box(l_output);
- return wlr_box_intersection(output_box, target_box, &out_box);
+ return wlr_box_intersection(output_box, target_lbox, &out_box);
}
}
struct wlr_output *wlr_output_layout_output_at(struct wlr_output_layout *layout,
- double x, double y) {
+ double lx, double ly) {
struct wlr_output_layout_output *l_output;
wl_list_for_each(l_output, &layout->outputs, link) {
struct wlr_box *box = wlr_output_layout_output_get_box(l_output);
- if (wlr_box_contains_point(box, x, y)) {
+ if (wlr_box_contains_point(box, lx, ly)) {
return l_output->output;
}
}
@@ -271,12 +271,12 @@ struct wlr_output *wlr_output_layout_output_at(struct wlr_output_layout *layout,
}
void wlr_output_layout_move(struct wlr_output_layout *layout,
- struct wlr_output *output, int x, int y) {
+ struct wlr_output *output, int lx, int ly) {
struct wlr_output_layout_output *l_output =
wlr_output_layout_get(layout, output);
if (l_output) {
- l_output->x = x;
- l_output->y = y;
+ l_output->x = lx;
+ l_output->y = ly;
l_output->state->auto_configured = false;
wlr_output_layout_reconfigure(layout);
} else {
@@ -295,25 +295,25 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout,
}
void wlr_output_layout_output_coords(struct wlr_output_layout *layout,
- struct wlr_output *reference, double *x, double *y) {
+ struct wlr_output *reference, double *lx, double *ly) {
assert(layout && reference);
- double src_x = *x;
- double src_y = *y;
+ double src_x = *lx;
+ double src_y = *ly;
struct wlr_output_layout_output *l_output;
wl_list_for_each(l_output, &layout->outputs, link) {
if (l_output->output == reference) {
- *x = src_x - (double)l_output->x;
- *y = src_y - (double)l_output->y;
+ *lx = src_x - (double)l_output->x;
+ *ly = src_y - (double)l_output->y;
return;
}
}
}
void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
- struct wlr_output *reference, double x, double y, double *dest_x,
- double *dest_y) {
- if (dest_x == NULL && dest_y == NULL) {
+ struct wlr_output *reference, double lx, double ly, double *dest_lx,
+ double *dest_ly) {
+ if (dest_lx == NULL && dest_ly == NULL) {
return;
}
@@ -326,11 +326,11 @@ void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
double output_x, output_y, output_distance;
struct wlr_box *box = wlr_output_layout_output_get_box(l_output);
- wlr_box_closest_point(box, x, y, &output_x, &output_y);
+ wlr_box_closest_point(box, lx, ly, &output_x, &output_y);
// calculate squared distance suitable for comparison
output_distance =
- (x - output_x) * (x - output_x) + (y - output_y) * (y - output_y);
+ (lx - output_x) * (lx - output_x) + (ly - output_y) * (ly - output_y);
if (!isfinite(output_distance)) {
output_distance = DBL_MAX;
@@ -343,11 +343,11 @@ void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
}
}
- if (dest_x) {
- *dest_x = min_x;
+ if (dest_lx) {
+ *dest_lx = min_x;
}
- if (dest_y) {
- *dest_y = min_y;
+ if (dest_ly) {
+ *dest_ly = min_y;
}
}
@@ -433,7 +433,7 @@ struct wlr_output *wlr_output_layout_get_center_output(
struct wlr_output *wlr_output_layout_adjacent_output(
struct wlr_output_layout *layout, enum wlr_direction direction,
- struct wlr_output *reference, double ref_x, double ref_y) {
+ struct wlr_output *reference, double ref_lx, double ref_ly) {
assert(reference);
struct wlr_box *ref_box = wlr_output_layout_get_box(layout, reference);
@@ -468,9 +468,9 @@ struct wlr_output *wlr_output_layout_adjacent_output(
// calculate distance from the given reference point
double x, y;
wlr_output_layout_closest_point(layout, l_output->output,
- ref_x, ref_y, &x, &y);
+ ref_lx, ref_ly, &x, &y);
double distance =
- (x - ref_x) * (x - ref_x) + (y - ref_y) * (y - ref_y);
+ (x - ref_lx) * (x - ref_lx) + (y - ref_ly) * (y - ref_ly);
if (distance < min_distance) {
min_distance = distance;
closest_output = l_output->output;