Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions attempt #2 #1704

Merged
merged 39 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
de39b42
xdg-shell: add transactions support via the toplevel interface
ammen99 Mar 7, 2023
0023ad0
view: expose the optional toplevel subobject
ammen99 Mar 12, 2023
9ffd7af
xwayland: add basic transactions support
ammen99 Jun 1, 2023
d05e234
core: move layer-shell to a subdirectory
ammen99 Jun 2, 2023
9afabb4
layer-shell: emit view map when mapping
ammen99 Jun 4, 2023
40f4f7d
view: do not draw unmapped views from offscreen buffer
ammen99 Jun 4, 2023
c93d43e
translation-node: add render instance class to the header file
ammen99 Jun 4, 2023
d5110e3
scene: add an optional subclass for reporting a node's opaque region
ammen99 Jun 4, 2023
f6d4496
core: make sure view_node_t is not used anywhere
ammen99 Jun 4, 2023
18b14cd
view: refactor view_node_tag_t
ammen99 Jun 4, 2023
9f78d2d
split view-node into multiple specialized implementations
ammen99 Jun 8, 2023
e65ebff
view: remove wlr_view_t class entirely
ammen99 Jun 8, 2023
fa60066
view: remove view_node_t
ammen99 Jun 8, 2023
eb46c7d
api: split view into view and toplevel-view
ammen99 Jun 10, 2023
bef837a
toplevel-view: nuke get_output_geometry()
ammen99 Jun 11, 2023
89400f2
share code for emitting {title,app-id}-changed signals
ammen99 Jun 11, 2023
0fe07c0
xwayland: simplify unmanaged views
ammen99 Jun 13, 2023
fa8bd18
toplevel-view: remove set_moving/resizing
ammen99 Jun 15, 2023
aa164b3
view: move windowed geometry management to a separate class
ammen99 Jun 15, 2023
818bb7c
api: move *_request from toplevel view to window-manager
ammen99 Jun 16, 2023
761d961
toplevel: move tiled edges to a toplevel state
ammen99 Jun 16, 2023
18f22cb
toplevel: clarify that move, resize and set_geometry are transaction …
ammen99 Jun 17, 2023
630eefa
toplevel: make fullscreen part of transactions
ammen99 Jun 17, 2023
b7a2134
fix xwayland conditional compilation
ammen99 Jun 17, 2023
ec85780
toplevel: replace get_wm_geometry() with get_geometry() and get_pendi…
ammen99 Jun 17, 2023
220b58d
toplevel: clean up set_minimized()
ammen99 Jun 17, 2023
0ae8946
core: small fixes related to the tracking of activated state
ammen99 Jun 17, 2023
9f051e9
animate: fix damage when unmapping the view
ammen99 Jun 17, 2023
f071b8a
debug: add XWL debugging category
ammen99 Jun 17, 2023
48dca36
xwayland: improve logging and handling of mapped toplevels geometry
ammen99 Jun 17, 2023
bbfa3e3
toplevel-node: use pending geometry when refocusing
ammen99 Jun 17, 2023
2fd6a68
seat: ignore drag grab reset
ammen99 Jun 17, 2023
3c07417
simple-tile: use transactions to resize views together
ammen99 Jun 17, 2023
5f3f013
simple-tile: fix working with workspace sets which don't have output yet
ammen99 Jun 19, 2023
384941d
xwayland-toplevel: fix geometry handling when unmapping
ammen99 Jun 19, 2023
68599f2
stipc: calculate base-geometry as it should be calculated
ammen99 Jun 19, 2023
93c56e7
xdg-toplevel: emit title-changed signal when needed
ammen99 Jun 24, 2023
9347729
toplevel-view: update decoration interface
ammen99 Jun 24, 2023
0af8942
simple-tile: fix output unplug crash
ammen99 Jun 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 66 additions & 20 deletions plugins/animate/animate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
#include <type_traits>
#include <map>
#include <wayfire/core.hpp>
#include "animate.hpp"
#include "system_fade.hpp"
#include "basic_animations.hpp"
#include "fire/fire.hpp"
#include "unmapped-view-node.hpp"
#include "wayfire/plugin.hpp"
#include "wayfire/scene-operations.hpp"
#include "wayfire/scene.hpp"
#include "wayfire/signal-provider.hpp"
#include <wayfire/matcher.hpp>
Expand Down Expand Up @@ -69,13 +72,23 @@ struct animation_hook : public animation_hook_base
std::string name;
wf::output_t *current_output = nullptr;
std::unique_ptr<animation_base> animation;
std::shared_ptr<wf::unmapped_view_snapshot_node> unmapped_contents;

