From 11aa41dc3c2e265a712b55d0a642739493ac78eb Mon Sep 17 00:00:00 2001 From: thomasanderson Date: Thu, 8 Jun 2017 15:22:38 -0700 Subject: [PATCH] Move ui::GetAtom to gfx::GetAtom This CL is a followup to [1]. However, unlike that CL, this one should have no functional changes as it is purely a refactoring. This CL adds gfx::GetAtom (and renames the ::ui namespace in x11_atom_cache to ::gfx) and updates all references that used to point to ui::GetAtom to gfx::GetAtom. Also update PRESUBMIT.py to include exceptions for 2 files that use XInternAtom appropriately. [1] https://codereview.chromium.org/2914103002/ BUG=730889 R=sadrul@chromium.org TBR=sky@chromium.org Review-Url: https://codereview.chromium.org/2924343002 Cr-Commit-Position: refs/heads/master@{#478103} --- PRESUBMIT.py | 5 +- ash/host/ash_window_tree_host_x11.cc | 2 +- .../media/webrtc/window_icon_util_x11.cc | 3 +- ui/aura/test/ui_controls_factory_aurax11.cc | 4 +- ui/aura/window_tree_host_x11.cc | 11 +-- ui/base/clipboard/clipboard_aurax11.cc | 23 ++--- .../os_exchange_data_provider_aurax11.cc | 69 +++++++------- ...exchange_data_provider_aurax11_unittest.cc | 5 +- ui/base/idle/screensaver_window_finder_x11.cc | 3 +- ui/base/x/selection_owner.cc | 18 ++-- ui/base/x/selection_requestor.cc | 5 +- ui/base/x/selection_requestor_unittest.cc | 13 +-- ui/base/x/selection_utils.cc | 27 +++--- ui/base/x/x11_menu_list.cc | 4 +- ui/base/x/x11_util.cc | 47 +++++----- ui/base/x/x11_util.h | 3 - .../x11/native_display_delegate_x11.cc | 20 ++--- ui/display/util/x11/edid_parser_x11.cc | 3 +- .../devices/x11/device_data_manager_x11.cc | 5 +- ui/events/platform/x11/x11_event_source.cc | 2 +- .../platform/x11/x11_hotplug_event_handler.cc | 20 ++--- ui/gfx/icc_profile_x11.cc | 2 +- ui/gfx/x/x11_atom_cache.cc | 8 +- ui/gfx/x/x11_atom_cache.h | 14 +-- ui/platform_window/x11/x11_window_base.cc | 19 ++-- .../ui_controls_factory_desktop_aurax11.cc | 3 +- ui/views/test/x11_property_change_waiter.cc | 4 +- .../desktop_drag_drop_client_aurax11.cc | 76 ++++++++-------- ...sktop_drag_drop_client_aurax11_unittest.cc | 3 +- .../widget/desktop_aura/desktop_screen_x11.cc | 5 +- .../desktop_screen_x11_unittest.cc | 4 +- .../desktop_window_tree_host_x11.cc | 90 ++++++++++--------- .../desktop_window_tree_host_x11_unittest.cc | 19 ++-- .../desktop_aura/x11_desktop_handler.cc | 4 +- ...opmost_window_finder_interactive_uitest.cc | 5 +- .../desktop_aura/x11_window_event_filter.cc | 4 +- 36 files changed, 282 insertions(+), 270 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index c0324ab809eee6..46e16be0020af6 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -191,11 +191,12 @@ ( r'XInternAtom|xcb_intern_atom', ( - 'Use ui::GetAtom() or ui::X11AtomCache::GetAtom() instead of', - 'interning atoms directly.', + 'Use gfx::GetAtom() instead of interning atoms directly.', ), True, ( + r"^gpu[\\\/]ipc[\\\/]service[\\\/]gpu_watchdog_thread\.cc$", + r"^remoting[\\\/]host[\\\/]linux[\\\/]x_server_clipboard\.cc$", r"^ui[\\\/]gfx[\\\/]x[\\\/]x11_atom_cache\.cc$", ), ), diff --git a/ash/host/ash_window_tree_host_x11.cc b/ash/host/ash_window_tree_host_x11.cc index 68d864a4c68f66..1ac912f27ff4c4 100644 --- a/ash/host/ash_window_tree_host_x11.cc +++ b/ash/host/ash_window_tree_host_x11.cc @@ -217,7 +217,7 @@ void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) { if (!ui::IsXInput2Available()) return; // Temporarily pause tap-to-click when the cursor is hidden. - Atom prop = ui::X11AtomCache::GetInstance()->GetAtom("Tap Paused"); + Atom prop = gfx::GetAtom("Tap Paused"); unsigned char value = state; const XIDeviceList& dev_list = ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(xdisplay()); diff --git a/chrome/browser/media/webrtc/window_icon_util_x11.cc b/chrome/browser/media/webrtc/window_icon_util_x11.cc index e9b34ae5ad7225..927b93873b3acf 100644 --- a/chrome/browser/media/webrtc/window_icon_util_x11.cc +++ b/chrome/browser/media/webrtc/window_icon_util_x11.cc @@ -8,6 +8,7 @@ #include #include "ui/base/x/x11_util.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_error_tracker.h" #include "ui/gfx/x/x11_types.h" @@ -15,7 +16,7 @@ gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) { DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW); Display* display = gfx::GetXDisplay(); - Atom property = ui::GetAtom("_NET_WM_ICON"); + Atom property = gfx::GetAtom("_NET_WM_ICON"); Atom actual_type; int actual_format; unsigned long bytes_after; // NOLINT: type required by XGetWindowProperty diff --git a/ui/aura/test/ui_controls_factory_aurax11.cc b/ui/aura/test/ui_controls_factory_aurax11.cc index 134264569b8df7..3dd0199806806e 100644 --- a/ui/aura/test/ui_controls_factory_aurax11.cc +++ b/ui/aura/test/ui_controls_factory_aurax11.cc @@ -16,10 +16,10 @@ #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/base/test/ui_controls_aura.h" -#include "ui/base/x/x11_util.h" #include "ui/compositor/dip_util.h" #include "ui/events/keycodes/keyboard_code_conversion_x.h" #include "ui/events/test/platform_event_waiter.h" +#include "ui/gfx/x/x11_atom_cache.h" namespace aura { namespace test { @@ -38,7 +38,7 @@ unsigned button_down_mask = 0; // Returns atom that indidates that the XEvent is marker event. Atom MarkerEventAtom() { - return ui::GetAtom("marker_event"); + return gfx::GetAtom("marker_event"); } // Returns true when the event is a marker event. diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc index f59d99ecee569c..0635b7a65ff21e 100644 --- a/ui/aura/window_tree_host_x11.cc +++ b/ui/aura/window_tree_host_x11.cc @@ -51,6 +51,7 @@ #include "ui/events/platform/platform_event_observer.h" #include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/x11/x11_event_source.h" +#include "ui/gfx/x/x11_atom_cache.h" using std::max; using std::min; @@ -145,8 +146,8 @@ WindowTreeHostX11::WindowTreeHostX11(const gfx::Rect& bounds) // should listen for activation events and anything else that GTK+ listens // for, and do something useful. ::Atom protocols[2]; - protocols[0] = ui::GetAtom("WM_DELETE_WINDOW"); - protocols[1] = ui::GetAtom("_NET_WM_PING"); + protocols[0] = gfx::GetAtom("WM_DELETE_WINDOW"); + protocols[1] = gfx::GetAtom("_NET_WM_PING"); XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with @@ -160,7 +161,7 @@ WindowTreeHostX11::WindowTreeHostX11(const gfx::Rect& bounds) static_assert(sizeof(long) >= sizeof(pid_t), "pid_t should not be larger than long"); long pid = getpid(); - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_PID"), XA_CARDINAL, + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(&pid), 1); @@ -307,10 +308,10 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) { break; case ClientMessage: { Atom message_type = static_cast(xev->xclient.data.l[0]); - if (message_type == ui::GetAtom("WM_DELETE_WINDOW")) { + if (message_type == gfx::GetAtom("WM_DELETE_WINDOW")) { // We have received a close message from the window manager. OnHostCloseRequested(); - } else if (message_type == ui::GetAtom("_NET_WM_PING")) { + } else if (message_type == gfx::GetAtom("_NET_WM_PING")) { XEvent reply_event = *xev; reply_event.xclient.window = x_root_window_; diff --git a/ui/base/clipboard/clipboard_aurax11.cc b/ui/base/clipboard/clipboard_aurax11.cc index 3def226d17c4c2..f7f2d74d436c5f 100644 --- a/ui/base/clipboard/clipboard_aurax11.cc +++ b/ui/base/clipboard/clipboard_aurax11.cc @@ -34,6 +34,7 @@ #include "ui/events/platform/platform_event_source.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/geometry/size.h" +#include "ui/gfx/x/x11_atom_cache.h" namespace ui { @@ -82,7 +83,7 @@ SelectionChangeObserver::SelectionChangeObserver() primary_sequence_number_(0) { int ignored; if (XFixesQueryExtension(gfx::GetXDisplay(), &event_base_, &ignored)) { - clipboard_atom_ = GetAtom(kClipboard); + clipboard_atom_ = gfx::GetAtom(kClipboard); XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(), clipboard_atom_, XFixesSetSelectionOwnerNotifyMask | @@ -159,7 +160,7 @@ bool TargetList::ContainsText() const { bool TargetList::ContainsFormat( const Clipboard::FormatType& format_type) const { - ::Atom atom = GetAtom(format_type.ToString().c_str()); + ::Atom atom = gfx::GetAtom(format_type.ToString().c_str()); return ContainsAtom(atom); } @@ -314,7 +315,7 @@ ClipboardAuraX11::AuraX11Details::AuraX11Details() 0, NULL)), selection_requestor_(x_display_, x_window_, this), - clipboard_owner_(x_display_, x_window_, GetAtom(kClipboard)), + clipboard_owner_(x_display_, x_window_, gfx::GetAtom(kClipboard)), primary_owner_(x_display_, x_window_, XA_PRIMARY) { XStoreName(x_display_, x_window_, "Chromium clipboard"); x_window_events_.reset( @@ -340,7 +341,7 @@ ::Atom ClipboardAuraX11::AuraX11Details::LookupSelectionForClipboardType( } ::Atom ClipboardAuraX11::AuraX11Details::GetCopyPasteSelection() const { - return GetAtom(kClipboard); + return gfx::GetAtom(kClipboard); } const SelectionFormatMap& @@ -359,7 +360,7 @@ void ClipboardAuraX11::AuraX11Details::CreateNewClipboardData() { void ClipboardAuraX11::AuraX11Details::InsertMapping( const std::string& key, const scoped_refptr& memory) { - ::Atom atom_key = GetAtom(key.c_str()); + ::Atom atom_key = gfx::GetAtom(key.c_str()); clipboard_data_.Insert(atom_key, memory); } @@ -391,7 +392,7 @@ SelectionData ClipboardAuraX11::AuraX11Details::RequestAndWaitForTypes( ::Atom selection_name = LookupSelectionForClipboardType(type); std::vector< ::Atom> intersection; - ui::GetAtomIntersection(types, targets.target_list(), &intersection); + GetAtomIntersection(types, targets.target_list(), &intersection); return selection_requestor_.RequestAndWaitForTypes(selection_name, intersection); } @@ -417,10 +418,10 @@ TargetList ClipboardAuraX11::AuraX11Details::WaitAndGetTargetsList( ::Atom out_type = None; if (selection_requestor_.PerformBlockingConvertSelection( - selection_name, GetAtom(kTargets), &data, &out_data_items, + selection_name, gfx::GetAtom(kTargets), &data, &out_data_items, &out_type)) { // Some apps return an |out_type| of "TARGETS". (crbug.com/377893) - if (out_type == XA_ATOM || out_type == GetAtom(kTargets)) { + if (out_type == XA_ATOM || out_type == gfx::GetAtom(kTargets)) { const ::Atom* atom_array = reinterpret_cast(data->front()); for (size_t i = 0; i < out_data_items; ++i) @@ -459,7 +460,7 @@ std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetTextAtoms() const { std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetAtomsForFormat( const Clipboard::FormatType& format) { std::vector< ::Atom> atoms; - atoms.push_back(GetAtom(format.ToString().c_str())); + atoms.push_back(gfx::GetAtom(format.ToString().c_str())); return atoms; } @@ -475,7 +476,7 @@ void ClipboardAuraX11::AuraX11Details::StoreCopyPasteDataAndWait() { if (XGetSelectionOwner(x_display_, selection) != x_window_) return; - ::Atom clipboard_manager_atom = GetAtom(kClipboardManager); + ::Atom clipboard_manager_atom = gfx::GetAtom(kClipboardManager); if (XGetSelectionOwner(x_display_, clipboard_manager_atom) == None) return; @@ -486,7 +487,7 @@ void ClipboardAuraX11::AuraX11Details::StoreCopyPasteDataAndWait() { base::TimeTicks start = base::TimeTicks::Now(); selection_requestor_.PerformBlockingConvertSelectionWithParameter( - GetAtom(kClipboardManager), GetAtom(kSaveTargets), targets); + gfx::GetAtom(kClipboardManager), gfx::GetAtom(kSaveTargets), targets); UMA_HISTOGRAM_TIMES("Clipboard.X11StoreCopyPasteDuration", base::TimeTicks::Now() - start); } diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc index 8123d3811f1623..1a6e9a1c78928c 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc +++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc @@ -16,8 +16,8 @@ #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/dragdrop/file_info.h" #include "ui/base/x/selection_utils.h" -#include "ui/base/x/x11_util.h" #include "ui/events/platform/platform_event_source.h" +#include "ui/gfx/x/x11_atom_cache.h" // Note: the GetBlah() methods are used immediately by the // web_contents_view_aura.cc:PrepareDropData(), while the omnibox is a @@ -43,7 +43,7 @@ OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11( own_window_(false), x_window_(x_window), format_map_(selection), - selection_owner_(x_display_, x_window_, GetAtom(kDndSelection)) {} + selection_owner_(x_display_, x_window_, gfx::GetAtom(kDndSelection)) {} OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11() : x_display_(gfx::GetXDisplay()), @@ -62,7 +62,7 @@ OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11() 0, NULL)), format_map_(), - selection_owner_(x_display_, x_window_, GetAtom(kDndSelection)) { + selection_owner_(x_display_, x_window_, gfx::GetAtom(kDndSelection)) { XStoreName(x_display_, x_window_, "Chromium Drag & Drop Window"); PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); @@ -100,13 +100,13 @@ OSExchangeDataProviderAuraX11::Clone() const { void OSExchangeDataProviderAuraX11::MarkOriginatedFromRenderer() { std::string empty; - format_map_.Insert(GetAtom(kRendererTaint), + format_map_.Insert(gfx::GetAtom(kRendererTaint), scoped_refptr( base::RefCountedString::TakeString(&empty))); } bool OSExchangeDataProviderAuraX11::DidOriginateFromRenderer() const { - return format_map_.find(GetAtom(kRendererTaint)) != format_map_.end(); + return format_map_.find(gfx::GetAtom(kRendererTaint)) != format_map_.end(); } void OSExchangeDataProviderAuraX11::SetString(const base::string16& text_data) { @@ -117,10 +117,10 @@ void OSExchangeDataProviderAuraX11::SetString(const base::string16& text_data) { scoped_refptr mem( base::RefCountedString::TakeString(&utf8)); - format_map_.Insert(GetAtom(Clipboard::kMimeTypeText), mem); - format_map_.Insert(GetAtom(kText), mem); - format_map_.Insert(GetAtom(kString), mem); - format_map_.Insert(GetAtom(kUtf8String), mem); + format_map_.Insert(gfx::GetAtom(Clipboard::kMimeTypeText), mem); + format_map_.Insert(gfx::GetAtom(kText), mem); + format_map_.Insert(gfx::GetAtom(kString), mem); + format_map_.Insert(gfx::GetAtom(kUtf8String), mem); } void OSExchangeDataProviderAuraX11::SetURL(const GURL& url, @@ -138,7 +138,7 @@ void OSExchangeDataProviderAuraX11::SetURL(const GURL& url, scoped_refptr mem( base::RefCountedBytes::TakeVector(&data)); - format_map_.Insert(GetAtom(Clipboard::kMimeTypeMozillaURL), mem); + format_map_.Insert(gfx::GetAtom(Clipboard::kMimeTypeMozillaURL), mem); // Set a string fallback as well. SetString(spec); @@ -158,7 +158,7 @@ void OSExchangeDataProviderAuraX11::SetURL(const GURL& url, std::string netscape_url = url.spec(); netscape_url += "\n"; netscape_url += base::UTF16ToUTF8(title); - format_map_.Insert(GetAtom(kNetscapeURL), + format_map_.Insert(gfx::GetAtom(kNetscapeURL), scoped_refptr( base::RefCountedString::TakeString(&netscape_url))); } @@ -184,7 +184,7 @@ void OSExchangeDataProviderAuraX11::SetFilenames( std::string joined_data = base::JoinString(paths, "\n"); scoped_refptr mem( base::RefCountedString::TakeString(&joined_data)); - format_map_.Insert(GetAtom(Clipboard::kMimeTypeURIList), mem); + format_map_.Insert(gfx::GetAtom(Clipboard::kMimeTypeURIList), mem); } void OSExchangeDataProviderAuraX11::SetPickledData( @@ -198,7 +198,7 @@ void OSExchangeDataProviderAuraX11::SetPickledData( scoped_refptr mem( base::RefCountedBytes::TakeVector(&bytes)); - format_map_.Insert(GetAtom(format.ToString().c_str()), mem); + format_map_.Insert(gfx::GetAtom(format.ToString().c_str()), mem); } bool OSExchangeDataProviderAuraX11::GetString(base::string16* result) const { @@ -211,7 +211,7 @@ bool OSExchangeDataProviderAuraX11::GetString(base::string16* result) const { std::vector<::Atom> text_atoms = ui::GetTextAtomsFrom(); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types); + GetAtomIntersection(text_atoms, GetTargets(), &requested_types); ui::SelectionData data(format_map_.GetFirstOf(requested_types)); if (data.IsValid()) { @@ -229,7 +229,7 @@ bool OSExchangeDataProviderAuraX11::GetURLAndTitle( base::string16* title) const { std::vector<::Atom> url_atoms = ui::GetURLAtomsFrom(); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); ui::SelectionData data(format_map_.GetFirstOf(requested_types)); if (data.IsValid()) { @@ -237,7 +237,7 @@ bool OSExchangeDataProviderAuraX11::GetURLAndTitle( // but that doesn't match the assumptions of the rest of the system which // expect single types. - if (data.GetType() == GetAtom(Clipboard::kMimeTypeMozillaURL)) { + if (data.GetType() == gfx::GetAtom(Clipboard::kMimeTypeMozillaURL)) { // Mozilla URLs are (UTF16: URL, newline, title). base::string16 unparsed; data.AssignTo(&unparsed); @@ -254,7 +254,7 @@ bool OSExchangeDataProviderAuraX11::GetURLAndTitle( *url = GURL(tokens[0]); return true; } - } else if (data.GetType() == GetAtom(Clipboard::kMimeTypeURIList)) { + } else if (data.GetType() == gfx::GetAtom(Clipboard::kMimeTypeURIList)) { std::vector tokens = ui::ParseURIList(data); for (std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it) { @@ -286,7 +286,7 @@ bool OSExchangeDataProviderAuraX11::GetFilenames( std::vector* filenames) const { std::vector<::Atom> url_atoms = ui::GetURIListAtomsFrom(); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); filenames->clear(); ui::SelectionData data(format_map_.GetFirstOf(requested_types)); @@ -309,7 +309,7 @@ bool OSExchangeDataProviderAuraX11::GetPickledData( const Clipboard::FormatType& format, base::Pickle* pickle) const { std::vector< ::Atom> requested_types; - requested_types.push_back(GetAtom(format.ToString().c_str())); + requested_types.push_back(gfx::GetAtom(format.ToString().c_str())); ui::SelectionData data(format_map_.GetFirstOf(requested_types)); if (data.IsValid()) { @@ -326,7 +326,7 @@ bool OSExchangeDataProviderAuraX11::GetPickledData( bool OSExchangeDataProviderAuraX11::HasString() const { std::vector<::Atom> text_atoms = ui::GetTextAtomsFrom(); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(text_atoms, GetTargets(), &requested_types); + GetAtomIntersection(text_atoms, GetTargets(), &requested_types); return !requested_types.empty() && !HasFile(); } @@ -334,7 +334,7 @@ bool OSExchangeDataProviderAuraX11::HasURL( OSExchangeData::FilenameToURLPolicy policy) const { std::vector<::Atom> url_atoms = ui::GetURLAtomsFrom(); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); if (requested_types.empty()) return false; @@ -343,10 +343,11 @@ bool OSExchangeDataProviderAuraX11::HasURL( // Windows does and stuffs all the data into one mime type. ui::SelectionData data(format_map_.GetFirstOf(requested_types)); if (data.IsValid()) { - if (data.GetType() == GetAtom(Clipboard::kMimeTypeMozillaURL)) { + if (data.GetType() == gfx::GetAtom(Clipboard::kMimeTypeMozillaURL)) { // File managers shouldn't be using this type, so this is a URL. return true; - } else if (data.GetType() == GetAtom(ui::Clipboard::kMimeTypeURIList)) { + } else if (data.GetType() == + gfx::GetAtom(ui::Clipboard::kMimeTypeURIList)) { std::vector tokens = ui::ParseURIList(data); for (std::vector::const_iterator it = tokens.begin(); it != tokens.end(); ++it) { @@ -365,7 +366,7 @@ bool OSExchangeDataProviderAuraX11::HasURL( bool OSExchangeDataProviderAuraX11::HasFile() const { std::vector<::Atom> url_atoms = ui::GetURIListAtomsFrom(); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); if (requested_types.empty()) return false; @@ -391,9 +392,9 @@ bool OSExchangeDataProviderAuraX11::HasFile() const { bool OSExchangeDataProviderAuraX11::HasCustomFormat( const Clipboard::FormatType& format) const { std::vector< ::Atom> url_atoms; - url_atoms.push_back(GetAtom(format.ToString().c_str())); + url_atoms.push_back(gfx::GetAtom(format.ToString().c_str())); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); return !requested_types.empty(); } @@ -403,7 +404,7 @@ void OSExchangeDataProviderAuraX11::SetFileContents( const std::string& file_contents) { DCHECK(!filename.empty()); DCHECK(format_map_.end() == - format_map_.find(GetAtom(Clipboard::kMimeTypeMozillaURL))); + format_map_.find(gfx::GetAtom(Clipboard::kMimeTypeMozillaURL))); file_contents_name_ = filename; @@ -423,12 +424,12 @@ void OSExchangeDataProviderAuraX11::SetFileContents( // things simpler for Chrome, we always 'fail' and let the destination do // the work. std::string failure("F"); - format_map_.Insert(GetAtom("XdndDirectSave0"), + format_map_.Insert(gfx::GetAtom("XdndDirectSave0"), scoped_refptr( base::RefCountedString::TakeString(&failure))); std::string file_contents_copy = file_contents; format_map_.Insert( - GetAtom("application/octet-stream"), + gfx::GetAtom("application/octet-stream"), scoped_refptr( base::RefCountedString::TakeString(&file_contents_copy))); } @@ -444,15 +445,15 @@ void OSExchangeDataProviderAuraX11::SetHtml(const base::string16& html, scoped_refptr mem( base::RefCountedBytes::TakeVector(&bytes)); - format_map_.Insert(GetAtom(Clipboard::kMimeTypeHTML), mem); + format_map_.Insert(gfx::GetAtom(Clipboard::kMimeTypeHTML), mem); } bool OSExchangeDataProviderAuraX11::GetHtml(base::string16* html, GURL* base_url) const { std::vector< ::Atom> url_atoms; - url_atoms.push_back(GetAtom(Clipboard::kMimeTypeHTML)); + url_atoms.push_back(gfx::GetAtom(Clipboard::kMimeTypeHTML)); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); ui::SelectionData data(format_map_.GetFirstOf(requested_types)); if (data.IsValid()) { @@ -466,9 +467,9 @@ bool OSExchangeDataProviderAuraX11::GetHtml(base::string16* html, bool OSExchangeDataProviderAuraX11::HasHtml() const { std::vector< ::Atom> url_atoms; - url_atoms.push_back(GetAtom(Clipboard::kMimeTypeHTML)); + url_atoms.push_back(gfx::GetAtom(Clipboard::kMimeTypeHTML)); std::vector< ::Atom> requested_types; - ui::GetAtomIntersection(url_atoms, GetTargets(), &requested_types); + GetAtomIntersection(url_atoms, GetTargets(), &requested_types); return !requested_types.empty(); } diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc index c96661c482fb77..8714f03f65c82a 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc +++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc @@ -13,8 +13,8 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/dragdrop/file_info.h" -#include "ui/base/x/x11_util.h" #include "ui/events/platform/x11/x11_event_source_glib.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "url/gurl.h" const char kFileURL[] = "file:///home/user/file.txt"; @@ -33,7 +33,8 @@ class OSExchangeDataProviderAuraX11Test : public testing::Test { scoped_refptr mem( base::RefCountedString::TakeString(&contents_copy)); - provider.format_map_.Insert(GetAtom(ui::Clipboard::kMimeTypeURIList), mem); + provider.format_map_.Insert(gfx::GetAtom(ui::Clipboard::kMimeTypeURIList), + mem); } protected: diff --git a/ui/base/idle/screensaver_window_finder_x11.cc b/ui/base/idle/screensaver_window_finder_x11.cc index 74228ba41a4442..e01cd247d39250 100644 --- a/ui/base/idle/screensaver_window_finder_x11.cc +++ b/ui/base/idle/screensaver_window_finder_x11.cc @@ -7,6 +7,7 @@ #include #include "ui/base/x/x11_util.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_error_tracker.h" namespace ui { @@ -32,7 +33,7 @@ bool ScreensaverWindowFinder::ScreensaverWindowExists() { // info.state == ScreenSaverOff or info.state == ScreenSaverDisabled does not // necessarily mean that a screensaver is not active, so add a special check // for xscreensaver. - static XAtom lock_atom = GetAtom("LOCK"); + XAtom lock_atom = gfx::GetAtom("LOCK"); std::vector atom_properties; if (GetIntArrayProperty(root, "_SCREENSAVER_STATUS", &atom_properties) && atom_properties.size() > 0) { diff --git a/ui/base/x/selection_owner.cc b/ui/base/x/selection_owner.cc index fa8c32179e2d41..76e6d9febc54d7 100644 --- a/ui/base/x/selection_owner.cc +++ b/ui/base/x/selection_owner.cc @@ -11,9 +11,9 @@ #include "base/logging.h" #include "base/memory/ptr_util.h" #include "ui/base/x/selection_utils.h" -#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_window_event_manager.h" #include "ui/events/platform/x11/x11_event_source.h" +#include "ui/gfx/x/x11_atom_cache.h" namespace ui { @@ -144,7 +144,7 @@ void SelectionOwner::OnSelectionRequest(const XEvent& event) { reply.xselection.property = None; // Indicates failure reply.xselection.time = event.xselectionrequest.time; - if (requested_target == GetAtom(kMultiple)) { + if (requested_target == gfx::GetAtom(kMultiple)) { // The contents of |requested_property| should be a list of // pairs. std::vector > conversions; @@ -164,8 +164,8 @@ void SelectionOwner::OnSelectionRequest(const XEvent& event) { // Set the property to indicate which conversions succeeded. This matches // what GTK does. XChangeProperty( - x_display_, requestor, requested_property, GetAtom(kAtomPair), 32, - PropModeReplace, + x_display_, requestor, requested_property, gfx::GetAtom(kAtomPair), + 32, PropModeReplace, reinterpret_cast(&conversion_results.front()), conversion_results.size()); @@ -206,10 +206,10 @@ void SelectionOwner::OnPropertyEvent(const XEvent& event) { bool SelectionOwner::ProcessTarget(XAtom target, XID requestor, XAtom property) { - XAtom multiple_atom = GetAtom(kMultiple); - XAtom save_targets_atom = GetAtom(kSaveTargets); - XAtom targets_atom = GetAtom(kTargets); - XAtom timestamp_atom = GetAtom(kTimestamp); + XAtom multiple_atom = gfx::GetAtom(kMultiple); + XAtom save_targets_atom = gfx::GetAtom(kSaveTargets); + XAtom targets_atom = gfx::GetAtom(kTargets); + XAtom timestamp_atom = gfx::GetAtom(kTimestamp); if (target == multiple_atom || target == save_targets_atom) return false; @@ -246,7 +246,7 @@ bool SelectionOwner::ProcessTarget(XAtom target, // the size of X requests. Notify the selection requestor that the data // will be sent incrementally by returning data of type "INCR". long length = it->second->size(); - XChangeProperty(x_display_, requestor, property, GetAtom(kIncr), 32, + XChangeProperty(x_display_, requestor, property, gfx::GetAtom(kIncr), 32, PropModeReplace, reinterpret_cast(&length), 1); diff --git a/ui/base/x/selection_requestor.cc b/ui/base/x/selection_requestor.cc index a6e402c3f9bb01..c4b8a7ec599e03 100644 --- a/ui/base/x/selection_requestor.cc +++ b/ui/base/x/selection_requestor.cc @@ -13,6 +13,7 @@ #include "ui/base/x/x11_util.h" #include "ui/events/platform/platform_event_dispatcher.h" #include "ui/events/platform/platform_event_source.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_types.h" namespace ui { @@ -62,7 +63,7 @@ SelectionRequestor::SelectionRequestor(XDisplay* x_display, x_property_(None), dispatcher_(dispatcher), current_request_index_(0u) { - x_property_ = GetAtom(kChromeSelection); + x_property_ = gfx::GetAtom(kChromeSelection); } SelectionRequestor::~SelectionRequestor() {} @@ -162,7 +163,7 @@ void SelectionRequestor::OnSelectionNotify(const XEvent& event) { if (event_property != None) XDeleteProperty(x_display_, x_window_, event_property); - if (request->out_type == GetAtom(kIncr)) { + if (request->out_type == gfx::GetAtom(kIncr)) { request->data_sent_incrementally = true; request->out_data.clear(); request->out_data_items = 0u; diff --git a/ui/base/x/selection_requestor_unittest.cc b/ui/base/x/selection_requestor_unittest.cc index 5a944124476547..d1b14674e3737e 100644 --- a/ui/base/x/selection_requestor_unittest.cc +++ b/ui/base/x/selection_requestor_unittest.cc @@ -15,6 +15,7 @@ #include "ui/base/x/selection_utils.h" #include "ui/base/x/x11_util.h" #include "ui/events/platform/platform_event_source.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_types.h" #include @@ -34,8 +35,8 @@ class SelectionRequestorTest : public testing::Test { void SendSelectionNotify(XAtom selection, XAtom target, const std::string& value) { - ui::SetStringProperty(x_window_, requestor_->x_property_, GetAtom("STRING"), - value); + ui::SetStringProperty(x_window_, requestor_->x_property_, + gfx::GetAtom("STRING"), value); XEvent xev; xev.type = SelectionNotify; @@ -106,7 +107,7 @@ void PerformBlockingConvertSelection(SelectionRequestor* requestor, selection, target, &out_data, &out_data_items, &out_type)); EXPECT_EQ(expected_data, ui::RefCountedMemoryToString(out_data)); EXPECT_EQ(expected_data.size(), out_data_items); - EXPECT_EQ(GetAtom("STRING"), out_type); + EXPECT_EQ(gfx::GetAtom("STRING"), out_type); } } // namespace @@ -117,10 +118,10 @@ TEST_F(SelectionRequestorTest, NestedRequests) { // Assume that |selection| will have no owner. If there is an owner, the owner // will set the property passed into the XConvertSelection() request which is // undesirable. - XAtom selection = GetAtom("FAKE_SELECTION"); + XAtom selection = gfx::GetAtom("FAKE_SELECTION"); - XAtom target1 = GetAtom("TARGET1"); - XAtom target2 = GetAtom("TARGET2"); + XAtom target1 = gfx::GetAtom("TARGET1"); + XAtom target2 = gfx::GetAtom("TARGET2"); base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); loop->task_runner()->PostTask( diff --git a/ui/base/x/selection_utils.cc b/ui/base/x/selection_utils.cc index 48eff625420766..3ab3c842497045 100644 --- a/ui/base/x/selection_utils.cc +++ b/ui/base/x/selection_utils.cc @@ -15,7 +15,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "ui/base/clipboard/clipboard.h" -#include "ui/base/x/x11_util.h" +#include "ui/gfx/x/x11_atom_cache.h" namespace ui { @@ -27,24 +27,24 @@ const char kUtf8String[] = "UTF8_STRING"; std::vector<::Atom> GetTextAtomsFrom() { std::vector< ::Atom> atoms; - atoms.push_back(GetAtom(kUtf8String)); - atoms.push_back(GetAtom(kString)); - atoms.push_back(GetAtom(kText)); - atoms.push_back(GetAtom(kTextPlain)); - atoms.push_back(GetAtom(kTextPlainUtf8)); + atoms.push_back(gfx::GetAtom(kUtf8String)); + atoms.push_back(gfx::GetAtom(kString)); + atoms.push_back(gfx::GetAtom(kText)); + atoms.push_back(gfx::GetAtom(kTextPlain)); + atoms.push_back(gfx::GetAtom(kTextPlainUtf8)); return atoms; } std::vector<::Atom> GetURLAtomsFrom() { std::vector< ::Atom> atoms; - atoms.push_back(GetAtom(Clipboard::kMimeTypeURIList)); - atoms.push_back(GetAtom(Clipboard::kMimeTypeMozillaURL)); + atoms.push_back(gfx::GetAtom(Clipboard::kMimeTypeURIList)); + atoms.push_back(gfx::GetAtom(Clipboard::kMimeTypeMozillaURL)); return atoms; } std::vector<::Atom> GetURIListAtomsFrom() { std::vector< ::Atom> atoms; - atoms.push_back(GetAtom(Clipboard::kMimeTypeURIList)); + atoms.push_back(gfx::GetAtom(Clipboard::kMimeTypeURIList)); return atoms; } @@ -181,10 +181,11 @@ size_t SelectionData::GetSize() const { } std::string SelectionData::GetText() const { - if (type_ == GetAtom(kUtf8String) || type_ == GetAtom(kText) || - type_ == GetAtom(kTextPlainUtf8)) { + if (type_ == gfx::GetAtom(kUtf8String) || type_ == gfx::GetAtom(kText) || + type_ == gfx::GetAtom(kTextPlainUtf8)) { return RefCountedMemoryToString(memory_); - } else if (type_ == GetAtom(kString) || type_ == GetAtom(kTextPlain)) { + } else if (type_ == gfx::GetAtom(kString) || + type_ == gfx::GetAtom(kTextPlain)) { std::string result; base::ConvertToUtf8AndNormalize(RefCountedMemoryToString(memory_), base::kCodepageLatin1, @@ -201,7 +202,7 @@ std::string SelectionData::GetText() const { base::string16 SelectionData::GetHtml() const { base::string16 markup; - if (type_ == GetAtom(Clipboard::kMimeTypeHTML)) { + if (type_ == gfx::GetAtom(Clipboard::kMimeTypeHTML)) { const unsigned char* data = GetData(); size_t size = GetSize(); diff --git a/ui/base/x/x11_menu_list.cc b/ui/base/x/x11_menu_list.cc index a7c2fda8117ef6..876865b41d2d0f 100644 --- a/ui/base/x/x11_menu_list.cc +++ b/ui/base/x/x11_menu_list.cc @@ -8,6 +8,7 @@ #include "base/memory/singleton.h" #include "ui/base/x/x11_util.h" +#include "ui/gfx/x/x11_atom_cache.h" namespace ui { @@ -17,8 +18,7 @@ XMenuList* XMenuList::GetInstance() { } XMenuList::XMenuList() - : menu_type_atom_(GetAtom("_NET_WM_WINDOW_TYPE_MENU")) { -} + : menu_type_atom_(gfx::GetAtom("_NET_WM_WINDOW_TYPE_MENU")) {} XMenuList::~XMenuList() { menus_.clear(); diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index bf3231c2e8d337..c2ff09a052e90f 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -94,7 +94,7 @@ int DefaultX11IOErrorHandler(XDisplay* d) { bool GetProperty(XID window, const std::string& property_name, long max_length, XAtom* type, int* format, unsigned long* num_items, unsigned char** property) { - XAtom property_atom = GetAtom(property_name.c_str()); + XAtom property_atom = gfx::GetAtom(property_name.c_str()); unsigned long remaining_bytes = 0; return XGetWindowProperty(gfx::GetXDisplay(), window, @@ -442,7 +442,7 @@ void SetUseOSWindowFrame(XID window, bool use_os_window_frame) { motif_hints.flags = (1L << 1); motif_hints.decorations = use_os_window_frame ? 1 : 0; - XAtom hint_atom = GetAtom("_MOTIF_WM_HINTS"); + XAtom hint_atom = gfx::GetAtom("_MOTIF_WM_HINTS"); XChangeProperty(gfx::GetXDisplay(), window, hint_atom, @@ -472,14 +472,11 @@ void SetHideTitlebarWhenMaximizedProperty(XID window, HideTitlebarWhenMaximized property) { // XChangeProperty() expects "hide" to be long. unsigned long hide = property; - XChangeProperty(gfx::GetXDisplay(), - window, - GetAtom("_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"), - XA_CARDINAL, - 32, // size in bits - PropModeReplace, - reinterpret_cast(&hide), - 1); + XChangeProperty(gfx::GetXDisplay(), window, + gfx::GetAtom("_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED"), + XA_CARDINAL, + 32, // size in bits + PropModeReplace, reinterpret_cast(&hide), 1); } void ClearX11DefaultRootWindow() { @@ -514,7 +511,7 @@ bool IsWindowVisible(XID window) { // Minimized windows are not visible. std::vector wm_states; if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) { - XAtom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN"); + XAtom hidden_atom = gfx::GetAtom("_NET_WM_STATE_HIDDEN"); if (base::ContainsValue(wm_states, hidden_atom)) return false; } @@ -825,8 +822,8 @@ bool SetIntArrayProperty(XID window, const std::string& type, const std::vector& value) { DCHECK(!value.empty()); - XAtom name_atom = GetAtom(name.c_str()); - XAtom type_atom = GetAtom(type.c_str()); + XAtom name_atom = gfx::GetAtom(name.c_str()); + XAtom type_atom = gfx::GetAtom(type.c_str()); // XChangeProperty() expects values of type 32 to be longs. std::unique_ptr data(new long[value.size()]); @@ -858,8 +855,8 @@ bool SetAtomArrayProperty(XID window, const std::string& type, const std::vector& value) { DCHECK(!value.empty()); - XAtom name_atom = GetAtom(name.c_str()); - XAtom type_atom = GetAtom(type.c_str()); + XAtom name_atom = gfx::GetAtom(name.c_str()); + XAtom type_atom = gfx::GetAtom(type.c_str()); // XChangeProperty() expects values of type 32 to be longs. std::unique_ptr data(new XAtom[value.size()]); @@ -894,10 +891,6 @@ bool SetStringProperty(XID window, return !err_tracker.FoundNewError(); } -XAtom GetAtom(const char* name) { - return X11AtomCache::GetInstance()->GetAtom(name); -} - void SetWindowClassHint(XDisplay* display, XID window, const std::string& res_name, @@ -913,13 +906,12 @@ void SetWindowClassHint(XDisplay* display, void SetWindowRole(XDisplay* display, XID window, const std::string& role) { if (role.empty()) { - XDeleteProperty(display, window, GetAtom("WM_WINDOW_ROLE")); + XDeleteProperty(display, window, gfx::GetAtom("WM_WINDOW_ROLE")); } else { char* role_c = const_cast(role.c_str()); - XChangeProperty(display, window, GetAtom("WM_WINDOW_ROLE"), XA_STRING, 8, - PropModeReplace, - reinterpret_cast(role_c), - role.size()); + XChangeProperty(display, window, gfx::GetAtom("WM_WINDOW_ROLE"), XA_STRING, + 8, PropModeReplace, + reinterpret_cast(role_c), role.size()); } } @@ -1185,7 +1177,8 @@ std::string GuessWindowManagerName() { bool IsCompositingManagerPresent() { static bool is_compositing_manager_present = - XGetSelectionOwner(gfx::GetXDisplay(), GetAtom("_NET_WM_CM_S0")) != None; + XGetSelectionOwner(gfx::GetXDisplay(), gfx::GetAtom("_NET_WM_CM_S0")) != + None; return is_compositing_manager_present; } @@ -1197,7 +1190,7 @@ bool IsX11WindowFullScreen(XID window) { // If _NET_WM_STATE_FULLSCREEN is in _NET_SUPPORTED, use the presence or // absence of _NET_WM_STATE_FULLSCREEN in _NET_WM_STATE to determine // whether we're fullscreen. - XAtom fullscreen_atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); + XAtom fullscreen_atom = gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"); if (WmSupportsHint(fullscreen_atom)) { std::vector atom_properties; if (GetAtomArrayProperty(window, @@ -1391,7 +1384,7 @@ XVisualManager::XVisualManager() for (int i = 0; i < visuals_len; ++i) visuals_[visual_list[i].visualid].reset(new XVisualData(visual_list[i])); - XAtom NET_WM_CM_S0 = GetAtom("_NET_WM_CM_S0"); + XAtom NET_WM_CM_S0 = gfx::GetAtom("_NET_WM_CM_S0"); using_compositing_wm_ = XGetSelectionOwner(display_, NET_WM_CM_S0) != None; // Choose the opaque visual. diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index 3dfdcb1b849dcf..c47ce2844d3883 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -177,9 +177,6 @@ UI_BASE_X_EXPORT bool SetStringProperty(XID window, XAtom type, const std::string& value); -// Gets the X atom for default display corresponding to atom_name. -UI_BASE_X_EXPORT XAtom GetAtom(const char* atom_name); - // Sets the WM_CLASS attribute for a given X11 window. UI_BASE_X_EXPORT void SetWindowClassHint(XDisplay* display, XID window, diff --git a/ui/display/manager/chromeos/x11/native_display_delegate_x11.cc b/ui/display/manager/chromeos/x11/native_display_delegate_x11.cc index d94e618ae00a2e..df9af546fa4444 100644 --- a/ui/display/manager/chromeos/x11/native_display_delegate_x11.cc +++ b/ui/display/manager/chromeos/x11/native_display_delegate_x11.cc @@ -16,7 +16,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ptr_util.h" -#include "ui/base/x/x11_util.h" #include "ui/display/manager/chromeos/x11/display_mode_x11.h" #include "ui/display/manager/chromeos/x11/display_snapshot_x11.h" #include "ui/display/manager/chromeos/x11/display_util_x11.h" @@ -25,6 +24,7 @@ #include "ui/display/util/x11/edid_parser_x11.h" #include "ui/events/platform/platform_event_source.h" #include "ui/gfx/geometry/rect.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_error_tracker.h" #include "ui/gfx/x/x11_types.h" @@ -403,7 +403,7 @@ bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output, Atom actual_type = None; int success = 0; RROutput output_id = static_cast(output).output(); - Atom prop = ui::GetAtom(kContentProtectionAtomName); + Atom prop = gfx::GetAtom(kContentProtectionAtomName); // TODO(kcwu): Move this to x11_util (similar method calls in this file and // output_util.cc) @@ -430,11 +430,11 @@ bool NativeDisplayDelegateX11::GetHDCPState(const DisplaySnapshot& output, if (success == Success && actual_type == XA_ATOM && actual_format == 32 && nitems == 1) { Atom value = reinterpret_cast(values)[0]; - if (value == ui::GetAtom(kProtectionUndesiredAtomName)) { + if (value == gfx::GetAtom(kProtectionUndesiredAtomName)) { *state = HDCP_STATE_UNDESIRED; - } else if (value == ui::GetAtom(kProtectionDesiredAtomName)) { + } else if (value == gfx::GetAtom(kProtectionDesiredAtomName)) { *state = HDCP_STATE_DESIRED; - } else if (value == ui::GetAtom(kProtectionEnabledAtomName)) { + } else if (value == gfx::GetAtom(kProtectionEnabledAtomName)) { *state = HDCP_STATE_ENABLED; } else { LOG(ERROR) << "Unknown " << kContentProtectionAtomName @@ -459,14 +459,14 @@ void NativeDisplayDelegateX11::SetHDCPState( bool NativeDisplayDelegateX11::SetHDCPState(const DisplaySnapshot& output, HDCPState state) { - Atom name = ui::GetAtom(kContentProtectionAtomName); + Atom name = gfx::GetAtom(kContentProtectionAtomName); Atom value = None; switch (state) { case HDCP_STATE_UNDESIRED: - value = ui::GetAtom(kProtectionUndesiredAtomName); + value = gfx::GetAtom(kProtectionUndesiredAtomName); break; case HDCP_STATE_DESIRED: - value = ui::GetAtom(kProtectionDesiredAtomName); + value = gfx::GetAtom(kProtectionDesiredAtomName); break; default: NOTREACHED() << "Invalid HDCP state: " << state; @@ -543,8 +543,8 @@ void NativeDisplayDelegateX11::UpdateCrtcsForNewFramebuffer( } bool NativeDisplayDelegateX11::IsOutputAspectPreservingScaling(RROutput id) { - Atom scaling_prop = ui::GetAtom("scaling mode"); - Atom full_aspect_atom = ui::GetAtom("Full aspect"); + Atom scaling_prop = gfx::GetAtom("scaling mode"); + Atom full_aspect_atom = gfx::GetAtom("Full aspect"); if (scaling_prop == None || full_aspect_atom == None) return false; diff --git a/ui/display/util/x11/edid_parser_x11.cc b/ui/display/util/x11/edid_parser_x11.cc index a39470869595ec..4c5f68298aee2f 100644 --- a/ui/display/util/x11/edid_parser_x11.cc +++ b/ui/display/util/x11/edid_parser_x11.cc @@ -34,8 +34,7 @@ bool GetEDIDProperty(XID output, std::vector* edid) { Display* display = gfx::GetXDisplay(); - static Atom edid_property = - ui::X11AtomCache::GetInstance()->GetAtom(RR_PROPERTY_RANDR_EDID); + Atom edid_property = gfx::GetAtom(RR_PROPERTY_RANDR_EDID); bool has_edid_property = false; int num_properties = 0; diff --git a/ui/events/devices/x11/device_data_manager_x11.cc b/ui/events/devices/x11/device_data_manager_x11.cc index abc70fce85448f..f2182752b365c9 100644 --- a/ui/events/devices/x11/device_data_manager_x11.cc +++ b/ui/events/devices/x11/device_data_manager_x11.cc @@ -243,7 +243,7 @@ void DeviceDataManagerX11::UpdateDeviceList(Display* display) { // Find all the touchpad devices. const XDeviceList& dev_list = ui::DeviceListCacheX11::GetInstance()->GetXDeviceList(display); - Atom xi_touchpad = ui::X11AtomCache::GetInstance()->GetAtom(XI_TOUCHPAD); + Atom xi_touchpad = gfx::GetAtom(XI_TOUCHPAD); for (int i = 0; i < dev_list.count; ++i) if (dev_list[i].type == xi_touchpad) touchpads_[dev_list[i].id] = true; @@ -256,8 +256,7 @@ void DeviceDataManagerX11::UpdateDeviceList(Display* display) { ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(display); Atom atoms[DT_LAST_ENTRY]; for (int data_type = 0; data_type < DT_LAST_ENTRY; ++data_type) - atoms[data_type] = - ui::X11AtomCache::GetInstance()->GetAtom(kCachedAtoms[data_type]); + atoms[data_type] = gfx::GetAtom(kCachedAtoms[data_type]); for (int i = 0; i < info_list.count; ++i) { const XIDeviceInfo& info = info_list[i]; diff --git a/ui/events/platform/x11/x11_event_source.cc b/ui/events/platform/x11/x11_event_source.cc index 6f2d835624c88c..b27acd877ee1e7 100644 --- a/ui/events/platform/x11/x11_event_source.cc +++ b/ui/events/platform/x11/x11_event_source.cc @@ -157,7 +157,7 @@ Time X11EventSource::GetCurrentServerTime() { // Create a new Window and Atom that will be used for the property change. dummy_window_ = XCreateSimpleWindow(display_, DefaultRootWindow(display_), 0, 0, 1, 1, 0, 0, 0); - dummy_atom_ = X11AtomCache::GetInstance()->GetAtom("CHROMIUM_TIMESTAMP"); + dummy_atom_ = gfx::GetAtom("CHROMIUM_TIMESTAMP"); dummy_window_events_.reset( new XScopedEventSelector(dummy_window_, PropertyChangeMask)); dummy_initialized_ = true; diff --git a/ui/events/platform/x11/x11_hotplug_event_handler.cc b/ui/events/platform/x11/x11_hotplug_event_handler.cc index f6f6b159b36674..0cb2568488a014 100644 --- a/ui/events/platform/x11/x11_hotplug_event_handler.cc +++ b/ui/events/platform/x11/x11_hotplug_event_handler.cc @@ -25,7 +25,6 @@ #include "base/sys_info.h" #include "base/threading/thread_task_runner_handle.h" #include "base/threading/worker_pool.h" -#include "ui/base/x/x11_util.h" #include "ui/events/devices/device_data_manager.h" #include "ui/events/devices/device_hotplug_event_observer.h" #include "ui/events/devices/device_util_linux.h" @@ -197,7 +196,7 @@ base::FilePath GetDevicePath(XDisplay* dpy, const XIDeviceInfo& device) { // Input device has a property "Device Node" pointing to its dev input node, // e.g. Device Node (250): "/dev/input/event8" - Atom device_node = ui::X11AtomCache::GetInstance()->GetAtom("Device Node"); + Atom device_node = gfx::GetAtom("Device Node"); if (device_node == None) return base::FilePath(); @@ -423,13 +422,13 @@ void X11HotplugEventHandler::OnHotplugEvent() { continue; Atom type = device_list_xi[i].type; - if (type == GetAtom(XI_KEYBOARD)) + if (type == gfx::GetAtom(XI_KEYBOARD)) device_types[id] = DEVICE_TYPE_KEYBOARD; - else if (type == GetAtom(XI_MOUSE)) + else if (type == gfx::GetAtom(XI_MOUSE)) device_types[id] = DEVICE_TYPE_MOUSE; - else if (type == GetAtom(XI_TOUCHPAD)) + else if (type == gfx::GetAtom(XI_TOUCHPAD)) device_types[id] = DEVICE_TYPE_TOUCHPAD; - else if (type == GetAtom(XI_TOUCHSCREEN)) + else if (type == gfx::GetAtom(XI_TOUCHSCREEN)) device_types[id] = DEVICE_TYPE_TOUCHSCREEN; } @@ -454,8 +453,9 @@ void X11HotplugEventHandler::OnHotplugEvent() { uint16_t vendor = 0; uint16_t product = 0; if (XIGetProperty(gfx::GetXDisplay(), device.deviceid, - GetAtom(XI_PROP_PRODUCT_ID), 0, 2, 0, XA_INTEGER, &type, - &format_return, &num_items_return, &bytes_after_return, + gfx::GetAtom(XI_PROP_PRODUCT_ID), 0, 2, 0, XA_INTEGER, + &type, &format_return, &num_items_return, + &bytes_after_return, reinterpret_cast(&product_info)) == 0 && product_info) { if (num_items_return == 2) { @@ -471,8 +471,8 @@ void X11HotplugEventHandler::OnHotplugEvent() { // X11 is not thread safe, so first get all the required state. DisplayState display_state; - display_state.mt_position_x = GetAtom("Abs MT Position X"); - display_state.mt_position_y = GetAtom("Abs MT Position Y"); + display_state.mt_position_x = gfx::GetAtom("Abs MT Position X"); + display_state.mt_position_y = gfx::GetAtom("Abs MT Position Y"); UiCallbacks callbacks; callbacks.keyboard_callback = base::Bind(&OnKeyboardDevices); diff --git a/ui/gfx/icc_profile_x11.cc b/ui/gfx/icc_profile_x11.cc index b2d7ca14eda65f..819c8a6d096b9f 100644 --- a/ui/gfx/icc_profile_x11.cc +++ b/ui/gfx/icc_profile_x11.cc @@ -25,7 +25,7 @@ ICCProfile ICCProfile::FromBestMonitor() { ICCProfile icc_profile; if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) return icc_profile; - Atom property = ui::X11AtomCache::GetInstance()->GetAtom("_ICC_PROFILE"); + Atom property = GetAtom("_ICC_PROFILE"); if (property != None) { Atom prop_type = None; int prop_format = 0; diff --git a/ui/gfx/x/x11_atom_cache.cc b/ui/gfx/x/x11_atom_cache.cc index a5ce80923eb183..893d6ad8bbf38c 100644 --- a/ui/gfx/x/x11_atom_cache.cc +++ b/ui/gfx/x/x11_atom_cache.cc @@ -156,7 +156,11 @@ const char* kAtomsToCache[] = {"Abs Dbl End Timestamp", } // namespace -namespace ui { +namespace gfx { + +XAtom GetAtom(const char* name) { + return X11AtomCache::GetInstance()->GetAtom(name); +} X11AtomCache* X11AtomCache::GetInstance() { return base::Singleton::get(); @@ -191,4 +195,4 @@ XAtom X11AtomCache::GetAtom(const char* name) const { return it->second; } -} // namespace ui +} // namespace gfx diff --git a/ui/gfx/x/x11_atom_cache.h b/ui/gfx/x/x11_atom_cache.h index 91e68786fb0136..19bebbe0c5b96e 100644 --- a/ui/gfx/x/x11_atom_cache.h +++ b/ui/gfx/x/x11_atom_cache.h @@ -17,7 +17,10 @@ template struct DefaultSingletonTraits; } -namespace ui { +namespace gfx { + +// Gets the X atom for default display corresponding to atom_name. +GFX_EXPORT XAtom GetAtom(const char* atom_name); // Pre-caches all Atoms on first use to minimize roundtrips to the X11 // server. By default, GetAtom() will CHECK() that atoms accessed through @@ -27,15 +30,16 @@ class GFX_EXPORT X11AtomCache { public: static X11AtomCache* GetInstance(); - // Returns the pre-interned Atom without having to go to the x server. - XAtom GetAtom(const char*) const; - private: + friend XAtom GetAtom(const char* atom_name); friend struct base::DefaultSingletonTraits; X11AtomCache(); ~X11AtomCache(); + // Returns the pre-interned Atom without having to go to the x server. + XAtom GetAtom(const char*) const; + XDisplay* xdisplay_; mutable std::map cached_atoms_; @@ -43,6 +47,6 @@ class GFX_EXPORT X11AtomCache { DISALLOW_COPY_AND_ASSIGN(X11AtomCache); }; -} // namespace ui +} // namespace gfx #endif // UI_GFX_X_X11_ATOM_CACHE_H_ diff --git a/ui/platform_window/x11/x11_window_base.cc b/ui/platform_window/x11/x11_window_base.cc index 61d555db80d4a0..4e8de812ae6b57 100644 --- a/ui/platform_window/x11/x11_window_base.cc +++ b/ui/platform_window/x11/x11_window_base.cc @@ -13,7 +13,6 @@ #include "base/strings/utf_string_conversions.h" #include "ui/base/platform_window_defaults.h" -#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_window_event_manager.h" #include "ui/events/devices/x11/touch_factory_x11.h" #include "ui/events/event.h" @@ -22,6 +21,7 @@ #include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/x11/x11_event_source.h" #include "ui/gfx/geometry/rect.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/platform_window/platform_window_delegate.h" namespace ui { @@ -113,8 +113,8 @@ void X11WindowBase::Create() { XFlush(xdisplay_); ::Atom protocols[2]; - protocols[0] = GetAtom("WM_DELETE_WINDOW"); - protocols[1] = GetAtom("_NET_WM_PING"); + protocols[0] = gfx::GetAtom("WM_DELETE_WINDOW"); + protocols[1] = gfx::GetAtom("_NET_WM_PING"); XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with @@ -127,8 +127,9 @@ void X11WindowBase::Create() { static_assert(sizeof(long) >= sizeof(pid_t), "pid_t should not be larger than long"); long pid = getpid(); - XChangeProperty(xdisplay_, xwindow_, GetAtom("_NET_WM_PID"), XA_CARDINAL, 32, - PropModeReplace, reinterpret_cast(&pid), 1); + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_PID"), XA_CARDINAL, + 32, PropModeReplace, reinterpret_cast(&pid), + 1); // Before we map the window, set size hints. Otherwise, some window managers // will ignore toplevel XMoveWindow commands. XSizeHints size_hints; @@ -214,8 +215,8 @@ void X11WindowBase::SetTitle(const base::string16& title) { return; window_title_ = title; std::string utf8str = base::UTF16ToUTF8(title); - XChangeProperty(xdisplay_, xwindow_, GetAtom("_NET_WM_NAME"), - GetAtom("UTF8_STRING"), 8, PropModeReplace, + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_NAME"), + gfx::GetAtom("UTF8_STRING"), 8, PropModeReplace, reinterpret_cast(utf8str.c_str()), utf8str.size()); XTextProperty xtp; @@ -293,9 +294,9 @@ void X11WindowBase::ProcessXWindowEvent(XEvent* xev) { case ClientMessage: { Atom message = static_cast(xev->xclient.data.l[0]); - if (message == GetAtom("WM_DELETE_WINDOW")) { + if (message == gfx::GetAtom("WM_DELETE_WINDOW")) { delegate_->OnCloseRequest(); - } else if (message == GetAtom("_NET_WM_PING")) { + } else if (message == gfx::GetAtom("_NET_WM_PING")) { XEvent reply_event = *xev; reply_event.xclient.window = xroot_window_; diff --git a/ui/views/test/ui_controls_factory_desktop_aurax11.cc b/ui/views/test/ui_controls_factory_desktop_aurax11.cc index c43e67b57f6cfe..534e0c4cb41d6a 100644 --- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc +++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc @@ -24,6 +24,7 @@ #include "ui/compositor/dip_util.h" #include "ui/events/keycodes/keyboard_code_conversion_x.h" #include "ui/events/test/platform_event_waiter.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_connection.h" #include "ui/views/test/test_desktop_screen_x11.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" @@ -45,7 +46,7 @@ unsigned button_down_mask = 0; // Returns atom that indidates that the XEvent is marker event. Atom MarkerEventAtom() { - return ui::GetAtom("marker_event"); + return gfx::GetAtom("marker_event"); } // Returns true when the event is a marker event. diff --git a/ui/views/test/x11_property_change_waiter.cc b/ui/views/test/x11_property_change_waiter.cc index b9937b3a117d0d..d267b823397fc8 100644 --- a/ui/views/test/x11_property_change_waiter.cc +++ b/ui/views/test/x11_property_change_waiter.cc @@ -7,10 +7,10 @@ #include #include "base/run_loop.h" -#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_window_event_manager.h" #include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/scoped_event_dispatcher.h" +#include "ui/gfx/x/x11_atom_cache.h" namespace views { @@ -58,7 +58,7 @@ uint32_t X11PropertyChangeWaiter::DispatchEvent( const ui::PlatformEvent& event) { if (!wait_ || event->type != PropertyNotify || event->xproperty.window != x_window_ || - event->xproperty.atom != ui::GetAtom(property_) || + event->xproperty.atom != gfx::GetAtom(property_) || ShouldKeepOnWaiting(event)) { return ui::POST_DISPATCH_PERFORM_DEFAULT; } diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc index 175ae236bad7fd..d53d9c72cc6bb3 100644 --- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc +++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc @@ -26,13 +26,13 @@ #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" #include "ui/base/layout.h" #include "ui/base/x/selection_utils.h" -#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_window_event_manager.h" #include "ui/display/screen.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" #include "ui/events/platform/platform_event_source.h" #include "ui/gfx/image/image_skia.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/views/controls/image_view.h" #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h" @@ -312,8 +312,7 @@ DesktopDragDropClientAuraX11::X11DragContext::X11DragContext( bool get_types_from_property = ((event.data.l[1] & 1) != 0); if (get_types_from_property) { - if (!ui::GetAtomArrayProperty(source_window_, - kXdndTypeList, + if (!ui::GetAtomArrayProperty(source_window_, kXdndTypeList, &unfetched_targets_)) { return; } @@ -391,8 +390,8 @@ void DesktopDragDropClientAuraX11::X11DragContext::RequestNextTarget() { ::Atom target = unfetched_targets_.back(); unfetched_targets_.pop_back(); - XConvertSelection(gfx::GetXDisplay(), ui::GetAtom(kXdndSelection), target, - ui::GetAtom(kChromiumDragReciever), local_window_, + XConvertSelection(gfx::GetXDisplay(), gfx::GetAtom(kXdndSelection), target, + gfx::GetAtom(kChromiumDragReciever), local_window_, position_time_stamp_); } @@ -408,7 +407,7 @@ void DesktopDragDropClientAuraX11::X11DragContext::OnSelectionNotify( DVLOG(1) << "SelectionNotify, format " << event.target; if (event.property != None) { - DCHECK_EQ(event.property, ui::GetAtom(kChromiumDragReciever)); + DCHECK_EQ(event.property, gfx::GetAtom(kChromiumDragReciever)); scoped_refptr data; ::Atom type = None; @@ -436,8 +435,7 @@ void DesktopDragDropClientAuraX11::X11DragContext::OnSelectionNotify( void DesktopDragDropClientAuraX11::X11DragContext::ReadActions() { if (!source_client_) { std::vector<::Atom> atom_array; - if (!ui::GetAtomArrayProperty(source_window_, - kXdndActionList, + if (!ui::GetAtomArrayProperty(source_window_, kXdndActionList, &atom_array)) { actions_.clear(); } else { @@ -466,11 +464,11 @@ int DesktopDragDropClientAuraX11::X11DragContext::GetDragOperation() const { void DesktopDragDropClientAuraX11::X11DragContext::MaskOperation( ::Atom xdnd_operation, int* drag_operation) const { - if (xdnd_operation == ui::GetAtom(kXdndActionCopy)) + if (xdnd_operation == gfx::GetAtom(kXdndActionCopy)) *drag_operation |= ui::DragDropTypes::DRAG_COPY; - else if (xdnd_operation == ui::GetAtom(kXdndActionMove)) + else if (xdnd_operation == gfx::GetAtom(kXdndActionMove)) *drag_operation |= ui::DragDropTypes::DRAG_MOVE; - else if (xdnd_operation == ui::GetAtom(kXdndActionLink)) + else if (xdnd_operation == gfx::GetAtom(kXdndActionLink)) *drag_operation |= ui::DragDropTypes::DRAG_LINK; } @@ -482,7 +480,7 @@ bool DesktopDragDropClientAuraX11::X11DragContext::CanDispatchEvent( uint32_t DesktopDragDropClientAuraX11::X11DragContext::DispatchEvent( const ui::PlatformEvent& event) { if (event->type == PropertyNotify && - event->xproperty.atom == ui::GetAtom(kXdndActionList)) { + event->xproperty.atom == gfx::GetAtom(kXdndActionList)) { ReadActions(); return ui::POST_DISPATCH_STOP_PROPAGATION; } @@ -516,7 +514,7 @@ DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11( // Mark that we are aware of drag and drop concepts. unsigned long xdnd_version = kMaxXdndVersion; - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom(kXdndAware), XA_ATOM, 32, + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom(kXdndAware), XA_ATOM, 32, PropModeReplace, reinterpret_cast(&xdnd_version), 1); } @@ -726,7 +724,7 @@ void DesktopDragDropClientAuraX11::OnXdndDrop( XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = ui::GetAtom(kXdndFinished); + xev.xclient.message_type = gfx::GetAtom(kXdndFinished); xev.xclient.format = 32; xev.xclient.window = source_window; xev.xclient.data.l[0] = xwindow_; @@ -775,10 +773,10 @@ int DesktopDragDropClientAuraX11::StartDragAndDrop( std::vector<::Atom> actions = GetOfferedDragOperations(); if (!source_provider_->file_contents_name().empty()) { - actions.push_back(ui::GetAtom(kXdndActionDirectSave)); + actions.push_back(gfx::GetAtom(kXdndActionDirectSave)); ui::SetStringProperty( - xwindow_, ui::GetAtom(kXdndDirectSave0), - ui::GetAtom(ui::Clipboard::kMimeTypeText), + xwindow_, gfx::GetAtom(kXdndDirectSave0), + gfx::GetAtom(ui::Clipboard::kMimeTypeText), source_provider_->file_contents_name().AsUTF8Unsafe()); } ui::SetAtomArrayProperty(xwindow_, kXdndActionList, "ATOM", actions); @@ -820,8 +818,8 @@ int DesktopDragDropClientAuraX11::StartDragAndDrop( source_provider_ = NULL; g_current_drag_drop_client = NULL; drag_operation_ = 0; - XDeleteProperty(xdisplay_, xwindow_, ui::GetAtom(kXdndActionList)); - XDeleteProperty(xdisplay_, xwindow_, ui::GetAtom(kXdndDirectSave0)); + XDeleteProperty(xdisplay_, xwindow_, gfx::GetAtom(kXdndActionList)); + XDeleteProperty(xdisplay_, xwindow_, gfx::GetAtom(kXdndDirectSave0)); return negotiated_operation_; } @@ -962,22 +960,22 @@ void DesktopDragDropClientAuraX11::SendXClientEvent(::Window xid, DesktopDragDropClientAuraX11* short_circuit = GetForWindow(xid); if (short_circuit) { Atom message_type = xev->xclient.message_type; - if (message_type == ui::GetAtom(kXdndEnter)) { + if (message_type == gfx::GetAtom(kXdndEnter)) { short_circuit->OnXdndEnter(xev->xclient); return; - } else if (message_type == ui::GetAtom(kXdndLeave)) { + } else if (message_type == gfx::GetAtom(kXdndLeave)) { short_circuit->OnXdndLeave(xev->xclient); return; - } else if (message_type == ui::GetAtom(kXdndPosition)) { + } else if (message_type == gfx::GetAtom(kXdndPosition)) { short_circuit->OnXdndPosition(xev->xclient); return; - } else if (message_type == ui::GetAtom(kXdndStatus)) { + } else if (message_type == gfx::GetAtom(kXdndStatus)) { short_circuit->OnXdndStatus(xev->xclient); return; - } else if (message_type == ui::GetAtom(kXdndFinished)) { + } else if (message_type == gfx::GetAtom(kXdndFinished)) { short_circuit->OnXdndFinished(xev->xclient); return; - } else if (message_type == ui::GetAtom(kXdndDrop)) { + } else if (message_type == gfx::GetAtom(kXdndDrop)) { short_circuit->OnXdndDrop(xev->xclient); return; } @@ -1115,22 +1113,22 @@ void DesktopDragDropClientAuraX11::NotifyDragLeave() { ::Atom DesktopDragDropClientAuraX11::DragOperationToAtom( int drag_operation) { if (drag_operation & ui::DragDropTypes::DRAG_COPY) - return ui::GetAtom(kXdndActionCopy); + return gfx::GetAtom(kXdndActionCopy); if (drag_operation & ui::DragDropTypes::DRAG_MOVE) - return ui::GetAtom(kXdndActionMove); + return gfx::GetAtom(kXdndActionMove); if (drag_operation & ui::DragDropTypes::DRAG_LINK) - return ui::GetAtom(kXdndActionLink); + return gfx::GetAtom(kXdndActionLink); return None; } ui::DragDropTypes::DragOperation DesktopDragDropClientAuraX11::AtomToDragOperation(::Atom atom) { - if (atom == ui::GetAtom(kXdndActionCopy)) + if (atom == gfx::GetAtom(kXdndActionCopy)) return ui::DragDropTypes::DRAG_COPY; - if (atom == ui::GetAtom(kXdndActionMove)) + if (atom == gfx::GetAtom(kXdndActionMove)) return ui::DragDropTypes::DRAG_MOVE; - if (atom == ui::GetAtom(kXdndActionLink)) + if (atom == gfx::GetAtom(kXdndActionLink)) return ui::DragDropTypes::DRAG_LINK; return ui::DragDropTypes::DRAG_NONE; @@ -1139,11 +1137,11 @@ DesktopDragDropClientAuraX11::AtomToDragOperation(::Atom atom) { std::vector<::Atom> DesktopDragDropClientAuraX11::GetOfferedDragOperations() { std::vector<::Atom> operations; if (drag_operation_ & ui::DragDropTypes::DRAG_COPY) - operations.push_back(ui::GetAtom(kXdndActionCopy)); + operations.push_back(gfx::GetAtom(kXdndActionCopy)); if (drag_operation_ & ui::DragDropTypes::DRAG_MOVE) - operations.push_back(ui::GetAtom(kXdndActionMove)); + operations.push_back(gfx::GetAtom(kXdndActionMove)); if (drag_operation_ & ui::DragDropTypes::DRAG_LINK) - operations.push_back(ui::GetAtom(kXdndActionLink)); + operations.push_back(gfx::GetAtom(kXdndActionLink)); return operations; } @@ -1171,7 +1169,7 @@ void DesktopDragDropClientAuraX11::CompleteXdndPosition( // sets this nor respects it if set. XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = ui::GetAtom(kXdndStatus); + xev.xclient.message_type = gfx::GetAtom(kXdndStatus); xev.xclient.format = 32; xev.xclient.window = source_window; xev.xclient.data.l[0] = xwindow_; @@ -1187,7 +1185,7 @@ void DesktopDragDropClientAuraX11::CompleteXdndPosition( void DesktopDragDropClientAuraX11::SendXdndEnter(::Window dest_window) { XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = ui::GetAtom(kXdndEnter); + xev.xclient.message_type = gfx::GetAtom(kXdndEnter); xev.xclient.format = 32; xev.xclient.window = dest_window; xev.xclient.data.l[0] = xwindow_; @@ -1214,7 +1212,7 @@ void DesktopDragDropClientAuraX11::SendXdndEnter(::Window dest_window) { void DesktopDragDropClientAuraX11::SendXdndLeave(::Window dest_window) { XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = ui::GetAtom(kXdndLeave); + xev.xclient.message_type = gfx::GetAtom(kXdndLeave); xev.xclient.format = 32; xev.xclient.window = dest_window; xev.xclient.data.l[0] = xwindow_; @@ -1233,7 +1231,7 @@ void DesktopDragDropClientAuraX11::SendXdndPosition( XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = ui::GetAtom(kXdndPosition); + xev.xclient.message_type = gfx::GetAtom(kXdndPosition); xev.xclient.format = 32; xev.xclient.window = dest_window; xev.xclient.data.l[0] = xwindow_; @@ -1258,7 +1256,7 @@ void DesktopDragDropClientAuraX11::SendXdndPosition( void DesktopDragDropClientAuraX11::SendXdndDrop(::Window dest_window) { XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = ui::GetAtom(kXdndDrop); + xev.xclient.message_type = gfx::GetAtom(kXdndDrop); xev.xclient.format = 32; xev.xclient.window = dest_window; xev.xclient.data.l[0] = xwindow_; diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc index 862d806f43ff6c..b2ee3f926ab8c0 100644 --- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc @@ -24,6 +24,7 @@ #include "ui/base/dragdrop/os_exchange_data.h" #include "ui/base/x/x11_util.h" #include "ui/events/event_utils.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_types.h" #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" @@ -301,7 +302,7 @@ TestDragDropClient::~TestDragDropClient() { } Atom TestDragDropClient::GetAtom(const char* name) { - return ui::GetAtom(name); + return gfx::GetAtom(name); } bool TestDragDropClient::MessageHasType(const XClientMessageEvent& event, diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 17145e383fbf2d..d7b8a3352778e2 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -27,6 +27,7 @@ #include "ui/gfx/geometry/point_conversions.h" #include "ui/gfx/geometry/size_conversions.h" #include "ui/gfx/native_widget_types.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_types.h" #include "ui/views/linux_ui/linux_ui.h" #include "ui/views/widget/desktop_aura/desktop_screen.h" @@ -235,7 +236,7 @@ bool DesktopScreenX11::CanDispatchEvent(const ui::PlatformEvent& event) { event->type - xrandr_event_base_ == RRNotify || (event->type == PropertyNotify && event->xproperty.window == x_root_window_ && - event->xproperty.atom == ui::GetAtom("_NET_WORKAREA")); + event->xproperty.atom == gfx::GetAtom("_NET_WORKAREA")); } uint32_t DesktopScreenX11::DispatchEvent(const ui::PlatformEvent& event) { @@ -244,7 +245,7 @@ uint32_t DesktopScreenX11::DispatchEvent(const ui::PlatformEvent& event) { XRRUpdateConfiguration(event); } else if (event->type - xrandr_event_base_ == RRNotify || (event->type == PropertyNotify && - event->xproperty.atom == ui::GetAtom("_NET_WORKAREA"))) { + event->xproperty.atom == gfx::GetAtom("_NET_WORKAREA"))) { // There's some sort of observer dispatch going on here, but I don't think // it's the screen's? if (configure_timer_.get() && configure_timer_->IsRunning()) { diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc index 15d8bd4c3b4a89..25c923b7e759fb 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc @@ -15,10 +15,10 @@ #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/base/hit_test.h" -#include "ui/base/x/x11_util.h" #include "ui/display/display_observer.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/font_render_params.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_types.h" #include "ui/views/test/views_test_base.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" @@ -304,7 +304,7 @@ TEST_F(DesktopScreenX11Test, GetDisplayNearestWindow) { // Tests that the window is maximized in response to a double click event. TEST_F(DesktopScreenX11Test, DoubleClickHeaderMaximizes) { - if (!ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) + if (!ui::WmSupportsHint(gfx::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) return; Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc index aacca36ce815f1..1414ba2b760f7f 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc @@ -48,6 +48,7 @@ #include "ui/gfx/image/image_skia_rep.h" #include "ui/gfx/path.h" #include "ui/gfx/path_x11.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/views/corewm/tooltip_aura.h" #include "ui/views/linux_ui/linux_ui.h" #include "ui/views/views_delegate.h" @@ -731,7 +732,7 @@ void DesktopWindowTreeHostX11::Activate() { // https://code.google.com/p/wmii/issues/detail?id=266 static bool wm_supports_active_window = ui::GuessWindowManager() != ui::WM_WMII && - ui::WmSupportsHint(ui::GetAtom("_NET_ACTIVE_WINDOW")); + ui::WmSupportsHint(gfx::GetAtom("_NET_ACTIVE_WINDOW")); Time timestamp = ui::X11EventSource::GetInstance()->GetTimestamp(); @@ -740,7 +741,7 @@ void DesktopWindowTreeHostX11::Activate() { memset(&xclient, 0, sizeof(xclient)); xclient.type = ClientMessage; xclient.xclient.window = xwindow_; - xclient.xclient.message_type = ui::GetAtom("_NET_ACTIVE_WINDOW"); + xclient.xclient.message_type = gfx::GetAtom("_NET_ACTIVE_WINDOW"); xclient.xclient.format = 32; xclient.xclient.data.l[0] = 1; // Specified we are an app. xclient.xclient.data.l[1] = timestamp; @@ -797,7 +798,7 @@ bool DesktopWindowTreeHostX11::IsActive() const { void DesktopWindowTreeHostX11::Maximize() { if (HasWMSpecProperty("_NET_WM_STATE_FULLSCREEN")) { // Unfullscreen the window if it is fullscreen. - SetWMSpecState(false, ui::GetAtom("_NET_WM_STATE_FULLSCREEN"), None); + SetWMSpecState(false, gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"), None); // Resize the window so that it does not have the same size as a monitor. // (Otherwise, some window managers immediately put the window back in @@ -817,8 +818,8 @@ void DesktopWindowTreeHostX11::Maximize() { // heuristics that are in the PropertyNotify and ConfigureNotify handlers. restored_bounds_in_pixels_ = bounds_in_pixels_; - SetWMSpecState(true, ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), - ui::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); + SetWMSpecState(true, gfx::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), + gfx::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); if (IsMinimized()) ShowWindowWithState(ui::SHOW_STATE_NORMAL); } @@ -830,8 +831,8 @@ void DesktopWindowTreeHostX11::Minimize() { void DesktopWindowTreeHostX11::Restore() { should_maximize_after_map_ = false; - SetWMSpecState(false, ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), - ui::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); + SetWMSpecState(false, gfx::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), + gfx::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); if (IsMinimized()) ShowWindowWithState(ui::SHOW_STATE_NORMAL); } @@ -851,7 +852,7 @@ bool DesktopWindowTreeHostX11::HasCapture() const { void DesktopWindowTreeHostX11::SetAlwaysOnTop(bool always_on_top) { is_always_on_top_ = always_on_top; - SetWMSpecState(always_on_top, ui::GetAtom("_NET_WM_STATE_ABOVE"), None); + SetWMSpecState(always_on_top, gfx::GetAtom("_NET_WM_STATE_ABOVE"), None); } bool DesktopWindowTreeHostX11::IsAlwaysOnTop() const { @@ -859,7 +860,7 @@ bool DesktopWindowTreeHostX11::IsAlwaysOnTop() const { } void DesktopWindowTreeHostX11::SetVisibleOnAllWorkspaces(bool always_visible) { - SetWMSpecState(always_visible, ui::GetAtom("_NET_WM_STATE_STICKY"), None); + SetWMSpecState(always_visible, gfx::GetAtom("_NET_WM_STATE_STICKY"), None); int new_desktop = 0; if (always_visible) { @@ -874,7 +875,7 @@ void DesktopWindowTreeHostX11::SetVisibleOnAllWorkspaces(bool always_visible) { memset (&xevent, 0, sizeof (xevent)); xevent.type = ClientMessage; xevent.xclient.window = xwindow_; - xevent.xclient.message_type = ui::GetAtom("_NET_WM_DESKTOP"); + xevent.xclient.message_type = gfx::GetAtom("_NET_WM_DESKTOP"); xevent.xclient.format = 32; xevent.xclient.data.l[0] = new_desktop; xevent.xclient.data.l[1] = 0; @@ -899,8 +900,8 @@ bool DesktopWindowTreeHostX11::SetWindowTitle(const base::string16& title) { return false; window_title_ = title; std::string utf8str = base::UTF16ToUTF8(title); - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_NAME"), - ui::GetAtom("UTF8_STRING"), 8, PropModeReplace, + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_NAME"), + gfx::GetAtom("UTF8_STRING"), 8, PropModeReplace, reinterpret_cast(utf8str.c_str()), utf8str.size()); XTextProperty xtp; @@ -997,7 +998,7 @@ void DesktopWindowTreeHostX11::SetFullscreen(bool fullscreen) { if (unmaximize_and_remaximize) Restore(); - SetWMSpecState(fullscreen, ui::GetAtom("_NET_WM_STATE_FULLSCREEN"), None); + SetWMSpecState(fullscreen, gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"), None); if (unmaximize_and_remaximize) Maximize(); @@ -1042,9 +1043,10 @@ void DesktopWindowTreeHostX11::SetOpacity(float opacity) { unsigned long cardinality = opacity_8bit * channel_multiplier; if (cardinality == 0xffffffff) { - XDeleteProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_WINDOW_OPACITY")); + XDeleteProperty(xdisplay_, xwindow_, + gfx::GetAtom("_NET_WM_WINDOW_OPACITY")); } else { - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_WINDOW_OPACITY"), + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_WINDOW_OPACITY"), XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(&cardinality), 1); } @@ -1302,22 +1304,22 @@ void DesktopWindowTreeHostX11::InitX11Window( switch (params.type) { case Widget::InitParams::TYPE_MENU: swa.override_redirect = True; - window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_MENU"); + window_type = gfx::GetAtom("_NET_WM_WINDOW_TYPE_MENU"); break; case Widget::InitParams::TYPE_TOOLTIP: swa.override_redirect = True; - window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_TOOLTIP"); + window_type = gfx::GetAtom("_NET_WM_WINDOW_TYPE_TOOLTIP"); break; case Widget::InitParams::TYPE_POPUP: swa.override_redirect = True; - window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_NOTIFICATION"); + window_type = gfx::GetAtom("_NET_WM_WINDOW_TYPE_NOTIFICATION"); break; case Widget::InitParams::TYPE_DRAG: swa.override_redirect = True; - window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_DND"); + window_type = gfx::GetAtom("_NET_WM_WINDOW_TYPE_DND"); break; default: - window_type = ui::GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); + window_type = gfx::GetAtom("_NET_WM_WINDOW_TYPE_NORMAL"); break; } // An in-activatable window should not interact with the system wm. @@ -1386,8 +1388,8 @@ void DesktopWindowTreeHostX11::InitX11Window( // should listen for activation events and anything else that GTK+ listens // for, and do something useful. ::Atom protocols[2]; - protocols[0] = ui::GetAtom("WM_DELETE_WINDOW"); - protocols[1] = ui::GetAtom("_NET_WM_PING"); + protocols[0] = gfx::GetAtom("WM_DELETE_WINDOW"); + protocols[1] = gfx::GetAtom("_NET_WM_PING"); XSetWMProtocols(xdisplay_, xwindow_, protocols, 2); // We need a WM_CLIENT_MACHINE and WM_LOCALE_NAME value so we integrate with @@ -1400,11 +1402,11 @@ void DesktopWindowTreeHostX11::InitX11Window( static_assert(sizeof(long) >= sizeof(pid_t), "pid_t should not be larger than long"); long pid = getpid(); - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_PID"), XA_CARDINAL, + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(&pid), 1); - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_WINDOW_TYPE"), + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_WINDOW_TYPE"), XA_ATOM, 32, PropModeReplace, reinterpret_cast(&window_type), 1); @@ -1415,18 +1417,18 @@ void DesktopWindowTreeHostX11::InitX11Window( if ((params.type == Widget::InitParams::TYPE_POPUP || params.type == Widget::InitParams::TYPE_BUBBLE) && !params.force_show_in_taskbar) { - state_atom_list.push_back(ui::GetAtom("_NET_WM_STATE_SKIP_TASKBAR")); + state_atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_SKIP_TASKBAR")); } // If the window should stay on top of other windows, add the // _NET_WM_STATE_ABOVE property. is_always_on_top_ = params.keep_on_top; if (is_always_on_top_) - state_atom_list.push_back(ui::GetAtom("_NET_WM_STATE_ABOVE")); + state_atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_ABOVE")); workspace_.clear(); if (params.visible_on_all_workspaces) { - state_atom_list.push_back(ui::GetAtom("_NET_WM_STATE_STICKY")); + state_atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_STICKY")); ui::SetIntProperty(xwindow_, "_NET_WM_DESKTOP", "CARDINAL", kAllDesktops); } else if (!params.workspace.empty()) { int workspace; @@ -1521,7 +1523,7 @@ gfx::Size DesktopWindowTreeHostX11::AdjustSize( void DesktopWindowTreeHostX11::OnWMStateUpdated() { std::vector< ::Atom> atom_list; - // Ignore the return value of ui::GetAtomArrayProperty(). Fluxbox removes the + // Ignore the return value of gfx::GetAtomArrayProperty(). Fluxbox removes the // _NET_WM_STATE property when no _NET_WM_STATE atoms are set. ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list); @@ -1643,7 +1645,7 @@ void DesktopWindowTreeHostX11::UpdateWMUserTime( type == ui::ET_TOUCH_PRESSED) { unsigned long wm_user_time_ms = static_cast( (ui::EventTimeFromNative(event) - base::TimeTicks()).InMilliseconds()); - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_USER_TIME"), + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_USER_TIME"), XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(&wm_user_time_ms), 1); @@ -1657,7 +1659,7 @@ void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled, memset(&xclient, 0, sizeof(xclient)); xclient.type = ClientMessage; xclient.xclient.window = xwindow_; - xclient.xclient.message_type = ui::GetAtom("_NET_WM_STATE"); + xclient.xclient.message_type = gfx::GetAtom("_NET_WM_STATE"); xclient.xclient.format = 32; xclient.xclient.data.l[0] = enabled ? k_NET_WM_STATE_ADD : k_NET_WM_STATE_REMOVE; @@ -1672,7 +1674,7 @@ void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled, } bool DesktopWindowTreeHostX11::HasWMSpecProperty(const char* property) const { - return window_properties_.find(ui::GetAtom(property)) != + return window_properties_.find(gfx::GetAtom(property)) != window_properties_.end(); } @@ -1853,7 +1855,7 @@ void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) { ? 0 : ui::X11EventSource::GetInstance()->GetTimestamp(); if (show_state == ui::SHOW_STATE_INACTIVE || wm_user_time_ms != 0) { - XChangeProperty(xdisplay_, xwindow_, ui::GetAtom("_NET_WM_USER_TIME"), + XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_NET_WM_USER_TIME"), XA_CARDINAL, 32, PropModeReplace, reinterpret_cast(&wm_user_time_ms), 1); @@ -2114,12 +2116,12 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent( } case ClientMessage: { Atom message_type = xev->xclient.message_type; - if (message_type == ui::GetAtom("WM_PROTOCOLS")) { + if (message_type == gfx::GetAtom("WM_PROTOCOLS")) { Atom protocol = static_cast(xev->xclient.data.l[0]); - if (protocol == ui::GetAtom("WM_DELETE_WINDOW")) { + if (protocol == gfx::GetAtom("WM_DELETE_WINDOW")) { // We have received a close message from the window manager. OnHostCloseRequested(); - } else if (protocol == ui::GetAtom("_NET_WM_PING")) { + } else if (protocol == gfx::GetAtom("_NET_WM_PING")) { XEvent reply_event = *xev; reply_event.xclient.window = x_root_window_; @@ -2129,17 +2131,17 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent( SubstructureRedirectMask | SubstructureNotifyMask, &reply_event); } - } else if (message_type == ui::GetAtom("XdndEnter")) { + } else if (message_type == gfx::GetAtom("XdndEnter")) { drag_drop_client_->OnXdndEnter(xev->xclient); - } else if (message_type == ui::GetAtom("XdndLeave")) { + } else if (message_type == gfx::GetAtom("XdndLeave")) { drag_drop_client_->OnXdndLeave(xev->xclient); - } else if (message_type == ui::GetAtom("XdndPosition")) { + } else if (message_type == gfx::GetAtom("XdndPosition")) { drag_drop_client_->OnXdndPosition(xev->xclient); - } else if (message_type == ui::GetAtom("XdndStatus")) { + } else if (message_type == gfx::GetAtom("XdndStatus")) { drag_drop_client_->OnXdndStatus(xev->xclient); - } else if (message_type == ui::GetAtom("XdndFinished")) { + } else if (message_type == gfx::GetAtom("XdndFinished")) { drag_drop_client_->OnXdndFinished(xev->xclient); - } else if (message_type == ui::GetAtom("XdndDrop")) { + } else if (message_type == gfx::GetAtom("XdndDrop")) { drag_drop_client_->OnXdndDrop(xev->xclient); } break; @@ -2183,11 +2185,11 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent( } case PropertyNotify: { ::Atom changed_atom = xev->xproperty.atom; - if (changed_atom == ui::GetAtom("_NET_WM_STATE")) { + if (changed_atom == gfx::GetAtom("_NET_WM_STATE")) { OnWMStateUpdated(); - } else if (changed_atom == ui::GetAtom("_NET_FRAME_EXTENTS")) { + } else if (changed_atom == gfx::GetAtom("_NET_FRAME_EXTENTS")) { OnFrameExtentsUpdated(); - } else if (changed_atom == ui::GetAtom("_NET_WM_DESKTOP")) { + } else if (changed_atom == gfx::GetAtom("_NET_WM_DESKTOP")) { if (UpdateWorkspace()) OnHostWorkspaceChanged(); } diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc index f071e7564650a1..612b41f5939901 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc @@ -31,6 +31,7 @@ #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/path.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/views/test/views_test_base.h" #include "ui/views/test/x11_property_change_waiter.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" @@ -59,7 +60,7 @@ class WMStateWaiter : public X11PropertyChangeWaiter { bool ShouldKeepOnWaiting(const ui::PlatformEvent& event) override { std::vector hints; if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &hints)) { - auto it = std::find(hints.cbegin(), hints.cend(), ui::GetAtom(hint_)); + auto it = std::find(hints.cbegin(), hints.cend(), gfx::GetAtom(hint_)); bool hint_set = (it != hints.cend()); return hint_set != wait_till_set_; } @@ -238,7 +239,7 @@ TEST_F(DesktopWindowTreeHostX11Test, Shape) { EXPECT_FALSE(ShapeRectContainsPoint(shape_rects, 205, 15)); } - if (ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) { + if (ui::WmSupportsHint(gfx::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"))) { // The shape should be changed to a rectangle which fills the entire screen // when |widget1| is maximized. { @@ -315,7 +316,7 @@ TEST_F(DesktopWindowTreeHostX11Test, Shape) { // Test that the widget ignores changes in fullscreen state initiated by the // window manager (e.g. via a window manager accelerator key). TEST_F(DesktopWindowTreeHostX11Test, WindowManagerTogglesFullscreen) { - if (!ui::WmSupportsHint(ui::GetAtom("_NET_WM_STATE_FULLSCREEN"))) + if (!ui::WmSupportsHint(gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"))) return; std::unique_ptr widget = CreateWidget(new ShapedWidgetDelegate()); @@ -340,10 +341,10 @@ TEST_F(DesktopWindowTreeHostX11Test, WindowManagerTogglesFullscreen) { memset(&xclient, 0, sizeof(xclient)); xclient.type = ClientMessage; xclient.xclient.window = xid; - xclient.xclient.message_type = ui::GetAtom("_NET_WM_STATE"); + xclient.xclient.message_type = gfx::GetAtom("_NET_WM_STATE"); xclient.xclient.format = 32; xclient.xclient.data.l[0] = 0; - xclient.xclient.data.l[1] = ui::GetAtom("_NET_WM_STATE_FULLSCREEN"); + xclient.xclient.data.l[1] = gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"); xclient.xclient.data.l[2] = 0; xclient.xclient.data.l[3] = 1; xclient.xclient.data.l[4] = 0; @@ -380,7 +381,7 @@ TEST_F(DesktopWindowTreeHostX11Test, ToggleMinimizePropogateToContentWindow) { // Minimize by sending _NET_WM_STATE_HIDDEN { std::vector< ::Atom> atom_list; - atom_list.push_back(ui::GetAtom("_NET_WM_STATE_HIDDEN")); + atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_HIDDEN")); ui::SetAtomArrayProperty(xid, "_NET_WM_STATE", "ATOM", atom_list); XEvent xevent; @@ -390,7 +391,7 @@ TEST_F(DesktopWindowTreeHostX11Test, ToggleMinimizePropogateToContentWindow) { xevent.xproperty.send_event = 1; xevent.xproperty.display = display; xevent.xproperty.window = xid; - xevent.xproperty.atom = ui::GetAtom("_NET_WM_STATE"); + xevent.xproperty.atom = gfx::GetAtom("_NET_WM_STATE"); xevent.xproperty.state = 0; XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, @@ -404,7 +405,7 @@ TEST_F(DesktopWindowTreeHostX11Test, ToggleMinimizePropogateToContentWindow) { // Show from minimized by sending _NET_WM_STATE_FOCUSED { std::vector< ::Atom> atom_list; - atom_list.push_back(ui::GetAtom("_NET_WM_STATE_FOCUSED")); + atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_FOCUSED")); ui::SetAtomArrayProperty(xid, "_NET_WM_STATE", "ATOM", atom_list); XEvent xevent; @@ -414,7 +415,7 @@ TEST_F(DesktopWindowTreeHostX11Test, ToggleMinimizePropogateToContentWindow) { xevent.xproperty.send_event = 1; xevent.xproperty.display = display; xevent.xproperty.window = xid; - xevent.xproperty.atom = ui::GetAtom("_NET_WM_STATE"); + xevent.xproperty.atom = gfx::GetAtom("_NET_WM_STATE"); xevent.xproperty.state = 0; XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc index 3ee269bb3d4bec..f5e7f20766276a 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc +++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc @@ -12,9 +12,9 @@ #include "ui/aura/env.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/base/x/x11_menu_list.h" -#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_window_event_manager.h" #include "ui/events/platform/platform_event_source.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_error_tracker.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" @@ -90,7 +90,7 @@ bool X11DesktopHandler::CanDispatchEvent(const ui::PlatformEvent& event) { uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) { switch (event->type) { case PropertyNotify: { - if (event->xproperty.atom == ui::GetAtom("_NET_CURRENT_DESKTOP")) { + if (event->xproperty.atom == gfx::GetAtom("_NET_CURRENT_DESKTOP")) { if (UpdateWorkspace()) { for (views::X11DesktopHandlerObserver& observer : observers_) observer.OnWorkspaceChanged(workspace_); diff --git a/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc b/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc index 355093016bf2cd..d94a8789cbf285 100644 --- a/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc +++ b/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc @@ -26,6 +26,7 @@ #include "ui/events/platform/x11/x11_event_source.h" #include "ui/gfx/path.h" #include "ui/gfx/path_x11.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/views/test/views_interactive_ui_test_base.h" #include "ui/views/test/x11_property_change_waiter.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" @@ -50,7 +51,7 @@ class MinimizeWaiter : public X11PropertyChangeWaiter { std::vector wm_states; if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) { auto it = std::find(wm_states.cbegin(), wm_states.cend(), - ui::GetAtom("_NET_WM_STATE_HIDDEN")); + gfx::GetAtom("_NET_WM_STATE_HIDDEN")); return it == wm_states.cend(); } return true; @@ -395,7 +396,7 @@ TEST_F(X11TopmostWindowFinderTest, Menu) { &swa); { ui::SetAtomProperty(menu_xid, "_NET_WM_WINDOW_TYPE", "ATOM", - ui::GetAtom("_NET_WM_WINDOW_TYPE_MENU")); + gfx::GetAtom("_NET_WM_WINDOW_TYPE_MENU")); } ui::SetUseOSWindowFrame(menu_xid, false); ShowAndSetXWindowBounds(menu_xid, gfx::Rect(140, 110, 100, 100)); diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.cc b/ui/views/widget/desktop_aura/x11_window_event_filter.cc index b1bee28b953ae7..5e01cd65addbfd 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc @@ -15,11 +15,11 @@ #include "ui/aura/window_delegate.h" #include "ui/aura/window_tree_host.h" #include "ui/base/hit_test.h" -#include "ui/base/x/x11_util.h" #include "ui/display/display.h" #include "ui/display/screen.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" +#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_types.h" #include "ui/views/linux_ui/linux_ui.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" @@ -220,7 +220,7 @@ bool X11WindowEventFilter::DispatchHostWindowDragMovement( event.xclient.type = ClientMessage; event.xclient.display = xdisplay_; event.xclient.window = xwindow_; - event.xclient.message_type = ui::GetAtom("_NET_WM_MOVERESIZE"); + event.xclient.message_type = gfx::GetAtom("_NET_WM_MOVERESIZE"); event.xclient.format = 32; event.xclient.data.l[0] = screen_location.x(); event.xclient.data.l[1] = screen_location.y();