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

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: Rebase. 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/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/platform_window/platform_window.h" 14 #include "ui/platform_window/platform_window.h"
15 #include "ui/platform_window/platform_window_delegate.h" 15 #include "ui/platform_window/platform_window_delegate.h"
16 #include "ui/platform_window/x11/x11_window_export.h" 16 #include "ui/platform_window/x11/x11_window_export.h"
17 17
18 typedef struct _XDisplay XDisplay; 18 typedef struct _XDisplay XDisplay;
19 typedef unsigned long XID; 19 typedef unsigned long XID;
20 typedef union _XEvent XEvent;
20 21
21 namespace ui { 22 namespace ui {
22 23
23 class X11_WINDOW_EXPORT X11Window : public PlatformWindow, 24 // Abstract base implementation for a X11 based PlatformWindow. Methods that
24 public PlatformEventDispatcher { 25 // are platform specific are left unimplemented.
26 class X11_WINDOW_EXPORT X11WindowBase : public PlatformWindow {
25 public: 27 public:
26 explicit X11Window(PlatformWindowDelegate* delegate); 28 explicit X11WindowBase(PlatformWindowDelegate* delegate);
27 ~X11Window() override; 29 ~X11WindowBase() override;
28 30
29 private: 31 // Creates new underlying XWindow. Does not map XWindow.
30 void Destroy(); 32 void Create();
31
32 void ProcessXInput2Event(XEvent* xevent);
33 33
34 // PlatformWindow: 34 // PlatformWindow:
35 void Show() override; 35 void Show() override;
36 void Hide() override; 36 void Hide() override;
37 void Close() override; 37 void Close() override;
38 void SetBounds(const gfx::Rect& bounds) override; 38 void SetBounds(const gfx::Rect& bounds) override;
39 gfx::Rect GetBounds() override; 39 gfx::Rect GetBounds() override;
40 void SetTitle(const base::string16& title) override; 40 void SetTitle(const base::string16& title) override;
41 void SetCapture() override; 41 void SetCapture() override;
42 void ReleaseCapture() override; 42 void ReleaseCapture() override;
43 void ToggleFullscreen() override; 43 void ToggleFullscreen() override;
44 void Maximize() override; 44 void Maximize() override;
45 void Minimize() override; 45 void Minimize() override;
46 void Restore() override; 46 void Restore() override;
47 void SetCursor(PlatformCursor cursor) override;
48 void MoveCursorTo(const gfx::Point& location) override; 47 void MoveCursorTo(const gfx::Point& location) override;
49 void ConfineCursorToBounds(const gfx::Rect& bounds) override; 48 void ConfineCursorToBounds(const gfx::Rect& bounds) override;
50 PlatformImeController* GetPlatformImeController() override; 49 PlatformImeController* GetPlatformImeController() override;
51 50
52 // PlatformEventDispatcher: 51 protected:
53 bool CanDispatchEvent(const PlatformEvent& event) override; 52 void Destroy();
54 uint32_t DispatchEvent(const PlatformEvent& event) override;
55 53
54 PlatformWindowDelegate* delegate() { return delegate_; }
55 XDisplay* xdisplay() { return xdisplay_; }
56 XID xwindow() { return xwindow_; }
57
58 // Checks if a XWindow exists for this PlatformWindow.
59 bool HasXWindow();
sadrul 2016/02/09 19:34:40 See comment in x11_window.cc. This can be replaced
kylechar 2016/02/09 21:31:54 Done.
60
61 // Processes events for this XWindow.
62 void ProcessXWindowEvent(XEvent* xev);
63
64 private:
56 PlatformWindowDelegate* delegate_; 65 PlatformWindowDelegate* delegate_;
57 66
58 XDisplay* xdisplay_; 67 XDisplay* xdisplay_;
59 XID xwindow_; 68 XID xwindow_;
60 XID xroot_window_; 69 XID xroot_window_;
61 X11AtomCache atom_cache_; 70 X11AtomCache atom_cache_;
62 71
63 base::string16 window_title_; 72 base::string16 window_title_;
64 73
65 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_| 74 // Setting the bounds is an asynchronous operation in X11. |requested_bounds_|
66 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is 75 // is the bounds requested using XConfigureWindow, and |confirmed_bounds_| is
67 // the bounds the X11 server has set on the window. 76 // the bounds the X11 server has set on the window.
68 gfx::Rect requested_bounds_; 77 gfx::Rect requested_bounds_;
69 gfx::Rect confirmed_bounds_; 78 gfx::Rect confirmed_bounds_;
70 79
71 bool window_mapped_; 80 bool window_mapped_ = false;
72 81
73 DISALLOW_COPY_AND_ASSIGN(X11Window); 82 DISALLOW_COPY_AND_ASSIGN(X11WindowBase);
74 }; 83 };
75 84
76 namespace test { 85 namespace test {
77 86
78 // Sets the value of the |override_redirect| flag when creating an X11 window. 87 // 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 88 // 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 89 // X11WindowBase::Show() blocks because it never receives the MapNotify event.
90 // It is
81 // unclear why this is necessary, but might be related to calls to 91 // unclear why this is necessary, but might be related to calls to
82 // XInitThreads(). 92 // XInitThreads().
83 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault( 93 X11_WINDOW_EXPORT void SetUseOverrideRedirectWindowByDefault(
84 bool override_redirect); 94 bool override_redirect);
85 95
86 } // namespace test 96 } // namespace test
87 97
88 } // namespace ui 98 } // namespace ui
89 99
90 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_H_ 100 #endif // UI_PLATFORM_WINDOW_X11_X11_WINDOW_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698