Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Issue 1892483005: SelectionOwner: add support for TIMESTAMP target (Closed)

Created:
4 years, 8 months ago by dcheng
Modified:
4 years, 8 months ago
Reviewers:
Elliot Glaysher, sadrul, sky
CC:
chromium-reviews, danakj, derat+watch_chromium.org, sadrul, yusukes+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

SelectionOwner: add support for TIMESTAMP target Even though XSetSelectionOwner() has a Time argument, there's no way to retrieve the timestamp associated with the selection from the X server itself. Instead, the X11 selection protocol requires selections to provide a TIMESTAMP target. Unfortunately, there's also no good way to get the current timestamp from the X server: one way is to make a no-op property change and observe the resulting PropertyNotify event. This is the what GTK does, but it both blocks and performs out-of-order event dispatching. In Chromium, we control our event source, so we implement an alternate strategy instead: we record the server time seen in X events with a time field and use the last seen value when taking ownership of the X selection. Of course, since this is X, the server time observer has to be careful to ignore instances where time == CurrentTime (explicitly set by some programs to indicate an X event is synthesized) and where time goes backwards (since events can be reordered). Note that despite all this logic to sanitize X server time, actually using the last seen time when calling XSetSelectionOwner() doesn't actually seem to be good enough. Random omnibox tests still fail in that case, so we still pass CurrentTime to XSetSelectionOwner() to increase the chances of success. ¯\_(ツ)_/¯ BUG=395077 Committed: https://crrev.com/5c42da4d3ec29ffaf0bb9d3fbd33a55f75249781 Cr-Commit-Position: refs/heads/master@{#389208}

Patch Set 1 #

Patch Set 2 : I hate X #

Total comments: 2

Patch Set 3 : . #

Patch Set 4 : . #

Total comments: 4

Patch Set 5 : . #

Total comments: 2

Patch Set 6 : Fix gyp? #

Patch Set 7 : ugh #

Total comments: 2

Patch Set 8 : nogncheck #

Total comments: 12

Patch Set 9 : address feedback #

Total comments: 2

Patch Set 10 : USE_GLIB #

Unified diffs Side-by-side diffs Delta from patch set Stats (+168 lines, -73 lines) Patch
M components/bookmarks.gypi View 1 2 3 4 5 6 1 chunk +6 lines, -0 lines 0 comments Download
M components/bookmarks/browser/BUILD.gn View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M components/bookmarks/browser/bookmark_utils_unittest.cc View 1 2 3 4 5 6 7 8 9 3 chunks +20 lines, -2 lines 0 comments Download
M ui/base/BUILD.gn View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M ui/base/ui_base.gyp View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M ui/base/x/selection_owner.h View 1 chunk +3 lines, -0 lines 0 comments Download
M ui/base/x/selection_owner.cc View 1 2 3 4 5 6 7 8 5 chunks +79 lines, -67 lines 0 comments Download
M ui/events/platform/x11/x11_event_source.h View 1 2 3 4 5 6 7 8 3 chunks +7 lines, -2 lines 0 comments Download
M ui/events/platform/x11/x11_event_source.cc View 1 2 3 4 5 6 7 8 2 chunks +44 lines, -1 line 0 comments Download

Messages

