Merge branch 'master' into master

This commit is contained in:
Radical 2023-02-14 08:18:02 +01:00 committed by GitHub
commit cdf928dcde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 62 additions and 83 deletions

View file

@ -15,4 +15,9 @@ struct sway_surface {
struct wl_event_source *frame_done_timer; struct wl_event_source *frame_done_timer;
}; };
void surface_enter_output(struct wlr_surface *surface,
struct sway_output *output);
void surface_leave_output(struct wlr_surface *surface,
struct sway_output *output);
#endif #endif

View file

@ -13,6 +13,7 @@
#include "sway/layers.h" #include "sway/layers.h"
#include "sway/output.h" #include "sway/output.h"
#include "sway/server.h" #include "sway/server.h"
#include "sway/surface.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/workspace.h" #include "sway/tree/workspace.h"
@ -382,8 +383,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
struct sway_output *output = wlr_output->data; struct sway_output *output = wlr_output->data;
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
sway_layer->layer_surface->surface, true); sway_layer->layer_surface->surface, true);
wlr_surface_send_enter(sway_layer->layer_surface->surface, surface_enter_output(sway_layer->layer_surface->surface, output);
sway_layer->layer_surface->output);
cursor_rebase_all(); cursor_rebase_all();
} }
@ -510,7 +510,7 @@ static void popup_handle_map(struct wl_listener *listener, void *data) {
struct sway_layer_surface *layer = popup_get_layer(popup); struct sway_layer_surface *layer = popup_get_layer(popup);
struct wlr_output *wlr_output = layer->layer_surface->output; struct wlr_output *wlr_output = layer->layer_surface->output;
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output"); sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
wlr_surface_send_enter(popup->wlr_popup->base->surface, wlr_output); surface_enter_output(popup->wlr_popup->base->surface, wlr_output->data);
popup_damage(popup, true); popup_damage(popup, true);
} }

View file

@ -2,8 +2,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
#include "sway/server.h" #include "sway/server.h"
#include "sway/surface.h" #include "sway/surface.h"
#include "sway/output.h"
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_surface *surface = wl_container_of(listener, surface, destroy); struct sway_surface *surface = wl_container_of(listener, surface, destroy);
@ -44,3 +46,26 @@ void handle_compositor_new_surface(struct wl_listener *listener, void *data) {
wl_resource_post_no_memory(wlr_surface->resource); wl_resource_post_no_memory(wlr_surface->resource);
} }
} }
static void surface_update_outputs(struct wlr_surface *surface) {
float scale = 1;
struct wlr_surface_output *surface_output;
wl_list_for_each(surface_output, &surface->current_outputs, link) {
if (surface_output->output->scale > scale) {
scale = surface_output->output->scale;
}
}
wlr_fractional_scale_v1_notify_scale(surface, scale);
}
void surface_enter_output(struct wlr_surface *surface,
struct sway_output *output) {
wlr_surface_send_enter(surface, output->wlr_output);
surface_update_outputs(surface);
}
void surface_leave_output(struct wlr_surface *surface,
struct sway_output *output) {
wlr_surface_send_leave(surface, output->wlr_output);
surface_update_outputs(surface);
}

View file

@ -577,7 +577,7 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
struct wlr_box window_box = { struct wlr_box window_box = {
c->pending.content_x - c->pending.x, c->pending.content_x - c->pending.x,
(c->current.border == B_PIXEL) ? c->current.border_thickness : 0, (c->current.border == B_PIXEL) ? c->pending.content_y - c->pending.y : 0,
c->pending.content_width, c->pending.content_width,
c->pending.content_height c->pending.content_height
}; };

View file

