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

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

Issue 1602173005: Add PlatformWindow/Event related code for Ozone X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split X11EventSource and X11Window. 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 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_H_ 5 #ifndef UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_
6 #define UI_PLATFORM_WINDOW_X11_X11_WINDOW_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/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"
12 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/x/x11_atom_cache.h" 14 #include "ui/gfx/x/x11_atom_cache.h"
14 #include "ui/platform_window/platform_window.h" 15 #include "ui/platform_window/platform_window.h"
15 #include "ui/platform_window/platform_window_delegate.h" 16 #include "ui/platform_window/platform_window_delegate.h"
16 #include "ui/platform_window/x11/x11_window_export.h" 17 #include "ui/platform_window/x11/x11_window_export.h"
17 18
18 typedef struct _XDisplay XDisplay; 19 typedef struct _XDisplay XDisplay;
19 typedef unsigned long XID; 20 typedef unsigned long XID;
21 typedef union _XEvent XEvent;
20 22
21 namespace ui { 23 namespace ui {
22 24
23 class X11_WINDOW_EXPORT X11Window : public PlatformWindow, 25 // Abstract base implementation for a X11 based PlatformWindow. Methods that
24 public PlatformEventDispatcher { 26 // are platform specific are left unimplemented.
27 class X11_WINDOW_EXPORT X11WindowBase : public PlatformWindow,
28 public PlatformEventDispatcher {
25 public: 29 public:
26 explicit X11Window(PlatformWindowDelegate* delegate); 30 explicit X11WindowBase(PlatformWindowDelegate* delegate);
27 ~X11Window() override; 31 ~X11WindowBase() 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;
48 void MoveCursorTo(const gfx::Point& location) override; 49 void MoveCursorTo(const gfx::Point& location) override;
49 void ConfineCursorToBounds(const gfx::Rect& bounds) override; 50 void ConfineCursorToBounds(const gfx::Rect& bounds) override;
50 PlatformImeController* GetPlatformImeController() override; 51 PlatformImeController* GetPlatformImeController() override;
51 52
52 // PlatformEventDispatcher: 53 protected:
53 bool CanDispatchEvent(const PlatformEvent& event) override; 54 void Destroy();
54 uint32_t DispatchEvent(const PlatformEvent& event) override; 55
sadrul 2016/02/02 16:33:54 Since X11WindowBase no longer actually implements
kylechar 2016/02/02 19:01:42 Yep! Done.
56 // Processes events for this XWindow.
57 void ProcessXWindowEvent(XEvent* xev);
55 58
56 PlatformWindowDelegate* delegate_; 59 PlatformWindowDelegate* delegate_;
57 60
58 XDisplay* xdisplay_; 61 XDisplay* xdisplay_;
59 XID xwindow_; 62 XID xwindow_;
60 XID xroot_window_; 63 XID xroot_window_;
61 X11AtomCache atom_cache_; 64 X11AtomCache atom_cache_;
62 65
63 base::string16 window_title_; 66 base::string16 window_title_;
64 67
65 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| 68 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_|
66 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is 69 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is
67 // the bounds the X11 server has set on the window. 70 // the bounds the X11 server has set on the window.
68 gfx::Rect requested_bounds_; 71 gfx::Rect requested_bounds_;
69 gfx::Rect confirmed_bounds_; 72 gfx::Rect confirmed_bounds_;
70 73
71 bool window_mapped_; 74 bool window_mapped_ = false;
sadrul 2016/02/02 16:33:54 data members need to be private (see style guide).
kylechar 2016/02/02 19:01:42 Fixed that here and in X11EventSource.
72 75
73 DISALLOW_COPY_AND_ASSIGN(X11Window); 76 private:
77 DISALLOW_COPY_AND_ASSIGN(X11WindowBase);
74 }; 78 };
75 79
76 namespace test { 80 namespace test {
77 81
78 // Sets the value of the |override_redirect| flag when creating an X11 window. 82 // 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 83 // 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 84 // X11WindowBase::Show() blocks because it never receives the MapNotify event.
85 // It is
81 // unclear why this is necessary, but might be related to calls to 86 // unclear why this is necessary, but might be related to calls to
82 // XInitThreads(). 87 // XInitThreads().
83 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( 88 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault(
84 bool override_redirect); 89 bool override_redirect);
85 90
86 } // namespace test 91 } // namespace test
87 92
88 } // namespace ui 93 } // namespace ui
89 94
90 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ 95 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698