aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/wayland/wl_seat.c10
-rw-r--r--backend/x11/backend.c22
-rw-r--r--examples/screenshot.c22
-rw-r--r--include/backend/x11.h2
-rw-r--r--include/render/gles2.h2
-rw-r--r--include/rootston/output.h3
-rw-r--r--include/wlr/types/wlr_compositor.h1
-rw-r--r--include/wlr/types/wlr_idle.h4
-rw-r--r--include/wlr/types/wlr_output_layout.h15
-rw-r--r--include/wlr/util/log.h6
-rw-r--r--include/wlr/xwm.h3
-rw-r--r--meson.build3
-rw-r--r--rootston/output.c132
-rw-r--r--rootston/seat.c2
-rw-r--r--types/wlr_compositor.c2
-rw-r--r--types/wlr_idle.c6
-rw-r--r--types/wlr_output_layout.c49
-rw-r--r--types/wlr_primary_selection.c12
-rw-r--r--types/wlr_surface.c6
-rw-r--r--util/log.c2
-rw-r--r--wlroots.syms49
-rw-r--r--xwayland/xwm.c26
22 files changed, 313 insertions, 66 deletions
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index b1f7cff6..841e693d 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -163,10 +163,12 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
struct wlr_input_device *dev = data;
assert(dev && dev->keyboard);
- struct wlr_event_keyboard_key wlr_event;
- wlr_event.keycode = key;
- wlr_event.state = state;
- wlr_event.time_msec = time;
+ struct wlr_event_keyboard_key wlr_event = {
+ .keycode = key,
+ .state = state,
+ .time_msec = time,
+ .update_state = false,
+ };
wlr_keyboard_notify_key(dev->keyboard, &wlr_event);
}
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 28a4fcac..8633ece3 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -188,6 +188,17 @@ static void init_atom(struct wlr_x11_backend *x11, struct wlr_x11_atom *atom,
atom->reply = xcb_intern_atom_reply(x11->xcb_conn, atom->cookie, NULL);
}
+static void parse_xcb_setup(struct wlr_output *output, xcb_connection_t *xcb_conn) {
+ const xcb_setup_t *xcb_setup = xcb_get_setup(xcb_conn);
+
+ snprintf(output->make, sizeof(output->make), "%.*s",
+ xcb_setup_vendor_length(xcb_setup),
+ xcb_setup_vendor(xcb_setup));
+ snprintf(output->model, sizeof(output->model), "%"PRIu16".%"PRIu16,
+ xcb_setup->protocol_major_version,
+ xcb_setup->protocol_minor_version);
+}
+
static bool wlr_x11_backend_start(struct wlr_backend *backend) {
struct wlr_x11_backend *x11 = (struct wlr_x11_backend *)backend;
struct wlr_x11_output *output = &x11->output;
@@ -207,6 +218,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
wlr_output_init(&output->wlr_output, &x11->backend, &output_impl,
x11->wl_display);
snprintf(output->wlr_output.name, sizeof(output->wlr_output.name), "X11-1");
+ parse_xcb_setup(&output->wlr_output, x11->xcb_conn);
output->win = xcb_generate_id(x11->xcb_conn);
xcb_create_window(x11->xcb_conn, XCB_COPY_FROM_PARENT, output->win,
@@ -221,11 +233,21 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
init_atom(x11, &x11->atoms.wm_protocols, 1, "WM_PROTOCOLS");
init_atom(x11, &x11->atoms.wm_delete_window, 0, "WM_DELETE_WINDOW");
+ init_atom(x11, &x11->atoms.net_wm_name, 1, "_NET_WM_NAME");
+ init_atom(x11, &x11->atoms.utf8_string, 0, "UTF8_STRING");
xcb_change_property(x11->xcb_conn, XCB_PROP_MODE_REPLACE, output->win,
x11->atoms.wm_protocols.reply->atom, XCB_ATOM_ATOM, 32, 1,
&x11->atoms.wm_delete_window.reply->atom);
+ char title[32];
+ if (snprintf(title, sizeof(title), "wlroots - %s", output->wlr_output.name)) {
+ xcb_change_property(x11->xcb_conn, XCB_PROP_MODE_REPLACE, output->win,
+ x11->atoms.net_wm_name.reply->atom,
+ x11->atoms.utf8_string.reply->atom, 8,
+ strlen(title), title);
+ }
+
xcb_map_window(x11->xcb_conn, output->win);
xcb_flush(x11->xcb_conn);
wlr_output_update_enabled(&output->wlr_output, true);
diff --git a/examples/screenshot.c b/examples/screenshot.c
index c163df75..7edb7327 100644
--- a/examples/screenshot.c
+++ b/examples/screenshot.c
@@ -121,12 +121,32 @@ static const struct wl_registry_listener registry_listener = {
.global_remove = handle_global_remove,
};
+static int backingfile(off_t size) {
+ static char template[] = "/tmp/wlroots-shared-XXXXXX";
+ int fd, ret;
+
+ fd = mkstemp(template);
+ if (fd < 0) {
+ return -1;
+ }
+
+ while ((ret = ftruncate(fd, size)) == EINTR) {}
+ if (ret < 0) {
+ close(fd);
+ return -1;
+ }
+
+ unlink(template);
+ return fd;
+}
+
+
static struct wl_buffer *create_shm_buffer(int width, int height,
void **data_out) {
int stride = width * 4;
int size = stride * height;
- int fd = os_create_anonymous_file(size);
+ int fd = backingfile(size);
if (fd < 0) {
fprintf(stderr, "creating a buffer file for %d B failed: %m\n", size);
return NULL;
diff --git a/include/backend/x11.h b/include/backend/x11.h
index c5f258c0..9e1c8146 100644
--- a/include/backend/x11.h
+++ b/include/backend/x11.h
@@ -46,6 +46,8 @@ struct wlr_x11_backend {
struct {
struct wlr_x11_atom wm_protocols;
struct wlr_x11_atom wm_delete_window;
+ struct wlr_x11_atom net_wm_name;
+ struct wlr_x11_atom utf8_string;
} atoms;
// The time we last received an event
diff --git a/include/render/gles2.h b/include/render/gles2.h
index 797c5293..e015160d 100644
--- a/include/render/gles2.h
+++ b/include/render/gles2.h
@@ -62,7 +62,7 @@ extern const GLchar fragment_src_external[];
bool _gles2_flush_errors(const char *file, int line);
#define gles2_flush_errors(...) \
- _gles2_flush_errors(_strip_path(__FILE__), __LINE__)
+ _gles2_flush_errors(wlr_strip_path(__FILE__), __LINE__)
#define GL_CALL(func) func; gles2_flush_errors()
diff --git a/include/rootston/output.h b/include/rootston/output.h
index 9682e4f5..a852a204 100644
--- a/include/rootston/output.h
+++ b/include/rootston/output.h
@@ -19,7 +19,8 @@ struct roots_output {
struct wlr_output_damage *damage;
struct wl_listener destroy;
- struct wl_listener frame;
+ struct wl_listener damage_frame;
+ struct wl_listener damage_destroy;
};
void handle_new_output(struct wl_listener *listener, void *data);
diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h
index 8481c590..5919b934 100644
--- a/include/wlr/types/wlr_compositor.h
+++ b/include/wlr/types/wlr_compositor.h
@@ -14,6 +14,7 @@ struct wlr_compositor {
struct {
struct wl_signal new_surface;
+ struct wl_signal destroy;
} events;
};
diff --git a/include/wlr/types/wlr_idle.h b/include/wlr/types/wlr_idle.h
index 689c33a4..1744f07c 100644
--- a/include/wlr/types/wlr_idle.h
+++ b/include/wlr/types/wlr_idle.h
@@ -19,7 +19,9 @@ struct wlr_idle {
struct wl_event_loop *event_loop;
struct wl_listener display_destroy;
- struct wl_signal activity_notify;
+ struct {
+ struct wl_signal activity_notify;
+ } events;
void *data;
};
diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h
index 7dd2b16a..4d10720e 100644
--- a/include/wlr/types/wlr_output_layout.h
+++ b/include/wlr/types/wlr_output_layout.h
@@ -96,4 +96,19 @@ void wlr_output_layout_add_auto(struct wlr_output_layout *layout,
struct wlr_output *wlr_output_layout_get_center_output(
struct wlr_output_layout *layout);
+enum wlr_direction {
+ WLR_DIRECTION_UP = 0,
+ WLR_DIRECTION_DOWN = 1,
+ WLR_DIRECTION_LEFT = 2,
+ WLR_DIRECTION_RIGHT = 4,
+};
+
+/**
+ * Get the closest adjacent output to the reference output from the reference
+ * point in the given 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);
+
#endif
diff --git a/include/wlr/util/log.h b/include/wlr/util/log.h
index 3d3f25f9..5528664b 100644
--- a/include/wlr/util/log.h
+++ b/include/wlr/util/log.h
@@ -28,13 +28,13 @@ void wlr_log_init(log_importance_t verbosity, log_callback_t callback);
void _wlr_log(log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3);
void _wlr_vlog(log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0);
-const char *_strip_path(const char *filepath);
+const char *wlr_strip_path(const char *filepath);
#define wlr_log(verb, fmt, ...) \
- _wlr_log(verb, "[%s:%d] " fmt, _strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
+ _wlr_log(verb, "[%s:%d] " fmt, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
#define wlr_vlog(verb, fmt, args) \
- _wlr_vlog(verb, "[%s:%d] " fmt, _strip_path(__FILE__), __LINE__, args)
+ _wlr_vlog(verb, "[%s:%d] " fmt, wlr_strip_path(__FILE__), __LINE__, args)
#define wlr_log_errno(verb, fmt, ...) \
wlr_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno))
diff --git a/include/wlr/xwm.h b/include/wlr/xwm.h
index 242ff9cc..65681607 100644
--- a/include/wlr/xwm.h
+++ b/include/wlr/xwm.h
@@ -93,7 +93,8 @@ struct wlr_xwm {
const xcb_query_extension_reply_t *xfixes;
- struct wl_listener compositor_surface_create;
+ struct wl_listener compositor_new_surface;
+ struct wl_listener compositor_destroy;
struct wl_listener seat_selection;
struct wl_listener seat_primary_selection;
};
diff --git a/meson.build b/meson.build
index 2fc78d33..d5ae7863 100644
--- a/meson.build
+++ b/meson.build
@@ -140,6 +140,8 @@ wlr_deps += [
math,
]
+symbols_file = 'wlroots.syms'
+symbols_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbols_file)
lib_wlr = library(
meson.project_name(),
version: '.'.join(so_version),
@@ -147,6 +149,7 @@ lib_wlr = library(
dependencies: wlr_deps,
include_directories: wlr_inc,
install: true,
+ link_args : symbols_flag,
)
wlroots = declare_dependency(
diff --git a/rootston/output.c b/rootston/output.c
index 8ef383c3..a354ebf8 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -182,6 +182,21 @@ static void xwayland_children_for_each_surface(
}
#endif
+static void drag_icons_for_each_surface(struct roots_input *input,
+ surface_iterator_func_t iterator, void *user_data) {
+ struct roots_seat *seat;
+ wl_list_for_each(seat, &input->seats, link) {
+ struct roots_drag_icon *drag_icon;
+ wl_list_for_each(drag_icon, &seat->drag_icons, link) {
+ if (!drag_icon->wlr_drag_icon->mapped) {
+ continue;
+ }
+ surface_for_each_surface(drag_icon->wlr_drag_icon->surface,
+ drag_icon->x, drag_icon->y, 0, iterator, user_data);
+ }
+ }
+}
+
struct render_data {
struct roots_output *output;
@@ -190,18 +205,22 @@ struct render_data {
};
/**
- * Checks whether a surface at (lx, ly) intersects an output. Sets `box` to the
- * surface box in the output, in output-local coordinates.
+ * Checks whether a surface at (lx, ly) intersects an output. If `box` is not
+ * NULL, it populates it with the surface box in the output, in output-local
+ * coordinates.
*/
static bool surface_intersect_output(struct wlr_surface *surface,
struct wlr_output_layout *output_layout, struct wlr_output *wlr_output,
double lx, double ly, float rotation, struct wlr_box *box) {
double ox = lx, oy = ly;
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
- box->x = ox * wlr_output->scale;
- box->y = oy * wlr_output->scale;
- box->width = surface->current->width * wlr_output->scale;
- box->height = surface->current->height * wlr_output->scale;
+
+ if (box != NULL) {
+ box->x = ox * wlr_output->scale;
+ box->y = oy * wlr_output->scale;
+ box->width = surface->current->width * wlr_output->scale;
+ box->height = surface->current->height * wlr_output->scale;
+ }
struct wlr_box layout_box = {
.x = lx, .y = ly,
@@ -239,7 +258,6 @@ static void render_surface(struct wlr_surface *surface, double lx, double ly,
float rotation, void *_data) {
struct render_data *data = _data;
struct roots_output *output = data->output;
- struct timespec *when = data->when;
struct wlr_renderer *renderer =
wlr_backend_get_renderer(output->wlr_output->backend);
assert(renderer);
@@ -281,8 +299,6 @@ static void render_surface(struct wlr_surface *surface, double lx, double ly,
wlr_render_with_matrix(renderer, surface->texture, &matrix);
}
- wlr_surface_send_frame_done(surface, when);
-
damage_finish:
pixman_region32_fini(&damage);
}
@@ -384,6 +400,20 @@ static bool has_standalone_surface(struct roots_view *view) {
return true;
}
+static void surface_send_frame_done(struct wlr_surface *surface, double lx,
+ double ly, float rotation, void *_data) {
+ struct render_data *data = _data;
+ struct roots_output *output = data->output;
+ struct timespec *when = data->when;
+
+ if (!surface_intersect_output(surface, output->desktop->layout,
+ output->wlr_output, lx, ly, rotation, NULL)) {
+ return;
+ }
+
+ wlr_surface_send_frame_done(surface, when);
+}
+
static void render_output(struct roots_output *output) {
struct wlr_output *wlr_output = output->wlr_output;
struct roots_desktop *desktop = output->desktop;
@@ -434,17 +464,17 @@ static void render_output(struct roots_output *output) {
return;
}
- if (!needs_swap) {
- // Output doesn't need swap and isn't damaged, skip rendering completely
- goto damage_finish;
- }
-
struct render_data data = {
.output = output,
.when = &now,
.damage = &damage,
};
+ if (!needs_swap) {
+ // Output doesn't need swap and isn't damaged, skip rendering completely
+ goto damage_finish;
+ }
+
wlr_renderer_begin(renderer, wlr_output);
if (!pixman_region32_not_empty(&damage)) {
@@ -490,17 +520,7 @@ static void render_output(struct roots_output *output) {
}
// Render drag icons
- struct roots_drag_icon *drag_icon = NULL;
- struct roots_seat *seat = NULL;
- wl_list_for_each(seat, &server->input->seats, link) {
- wl_list_for_each(drag_icon, &seat->drag_icons, link) {
- if (!drag_icon->wlr_drag_icon->mapped) {
- continue;
- }
- render_surface(drag_icon->wlr_drag_icon->surface,
- drag_icon->x, drag_icon->y, 0, &data);
- }
- }
+ drag_icons_for_each_surface(server->input, render_surface, &data);
renderer_end:
wlr_renderer_scissor(renderer, NULL);
@@ -512,12 +532,32 @@ renderer_end:
damage_finish:
pixman_region32_fini(&damage);
-}
-static void output_damage_handle_frame(struct wl_listener *listener,
- void *data) {
- struct roots_output *output = wl_container_of(listener, output, frame);
- render_output(output);
+ // Send frame done events to all surfaces
+ if (output->fullscreen_view != NULL) {
+ struct roots_view *view = output->fullscreen_view;
+ if (wlr_output->fullscreen_surface == view->wlr_surface) {
+ // The surface is managed by the wlr_output
+ return;
+ }
+
+ view_for_each_surface(view, surface_send_frame_done, &data);
+
+#ifdef WLR_HAS_XWAYLAND
+ if (view->type == ROOTS_XWAYLAND_VIEW) {
+ xwayland_children_for_each_surface(view->xwayland_surface,
+ surface_send_frame_done, &data);
+ }
+#endif
+ } else {
+ struct roots_view *view;
+ wl_list_for_each_reverse(view, &desktop->views, link) {
+ view_for_each_surface(view, surface_send_frame_done, &data);
+ }
+
+ drag_icons_for_each_surface(server->input, surface_send_frame_done,
+ &data);
+ }
}
void output_damage_whole(struct roots_output *output) {
@@ -681,19 +721,37 @@ static void set_mode(struct wlr_output *output,
}
}
-static void output_handle_destroy(struct wl_listener *listener, void *data) {
- struct roots_output *output = wl_container_of(listener, output, destroy);
-
+static void output_destroy(struct roots_output *output) {
// TODO: cursor
//example_config_configure_cursor(sample->config, sample->cursor,
// sample->compositor);
wl_list_remove(&output->link);
wl_list_remove(&output->destroy.link);
- wl_list_remove(&output->frame.link);
+ wl_list_remove(&output->damage_frame.link);
+ wl_list_remove(&output->damage_destroy.link);
free(output);
}
+static void output_handle_destroy(struct wl_listener *listener, void *data) {
+ struct roots_output *output = wl_container_of(listener, output, destroy);
+ output_destroy(output);
+}
+
+static void output_damage_handle_frame(struct wl_listener *listener,
+ void *data) {
+ struct roots_output *output =
+ wl_container_of(listener, output, damage_frame);
+ render_output(output);
+}
+
+static void output_damage_handle_destroy(struct wl_listener *listener,
+ void *data) {
+ struct roots_output *output =
+ wl_container_of(listener, output, damage_destroy);
+ output_destroy(output);
+}
+
void handle_new_output(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = wl_container_of(listener, desktop,
new_output);
@@ -722,8 +780,10 @@ void handle_new_output(struct wl_listener *listener, void *data) {
output->destroy.notify = output_handle_destroy;
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
- output->frame.notify = output_damage_handle_frame;
- wl_signal_add(&output->damage->events.frame, &output->frame);
+ output->damage_frame.notify = output_damage_handle_frame;
+ wl_signal_add(&output->damage->events.frame, &output->damage_frame);
+ output->damage_destroy.notify = output_damage_handle_destroy;
+ wl_signal_add(&output->damage->events.destroy, &output->damage_destroy);
struct roots_output_config *output_config =
roots_config_get_output(config, wlr_output);
diff --git a/rootston/seat.c b/rootston/seat.c
index 38c26628..1b7d05c4 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -408,10 +408,10 @@ static void handle_keyboard_destroy(struct wl_listener *listener, void *data) {
struct roots_keyboard *keyboard =
wl_container_of(listener, keyboard, device_destroy);
struct roots_seat *seat = keyboard->seat;
- roots_keyboard_destroy(keyboard);
wl_list_remove(&keyboard->device_destroy.link);
wl_list_remove(&keyboard->keyboard_key.link);
wl_list_remove(&keyboard->keyboard_modifiers.link);
+ roots_keyboard_destroy(keyboard);
seat_update_capabilities(seat);
}
diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c
index 008f2e51..f27655c0 100644
--- a/types/wlr_compositor.c
+++ b/types/wlr_compositor.c
@@ -90,6 +90,7 @@ void wlr_compositor_destroy(struct wlr_compositor *compositor) {
if (compositor == NULL) {
return;
}
+ wlr_signal_emit_safe(&compositor->events.destroy, compositor);
wl_list_remove(&compositor->display_destroy.link);
wl_global_destroy(compositor->wl_global);
free(compositor);
@@ -195,6 +196,7 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
wl_list_init(&compositor->wl_resources);
wl_list_init(&compositor->surfaces);
wl_signal_init(&compositor->events.new_surface);
+ wl_signal_init(&compositor->events.destroy);
compositor->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &compositor->display_destroy);
diff --git a/types/wlr_idle.c b/types/wlr_idle.c
index 51963aea..a3981479 100644
--- a/types/wlr_idle.c
+++ b/types/wlr_idle.c
@@ -122,7 +122,7 @@ static void create_idle_timer(struct wl_client *client,
wl_signal_add(&timer->seat->events.destroy, &timer->seat_destroy);
timer->input_listener.notify = handle_input_notification;
- wl_signal_add(&idle->activity_notify, &timer->input_listener);
+ wl_signal_add(&idle->events.activity_notify, &timer->input_listener);
// create the timer
timer->idle_source =
wl_event_loop_add_timer(idle->event_loop, idle_notify, timer);
@@ -181,7 +181,7 @@ struct wlr_idle *wlr_idle_create(struct wl_display *display) {
return NULL;
}
wl_list_init(&idle->idle_timers);
- wl_signal_init(&idle->activity_notify);
+ wl_signal_init(&idle->events.activity_notify);
idle->event_loop = wl_display_get_event_loop(display);
if (idle->event_loop == NULL) {
@@ -204,5 +204,5 @@ struct wlr_idle *wlr_idle_create(struct wl_display *display) {
}
void wlr_idle_notify_activity(struct wlr_idle *idle, struct wlr_seat *seat) {
- wlr_signal_emit_safe(&idle->activity_notify, seat);
+ wlr_signal_emit_safe(&idle->events.activity_notify, seat);
}
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c
index db0389bd..c305f04d 100644
--- a/types/wlr_output_layout.c
+++ b/types/wlr_output_layout.c
@@ -421,3 +421,52 @@ struct wlr_output *wlr_output_layout_get_center_output(
return wlr_output_layout_output_at(layout, dest_x, dest_y);
}
+
+
+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) {
+ assert(reference);
+
+ struct wlr_box *ref_box = wlr_output_layout_get_box(layout, reference);
+
+ double min_distance = DBL_MAX;
+ struct wlr_output *closest_output = NULL;
+ struct wlr_output_layout_output *l_output;
+ wl_list_for_each(l_output, &layout->outputs, link) {
+ if (reference != NULL && reference == l_output->output) {
+ continue;
+ }
+ struct wlr_box *box = wlr_output_layout_output_get_box(l_output);
+
+ bool match = false;
+ // test to make sure this output is in the given direction
+ if (direction & WLR_DIRECTION_LEFT) {
+ match = box->x + box->width <= ref_box->x || match;
+ }
+ if (direction & WLR_DIRECTION_RIGHT) {
+ match = box->x >= ref_box->x + ref_box->width || match;
+ }
+ if (direction & WLR_DIRECTION_UP) {
+ match = box->y + box->height <= ref_box->y || match;
+ }
+ if (direction & WLR_DIRECTION_DOWN) {
+ match = box->y >= ref_box->y + ref_box->height || match;
+ }
+ if (!match) {
+ continue;
+ }
+
+ // 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);
+ double distance =
+ (x - ref_x) * (x - ref_x) + (y - ref_y) * (y - ref_y);
+ if (distance < min_distance) {
+ min_distance = distance;
+ closest_output = l_output->output;
+ }
+ }
+ return closest_output;
+}
diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c
index 9c267405..b8f3094b 100644
--- a/types/wlr_primary_selection.c
+++ b/types/wlr_primary_selection.c
@@ -253,6 +253,16 @@ void wlr_seat_set_primary_selection(struct wlr_seat *seat,
}
}
+
+static const struct gtk_primary_selection_device_interface device_impl;
+
+static struct wlr_seat_client *seat_client_from_device_resource(
+ struct wl_resource *resource) {
+ assert(wl_resource_instance_of(resource,
+ &gtk_primary_selection_device_interface, &device_impl));
+ return wl_resource_get_user_data(resource);
+}
+
static void device_handle_set_selection(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *source_resource,
uint32_t serial) {
@@ -262,7 +272,7 @@ static void device_handle_set_selection(struct wl_client *client,
}
struct wlr_seat_client *seat_client =
- wlr_seat_client_from_resource(resource);
+ seat_client_from_device_resource(resource);
struct wlr_primary_selection_source *wlr_source =
(struct wlr_primary_selection_source *)source;
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index e2588167..d63fc1f1 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -170,12 +170,6 @@ static bool wlr_surface_update_size(struct wlr_surface *surface,
height = tmp;
}
- struct wlr_frame_callback *cb, *tmp;
- wl_list_for_each_safe(cb, tmp, &state->frame_callback_list, link) {
- wl_resource_destroy(cb->resource);
- }
- wl_list_init(&state->frame_callback_list);
-
bool update_damage = false;
if (width != state->width || height != state->height) {
// Damage the whole surface on resize
diff --git a/util/log.c b/util/log.c
index 327402e6..2adcae2d 100644
--- a/util/log.c
+++ b/util/log.c
@@ -73,7 +73,7 @@ void _wlr_log(log_importance_t verbosity, const char *fmt, ...) {
// e.g. '/src/build/wlroots/backend/wayland/backend.c' and
// '../backend/wayland/backend.c' will both be stripped to
// 'backend/wayland/backend.c'
-const char *_strip_path(const char *filepath) {
+const char *wlr_strip_path(const char *filepath) {
static int srclen = sizeof(WLR_SRC_DIR);
if (strstr(filepath, WLR_SRC_DIR) == filepath) {
filepath += srclen;
diff --git a/wlroots.syms b/wlroots.syms
new file mode 100644
index 00000000..93d6fe51
--- /dev/null
+++ b/wlroots.syms
@@ -0,0 +1,49 @@
+WLROOTS_0_0_0 {
+ global:
+ wlr_*;
+ _wlr_log;
+ local:
+ wlr_data_device_keyboard_drag_interface;
+ wlr_data_device_pointer_drag_interface;
+ wlr_data_device_touch_drag_interface;
+ wlr_drm_backend_get_session;
+ wlr_drm_check_features;
+ wlr_drm_connector_cleanup;
+ wlr_drm_connector_start_renderer;
+ wlr_drm_event;
+ wlr_drm_get_connector_props;
+ wlr_drm_get_crtc_props;
+ wlr_drm_get_plane_props;
+ wlr_drm_get_prop;
+ wlr_drm_get_prop_blob;
+ wlr_drm_plane_surfaces_init;
+ wlr_drm_renderer_finish;
+ wlr_drm_renderer_init;
+ wlr_drm_resources_free;
+ wlr_drm_resources_init;
+ wlr_drm_restore_outputs;
+ wlr_drm_scan_connectors;
+ wlr_drm_surface_finish;
+ wlr_drm_surface_get_front;
+ wlr_drm_surface_init;
+ wlr_drm_surface_make_current;
+ wlr_drm_surface_mgpu_copy;
+ wlr_drm_surface_post;
+ wlr_drm_surface_swap_buffers;
+ wlr_egl_get_buffer_age;
+ wlr_libinput_event;
+ wlr_libinput_keyboard_create;
+ wlr_libinput_pointer_create;
+ wlr_libinput_tablet_pad_create;
+ wlr_libinput_tablet_tool_create;
+ wlr_libinput_touch_create;
+ wlr_log_stderr;
+ wlr_signal_emit_safe;
+ wlr_subsurface_destroy;
+ wlr_wl_output_for_surface;
+ wlr_wl_output_layout_get_box;
+ wlr_wl_output_move_cursor;
+ wlr_wl_output_update_cursor;
+ wlr_wl_registry_poll;
+ *;
+};
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 94dfdaab..0d957260 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -1019,11 +1019,11 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) {
return count;
}
-static void handle_compositor_surface_create(struct wl_listener *listener,
+static void handle_compositor_new_surface(struct wl_listener *listener,
void *data) {
- struct wlr_surface *surface = data;
struct wlr_xwm *xwm =
- wl_container_of(listener, xwm, compositor_surface_create);
+ wl_container_of(listener, xwm, compositor_new_surface);
+ struct wlr_surface *surface = data;
if (wl_resource_get_client(surface->resource) != xwm->xwayland->client) {
return;
}
@@ -1043,6 +1043,16 @@ static void handle_compositor_surface_create(struct wl_listener *listener,
}
}
+static void handle_compositor_destroy(struct wl_listener *listener,
+ void *data) {
+ struct wlr_xwm *xwm =
+ wl_container_of(listener, xwm, compositor_destroy);
+ wl_list_remove(&xwm->compositor_new_surface.link);
+ wl_list_remove(&xwm->compositor_destroy.link);
+ wl_list_init(&xwm->compositor_new_surface.link);
+ wl_list_init(&xwm->compositor_destroy.link);
+}
+
void wlr_xwayland_surface_activate(struct wlr_xwayland_surface *xsurface,
bool activated) {
struct wlr_xwayland_surface *focused = xsurface->xwm->focus_surface;
@@ -1124,7 +1134,8 @@ void xwm_destroy(struct wlr_xwm *xwm) {
wl_list_for_each_safe(xsurface, tmp, &xwm->unpaired_surfaces, link) {
wlr_xwayland_surface_destroy(xsurface);
}
- wl_list_remove(&xwm->compositor_surface_create.link);
+ wl_list_remove(&xwm->compositor_new_surface.link);
+ wl_list_remove(&xwm->compositor_destroy.link);
xcb_disconnect(xwm->xcb_conn);
free(xwm);
@@ -1407,9 +1418,12 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
xwm_selection_init(xwm);
- xwm->compositor_surface_create.notify = handle_compositor_surface_create;
+ xwm->compositor_new_surface.notify = handle_compositor_new_surface;
wl_signal_add(&wlr_xwayland->compositor->events.new_surface,
- &xwm->compositor_surface_create);
+ &xwm->compositor_new_surface);
+ xwm->compositor_destroy.notify = handle_compositor_destroy;
+ wl_signal_add(&wlr_xwayland->compositor->events.destroy,
+ &xwm->compositor_destroy);
xwm_create_wm_window(xwm);