mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
Use scene-graph for damage tracking
References: https://github.com/swaywm/wlroots/pull/3117
This commit is contained in:
parent
128fa90ea1
commit
d46e8a82dd
13 changed files with 11 additions and 299 deletions
12
cage.c
12
cage.c
|
|
@ -187,9 +187,6 @@ usage(FILE *file, const char *cage)
|
||||||
"Usage: %s [OPTIONS] [--] APPLICATION\n"
|
"Usage: %s [OPTIONS] [--] APPLICATION\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -d\t Don't draw client side decorations, when possible\n"
|
" -d\t Don't draw client side decorations, when possible\n"
|
||||||
#ifdef DEBUG
|
|
||||||
" -D\t Turn on damage tracking debugging\n"
|
|
||||||
#endif
|
|
||||||
" -h\t Display this help message\n"
|
" -h\t Display this help message\n"
|
||||||
" -m extend Extend the display across all connected outputs (default)\n"
|
" -m extend Extend the display across all connected outputs (default)\n"
|
||||||
" -m last Use only the last connected output\n"
|
" -m last Use only the last connected output\n"
|
||||||
|
|
@ -205,20 +202,11 @@ static bool
|
||||||
parse_args(struct cg_server *server, int argc, char *argv[])
|
parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
#ifdef DEBUG
|
|
||||||
while ((c = getopt(argc, argv, "dDhm:rsv")) != -1) {
|
|
||||||
#else
|
|
||||||
while ((c = getopt(argc, argv, "dhm:rsv")) != -1) {
|
while ((c = getopt(argc, argv, "dhm:rsv")) != -1) {
|
||||||
#endif
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
server->xdg_decoration = true;
|
server->xdg_decoration = true;
|
||||||
break;
|
break;
|
||||||
#ifdef DEBUG
|
|
||||||
case 'D':
|
|
||||||
server->debug_damage_tracking = true;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(stdout, argv[0]);
|
usage(stdout, argv[0]);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,6 @@ cage_sources = [
|
||||||
'cage.c',
|
'cage.c',
|
||||||
'idle_inhibit_v1.c',
|
'idle_inhibit_v1.c',
|
||||||
'output.c',
|
'output.c',
|
||||||
'render.c',
|
|
||||||
'seat.c',
|
'seat.c',
|
||||||
'util.c',
|
'util.c',
|
||||||
'view.c',
|
'view.c',
|
||||||
|
|
|
||||||
90
output.c
90
output.c
|
|
@ -225,50 +225,9 @@ output_disable(struct cg_output *output)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
damage_surface_iterator(struct cg_output *output, struct wlr_surface *surface, struct wlr_box *box, void *user_data)
|
handle_output_frame(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
struct cg_output *output = wl_container_of(listener, output, frame);
|
||||||
bool whole = *(bool *) user_data;
|
|
||||||
|
|
||||||
scale_box(box, output->wlr_output->scale);
|
|
||||||
|
|
||||||
if (whole) {
|
|
||||||
wlr_output_damage_add_box(output->damage, box);
|
|
||||||
} else if (pixman_region32_not_empty(&surface->buffer_damage)) {
|
|
||||||
pixman_region32_t damage;
|
|
||||||
pixman_region32_init(&damage);
|
|
||||||
wlr_surface_get_effective_damage(surface, &damage);
|
|
||||||
|
|
||||||
wlr_region_scale(&damage, &damage, wlr_output->scale);
|
|
||||||
if (ceil(wlr_output->scale) > surface->current.scale) {
|
|
||||||
/* When scaling up a surface it'll become
|
|
||||||
blurry, so we need to expand the damage
|
|
||||||
region. */
|
|
||||||
wlr_region_expand(&damage, &damage, ceil(wlr_output->scale) - surface->current.scale);
|
|
||||||
}
|
|
||||||
pixman_region32_translate(&damage, box->x, box->y);
|
|
||||||
wlr_output_damage_add(output->damage, &damage);
|
|
||||||
pixman_region32_fini(&damage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
output_damage_surface(struct cg_output *output, struct wlr_surface *surface, double lx, double ly, bool whole)
|
|
||||||
{
|
|
||||||
if (!output->wlr_output->enabled) {
|
|
||||||
wlr_log(WLR_DEBUG, "Not adding damage for disabled output %s", output->wlr_output->name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double ox = lx, oy = ly;
|
|
||||||
wlr_output_layout_output_coords(output->server->output_layout, output->wlr_output, &ox, &oy);
|
|
||||||
output_surface_for_each_surface(output, surface, ox, oy, damage_surface_iterator, &whole);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
handle_output_damage_frame(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct cg_output *output = wl_container_of(listener, output, damage_frame);
|
|
||||||
struct send_frame_done_data frame_data = {0};
|
struct send_frame_done_data frame_data = {0};
|
||||||
|
|
||||||
if (!output->wlr_output->enabled) {
|
if (!output->wlr_output->enabled) {
|
||||||
|
|
@ -287,33 +246,12 @@ handle_output_damage_frame(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
last_scanned_out = scanned_out;
|
last_scanned_out = scanned_out;
|
||||||
|
|
||||||
if (scanned_out) {
|
if (!scanned_out) {
|
||||||
goto frame_done;
|
wlr_scene_output_commit(output->scene_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needs_frame;
|
|
||||||
pixman_region32_t damage;
|
|
||||||
pixman_region32_init(&damage);
|
|
||||||
if (!wlr_output_damage_attach_render(output->damage, &needs_frame, &damage)) {
|
|
||||||
wlr_log(WLR_ERROR, "Cannot make damage output current");
|
|
||||||
goto damage_finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!needs_frame) {
|
|
||||||
wlr_output_rollback(output->wlr_output);
|
|
||||||
goto damage_finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
output_render(output, &damage);
|
|
||||||
|
|
||||||
damage_finish:
|
|
||||||
pixman_region32_fini(&damage);
|
|
||||||
|
|
||||||
frame_done:
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &frame_data.when);
|
clock_gettime(CLOCK_MONOTONIC, &frame_data.when);
|
||||||
send_frame_done(output, &frame_data);
|
send_frame_done(output, &frame_data);
|
||||||
|
|
||||||
wlr_output_damage_add_whole(output->damage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -357,8 +295,7 @@ output_destroy(struct cg_output *output)
|
||||||
wl_list_remove(&output->destroy.link);
|
wl_list_remove(&output->destroy.link);
|
||||||
wl_list_remove(&output->commit.link);
|
wl_list_remove(&output->commit.link);
|
||||||
wl_list_remove(&output->mode.link);
|
wl_list_remove(&output->mode.link);
|
||||||
wl_list_remove(&output->damage_frame.link);
|
wl_list_remove(&output->frame.link);
|
||||||
wl_list_remove(&output->damage_destroy.link);
|
|
||||||
wl_list_remove(&output->link);
|
wl_list_remove(&output->link);
|
||||||
|
|
||||||
wlr_output_layout_remove(server->output_layout, output->wlr_output);
|
wlr_output_layout_remove(server->output_layout, output->wlr_output);
|
||||||
|
|
@ -380,18 +317,10 @@ output_destroy(struct cg_output *output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
handle_output_damage_destroy(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct cg_output *output = wl_container_of(listener, output, damage_destroy);
|
|
||||||
output_destroy(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_output_destroy(struct wl_listener *listener, void *data)
|
handle_output_destroy(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct cg_output *output = wl_container_of(listener, output, destroy);
|
struct cg_output *output = wl_container_of(listener, output, destroy);
|
||||||
wlr_output_damage_destroy(output->damage);
|
|
||||||
output_destroy(output);
|
output_destroy(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -414,7 +343,8 @@ handle_new_output(struct wl_listener *listener, void *data)
|
||||||
|
|
||||||
output->wlr_output = wlr_output;
|
output->wlr_output = wlr_output;
|
||||||
output->server = server;
|
output->server = server;
|
||||||
output->damage = wlr_output_damage_create(wlr_output);
|
output->scene_output = wlr_scene_output_create(server->scene, wlr_output);
|
||||||
|
|
||||||
wl_list_insert(&server->outputs, &output->link);
|
wl_list_insert(&server->outputs, &output->link);
|
||||||
|
|
||||||
output->commit.notify = handle_output_commit;
|
output->commit.notify = handle_output_commit;
|
||||||
|
|
@ -423,10 +353,8 @@ handle_new_output(struct wl_listener *listener, void *data)
|
||||||
wl_signal_add(&wlr_output->events.mode, &output->mode);
|
wl_signal_add(&wlr_output->events.mode, &output->mode);
|
||||||
output->destroy.notify = handle_output_destroy;
|
output->destroy.notify = handle_output_destroy;
|
||||||
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
|
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
|
||||||
output->damage_frame.notify = handle_output_damage_frame;
|
output->frame.notify = handle_output_frame;
|
||||||
wl_signal_add(&output->damage->events.frame, &output->damage_frame);
|
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||||
output->damage_destroy.notify = handle_output_damage_destroy;
|
|
||||||
wl_signal_add(&output->damage->events.destroy, &output->damage_destroy);
|
|
||||||
|
|
||||||
struct wlr_output_mode *preferred_mode = wlr_output_preferred_mode(wlr_output);
|
struct wlr_output_mode *preferred_mode = wlr_output_preferred_mode(wlr_output);
|
||||||
if (preferred_mode) {
|
if (preferred_mode) {
|
||||||
|
|
|
||||||
8
output.h
8
output.h
|
|
@ -11,13 +11,12 @@
|
||||||
struct cg_output {
|
struct cg_output {
|
||||||
struct cg_server *server;
|
struct cg_server *server;
|
||||||
struct wlr_output *wlr_output;
|
struct wlr_output *wlr_output;
|
||||||
struct wlr_output_damage *damage;
|
struct wlr_scene_output *scene_output;
|
||||||
|
|
||||||
struct wl_listener commit;
|
struct wl_listener commit;
|
||||||
struct wl_listener mode;
|
struct wl_listener mode;
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener damage_frame;
|
struct wl_listener frame;
|
||||||
struct wl_listener damage_destroy;
|
|
||||||
|
|
||||||
struct wl_list link; // cg_server::outputs
|
struct wl_list link; // cg_server::outputs
|
||||||
};
|
};
|
||||||
|
|
@ -26,9 +25,6 @@ typedef void (*cg_surface_iterator_func_t)(struct cg_output *output, struct wlr_
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
void handle_new_output(struct wl_listener *listener, void *data);
|
void handle_new_output(struct wl_listener *listener, void *data);
|
||||||
void output_surface_for_each_surface(struct cg_output *output, struct wlr_surface *surface, double ox, double oy,
|
|
||||||
cg_surface_iterator_func_t iterator, void *user_data);
|
|
||||||
void output_damage_surface(struct cg_output *output, struct wlr_surface *surface, double lx, double ly, bool whole);
|
|
||||||
void output_set_window_title(struct cg_output *output, const char *title);
|
void output_set_window_title(struct cg_output *output, const char *title);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
109
render.c
109
render.c
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* Cage: A Wayland kiosk.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2018-2020 Jente Hidskes
|
|
||||||
* Copyright (C) 2019 The Sway authors
|
|
||||||
*
|
|
||||||
* See the LICENSE file accompanying this file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <wayland-server-core.h>
|
|
||||||
#include <wlr/backend.h>
|
|
||||||
#include <wlr/render/wlr_renderer.h>
|
|
||||||
#include <wlr/types/wlr_matrix.h>
|
|
||||||
#include <wlr/types/wlr_output.h>
|
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
|
||||||
#include <wlr/types/wlr_scene.h>
|
|
||||||
#include <wlr/types/wlr_surface.h>
|
|
||||||
#include <wlr/util/box.h>
|
|
||||||
#include <wlr/util/log.h>
|
|
||||||
#include <wlr/util/region.h>
|
|
||||||
|
|
||||||
#include "output.h"
|
|
||||||
#include "seat.h"
|
|
||||||
#include "server.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "view.h"
|
|
||||||
|
|
||||||
static void
|
|
||||||
scissor_output(struct wlr_output *output, pixman_box32_t *rect)
|
|
||||||
{
|
|
||||||
struct wlr_box box = {
|
|
||||||
.x = rect->x1,
|
|
||||||
.y = rect->y1,
|
|
||||||
.width = rect->x2 - rect->x1,
|
|
||||||
.height = rect->y2 - rect->y1,
|
|
||||||
};
|
|
||||||
|
|
||||||
int output_width, output_height;
|
|
||||||
wlr_output_transformed_resolution(output, &output_width, &output_height);
|
|
||||||
enum wl_output_transform transform = wlr_output_transform_invert(output->transform);
|
|
||||||
wlr_box_transform(&box, &box, transform, output_width, output_height);
|
|
||||||
|
|
||||||
wlr_renderer_scissor(output->renderer, &box);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct render_data {
|
|
||||||
pixman_region32_t *damage;
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
output_render(struct cg_output *output, pixman_region32_t *damage)
|
|
||||||
{
|
|
||||||
struct cg_server *server = output->server;
|
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
|
||||||
|
|
||||||
wlr_renderer_begin(server->renderer, wlr_output->width, wlr_output->height);
|
|
||||||
|
|
||||||
if (!pixman_region32_not_empty(damage)) {
|
|
||||||
wlr_log(WLR_DEBUG, "Output isn't damaged but needs a buffer swap");
|
|
||||||
goto renderer_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (server->debug_damage_tracking) {
|
|
||||||
wlr_renderer_clear(server->renderer, (float[]){1.0f, 0.0f, 0.0f, 1.0f});
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
|
||||||
int nrects;
|
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(damage, &nrects);
|
|
||||||
for (int i = 0; i < nrects; i++) {
|
|
||||||
scissor_output(wlr_output, &rects[i]);
|
|
||||||
wlr_renderer_clear(server->renderer, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
double lx = 0, ly = 0;
|
|
||||||
wlr_output_layout_output_coords(output->server->output_layout, output->wlr_output, &lx, &ly);
|
|
||||||
wlr_scene_render_output(server->scene, wlr_output, lx, ly, damage);
|
|
||||||
|
|
||||||
renderer_end:
|
|
||||||
/* Draw software cursor in case hardware cursors aren't
|
|
||||||
available. This is a no-op when they are. */
|
|
||||||
wlr_output_render_software_cursors(wlr_output, damage);
|
|
||||||
wlr_renderer_scissor(server->renderer, NULL);
|
|
||||||
wlr_renderer_end(server->renderer);
|
|
||||||
|
|
||||||
int output_width, output_height;
|
|
||||||
wlr_output_transformed_resolution(wlr_output, &output_width, &output_height);
|
|
||||||
|
|
||||||
pixman_region32_t frame_damage;
|
|
||||||
pixman_region32_init(&frame_damage);
|
|
||||||
|
|
||||||
enum wl_output_transform transform = wlr_output_transform_invert(wlr_output->transform);
|
|
||||||
wlr_region_transform(&frame_damage, &output->damage->current, transform, output_width, output_height);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (server->debug_damage_tracking) {
|
|
||||||
pixman_region32_union_rect(&frame_damage, &frame_damage, 0, 0, output_width, output_height);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wlr_output_set_damage(wlr_output, &frame_damage);
|
|
||||||
pixman_region32_fini(&frame_damage);
|
|
||||||
|
|
||||||
if (!wlr_output_commit(wlr_output)) {
|
|
||||||
wlr_log(WLR_ERROR, "Could not commit output");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
14
seat.c
14
seat.c
|
|
@ -587,15 +587,6 @@ handle_cursor_motion(struct wl_listener *listener, void *data)
|
||||||
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
wlr_idle_notify_activity(seat->server->idle, seat->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
drag_icon_damage(struct cg_drag_icon *drag_icon)
|
|
||||||
{
|
|
||||||
struct cg_output *output;
|
|
||||||
wl_list_for_each (output, &drag_icon->seat->server->outputs, link) {
|
|
||||||
output_damage_surface(output, drag_icon->wlr_drag_icon->surface, drag_icon->lx, drag_icon->ly, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drag_icon_update_position(struct cg_drag_icon *drag_icon)
|
drag_icon_update_position(struct cg_drag_icon *drag_icon)
|
||||||
{
|
{
|
||||||
|
|
@ -603,8 +594,6 @@ drag_icon_update_position(struct cg_drag_icon *drag_icon)
|
||||||
struct cg_seat *seat = drag_icon->seat;
|
struct cg_seat *seat = drag_icon->seat;
|
||||||
struct wlr_touch_point *point;
|
struct wlr_touch_point *point;
|
||||||
|
|
||||||
drag_icon_damage(drag_icon);
|
|
||||||
|
|
||||||
switch (wlr_icon->drag->grab_type) {
|
switch (wlr_icon->drag->grab_type) {
|
||||||
case WLR_DRAG_GRAB_KEYBOARD:
|
case WLR_DRAG_GRAB_KEYBOARD:
|
||||||
return;
|
return;
|
||||||
|
|
@ -622,8 +611,6 @@ drag_icon_update_position(struct cg_drag_icon *drag_icon)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
drag_icon_damage(drag_icon);
|
|
||||||
|
|
||||||
wlr_scene_node_set_position(drag_icon->scene_node, drag_icon->lx, drag_icon->ly);
|
wlr_scene_node_set_position(drag_icon->scene_node, drag_icon->lx, drag_icon->ly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -632,7 +619,6 @@ handle_drag_icon_destroy(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct cg_drag_icon *drag_icon = wl_container_of(listener, drag_icon, destroy);
|
struct cg_drag_icon *drag_icon = wl_container_of(listener, drag_icon, destroy);
|
||||||
|
|
||||||
drag_icon_damage(drag_icon);
|
|
||||||
wl_list_remove(&drag_icon->link);
|
wl_list_remove(&drag_icon->link);
|
||||||
wl_list_remove(&drag_icon->destroy.link);
|
wl_list_remove(&drag_icon->destroy.link);
|
||||||
wlr_scene_node_destroy(drag_icon->scene_node);
|
wlr_scene_node_destroy(drag_icon->scene_node);
|
||||||
|
|
|
||||||
3
server.h
3
server.h
|
|
@ -51,9 +51,6 @@ struct cg_server {
|
||||||
bool xdg_decoration;
|
bool xdg_decoration;
|
||||||
bool allow_vt_switch;
|
bool allow_vt_switch;
|
||||||
enum wl_output_transform output_transform;
|
enum wl_output_transform output_transform;
|
||||||
#ifdef DEBUG
|
|
||||||
bool debug_damage_tracking;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
31
view.c
31
view.c
|
|
@ -24,13 +24,6 @@
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
|
||||||
view_child_handle_commit(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct cg_view_child *child = wl_container_of(listener, child, commit);
|
|
||||||
view_damage_part(child->view);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
view_child_finish(struct cg_view_child *child)
|
view_child_finish(struct cg_view_child *child)
|
||||||
{
|
{
|
||||||
|
|
@ -38,10 +31,7 @@ view_child_finish(struct cg_view_child *child)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
view_damage_whole(child->view);
|
|
||||||
|
|
||||||
wl_list_remove(&child->link);
|
wl_list_remove(&child->link);
|
||||||
wl_list_remove(&child->commit.link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -50,9 +40,6 @@ view_child_init(struct cg_view_child *child, struct cg_view *view, struct wlr_su
|
||||||
child->view = view;
|
child->view = view;
|
||||||
child->wlr_surface = wlr_surface;
|
child->wlr_surface = wlr_surface;
|
||||||
|
|
||||||
child->commit.notify = view_child_handle_commit;
|
|
||||||
wl_signal_add(&wlr_surface->events.commit, &child->commit);
|
|
||||||
|
|
||||||
wl_list_insert(&view->children, &child->link);
|
wl_list_insert(&view->children, &child->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,24 +65,6 @@ view_is_transient_for(struct cg_view *child, struct cg_view *parent)
|
||||||
return child->impl->is_transient_for(child, parent);
|
return child->impl->is_transient_for(child, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
view_damage_part(struct cg_view *view)
|
|
||||||
{
|
|
||||||
struct cg_output *output;
|
|
||||||
wl_list_for_each (output, &view->server->outputs, link) {
|
|
||||||
output_damage_surface(output, view->wlr_surface, view->lx, view->ly, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
view_damage_whole(struct cg_view *view)
|
|
||||||
{
|
|
||||||
struct cg_output *output;
|
|
||||||
wl_list_for_each (output, &view->server->outputs, link) {
|
|
||||||
output_damage_surface(output, view->wlr_surface, view->lx, view->ly, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
view_activate(struct cg_view *view, bool activate)
|
view_activate(struct cg_view *view, bool activate)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
4
view.h
4
view.h
|
|
@ -50,16 +50,12 @@ struct cg_view_child {
|
||||||
struct wlr_surface *wlr_surface;
|
struct wlr_surface *wlr_surface;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
|
||||||
struct wl_listener commit;
|
|
||||||
|
|
||||||
void (*destroy)(struct cg_view_child *child);
|
void (*destroy)(struct cg_view_child *child);
|
||||||
};
|
};
|
||||||
|
|
||||||
char *view_get_title(struct cg_view *view);
|
char *view_get_title(struct cg_view *view);
|
||||||
bool view_is_primary(struct cg_view *view);
|
bool view_is_primary(struct cg_view *view);
|
||||||
bool view_is_transient_for(struct cg_view *child, struct cg_view *parent);
|
bool view_is_transient_for(struct cg_view *child, struct cg_view *parent);
|
||||||
void view_damage_part(struct cg_view *view);
|
|
||||||
void view_damage_whole(struct cg_view *view);
|
|
||||||
void view_activate(struct cg_view *view, bool activate);
|
void view_activate(struct cg_view *view, bool activate);
|
||||||
void view_position(struct cg_view *view);
|
void view_position(struct cg_view *view);
|
||||||
void view_unmap(struct cg_view *view);
|
void view_unmap(struct cg_view *view);
|
||||||
|
|
|
||||||
19
xdg_shell.c
19
xdg_shell.c
|
|
@ -69,7 +69,6 @@ handle_xdg_popup_map(struct wl_listener *listener, void *data)
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
wlr_xdg_popup_get_position(popup->wlr_popup, &sx, &sy);
|
wlr_xdg_popup_get_position(popup->wlr_popup, &sx, &sy);
|
||||||
wlr_scene_node_set_position(&popup->scene_surface->node, sx, sy);
|
wlr_scene_node_set_position(&popup->scene_surface->node, sx, sy);
|
||||||
view_damage_whole(popup->view_child.view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -77,7 +76,6 @@ handle_xdg_popup_unmap(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct cg_xdg_popup *popup = wl_container_of(listener, popup, unmap);
|
struct cg_xdg_popup *popup = wl_container_of(listener, popup, unmap);
|
||||||
wlr_scene_node_destroy(&popup->scene_surface->node);
|
wlr_scene_node_destroy(&popup->scene_surface->node);
|
||||||
view_damage_whole(popup->view_child.view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -235,24 +233,12 @@ handle_xdg_shell_surface_request_fullscreen(struct wl_listener *listener, void *
|
||||||
wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_surface, event->fullscreen);
|
wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_surface, event->fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
handle_xdg_shell_surface_commit(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit);
|
|
||||||
struct cg_view *view = &xdg_shell_view->view;
|
|
||||||
view_damage_part(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_xdg_shell_surface_unmap(struct wl_listener *listener, void *data)
|
handle_xdg_shell_surface_unmap(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, unmap);
|
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, unmap);
|
||||||
struct cg_view *view = &xdg_shell_view->view;
|
struct cg_view *view = &xdg_shell_view->view;
|
||||||
|
|
||||||
view_damage_whole(view);
|
|
||||||
|
|
||||||
wl_list_remove(&xdg_shell_view->commit.link);
|
|
||||||
|
|
||||||
view_unmap(view);
|
view_unmap(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,12 +248,7 @@ handle_xdg_shell_surface_map(struct wl_listener *listener, void *data)
|
||||||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, map);
|
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, map);
|
||||||
struct cg_view *view = &xdg_shell_view->view;
|
struct cg_view *view = &xdg_shell_view->view;
|
||||||
|
|
||||||
xdg_shell_view->commit.notify = handle_xdg_shell_surface_commit;
|
|
||||||
wl_signal_add(&xdg_shell_view->xdg_surface->surface->events.commit, &xdg_shell_view->commit);
|
|
||||||
|
|
||||||
view_map(view, xdg_shell_view->xdg_surface->surface);
|
view_map(view, xdg_shell_view->xdg_surface->surface);
|
||||||
|
|
||||||
view_damage_whole(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ struct cg_xdg_shell_view {
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener unmap;
|
struct wl_listener unmap;
|
||||||
struct wl_listener map;
|
struct wl_listener map;
|
||||||
struct wl_listener commit;
|
|
||||||
struct wl_listener request_fullscreen;
|
struct wl_listener request_fullscreen;
|
||||||
struct wl_listener new_popup;
|
struct wl_listener new_popup;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
17
xwayland.c
17
xwayland.c
|
|
@ -103,24 +103,12 @@ handle_xwayland_surface_request_fullscreen(struct wl_listener *listener, void *d
|
||||||
wlr_xwayland_surface_set_fullscreen(xwayland_view->xwayland_surface, xwayland_surface->fullscreen);
|
wlr_xwayland_surface_set_fullscreen(xwayland_view->xwayland_surface, xwayland_surface->fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
handle_xwayland_surface_commit(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
struct cg_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, commit);
|
|
||||||
struct cg_view *view = &xwayland_view->view;
|
|
||||||
view_damage_part(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_xwayland_surface_unmap(struct wl_listener *listener, void *data)
|
handle_xwayland_surface_unmap(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
struct cg_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, unmap);
|
struct cg_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, unmap);
|
||||||
struct cg_view *view = &xwayland_view->view;
|
struct cg_view *view = &xwayland_view->view;
|
||||||
|
|
||||||
view_damage_whole(view);
|
|
||||||
|
|
||||||
wl_list_remove(&xwayland_view->commit.link);
|
|
||||||
|
|
||||||
view_unmap(view);
|
view_unmap(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,12 +123,7 @@ handle_xwayland_surface_map(struct wl_listener *listener, void *data)
|
||||||
view->ly = xwayland_view->xwayland_surface->y;
|
view->ly = xwayland_view->xwayland_surface->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
xwayland_view->commit.notify = handle_xwayland_surface_commit;
|
|
||||||
wl_signal_add(&xwayland_view->xwayland_surface->surface->events.commit, &xwayland_view->commit);
|
|
||||||
|
|
||||||
view_map(view, xwayland_view->xwayland_surface->surface);
|
view_map(view, xwayland_view->xwayland_surface->surface);
|
||||||
|
|
||||||
view_damage_whole(view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ struct cg_xwayland_view {
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener unmap;
|
struct wl_listener unmap;
|
||||||
struct wl_listener map;
|
struct wl_listener map;
|
||||||
struct wl_listener commit;
|
|
||||||
struct wl_listener request_fullscreen;
|
struct wl_listener request_fullscreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue