-
Notifications
You must be signed in to change notification settings - Fork 107
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
Sequence xdg-top-level and xdg-surface configure events correctly. #281
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5aac9a2
Sequence xdg-top-level and xdg-surface configure events correctly.
AlanGriffiths 7373b7b
Don't send too many zxdg_surface_v6 "configure" events.
AlanGriffiths fa87114
Better names
AlanGriffiths 2a030b7
Fix menus
AlanGriffiths a9f044c
Remove workaround
AlanGriffiths File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,15 @@ class XdgSurfaceV6 : wayland::XdgSurfaceV6, WlAbstractMirWindow | |
void get_popup(uint32_t id, struct wl_resource* parent, struct wl_resource* positioner) override; | ||
void set_window_geometry(int32_t x, int32_t y, int32_t width, int32_t height) override; | ||
void ack_configure(uint32_t serial) override; | ||
void commit(WlSurfaceState const& state) override; | ||
|
||
void set_parent(optional_value<SurfaceId> parent_id); | ||
void set_title(std::string const& title); | ||
void move(struct wl_resource* seat, uint32_t serial); | ||
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 set_next_commit_action(std::function<void()> action); | ||
void clear_next_commit_action(); | ||
void set_max_size(int32_t width, int32_t height); | ||
void set_min_size(int32_t width, int32_t height); | ||
void set_maximized(); | ||
|
@@ -75,6 +78,7 @@ class XdgSurfaceV6 : wayland::XdgSurfaceV6, WlAbstractMirWindow | |
struct wl_resource* const parent; | ||
std::shared_ptr<Shell> const shell; | ||
std::shared_ptr<XdgSurfaceV6EventSink> const sink; | ||
std::function<void()> next_commit_action{[]{}}; | ||
}; | ||
|
||
class XdgSurfaceV6EventSink : public BasicSurfaceEventSink | ||
|
@@ -91,15 +95,13 @@ class XdgSurfaceV6EventSink : public BasicSurfaceEventSink | |
[](auto, auto, auto){}; | ||
|
||
private: | ||
void post_configure(int serial) const; | ||
|
||
std::shared_ptr<bool> const destroyed; | ||
}; | ||
|
||
class XdgPopupV6 : wayland::XdgPopupV6 | ||
{ | ||
public: | ||
XdgPopupV6(struct wl_client* client, struct wl_resource* parent, uint32_t id); | ||
XdgPopupV6(struct wl_client* client, struct wl_resource* parent, uint32_t id, XdgSurfaceV6* self); | ||
|
||
void grab(struct wl_resource* seat, uint32_t serial) override; | ||
void destroy() override; | ||
|
@@ -242,7 +244,7 @@ void mf::XdgSurfaceV6::get_popup(uint32_t id, struct wl_resource* parent, struct | |
params->aux_rect_placement_offset_y = pos->aux_rect_placement_offset_y; | ||
params->placement_hints = mir_placement_hints_slide_any; | ||
|
||
new XdgPopupV6{client, parent, id}; | ||
new XdgPopupV6{client, parent, id, this}; | ||
surface->set_role(this); | ||
} | ||
|
||
|
@@ -433,15 +435,35 @@ void mf::XdgSurfaceV6::unset_maximized() | |
} | ||
} | ||
|
||
void mir::frontend::XdgSurfaceV6::clear_next_commit_action() | ||
{ | ||
next_commit_action = []{}; | ||
} | ||
|
||
void mir::frontend::XdgSurfaceV6::set_next_commit_action(std::function<void()> action) | ||
{ | ||
next_commit_action = [this, action] | ||
{ | ||
action(); | ||
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); | ||
next_commit_action(); | ||
clear_next_commit_action(); | ||
} | ||
|
||
// XdgSurfaceV6EventSink | ||
|
||
mf::XdgSurfaceV6EventSink::XdgSurfaceV6EventSink(WlSeat* seat, wl_client* client, wl_resource* target, | ||
wl_resource* event_sink, std::shared_ptr<bool> const& destroyed) | ||
: BasicSurfaceEventSink(seat, client, target, event_sink), | ||
destroyed{destroyed} | ||
{ | ||
auto const serial = wl_display_next_serial(wl_client_get_display(client)); | ||
post_configure(serial); | ||
} | ||
|
||
void mf::XdgSurfaceV6EventSink::send_resize(geometry::Size const& new_size) const | ||
|
@@ -454,19 +476,15 @@ 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) | ||
mf::XdgPopupV6::XdgPopupV6(struct wl_client* client, struct wl_resource* parent, uint32_t id, XdgSurfaceV6* self) | ||
: wayland::XdgPopupV6(client, parent, id) | ||
{} | ||
{ | ||
// TODO Make this readable!!! This "works" by exploiting the non-obvious side-effect | ||
// of causing a zxdg_surface_v6_send_configure() event to become pending. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding this comment |
||
self->set_next_commit_action([]{}); | ||
} | ||
|
||
void mf::XdgPopupV6::grab(struct wl_resource* seat, uint32_t serial) | ||
{ | ||
|
@@ -490,6 +508,8 @@ 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->clear_next_commit_action(); | ||
|
||
wl_array states; | ||
wl_array_init(&states); | ||
|
||
|
@@ -521,6 +541,15 @@ mf::XdgToplevelV6::XdgToplevelV6(struct wl_client* client, struct wl_resource* p | |
|
||
wl_array_release(&states); | ||
}); | ||
|
||
self->set_next_commit_action( | ||
[resource = this->resource, self] | ||
{ | ||
wl_array states; | ||
wl_array_init(&states); | ||
zxdg_toplevel_v6_send_configure(resource, 0, 0, &states); | ||
wl_array_release(&states); | ||
}); | ||
} | ||
|
||
void mf::XdgToplevelV6::destroy() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[non-blocking] perhaps
next_commit_action
could be a vector so multiple lambdas can be added and executed with no danger of overwriting and not running an action.