From cb2f24550ba87cb1b976ea8ae1b0cf2cbd97030c Mon Sep 17 00:00:00 2001 From: Dongseong Hwang Date: Thu, 1 Aug 2013 21:35:28 +0300 Subject: [PATCH 1/4] Add factory mechanism to DesktopRootWindowHost. Uses the given DesktopRootWindowHostFactory to override the default DesktopRootWindowHost implementation for embedder. After this patch, xwalk maintains DesktopRootWindowHost inside xwalk. --- .../desktop_aura/desktop_root_window_host.h | 10 ++++++++++ .../desktop_root_window_host_win.cc | 6 ++++++ .../desktop_root_window_host_x11.cc | 17 +++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host.h b/ui/views/widget/desktop_aura/desktop_root_window_host.h index 7d02d4a2d7583..3816279fe131e 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host.h @@ -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); diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index fb47a6bf03f75..175c93ec77326 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -869,4 +869,10 @@ DesktopRootWindowHost* DesktopRootWindowHost::Create( initial_bounds); } +// static +bool DesktopRootWindowHost::InitDesktopRootWindowHostFactory( + DesktopRootWindowHostFactory* factory) { + return true; +} + } // namespace views diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 1ee15b40cac10..414c272f77ac2 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -56,6 +56,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; @@ -1227,9 +1230,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 From f6ae661691a683e137fff0e03814948e881676f0 Mon Sep 17 00:00:00 2001 From: Dongseong Hwang Date: Thu, 1 Aug 2013 22:03:57 +0300 Subject: [PATCH 2/4] Make DesktopDragDropClientAuraX11 not depend on DesktopRootWindowHostX11. --- .../desktop_aura/desktop_drag_drop_client_aurax11.cc | 9 ++++----- .../desktop_aura/desktop_drag_drop_client_aurax11.h | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) 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 e0ad0e35cf986..1e36387954f8e 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 @@ -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; @@ -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), @@ -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_, @@ -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); diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h index 47c4f2b0a6663..4b5d7abfc8b8d 100644 --- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h +++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h @@ -31,6 +31,7 @@ class Point; } namespace ui { +class DesktopSelectionProviderAuraX11; class DragSource; class DropTargetEvent; class OSExchangeData; @@ -38,7 +39,6 @@ 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 @@ -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); @@ -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_; From 31b5a7399e1e4c7383fa351351ffa9356b1680bd Mon Sep 17 00:00:00 2001 From: Dongseong Hwang Date: Thu, 1 Aug 2013 22:24:34 +0300 Subject: [PATCH 3/4] Export DesktopCursorLoaderUpdaterAuraX11 and DesktopFocusRules to maintain DesktopRootWindowHost inside xwalk. We will perhaps make something like ui/views/widget/desktop_aura inside xwalk to satisfy our all requirements. At that time, this patch can be rollbacked. --- .../desktop_aura/desktop_cursor_loader_updater_aurax11.h | 4 +++- ui/views/widget/desktop_aura/desktop_focus_rules.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h b/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h index 3018c977a05c8..36497bcbe5a9a 100644 --- a/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h +++ b/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h @@ -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(); diff --git a/ui/views/widget/desktop_aura/desktop_focus_rules.h b/ui/views/widget/desktop_aura/desktop_focus_rules.h index a7db8c2504f71..d276cd7a16686 100644 --- a/ui/views/widget/desktop_aura/desktop_focus_rules.h +++ b/ui/views/widget/desktop_aura/desktop_focus_rules.h @@ -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(); From f96da006266f978012f4c9d7ec419c2114815019 Mon Sep 17 00:00:00 2001 From: Dongseong Hwang Date: Thu, 1 Aug 2013 22:29:14 +0300 Subject: [PATCH 4/4] Rollback all changes of DesktopRootWindowHostX11 that we made, because xwalk maintains DesktopRootWindowHost by itself. Revert "Fix the issue that app window can not enter fullscreen mode on Tizen 3.0" Revert "Use XmbSetWMProperties to set window title for i18n issue" Revert "[Backport] Aura: enable the touch events dispatch in DesktopRootWindowHostX11" Revert "Fixup due to lint error." Revert "Make the close button can close the native app window" Revert "Add option to choose if the window border is showed" --- .../desktop_root_window_host_x11.cc | 61 ++++++------------- .../desktop_root_window_host_x11.h | 11 +--- 2 files changed, 19 insertions(+), 53 deletions(-) diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 414c272f77ac2..04447efea3b18 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -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" @@ -144,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; @@ -168,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 | @@ -236,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 @@ -294,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()); @@ -596,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() { @@ -724,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); } } @@ -1033,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: @@ -1180,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 @@ -1216,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: diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h index 327c8236a5083..399d823b7b828 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h @@ -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" @@ -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; @@ -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: @@ -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 close_widget_factory_; // X11 things @@ -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_;