aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/drm.c12
-rw-r--r--backend/drm/util.c6
-rw-r--r--backend/session/logind.c14
-rw-r--r--backend/wayland/backend.c33
-rw-r--r--backend/wayland/output.c15
-rw-r--r--backend/wayland/wl_seat.c24
-rw-r--r--backend/x11/backend.c17
7 files changed, 96 insertions, 25 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index cf6ad550..96b7d93d 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -453,11 +453,7 @@ static bool wlr_drm_connector_set_mode(struct wlr_output *output,
conn->state = WLR_DRM_CONN_CONNECTED;
conn->output.current_mode = mode;
- if (conn->output.width != mode->width || conn->output.height != mode->height) {
- conn->output.width = mode->width;
- conn->output.height = mode->height;
- wl_signal_emit(&conn->output.events.resolution, &conn->output);
- }
+ wlr_output_update_size(&conn->output, mode->width, mode->height);
// Since realloc_crtcs can deallocate planes on OTHER outputs,
// we actually need to reinitalise any than has changed
@@ -633,8 +629,10 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
struct wlr_box transformed_box;
wlr_box_transform(&box, transform, &transformed_box);
- transformed_box.x -= plane->cursor_hotspot_x;
- transformed_box.y -= plane->cursor_hotspot_y;
+ if (plane != NULL) {
+ transformed_box.x -= plane->cursor_hotspot_x;
+ transformed_box.y -= plane->cursor_hotspot_y;
+ }
return drm->iface->crtc_move_cursor(drm, conn->crtc, transformed_box.x,
transformed_box.y);
diff --git a/backend/drm/util.c b/backend/drm/util.c
index c27d7b67..25256343 100644
--- a/backend/drm/util.c
+++ b/backend/drm/util.c
@@ -93,6 +93,12 @@ void parse_edid(struct wlr_output *restrict output, size_t len, const uint8_t *d
uint16_t id = (data[8] << 8) | data[9];
snprintf(output->make, sizeof(output->make), "%s", get_manufacturer(id));
+ uint16_t model = data[10] | (data[11] << 8);
+ snprintf(output->model, sizeof(output->model), "0x%04X", model);
+
+ uint32_t serial = data[12] | (data[13] << 8) | (data[14] << 8) | (data[15] << 8);
+ snprintf(output->serial, sizeof(output->serial), "0x%08X", serial);
+
output->phys_width = ((data[68] & 0xf0) << 4) | data[66];
output->phys_height = ((data[68] & 0x0f) << 8) | data[67];
diff --git a/backend/session/logind.c b/backend/session/logind.c
index daff75b6..e9d4c8f3 100644
--- a/backend/session/logind.c
+++ b/backend/session/logind.c
@@ -347,12 +347,6 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) {
goto error;
}
- ret = sd_session_get_vt(session->id, &session->base.vtnr);
- if (ret < 0) {
- wlr_log(L_ERROR, "Session not running in virtual terminal");
- goto error;
- }
-
char *seat;
ret = sd_session_get_seat(session->id, &seat);
if (ret < 0) {
@@ -360,6 +354,14 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) {
goto error;
}
snprintf(session->base.seat, sizeof(session->base.seat), "%s", seat);
+
+ if (strcmp(seat, "seat0") == 0) {
+ ret = sd_session_get_vt(session->id, &session->base.vtnr);
+ if (ret < 0) {
+ wlr_log(L_ERROR, "Session not running in virtual terminal");
+ goto error;
+ }
+ }
free(seat);
ret = sd_bus_default_system(&session->bus);
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 1801f3e0..39ecc10f 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
+#include <limits.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <wayland-server.h>
@@ -117,6 +118,38 @@ struct wlr_wl_backend_output *wlr_wl_output_for_surface(
return NULL;
}
+void wlr_wl_output_layout_get_box(struct wlr_wl_backend *backend,
+ struct wlr_box *box) {
+ int min_x = INT_MAX, min_y = INT_MAX;
+ int max_x = INT_MIN, max_y = INT_MIN;
+
+ struct wlr_wl_backend_output *output;
+ wl_list_for_each(output, &backend->outputs, link) {
+ struct wlr_output *wlr_output = &output->wlr_output;
+
+ int width, height;
+ wlr_output_effective_resolution(wlr_output, &width, &height);
+
+ if (wlr_output->lx < min_x) {
+ min_x = wlr_output->lx;
+ }
+ if (wlr_output->ly < min_y) {
+ min_y = wlr_output->ly;
+ }
+ if (wlr_output->lx + width > max_x) {
+ max_x = wlr_output->lx + width;
+ }
+ if (wlr_output->ly + height > max_y) {
+ max_y = wlr_output->ly + height;
+ }
+ }
+
+ box->x = min_x;
+ box->y = min_y;
+ box->width = max_x - min_x;
+ box->height = max_y - min_y;
+}
+
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display) {
wlr_log(L_INFO, "Creating wayland backend");
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index c4301617..fc09903e 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -28,6 +28,14 @@ static struct wl_callback_listener frame_listener = {
.done = surface_frame_callback
};
+static bool wlr_wl_output_set_custom_mode(struct wlr_output *_output,
+ int32_t width, int32_t height, int32_t refresh) {
+ struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
+ wl_egl_window_resize(output->egl_window, width, height, 0, 0);
+ wlr_output_update_size(&output->wlr_output, width, height);
+ return true;
+}
+
static void wlr_wl_output_make_current(struct wlr_output *_output) {
struct wlr_wl_backend_output *output = (struct wlr_wl_backend_output *)_output;
if (!eglMakeCurrent(output->backend->egl.display,
@@ -146,6 +154,8 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
wl_signal_emit(&output->backend->backend.events.output_remove,
&output->wlr_output);
+ wl_list_remove(&output->link);
+
if (output->cursor.buf_size != 0) {
assert(output->cursor.data);
assert(output->cursor.buffer);
@@ -163,6 +173,7 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
if (output->frame_callback) {
wl_callback_destroy(output->frame_callback);
}
+
eglDestroySurface(output->backend->egl.display, output->surface);
wl_egl_window_destroy(output->egl_window);
zxdg_toplevel_v6_destroy(output->xdg_toplevel);
@@ -185,6 +196,7 @@ bool wlr_wl_output_move_cursor(struct wlr_output *_output, int x, int y) {
}
static struct wlr_output_impl output_impl = {
+ .set_custom_mode = wlr_wl_output_set_custom_mode,
.transform = wlr_wl_output_transform,
.destroy = wlr_wl_output_destroy,
.make_current = wlr_wl_output_make_current,
@@ -218,14 +230,13 @@ static void xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *x
// loop over states for maximized etc?
wl_egl_window_resize(output->egl_window, width, height, 0, 0);
wlr_output_update_size(&output->wlr_output, width, height);
- wl_signal_emit(&output->wlr_output.events.resolution, output);
}
static void xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel) {
struct wlr_wl_backend_output *output = data;
assert(output && output->xdg_toplevel == xdg_toplevel);
- wl_display_terminate(output->backend->local_display);
+ wlr_output_destroy((struct wlr_output *)output);
}
static struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index 77c46164..9fcc48dd 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -21,7 +21,10 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
struct wlr_wl_pointer *wlr_wl_pointer = (struct wlr_wl_pointer *)dev->pointer;
struct wlr_wl_backend_output *output =
wlr_wl_output_for_surface(wlr_wl_dev->backend, surface);
- assert(output);
+ if (!output) {
+ // GNOME sends a pointer enter when the surface is being destroyed
+ return;
+ }
wlr_wl_pointer->current_output = output;
output->enter_serial = serial;
wlr_wl_output_update_cursor(output);
@@ -49,22 +52,29 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
return;
}
+ struct wlr_output *wlr_output = &wlr_wl_pointer->current_output->wlr_output;
+
struct wlr_box box;
wl_egl_window_get_attached_size(wlr_wl_pointer->current_output->egl_window,
&box.width, &box.height);
box.x = wl_fixed_to_int(surface_x);
box.y = wl_fixed_to_int(surface_y);
struct wlr_box transformed;
- wlr_box_transform(&box,
- wlr_wl_pointer->current_output->wlr_output.transform, &transformed);
+
+ wlr_box_transform(&box, wlr_output->transform, &transformed);
+ box.x /= wlr_output->scale;
+ box.y /= wlr_output->scale;
+
+ struct wlr_box layout_box;
+ wlr_wl_output_layout_get_box(wlr_wl_pointer->current_output->backend, &layout_box);
struct wlr_event_pointer_motion_absolute wlr_event;
wlr_event.device = dev;
wlr_event.time_msec = time;
- wlr_event.width_mm = transformed.width;
- wlr_event.height_mm = transformed.height;
- wlr_event.x_mm = transformed.x;
- wlr_event.y_mm = transformed.y;
+ wlr_event.width_mm = layout_box.width;
+ wlr_event.height_mm = layout_box.height;
+ wlr_event.x_mm = transformed.x + wlr_output->lx + layout_box.x;
+ wlr_event.y_mm = transformed.y + wlr_output->ly + layout_box.y;
wl_signal_emit(&dev->pointer->events.motion_absolute, &wlr_event);
}
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index b798daf6..5a6e90b5 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -118,7 +118,6 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
xcb_configure_notify_event_t *ev = (xcb_configure_notify_event_t *)event;
wlr_output_update_size(&output->wlr_output, ev->width, ev->height);
- wl_signal_emit(&output->wlr_output.events.resolution, output);
// Move the pointer to its new location
xcb_query_pointer_cookie_t cookie =
@@ -267,8 +266,8 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
snprintf(output->wlr_output.name, sizeof(output->wlr_output.name), "X11-1");
output->win = xcb_generate_id(x11->xcb_conn);
- xcb_create_window(x11->xcb_conn, XCB_COPY_FROM_PARENT, output->win, x11->screen->root,
- 0, 0, 1024, 768, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ xcb_create_window(x11->xcb_conn, XCB_COPY_FROM_PARENT, output->win,
+ x11->screen->root, 0, 0, 1024, 768, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT,
x11->screen->root_visual, mask, values);
output->surf = wlr_egl_create_surface(&x11->egl, &output->win);
@@ -329,6 +328,17 @@ static struct wlr_backend_impl backend_impl = {
.get_egl = wlr_x11_backend_get_egl,
};
+static bool output_set_custom_mode(struct wlr_output *wlr_output, int32_t width,
+ int32_t height, int32_t refresh) {
+ struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
+ struct wlr_x11_backend *x11 = output->x11;
+
+ const uint32_t values[] = { width, height };
+ xcb_configure_window(x11->xcb_conn, output->win,
+ XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
+ return true;
+}
+
static void output_transform(struct wlr_output *wlr_output, enum wl_output_transform transform) {
struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
output->wlr_output.transform = transform;
@@ -362,6 +372,7 @@ static void output_swap_buffers(struct wlr_output *wlr_output) {
}
static struct wlr_output_impl output_impl = {
+ .set_custom_mode = output_set_custom_mode,
.transform = output_transform,
.destroy = output_destroy,
.make_current = output_make_current,