Skip to content

Commit

Permalink
Don't send too many zxdg_surface_v6 "configure" events.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGriffiths committed Mar 23, 2018
1 parent 5aac9a2 commit 7373b7b
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/server/frontend_wayland/xdg_shell_v6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class XdgSurfaceV6 : wayland::XdgSurfaceV6, WlAbstractMirWindow
void resize(struct wl_resource* /*seat*/, uint32_t /*serial*/, uint32_t edges);
void set_notify_resize(std::function<void(geometry::Size const& new_size, MirWindowState state, bool active)> notify_resize);
void on_next_commit(std::function<void()> deferred);
void clear_on_next_commit();
void set_max_size(int32_t width, int32_t height);
void set_min_size(int32_t width, int32_t height);
void set_maximized();
Expand Down Expand Up @@ -94,8 +95,6 @@ class XdgSurfaceV6EventSink : public BasicSurfaceEventSink
[](auto, auto, auto){};

private:
void post_configure(int serial) const;

std::shared_ptr<bool> const destroyed;
};

Expand Down Expand Up @@ -436,18 +435,26 @@ void mf::XdgSurfaceV6::unset_maximized()
}
}

void mir::frontend::XdgSurfaceV6::clear_on_next_commit()
{
commit_action = []{};
}

void mir::frontend::XdgSurfaceV6::on_next_commit(std::function<void()> deferred)
{
commit_action = deferred;
commit_action = [this, deferred]
{
deferred();
auto const serial = wl_display_next_serial(wl_client_get_display(client));
zxdg_surface_v6_send_configure(event_sink, serial);
};
}

void mir::frontend::XdgSurfaceV6::commit(mir::frontend::WlSurfaceState const& state)
{
WlAbstractMirWindow::commit(state);
auto const serial = wl_display_next_serial(wl_client_get_display(client));
commit_action();
commit_action = []{};
zxdg_surface_v6_send_configure(event_sink, serial);
}

// XdgSurfaceV6EventSink
Expand All @@ -469,14 +476,6 @@ void mf::XdgSurfaceV6EventSink::send_resize(geometry::Size const& new_size) cons
}));
}

void mf::XdgSurfaceV6EventSink::post_configure(int serial) const
{
seat->spawn(run_unless(destroyed, [event_sink= event_sink, serial]()
{
zxdg_surface_v6_send_configure(event_sink, serial);
}));
}

// XdgPopupV6

mf::XdgPopupV6::XdgPopupV6(struct wl_client* client, struct wl_resource* parent, uint32_t id)
Expand Down Expand Up @@ -505,7 +504,7 @@ mf::XdgToplevelV6::XdgToplevelV6(struct wl_client* client, struct wl_resource* p
self->set_notify_resize(
[this](geom::Size const& new_size, MirWindowState state, bool active)
{
this->self->on_next_commit([]{});
this->self->clear_on_next_commit();

wl_array states;
wl_array_init(&states);
Expand Down Expand Up @@ -539,7 +538,7 @@ mf::XdgToplevelV6::XdgToplevelV6(struct wl_client* client, struct wl_resource* p
wl_array_release(&states);
});

self->on_next_commit([resource=this->resource]
self->on_next_commit([resource=this->resource, self]
{
wl_array states;
wl_array_init(&states);
Expand Down

0 comments on commit 7373b7b

Please sign in to comment.