Skip to content

Commit

Permalink
Move ui::GetAtom to gfx::GetAtom
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
tanderson-google authored and Commit Bot committed Jun 8, 2017
1 parent 6704b38 commit 11aa41d
Show file tree
Hide file tree
Showing 36 changed files with 282 additions and 270 deletions.
5 changes: 3 additions & 2 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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$",
),
),
Expand Down
2 changes: 1 addition & 1 deletion ash/host/ash_window_tree_host_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/media/webrtc/window_icon_util_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
#include <X11/Xutil.h>

#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"

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
Expand Down
4 changes: 2 additions & 2 deletions ui/aura/test/ui_controls_factory_aurax11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions ui/aura/window_tree_host_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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<unsigned char*>(&pid),
1);

Expand Down Expand Up @@ -307,10 +308,10 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
break;
case ClientMessage: {
Atom message_type = static_cast<Atom>(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_;

Expand Down
23 changes: 12 additions & 11 deletions ui/base/clipboard/clipboard_aurax11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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(
Expand All @@ -340,7 +341,7 @@ ::Atom ClipboardAuraX11::AuraX11Details::LookupSelectionForClipboardType(
}

::Atom ClipboardAuraX11::AuraX11Details::GetCopyPasteSelection() const {
return GetAtom(kClipboard);
return gfx::GetAtom(kClipboard);
}

const SelectionFormatMap&
Expand All @@ -359,7 +360,7 @@ void ClipboardAuraX11::AuraX11Details::CreateNewClipboardData() {
void ClipboardAuraX11::AuraX11Details::InsertMapping(
const std::string& key,
const scoped_refptr<base::RefCountedMemory>& memory) {
::Atom atom_key = GetAtom(key.c_str());
::Atom atom_key = gfx::GetAtom(key.c_str());
clipboard_data_.Insert(atom_key, memory);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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<const ::Atom*>(data->front());
for (size_t i = 0; i < out_data_items; ++i)
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;

Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 11aa41d

Please sign in to comment.