Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

XWalk maintains DesktopRootWindowHostXWalk copied from DesktopRootWindowHostX11 by itself. #42

Merged
merged 4 commits into from
Aug 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_CURSOR_LOADER_UPDATER_AURAX11_H_

#include "base/compiler_specific.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"

namespace views {

// Loads the subset of aura cursors that X11 doesn't provide.
class DesktopCursorLoaderUpdaterAuraX11 : public DesktopCursorLoaderUpdater {
class VIEWS_EXPORT DesktopCursorLoaderUpdaterAuraX11 :
public DesktopCursorLoaderUpdater {
public:
DesktopCursorLoaderUpdaterAuraX11();
virtual ~DesktopCursorLoaderUpdaterAuraX11();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
#include "ui/base/events/event.h"
#include "ui/base/x/x11_util.h"
#include "ui/views/widget/desktop_aura/desktop_root_window_host_x11.h"

using aura::client::DragDropDelegate;
using ui::OSExchangeData;
Expand Down Expand Up @@ -174,11 +173,11 @@ bool DesktopDragDropClientAuraX11::X11DragContext::Dispatch(
///////////////////////////////////////////////////////////////////////////////

DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11(
views::DesktopRootWindowHostX11* root_window_host,
ui::DesktopSelectionProviderAuraX11* provider,
aura::RootWindow* root_window,
Display* xdisplay,
::Window xwindow)
: root_window_host_(root_window_host),
: selection_event_provider_(provider),
root_window_(root_window),
xdisplay_(xdisplay),
xwindow_(xwindow),
Expand Down Expand Up @@ -286,7 +285,7 @@ void DesktopDragDropClientAuraX11::OnXdndDrop(
aura::client::GetDragDropDelegate(target_window_);
if (delegate) {
ui::OSExchangeData data(new ui::OSExchangeDataProviderAuraX11(
root_window_host_, xwindow_, current_context_->targets()));
selection_event_provider_, xwindow_, current_context_->targets()));
ui::DropTargetEvent event(data,
target_window_location_,
target_window_root_location_,
Expand Down Expand Up @@ -374,7 +373,7 @@ void DesktopDragDropClientAuraX11::DragTranslate(
return;

data->reset(new OSExchangeData(new ui::OSExchangeDataProviderAuraX11(
root_window_host_, xwindow_, current_context_->targets())));
selection_event_provider_, xwindow_, current_context_->targets())));
gfx::Point location = root_location;
aura::Window::ConvertPointToTarget(root_window_, target_window_, &location);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class Point;
}

namespace ui {
class DesktopSelectionProviderAuraX11;
class DragSource;
class DropTargetEvent;
class OSExchangeData;
class RootWindow;
}

namespace views {
class DesktopRootWindowHostX11;

// Implements drag and drop on X11 for aura. On one side, this class takes raw
// X11 events forwarded from DesktopRootWindowHostLinux, while on the other, it
Expand All @@ -48,7 +48,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
public aura::WindowObserver {
public:
DesktopDragDropClientAuraX11(
views::DesktopRootWindowHostX11* root_window_host,
ui::DesktopSelectionProviderAuraX11* provider,
aura::RootWindow* root_window,
Display* xdisplay,
::Window xwindow);
Expand Down Expand Up @@ -101,7 +101,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// server.
void SendXClientEvent(unsigned long xid, XEvent* xev);

views::DesktopRootWindowHostX11* root_window_host_;
ui::DesktopSelectionProviderAuraX11* selection_event_provider_;
aura::RootWindow* root_window_;

Display* xdisplay_;
Expand Down
3 changes: 2 additions & 1 deletion ui/views/widget/desktop_aura/desktop_focus_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#define UI_VIEWS_WIDGET_DESKTOP_FOCUS_RULES_H_

#include "ui/views/corewm/base_focus_rules.h"
#include "ui/views/views_export.h"

namespace views {

class DesktopFocusRules : public corewm::BaseFocusRules {
class VIEWS_EXPORT DesktopFocusRules : public corewm::BaseFocusRules {
public:
DesktopFocusRules();
virtual ~DesktopFocusRules();
Expand Down
10 changes: 10 additions & 0 deletions ui/views/widget/desktop_aura/desktop_root_window_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ class VIEWS_EXPORT DesktopRootWindowHost {
DesktopNativeWidgetAura* desktop_native_widget_aura,
const gfx::Rect& initial_bounds);

typedef DesktopRootWindowHost* (DesktopRootWindowHostFactory)(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura,
const gfx::Rect& initial_bounds);
// Uses the given DesktopRootWindowHostFactory to override the default
// DesktopRootWindowHost implementation for embedder.
// Returns true if the factory was successfully registered.
static bool InitDesktopRootWindowHostFactory(
DesktopRootWindowHostFactory* factory);

// Return the NativeTheme to use for |window|.
static ui::NativeTheme* GetNativeTheme(aura::Window* window);

Expand Down
6 changes: 6 additions & 0 deletions ui/views/widget/desktop_aura/desktop_root_window_host_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -869,4 +869,10 @@ DesktopRootWindowHost* DesktopRootWindowHost::Create(
initial_bounds);
}

// static
bool DesktopRootWindowHost::InitDesktopRootWindowHostFactory(
DesktopRootWindowHostFactory* factory) {
return true;
}

} // namespace views
78 changes: 34 additions & 44 deletions ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "base/message_pump_aurax11.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/user_action_client.h"
#include "ui/aura/focus_manager.h"
Expand Down Expand Up @@ -56,6 +55,9 @@ DEFINE_WINDOW_PROPERTY_KEY(

namespace {

DesktopRootWindowHost::DesktopRootWindowHostFactory*
desktop_root_window_host_factory_ = NULL;

// Standard Linux mouse buttons for going back and forward.
const int kBackMouseButton = 8;
const int kForwardMouseButton = 9;
Expand Down Expand Up @@ -141,7 +143,7 @@ ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) {

void DesktopRootWindowHostX11::InitX11Window(
const Widget::InitParams& params) {
unsigned long attribute_mask = CWBackPixmap;
unsigned long attribute_mask = CWBackPixmap; // NOLINT(*)
XSetWindowAttributes swa;
memset(&swa, 0, sizeof(swa));
swa.background_pixmap = None;
Expand All @@ -165,7 +167,7 @@ void DesktopRootWindowHostX11::InitX11Window(

// TODO(erg): Maybe need to set a ViewProp here like in RWHL::RWHL().

long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask |
long event_mask = ButtonPressMask | ButtonReleaseMask | FocusChangeMask | // NOLINT(*)
KeyPressMask | KeyReleaseMask |
EnterWindowMask | LeaveWindowMask |
ExposureMask | VisibilityChangeMask |
Expand Down Expand Up @@ -233,7 +235,6 @@ aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow(
root_window_->SetLayoutManager(new DesktopLayoutManager(root_window_));
root_window_->SetProperty(kViewsWindowForRootWindow, content_window_);
root_window_->SetProperty(kHostForRootWindow, this);
root_window_->SetProperty(aura::client::kShowStateKey, params.show_state);
root_window_host_delegate_ = root_window_;

// If we're given a parent, we need to mark ourselves as transient to another
Expand Down Expand Up @@ -291,22 +292,7 @@ aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow(
// TODO(erg): Unify this code once the other consumer goes away.
x11_window_event_filter_.reset(
new X11WindowEventFilter(root_window_, activation_client_.get()));

// We reuse the |remove_standard_frame| in to tell if the window border is
// used. Note the |remove_standard_frame| is originally designed for
// Windows, see comments in ui/views/widget.h.
bool use_os_border = params.remove_standard_frame ? false : true;
x11_window_event_filter_->SetUseHostWindowBorders(use_os_border);

// DesktopRootWindowHost should handle the close event emitted by
// window manager, e.g. press close button.
//
// For a frameless window (not use os border), the custom frame
// view will draw the border and handle the close event by hit
// test.
if (use_os_border)
root_window_->AddRootWindowObserver(this);

x11_window_event_filter_->SetUseHostWindowBorders(false);
desktop_native_widget_aura_->root_window_event_filter()->AddHandler(
x11_window_event_filter_.get());

Expand Down Expand Up @@ -593,8 +579,7 @@ void DesktopRootWindowHostX11::SetAlwaysOnTop(bool always_on_top) {
}

void DesktopRootWindowHostX11::SetWindowTitle(const string16& title) {
XmbSetWMProperties(xdisplay_, xwindow_, UTF16ToUTF8(title).c_str(), NULL,
NULL, 0, NULL, NULL, NULL);
XStoreName(xdisplay_, xwindow_, UTF16ToUTF8(title).c_str());
}

void DesktopRootWindowHostX11::ClearNativeFocus() {
Expand Down Expand Up @@ -721,13 +706,6 @@ void DesktopRootWindowHostX11::Show() {
// asynchronous.
base::MessagePumpAuraX11::Current()->BlockUntilWindowMapped(xwindow_);
window_mapped_ = true;

// In some window managers, the window state change only takes effect after
// the window gets mapped.
ui::WindowShowState show_state =
root_window_->GetProperty(aura::client::kShowStateKey);
if (show_state == ui::SHOW_STATE_FULLSCREEN)
SetFullscreen(true);
}
}

Expand Down Expand Up @@ -1030,13 +1008,17 @@ bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
int num_coalesced = 0;

switch (type) {
case ui::ET_TOUCH_MOVED:
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_RELEASED: {
ui::TouchEvent touchev(xev);
root_window_host_delegate_->OnHostTouchEvent(&touchev);
break;
}
// case ui::ET_TOUCH_MOVED:
// num_coalesced = CoalescePendingMotionEvents(xev, &last_event);
// if (num_coalesced > 0)
// xev = &last_event;
// // fallthrough
// case ui::ET_TOUCH_PRESSED:
// case ui::ET_TOUCH_RELEASED: {
// ui::TouchEvent touchev(xev);
// root_window_host_delegate_->OnHostTouchEvent(&touchev);
// break;
// }
case ui::ET_MOUSE_MOVED:
case ui::ET_MOUSE_DRAGGED:
case ui::ET_MOUSE_PRESSED:
Expand Down Expand Up @@ -1177,11 +1159,11 @@ bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
// Get our new window property state if the WM has told us its changed.
::Atom state = atom_cache_.GetAtom("_NET_WM_STATE");

std::vector< ::Atom> atom_list;
std::vector< ::Atom> atom_list; // NOLINT(*)
if (xev->xproperty.atom == state &&
ui::GetAtomArrayProperty(xwindow_, "_NET_WM_STATE", &atom_list)) {
window_properties_.clear();
std::copy(atom_list.begin(), atom_list.end(),
std::copy(atom_list.begin(), atom_list.end(), // NOLINT(*)
inserter(window_properties_, window_properties_.begin()));

// Now that we have different window properties, we may need to
Expand Down Expand Up @@ -1213,12 +1195,6 @@ bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
return true;
}

void DesktopRootWindowHostX11::OnRootWindowHostCloseRequested(
const aura::RootWindow* root) {
DCHECK(root == root_window_);
Close();
}

////////////////////////////////////////////////////////////////////////////////
// DesktopRootWindowHost, public:

Expand All @@ -1227,9 +1203,23 @@ DesktopRootWindowHost* DesktopRootWindowHost::Create(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura,
const gfx::Rect& initial_bounds) {
if (desktop_root_window_host_factory_)
return desktop_root_window_host_factory_(native_widget_delegate,
desktop_native_widget_aura,
initial_bounds);
return new DesktopRootWindowHostX11(native_widget_delegate,
desktop_native_widget_aura,
initial_bounds);
}

// static
bool DesktopRootWindowHost::InitDesktopRootWindowHostFactory(
DesktopRootWindowHostFactory* factory) {
if (desktop_root_window_host_factory_)
return false;

desktop_root_window_host_factory_ = factory;
return true;
}

} // namespace views
11 changes: 2 additions & 9 deletions ui/views/widget/desktop_aura/desktop_root_window_host_x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/memory/weak_ptr.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/root_window_host.h"
#include "ui/aura/root_window_observer.h"
#include "ui/base/cursor/cursor_loader_x11.h"
#include "ui/base/dragdrop/desktop_selection_provider_aurax11.h"
#include "ui/base/x/x11_atom_cache.h"
Expand All @@ -23,7 +22,6 @@
#include "ui/views/widget/desktop_aura/desktop_root_window_host.h"

namespace aura {
class RootWindow;
namespace client {
class FocusClient;
class ScreenPositionClient;
Expand All @@ -42,10 +40,9 @@ namespace corewm {
class CursorManager;
}

class VIEWS_EXPORT DesktopRootWindowHostX11 :
class VIEWS_EXPORT DesktopRootWindowHostX11 : // NOLINT(*)
public DesktopRootWindowHost,
public aura::RootWindowHost,
public aura::RootWindowObserver,
public ui::DesktopSelectionProviderAuraX11,
public base::MessageLoop::Dispatcher {
public:
Expand Down Expand Up @@ -182,10 +179,6 @@ class VIEWS_EXPORT DesktopRootWindowHostX11 :
// Overridden from Dispatcher:
virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;

// Overriden from aura::RootWindowObserver:
virtual void OnRootWindowHostCloseRequested(
const aura::RootWindow* root) OVERRIDE;

base::WeakPtrFactory<DesktopRootWindowHostX11> close_widget_factory_;

// X11 things
Expand All @@ -208,7 +201,7 @@ class VIEWS_EXPORT DesktopRootWindowHostX11 :
bool focus_when_shown_;

// The window manager state bits.
std::set< ::Atom> window_properties_;
std::set< ::Atom> window_properties_; // NOLINT(*)

// We are owned by the RootWindow, but we have to have a back pointer to it.
aura::RootWindow* root_window_;
Expand Down