mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 07:55:59 +01:00
subcompositor: move+rename subsurface_parent_commit()
This commit is contained in:
parent
4cc3abb966
commit
3abedaf211
3 changed files with 52 additions and 45 deletions
8
include/types/wlr_subcompositor.h
Normal file
8
include/types/wlr_subcompositor.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef TYPES_WLR_SUBCOMPOSITOR_H
|
||||||
|
#define TYPES_WLR_SUBCOMPOSITOR_H
|
||||||
|
|
||||||
|
#include <wlr/types/wlr_subcompositor.h>
|
||||||
|
|
||||||
|
void subsurface_handle_parent_commit(struct wlr_subsurface *subsurface);
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,6 +12,7 @@
|
||||||
#include <wlr/util/region.h>
|
#include <wlr/util/region.h>
|
||||||
#include "types/wlr_buffer.h"
|
#include "types/wlr_buffer.h"
|
||||||
#include "types/wlr_region.h"
|
#include "types/wlr_region.h"
|
||||||
|
#include "types/wlr_subcompositor.h"
|
||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
|
|
||||||
#define COMPOSITOR_VERSION 5
|
#define COMPOSITOR_VERSION 5
|
||||||
|
@ -405,8 +406,6 @@ static void surface_update_input_region(struct wlr_surface *surface) {
|
||||||
|
|
||||||
static void surface_state_init(struct wlr_surface_state *state);
|
static void surface_state_init(struct wlr_surface_state *state);
|
||||||
|
|
||||||
static void subsurface_parent_commit(struct wlr_subsurface *subsurface);
|
|
||||||
|
|
||||||
static void surface_cache_pending(struct wlr_surface *surface) {
|
static void surface_cache_pending(struct wlr_surface *surface) {
|
||||||
struct wlr_surface_state *cached = calloc(1, sizeof(*cached));
|
struct wlr_surface_state *cached = calloc(1, sizeof(*cached));
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
|
@ -468,7 +467,7 @@ static void surface_commit_state(struct wlr_surface *surface,
|
||||||
wl_list_insert(&surface->current.subsurfaces_above,
|
wl_list_insert(&surface->current.subsurfaces_above,
|
||||||
&subsurface->current.link);
|
&subsurface->current.link);
|
||||||
|
|
||||||
subsurface_parent_commit(subsurface);
|
subsurface_handle_parent_commit(subsurface);
|
||||||
}
|
}
|
||||||
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
|
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
|
||||||
pending.link) {
|
pending.link) {
|
||||||
|
@ -476,7 +475,7 @@ static void surface_commit_state(struct wlr_surface *surface,
|
||||||
wl_list_insert(&surface->current.subsurfaces_below,
|
wl_list_insert(&surface->current.subsurfaces_below,
|
||||||
&subsurface->current.link);
|
&subsurface->current.link);
|
||||||
|
|
||||||
subsurface_parent_commit(subsurface);
|
subsurface_handle_parent_commit(subsurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're committing the pending state, bump the pending sequence number
|
// If we're committing the pending state, bump the pending sequence number
|
||||||
|
@ -492,47 +491,6 @@ static void surface_commit_state(struct wlr_surface *surface,
|
||||||
wl_signal_emit_mutable(&surface->events.commit, surface);
|
wl_signal_emit_mutable(&surface->events.commit, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void collect_subsurface_damage_iter(struct wlr_surface *surface,
|
|
||||||
int sx, int sy, void *data) {
|
|
||||||
struct wlr_subsurface *subsurface = data;
|
|
||||||
pixman_region32_t *damage = &subsurface->parent->external_damage;
|
|
||||||
pixman_region32_union_rect(damage, damage,
|
|
||||||
subsurface->current.x + sx,
|
|
||||||
subsurface->current.y + sy,
|
|
||||||
surface->current.width, surface->current.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: untangle from wlr_surface
|
|
||||||
static void subsurface_parent_commit(struct wlr_subsurface *subsurface) {
|
|
||||||
struct wlr_surface *surface = subsurface->surface;
|
|
||||||
|
|
||||||
bool moved = subsurface->current.x != subsurface->pending.x ||
|
|
||||||
subsurface->current.y != subsurface->pending.y;
|
|
||||||
if (subsurface->mapped && moved) {
|
|
||||||
wlr_surface_for_each_surface(surface,
|
|
||||||
collect_subsurface_damage_iter, subsurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subsurface->synchronized && subsurface->has_cache) {
|
|
||||||
wlr_surface_unlock_cached(surface, subsurface->cached_seq);
|
|
||||||
subsurface->has_cache = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
subsurface->current.x = subsurface->pending.x;
|
|
||||||
subsurface->current.y = subsurface->pending.y;
|
|
||||||
if (subsurface->mapped && (moved || subsurface->reordered)) {
|
|
||||||
subsurface->reordered = false;
|
|
||||||
wlr_surface_for_each_surface(surface,
|
|
||||||
collect_subsurface_damage_iter, subsurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!subsurface->added) {
|
|
||||||
subsurface->added = true;
|
|
||||||
wl_signal_emit_mutable(&subsurface->parent->events.new_subsurface,
|
|
||||||
subsurface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void surface_handle_commit(struct wl_client *client,
|
static void surface_handle_commit(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
#include <wlr/types/wlr_subcompositor.h>
|
#include <wlr/types/wlr_subcompositor.h>
|
||||||
#include "types/wlr_region.h"
|
#include "types/wlr_region.h"
|
||||||
|
#include "types/wlr_subcompositor.h"
|
||||||
|
|
||||||
#define SUBCOMPOSITOR_VERSION 1
|
#define SUBCOMPOSITOR_VERSION 1
|
||||||
|
|
||||||
|
@ -329,6 +330,46 @@ static void subsurface_handle_surface_client_commit(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void collect_damage_iter(struct wlr_surface *surface,
|
||||||
|
int sx, int sy, void *data) {
|
||||||
|
struct wlr_subsurface *subsurface = data;
|
||||||
|
pixman_region32_t *damage = &subsurface->parent->external_damage;
|
||||||
|
pixman_region32_union_rect(damage, damage,
|
||||||
|
subsurface->current.x + sx,
|
||||||
|
subsurface->current.y + sy,
|
||||||
|
surface->current.width, surface->current.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void subsurface_handle_parent_commit(struct wlr_subsurface *subsurface) {
|
||||||
|
struct wlr_surface *surface = subsurface->surface;
|
||||||
|
|
||||||
|
bool moved = subsurface->current.x != subsurface->pending.x ||
|
||||||
|
subsurface->current.y != subsurface->pending.y;
|
||||||
|
if (subsurface->mapped && moved) {
|
||||||
|
wlr_surface_for_each_surface(surface,
|
||||||
|
collect_damage_iter, subsurface);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subsurface->synchronized && subsurface->has_cache) {
|
||||||
|
wlr_surface_unlock_cached(surface, subsurface->cached_seq);
|
||||||
|
subsurface->has_cache = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
subsurface->current.x = subsurface->pending.x;
|
||||||
|
subsurface->current.y = subsurface->pending.y;
|
||||||
|
if (subsurface->mapped && (moved || subsurface->reordered)) {
|
||||||
|
subsurface->reordered = false;
|
||||||
|
wlr_surface_for_each_surface(surface,
|
||||||
|
collect_damage_iter, subsurface);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!subsurface->added) {
|
||||||
|
subsurface->added = true;
|
||||||
|
wl_signal_emit_mutable(&subsurface->parent->events.new_subsurface,
|
||||||
|
subsurface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
|
static struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
|
||||||
struct wlr_surface *parent, uint32_t version, uint32_t id) {
|
struct wlr_surface *parent, uint32_t version, uint32_t id) {
|
||||||
struct wl_client *client = wl_resource_get_client(surface->resource);
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
||||||
|
|
Loading…
Reference in a new issue