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

core: do not resize view in move_view_to_output #2211

Merged
merged 4 commits into from
Mar 13, 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
12 changes: 12 additions & 0 deletions plugins/protocols/wayfire-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ class wfs_output
void create_hotspot(uint32_t hotspot, uint32_t threshold, uint32_t timeout,
uint32_t id)
{
if (!this->output)
{
// It can happen that the client requests a hotspot immediately after an output is destroyed -
// this is an inherent race condition because the compositor and client are not in sync.
//
// In this case, we create a dummy hotspot resource to avoid Wayland protocol errors.
auto resource = wl_resource_create(
wl_resource_get_client(this->resource), &zwf_hotspot_v2_interface, 1, id);
wl_resource_set_implementation(resource, NULL, NULL, NULL);
return;
}

// will be auto-deleted when the resource is destroyed by the client
new wfs_hotspot(this->output, hotspot, threshold, timeout,
wl_resource_get_client(this->resource), id);
Expand Down
1 change: 0 additions & 1 deletion src/api/wayfire/unstable/wlr-text-input-v3-popup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class text_input_v3_popup : public wf::view_interface_t
wf::geometry_t geometry{0, 0, 0, 0};
std::shared_ptr<wf::scene::wlr_surface_node_t> main_surface;
std::shared_ptr<wf::scene::translation_node_t> surface_root_node;
bool _is_mapped = false;

virtual wlr_surface *get_keyboard_focus_surface() override
{
Expand Down
19 changes: 11 additions & 8 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,19 @@ void wf::compositor_core_impl_t::post_init()

void wf::compositor_core_impl_t::shutdown()
{
this->state = compositor_state_t::SHUTDOWN;
core_shutdown_signal ev;
this->emit(&ev);
wl_display_terminate(wf::get_core().display);
// We might get multiple signals in some scenarios. Shutdown only on the first instance.
if (this->state != compositor_state_t::SHUTDOWN)
{
wl_display_terminate(wf::get_core().display);
}
}

void wf::compositor_core_impl_t::fini()
{
this->state = compositor_state_t::SHUTDOWN;
core_shutdown_signal ev;
this->emit(&ev);

LOGI("Unloading plugins...");
plugin_mgr.reset();
LOGI("Stopping clients...");
Expand Down Expand Up @@ -494,10 +499,8 @@ void wf::move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output,
new_output_g = new_output->get_relative_geometry();
auto ratio_x = (double)new_output_g.width / old_output_g.width;
auto ratio_y = (double)new_output_g.height / old_output_g.height;
view_g.x *= ratio_x;
view_g.y *= ratio_y;
view_g.width *= ratio_x;
view_g.height *= ratio_y;
view_g.x *= ratio_x;
view_g.y *= ratio_y;
}

assert(new_output);
Expand Down
1 change: 1 addition & 0 deletions src/core/output-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ class output_layout_t::impl
{
// Destroy outputs first
this->outputs.clear();
noop_output.reset();

// Disconnect all signals
on_new_output.disconnect();
Expand Down
4 changes: 1 addition & 3 deletions src/core/seat/input-method-popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ void wf::text_input_v3_popup::map()

priv->set_mapped_surface_contents(main_surface);
priv->set_mapped(true);
_is_mapped = true;
on_commit.connect(&surface->events.commit);

update_geometry();
Expand All @@ -80,7 +79,6 @@ void wf::text_input_v3_popup::unmap()

emit_view_unmap();
priv->set_mapped(false);
_is_mapped = false;
on_commit.disconnect();
}

Expand Down Expand Up @@ -163,7 +161,7 @@ void wf::text_input_v3_popup::update_geometry()

bool wf::text_input_v3_popup::is_mapped() const
{
return priv->wsurface != nullptr && _is_mapped;
return priv->is_mapped;
}

wf::geometry_t wf::text_input_v3_popup::get_geometry()
Expand Down
2 changes: 1 addition & 1 deletion src/core/seat/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ wf::tablet_pad_t::tablet_pad_t(wlr_input_device *pad) :
void wf::tablet_pad_t::update_focus()
{
auto focus_view = wf::get_core().seat->get_active_view();
auto focus_surface = focus_view ? focus_view->priv->wsurface : nullptr;
auto focus_surface = focus_view ? focus_view->get_wlr_surface() : nullptr;
update_focus(focus_surface);
}

Expand Down
2 changes: 1 addition & 1 deletion src/view/layer-shell/layer-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class wayfire_layer_shell_view : public wf::view_interface_t
/* Just pass to the default wlr surface implementation */
bool is_mapped() const override
{
return priv->wsurface != nullptr;
return priv->is_mapped;
}

std::string get_app_id() override final
Expand Down
7 changes: 5 additions & 2 deletions src/view/view-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ void wf::view_interface_t::view_priv_impl::set_mapped_surface_contents(
return;
}

wsurface = content->get_surface();
wsurface = content->get_surface();
is_mapped = true;

// Locate the proper place to add the surface contents.
// This is not trivial because we may have added content node before (if we currently are remapping).
Expand All @@ -233,7 +234,9 @@ void wf::view_interface_t::view_priv_impl::set_mapped_surface_contents(

void wf::view_interface_t::view_priv_impl::unset_mapped_surface_contents()
{
wsurface = nullptr;
wsurface = nullptr;
is_mapped = false;

replace_node_or_add_front(surface_root_node, current_content, dummy_node);

if (auto wcont = dynamic_cast<scene::wlr_surface_node_t*>(current_content.get()))
Expand Down
1 change: 1 addition & 0 deletions src/view/view-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace wf
class view_interface_t::view_priv_impl
{
public:
bool is_mapped = false;
wlr_surface *wsurface = nullptr;
size_t last_view_cnt = 0;
uint32_t allowed_actions = VIEW_ALLOW_ALL;
Expand Down
2 changes: 1 addition & 1 deletion src/view/xdg-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void wayfire_xdg_popup::update_size()

bool wayfire_xdg_popup::is_mapped() const
{
return priv->wsurface != nullptr;
return priv->is_mapped;
}

void wayfire_xdg_popup::handle_app_id_changed(std::string new_app_id)
Expand Down
4 changes: 2 additions & 2 deletions src/view/xdg-shell/xdg-toplevel-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ std::string wf::xdg_toplevel_view_base_t::get_title()

bool wf::xdg_toplevel_view_base_t::is_mapped() const
{
return priv->wsurface;
return priv->is_mapped;
}

// ------------------------------------------ xdg-toplevel impl ----------------------------------------------
Expand Down Expand Up @@ -284,7 +284,7 @@ bool wf::xdg_toplevel_view_t::should_be_decorated()

bool wf::xdg_toplevel_view_t::is_mapped() const
{
return wtoplevel->current().mapped && priv->wsurface;
return wtoplevel->current().mapped && priv->is_mapped;
}

void wf::xdg_toplevel_view_t::map()
Expand Down
1 change: 1 addition & 0 deletions src/view/xwayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class xwayland_view_controller_t
});
on_dissociate.set_callback([&] (void*)
{
view->priv->wsurface = nullptr;
on_map.disconnect();
on_unmap.disconnect();
});
Expand Down
2 changes: 1 addition & 1 deletion src/view/xwayland/xwayland-view-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void wf::xwayland_view_base_t::close()

bool wf::xwayland_view_base_t::is_mapped() const
{
return priv->wsurface != nullptr;
return priv->is_mapped;
}

wlr_surface*wf::xwayland_view_base_t::get_keyboard_focus_surface()
Expand Down
Loading