Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: ui/platform_window/x11/x11_window.h

Issue 1602173005: Add PlatformWindow/Event related code for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: XEventDispatcher added. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 8 #include <stdint.h>
9 9
10 #include "base/callback.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "ui/events/platform/platform_event_dispatcher.h" 12 #include "ui/events/platform/platform_event_dispatcher.h"
13 #include "ui/events/platform/x11/x11_event_source.h"
12 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/x/x11_atom_cache.h" 15 #include "ui/gfx/x/x11_atom_cache.h"
14 #include "ui/platform_window/platform_window.h" 16 #include "ui/platform_window/platform_window.h"
15 #include "ui/platform_window/platform_window_delegate.h" 17 #include "ui/platform_window/platform_window_delegate.h"
16 #include "ui/platform_window/x11/x11_window_export.h" 18 #include "ui/platform_window/x11/x11_window_export.h"
17 19
18 typedef struct _XDisplay XDisplay; 20 typedef struct _XDisplay XDisplay;
19 typedef unsigned long XID; 21 typedef unsigned long XID;
22 typedef union _XEvent XEvent;
20 23
21 namespace ui { 24 namespace ui {
22 25
23 class X11_WINDOW_EXPORT X11Window : public PlatformWindow, 26 class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
24 public PlatformEventDispatcher { 27 public PlatformEventDispatcher,
28 public XEventDispatcher {
25 public: 29 public:
26 explicit X11Window(PlatformWindowDelegate* delegate); 30 explicit X11Window(PlatformWindowDelegate* delegate);
27 ~X11Window() override; 31 ~X11Window() override;
28 32
29 private: 33 // Creates new underlying XWindow. Does not map XWindow.
30 void Destroy(); 34 void Create();
31
32 void ProcessXInput2Event(XEvent* xevent);
33 35
34 // PlatformWindow: 36 // PlatformWindow:
35 void Show() override; 37 void Show() override;
36 void Hide() override; 38 void Hide() override;
37 void Close() override; 39 void Close() override;
38 void SetBounds(const gfx::Rect& bounds) override; 40 void SetBounds(const gfx::Rect& bounds) override;
39 gfx::Rect GetBounds() override; 41 gfx::Rect GetBounds() override;
40 void SetTitle(const base::string16& title) override; 42 void SetTitle(const base::string16& title) override;
41 void SetCapture() override; 43 void SetCapture() override;
42 void ReleaseCapture() override; 44 void ReleaseCapture() override;
43 void ToggleFullscreen() override; 45 void ToggleFullscreen() override;
44 void Maximize() override; 46 void Maximize() override;
45 void Minimize() override; 47 void Minimize() override;
46 void Restore() override; 48 void Restore() override;
47 void SetCursor(PlatformCursor cursor) override; 49 void SetCursor(PlatformCursor cursor) override;
48 void MoveCursorTo(const gfx::Point& location) override; 50 void MoveCursorTo(const gfx::Point& location) override;
49 void ConfineCursorToBounds(const gfx::Rect& bounds) override; 51 void ConfineCursorToBounds(const gfx::Rect& bounds) override;
50 PlatformImeController* GetPlatformImeController() override; 52 PlatformImeController* GetPlatformImeController() override;
51 53
54 private:
55 void Destroy();
56
57 void ProcessXInput2Event(XEvent* xev);
58 void ProcessXWindowEvent(const XEvent& xev);
59
52 // PlatformEventDispatcher: 60 // PlatformEventDispatcher:
53 bool CanDispatchEvent(const PlatformEvent& event) override; 61 bool CanDispatchEvent(const PlatformEvent& event) override;
54 uint32_t DispatchEvent(const PlatformEvent& event) override; 62 uint32_t DispatchEvent(const PlatformEvent& event) override;
55 63
64 // XEventDispatcher:
65 bool DispatchXEvent(const XEvent& xev) override;
66
56 PlatformWindowDelegate* delegate_; 67 PlatformWindowDelegate* delegate_;
57 68
58 XDisplay* xdisplay_; 69 XDisplay* xdisplay_;
59 XID xwindow_; 70 XID xwindow_;
60 XID xroot_window_; 71 XID xroot_window_;
61 X11AtomCache atom_cache_; 72 X11AtomCache atom_cache_;
62 73
63 base::string16 window_title_; 74 base::string16 window_title_;
64 75
65 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| 76 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_|
66 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is 77 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is
67 // the bounds the X11 server has set on the window. 78 // the bounds the X11 server has set on the window.
68 gfx::Rect requested_bounds_; 79 gfx::Rect requested_bounds_;
69 gfx::Rect confirmed_bounds_; 80 gfx::Rect confirmed_bounds_;
70 81
71 bool window_mapped_; 82 bool window_mapped_ = false;
72 83
73 DISALLOW_COPY_AND_ASSIGN(X11Window); 84 DISALLOW_COPY_AND_ASSIGN(X11Window);
74 }; 85 };
75 86
76 namespace test { 87 namespace test {
77 88
78 // Sets the value of the |override_redirect| flag when creating an X11 window. 89 // 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 90 // 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 91 // 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 92 // unclear why this is necessary, but might be related to calls to
82 // XInitThreads(). 93 // XInitThreads().
83 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( 94 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault(
84 bool override_redirect); 95 bool override_redirect);
85 96
86 } // namespace test 97 } // namespace test
87 98
88 } // namespace ui 99 } // namespace ui
89 100
90 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ 101 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698