Merge pull request #1657 from emersion/render-fixes

Misc minor fixes
master
Drew DeVault 7 years ago committed by GitHub
commit b6b674fd76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,6 @@ struct sway_server {
const char *socket; const char *socket;
struct wlr_backend *backend; struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_compositor *compositor; struct wlr_compositor *compositor;
struct wlr_data_device_manager *data_device_manager; struct wlr_data_device_manager *data_device_manager;

@ -41,6 +41,9 @@ static void rotate_child_position(double *sx, double *sy, double sw, double sh,
static void render_surface(struct wlr_surface *surface, static void render_surface(struct wlr_surface *surface,
struct wlr_output *wlr_output, struct timespec *when, struct wlr_output *wlr_output, struct timespec *when,
double lx, double ly, float rotation) { double lx, double ly, float rotation) {
struct wlr_renderer *renderer =
wlr_backend_get_renderer(wlr_output->backend);
if (!wlr_surface_has_buffer(surface)) { if (!wlr_surface_has_buffer(surface)) {
return; return;
} }
@ -65,8 +68,8 @@ static void render_surface(struct wlr_surface *surface,
float matrix[9]; float matrix[9];
wlr_matrix_project_box(matrix, &render_box, surface->current->transform, wlr_matrix_project_box(matrix, &render_box, surface->current->transform,
0, wlr_output->transform_matrix); 0, wlr_output->transform_matrix);
wlr_render_texture_with_matrix(server.renderer, surface->texture, wlr_render_texture_with_matrix(renderer, surface->texture, matrix,
matrix, 1.0f); // TODO: configurable alpha 1.0f); // TODO: configurable alpha
wlr_surface_send_frame_done(surface, when); wlr_surface_send_frame_done(surface, when);
} }
@ -192,15 +195,14 @@ static void render_layer(struct sway_output *output,
} }
} }
static void output_frame_notify(struct wl_listener *listener, void *data) { static void handle_output_frame(struct wl_listener *listener, void *data) {
struct sway_output *soutput = wl_container_of(listener, soutput, frame); struct sway_output *soutput = wl_container_of(listener, soutput, frame);
struct wlr_output *wlr_output = data; struct wlr_output *wlr_output = data;
struct sway_server *server = soutput->server; struct wlr_renderer *renderer =
struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); wlr_backend_get_renderer(wlr_output->backend);
int buffer_age = -1; wlr_output_make_current(wlr_output, NULL);
wlr_output_make_current(wlr_output, &buffer_age); wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height);
wlr_renderer_begin(server->renderer, wlr_output->width, wlr_output->height);
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
wlr_renderer_clear(renderer, clear_color); wlr_renderer_clear(renderer, clear_color);
@ -218,7 +220,8 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
&soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]);
struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *focus = sway_seat_get_focus_inactive(seat, soutput->swayc); struct sway_container *focus =
sway_seat_get_focus_inactive(seat, soutput->swayc);
struct sway_container *workspace = (focus->type == C_WORKSPACE ? struct sway_container *workspace = (focus->type == C_WORKSPACE ?
focus : focus :
container_parent(focus, C_WORKSPACE)); container_parent(focus, C_WORKSPACE));
@ -248,7 +251,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
render_layer(soutput, output_box, &now, render_layer(soutput, output_box, &now,
&soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); &soutput->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]);
wlr_renderer_end(server->renderer); wlr_renderer_end(renderer);
wlr_output_swap_buffers(wlr_output, &now, NULL); wlr_output_swap_buffers(wlr_output, &now, NULL);
soutput->last_frame = now; soutput->last_frame = now;
} }
@ -306,7 +309,7 @@ void handle_new_output(struct wl_listener *listener, void *data) {
sway_input_manager_configure_xcursor(input_manager); sway_input_manager_configure_xcursor(input_manager);
wl_signal_add(&wlr_output->events.frame, &output->frame); wl_signal_add(&wlr_output->events.frame, &output->frame);
output->frame.notify = output_frame_notify; output->frame.notify = handle_output_frame;
wl_signal_add(&wlr_output->events.destroy, &output->destroy); wl_signal_add(&wlr_output->events.destroy, &output->destroy);
output->destroy.notify = handle_output_destroy; output->destroy.notify = handle_output_destroy;
wl_signal_add(&wlr_output->events.mode, &output->mode); wl_signal_add(&wlr_output->events.mode, &output->mode);

@ -104,14 +104,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_surface *sway_surface = struct sway_xwayland_surface *sway_surface =
wl_container_of(listener, sway_surface, destroy); wl_container_of(listener, sway_surface, destroy);
struct wlr_xwayland_surface *xsurface = data;
wl_list_remove(&sway_surface->commit.link); wl_list_remove(&sway_surface->commit.link);
wl_list_remove(&sway_surface->destroy.link); wl_list_remove(&sway_surface->destroy.link);
wl_list_remove(&sway_surface->request_configure.link); wl_list_remove(&sway_surface->request_configure.link);
if (xsurface->override_redirect && xsurface->mapped) {
wl_list_remove(&sway_surface->view->unmanaged_view_link); wl_list_remove(&sway_surface->view->unmanaged_view_link);
wl_list_init(&sway_surface->view->unmanaged_view_link);
}
struct sway_container *parent = container_view_destroy(sway_surface->view->swayc); struct sway_container *parent = container_view_destroy(sway_surface->view->swayc);
if (parent) { if (parent) {
@ -125,11 +122,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
static void handle_unmap_notify(struct wl_listener *listener, void *data) { static void handle_unmap_notify(struct wl_listener *listener, void *data) {
struct sway_xwayland_surface *sway_surface = struct sway_xwayland_surface *sway_surface =
wl_container_of(listener, sway_surface, unmap_notify); wl_container_of(listener, sway_surface, unmap_notify);
struct wlr_xwayland_surface *xsurface = data;
if (xsurface->override_redirect && xsurface->mapped) {
wl_list_remove(&sway_surface->view->unmanaged_view_link); wl_list_remove(&sway_surface->view->unmanaged_view_link);
wl_list_init(&sway_surface->view->unmanaged_view_link); wl_list_init(&sway_surface->view->unmanaged_view_link);
}
// take it out of the tree // take it out of the tree
struct sway_container *parent = container_view_destroy(sway_surface->view->swayc); struct sway_container *parent = container_view_destroy(sway_surface->view->swayc);
@ -150,7 +145,9 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
sway_surface->view->surface = xsurface->surface; sway_surface->view->surface = xsurface->surface;
// put it back into the tree // put it back into the tree
if (xsurface->override_redirect) { if (wlr_xwayland_surface_is_unmanaged(xsurface) ||
xsurface->override_redirect) {
wl_list_remove(&sway_surface->view->unmanaged_view_link);
wl_list_insert(&root_container.sway_root->unmanaged_views, wl_list_insert(&root_container.sway_root->unmanaged_views,
&sway_surface->view->unmanaged_view_link); &sway_surface->view->unmanaged_view_link);
} else { } else {
@ -209,6 +206,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
sway_view->surface = xsurface->surface; sway_view->surface = xsurface->surface;
sway_surface->view = sway_view; sway_surface->view = sway_view;
wl_list_init(&sway_view->unmanaged_view_link);
// TODO: // TODO:
// - Look up pid and open on appropriate workspace // - Look up pid and open on appropriate workspace
// - Set new view to maximized so it behaves nicely // - Set new view to maximized so it behaves nicely
@ -230,18 +229,5 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_signal_add(&xsurface->events.map_notify, &sway_surface->map_notify); wl_signal_add(&xsurface->events.map_notify, &sway_surface->map_notify);
sway_surface->map_notify.notify = handle_map_notify; sway_surface->map_notify.notify = handle_map_notify;
if (wlr_xwayland_surface_is_unmanaged(xsurface)) { handle_map_notify(&sway_surface->map_notify, xsurface);
// these don't get a container in the tree
wl_list_insert(&root_container.sway_root->unmanaged_views,
&sway_view->unmanaged_view_link);
return;
}
struct sway_seat *seat = input_manager_current_seat(input_manager);
struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
struct sway_container *cont = container_view_create(focus, sway_view);
sway_view->swayc = cont;
arrange_windows(cont->parent, -1, -1);
sway_input_manager_set_focus(input_manager, cont);
} }

@ -1,19 +1,19 @@
#define _POSIX_C_SOURCE 200112L #define _POSIX_C_SOURCE 200112L
#include <stdlib.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/render/gles2.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_layer_shell.h> #include <wlr/types/wlr_layer_shell.h>
#include <wlr/types/wlr_screenshooter.h> #include <wlr/types/wlr_screenshooter.h>
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_wl_shell.h> #include <wlr/types/wlr_wl_shell.h>
#include <wlr/util/log.h>
// TODO WLR: make Xwayland optional // TODO WLR: make Xwayland optional
#include <wlr/xwayland.h> #include <wlr/xwayland.h>
#include <wlr/util/log.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/server.h" #include "sway/server.h"
@ -42,11 +42,12 @@ bool server_init(struct sway_server *server) {
server->wl_event_loop = wl_display_get_event_loop(server->wl_display); server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
server->backend = wlr_backend_autocreate(server->wl_display); server->backend = wlr_backend_autocreate(server->wl_display);
server->renderer = wlr_gles2_renderer_create(server->backend); struct wlr_renderer *renderer = wlr_backend_get_renderer(server->backend);
assert(renderer);
wl_display_init_shm(server->wl_display); wl_display_init_shm(server->wl_display);
server->compositor = wlr_compositor_create( server->compositor = wlr_compositor_create(server->wl_display, renderer);
server->wl_display, server->renderer);
server->data_device_manager = server->data_device_manager =
wlr_data_device_manager_create(server->wl_display); wlr_data_device_manager_create(server->wl_display);
@ -95,8 +96,7 @@ bool server_init(struct sway_server *server) {
} }
void server_fini(struct sway_server *server) { void server_fini(struct sway_server *server) {
// TODO WLR: tear down more stuff // TODO
wlr_backend_destroy(server->backend);
} }
void server_run(struct sway_server *server) { void server_run(struct sway_server *server) {

Loading…
Cancel
Save