Total messages: 49 (19 generated)
dcheng
Behold the beauty and elegance of the X selection protocol.
4 years, 8 months ago (2016-04-15 20:35:36 UTC) #3
dcheng
cc lambroslambrou@ as well, since I think there's a long-standing TODO in remoting's X server ...
4 years, 8 months ago (2016-04-15 21:21:09 UTC) #4
Elliot Glaysher
https://codereview.chromium.org/1892483005/diff/20001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/20001/ui/base/x/selection_owner.cc#newcode82 ui/base/x/selection_owner.cc:82: XIfEvent(display, &event, +predicate, reinterpret_cast<XPointer>(&args)); "+" predicate? I assume the ...
4 years, 8 months ago (2016-04-15 21:45:32 UTC) #6
dcheng
https://codereview.chromium.org/1892483005/diff/20001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/20001/ui/base/x/selection_owner.cc#newcode82 ui/base/x/selection_owner.cc:82: XIfEvent(display, &event, +predicate, reinterpret_cast<XPointer>(&args)); On 2016/04/15 at 21:45:31, Elliot ...
4 years, 8 months ago (2016-04-15 21:53:47 UTC) #7
dcheng
Ack, it looks like there's some failures with DND. Let me look at those
4 years, 8 months ago (2016-04-15 21:54:50 UTC) #8
dcheng
PTAL, I think it should be fixed now. The problem is that OSExchangeDataProviderAuraX11's X11 window ...
4 years, 8 months ago (2016-04-18 21:34:03 UTC) #9
sadrul
https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc#newcode83 ui/base/x/selection_owner.cc:83: return event.xproperty.time; How does things break when we use ...
4 years, 8 months ago (2016-04-19 16:11:53 UTC) #10
dcheng
https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc#newcode83 ui/base/x/selection_owner.cc:83: return event.xproperty.time; On 2016/04/19 at 16:11:52, sadrul wrote: > ...
4 years, 8 months ago (2016-04-19 17:24:15 UTC) #11
Elliot Glaysher
https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc#newcode83 ui/base/x/selection_owner.cc:83: return event.xproperty.time; On 2016/04/19 17:24:15, dcheng wrote: > Processing ...
4 years, 8 months ago (2016-04-19 17:30:36 UTC) #12
dcheng
https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc#newcode83 ui/base/x/selection_owner.cc:83: return event.xproperty.time; On 2016/04/19 at 17:30:36, Elliot Glaysher wrote: ...
4 years, 8 months ago (2016-04-19 17:44:11 UTC) #13
Elliot Glaysher
On 2016/04/19 17:44:11, dcheng wrote: > https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc > File ui/base/x/selection_owner.cc (right): > > https://codereview.chromium.org/1892483005/diff/60001/ui/base/x/selection_owner.cc#newcode83 > ...
4 years, 8 months ago (2016-04-19 17:57:42 UTC) #14
dcheng
https://codereview.chromium.org/1892483005/diff/80001/ui/events/platform/x11/x11_event_source.cc File ui/events/platform/x11/x11_event_source.cc (right): https://codereview.chromium.org/1892483005/diff/80001/ui/events/platform/x11/x11_event_source.cc#newcode133 ui/events/platform/x11/x11_event_source.cc:133: void X11EventSource::ExtractTimeFromXEvent(const XEvent& xevent) { An alternative was to ...
4 years, 8 months ago (2016-04-19 21:56:45 UTC) #15
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1892483005/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1892483005/100001
4 years, 8 months ago (2016-04-19 22:06:25 UTC) #17
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/215136)
4 years, 8 months ago (2016-04-19 22:55:34 UTC) #19
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1892483005/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1892483005/120001
4 years, 8 months ago (2016-04-20 00:54:17 UTC) #21
dcheng
PTAL. Added a few more hacks, because X. https://codereview.chromium.org/1892483005/diff/120001/components/bookmarks/browser/bookmark_utils_unittest.cc File components/bookmarks/browser/bookmark_utils_unittest.cc (right): https://codereview.chromium.org/1892483005/diff/120001/components/bookmarks/browser/bookmark_utils_unittest.cc#newcode91 components/bookmarks/browser/bookmark_utils_unittest.cc:91: ui::X11EventSourceGlib ...
4 years, 8 months ago (2016-04-20 00:55:26 UTC) #22
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_gn_chromeos_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_gn_chromeos_rel/builds/174845)
4 years, 8 months ago (2016-04-20 01:03:52 UTC) #24
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1892483005/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1892483005/140001
4 years, 8 months ago (2016-04-20 01:28:31 UTC) #26
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 8 months ago (2016-04-20 02:31:57 UTC) #28
Elliot Glaysher
Thank you for humouring me. LGTM. https://codereview.chromium.org/1892483005/diff/140001/components/bookmarks/browser/bookmark_utils_unittest.cc File components/bookmarks/browser/bookmark_utils_unittest.cc (right): https://codereview.chromium.org/1892483005/diff/140001/components/bookmarks/browser/bookmark_utils_unittest.cc#newcode43 components/bookmarks/browser/bookmark_utils_unittest.cc:43: event_source_(gfx::GetXDisplay()) { I ...
4 years, 8 months ago (2016-04-20 17:37:22 UTC) #29
sadrul
https://codereview.chromium.org/1892483005/diff/140001/ui/base/x/selection_owner.cc File ui/base/x/selection_owner.cc (right): https://codereview.chromium.org/1892483005/diff/140001/ui/base/x/selection_owner.cc#newcode124 ui/base/x/selection_owner.cc:124: X11EventSource::GetInstance()->last_seen_server_time(); Can this use something else (like CurrentTime) if ...
4 years, 8 months ago (2016-04-20 17:58:43 UTC) #30
sadrul
https://codereview.chromium.org/1892483005/diff/140001/ui/events/platform/x11/x11_event_source.cc File ui/events/platform/x11/x11_event_source.cc (right): https://codereview.chromium.org/1892483005/diff/140001/ui/events/platform/x11/x11_event_source.cc#newcode157 ui/events/platform/x11/x11_event_source.cc:157: return static_cast<XIDeviceEvent*>(xevent.xcookie.data)->time; Also, you should check DeviceDataManagerX11::IsXIDeviceEvent() before casting ...
4 years, 8 months ago (2016-04-20 18:01:08 UTC) #31
dcheng
+sky for //components/bookmarks as well I made two other changes: - Made it so the ...
4 years, 8 months ago (2016-04-20 18:55:43 UTC) #33
sky
LGTM
4 years, 8 months ago (2016-04-20 19:53:58 UTC) #34
sadrul
lgtm https://codereview.chromium.org/1892483005/diff/160001/components/bookmarks/browser/bookmark_utils_unittest.cc File components/bookmarks/browser/bookmark_utils_unittest.cc (right): https://codereview.chromium.org/1892483005/diff/160001/components/bookmarks/browser/bookmark_utils_unittest.cc#newcode89 components/bookmarks/browser/bookmark_utils_unittest.cc:89: #if defined(USE_X11) To be safe, guard all these ...
4 years, 8 months ago (2016-04-22 17:17:25 UTC) #35
sadrul
[ Please update the CL description to briefly mention the intricacies of CurrentTime etc. ]
4 years, 8 months ago (2016-04-22 17:18:42 UTC) #36
dcheng
Also updated the CL description with my sad tale. https://codereview.chromium.org/1892483005/diff/160001/components/bookmarks/browser/bookmark_utils_unittest.cc File components/bookmarks/browser/bookmark_utils_unittest.cc (right): https://codereview.chromium.org/1892483005/diff/160001/components/bookmarks/browser/bookmark_utils_unittest.cc#newcode89 components/bookmarks/browser/bookmark_utils_unittest.cc:89: ...
4 years, 8 months ago (2016-04-22 18:20:15 UTC) #45
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1892483005/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1892483005/180001
4 years, 8 months ago (2016-04-22 18:20:18 UTC) #46
commit-bot: I haz the power
Committed patchset #10 (id:180001)
4 years, 8 months ago (2016-04-22 19:27:09 UTC) #47
commit-bot: I haz the power
4 years, 8 months ago (2016-04-22 19:51:43 UTC) #49
Message was sent while issue was closed.
Patchset 10 (id:??) landed as
https://crrev.com/5c42da4d3ec29ffaf0bb9d3fbd33a55f75249781
Cr-Commit-Position: refs/heads/master@{#389208}

Powered by Google App Engine
This is Rietveld 408576698