From 488b420457ae3b003ba2cd9e9dd12fc4067833ec Mon Sep 17 00:00:00 2001 From: "xiyuan@chromium.org" Date: Tue, 15 Nov 2011 00:20:18 +0000 Subject: [Aura] Support always-on-top top level window. BUG=97256,102582 TEST=AlwaysOnTop related tests in ShellTest should pass. Review URL: http://codereview.chromium.org/8387043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109990 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/base/x/x11_util.cc | 22 ++++++++++++++++------ ui/base/x/x11_util.h | 4 ++++ 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'ui/base') diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index dada148..aa11de8 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -114,12 +114,7 @@ class XCursorCache { public: XCursorCache() {} ~XCursorCache() { - Display* display = base::MessagePumpForUI::GetDefaultXDisplay(); - for (std::map::iterator it = - cache_.begin(); it != cache_.end(); ++it) { - XFreeCursor(display, it->second); - } - cache_.clear(); + Clear(); } Cursor GetCursor(int cursor_shape) { @@ -134,6 +129,15 @@ class XCursorCache { return it.first->second; } + void Clear() { + Display* display = base::MessagePumpForUI::GetDefaultXDisplay(); + for (std::map::iterator it = + cache_.begin(); it != cache_.end(); ++it) { + XFreeCursor(display, it->second); + } + cache_.clear(); + } + private: // Maps X11 font cursor shapes to Cursor IDs. std::map cache_; @@ -218,6 +222,12 @@ int GetDefaultScreen(Display* display) { Cursor GetXCursor(int cursor_shape) { CR_DEFINE_STATIC_LOCAL(XCursorCache, cache, ()); + + if (cursor_shape == kCursorClearXCursorCache) { + cache.Clear(); + return 0; + } + return cache.GetCursor(cursor_shape); } diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index f9e979c..888e76a 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -68,6 +68,10 @@ UI_EXPORT bool QueryRenderSupport(Display* dpy); // Return the default screen number for the display int GetDefaultScreen(Display* display); +// TODO(xiyuan): Fix the stale XCursorCache problem per http://crbug.com/102759. +// A special cursor that makes GetXCursor below to clear its XCursorCache. +const int kCursorClearXCursorCache = -1; + // Returns an X11 Cursor, sharable across the process. // |cursor_shape| is an X font cursor shape, see XCreateFontCursor(). UI_EXPORT Cursor GetXCursor(int cursor_shape); -- cgit v1.1