void damage_whole_view()
{
view->damage();
if (unmapped_contents)
{
wf::scene::damage_node(unmapped_contents, unmapped_contents->get_bounding_box());
}
}

/* Update animation right before each frame */
wf::effect_hook_t update_animation_hook = [=] ()
{
view->damage();
damage_whole_view();
bool result = animation->step();
view->damage();
damage_whole_view();

if (!result)
{
Expand Down Expand Up @@ -122,21 +135,62 @@ struct animation_hook : public animation_hook_base
/* Animation is driven by the output render cycle the view is on.
* Thus, we need to keep in sync with the current output. */
view->connect(&on_set_output);

// Take a ref on the view, so that it remains available for as long as the animation runs.
wf::scene::set_node_enabled(view->get_root_node(), true);
view->take_ref();

if (type == ANIMATION_TYPE_UNMAP)
{
set_unmapped_contents();
}
}

void stop_hook(bool detached) override
{
/* We don't want to change the state of the view if it was detached */
if ((type == ANIMATION_TYPE_MINIMIZE) && !detached)
view->erase_data(name);
}

// When showing the final unmap animation, we show a ``fake'' node instead of the actual view contents,
// because the underlying (sub)surfaces might be destroyed.
//
// The unmapped contents have to be visible iff the view is in an unmap animation.
void set_unmapped_contents()
{
if (!unmapped_contents)
{
view->set_minimized(true);
unmapped_contents = std::make_shared<wf::unmapped_view_snapshot_node>(view);
auto parent = dynamic_cast<wf::scene::floating_inner_node_t*>(
view->get_surface_root_node()->parent());

if (parent)
{
wf::scene::add_front(
std::dynamic_pointer_cast<wf::scene::floating_inner_node_t>(parent->shared_from_this()),
unmapped_contents);
}
}
}

view->erase_data(name);
void unset_unmapped_contents()
{
if (unmapped_contents)
{
wf::scene::remove_child(unmapped_contents);
unmapped_contents.reset();
}
}

void reverse(wf_animation_type type) override
{
if (type == ANIMATION_TYPE_UNMAP)
{
set_unmapped_contents();
} else
{
unset_unmapped_contents();
}

this->type = type;
if (animation)
{
Expand All @@ -160,12 +214,9 @@ struct animation_hook : public animation_hook_base
on_set_output.disconnect();
this->animation.reset();

// remove from list
if (type == ANIMATION_TYPE_UNMAP)
{
wf::scene::set_node_enabled(view->get_root_node(), false);
view->unref();
}
unset_unmapped_contents();
wf::scene::set_node_enabled(view->get_root_node(), false);
view->unref();
}

animation_hook(const animation_hook &) = delete;
Expand Down Expand Up @@ -309,13 +360,6 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
{
name = "animation-hook-" + name;

if (type == ANIMATION_TYPE_UNMAP)
{
wf::scene::set_node_enabled(view->get_root_node(), true);
view->take_ref();
view->take_snapshot();
}

if (type == ANIMATION_TYPE_MAP)
{
if (try_reverse(view, type, name, SHOWN))
Expand Down Expand Up @@ -399,12 +443,14 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
{
if (ev->state)
{
ev->carried_out = true;
set_animation<zoom_animation>(ev->view, ANIMATION_TYPE_MINIMIZE, default_duration, "minimize");
} else
{
set_animation<zoom_animation>(ev->view, ANIMATION_TYPE_RESTORE, default_duration, "minimize");
}

// ev->carried_out should remain false, so that core also does the automatic minimize/restore and
// refocus
};

wf::signal::connection_t<wf::output_start_rendering_signal> on_render_start =
Expand Down
7 changes: 5 additions & 2 deletions plugins/animate/basic_animations.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "animate.hpp"
#include "wayfire/toplevel-view.hpp"
#include <memory>
#include <wayfire/plugin.hpp>
#include <wayfire/opengl.hpp>
Expand Down Expand Up @@ -96,13 +97,15 @@ class zoom_animation : public animation_base

if (type & MINIMIZE_STATE_ANIMATION)
{
auto hint = view->get_minimize_hint();
auto toplevel = wf::toplevel_cast(view);
wf::dassert(toplevel != nullptr, "We cannot minimize non-toplevel views!");
auto hint = toplevel->get_minimize_hint();
if ((hint.width > 0) && (hint.height > 0))
{
int hint_cx = hint.x + hint.width / 2;
int hint_cy = hint.y + hint.height / 2;

auto bbox = view->get_wm_geometry();
auto bbox = toplevel->get_geometry();
int view_cx = bbox.x + bbox.width / 2;
int view_cy = bbox.y + bbox.height / 2;

Expand Down
60 changes: 60 additions & 0 deletions plugins/animate/unmapped-view-node.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#pragma once

#include "wayfire/geometry.hpp"
#include "wayfire/opengl.hpp"
#include "wayfire/region.hpp"
#include "wayfire/scene-render.hpp"
#include "wayfire/scene.hpp"
#include <wayfire/view.hpp>

namespace wf
{
class unmapped_view_snapshot_node : public wf::scene::node_t
{
wf::render_target_t snapshot;
wf::geometry_t bbox;

public:
unmapped_view_snapshot_node(wayfire_view view) : node_t(false)
{
view->take_snapshot(snapshot);
bbox = view->get_surface_root_node()->get_bounding_box();
}

~unmapped_view_snapshot_node()
{
OpenGL::render_begin();
snapshot.release();
OpenGL::render_end();
}

wf::geometry_t get_bounding_box() override
{
return bbox;
}

void gen_render_instances(std::vector<scene::render_instance_uptr>& instances,
scene::damage_callback push_damage, wf::output_t *shown_on) override
{
instances.push_back(std::make_unique<rinstance_t>(this, push_damage, shown_on));
}

private:
class rinstance_t : public wf::scene::simple_render_instance_t<unmapped_view_snapshot_node>
{
public:
using simple_render_instance_t::simple_render_instance_t;
void render(const wf::render_target_t& target, const wf::region_t& region)
{
OpenGL::render_begin(target);
for (auto& box : region)
{
target.logic_scissor(wlr_box_from_pixman_box(box));
OpenGL::render_texture(self->snapshot.tex, target, self->get_bounding_box());
}

OpenGL::render_end();
}
};
};
}
8 changes: 4 additions & 4 deletions plugins/blur/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class blur_render_instance_t : public transformer_render_instance_t<blur_node_t>
{
if (self->get_children().size() == 1)
{
if (auto vnode = dynamic_cast<view_node_t*>(self->get_children().front().get()))
if (auto opaque = dynamic_cast<opaque_region_node_t*>(self->get_children().front().get()))
{
return (damage ^ vnode->get_opaque_region()).empty();
return (damage ^ opaque->get_opaque_region()).empty();
}
}

Expand All @@ -93,11 +93,11 @@ class blur_render_instance_t : public transformer_render_instance_t<blur_node_t>
{
if (self->get_children().size() == 1)
{
if (auto vnode = dynamic_cast<view_node_t*>(self->get_children().front().get()))
if (auto opaque = dynamic_cast<opaque_region_node_t*>(self->get_children().front().get()))
{
const int padding =
calculate_damage_padding(target, self->provider()->calculate_blur_radius());
auto opaque_region = vnode->get_opaque_region();
auto opaque_region = opaque->get_opaque_region();
opaque_region.expand_edges(-padding);

wf::region_t translucent_region = damage ^ opaque_region;
Expand Down
Loading