Skip to content

Commit

Permalink
exo: Flush data device related events properly.
Browse files Browse the repository at this point in the history
Bug: 833986
Test: No delays when using copy-and-paste in Crostini.
Change-Id: I6722dbd81548b760db8e1ae9a4e3cd1d4c6bf645
Reviewed-on: https://chromium-review.googlesource.com/1015700
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Commit-Queue: David Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551462}
  • Loading branch information
reveman-chromium authored and Commit Bot committed Apr 17, 2018
1 parent 6db6869 commit 84227cb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions components/exo/wayland/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3117,31 +3117,37 @@ class WaylandDataSourceDelegate : public DataSourceDelegate {
void OnDataSourceDestroying(DataSource* device) override { delete this; }
void OnTarget(const std::string& mime_type) override {
wl_data_source_send_target(data_source_resource_, mime_type.c_str());
wl_client_flush(wl_resource_get_client(data_source_resource_));
}
void OnSend(const std::string& mime_type, base::ScopedFD fd) override {
wl_data_source_send_send(data_source_resource_, mime_type.c_str(),
fd.get());
wl_client_flush(wl_resource_get_client(data_source_resource_));
}
void OnCancelled() override {
wl_data_source_send_cancelled(data_source_resource_);
wl_client_flush(wl_resource_get_client(data_source_resource_));
}
void OnDndDropPerformed() override {
if (wl_resource_get_version(data_source_resource_) >=
WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION) {
wl_data_source_send_dnd_drop_performed(data_source_resource_);
wl_client_flush(wl_resource_get_client(data_source_resource_));
}
}
void OnDndFinished() override {
if (wl_resource_get_version(data_source_resource_) >=
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
wl_data_source_send_dnd_finished(data_source_resource_);
wl_client_flush(wl_resource_get_client(data_source_resource_));
}
}
void OnAction(DndAction dnd_action) override {
if (wl_resource_get_version(data_source_resource_) >=
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
wl_data_source_send_action(data_source_resource_,
WaylandDataDeviceManagerDndAction(dnd_action));
wl_client_flush(wl_resource_get_client(data_source_resource_));
}
}

Expand Down Expand Up @@ -3183,6 +3189,7 @@ class WaylandDataOfferDelegate : public DataOfferDelegate {
void OnDataOfferDestroying(DataOffer* device) override { delete this; }
void OnOffer(const std::string& mime_type) override {
wl_data_offer_send_offer(data_offer_resource_, mime_type.c_str());
wl_client_flush(wl_resource_get_client(data_offer_resource_));
}
void OnSourceActions(
const base::flat_set<DndAction>& source_actions) override {
Expand All @@ -3191,13 +3198,15 @@ class WaylandDataOfferDelegate : public DataOfferDelegate {
wl_data_offer_send_source_actions(
data_offer_resource_,
WaylandDataDeviceManagerDndActions(source_actions));
wl_client_flush(wl_resource_get_client(data_offer_resource_));
}
}
void OnAction(DndAction action) override {
if (wl_resource_get_version(data_offer_resource_) >=
WL_DATA_OFFER_ACTION_SINCE_VERSION) {
wl_data_offer_send_action(data_offer_resource_,
WaylandDataDeviceManagerDndAction(action));
wl_client_flush(wl_resource_get_client(data_offer_resource_));
}
}

Expand Down Expand Up @@ -3267,6 +3276,7 @@ class WaylandDataDeviceDelegate : public DataDeviceDelegate {
std::move(data_offer));

wl_data_device_send_data_offer(data_device_resource_, data_offer_resource);
wl_client_flush(client_);

return GetUserDataAs<DataOffer>(data_offer_resource);
}
Expand All @@ -3278,17 +3288,26 @@ class WaylandDataDeviceDelegate : public DataDeviceDelegate {
wl_display_next_serial(wl_client_get_display(client_)),
GetSurfaceResource(surface), wl_fixed_from_double(point.x()),
wl_fixed_from_double(point.y()), GetDataOfferResource(&data_offer));
wl_client_flush(client_);
}
void OnLeave() override {
wl_data_device_send_leave(data_device_resource_);
wl_client_flush(client_);
}
void OnLeave() override { wl_data_device_send_leave(data_device_resource_); }
void OnMotion(base::TimeTicks time_stamp, const gfx::PointF& point) override {
wl_data_device_send_motion(
data_device_resource_, TimeTicksToMilliseconds(time_stamp),
wl_fixed_from_double(point.x()), wl_fixed_from_double(point.y()));
wl_client_flush(client_);
}
void OnDrop() override {
wl_data_device_send_drop(data_device_resource_);
wl_client_flush(client_);
}
void OnDrop() override { wl_data_device_send_drop(data_device_resource_); }
void OnSelection(const DataOffer& data_offer) override {
wl_data_device_send_selection(data_device_resource_,
GetDataOfferResource(&data_offer));
wl_client_flush(client_);
}

private:
Expand Down

0 comments on commit 84227cb

Please sign in to comment.