aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/backend.c9
-rw-r--r--backend/meson.build5
-rw-r--r--include/wlr/types/wlr_cursor.h25
-rw-r--r--include/wlr/types/wlr_xdg_shell.h3
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h3
-rw-r--r--include/xwayland/xwm.h1
-rw-r--r--meson.build64
-rw-r--r--meson_options.txt1
-rw-r--r--rootston/input.c3
-rw-r--r--rootston/output.c1
-rw-r--r--rootston/seat.c27
-rw-r--r--xwayland/selection.c97
12 files changed, 164 insertions, 75 deletions
diff --git a/backend/backend.c b/backend/backend.c
index c67be617..52344dac 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -11,9 +11,14 @@
#include <wlr/backend/multi.h>
#include <wlr/backend/session.h>
#include <wlr/backend/wayland.h>
-#include <wlr/backend/x11.h>
+#include <wlr/config.h>
#include <wlr/util/log.h>
+/* WLR_HAS_X11_BACKEND needs to be after wlr/config.h */
+#ifdef WLR_HAS_X11_BACKEND
+#include <wlr/backend/x11.h>
+#endif
+
void wlr_backend_init(struct wlr_backend *backend,
const struct wlr_backend_impl *impl) {
assert(backend);
@@ -94,6 +99,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
}
}
+#ifdef WLR_HAS_X11_BACKEND
const char *x11_display = getenv("DISPLAY");
if (x11_display) {
struct wlr_backend *x11_backend =
@@ -101,6 +107,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
wlr_multi_backend_add(backend, x11_backend);
return backend;
}
+#endif
// Attempt DRM+libinput
struct wlr_session *session = wlr_session_create(display);
diff --git a/backend/meson.build b/backend/meson.build
index c0ed76f1..a74ea024 100644
--- a/backend/meson.build
+++ b/backend/meson.build
@@ -24,7 +24,6 @@ backend_files = files(
'wayland/output.c',
'wayland/registry.c',
'wayland/wl_seat.c',
- 'x11/backend.c',
)
backend_deps = [
@@ -50,6 +49,10 @@ if conf_data.get('WLR_HAS_SYSTEMD', false)
backend_deps += systemd
endif
+if conf_data.get('WLR_HAS_X11_BACKEND', false)
+ backend_files += files('x11/backend.c')
+endif
+
if conf_data.get('WLR_HAS_ELOGIND', false)
backend_files += files('session/logind.c')
backend_deps += elogind
diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h
index da010972..70dca9f7 100644
--- a/include/wlr/types/wlr_cursor.h
+++ b/include/wlr/types/wlr_cursor.h
@@ -7,12 +7,37 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
+/**
+ * wlr_cursor implements the behavior of the "cursor", that is, the image on the
+ * screen typically moved about with a mouse or so. It provides tracking for
+ * this in global coordinates, and integrates with wlr_output,
+ * wlr_output_layout, and wlr_input_device. You can use it to abstract multiple
+ * input devices over a single cursor, constrain cursor movement to the usable
+ * area of a wlr_output_layout and communicate position updates to the hardware
+ * cursor, constrain specific input devices to specific outputs or regions of
+ * the screen, and so on.
+ */
+
struct wlr_cursor_state;
struct wlr_cursor {
struct wlr_cursor_state *state;
double x, y;
+ /**
+ * The interpretation of these signals is the responsibility of the
+ * compositor, but some helpers are provided for your benefit. If you
+ * receive a relative motion event, for example, you may want to call
+ * wlr_cursor_move. If you receive an absolute event, call
+ * wlr_cursor_warp_absolute. If you pass an input device into these
+ * functions, it will apply the region/output constraints associated with
+ * that device to the resulting cursor motion. If an output layout is
+ * attached, these functions will constrain the resulting cursor motion to
+ * within the usable space of the output layout.
+ *
+ * Re-broadcasting these signals to, for example, a wlr_seat, is also your
+ * responsibility.
+ */
struct {
struct wl_signal motion;
struct wl_signal motion_absolute;
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index 2724e0f7..a5cd3d54 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -40,6 +40,9 @@ struct wlr_xdg_popup {
bool committed;
struct wlr_xdg_surface *parent;
struct wlr_seat *seat;
+
+ // Position of the popup relative to the upper left corner of the window
+ // geometry of the parent surface
struct wlr_box geometry;
struct wl_list grab_link; // wlr_xdg_popup_grab::popups
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index 67d937fe..c6820f01 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -40,6 +40,9 @@ struct wlr_xdg_popup_v6 {
bool committed;
struct wlr_xdg_surface_v6 *parent;
struct wlr_seat *seat;
+
+ // Position of the popup relative to the upper left corner of the window
+ // geometry of the parent surface
struct wlr_box geometry;
struct wl_list grab_link; // wlr_xdg_popup_grab_v6::popups
diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h
index 4b15cc84..9e21ea3a 100644
--- a/include/xwayland/xwm.h
+++ b/include/xwayland/xwm.h
@@ -2,6 +2,7 @@
#define XWAYLAND_XWM_H
#include <wayland-server-core.h>
+#include <wlr/config.h>
#include <wlr/xwayland.h>
#include <xcb/render.h>
diff --git a/meson.build b/meson.build
index c7ca038c..7740b416 100644
--- a/meson.build
+++ b/meson.build
@@ -58,14 +58,6 @@ libinput = dependency('libinput', version: '>=1.7.0')
xkbcommon = dependency('xkbcommon')
udev = dependency('libudev')
pixman = dependency('pixman-1')
-xcb = dependency('xcb')
-xcb_composite = dependency('xcb-composite')
-xcb_xfixes = dependency('xcb-xfixes')
-xcb_image = dependency('xcb-image')
-xcb_render = dependency('xcb-render')
-xcb_icccm = dependency('xcb-icccm', required: false)
-xcb_errors = dependency('xcb-errors', required: get_option('enable_xcb_errors') == 'true')
-x11_xcb = dependency('x11-xcb')
libcap = dependency('libcap', required: get_option('enable_libcap') == 'true')
systemd = dependency('libsystemd', required: get_option('enable_systemd') == 'true')
elogind = dependency('libelogind', required: get_option('enable_elogind') == 'true')
@@ -75,14 +67,6 @@ exclude_headers = []
wlr_parts = []
wlr_deps = []
-if xcb_icccm.found()
- conf_data.set('WLR_HAS_XCB_ICCCM', true)
-endif
-
-if xcb_errors.found() and get_option('enable_xcb_errors') != 'false'
- conf_data.set('WLR_HAS_XCB_ERRORS', true)
-endif
-
if libcap.found() and get_option('enable_libcap') != 'false'
conf_data.set('WLR_HAS_LIBCAP', true)
wlr_deps += libcap
@@ -97,6 +81,38 @@ if elogind.found() and get_option('enable_elogind') != 'false'
conf_data.set('WLR_HAS_ELOGIND', true)
endif
+if get_option('enable_x11_backend') or get_option('enable_xwayland')
+ xcb = dependency('xcb')
+ xcb_composite = dependency('xcb-composite')
+ xcb_xfixes = dependency('xcb-xfixes')
+ xcb_image = dependency('xcb-image')
+ xcb_render = dependency('xcb-render')
+ x11_xcb = dependency('x11-xcb')
+
+ xcb_icccm = dependency('xcb-icccm', required: false)
+ xcb_errors = dependency('xcb-errors', required: get_option('enable_xcb_errors') == 'true')
+
+ if xcb_icccm.found()
+ conf_data.set('WLR_HAS_XCB_ICCCM', true)
+ endif
+
+ if xcb_errors.found() and get_option('enable_xcb_errors') != 'false'
+ conf_data.set('WLR_HAS_XCB_ERRORS', true)
+ endif
+
+ wlr_deps += [
+ xcb,
+ xcb_composite,
+ x11_xcb,
+ ]
+else
+ add_project_arguments('-DMESA_EGL_NO_X11_HEADERS', language: 'c')
+endif
+
+if get_option('enable_x11_backend')
+ conf_data.set('WLR_HAS_X11_BACKEND', true)
+endif
+
if get_option('enable_xwayland')
subdir('xwayland')
wlr_parts += [lib_wlr_xwayland]
@@ -138,9 +154,6 @@ wlr_deps += [
xkbcommon,
udev,
pixman,
- xcb,
- xcb_composite,
- x11_xcb,
math,
]
@@ -168,12 +181,13 @@ summary = [
'----------------',
'wlroots @0@'.format(meson.project_version()),
'',
- ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)),
- ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)),
- ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)),
- ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)),
- ' xcb-icccm: @0@'.format(conf_data.get('WLR_HAS_XCB_ICCCM', false)),
- ' xcb-errors: @0@'.format(conf_data.get('WLR_HAS_XCB_ERRORS', false)),
+ ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)),
+ ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)),
+ ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)),
+ ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)),
+ ' x11_backend: @0@'.format(conf_data.get('WLR_HAS_X11_BACKEND', false)),
+ ' xcb-icccm: @0@'.format(conf_data.get('WLR_HAS_XCB_ICCCM', false)),
+ ' xcb-errors: @0@'.format(conf_data.get('WLR_HAS_XCB_ERRORS', false)),
'----------------',
''
]
diff --git a/meson_options.txt b/meson_options.txt
index 4812b6f8..9e8567d0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -3,3 +3,4 @@ option('enable_systemd', type: 'combo', choices: ['auto', 'true', 'false'], valu
option('enable_elogind', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind')
option('enable_xcb_errors', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Use xcb-errors util library')
option('enable_xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications')
+option('enable_x11_backend', type: 'boolean', value: true, description: 'Enable X11 backend')
diff --git a/rootston/input.c b/rootston/input.c
index 657b0946..3e1b06fb 100644
--- a/rootston/input.c
+++ b/rootston/input.c
@@ -2,10 +2,13 @@
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/backend/libinput.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/util/log.h>
#include <wlr/xcursor.h>
+#ifdef WLR_HAS_XWAYLAND
#include <wlr/xwayland.h>
+#endif
#include "rootston/config.h"
#include "rootston/input.h"
#include "rootston/keyboard.h"
diff --git a/rootston/output.c b/rootston/output.c
index 8d6444d6..52ece54d 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
+#include <wlr/config.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_output_layout.h>
diff --git a/rootston/seat.c b/rootston/seat.c
index d2d211ba..bdcad5c7 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -723,6 +723,33 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
wl_list_insert(&seat->input->server->desktop->views, &view->link);
}
+
+ bool unfullscreen = true;
+
+#ifdef WLR_HAS_XWAYLAND
+ if (view && view->type == ROOTS_XWAYLAND_VIEW &&
+ view->xwayland_surface->override_redirect) {
+ unfullscreen = false;
+ }
+#endif
+
+ if (view && unfullscreen) {
+ struct roots_desktop *desktop = view->desktop;
+ struct roots_output *output;
+ struct wlr_box box;
+ view_get_box(view, &box);
+ wl_list_for_each(output, &desktop->outputs, link) {
+ if (output->fullscreen_view &&
+ output->fullscreen_view != view &&
+ wlr_output_layout_intersects(
+ desktop->layout,
+ output->wlr_output, &box)) {
+ view_set_fullscreen(output->fullscreen_view,
+ false, NULL);
+ }
+ }
+ }
+
struct roots_view *prev_focus = roots_seat_get_focus(seat);
if (view == prev_focus) {
return;
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 1d390026..72f3de3e 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -47,7 +47,21 @@ static int xwm_selection_flush_source_data(struct wlr_xwm_selection *selection)
return length;
}
-static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
+static void xwm_data_source_remove_property_source(
+ struct wlr_xwm_selection *selection) {
+ if (selection->property_source) {
+ wl_event_source_remove(selection->property_source);
+ }
+ selection->property_source = NULL;
+}
+
+static void xwm_data_source_close_source_fd(
+ struct wlr_xwm_selection *selection) {
+ close(selection->source_fd);
+ selection->source_fd = -1;
+}
+
+static int xwm_data_source_read(int fd, uint32_t mask, void *data) {
struct wlr_xwm_selection *selection = data;
struct wlr_xwm *xwm = selection->xwm;
@@ -72,13 +86,13 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
}
wlr_log(L_DEBUG, "read %d (available %d, mask 0x%x) bytes: \"%.*s\"",
- len, available, mask, len, (char *) p);
+ len, available, mask, len, (char *) p);
selection->source_data.size = current + len;
if (selection->source_data.size >= incr_chunk_size) {
if (!selection->incr) {
wlr_log(L_DEBUG, "got %zu bytes, starting incr",
- selection->source_data.size);
+ selection->source_data.size);
selection->incr = 1;
xcb_change_property(xwm->xcb_conn,
XCB_PROP_MODE_REPLACE,
@@ -89,20 +103,17 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
1, &incr_chunk_size);
selection->property_set = true;
selection->flush_property_on_delete = 1;
- wl_event_source_remove(selection->property_source);
- selection->property_source = NULL;
+ xwm_data_source_remove_property_source(selection);
xwm_selection_send_notify(selection, selection->request.property);
} else if (selection->property_set) {
- wlr_log(L_DEBUG, "got %zu bytes, waiting for "
- "property delete", selection->source_data.size);
+ wlr_log(L_DEBUG, "got %zu bytes, waiting for property delete",
+ selection->source_data.size);
selection->flush_property_on_delete = 1;
- wl_event_source_remove(selection->property_source);
- selection->property_source = NULL;
+ xwm_data_source_remove_property_source(selection);
} else {
- wlr_log(L_DEBUG, "got %zu bytes, "
- "property deleted, setting new property",
- selection->source_data.size);
+ wlr_log(L_DEBUG, "got %zu bytes, property deleted, setting new "
+ "property", selection->source_data.size);
xwm_selection_flush_source_data(selection);
}
} else if (len == 0 && !selection->incr) {
@@ -111,9 +122,8 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
xwm_selection_flush_source_data(selection);
xwm_selection_send_notify(selection, selection->request.property);
xcb_flush(xwm->xcb_conn);
- wl_event_source_remove(selection->property_source);
- selection->property_source = NULL;
- close(fd);
+ xwm_data_source_remove_property_source(selection);
+ xwm_data_source_close_source_fd(selection);
wl_array_release(&selection->source_data);
selection->request.requestor = XCB_NONE;
} else if (len == 0 && selection->incr) {
@@ -121,20 +131,16 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
selection->flush_property_on_delete = 1;
if (selection->property_set) {
- wlr_log(L_DEBUG, "got %zu bytes, waiting for "
- "property delete", selection->source_data.size);
+ wlr_log(L_DEBUG, "got %zu bytes, waiting for property delete",
+ selection->source_data.size);
} else {
- wlr_log(L_DEBUG, "got %zu bytes, "
- "property deleted, setting new property",
- selection->source_data.size);
+ wlr_log(L_DEBUG, "got %zu bytes, property deleted, setting new "
+ "property", selection->source_data.size);
xwm_selection_flush_source_data(selection);
}
xcb_flush(xwm->xcb_conn);
- wl_event_source_remove(selection->property_source);
- selection->property_source = NULL;
- close(selection->source_fd);
- selection->source_fd = -1;
- close(fd);
+ xwm_data_source_remove_property_source(selection);
+ xwm_data_source_close_source_fd(selection);
} else {
wlr_log(L_DEBUG, "nothing happened, buffered the bytes");
}
@@ -143,9 +149,8 @@ static int xwm_read_data_source(int fd, uint32_t mask, void *data) {
error_out:
xwm_selection_send_notify(selection, XCB_ATOM_NONE);
- wl_event_source_remove(selection->property_source);
- selection->property_source = NULL;
- close(fd);
+ xwm_data_source_remove_property_source(selection);
+ xwm_data_source_close_source_fd(selection);
wl_array_release(&selection->source_data);
return 0;
}
@@ -191,9 +196,7 @@ static void xwm_selection_send_data(struct wlr_xwm_selection *selection,
struct wl_event_loop *loop =
wl_display_get_event_loop(selection->xwm->xwayland->wl_display);
selection->property_source = wl_event_loop_add_fd(loop,
- selection->source_fd,
- WL_EVENT_READABLE,
- xwm_read_data_source,
+ selection->source_fd, WL_EVENT_READABLE, xwm_data_source_read,
selection);
xwm_selection_source_send(selection, mime_type, p[1]);
@@ -371,7 +374,13 @@ static void xwm_handle_selection_request(struct wlr_xwm *xwm,
}
}
-static int writable_callback(int fd, uint32_t mask, void *data) {
+static void xwm_data_source_destroy_property_reply(
+ struct wlr_xwm_selection *selection) {
+ free(selection->property_reply);
+ selection->property_reply = NULL;
+}
+
+static int xwm_data_source_write(int fd, uint32_t mask, void *data) {
struct wlr_xwm_selection *selection = data;
struct wlr_xwm *xwm = selection->xwm;
@@ -381,13 +390,9 @@ static int writable_callback(int fd, uint32_t mask, void *data) {
int len = write(fd, property + selection->property_start, remainder);
if (len == -1) {
- free(selection->property_reply);
- selection->property_reply = NULL;
- if (selection->property_source) {
- wl_event_source_remove(selection->property_source);
- }
- selection->property_source = NULL;
- close(fd);
+ xwm_data_source_destroy_property_reply(selection);
+ xwm_data_source_remove_property_source(selection);
+ xwm_data_source_close_source_fd(selection);
wlr_log(L_ERROR, "write error to target fd: %m");
return 1;
}
@@ -398,12 +403,8 @@ static int writable_callback(int fd, uint32_t mask, void *data) {
selection->property_start += len;
if (len == remainder) {
- free(selection->property_reply);
- selection->property_reply = NULL;
- if (selection->property_source) {
- wl_event_source_remove(selection->property_source);
- }
- selection->property_source = NULL;
+ xwm_data_source_destroy_property_reply(selection);
+ xwm_data_source_remove_property_source(selection);
if (selection->incr) {
xcb_delete_property(xwm->xcb_conn,
@@ -411,7 +412,7 @@ static int writable_callback(int fd, uint32_t mask, void *data) {
xwm->atoms[WL_SELECTION]);
} else {
wlr_log(L_DEBUG, "transfer complete");
- close(fd);
+ xwm_data_source_close_source_fd(selection);
}
}
@@ -422,13 +423,13 @@ static void xwm_write_property(struct wlr_xwm_selection *selection,
xcb_get_property_reply_t *reply) {
selection->property_start = 0;
selection->property_reply = reply;
- writable_callback(selection->source_fd, WL_EVENT_WRITABLE, selection);
+ xwm_data_source_write(selection->source_fd, WL_EVENT_WRITABLE, selection);
if (selection->property_reply) {
struct wl_event_loop *loop =
wl_display_get_event_loop(selection->xwm->xwayland->wl_display);
selection->property_source = wl_event_loop_add_fd(loop,
- selection->source_fd, WL_EVENT_WRITABLE, writable_callback,
+ selection->source_fd, WL_EVENT_WRITABLE, xwm_data_source_write,
selection);
}
}