aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/x11/backend.c12
-rw-r--r--backend/x11/output.c4
-rw-r--r--examples/output-layout.c4
-rw-r--r--examples/rotation.c4
-rw-r--r--examples/tablet.c4
-rw-r--r--examples/touch.c4
-rw-r--r--include/backend/x11.h3
-rw-r--r--include/wlr/types/wlr_output_layout.h25
-rw-r--r--types/wlr_output_layout.c62
9 files changed, 67 insertions, 55 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index f598aea1..59b75a03 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -171,6 +171,15 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
}
}
+ // create a blank cursor
+ xcb_pixmap_t pix = xcb_generate_id(x11->xcb_conn);
+ xcb_create_pixmap(x11->xcb_conn, 1, pix, x11->screen->root, 1, 1);
+
+ x11->cursor = xcb_generate_id(x11->xcb_conn);
+ xcb_create_cursor(x11->xcb_conn, x11->cursor, pix, pix, 0, 0, 0, 0, 0, 0,
+ 0, 0);
+ xcb_free_pixmap(x11->xcb_conn, pix);
+
#ifdef WLR_HAS_XCB_XKB
const xcb_query_extension_reply_t *reply =
xcb_get_extension_data(x11->xcb_conn, &xcb_xkb_id);
@@ -239,6 +248,9 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) {
wlr_egl_finish(&x11->egl);
+ if (x11->cursor) {
+ xcb_free_cursor(x11->xcb_conn, x11->cursor);
+ }
if (x11->xlib_conn) {
XCloseDisplay(x11->xlib_conn);
}
diff --git a/backend/x11/output.c b/backend/x11/output.c
index 4ccabd51..4a8ac84c 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -136,6 +136,10 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
strlen(title), title);
}
+ uint32_t cursor_values[] = { x11->cursor };
+ xcb_change_window_attributes(x11->xcb_conn, output->win, XCB_CW_CURSOR,
+ cursor_values);
+
xcb_map_window(x11->xcb_conn, output->win);
xcb_flush(x11->xcb_conn);
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 53aae7f0..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,8 +195,7 @@ int main(int argc, char *argv[]) {
compositor.keyboard_key_cb = handle_keyboard_key;
compositor_init(&compositor);
- struct wlr_egl *egl = wlr_backend_get_egl(compositor.backend);
- state.renderer = wlr_gles2_renderer_create(egl);
+ 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 37873797..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,8 +136,7 @@ int main(int argc, char *argv[]) {
compositor.keyboard_key_cb = handle_keyboard_key;
compositor_init(&compositor);
- struct wlr_egl *egl = wlr_backend_get_egl(compositor.backend);
- state.renderer = wlr_gles2_renderer_create(egl);
+ 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 d80b4b2f..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,8 +191,7 @@ int main(int argc, char *argv[]) {
};
compositor_init(&compositor);
- struct wlr_egl *egl = wlr_backend_get_egl(compositor.backend);
- state.renderer = wlr_gles2_renderer_create(egl);
+ 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 16024fc8..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,8 +107,7 @@ int main(int argc, char *argv[]) {
};
compositor_init(&compositor);
- struct wlr_egl *egl = wlr_backend_get_egl(compositor.backend);
- state.renderer = wlr_gles2_renderer_create(egl);
+ 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/backend/x11.h b/include/backend/x11.h
index 0426e481..33c9a427 100644
--- a/include/backend/x11.h
+++ b/include/backend/x11.h
@@ -58,6 +58,9 @@ struct wlr_x11_backend {
// The time we last received an event
xcb_timestamp_t time;
+ // A blank cursor
+ xcb_cursor_t cursor;
+
#ifdef WLR_HAS_XCB_XKB
bool xkb_supported;
uint8_t xkb_base_event;
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/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;