| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_H_ | 5 #ifndef UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ |
| 6 #define UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ | 6 #define UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | 8 #include "base/macros.h" |
| 11 #include "ui/events/platform/platform_event_dispatcher.h" | 9 #include "ui/events/platform/platform_event_dispatcher.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/platform_window/x11/x11_window_base.h" |
| 13 #include "ui/gfx/x/x11_atom_cache.h" | |
| 14 #include "ui/platform_window/platform_window.h" | |
| 15 #include "ui/platform_window/platform_window_delegate.h" | |
| 16 #include "ui/platform_window/x11/x11_window_export.h" | 11 #include "ui/platform_window/x11/x11_window_export.h" |
| 17 | 12 |
| 18 typedef struct _XDisplay XDisplay; | |
| 19 typedef unsigned long XID; | |
| 20 | |
| 21 namespace ui { | 13 namespace ui { |
| 22 | 14 |
| 23 class X11_WINDOW_EXPORT X11Window : public PlatformWindow, | 15 // PlatformWindow implementation for X11. PlatformEvents are XEvents. |
| 16 class X11_WINDOW_EXPORT X11Window : public X11WindowBase, |
| 24 public PlatformEventDispatcher { | 17 public PlatformEventDispatcher { |
| 25 public: | 18 public: |
| 26 explicit X11Window(PlatformWindowDelegate* delegate); | 19 explicit X11Window(PlatformWindowDelegate* delegate); |
| 27 ~X11Window() override; | 20 ~X11Window() override; |
| 28 | 21 |
| 22 // PlatformWindow: |
| 23 void SetCursor(PlatformCursor cursor) override; |
| 24 |
| 29 private: | 25 private: |
| 30 void Destroy(); | 26 void ProcessXInput2Event(XEvent* xev); |
| 31 | |
| 32 void ProcessXInput2Event(XEvent* xevent); | |
| 33 | |
| 34 // PlatformWindow: | |
| 35 void Show() override; | |
| 36 void Hide() override; | |
| 37 void Close() override; | |
| 38 void SetBounds(const gfx::Rect& bounds) override; | |
| 39 gfx::Rect GetBounds() override; | |
| 40 void SetTitle(const base::string16& title) override; | |
| 41 void SetCapture() override; | |
| 42 void ReleaseCapture() override; | |
| 43 void ToggleFullscreen() override; | |
| 44 void Maximize() override; | |
| 45 void Minimize() override; | |
| 46 void Restore() override; | |
| 47 void SetCursor(PlatformCursor cursor) override; | |
| 48 void MoveCursorTo(const gfx::Point& location) override; | |
| 49 void ConfineCursorToBounds(const gfx::Rect& bounds) override; | |
| 50 PlatformImeController* GetPlatformImeController() override; | |
| 51 | 27 |
| 52 // PlatformEventDispatcher: | 28 // PlatformEventDispatcher: |
| 53 bool CanDispatchEvent(const PlatformEvent& event) override; | 29 bool CanDispatchEvent(const PlatformEvent& event) override; |
| 54 uint32_t DispatchEvent(const PlatformEvent& event) override; | 30 uint32_t DispatchEvent(const PlatformEvent& event) override; |
| 55 | 31 |
| 56 PlatformWindowDelegate* delegate_; | |
| 57 | |
| 58 XDisplay* xdisplay_; | |
| 59 XID xwindow_; | |
| 60 XID xroot_window_; | |
| 61 X11AtomCache atom_cache_; | |
| 62 | |
| 63 base::string16 window_title_; | |
| 64 | |
| 65 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| | |
| 66 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is | |
| 67 // the bounds the X11 server has set on the window. | |
| 68 gfx::Rect requested_bounds_; | |
| 69 gfx::Rect confirmed_bounds_; | |
| 70 | |
| 71 bool window_mapped_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(X11Window); | 32 DISALLOW_COPY_AND_ASSIGN(X11Window); |
| 74 }; | 33 }; |
| 75 | 34 |
| 76 namespace test { | |
| 77 | |
| 78 // Sets the value of the |override_redirect| flag when creating an X11 window. | |
| 79 // It is necessary to set this flag on for various tests, otherwise the call to | |
| 80 // X11Window::Show() blocks because it never receives the MapNotify event. It is | |
| 81 // unclear why this is necessary, but might be related to calls to | |
| 82 // XInitThreads(). | |
| 83 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( | |
| 84 bool override_redirect); | |
| 85 | |
| 86 } // namespace test | |
| 87 | |
| 88 } // namespace ui | 35 } // namespace ui |
| 89 | 36 |
| 90 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ | 37 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ |
| OLD | NEW |