| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_ | 5 #ifndef UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_ |
| 6 #define UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_ | 6 #define UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/x/x11_atom_cache.h" | 13 #include "ui/gfx/x/x11_atom_cache.h" |
| 14 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
| 15 #include "ui/platform_window/platform_window.h" | 15 #include "ui/platform_window/platform_window.h" |
| 16 #include "ui/platform_window/platform_window_delegate.h" | 16 #include "ui/platform_window/platform_window_delegate.h" |
| 17 #include "ui/platform_window/x11/x11_window_export.h" | 17 #include "ui/platform_window/x11/x11_window_export.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 class XScopedEventSelector; | 21 class XScopedEventSelector; |
| 22 | 22 |
| 23 // Abstract base implementation for a X11 based PlatformWindow. Methods that | 23 // Abstract base implementation for a X11 based PlatformWindow. Methods that |
| 24 // are platform specific are left unimplemented. | 24 // are platform specific are left unimplemented. |
| 25 class X11_WINDOW_EXPORT X11WindowBase : public PlatformWindow { | 25 class X11_WINDOW_EXPORT X11WindowBase : public PlatformWindow { |
| 26 public: | 26 public: |
| 27 explicit X11WindowBase(PlatformWindowDelegate* delegate); | 27 X11WindowBase(PlatformWindowDelegate* delegate, const gfx::Rect& bounds); |
| 28 ~X11WindowBase() override; | 28 ~X11WindowBase() override; |
| 29 | 29 |
| 30 // Creates new underlying XWindow. Does not map XWindow. | 30 // Creates new underlying XWindow. Does not map XWindow. |
| 31 void Create(); | 31 void Create(); |
| 32 | 32 |
| 33 // PlatformWindow: | 33 // PlatformWindow: |
| 34 void Show() override; | 34 void Show() override; |
| 35 void Hide() override; | 35 void Hide() override; |
| 36 void Close() override; | 36 void Close() override; |
| 37 void SetBounds(const gfx::Rect& bounds) override; | 37 void SetBounds(const gfx::Rect& bounds) override; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 64 PlatformWindowDelegate* delegate_; | 64 PlatformWindowDelegate* delegate_; |
| 65 | 65 |
| 66 XDisplay* xdisplay_; | 66 XDisplay* xdisplay_; |
| 67 XID xwindow_; | 67 XID xwindow_; |
| 68 XID xroot_window_; | 68 XID xroot_window_; |
| 69 X11AtomCache atom_cache_; | 69 X11AtomCache atom_cache_; |
| 70 std::unique_ptr<ui::XScopedEventSelector> xwindow_events_; | 70 std::unique_ptr<ui::XScopedEventSelector> xwindow_events_; |
| 71 | 71 |
| 72 base::string16 window_title_; | 72 base::string16 window_title_; |
| 73 | 73 |
| 74 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| | 74 // The bounds of |xwindow_|. |
| 75 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is | 75 gfx::Rect bounds_; |
| 76 // the bounds the X11 server has set on the window. | |
| 77 gfx::Rect requested_bounds_; | |
| 78 gfx::Rect confirmed_bounds_; | |
| 79 | 76 |
| 80 bool window_mapped_ = false; | 77 bool window_mapped_ = false; |
| 81 | 78 |
| 82 DISALLOW_COPY_AND_ASSIGN(X11WindowBase); | 79 DISALLOW_COPY_AND_ASSIGN(X11WindowBase); |
| 83 }; | 80 }; |
| 84 | 81 |
| 85 namespace test { | 82 namespace test { |
| 86 | 83 |
| 87 // Sets the value of the |override_redirect| flag when creating an X11 window. | 84 // Sets the value of the |override_redirect| flag when creating an X11 window. |
| 88 // It is necessary to set this flag on for various tests, otherwise the call to | 85 // It is necessary to set this flag on for various tests, otherwise the call to |
| 89 // X11WindowBase::Show() blocks because it never receives the MapNotify event. | 86 // X11WindowBase::Show() blocks because it never receives the MapNotify event. |
| 90 // It is | 87 // It is |
| 91 // unclear why this is necessary, but might be related to calls to | 88 // unclear why this is necessary, but might be related to calls to |
| 92 // XInitThreads(). | 89 // XInitThreads(). |
| 93 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( | 90 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( |
| 94 bool override_redirect); | 91 bool override_redirect); |
| 95 | 92 |
| 96 } // namespace test | 93 } // namespace test |
| 97 | 94 |
| 98 } // namespace ui | 95 } // namespace ui |
| 99 | 96 |
| 100 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_ | 97 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_ |
| OLD | NEW |