aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.travis.yml8
-rw-r--r--backend/drm/backend.c1
-rw-r--r--backend/drm/drm.c2
-rw-r--r--backend/meson.build4
-rw-r--r--include/rootston/cursor.h2
-rw-r--r--include/rootston/seat.h8
-rw-r--r--include/rootston/view.h19
-rw-r--r--include/wlr/render/matrix.h4
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--meson.build44
-rw-r--r--render/gles2/renderer.c2
-rw-r--r--render/matrix.c49
-rw-r--r--rootston/cursor.c103
-rw-r--r--rootston/desktop.c93
-rw-r--r--rootston/output.c91
-rw-r--r--rootston/seat.c50
-rw-r--r--rootston/xwayland.c7
-rw-r--r--types/wlr_data_device.c7
-rw-r--r--types/wlr_keyboard.c4
-rw-r--r--types/wlr_output.c11
-rw-r--r--types/wlr_output_layout.c3
22 files changed, 416 insertions, 100 deletions
diff --git a/.gitignore b/.gitignore
index d4edde88..48945461 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,12 +4,10 @@ Makefile
cmake_install.cmake
install_manifest.txt
.clang_complete
-*.swp
*.o
*.a
bin/
test/
build/
-.lvimrc
wayland-*-protocol.*
wlr-example.ini
diff --git a/.travis.yml b/.travis.yml
index f6bbd7f4..0028de93 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,12 @@ compiler:
- gcc
- clang
+# Settings to try
+env:
+ matrix:
+ - OPTIONS="-Denable_libcap=true -Denable_systemd=true -Denable_elogind=false -Denable_xwayland=true"
+ - OPTIONS="-Denable_libcap=false -Denable_systemd=false -Denable_elogind=false -Denable_xwayland=false"
+
arch:
packages:
- meson
@@ -19,7 +25,7 @@ arch:
- xcb-util-image
- libcap
script:
- - "meson build"
+ - "meson build $OPTIONS"
- "ninja -C build"
script:
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 0cb64930..de69dad5 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -175,6 +175,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
return &drm->backend;
error_event:
+ wl_list_remove(&drm->session_signal.link);
wl_event_source_remove(drm->drm_event);
error_fd:
wlr_session_close_file(drm->session, drm->fd);
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 47bd4e3a..63a6e2da 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -459,7 +459,7 @@ static bool wlr_drm_connector_set_mode(struct wlr_output *output,
if (!crtc) {
return false;
}
- wlr_log(L_DEBUG, "%s: crtc=%ju ovr=%jd pri=%jd cur=%jd", conn->output.name,
+ wlr_log(L_DEBUG, "%s: crtc=%td ovr=%td pri=%td cur=%td", conn->output.name,
crtc - drm->crtcs,
crtc->overlay ? crtc->overlay - drm->overlay_planes : -1,
crtc->primary ? crtc->primary - drm->primary_planes : -1,
diff --git a/backend/meson.build b/backend/meson.build
index b8084448..173b65f6 100644
--- a/backend/meson.build
+++ b/backend/meson.build
@@ -33,11 +33,11 @@ else
backend_files += files('session/direct.c')
endif
-if systemd.found()
+if systemd.found() and get_option('enable_systemd')
backend_files += files('session/logind.c')
endif
-if elogind.found()
+if elogind.found() and get_option('enable_elogind')
backend_files += files('session/logind.c')
endif
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h
index 19ac4034..90d54c12 100644
--- a/include/rootston/cursor.h
+++ b/include/rootston/cursor.h
@@ -27,6 +27,8 @@ struct roots_cursor {
float view_rotation;
uint32_t resize_edges;
+ struct roots_seat_view *pointer_view;
+
struct wl_listener motion;
struct wl_listener motion_absolute;
struct wl_listener button;
diff --git a/include/rootston/seat.h b/include/rootston/seat.h
index cf5dd3b2..966d98e5 100644
--- a/include/rootston/seat.h
+++ b/include/rootston/seat.h
@@ -28,6 +28,11 @@ struct roots_seat {
struct roots_seat_view {
struct roots_seat *seat;
struct roots_view *view;
+
+ bool has_button_grab;
+ double grab_sx;
+ double grab_sy;
+
struct wl_list link; // roots_seat::views
struct wl_listener view_destroy;
@@ -84,4 +89,7 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view);
+struct roots_seat_view *roots_seat_view_from_view( struct roots_seat *seat,
+ struct roots_view *view);
+
#endif
diff --git a/include/rootston/view.h b/include/rootston/view.h
index 579b148a..e1172bca 100644
--- a/include/rootston/view.h
+++ b/include/rootston/view.h
@@ -51,7 +51,9 @@ struct roots_xwayland_surface {
enum roots_view_type {
ROOTS_WL_SHELL_VIEW,
ROOTS_XDG_SHELL_V6_VIEW,
+#ifdef WLR_HAS_XWAYLAND
ROOTS_XWAYLAND_VIEW,
+#endif
};
struct roots_view {
@@ -61,6 +63,10 @@ struct roots_view {
double x, y;
float rotation;
+ bool decorated;
+ int border_width;
+ int titlebar_height;
+
bool maximized;
struct roots_output *fullscreen_output;
struct {
@@ -126,4 +132,17 @@ bool view_center(struct roots_view *view);
void view_setup(struct roots_view *view);
void view_teardown(struct roots_view *view);
+void view_get_deco_box(const struct roots_view *view, struct wlr_box *box);
+
+enum roots_deco_part {
+ ROOTS_DECO_PART_NONE = 0,
+ ROOTS_DECO_PART_TOP_BORDER = (1 << 0),
+ ROOTS_DECO_PART_BOTTOM_BORDER = (1 << 1),
+ ROOTS_DECO_PART_LEFT_BORDER = (1 << 2),
+ ROOTS_DECO_PART_RIGHT_BORDER = (1 << 3),
+ ROOTS_DECO_PART_TITLEBAR = (1 << 4),
+};
+
+enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy);
+
#endif
diff --git a/include/wlr/render/matrix.h b/include/wlr/render/matrix.h
index 0b35aad3..a333bf0f 100644
--- a/include/wlr/render/matrix.h
+++ b/include/wlr/render/matrix.h
@@ -2,6 +2,7 @@
#define WLR_RENDER_MATRIX_H
#include <stdint.h>
+#include <wlr/types/wlr_box.h>
void wlr_matrix_identity(float (*output)[16]);
void wlr_matrix_translate(float (*output)[16], float x, float y, float z);
@@ -14,5 +15,8 @@ void wlr_matrix_transform(float mat[static 16],
enum wl_output_transform transform);
void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
enum wl_output_transform transform);
+void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
+ enum wl_output_transform transform, float rotation, float
+ (*projection)[16]);
#endif
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 71463cb5..55431ab1 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -89,6 +89,8 @@ struct wlr_output {
struct wlr_surface;
void wlr_output_enable(struct wlr_output *output, bool enable);
+void wlr_output_create_global(struct wlr_output *output);
+void wlr_output_destroy_global(struct wlr_output *output);
bool wlr_output_set_mode(struct wlr_output *output,
struct wlr_output_mode *mode);
bool wlr_output_set_custom_mode(struct wlr_output *output, int32_t width,
diff --git a/meson.build b/meson.build
index aee4b11b..55b07efa 100644
--- a/meson.build
+++ b/meson.build
@@ -153,6 +153,22 @@ wlroots = declare_dependency(
include_directories: wlr_inc,
)
+
+summary = [
+ '',
+ '----------------',
+ 'wlroots @0@'.format(meson.project_version()),
+ '',
+ ' libcap: @0@'.format(get_option('enable_libcap')),
+ ' systemd: @0@'.format(get_option('enable_systemd')),
+ ' elogind: @0@'.format(get_option('enable_elogind')),
+ ' xwayland: @0@'.format(get_option('enable_xwayland')),
+ '----------------',
+ ''
+]
+message('\n'.join(summary))
+
+
subdir('rootston')
subdir('examples')
@@ -164,3 +180,31 @@ pkgconfig.generate(
name: meson.project_name(),
description: 'Wayland compositor library',
)
+
+git = find_program('git', required: false)
+if git.found()
+ all_files = run_command(
+ git,
+ ['--git-dir=@0@/.git'.format(meson.source_root()),
+ 'ls-files',
+ ':/*.[ch]'])
+ all_files = files(all_files.stdout().split())
+
+ etags = find_program('etags', required: false)
+ if etags.found() and all_files.length() > 0
+ custom_target('etags',
+ build_by_default: true,
+ input: all_files,
+ output: 'TAGS',
+ command: [etags.path(), '-o', 'TAGS'] + all_files)
+ endif
+
+ ctags = find_program('ctags', required: false)
+ if ctags.found() and all_files.length() > 0
+ custom_target('ctags',
+ build_by_default: true,
+ input: all_files,
+ output: 'tags',
+ command: [ctags.path(), '-o', 'tags'] + all_files)
+ endif
+endif
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c
index cc06ad08..8c5b81ad 100644
--- a/render/gles2/renderer.c
+++ b/render/gles2/renderer.c
@@ -177,7 +177,7 @@ static bool wlr_gles2_render_texture(struct wlr_renderer *_renderer,
static void wlr_gles2_render_quad(struct wlr_renderer *renderer,
const float (*color)[4], const float (*matrix)[16]) {
GL_CALL(glUseProgram(shaders.quad));
- GL_CALL(glUniformMatrix4fv(0, 1, GL_TRUE, *matrix));
+ GL_CALL(glUniformMatrix4fv(0, 1, GL_FALSE, *matrix));
GL_CALL(glUniform4f(1, (*color)[0], (*color)[1], (*color)[2], (*color)[3]));
draw_quad();
}
diff --git a/render/matrix.c b/render/matrix.c
index 54dba4cc..9a1b2bb4 100644
--- a/render/matrix.c
+++ b/render/matrix.c
@@ -1,6 +1,8 @@
#include <string.h>
#include <math.h>
#include <wayland-server-protocol.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_output.h>
#include <wlr/render/matrix.h>
/* Obtains the index for the given row/column */
@@ -158,3 +160,50 @@ void wlr_matrix_texture(float mat[static 16], int32_t width, int32_t height,
mat[10] = 1.0f;
mat[15] = 1.0f;
}
+
+void wlr_matrix_project_box(float (*mat)[16], struct wlr_box *box,
+ enum wl_output_transform transform, float rotation,
+ float (*projection)[16]) {
+ int x = box->x;
+ int y = box->y;
+ int width = box->width;
+ int height = box->height;
+
+ float translate_center[16];
+ wlr_matrix_translate(&translate_center,
+ (int)x + width / 2, (int)y + height / 2, 0);
+
+ float rotate[16];
+ wlr_matrix_rotate(&rotate, rotation);
+
+ float translate_origin[16];
+ wlr_matrix_translate(&translate_origin, -width / 2,
+ -height / 2, 0);
+
+ float scale[16];
+ wlr_matrix_scale(&scale, width, height, 1);
+
+ wlr_matrix_mul(&translate_center, &rotate, mat);
+ wlr_matrix_mul(mat, &translate_origin, mat);
+ wlr_matrix_mul(mat, &scale, mat);
+
+ if (transform != WL_OUTPUT_TRANSFORM_NORMAL) {
+ float surface_translate_center[16];
+ wlr_matrix_translate(&surface_translate_center, 0.5, 0.5, 0);
+
+ float surface_transform[16];
+ wlr_matrix_transform(surface_transform,
+ wlr_output_transform_invert(transform));
+
+ float surface_translate_origin[16];
+ wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0);
+
+ wlr_matrix_mul(mat, &surface_translate_center,
+ mat);
+ wlr_matrix_mul(mat, &surface_transform, mat);
+ wlr_matrix_mul(mat, &surface_translate_origin,
+ mat);
+ }
+
+ wlr_matrix_mul(projection, mat, mat);
+}
diff --git a/rootston/cursor.c b/rootston/cursor.c
index 8bd514cc..d8753f44 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -30,19 +30,93 @@ void roots_cursor_destroy(struct roots_cursor *cursor) {
// TODO
}
+static void seat_view_deco_motion(struct roots_seat_view *view, double deco_sx, double deco_sy) {
+ struct roots_cursor *cursor = view->seat->cursor;
+
+ double sx = deco_sx;
+ double sy = deco_sy;
+ if (view->has_button_grab) {
+ sx = view->grab_sx;
+ sy = view->grab_sy;
+ }
+
+ enum roots_deco_part parts = view_get_deco_part(view->view, sx, sy);
+
+ bool is_titlebar = (parts & ROOTS_DECO_PART_TITLEBAR);
+ uint32_t edges = 0;
+ if (parts & ROOTS_DECO_PART_LEFT_BORDER) {
+ edges |= WLR_EDGE_LEFT;
+ } else if (parts & ROOTS_DECO_PART_RIGHT_BORDER) {
+ edges |= WLR_EDGE_RIGHT;
+ } else if (parts & ROOTS_DECO_PART_BOTTOM_BORDER) {
+ edges |= WLR_EDGE_BOTTOM;
+ } else if (parts & ROOTS_DECO_PART_TOP_BORDER) {
+ edges |= WLR_EDGE_TOP;
+ }
+
+ if (view->has_button_grab) {
+ if (is_titlebar) {
+ roots_seat_begin_move(view->seat, view->view);
+ } else if (edges) {
+ roots_seat_begin_resize(view->seat, view->view, edges);
+ }
+ view->has_button_grab = false;
+ } else {
+ if (is_titlebar) {
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ cursor->default_xcursor, cursor->cursor);
+ } else if (edges) {
+ const char *resize_name = wlr_xcursor_get_resize_name(edges);
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ resize_name, cursor->cursor);
+ }
+ }
+}
+
+static void seat_view_deco_leave(struct roots_seat_view *view) {
+ struct roots_cursor *cursor = view->seat->cursor;
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ cursor->default_xcursor, cursor->cursor);
+ view->has_button_grab = false;
+}
+
+static void seat_view_deco_button(struct roots_seat_view *view, double sx,
+ double sy, uint32_t button, uint32_t state) {
+ if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED) {
+ view->has_button_grab = true;
+ view->grab_sx = sx;
+ view->grab_sy = sy;
+ } else {
+ view->has_button_grab = false;
+ }
+
+ enum roots_deco_part parts = view_get_deco_part(view->view, sx, sy);
+ if (state == WLR_BUTTON_RELEASED && (parts & ROOTS_DECO_PART_TITLEBAR)) {
+ struct roots_cursor *cursor = view->seat->cursor;
+ wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
+ cursor->default_xcursor, cursor->cursor);
+ }
+}
+
static void roots_cursor_update_position(struct roots_cursor *cursor,
uint32_t time) {
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
struct roots_seat *seat = cursor->seat;
struct roots_view *view;
- struct wlr_surface *surface;
+ struct wlr_surface *surface = NULL;
double sx, sy;
switch (cursor->mode) {
case ROOTS_CURSOR_PASSTHROUGH:
view = desktop_view_at(desktop, cursor->cursor->x, cursor->cursor->y,
&surface, &sx, &sy);
- bool set_compositor_cursor = !view && cursor->cursor_client;
- if (view) {
+ struct roots_seat_view *seat_view =
+ roots_seat_view_from_view(seat, view);
+ if (cursor->pointer_view && (surface || seat_view != cursor->pointer_view)) {
+ seat_view_deco_leave(cursor->pointer_view);
+ cursor->pointer_view = NULL;
+ }
+ bool set_compositor_cursor = !view && !surface && cursor->cursor_client;
+ if (view && surface) {
struct wl_client *view_client =
wl_resource_get_client(view->wlr_surface->resource);
set_compositor_cursor = view_client != cursor->cursor_client;
@@ -52,7 +126,13 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
cursor->default_xcursor, cursor->cursor);
cursor->cursor_client = NULL;
}
- if (view) {
+ if (view && !surface) {
+ if (seat_view) {
+ cursor->pointer_view = seat_view;
+ seat_view_deco_motion(seat_view, sx, sy);
+ }
+ } if (view && surface) {
+ // motion over a view surface
wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy);
wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy);
} else {
@@ -131,7 +211,7 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
struct roots_desktop *desktop = seat->input->server->desktop;
bool is_touch = device->type == WLR_INPUT_DEVICE_TOUCH;
- struct wlr_surface *surface;
+ struct wlr_surface *surface = NULL;
double sx, sy;
struct roots_view *view =
desktop_view_at(desktop, lx, ly, &surface, &sx, &sy);
@@ -166,6 +246,13 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
}
return;
}
+
+ if (view && !surface) {
+ if (cursor->pointer_view) {
+ seat_view_deco_button(cursor->pointer_view, sx, sy, button, state);
+ }
+ }
+
if (state == WLR_BUTTON_RELEASED &&
cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {
cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
@@ -174,8 +261,10 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
}
}
- if (!is_touch) {
- wlr_seat_pointer_notify_button(seat->seat, time, button, state);
+ if (view && surface) {
+ if (!is_touch) {
+ wlr_seat_pointer_notify_button(seat->seat, time, button, state);
+ }
}
switch (state) {
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 5d400c10..435e9426 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -19,6 +19,7 @@
#include "rootston/server.h"
#include "rootston/seat.h"
#include "rootston/xcursor.h"
+#include "rootston/view.h"
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x;
@@ -31,6 +32,55 @@ void view_get_box(const struct roots_view *view, struct wlr_box *box) {
}
}
+void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
+ view_get_box(view, box);
+ if (!view->decorated) {
+ return;
+ }
+
+ box->x -= view->border_width;
+ box->y -= (view->border_width + view->titlebar_height);
+ box->width += view->border_width * 2;
+ box->height += (view->border_width * 2 + view->titlebar_height);
+}
+
+enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy) {
+ if (!view->decorated) {
+ return ROOTS_DECO_PART_NONE;
+ }
+
+ int sw = view->wlr_surface->current->width;
+ int sh = view->wlr_surface->current->height;
+ int bw = view->border_width;
+ int titlebar_h = view->titlebar_height;
+
+ if (sx > 0 && sx < sw && sy < 0 && sy > -view->titlebar_height) {
+ return ROOTS_DECO_PART_TITLEBAR;
+ }
+
+ enum roots_deco_part parts = 0;
+ if (sy >= -(titlebar_h + bw) &&
+ sy <= sh + bw) {
+ if (sx < 0 && sx > -bw) {
+ parts |= ROOTS_DECO_PART_LEFT_BORDER;
+ } else if (sx > sw && sx < sw + bw) {
+ parts |= ROOTS_DECO_PART_RIGHT_BORDER;
+ }
+ }
+
+ if (sx >= -bw && sx <= sw + bw) {
+ if (sy > sh && sy <= sh + bw) {
+ parts |= ROOTS_DECO_PART_BOTTOM_BORDER;
+ } else if (sy >= -(titlebar_h + bw) && sy < 0) {
+ parts |= ROOTS_DECO_PART_TOP_BORDER;
+ }
+ }
+
+ // TODO corners
+
+ return parts;
+}
+
static void view_update_output(const struct roots_view *view,
const struct wlr_box *before) {
struct roots_desktop *desktop = view->desktop;
@@ -347,6 +397,13 @@ static bool view_at(struct roots_view *view, double lx, double ly,
return true;
}
+ if (view_get_deco_part(view, view_sx, view_sy)) {
+ *sx = view_sx;
+ *sy = view_sy;
+ *surface = NULL;
+ return true;
+ }
+
if (wlr_box_contains_point(&box, view_sx, view_sy) &&
pixman_region32_contains_point(&view->wlr_surface->current->input,
view_sx, view_sy, NULL)) {
@@ -433,6 +490,24 @@ struct roots_desktop *desktop_create(struct roots_server *server,
desktop->server = server;
desktop->config = config;
+ desktop->layout = wlr_output_layout_create();
+ desktop->layout_change.notify = handle_layout_change;
+ wl_signal_add(&desktop->layout->events.change, &desktop->layout_change);
+
+ desktop->compositor = wlr_compositor_create(server->wl_display,
+ server->renderer);
+
+ desktop->xdg_shell_v6 = wlr_xdg_shell_v6_create(server->wl_display);
+ wl_signal_add(&desktop->xdg_shell_v6->events.new_surface,
+ &desktop->xdg_shell_v6_surface);
+ desktop->xdg_shell_v6_surface.notify = handle_xdg_shell_v6_surface;
+
+ desktop->wl_shell = wlr_wl_shell_create(server->wl_display);
+ wl_signal_add(&desktop->wl_shell->events.new_surface,
+ &desktop->wl_shell_surface);
+ desktop->wl_shell_surface.notify = handle_wl_shell_surface;
+
+#ifdef WLR_HAS_XWAYLAND
const char *cursor_theme = NULL;
const char *cursor_default = ROOTS_XCURSOR_DEFAULT;
struct roots_cursor_config *cc =
@@ -453,24 +528,6 @@ struct roots_desktop *desktop_create(struct roots_server *server,
return NULL;
}
- desktop->layout = wlr_output_layout_create();
- desktop->layout_change.notify = handle_layout_change;
- wl_signal_add(&desktop->layout->events.change, &desktop->layout_change);
-
- desktop->compositor = wlr_compositor_create(server->wl_display,
- server->renderer);
-
- desktop->xdg_shell_v6 = wlr_xdg_shell_v6_create(server->wl_display);
- wl_signal_add(&desktop->xdg_shell_v6->events.new_surface,
- &desktop->xdg_shell_v6_surface);
- desktop->xdg_shell_v6_surface.notify = handle_xdg_shell_v6_surface;
-
- desktop->wl_shell = wlr_wl_shell_create(server->wl_display);
- wl_signal_add(&desktop->wl_shell->events.new_surface,
- &desktop->wl_shell_surface);
- desktop->wl_shell_surface.notify = handle_wl_shell_surface;
-
-#ifdef WLR_HAS_XWAYLAND
if (config->xwayland) {
desktop->xwayland = wlr_xwayland_create(server->wl_display,
desktop->compositor);
diff --git a/rootston/output.c b/rootston/output.c
index c26ea36e..1fb848b9 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -52,47 +52,15 @@ static void render_surface(struct wlr_surface *surface,
.width = render_width, .height = render_height,
};
if (wlr_output_layout_intersects(desktop->layout, wlr_output, &render_box)) {
+ struct wlr_box project_box = {
+ .x = ox,
+ .y = oy,
+ .width = render_width,
+ .height = render_height,
+ };
float matrix[16];
-
- float translate_center[16];
- wlr_matrix_translate(&translate_center,
- (int)ox + render_width / 2, (int)oy + render_height / 2, 0);
-
- float rotate[16];
- wlr_matrix_rotate(&rotate, rotation);
-
- float translate_origin[16];
- wlr_matrix_translate(&translate_origin, -render_width / 2,
- -render_height / 2, 0);
-
- float scale[16];
- wlr_matrix_scale(&scale, render_width, render_height, 1);
-
- float transform[16];
- wlr_matrix_mul(&translate_center, &rotate, &transform);
- wlr_matrix_mul(&transform, &translate_origin, &transform);
- wlr_matrix_mul(&transform, &scale, &transform);
-
- if (surface->current->transform != WL_OUTPUT_TRANSFORM_NORMAL) {
- float surface_translate_center[16];
- wlr_matrix_translate(&surface_translate_center, 0.5, 0.5, 0);
-
- float surface_transform[16];
- wlr_matrix_transform(surface_transform,
- wlr_output_transform_invert(surface->current->transform));
-
- float surface_translate_origin[16];
- wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0);
-
- wlr_matrix_mul(&transform, &surface_translate_center,
- &transform);
- wlr_matrix_mul(&transform, &surface_transform, &transform);
- wlr_matrix_mul(&transform, &surface_translate_origin,
- &transform);
- }
-
- wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix);
-
+ wlr_matrix_project_box(&matrix, &project_box, surface->current->transform,
+ rotation, &wlr_output->transform_matrix);
wlr_render_with_matrix(desktop->server->renderer, surface->texture,
&matrix);
@@ -169,6 +137,7 @@ static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface,
}
}
+#ifdef WLR_HAS_XWAYLAND
static void render_xwayland_children(struct wlr_xwayland_surface *surface,
struct roots_desktop *desktop, struct wlr_output *wlr_output,
struct timespec *when) {
@@ -181,9 +150,45 @@ static void render_xwayland_children(struct wlr_xwayland_surface *surface,
render_xwayland_children(child, desktop, wlr_output, when);
}
}
+#endif
+
+static void render_decorations(struct roots_view *view,
+ struct roots_desktop *desktop, struct wlr_output *output) {
+ if (!view->decorated) {
+ return;
+ }
+ struct wlr_box deco_box;
+ view_get_deco_box(view, &deco_box);
+ double sx = deco_box.x - view->x;
+ double sy = deco_box.y - view->y;
+ rotate_child_position(&sx, &sy, deco_box.width, deco_box.height,
+ view->wlr_surface->current->width,
+ view->wlr_surface->current->height, view->rotation);
+ double ox = sx + view->x;
+ double oy = sy + view->y;
+
+ wlr_output_layout_output_coords(desktop->layout, output, &ox, &oy);
+ ox *= output->scale;
+ oy *= output->scale;
+
+ struct wlr_box project_box = {
+ .x = ox,
+ .y = oy,
+ .width = deco_box.width,
+ .height = deco_box.height,
+ };
+
+ float matrix[16];
+ wlr_matrix_project_box(&matrix, &project_box, WL_OUTPUT_TRANSFORM_NORMAL,
+ view->rotation, &output->transform_matrix);
+ float color[4] = { 0.2, 0.2, 0.2, 1 };
+ wlr_render_colored_quad(desktop->server->renderer, &color, &matrix);
+}
static void render_view(struct roots_view *view, struct roots_desktop *desktop,
struct wlr_output *wlr_output, struct timespec *when) {
+ render_decorations(view, desktop, wlr_output);
+
switch (view->type) {
case ROOTS_XDG_SHELL_V6_VIEW:
render_surface(view->wlr_surface, desktop, wlr_output, when,
@@ -195,10 +200,12 @@ static void render_view(struct roots_view *view, struct roots_desktop *desktop,
render_wl_shell_surface(view->wl_shell_surface, desktop, wlr_output,
when, view->x, view->y, view->rotation, false);
break;
+#ifdef WLR_HAS_XWAYLAND
case ROOTS_XWAYLAND_VIEW:
render_surface(view->wlr_surface, desktop, wlr_output, when,
view->x, view->y, view->rotation);
break;
+#endif
}
}
@@ -212,8 +219,10 @@ static bool has_standalone_surface(struct roots_view *view) {
return wl_list_empty(&view->xdg_surface_v6->popups);
case ROOTS_WL_SHELL_VIEW:
return wl_list_empty(&view->wl_shell_surface->popups);
+#ifdef WLR_HAS_XWAYLAND
case ROOTS_XWAYLAND_VIEW:
return wl_list_empty(&view->xwayland_surface->children);
+#endif
}
return true;
}
@@ -261,10 +270,12 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
// During normal rendering the xwayland window tree isn't traversed
// because all windows are rendered. Here we only want to render
// the fullscreen window's children so we have to traverse the tree.
+#ifdef WLR_HAS_XWAYLAND
if (view->type == ROOTS_XWAYLAND_VIEW) {
render_xwayland_children(view->xwayland_surface, desktop,
wlr_output, &now);
}
+#endif
}
wlr_renderer_end(server->renderer);
wlr_output_swap_buffers(wlr_output);
diff --git a/rootston/seat.c b/rootston/seat.c
index 1a0e6253..d7353d1e 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -573,6 +573,10 @@ static void seat_view_destroy(struct roots_seat_view *seat_view) {
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
}
+ if (seat_view == seat->cursor->pointer_view) {
+ seat->cursor->pointer_view = NULL;
+ }
+
wl_list_remove(&seat_view->view_destroy.link);
wl_list_remove(&seat_view->link);
free(seat_view);
@@ -601,7 +605,7 @@ static struct roots_seat_view *seat_add_view(struct roots_seat *seat,
seat_view->seat = seat;
seat_view->view = view;
- wl_list_insert(&seat->views, &seat_view->link);
+ wl_list_insert(seat->views.prev, &seat_view->link);
seat_view->view_destroy.notify = seat_view_handle_destroy;
wl_signal_add(&view->events.destroy, &seat_view->view_destroy);
@@ -609,6 +613,31 @@ static struct roots_seat_view *seat_add_view(struct roots_seat *seat,
return seat_view;
}
+struct roots_seat_view *roots_seat_view_from_view(
+ struct roots_seat *seat, struct roots_view *view) {
+ if (view == NULL) {
+ return NULL;
+ }
+
+ bool found = false;
+ struct roots_seat_view *seat_view = NULL;
+ wl_list_for_each(seat_view, &seat->views, link) {
+ if (seat_view->view == view) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ seat_view = seat_add_view(seat, view);
+ if (seat_view == NULL) {
+ wlr_log(L_ERROR, "Allocation failed");
+ return NULL;
+ }
+ }
+
+ return seat_view;
+}
+
void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
// Make sure the view will be rendered on top of others, even if it's
// already focused in this seat
@@ -622,26 +651,17 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
return;
}
+#ifdef WLR_HAS_XWAYLAND
if (view && view->type == ROOTS_XWAYLAND_VIEW &&
view->xwayland_surface->override_redirect) {
return;
}
-
+#endif
struct roots_seat_view *seat_view = NULL;
if (view != NULL) {
- bool found = false;
- wl_list_for_each(seat_view, &seat->views, link) {
- if (seat_view->view == view) {
- found = true;
- break;
- }
- }
- if (!found) {
- seat_view = seat_add_view(seat, view);
- if (seat_view == NULL) {
- wlr_log(L_ERROR, "Allocation failed");
- return;
- }
+ seat_view = roots_seat_view_from_view(seat, view);
+ if (seat_view == NULL) {
+ return;
}
}
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 3d84dc19..69c44add 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -296,6 +296,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->type = ROOTS_XWAYLAND_VIEW;
view->x = (double)surface->x;
view->y = (double)surface->y;
+
view->xwayland_surface = surface;
view->roots_xwayland_surface = roots_surface;
view->wlr_surface = surface->surface;
@@ -311,6 +312,12 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_list_insert(&desktop->views, &view->link);
if (!surface->override_redirect) {
+ if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {
+ view->decorated = true;
+ view->border_width = 4;
+ view->titlebar_height = 12;
+ }
+
view_setup(view);
}
}
diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c
index 5a6bc198..c359be79 100644
--- a/types/wlr_data_device.c
+++ b/types/wlr_data_device.c
@@ -173,16 +173,19 @@ static void data_offer_resource_destroy(struct wl_resource *resource) {
goto out;
}
- offer->source->offer = NULL;
-
// If the drag destination has version < 3, wl_data_offer.finish
// won't be called, so do this here as a safety net, because
// we still want the version >= 3 drag source to be happy.
if (wl_resource_get_version(offer->resource) <
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
data_source_notify_finish(offer->source);
+ offer->source->offer = NULL;
} else if (offer->source->dnd_finish) {
+ // source->cancel can free the source
+ offer->source->offer = NULL;
offer->source->cancel(offer->source);
+ } else {
+ offer->source->offer = NULL;
}
out:
diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c
index b0dc97aa..29552eb4 100644
--- a/types/wlr_keyboard.c
+++ b/types/wlr_keyboard.c
@@ -215,13 +215,13 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
}
kb->keymap_fd = os_create_anonymous_file(kb->keymap_size);
if (kb->keymap_fd < 0) {
- wlr_log(L_ERROR, "creating a keymap file for %lu bytes failed", kb->keymap_size);
+ wlr_log(L_ERROR, "creating a keymap file for %zu bytes failed", kb->keymap_size);
goto err;
}
void *ptr = mmap(NULL, kb->keymap_size,
PROT_READ | PROT_WRITE, MAP_SHARED, kb->keymap_fd, 0);
if (ptr == (void*)-1) {
- wlr_log(L_ERROR, "failed to mmap() %lu bytes", kb->keymap_size);
+ wlr_log(L_ERROR, "failed to mmap() %zu bytes", kb->keymap_size);
goto err;
}
strcpy(ptr, keymap_str);
diff --git a/types/wlr_output.c b/types/wlr_output.c
index b47fb3a0..426926ac 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -113,7 +113,7 @@ static void wl_output_bind(struct wl_client *wl_client, void *data,
wl_output_send_to_resource(wl_resource);
}
-static void wlr_output_create_global(struct wlr_output *output) {
+void wlr_output_create_global(struct wlr_output *output) {
if (output->wl_global != NULL) {
return;
}
@@ -122,7 +122,7 @@ static void wlr_output_create_global(struct wlr_output *output) {
output->wl_global = wl_global;
}
-static void wlr_output_destroy_global(struct wlr_output *output) {
+void wlr_output_destroy_global(struct wlr_output *output) {
if (output->wl_global == NULL) {
return;
}
@@ -140,13 +140,6 @@ void wlr_output_update_enabled(struct wlr_output *output, bool enabled) {
}
output->enabled = enabled;
-
- if (enabled) {
- wlr_output_create_global(output);
- } else {
- wlr_output_destroy_global(output);
- }
-
wl_signal_emit(&output->events.enable, output);
}
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c
index d1d67e7d..b01fb840 100644
--- a/types/wlr_output_layout.c
+++ b/types/wlr_output_layout.c
@@ -203,6 +203,7 @@ void wlr_output_layout_add(struct wlr_output_layout *layout,
l_output->y = y;
l_output->state->auto_configured = false;
wlr_output_layout_reconfigure(layout);
+ wlr_output_create_global(output);
wl_signal_emit(&layout->events.add, l_output);
}
@@ -289,6 +290,7 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout,
wlr_output_layout_output_destroy(l_output);
wlr_output_layout_reconfigure(layout);
}
+ wlr_output_destroy_global(output);
}
void wlr_output_layout_output_coords(struct wlr_output_layout *layout,
@@ -394,6 +396,7 @@ void wlr_output_layout_add_auto(struct wlr_output_layout *layout,
l_output->state->auto_configured = true;
wlr_output_layout_reconfigure(layout);
+ wlr_output_create_global(output);
wl_signal_emit(&layout->events.add, l_output);
}