OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_AURA_WINDOW_H_ | 5 #ifndef UI_AURA_WINDOW_H_ |
6 #define UI_AURA_WINDOW_H_ | 6 #define UI_AURA_WINDOW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 // Window takes ownership of the EventFilter. | 172 // Window takes ownership of the EventFilter. |
173 void SetEventFilter(EventFilter* event_filter); | 173 void SetEventFilter(EventFilter* event_filter); |
174 EventFilter* event_filter() { return event_filter_.get(); } | 174 EventFilter* event_filter() { return event_filter_.get(); } |
175 | 175 |
176 // Add/remove observer. | 176 // Add/remove observer. |
177 void AddObserver(WindowObserver* observer); | 177 void AddObserver(WindowObserver* observer); |
178 void RemoveObserver(WindowObserver* observer); | 178 void RemoveObserver(WindowObserver* observer); |
179 | 179 |
180 // When set to true, this Window will stop propagation of all events targeted | 180 // When set to true, this Window will stop propagation of all events targeted |
181 // at Windows below it in the z-order, but only if this Window has children. | 181 // at Windows below it in the z-order, but only if this Window has children |
| 182 // with the stops_event_propagation_ is true. If none of child has this |
| 183 // property as true, then event will not be stopped. |
182 // This is used to implement lock-screen type functionality where we do not | 184 // This is used to implement lock-screen type functionality where we do not |
183 // want events to be sent to running logged-in windows when the lock screen is | 185 // want events to be sent to running logged-in windows when the lock screen is |
184 // displayed. | 186 // displayed. |
185 void set_stops_event_propagation(bool stops_event_propagation) { | 187 void set_stops_event_propagation(bool stops_event_propagation) { |
186 stops_event_propagation_ = stops_event_propagation; | 188 stops_event_propagation_ = stops_event_propagation; |
187 } | 189 } |
| 190 bool stops_event_propagation() const { |
| 191 return stops_event_propagation_; |
| 192 } |
188 | 193 |
189 void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; } | 194 void set_ignore_events(bool ignore_events) { ignore_events_ = ignore_events; } |
190 | 195 |
191 // Returns true if relative-to-this-Window's-origin |local_point| falls | 196 // Returns true if relative-to-this-Window's-origin |local_point| falls |
192 // within this Window's bounds. | 197 // within this Window's bounds. |
193 bool ContainsPoint(const gfx::Point& local_point); | 198 bool ContainsPoint(const gfx::Point& local_point); |
194 | 199 |
195 // Returns true if the mouse pointer at relative-to-this-Window's-origin | 200 // Returns true if the mouse pointer at relative-to-this-Window's-origin |
196 // |local_point| can trigger an event for this Window. | 201 // |local_point| can trigger an event for this Window. |
197 // TODO(beng): A Window can supply a hit-test mask to cause some portions of | 202 // TODO(beng): A Window can supply a hit-test mask to cause some portions of |
(...skipping 15 matching lines...) Expand all Loading... |
213 // Claims or relinquishes the claim to focus. | 218 // Claims or relinquishes the claim to focus. |
214 void Focus(); | 219 void Focus(); |
215 void Blur(); | 220 void Blur(); |
216 | 221 |
217 // Returns true if the Window is currently the focused window. | 222 // Returns true if the Window is currently the focused window. |
218 bool HasFocus() const; | 223 bool HasFocus() const; |
219 | 224 |
220 // Returns true if the Window can be focused. | 225 // Returns true if the Window can be focused. |
221 virtual bool CanFocus() const; | 226 virtual bool CanFocus() const; |
222 | 227 |
| 228 // Returns true if the Window can receive events. |
| 229 virtual bool CanReceiveEvents() const; |
| 230 |
223 // Returns the FocusManager for the Window, which may be attached to a parent | 231 // Returns the FocusManager for the Window, which may be attached to a parent |
224 // Window. Can return NULL if the Window has no FocusManager. | 232 // Window. Can return NULL if the Window has no FocusManager. |
225 virtual internal::FocusManager* GetFocusManager(); | 233 virtual internal::FocusManager* GetFocusManager(); |
226 virtual const internal::FocusManager* GetFocusManager() const; | 234 virtual const internal::FocusManager* GetFocusManager() const; |
227 | 235 |
228 // Does a mouse capture on the window. This does nothing if the window isn't | 236 // Does a mouse capture on the window. This does nothing if the window isn't |
229 // showing (VISIBILITY_SHOWN) or isn't contained in a valid window hierarchy. | 237 // showing (VISIBILITY_SHOWN) or isn't contained in a valid window hierarchy. |
230 void SetCapture(); | 238 void SetCapture(); |
231 | 239 |
232 // Releases a mouse capture. | 240 // Releases a mouse capture. |
(...skipping 10 matching lines...) Expand all Loading... |
243 void SetIntProperty(const char* name, int value); | 251 void SetIntProperty(const char* name, int value); |
244 | 252 |
245 // Returns the window property for given |name|. Returns NULL or 0 if | 253 // Returns the window property for given |name|. Returns NULL or 0 if |
246 // the property does not exist. | 254 // the property does not exist. |
247 // TODO(oshima): Returning 0 for non existing property is problematic. | 255 // TODO(oshima): Returning 0 for non existing property is problematic. |
248 // Fix ViewProp to be able to tell if the property exists and | 256 // Fix ViewProp to be able to tell if the property exists and |
249 // change it to -1. | 257 // change it to -1. |
250 void* GetProperty(const char* name) const; | 258 void* GetProperty(const char* name) const; |
251 int GetIntProperty(const char* name) const; | 259 int GetIntProperty(const char* name) const; |
252 | 260 |
| 261 // This window is currently stopping event propagation for any windows behind |
| 262 // it in the z-order. |
| 263 bool StopsEventPropagation() const; |
| 264 |
253 protected: | 265 protected: |
254 // Returns the root window or NULL if we aren't yet attached to the root | 266 // Returns the root window or NULL if we aren't yet attached to the root |
255 // window. | 267 // window. |
256 virtual RootWindow* GetRootWindow(); | 268 virtual RootWindow* GetRootWindow(); |
257 | 269 |
258 // Called when the |window| is detached from the root window by being removed | 270 // Called when the |window| is detached from the root window by being removed |
259 // from its parent. | 271 // from its parent. |
260 virtual void WindowDetachedFromRootWindow(aura::Window* window); | 272 virtual void WindowDetachedFromRootWindow(aura::Window* window); |
261 | 273 |
262 private: | 274 private: |
263 friend class LayoutManager; | 275 friend class LayoutManager; |
264 | 276 |
265 // Changes the bounds of the window without condition. | 277 // Changes the bounds of the window without condition. |
266 void SetBoundsInternal(const gfx::Rect& new_bounds); | 278 void SetBoundsInternal(const gfx::Rect& new_bounds); |
267 | 279 |
268 // Updates the visible state of the layer, but does not make visible-state | 280 // Updates the visible state of the layer, but does not make visible-state |
269 // specific changes. Called from Show()/Hide(). | 281 // specific changes. Called from Show()/Hide(). |
270 void SetVisible(bool visible); | 282 void SetVisible(bool visible); |
271 | 283 |
272 // Schedules a paint for the Window's entire bounds. | 284 // Schedules a paint for the Window's entire bounds. |
273 void SchedulePaint(); | 285 void SchedulePaint(); |
274 | 286 |
275 // This window is currently stopping event propagation for any windows behind | |
276 // it in the z-order. | |
277 bool StopsEventPropagation() const; | |
278 | |
279 // Gets a Window (either this one or a subwindow) containing |local_point|. | 287 // Gets a Window (either this one or a subwindow) containing |local_point|. |
280 // If |return_tightest| is true, returns the tightest-containing (i.e. | 288 // If |return_tightest| is true, returns the tightest-containing (i.e. |
281 // furthest down the hierarchy) Window containing the point; otherwise, | 289 // furthest down the hierarchy) Window containing the point; otherwise, |
282 // returns the loosest. If |for_event_handling| is true, then hit-test masks | 290 // returns the loosest. If |for_event_handling| is true, then hit-test masks |
283 // and StopsEventPropagation() are honored; otherwise, only bounds checks are | 291 // and StopsEventPropagation() are honored; otherwise, only bounds checks are |
284 // performed. | 292 // performed. |
285 Window* GetWindowForPoint(const gfx::Point& local_point, | 293 Window* GetWindowForPoint(const gfx::Point& local_point, |
286 bool return_tightest, | 294 bool return_tightest, |
287 bool for_event_handling); | 295 bool for_event_handling); |
288 | 296 |
289 // Called when this window's parent has changed. | 297 // Called when this window's parent has changed. |
290 void OnParentChanged(); | 298 void OnParentChanged(); |
291 | 299 |
292 // Called when this window's stacking order among its siblings is changed. | 300 // Called when this window's stacking order among its siblings is changed. |
293 void OnStackingChanged(); | 301 void OnStackingChanged(); |
294 | 302 |
295 // Overridden from ui::LayerDelegate: | 303 // Overridden from ui::LayerDelegate: |
296 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; | 304 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
297 | 305 |
298 // Updates the layer name with a name based on the window's name and id. | 306 // Updates the layer name with a name based on the window's name and id. |
299 void UpdateLayerName(const std::string& name); | 307 void UpdateLayerName(const std::string& name); |
300 | 308 |
| 309 // Returns true if the Window is behind a window that stops event propagation. |
| 310 bool IsBehindStopEventsWindow() const; |
| 311 |
301 client::WindowType type_; | 312 client::WindowType type_; |
302 | 313 |
303 WindowDelegate* delegate_; | 314 WindowDelegate* delegate_; |
304 | 315 |
305 scoped_ptr<ui::Layer> layer_; | 316 scoped_ptr<ui::Layer> layer_; |
306 | 317 |
307 // The Window's parent. | 318 // The Window's parent. |
308 Window* parent_; | 319 Window* parent_; |
309 | 320 |
310 // Child windows. Topmost is last. | 321 // Child windows. Topmost is last. |
(...skipping 29 matching lines...) Expand all Loading... |
340 // TODO(oshima): Consolidcate ViewProp and aura::window property | 351 // TODO(oshima): Consolidcate ViewProp and aura::window property |
341 // implementation. | 352 // implementation. |
342 std::map<const char*, void*> prop_map_; | 353 std::map<const char*, void*> prop_map_; |
343 | 354 |
344 DISALLOW_COPY_AND_ASSIGN(Window); | 355 DISALLOW_COPY_AND_ASSIGN(Window); |
345 }; | 356 }; |
346 | 357 |
347 } // namespace aura | 358 } // namespace aura |
348 | 359 |
349 #endif // UI_AURA_WINDOW_H_ | 360 #endif // UI_AURA_WINDOW_H_ |
OLD | NEW |