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

fix more crashes #2312

Merged
merged 14 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions plugins/animate/fire/fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,14 @@ class fire_node_t : public wf::scene::floating_inner_node_t

class fire_render_instance_t : public wf::scene::render_instance_t
{
fire_node_t *self;
std::shared_ptr<fire_node_t> self;

public:
fire_render_instance_t(fire_node_t *self,
wf::scene::damage_callback push_damage,
wf::output_t *output)
{
this->self = self;

this->self = std::dynamic_pointer_cast<fire_node_t>(self->shared_from_this());
auto child_damage = [=] (const wf::region_t& damage)
{
push_damage(damage | self->get_bounding_box());
Expand Down
13 changes: 8 additions & 5 deletions plugins/common/wayfire/plugins/common/move-drag-interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ inline std::vector<wayfire_toplevel_view> get_target_views(wayfire_toplevel_view
// coordinates and thus we just need to schedule them for rendering.
class dragged_view_node_t : public wf::scene::node_t
{
std::vector<dragged_view_t> views;

public:
std::vector<dragged_view_t> views;
dragged_view_node_t(std::vector<dragged_view_t> views) : node_t(false)
{
this->views = views;
Expand All @@ -322,7 +321,8 @@ class dragged_view_node_t : public wf::scene::node_t
void gen_render_instances(std::vector<scene::render_instance_uptr>& instances,
scene::damage_callback push_damage, wf::output_t *output = nullptr) override
{
instances.push_back(std::make_unique<dragged_view_render_instance_t>(this, push_damage, output));
instances.push_back(std::make_unique<dragged_view_render_instance_t>(
std::dynamic_pointer_cast<dragged_view_node_t>(shared_from_this()), push_damage, output));
}

wf::geometry_t get_bounding_box() override
Expand Down Expand Up @@ -351,8 +351,8 @@ class dragged_view_node_t : public wf::scene::node_t
};

public:
dragged_view_render_instance_t(dragged_view_node_t *self, wf::scene::damage_callback push_damage,
wf::output_t *shown_on)
dragged_view_render_instance_t(std::shared_ptr<dragged_view_node_t> self,
wf::scene::damage_callback push_damage, wf::output_t *shown_on)
{
auto push_damage_child = [=] (wf::region_t child_damage)
{
Expand Down Expand Up @@ -477,6 +477,8 @@ class core_drag_t : public signal::provider_t
wf::dassert(tentative_grab_position.has_value(),
"First, the drag operation should be set as pending!");
wf::dassert(grab_view->is_mapped(), "Dragged view should be mapped!");
wf::dassert(!this->view, "Drag operation already in progress!");

auto bbox = wf::view_bounding_box_up_to(grab_view, "wobbly");
wf::point_t rel_grab_pos = {
int(bbox.x + relative.x * bbox.width),
Expand Down Expand Up @@ -625,6 +627,7 @@ class core_drag_t : public signal::provider_t

// Remove overlay hooks and damage outputs BEFORE popping the transformer
wf::scene::remove_child(render_node);
render_node->views.clear();
render_node = nullptr;

for (auto& v : all_views)
Expand Down
4 changes: 2 additions & 2 deletions plugins/common/wayfire/plugins/common/workspace-wall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class workspace_wall_t : public wf::signal::provider_t
{
class wwall_render_instance_t : public scene::render_instance_t
{
workspace_wall_node_t *self;
std::shared_ptr<workspace_wall_node_t> self;
per_workspace_map_t<std::vector<scene::render_instance_uptr>> instances;

scene::damage_callback push_damage;
Expand All @@ -257,7 +257,7 @@ class workspace_wall_t : public wf::signal::provider_t
wwall_render_instance_t(workspace_wall_node_t *self,
scene::damage_callback push_damage)
{
this->self = self;
this->self = std::dynamic_pointer_cast<workspace_wall_node_t>(self->shared_from_this());
this->push_damage = push_damage;
self->connect(&on_wall_damage);

Expand Down
4 changes: 2 additions & 2 deletions plugins/cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class wayfire_cube : public wf::per_output_plugin_instance_t, public wf::pointer
{
class cube_render_instance_t : public wf::scene::render_instance_t
{
cube_render_node_t *self;
std::shared_ptr<cube_render_node_t> self;
wf::scene::damage_callback push_damage;

std::vector<std::vector<wf::scene::render_instance_uptr>> ws_instances;
Expand All @@ -59,7 +59,7 @@ class wayfire_cube : public wf::per_output_plugin_instance_t, public wf::pointer
public:
cube_render_instance_t(cube_render_node_t *self, wf::scene::damage_callback push_damage)
{
this->self = self;
this->self = std::dynamic_pointer_cast<cube_render_node_t>(self->shared_from_this());
this->push_damage = push_damage;
self->connect(&on_cube_damage);

Expand Down
4 changes: 2 additions & 2 deletions plugins/decor/deco-subsurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in

class decoration_render_instance_t : public wf::scene::render_instance_t
{
simple_decoration_node_t *self;
std::shared_ptr<simple_decoration_node_t> self;
wf::scene::damage_callback push_damage;

wf::signal::connection_t<wf::scene::node_damage_signal> on_surface_damage =
Expand All @@ -177,7 +177,7 @@ class simple_decoration_node_t : public wf::scene::node_t, public wf::pointer_in
public:
decoration_render_instance_t(simple_decoration_node_t *self, wf::scene::damage_callback push_damage)
{
this->self = self;
this->self = std::dynamic_pointer_cast<simple_decoration_node_t>(self->shared_from_this());
this->push_damage = push_damage;
self->connect(&on_surface_damage);
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/grid/wayfire/plugins/crossfade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ class crossfade_node_t : public scene::view_2d_transformer_t

class crossfade_render_instance_t : public scene::render_instance_t
{
crossfade_node_t *self;
std::shared_ptr<crossfade_node_t> self;
wf::signal::connection_t<scene::node_damage_signal> on_damage;

public:
crossfade_render_instance_t(crossfade_node_t *self,
scene::damage_callback push_damage)
{
this->self = self;
this->self = std::dynamic_pointer_cast<crossfade_node_t>(self->shared_from_this());
scene::damage_callback push_damage_child = [=] (const wf::region_t&)
{
// XXX: we could attempt to calculate a meaningful damage, but
Expand Down
15 changes: 13 additions & 2 deletions plugins/ipc/stipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,27 @@ class stipc_plugin_t : public wf::plugin_interface_t
}
};

int delay_counter = 0;
wf::signal::connection_t<wf::txn::new_transaction_signal> on_new_tx =
[=] (wf::txn::new_transaction_signal *ev)
{
ev->tx->add_object(std::make_shared<never_ready_object>());
on_new_tx.disconnect();

delay_counter--;
if (delay_counter <= 0)
{
on_new_tx.disconnect();
}
};

ipc::method_callback delay_next_tx = [=] (nlohmann::json)
{
wf::get_core().tx_manager->connect(&on_new_tx);
if (!on_new_tx.is_connected())
{
wf::get_core().tx_manager->connect(&on_new_tx);
}

++delay_counter;
return wf::ipc::json_ok();
};

Expand Down
4 changes: 2 additions & 2 deletions plugins/scale/scale-title-overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ class title_overlay_render_instance_t : public render_instance_t
push_to_parent(ev->region);
};

title_overlay_node_t *self;
std::shared_ptr<title_overlay_node_t> self;
damage_callback push_to_parent;

public:
title_overlay_render_instance_t(title_overlay_node_t *self,
damage_callback push_dmg)
{
this->self = self;
this->self = std::dynamic_pointer_cast<title_overlay_node_t>(self->shared_from_this());
this->push_to_parent = push_dmg;
self->connect(&on_node_damaged);
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/single_plugins/switcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <glm/gtc/matrix_transform.hpp>

#include <algorithm>
#include <exception>
#include <set>

constexpr const char *switcher_transformer = "switcher-3d";
Expand Down Expand Up @@ -122,7 +121,7 @@ class WayfireSwitcher : public wf::per_output_plugin_instance_t, public wf::keyb
{
class switcher_render_instance_t : public wf::scene::render_instance_t
{
switcher_render_node_t *self;
std::shared_ptr<switcher_render_node_t> self;
wf::scene::damage_callback push_damage;
wf::signal::connection_t<wf::scene::node_damage_signal> on_switcher_damage =
[=] (wf::scene::node_damage_signal *ev)
Expand All @@ -133,7 +132,7 @@ class WayfireSwitcher : public wf::per_output_plugin_instance_t, public wf::keyb
public:
switcher_render_instance_t(switcher_render_node_t *self, wf::scene::damage_callback push_damage)
{
this->self = self;
this->self = std::dynamic_pointer_cast<switcher_render_node_t>(self->shared_from_this());
this->push_damage = push_damage;
self->connect(&on_switcher_damage);
}
Expand Down Expand Up @@ -901,6 +900,7 @@ class WayfireSwitcher : public wf::per_output_plugin_instance_t, public wf::keyb
{
if (output->is_plugin_active(grab_interface.name))
{
input_grab->ungrab_input();
deinit_switcher();
}

Expand Down
28 changes: 13 additions & 15 deletions plugins/tile/tile-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,7 @@ class tile_output_plugin_t : public wf::pointer_interaction_t, public wf::custom
// Deactivate plugin, so that others can react to the events
output->deactivate_plugin(&grab_interface);
input_grab->ungrab_input();

if (!force_stop)
{
controller->input_released();
}

controller->input_released(force_stop);
controller = get_default_controller();
}

Expand All @@ -151,10 +146,15 @@ class tile_output_plugin_t : public wf::pointer_interaction_t, public wf::custom
tile_workspace_set_data_t::get(view->get_wset()).attach_view(view, vp);
}

void detach_view(nonstd::observer_ptr<tile::view_node_t> view, bool reinsert = true)
void detach_view(wayfire_toplevel_view view, bool reinsert = true)
{
stop_controller(true);
tile_workspace_set_data_t::get(view->view->get_wset()).detach_views({view}, reinsert);

// Note that stopping the controller might untile the view, or change its tiled node.
if (auto node = tile::view_node_t::get_node(view))
{
tile_workspace_set_data_t::get(view->get_wset()).detach_views({node}, reinsert);
}
}

wf::signal::connection_t<view_mapped_signal> on_view_mapped = [=] (view_mapped_signal *ev)
Expand All @@ -170,11 +170,9 @@ class tile_output_plugin_t : public wf::pointer_interaction_t, public wf::custom

wf::signal::connection_t<view_unmapped_signal> on_view_unmapped = [=] (wf::view_unmapped_signal *ev)
{
auto node = wf::tile::view_node_t::get_node(ev->view);
if (node)
if (wf::tile::view_node_t::get_node(ev->view))
{
stop_controller(true);
detach_view(node);
detach_view(toplevel_cast(ev->view));
}
};

Expand Down Expand Up @@ -206,7 +204,7 @@ class tile_output_plugin_t : public wf::pointer_interaction_t, public wf::custom
auto existing_node = wf::tile::view_node_t::get_node(view);
if (existing_node)
{
detach_view(existing_node);
detach_view(view);
attach_view(view, vp);
}
}
Expand All @@ -226,7 +224,7 @@ class tile_output_plugin_t : public wf::pointer_interaction_t, public wf::custom

if (ev->view->minimized && existing_node)
{
detach_view(existing_node);
detach_view(ev->view);
}

if (!ev->view->minimized && tile_window_by_default(ev->view))
Expand Down Expand Up @@ -272,7 +270,7 @@ class tile_output_plugin_t : public wf::pointer_interaction_t, public wf::custom
auto existing_node = tile::view_node_t::get_node(view);
if (existing_node)
{
detach_view(existing_node);
detach_view(view);
wf::get_core().default_wm->tile_request(view, 0);
} else
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/tile/tree-controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void move_view_controller_t::input_motion()
drag_helper->handle_motion(wf::get_core().get_cursor_position().round_down());
}

void move_view_controller_t::input_released()
void move_view_controller_t::input_released(bool force_stop)
{
drag_helper->handle_input_released();
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/tile/tree-controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class tile_controller_t
* Note that a controller may be deleted without receiving input_released(),
* in which case it should simply stop operation.
*/
virtual void input_released()
virtual void input_released(bool force_stop)
{}
};

Expand All @@ -82,7 +82,7 @@ class move_view_controller_t : public tile_controller_t
~move_view_controller_t();

void input_motion() override;
void input_released() override;
void input_released(bool force_stop) override;

protected:
wf::shared_data::ref_ptr_t<wf::move_drag::core_drag_t> drag_helper;
Expand Down
11 changes: 8 additions & 3 deletions plugins/vswitch/vswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class wf_vswitch_global_plugin_t : public wf::per_output_plugin_t<vswitch>
return wf::ipc::json_error("Workspace coordinates are too big!");
}

std::vector<wayfire_toplevel_view> switch_with_views;
wayfire_toplevel_view switch_with_view;
if (data.contains("view-id"))
{
auto view = toplevel_cast(wf::ipc::find_view_by_id(data["view-id"]));
Expand All @@ -281,15 +281,20 @@ class wf_vswitch_global_plugin_t : public wf::per_output_plugin_t<vswitch>
return wf::ipc::json_error("Cannot grab unmapped view!");
}

switch_with_views.push_back(view);
if (view->get_output() != wo)
{
return wf::ipc::json_error("Cannot grab view on a different output!");
}

switch_with_view = view;
}

if (output_instance[wo]->set_capabilities(wf::CAPABILITY_MANAGE_COMPOSITOR))
{
wf::point_t new_viewport = {data["x"], data["y"]};
wf::point_t cur_viewport = wo->wset()->get_current_workspace();
wf::point_t delta = new_viewport - cur_viewport;
output_instance[wo]->add_direction(delta);
output_instance[wo]->add_direction(delta, switch_with_view);
}

return wf::ipc::json_ok();
Expand Down
2 changes: 2 additions & 0 deletions plugins/wobbly/wobbly.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ void wobbly_add_geometry(struct wobbly_surface *surface)
void wobbly_resize(struct wobbly_surface *surface, int width, int height)
{
WobblyWindow *ww = surface->ww;
width = width > 1 ? width : 1;
height = height > 1 ? height : 1;

surface->synced = 0;
ww->wobbly |= WobblyInitial;
Expand Down
2 changes: 1 addition & 1 deletion plugins/wobbly/wobbly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ class wayfire_wobbly : public wf::plugin_interface_t
{
for (auto& view : wf::get_core().get_all_views())
{
auto wobbly = view->get_transformed_node()->get_transformer<wobbly_transformer_node_t>();
auto wobbly = view->get_transformed_node()->get_transformer<wobbly_transformer_node_t>("wobbly");
if (wobbly)
{
wobbly->destroy_self();
Expand Down
2 changes: 1 addition & 1 deletion src/api/wayfire/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class plugin_interface_t
using wayfire_plugin_load_func = wf::plugin_interface_t * (*)();

/** The version of Wayfire's API/ABI */
constexpr uint32_t WAYFIRE_API_ABI_VERSION = 2024'04'02;
constexpr uint32_t WAYFIRE_API_ABI_VERSION = 2024'04'04;

/**
* Each plugin must also provide a function which returns the Wayfire API/ABI
Expand Down
Loading
Loading