OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WINDOW_GTK_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WINDOW_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
oshima
2011/11/29 20:18:06
not necessary here?
flackr
2011/11/30 20:16:54
Done.
| |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "chrome/browser/chromeos/login/lock_window.h" | |
14 #include "chrome/browser/chromeos/login/screen_locker_delegate.h" | |
15 #include "ui/views/widget/native_widget_gtk.h" | |
16 | |
17 class DOMView; | |
18 | |
19 namespace views { | |
20 class Widget; | |
21 class View; | |
22 } | |
23 | |
24 namespace chromeos { | |
25 | |
26 // A ScreenLock window that covers entire screen to keep the keyboard | |
27 // focus/events inside the grab widget. | |
28 class LockWindowGtk : public views::NativeWidgetGtk, | |
29 public LockWindow { | |
30 public: | |
31 LockWindowGtk(); | |
oshima
2011/11/29 20:18:06
ditto
flackr
2011/11/30 20:16:54
Done.
| |
32 | |
33 // LockWindow implementation: | |
34 virtual void SetContentsView(views::View* content) OVERRIDE; | |
35 virtual void Show(DOMView* dom_view) OVERRIDE; | |
36 virtual views::Widget* GetWidget() OVERRIDE; | |
37 | |
38 protected: | |
39 // NativeWidgetGtk overrides: | |
40 virtual gboolean OnButtonPress(GtkWidget* widget, | |
41 GdkEventButton* event) OVERRIDE; | |
42 virtual void OnDestroy(GtkWidget* object) OVERRIDE; | |
43 virtual void ClearNativeFocus() OVERRIDE; | |
44 virtual void HandleGtkGrabBroke() OVERRIDE; | |
45 | |
46 private: | |
47 virtual ~LockWindowGtk() {} | |
oshima
2011/11/29 20:18:06
move impl to .cc
flackr
2011/11/30 20:16:54
Done.
| |
48 | |
49 // Initialize the lock window. | |
50 void Init(); | |
51 | |
52 // Called when the window manager is ready to handle locked state. | |
53 void OnWindowManagerReady(); | |
54 | |
55 // Called when the all inputs are grabbed. | |
56 void OnGrabInputs(); | |
57 | |
58 // Clear current GTK grab. | |
59 void ClearGtkGrab(); | |
60 | |
61 // Try to grab all inputs. It initiates another try if it fails to | |
62 // grab and the retry count is within a limit, or fails with CHECK. | |
63 void TryGrabAllInputs(); | |
64 | |
65 // This method tries to steal pointer/keyboard grab from other | |
66 // client by sending events that will hopefully close menus or windows | |
67 // that have the grab. | |
68 void TryUngrabOtherClients(); | |
69 | |
70 // Event handler for client-event. | |
71 CHROMEGTK_CALLBACK_1(LockWindowGtk, void, OnClientEvent, GdkEventClient*) | |
72 | |
73 // The screen locker window. | |
74 views::Widget* lock_window_; | |
75 | |
76 // The widget to grab inputs on. This is initialized by Grab to be the | |
77 // RenderHostView displaying the WebUI. | |
78 GtkWidget* grab_widget_; | |
79 | |
80 // True if the screen locker's window has been drawn. | |
81 bool drawn_; | |
82 | |
83 // True if both mouse input and keyboard input are grabbed. | |
84 bool input_grabbed_; | |
85 | |
86 base::WeakPtrFactory<LockWindowGtk> weak_factory_; | |
87 | |
88 // The number times the widget tried to grab all focus. | |
89 int grab_failure_count_; | |
90 | |
91 // Status of keyboard and mouse grab. | |
92 GdkGrabStatus kbd_grab_status_; | |
93 GdkGrabStatus mouse_grab_status_; | |
94 | |
95 DISALLOW_COPY_AND_ASSIGN(LockWindowGtk); | |
96 }; | |
97 | |
98 } // namespace chromeos | |
99 | |
100 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOCK_WINDOW_GTK_H_ | |
OLD | NEW |