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

Side by Side Diff: ui/views/widget/desktop_aura/x11_desktop_handler.h

Issue 2165083002: Linux: Refactor X11DesktopHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
(...skipping 26 matching lines...) Expand all
37 // Returns the singleton handler. 37 // Returns the singleton handler.
38 static X11DesktopHandler* get(); 38 static X11DesktopHandler* get();
39 39
40 // Adds/removes X11DesktopHandlerObservers. 40 // Adds/removes X11DesktopHandlerObservers.
41 void AddObserver(X11DesktopHandlerObserver* observer); 41 void AddObserver(X11DesktopHandlerObserver* observer);
42 void RemoveObserver(X11DesktopHandlerObserver* observer); 42 void RemoveObserver(X11DesktopHandlerObserver* observer);
43 43
44 // Gets the current workspace ID. 44 // Gets the current workspace ID.
45 std::string GetWorkspace(); 45 std::string GetWorkspace();
46 46
47 // Gets/sets the X11 server time of the most recent mouse click, touch or
48 // key press on a Chrome window.
49 int wm_user_time_ms() const { return wm_user_time_ms_; }
50 void set_wm_user_time_ms(Time time_ms);
51
52 // Sends a request to the window manager to activate |window|.
53 // This method should only be called if the window is already mapped.
54 void ActivateWindow(::Window window);
55
56 // Attempts to get the window manager to deactivate |window| by moving it to
57 // the bottom of the stack. Regardless of whether |window| was actually
58 // deactivated, sets the window as inactive in our internal state.
59 void DeactivateWindow(::Window window);
60
61 // Checks if the current active window is |window|.
62 bool IsActiveWindow(::Window window) const;
63
64 // Processes activation/focus related events. Some of these events are
65 // dispatched to the X11 window dispatcher, and not to the X11 root-window
66 // dispatcher. The window dispatcher sends these events to here.
67 void ProcessXEvent(XEvent* event);
68
69 // ui::PlatformEventDispatcher 47 // ui::PlatformEventDispatcher
70 bool CanDispatchEvent(const ui::PlatformEvent& event) override; 48 bool CanDispatchEvent(const ui::PlatformEvent& event) override;
71 uint32_t DispatchEvent(const ui::PlatformEvent& event) override; 49 uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
72 50
73 // Overridden from aura::EnvObserver: 51 // Overridden from aura::EnvObserver:
74 void OnWindowInitialized(aura::Window* window) override; 52 void OnWindowInitialized(aura::Window* window) override;
75 void OnWillDestroyEnv() override; 53 void OnWillDestroyEnv() override;
76 54
77 private: 55 private:
78 enum ActiveState {
79 ACTIVE,
80 NOT_ACTIVE
81 };
82
83 X11DesktopHandler(); 56 X11DesktopHandler();
84 ~X11DesktopHandler() override; 57 ~X11DesktopHandler() override;
85 58
86 // Handles changes in activation.
87 void OnActiveWindowChanged(::Window window, ActiveState active_state);
88
89 // Called when |window| has been created or destroyed. |window| may not be 59 // Called when |window| has been created or destroyed. |window| may not be
90 // managed by Chrome. 60 // managed by Chrome.
91 void OnWindowCreatedOrDestroyed(int event_type, XID window); 61 void OnWindowCreatedOrDestroyed(int event_type, XID window);
92 62
93 // Makes a round trip to the X server to get the current workspace. 63 // Makes a round trip to the X server to get the current workspace.
94 bool UpdateWorkspace(); 64 bool UpdateWorkspace();
95 65
96 // The display and the native X window hosting the root window. 66 // The display and the native X window hosting the root window.
97 XDisplay* xdisplay_; 67 XDisplay* xdisplay_;
98 68
99 // The native root window. 69 // The native root window.
100 ::Window x_root_window_; 70 ::Window x_root_window_;
101 71
102 // The last known active X window
103 ::Window x_active_window_;
104
105 // The X11 server time of the most recent mouse click, touch, or key press
106 // on a Chrome window.
107 Time wm_user_time_ms_;
108
109 // The active window according to X11 server.
110 ::Window current_window_;
111
112 // Whether we should treat |current_window_| as active. In particular, we
113 // pretend that a window is deactivated after a call to DeactivateWindow().
114 ActiveState current_window_active_state_;
115
116 ui::X11AtomCache atom_cache_; 72 ui::X11AtomCache atom_cache_;
117 73
118 bool wm_supports_active_window_;
119
120 base::ObserverList<X11DesktopHandlerObserver> observers_; 74 base::ObserverList<X11DesktopHandlerObserver> observers_;
121 75
122 std::string workspace_; 76 std::string workspace_;
123 77
124 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler); 78 DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler);
125 }; 79 };
126 80
127 } // namespace views 81 } // namespace views
128 82
129 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_ 83 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698