mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
Merge branch 'master' into display-destroy
This commit is contained in:
commit
75ef7860bb
19 changed files with 111 additions and 28 deletions
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
@ -119,6 +120,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;
|
||||
}
|
||||
|
||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_wl_backend *backend =
|
||||
wl_container_of(listener, backend, local_display_destroy);
|
||||
|
|
|
@ -33,7 +33,6 @@ static bool wlr_wl_output_set_custom_mode(struct wlr_output *_output,
|
|||
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);
|
||||
wl_signal_emit(&output->wlr_output.events.resolution, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,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);
|
||||
|
@ -172,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);
|
||||
|
@ -228,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 = {
|
||||
|
|
|
@ -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,23 +52,28 @@ 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_output_transform_apply_to_box(
|
||||
wlr_wl_pointer->current_output->wlr_output.transform, &box,
|
||||
&transformed);
|
||||
wlr_output_transform_apply_to_box(wlr_output->transform, &box, &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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -72,7 +72,7 @@ static void handle_output_add(struct output_state *ostate) {
|
|||
example_config_get_output(sample->config, ostate->output);
|
||||
|
||||
if (o_config) {
|
||||
wlr_output_transform(ostate->output, o_config->transform);
|
||||
wlr_output_set_transform(ostate->output, o_config->transform);
|
||||
wlr_output_layout_add(sample->layout, ostate->output, o_config->x,
|
||||
o_config->y);
|
||||
} else {
|
||||
|
|
|
@ -136,7 +136,7 @@ static void handle_output_add(struct output_state *ostate) {
|
|||
example_config_get_output(sample->config, ostate->output);
|
||||
|
||||
if (o_config) {
|
||||
wlr_output_transform(ostate->output, o_config->transform);
|
||||
wlr_output_set_transform(ostate->output, o_config->transform);
|
||||
wlr_output_layout_add(sample->layout, ostate->output, o_config->x,
|
||||
o_config->y);
|
||||
} else {
|
||||
|
|
|
@ -101,7 +101,7 @@ static void handle_output_add(struct output_state *ostate) {
|
|||
example_config_get_output(sample->config, ostate->output);
|
||||
|
||||
if (o_config) {
|
||||
wlr_output_transform(ostate->output, o_config->transform);
|
||||
wlr_output_set_transform(ostate->output, o_config->transform);
|
||||
wlr_output_layout_add(sample->layout, ostate->output, o_config->x,
|
||||
o_config->y);
|
||||
} else {
|
||||
|
|
|
@ -78,7 +78,7 @@ static void handle_output_add(struct output_state *output) {
|
|||
struct output_config *conf;
|
||||
wl_list_for_each(conf, &state->config->outputs, link) {
|
||||
if (strcmp(conf->name, output->output->name) == 0) {
|
||||
wlr_output_transform(output->output, conf->transform);
|
||||
wlr_output_set_transform(output->output, conf->transform);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <wayland-egl.h>
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/backend/wayland.h>
|
||||
#include <wlr/types/wlr_box.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wayland-util.h>
|
||||
|
@ -76,6 +77,8 @@ void wlr_wl_registry_poll(struct wlr_wl_backend *backend);
|
|||
void wlr_wl_output_update_cursor(struct wlr_wl_backend_output *output);
|
||||
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
|
||||
struct wlr_wl_backend *backend, struct wl_surface *surface);
|
||||
void wlr_wl_output_layout_get_box(struct wlr_wl_backend *backend,
|
||||
struct wlr_box *box);
|
||||
|
||||
extern const struct wl_seat_listener seat_listener;
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ struct wlr_output {
|
|||
struct wl_signal frame;
|
||||
struct wl_signal swap_buffers;
|
||||
struct wl_signal resolution;
|
||||
struct wl_signal scale;
|
||||
struct wl_signal transform;
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
|
@ -87,7 +89,7 @@ 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,
|
||||
int32_t height, int32_t refresh);
|
||||
void wlr_output_transform(struct wlr_output *output,
|
||||
void wlr_output_set_transform(struct wlr_output *output,
|
||||
enum wl_output_transform transform);
|
||||
void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly);
|
||||
void wlr_output_set_scale(struct wlr_output *output, uint32_t scale);
|
||||
|
|
|
@ -33,6 +33,13 @@ struct wlr_xwayland {
|
|||
struct wl_signal new_surface;
|
||||
} events;
|
||||
|
||||
/**
|
||||
* Add a custom event handler to xwayland. Return 1 if the event was
|
||||
* handled or 0 to use the default wlr-xwayland handler. wlr-xwayland will
|
||||
* free the event.
|
||||
*/
|
||||
int (*user_event_handler)(struct wlr_xwm *xwm, xcb_generic_event_t *event);
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ if get_option('enable_xwayland')
|
|||
wlr_parts += [lib_wlr_xwayland]
|
||||
conf_data.set('WLR_HAS_XWAYLAND', true)
|
||||
else
|
||||
exclude_files += ['xwayland.h']
|
||||
exclude_files += ['xwayland.h', 'xwm.h']
|
||||
endif
|
||||
configure_file(output: 'config.h', install_dir: 'include/wlr', configuration: conf_data)
|
||||
install_subdir('include/wlr', install_dir: 'include', exclude_files: exclude_files)
|
||||
|
|
|
@ -321,7 +321,7 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
set_mode(wlr_output, output_config);
|
||||
}
|
||||
wlr_output_set_scale(wlr_output, output_config->scale);
|
||||
wlr_output_transform(wlr_output, output_config->transform);
|
||||
wlr_output_set_transform(wlr_output, output_config->transform);
|
||||
wlr_output_layout_add(desktop->layout, wlr_output, output_config->x,
|
||||
output_config->y);
|
||||
} else {
|
||||
|
|
|
@ -206,9 +206,11 @@ void wlr_output_update_size(struct wlr_output *output, int32_t width,
|
|||
wl_resource_for_each(resource, &output->wl_resources) {
|
||||
wlr_output_send_current_mode_to_resource(resource);
|
||||
}
|
||||
|
||||
wl_signal_emit(&output->events.resolution, output);
|
||||
}
|
||||
|
||||
void wlr_output_transform(struct wlr_output *output,
|
||||
void wlr_output_set_transform(struct wlr_output *output,
|
||||
enum wl_output_transform transform) {
|
||||
output->impl->transform(output, transform);
|
||||
wlr_output_update_matrix(output);
|
||||
|
@ -218,6 +220,8 @@ void wlr_output_transform(struct wlr_output *output,
|
|||
wl_resource_for_each(resource, &output->wl_resources) {
|
||||
wl_output_send_to_resource(resource);
|
||||
}
|
||||
|
||||
wl_signal_emit(&output->events.transform, output);
|
||||
}
|
||||
|
||||
void wlr_output_set_position(struct wlr_output *output, int32_t lx,
|
||||
|
@ -248,6 +252,8 @@ void wlr_output_set_scale(struct wlr_output *output, uint32_t scale) {
|
|||
wl_resource_for_each(resource, &output->wl_resources) {
|
||||
wl_output_send_to_resource(resource);
|
||||
}
|
||||
|
||||
wl_signal_emit(&output->events.scale, output);
|
||||
}
|
||||
|
||||
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||
|
@ -263,6 +269,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
|||
wl_signal_init(&output->events.frame);
|
||||
wl_signal_init(&output->events.swap_buffers);
|
||||
wl_signal_init(&output->events.resolution);
|
||||
wl_signal_init(&output->events.scale);
|
||||
wl_signal_init(&output->events.transform);
|
||||
wl_signal_init(&output->events.destroy);
|
||||
}
|
||||
|
||||
|
@ -275,9 +283,9 @@ void wlr_output_destroy(struct wlr_output *output) {
|
|||
|
||||
struct wlr_output_mode *mode, *tmp_mode;
|
||||
wl_list_for_each_safe(mode, tmp_mode, &output->modes, link) {
|
||||
wl_list_remove(&mode->link);
|
||||
free(mode);
|
||||
}
|
||||
wl_list_remove(&output->modes);
|
||||
if (output->impl && output->impl->destroy) {
|
||||
output->impl->destroy(output);
|
||||
} else {
|
||||
|
|
|
@ -19,6 +19,8 @@ struct wlr_output_layout_output_state {
|
|||
bool auto_configured;
|
||||
|
||||
struct wl_listener resolution;
|
||||
struct wl_listener scale;
|
||||
struct wl_listener transform;
|
||||
struct wl_listener output_destroy;
|
||||
};
|
||||
|
||||
|
@ -46,6 +48,8 @@ static void wlr_output_layout_output_destroy(
|
|||
struct wlr_output_layout_output *l_output) {
|
||||
wl_signal_emit(&l_output->events.destroy, l_output);
|
||||
wl_list_remove(&l_output->state->resolution.link);
|
||||
wl_list_remove(&l_output->state->scale.link);
|
||||
wl_list_remove(&l_output->state->transform.link);
|
||||
wl_list_remove(&l_output->state->output_destroy.link);
|
||||
wl_list_remove(&l_output->link);
|
||||
free(l_output->state);
|
||||
|
@ -134,6 +138,18 @@ static void handle_output_resolution(struct wl_listener *listener, void *data) {
|
|||
wlr_output_layout_reconfigure(state->layout);
|
||||
}
|
||||
|
||||
static void handle_output_scale(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output_layout_output_state *state =
|
||||
wl_container_of(listener, state, scale);
|
||||
wlr_output_layout_reconfigure(state->layout);
|
||||
}
|
||||
|
||||
static void handle_output_transform(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output_layout_output_state *state =
|
||||
wl_container_of(listener, state, transform);
|
||||
wlr_output_layout_reconfigure(state->layout);
|
||||
}
|
||||
|
||||
static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output_layout_output_state *state =
|
||||
wl_container_of(listener, state, output_destroy);
|
||||
|
@ -162,6 +178,10 @@ static struct wlr_output_layout_output *wlr_output_layout_output_create(
|
|||
|
||||
wl_signal_add(&output->events.resolution, &l_output->state->resolution);
|
||||
l_output->state->resolution.notify = handle_output_resolution;
|
||||
wl_signal_add(&output->events.scale, &l_output->state->scale);
|
||||
l_output->state->scale.notify = handle_output_scale;
|
||||
wl_signal_add(&output->events.transform, &l_output->state->transform);
|
||||
l_output->state->transform.notify = handle_output_transform;
|
||||
wl_signal_add(&output->events.destroy, &l_output->state->output_destroy);
|
||||
l_output->state->output_destroy.notify = handle_output_destroy;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "wlr/util/log.h"
|
||||
#include "wlr/xwayland.h"
|
||||
#include "sockets.h"
|
||||
#include "xwm.h"
|
||||
#include "wlr/xwm.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
static inline int clearenv(void) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "wlr/types/wlr_surface.h"
|
||||
#include "wlr/xwayland.h"
|
||||
#include "wlr/xcursor.h"
|
||||
#include "xwm.h"
|
||||
#include "wlr/xwm.h"
|
||||
|
||||
#ifdef HAS_XCB_ICCCM
|
||||
#include <xcb/xcb_icccm.h>
|
||||
|
@ -938,6 +938,12 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) {
|
|||
|
||||
while ((event = xcb_poll_for_event(xwm->xcb_conn))) {
|
||||
count++;
|
||||
|
||||
if (xwm->xwayland->user_event_handler &&
|
||||
xwm->xwayland->user_event_handler(xwm, event)) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) {
|
||||
case XCB_CREATE_NOTIFY:
|
||||
xwm_handle_create_notify(xwm, (xcb_create_notify_event_t *)event);
|
||||
|
|
Loading…
Reference in a new issue