Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_ |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <X11/extensions/shape.h> | 10 #include <X11/extensions/shape.h> |
| 11 #include <X11/Xlib.h> | 11 #include <X11/Xlib.h> |
| 12 #include <X11/Xutil.h> | 12 #include <X11/Xutil.h> |
| 13 | 13 |
| 14 #include "base/cancelable_callback.h" | 14 #include "base/cancelable_callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "ui/aura/scoped_window_targeter.h" | |
| 18 #include "ui/aura/window_tree_host.h" | 19 #include "ui/aura/window_tree_host.h" |
| 19 #include "ui/base/cursor/cursor_loader_x11.h" | 20 #include "ui/base/cursor/cursor_loader_x11.h" |
| 20 #include "ui/events/platform/platform_event_dispatcher.h" | 21 #include "ui/events/platform/platform_event_dispatcher.h" |
| 21 #include "ui/gfx/geometry/insets.h" | 22 #include "ui/gfx/geometry/insets.h" |
| 22 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
| 23 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 24 #include "ui/gfx/x/x11_atom_cache.h" | 25 #include "ui/gfx/x/x11_atom_cache.h" |
| 25 #include "ui/views/views_export.h" | 26 #include "ui/views/views_export.h" |
| 26 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" | 27 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
| 27 | 28 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 44 class VIEWS_EXPORT DesktopWindowTreeHostX11 | 45 class VIEWS_EXPORT DesktopWindowTreeHostX11 |
| 45 : public DesktopWindowTreeHost, | 46 : public DesktopWindowTreeHost, |
| 46 public aura::WindowTreeHost, | 47 public aura::WindowTreeHost, |
| 47 public ui::PlatformEventDispatcher { | 48 public ui::PlatformEventDispatcher { |
| 48 public: | 49 public: |
| 49 DesktopWindowTreeHostX11( | 50 DesktopWindowTreeHostX11( |
| 50 internal::NativeWidgetDelegate* native_widget_delegate, | 51 internal::NativeWidgetDelegate* native_widget_delegate, |
| 51 DesktopNativeWidgetAura* desktop_native_widget_aura); | 52 DesktopNativeWidgetAura* desktop_native_widget_aura); |
| 52 ~DesktopWindowTreeHostX11() override; | 53 ~DesktopWindowTreeHostX11() override; |
| 53 | 54 |
| 55 class ScopedHandle { | |
| 56 public: | |
| 57 explicit ScopedHandle(const base::Closure& destroy_callback); | |
| 58 ~ScopedHandle(); | |
| 59 | |
| 60 private: | |
| 61 base::Closure destroy_callback_; | |
| 62 DISALLOW_COPY_AND_ASSIGN(ScopedHandle); | |
| 63 }; | |
| 64 | |
| 54 // A way of converting an X11 |xid| host window into a |content_window_|. | 65 // A way of converting an X11 |xid| host window into a |content_window_|. |
| 55 static aura::Window* GetContentWindowForXID(XID xid); | 66 static aura::Window* GetContentWindowForXID(XID xid); |
| 56 | 67 |
| 57 // A way of converting an X11 |xid| host window into this object. | 68 // A way of converting an X11 |xid| host window into this object. |
| 58 static DesktopWindowTreeHostX11* GetHostForXID(XID xid); | 69 static DesktopWindowTreeHostX11* GetHostForXID(XID xid); |
| 59 | 70 |
| 60 // Get all open top-level windows. This includes windows that may not be | 71 // Get all open top-level windows. This includes windows that may not be |
| 61 // visible. This list is sorted in their stacking order, i.e. the first window | 72 // visible. This list is sorted in their stacking order, i.e. the first window |
| 62 // is the topmost window. | 73 // is the topmost window. |
| 63 static std::vector<aura::Window*> GetAllOpenWindows(); | 74 static std::vector<aura::Window*> GetAllOpenWindows(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 76 void AddObserver(DesktopWindowTreeHostObserverX11* observer); | 87 void AddObserver(DesktopWindowTreeHostObserverX11* observer); |
| 77 void RemoveObserver(DesktopWindowTreeHostObserverX11* observer); | 88 void RemoveObserver(DesktopWindowTreeHostObserverX11* observer); |
| 78 | 89 |
| 79 // Swaps the current handler for events in the non client view with |handler|. | 90 // Swaps the current handler for events in the non client view with |handler|. |
| 80 void SwapNonClientEventHandler(std::unique_ptr<ui::EventHandler> handler); | 91 void SwapNonClientEventHandler(std::unique_ptr<ui::EventHandler> handler); |
| 81 | 92 |
| 82 // Runs the |func| callback for each content-window, and deallocates the | 93 // Runs the |func| callback for each content-window, and deallocates the |
| 83 // internal list of open windows. | 94 // internal list of open windows. |
| 84 static void CleanUpWindowList(void (*func)(aura::Window* window)); | 95 static void CleanUpWindowList(void (*func)(aura::Window* window)); |
| 85 | 96 |
| 97 // Disables event listening to make |dialog| modal. | |
| 98 std::unique_ptr<ScopedHandle> DisableEventListening(XID dialog); | |
| 99 | |
| 100 // Returns XID of dialog currently displayed. When it returns 0, | |
| 101 // there is no dialog on the host window. | |
| 102 XID GetModalDialog(); | |
| 103 | |
| 86 protected: | 104 protected: |
| 87 // Overridden from DesktopWindowTreeHost: | 105 // Overridden from DesktopWindowTreeHost: |
| 88 void Init(aura::Window* content_window, | 106 void Init(aura::Window* content_window, |
| 89 const Widget::InitParams& params) override; | 107 const Widget::InitParams& params) override; |
| 90 void OnNativeWidgetCreated(const Widget::InitParams& params) override; | 108 void OnNativeWidgetCreated(const Widget::InitParams& params) override; |
| 91 std::unique_ptr<corewm::Tooltip> CreateTooltip() override; | 109 std::unique_ptr<corewm::Tooltip> CreateTooltip() override; |
| 92 std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient( | 110 std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient( |
| 93 DesktopNativeCursorManager* cursor_manager) override; | 111 DesktopNativeCursorManager* cursor_manager) override; |
| 94 void Close() override; | 112 void Close() override; |
| 95 void CloseNow() override; | 113 void CloseNow() override; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 // ui::PlatformEventDispatcher: | 277 // ui::PlatformEventDispatcher: |
| 260 bool CanDispatchEvent(const ui::PlatformEvent& event) override; | 278 bool CanDispatchEvent(const ui::PlatformEvent& event) override; |
| 261 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; | 279 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; |
| 262 | 280 |
| 263 void DelayedResize(const gfx::Size& size_in_pixels); | 281 void DelayedResize(const gfx::Size& size_in_pixels); |
| 264 | 282 |
| 265 gfx::Rect GetWorkAreaBoundsInPixels() const; | 283 gfx::Rect GetWorkAreaBoundsInPixels() const; |
| 266 gfx::Rect ToDIPRect(const gfx::Rect& rect_in_pixels) const; | 284 gfx::Rect ToDIPRect(const gfx::Rect& rect_in_pixels) const; |
| 267 gfx::Rect ToPixelRect(const gfx::Rect& rect_in_dip) const; | 285 gfx::Rect ToPixelRect(const gfx::Rect& rect_in_dip) const; |
| 268 | 286 |
| 287 // Enables event listening after closing |dialog|. | |
| 288 void EnableEventListening(); | |
| 289 | |
| 269 // X11 things | 290 // X11 things |
| 270 // The display and the native X window hosting the root window. | 291 // The display and the native X window hosting the root window. |
| 271 XDisplay* xdisplay_; | 292 XDisplay* xdisplay_; |
| 272 ::Window xwindow_; | 293 ::Window xwindow_; |
| 273 | 294 |
| 274 // Events selected on |xwindow_|. | 295 // Events selected on |xwindow_|. |
| 275 std::unique_ptr<ui::XScopedEventSelector> xwindow_events_; | 296 std::unique_ptr<ui::XScopedEventSelector> xwindow_events_; |
| 276 | 297 |
| 277 // The native root window. | 298 // The native root window. |
| 278 ::Window x_root_window_; | 299 ::Window x_root_window_; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 bool ignore_keyboard_input_; | 426 bool ignore_keyboard_input_; |
| 406 | 427 |
| 407 // Used for tracking activation state in {Before|After}ActivationStateChanged. | 428 // Used for tracking activation state in {Before|After}ActivationStateChanged. |
| 408 bool was_active_; | 429 bool was_active_; |
| 409 bool had_pointer_; | 430 bool had_pointer_; |
| 410 bool had_pointer_grab_; | 431 bool had_pointer_grab_; |
| 411 bool had_window_focus_; | 432 bool had_window_focus_; |
| 412 | 433 |
| 413 base::CancelableCallback<void()> delayed_resize_task_; | 434 base::CancelableCallback<void()> delayed_resize_task_; |
| 414 | 435 |
| 436 std::unique_ptr<aura::ScopedWindowTargeter> targeter_for_modal_; | |
| 437 | |
| 438 XID modal_dialog_xid_; | |
| 439 | |
| 440 ScopedHandle* scoped_handle_; | |
|
sadrul
2016/09/30 12:22:27
You shouldn't need this?
joone
2016/10/01 00:03:16
Removed.
| |
| 441 | |
| 415 base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_; | 442 base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_; |
| 443 base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_; | |
| 416 | 444 |
| 417 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11); | 445 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11); |
| 418 }; | 446 }; |
| 419 | 447 |
| 420 } // namespace views | 448 } // namespace views |
| 421 | 449 |
| 422 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_ | 450 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_X11_H_ |
| OLD | NEW |