@ -739,6 +739,8 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
const char *event_type = json_object_get_string(json_object_array_get_idx(request, i)); const char *event_type = json_object_get_string(json_object_array_get_idx(request, i));
if (strcmp(event_type, "workspace") == 0) { if (strcmp(event_type, "workspace") == 0) {
client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE); client->subscribed_events |= event_mask(IPC_EVENT_WORKSPACE);
} else if (strcmp(event_type, "output") == 0) {
client->subscribed_events |= event_mask(IPC_EVENT_OUTPUT);
} else if (strcmp(event_type, "barconfig_update") == 0) { } else if (strcmp(event_type, "barconfig_update") == 0) {
client->subscribed_events |= event_mask(IPC_EVENT_BARCONFIG_UPDATE); client->subscribed_events |= event_mask(IPC_EVENT_BARCONFIG_UPDATE);
} else if (strcmp(event_type, "bar_state_update") == 0) { } else if (strcmp(event_type, "bar_state_update") == 0) {

View file

@ -5,6 +5,7 @@
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/output.h" #include "sway/output.h"
#include "sway/server.h" #include "sway/server.h"
#include "sway/surface.h"
struct sway_session_lock_surface { struct sway_session_lock_surface {
struct wlr_session_lock_surface_v1 *lock_surface; struct wlr_session_lock_surface_v1 *lock_surface;
@ -31,7 +32,7 @@ static void handle_surface_map(struct wl_listener *listener, void *data) {
if (server.session_lock.focused == NULL) { if (server.session_lock.focused == NULL) {
set_lock_focused_surface(surf->surface); set_lock_focused_surface(surf->surface);
} }
wlr_surface_send_enter(surf->surface, surf->output->wlr_output); surface_enter_output(surf->surface, surf->output);
output_damage_whole(surf->output); output_damage_whole(surf->output);
} }

View file

@ -14,6 +14,7 @@
#include <wlr/types/wlr_data_control_v1.h> #include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_drm.h> #include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h> #include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_idle_notify_v1.h> #include <wlr/types/wlr_idle_notify_v1.h>
@ -214,6 +215,7 @@ bool server_init(struct sway_server *server) {
wlr_single_pixel_buffer_manager_v1_create(server->wl_display); wlr_single_pixel_buffer_manager_v1_create(server->wl_display);
server->content_type_manager_v1 = server->content_type_manager_v1 =
wlr_content_type_manager_v1_create(server->wl_display, 1); wlr_content_type_manager_v1_create(server->wl_display, 1);
wlr_fractional_scale_manager_v1_create(server->wl_display, 1);
struct wlr_xdg_foreign_registry *foreign_registry = struct wlr_xdg_foreign_registry *foreign_registry =
wlr_xdg_foreign_registry_create(server->wl_display); wlr_xdg_foreign_registry_create(server->wl_display);

View file

@ -337,8 +337,9 @@ node and will have the following properties:
this, but borders are included. this, but borders are included.
|- window_rect |- window_rect
: object : object
: The geometry of the contents inside the node. The window decorations are : The geometry of the content inside the node. These coordinates are relative
excluded from this calculation, but borders are included. to the node itself. Window decorations and borders are outside the
_window_rect_
|- deco_rect |- deco_rect
: object : object
: The geometry of the decorations for the node relative to the parent node : The geometry of the decorations for the node relative to the parent node

View file

@ -3,14 +3,10 @@
#include <drm_fourcc.h> #include <drm_fourcc.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_subcompositor.h> #include <wlr/types/wlr_subcompositor.h>
#include <wlr/render/drm_format_set.h>
#include "linux-dmabuf-unstable-v1-protocol.h" #include "linux-dmabuf-unstable-v1-protocol.h"
#include "cairo_util.h" #include "cairo_util.h"
#include "pango.h" #include "pango.h"
@ -22,6 +18,7 @@
#include "sway/ipc-server.h" #include "sway/ipc-server.h"
#include "sway/output.h" #include "sway/output.h"
#include "sway/server.h" #include "sway/server.h"
#include "sway/surface.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
#include "sway/tree/workspace.h" #include "sway/tree/workspace.h"
@ -1060,16 +1057,6 @@ void container_end_mouse_operation(struct sway_container *container) {
} }
} }
static bool devid_from_fd(int fd, dev_t *devid) {
struct stat stat;
if (fstat(fd, &stat) != 0) {
sway_log_errno(SWAY_ERROR, "fstat failed");
return false;
}
*devid = stat.st_rdev;
return true;
}
static void set_fullscreen(struct sway_container *con, bool enable) { static void set_fullscreen(struct sway_container *con, bool enable) {
if (!con->view) { if (!con->view) {
return; return;
@ -1096,60 +1083,18 @@ static void set_fullscreen(struct sway_container *con, bool enable) {
} }
struct sway_output *output = con->pending.workspace->output; struct sway_output *output = con->pending.workspace->output;
struct wlr_output *wlr_output = output->wlr_output;
// TODO: add wlroots helpers for all of this stuff const struct wlr_linux_dmabuf_feedback_v1_init_options options = {
.main_renderer = server.renderer,
const struct wlr_drm_format_set *renderer_formats = .scanout_primary_output = output->wlr_output,
wlr_renderer_get_dmabuf_texture_formats(server.renderer);
assert(renderer_formats);
int renderer_drm_fd = wlr_renderer_get_drm_fd(server.renderer);
int backend_drm_fd = wlr_backend_get_drm_fd(wlr_output->backend);
if (renderer_drm_fd < 0 || backend_drm_fd < 0) {
return;
}
dev_t render_dev, scanout_dev;
if (!devid_from_fd(renderer_drm_fd, &render_dev) ||
!devid_from_fd(backend_drm_fd, &scanout_dev)) {
return;
}
const struct wlr_drm_format_set *output_formats =
wlr_output_get_primary_formats(output->wlr_output,
WLR_BUFFER_CAP_DMABUF);
if (!output_formats) {
return;
}
struct wlr_drm_format_set scanout_formats = {0};
if (!wlr_drm_format_set_intersect(&scanout_formats,
output_formats, renderer_formats)) {
return;
}
struct wlr_linux_dmabuf_feedback_v1_tranche tranches[] = {
{
.target_device = scanout_dev,
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
.formats = &scanout_formats,
},
{
.target_device = render_dev,
.formats = renderer_formats,
},
};
const struct wlr_linux_dmabuf_feedback_v1 feedback = {
.main_device = render_dev,
.tranches = tranches,
.tranches_len = sizeof(tranches) / sizeof(tranches[0]),
}; };
struct wlr_linux_dmabuf_feedback_v1 feedback = {0};
if (!wlr_linux_dmabuf_feedback_v1_init_with_options(&feedback, &options)) {
return;
}
wlr_linux_dmabuf_v1_set_surface_feedback(server.linux_dmabuf_v1, wlr_linux_dmabuf_v1_set_surface_feedback(server.linux_dmabuf_v1,
con->view->surface, &feedback); con->view->surface, &feedback);
wlr_linux_dmabuf_feedback_v1_finish(&feedback);
wlr_drm_format_set_finish(&scanout_formats);
} }
static void container_fullscreen_workspace(struct sway_container *con) { static void container_fullscreen_workspace(struct sway_container *con) {
@ -1321,14 +1266,14 @@ bool container_is_fullscreen_or_child(struct sway_container *container) {
static void surface_send_enter_iterator(struct wlr_surface *surface, static void surface_send_enter_iterator(struct wlr_surface *surface,
int x, int y, void *data) { int x, int y, void *data) {
struct wlr_output *wlr_output = data; struct sway_output *output = data;
wlr_surface_send_enter(surface, wlr_output); surface_enter_output(surface, output);
} }
static void surface_send_leave_iterator(struct wlr_surface *surface, static void surface_send_leave_iterator(struct wlr_surface *surface,
int x, int y, void *data) { int x, int y, void *data) {
struct wlr_output *wlr_output = data; struct sway_output *output = data;
wlr_surface_send_leave(surface, wlr_output); surface_leave_output(surface, output);
} }
void container_discover_outputs(struct sway_container *con) { void container_discover_outputs(struct sway_container *con) {
@ -1354,7 +1299,7 @@ void container_discover_outputs(struct sway_container *con) {
sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output); sway_log(SWAY_DEBUG, "Container %p entered output %p", con, output);
if (con->view) { if (con->view) {
view_for_each_surface(con->view, view_for_each_surface(con->view,
surface_send_enter_iterator, output->wlr_output); surface_send_enter_iterator, output);
if (con->view->foreign_toplevel) { if (con->view->foreign_toplevel) {
wlr_foreign_toplevel_handle_v1_output_enter( wlr_foreign_toplevel_handle_v1_output_enter(
con->view->foreign_toplevel, output->wlr_output); con->view->foreign_toplevel, output->wlr_output);
@ -1366,7 +1311,7 @@ void container_discover_outputs(struct sway_container *con) {
sway_log(SWAY_DEBUG, "Container %p left output %p", con, output); sway_log(SWAY_DEBUG, "Container %p left output %p", con, output);
if (con->view) { if (con->view) {
view_for_each_surface(con->view, view_for_each_surface(con->view,
surface_send_leave_iterator, output->wlr_output); surface_send_leave_iterator, output);
if (con->view->foreign_toplevel) { if (con->view->foreign_toplevel) {
wlr_foreign_toplevel_handle_v1_output_leave( wlr_foreign_toplevel_handle_v1_output_leave(
con->view->foreign_toplevel, output->wlr_output); con->view->foreign_toplevel, output->wlr_output);

View file

@ -25,6 +25,7 @@
#include "sway/output.h" #include "sway/output.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "sway/server.h" #include "sway/server.h"
#include "sway/surface.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/container.h" #include "sway/tree/container.h"
#include "sway/tree/view.h" #include "sway/tree/view.h"
@ -1148,7 +1149,7 @@ void view_child_init(struct sway_view_child *child,
if (container != NULL) { if (container != NULL) {
struct sway_workspace *workspace = container->pending.workspace; struct sway_workspace *workspace = container->pending.workspace;
if (workspace) { if (workspace) {
wlr_surface_send_enter(child->surface, workspace->output->wlr_output); surface_enter_output(child->surface, workspace->output);
} }
} }

View file

@ -33,11 +33,8 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
} }
struct wlr_seat *wlr_seat = event->token->seat; struct wlr_seat *wlr_seat = event->token->seat;
// The requesting seat may have been destroyed. struct sway_seat *seat = wlr_seat ? wlr_seat->data : NULL;
if (wlr_seat) { view_request_activate(view, seat);
struct sway_seat *seat = wlr_seat->data;
view_request_activate(view, seat);
}
} }
void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) { void xdg_activation_v1_handle_new_token(struct wl_listener *listener, void *data) {