aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-11-12 22:12:50 +0100
committeremersion <contact@emersion.fr>2017-11-12 22:12:50 +0100
commitf8b43940b1a14e78c5365c9c1d17bfc79f523530 (patch)
treead2aa347b862cc7446a1cc80f5932847e1491fbe /rootston
parent2e312a7e27fac0ef299abbdf5f66cf164992f02f (diff)
parenta317ecdab8ef8deb184b72db208794daa4c4a3a0 (diff)
Merge branch 'master' into cursor-scale
Diffstat (limited to 'rootston')
-rw-r--r--rootston/desktop.c24
-rw-r--r--rootston/main.c29
-rw-r--r--rootston/output.c43
-rw-r--r--rootston/seat.c8
4 files changed, 64 insertions, 40 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 51bb0e2a..1695d007 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -167,9 +167,22 @@ bool view_center(struct roots_view *view) {
view_get_box(view, &box);
struct roots_desktop *desktop = view->desktop;
+ struct roots_input *input = desktop->server->input;
+ struct roots_seat *seat = NULL, *_seat;
+ wl_list_for_each(_seat, &input->seats, link) {
+ if (!seat || (seat->seat->last_event.tv_sec > _seat->seat->last_event.tv_sec &&
+ seat->seat->last_event.tv_nsec > _seat->seat->last_event.tv_nsec)) {
+ seat = _seat;
+ }
+ }
+ if (!seat) {
+ return false;
+ }
struct wlr_output *output =
- wlr_output_layout_get_center_output(desktop->layout);
+ wlr_output_layout_output_at(desktop->layout,
+ seat->cursor->cursor->x,
+ seat->cursor->cursor->y);
if (!output) {
// empty layout
return false;
@@ -218,7 +231,7 @@ void view_teardown(struct roots_view *view) {
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
- for (int i = desktop->views->length - 1; i >= 0; --i) {
+ for (ssize_t i = desktop->views->length - 1; i >= 0; --i) {
struct roots_view *view = desktop->views->items[i];
if (view->type == ROOTS_WL_SHELL_VIEW &&
@@ -230,11 +243,12 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
double view_sx = lx - view->x;
double view_sy = ly - view->y;
+ struct wlr_surface_state *state = view->wlr_surface->current;
struct wlr_box box = {
.x = 0,
.y = 0,
- .width = view->wlr_surface->current->buffer_width,
- .height = view->wlr_surface->current->buffer_height,
+ .width = state->buffer_width / state->scale,
+ .height = state->buffer_height / state->scale,
};
if (view->rotation != 0.0) {
// Coordinates relative to the center of the view
@@ -248,7 +262,6 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
}
if (view->type == ROOTS_XDG_SHELL_V6_VIEW) {
- // TODO: test if this works with rotated views
double popup_sx, popup_sy;
struct wlr_xdg_surface_v6 *popup =
wlr_xdg_surface_v6_popup_at(view->xdg_surface_v6,
@@ -263,7 +276,6 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
}
if (view->type == ROOTS_WL_SHELL_VIEW) {
- // TODO: test if this works with rotated views
double popup_sx, popup_sy;
struct wlr_wl_shell_surface *popup =
wlr_wl_shell_surface_popup_at(view->wl_shell_surface,
diff --git a/rootston/main.c b/rootston/main.c
index d55bc682..365ff6e0 100644
--- a/rootston/main.c
+++ b/rootston/main.c
@@ -12,6 +12,18 @@
struct roots_server server = { 0 };
+static void ready(struct wl_listener *listener, void *data) {
+ if (server.config->startup_cmd != NULL) {
+ const char *cmd = server.config->startup_cmd;
+ pid_t pid = fork();
+ if (pid < 0) {
+ wlr_log(L_ERROR, "cannot execute binding command: fork() failed");
+ } else if (pid == 0) {
+ execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
+ }
+ }
+}
+
int main(int argc, char **argv) {
assert(server.config = roots_config_create_from_args(argc, argv));
assert(server.wl_display = wl_display_create());
@@ -43,17 +55,12 @@ int main(int argc, char **argv) {
}
setenv("WAYLAND_DISPLAY", socket, true);
-
- if (server.config->startup_cmd != NULL) {
- const char *cmd = server.config->startup_cmd;
- pid_t pid = fork();
- if (pid < 0) {
- wlr_log(L_ERROR, "cannot execute binding command: fork() failed");
- return 1;
- } else if (pid == 0) {
- execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
- }
- }
+#ifndef HAS_XWAYLAND
+ ready(NULL, NULL);
+#else
+ struct wl_listener xwayland_ready = { .notify = ready };
+ wl_signal_add(&server.desktop->xwayland->events.ready, &xwayland_ready);
+#endif
wl_display_run(server.wl_display);
wlr_backend_destroy(server.backend);
diff --git a/rootston/output.c b/rootston/output.c
index 3ed5a02c..145016b3 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -21,30 +21,33 @@ static void render_surface(struct wlr_surface *surface,
struct roots_desktop *desktop, struct wlr_output *wlr_output,
struct timespec *when, double lx, double ly, float rotation) {
if (surface->texture->valid) {
- float scale_factor = (float)wlr_output->scale / surface->current->scale;
- int width = surface->current->buffer_width * scale_factor;
- int height = surface->current->buffer_height * scale_factor;
+ double surface_scale = surface->current->scale;
+ double width = (double)surface->current->buffer_width / surface_scale;
+ double height = (double)surface->current->buffer_height / surface_scale;
+ int render_width = width * wlr_output->scale;
+ int render_height = height * wlr_output->scale;
double ox = lx, oy = ly;
wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy);
ox *= wlr_output->scale;
oy *= wlr_output->scale;
if (wlr_output_layout_intersects(desktop->layout, wlr_output,
- lx, ly, lx + width, ly + height)) {
+ lx, ly, lx + render_width, ly + render_height)) {
float matrix[16];
float translate_origin[16];
wlr_matrix_translate(&translate_origin,
- (int)ox + width / 2, (int)oy + height / 2, 0);
+ (int)ox + render_width / 2, (int)oy + render_height / 2, 0);
float rotate[16];
wlr_matrix_rotate(&rotate, rotation);
float translate_center[16];
- wlr_matrix_translate(&translate_center, -width / 2, -height / 2, 0);
+ wlr_matrix_translate(&translate_center, -render_width / 2,
+ -render_height / 2, 0);
float scale[16];
- wlr_matrix_scale(&scale, width, height, 1);
+ wlr_matrix_scale(&scale, render_width, render_height, 1);
float transform[16];
wlr_matrix_mul(&translate_origin, &rotate, &transform);
@@ -52,12 +55,12 @@ static void render_surface(struct wlr_surface *surface,
wlr_matrix_mul(&transform, &scale, &transform);
wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix);
- wlr_render_with_matrix(desktop->server->renderer,
- surface->texture, &matrix);
+ wlr_render_with_matrix(desktop->server->renderer, surface->texture,
+ &matrix);
struct wlr_frame_callback *cb, *cnext;
wl_list_for_each_safe(cb, cnext,
- &surface->current->frame_callback_list, link) {
+ &surface->current->frame_callback_list, link) {
wl_callback_send_done(cb->resource, timespec_to_msec(when));
wl_resource_destroy(cb->resource);
}
@@ -65,19 +68,20 @@ static void render_surface(struct wlr_surface *surface,
struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) {
- double sx = subsurface->surface->current->subsurface_position.x,
- sy = subsurface->surface->current->subsurface_position.y;
- double sw = subsurface->surface->current->buffer_width,
- sh = subsurface->surface->current->buffer_height;
+ struct wlr_surface_state *state = subsurface->surface->current;
+ double sx = state->subsurface_position.x;
+ double sy = state->subsurface_position.y;
+ double sw = state->buffer_width / state->scale;
+ double sh = state->buffer_height / state->scale;
if (rotation != 0.0) {
// Coordinates relative to the center of the subsurface
- double ox = sx - (double)width/2 + sw/2,
- oy = sy - (double)height/2 + sh/2;
+ double ox = sx - width/2 + sw/2,
+ oy = sy - height/2 + sh/2;
// Rotated coordinates
double rx = cos(-rotation)*ox - sin(-rotation)*oy,
ry = cos(-rotation)*oy + sin(-rotation)*ox;
- sx = rx + (double)width/2 - sw/2;
- sy = ry + (double)height/2 - sh/2;
+ sx = rx + width/2 - sw/2;
+ sy = ry + height/2 - sh/2;
}
render_surface(subsurface->surface, desktop, wlr_output, when,
@@ -104,7 +108,8 @@ static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface,
popup->popup_state->geometry.y - popup->geometry->y;
render_surface(popup->surface, desktop, wlr_output, when, popup_x,
popup_y, rotation);
- render_xdg_v6_popups(popup, desktop, wlr_output, when, popup_x, popup_y, rotation);
+ render_xdg_v6_popups(popup, desktop, wlr_output, when, popup_x, popup_y,
+ rotation);
}
}
diff --git a/rootston/seat.c b/rootston/seat.c
index 3ec6f1b7..6d8dc749 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -1,11 +1,9 @@
-#include <wayland-server.h>
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include <assert.h>
-
+#include <wayland-server.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
-
#include "rootston/xcursor.h"
#include "rootston/input.h"
#include "rootston/seat.h"
@@ -298,6 +296,8 @@ static void seat_add_keyboard(struct roots_seat *seat, struct wlr_input_device *
keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers;
wl_signal_add(&keyboard->device->keyboard->events.modifiers,
&keyboard->keyboard_modifiers);
+
+ wlr_seat_set_keyboard(seat->seat, device);
}
static void seat_add_pointer(struct roots_seat *seat, struct wlr_input_device *device) {