OLD | NEW |
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 CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "content/browser/accessibility/browser_accessibility_manager.h" | 16 #include "content/browser/accessibility/browser_accessibility_manager.h" |
17 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "ui/base/animation/animation_delegate.h" | 19 #include "ui/base/animation/animation_delegate.h" |
20 #include "ui/base/animation/slide_animation.h" | 20 #include "ui/base/animation/slide_animation.h" |
21 #include "ui/base/gtk/gtk_signal.h" | 21 #include "ui/base/gtk/gtk_signal.h" |
22 #include "ui/base/gtk/gtk_signal_registrar.h" | 22 #include "ui/base/gtk/gtk_signal_registrar.h" |
23 #include "ui/base/gtk/owned_widget_gtk.h" | 23 #include "ui/base/gtk/owned_widget_gtk.h" |
| 24 #include "ui/base/x/active_window_watcher_x_observer.h" |
24 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
25 #include "ui/gfx/point.h" | 26 #include "ui/gfx/point.h" |
26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
27 #include "webkit/glue/webcursor.h" | 28 #include "webkit/glue/webcursor.h" |
28 #include "webkit/plugins/npapi/gtk_plugin_container_manager.h" | 29 #include "webkit/plugins/npapi/gtk_plugin_container_manager.h" |
29 | 30 |
30 class GtkIMContextWrapper; | 31 class GtkIMContextWrapper; |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 class RenderWidgetHost; | 34 class RenderWidgetHost; |
34 class RenderWidgetHostImpl; | 35 class RenderWidgetHostImpl; |
35 struct NativeWebKeyboardEvent; | 36 struct NativeWebKeyboardEvent; |
36 } | 37 } |
37 | 38 |
38 class GtkKeyBindingsHandler; | 39 class GtkKeyBindingsHandler; |
39 | 40 |
40 typedef struct _GtkClipboard GtkClipboard; | 41 typedef struct _GtkClipboard GtkClipboard; |
41 typedef struct _GtkSelectionData GtkSelectionData; | 42 typedef struct _GtkSelectionData GtkSelectionData; |
42 | 43 |
43 // ----------------------------------------------------------------------------- | 44 // ----------------------------------------------------------------------------- |
44 // See comments in render_widget_host_view.h about this class and its members. | 45 // See comments in render_widget_host_view.h about this class and its members. |
45 // ----------------------------------------------------------------------------- | 46 // ----------------------------------------------------------------------------- |
46 class CONTENT_EXPORT RenderWidgetHostViewGtk | 47 class CONTENT_EXPORT RenderWidgetHostViewGtk |
47 : public content::RenderWidgetHostViewBase, | 48 : public content::RenderWidgetHostViewBase, |
48 public BrowserAccessibilityDelegate { | 49 public BrowserAccessibilityDelegate, |
| 50 public ui::ActiveWindowWatcherXObserver { |
49 public: | 51 public: |
50 virtual ~RenderWidgetHostViewGtk(); | 52 virtual ~RenderWidgetHostViewGtk(); |
51 | 53 |
52 // RenderWidgetHostView implementation. | 54 // RenderWidgetHostView implementation. |
53 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; | 55 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; |
54 virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; | 56 virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; |
55 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 57 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
56 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; | 58 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; |
57 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 59 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
58 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; | 60 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; | 122 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; |
121 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; | 123 virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; |
122 virtual gfx::Rect GetRootWindowBounds() OVERRIDE; | 124 virtual gfx::Rect GetRootWindowBounds() OVERRIDE; |
123 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; | 125 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; |
124 virtual bool LockMouse() OVERRIDE; | 126 virtual bool LockMouse() OVERRIDE; |
125 virtual void UnlockMouse() OVERRIDE; | 127 virtual void UnlockMouse() OVERRIDE; |
126 virtual void OnAccessibilityNotifications( | 128 virtual void OnAccessibilityNotifications( |
127 const std::vector<AccessibilityHostMsg_NotificationParams>& params) | 129 const std::vector<AccessibilityHostMsg_NotificationParams>& params) |
128 OVERRIDE; | 130 OVERRIDE; |
129 | 131 |
| 132 // ActiveWindowWatcherXObserver implementation. |
| 133 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; |
| 134 |
130 // If the widget is aligned with an edge of the monitor its on and the user | 135 // If the widget is aligned with an edge of the monitor its on and the user |
131 // attempts to drag past that edge we track the number of times it has | 136 // attempts to drag past that edge we track the number of times it has |
132 // occurred, so that we can force the widget to scroll when it otherwise | 137 // occurred, so that we can force the widget to scroll when it otherwise |
133 // would be unable to. | 138 // would be unable to. |
134 void ModifyEventForEdgeDragging(GtkWidget* widget, GdkEventMotion* event); | 139 void ModifyEventForEdgeDragging(GtkWidget* widget, GdkEventMotion* event); |
135 | 140 |
136 // Mouse events always provide a movementX/Y which needs to be computed. | 141 // Mouse events always provide a movementX/Y which needs to be computed. |
137 // Also, mouse lock requires knowledge of last unlocked cursor coordinates. | 142 // Also, mouse lock requires knowledge of last unlocked cursor coordinates. |
138 // State is stored on the host view to do this, and the mouse event modified. | 143 // State is stored on the host view to do this, and the mouse event modified. |
139 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); | 144 void ModifyEventMovementAndCoords(WebKit::WebMouseEvent* event); |
(...skipping 25 matching lines...) Expand all Loading... |
165 | 170 |
166 protected: | 171 protected: |
167 friend class content::RenderWidgetHostView; | 172 friend class content::RenderWidgetHostView; |
168 | 173 |
169 // Should construct only via RenderWidgetHostView::CreateViewForWidget. | 174 // Should construct only via RenderWidgetHostView::CreateViewForWidget. |
170 explicit RenderWidgetHostViewGtk(content::RenderWidgetHost* widget); | 175 explicit RenderWidgetHostViewGtk(content::RenderWidgetHost* widget); |
171 | 176 |
172 private: | 177 private: |
173 friend class RenderWidgetHostViewGtkWidget; | 178 friend class RenderWidgetHostViewGtkWidget; |
174 | 179 |
175 CHROMEGTK_CALLBACK_1(RenderWidgetHostViewGtk, | |
176 gboolean, | |
177 OnWindowStateEvent, | |
178 GdkEventWindowState*); | |
179 | |
180 CHROMEGTK_CALLBACK_0(RenderWidgetHostViewGtk, | 180 CHROMEGTK_CALLBACK_0(RenderWidgetHostViewGtk, |
181 void, | 181 void, |
182 OnDestroy); | 182 OnDestroy); |
183 | 183 |
184 // Returns whether the widget needs an input grab (GTK+ and X) to work | 184 // Returns whether the widget needs an input grab (GTK+ and X) to work |
185 // properly. | 185 // properly. |
186 bool NeedsInputGrab(); | 186 bool NeedsInputGrab(); |
187 | 187 |
188 // Returns whether this render view is a popup (<select> dropdown or | 188 // Returns whether this render view is a popup (<select> dropdown or |
189 // autocomplete window). | 189 // autocomplete window). |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool was_imcontext_focused_before_grab_; | 249 bool was_imcontext_focused_before_grab_; |
250 | 250 |
251 // True if we are responsible for creating an X grab. This will only be used | 251 // True if we are responsible for creating an X grab. This will only be used |
252 // for <select> dropdowns. It should be true for most such cases, but false | 252 // for <select> dropdowns. It should be true for most such cases, but false |
253 // for extension popups. | 253 // for extension popups. |
254 bool do_x_grab_; | 254 bool do_x_grab_; |
255 | 255 |
256 // Is the widget fullscreen? | 256 // Is the widget fullscreen? |
257 bool is_fullscreen_; | 257 bool is_fullscreen_; |
258 | 258 |
| 259 // Has the window ever been marked active? Only valid for fullscreen or |
| 260 // popup windows. |
| 261 bool made_active_; |
| 262 |
259 // Used to record the last position of the mouse. | 263 // Used to record the last position of the mouse. |
260 // While the mouse is locked, they store the last known position just as mouse | 264 // While the mouse is locked, they store the last known position just as mouse |
261 // lock was entered. | 265 // lock was entered. |
262 // Relative to the upper-left corner of the view. | 266 // Relative to the upper-left corner of the view. |
263 gfx::Point unlocked_mouse_position_; | 267 gfx::Point unlocked_mouse_position_; |
264 // Relative to the upper-left corner of the screen. | 268 // Relative to the upper-left corner of the screen. |
265 gfx::Point unlocked_global_mouse_position_; | 269 gfx::Point unlocked_global_mouse_position_; |
266 // Last hidden cursor position. Relative to screen. | 270 // Last hidden cursor position. Relative to screen. |
267 gfx::Point global_mouse_position_; | 271 gfx::Point global_mouse_position_; |
268 // Indicates when mouse motion is valid after the widget has moved. | 272 // Indicates when mouse motion is valid after the widget has moved. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 GdkEventButton* last_mouse_down_; | 312 GdkEventButton* last_mouse_down_; |
309 | 313 |
310 // Instance of accessibility information for the root of the AtkObject | 314 // Instance of accessibility information for the root of the AtkObject |
311 // tree representation of the WebKit render tree. | 315 // tree representation of the WebKit render tree. |
312 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; | 316 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_; |
313 | 317 |
314 ui::GtkSignalRegistrar signals_; | 318 ui::GtkSignalRegistrar signals_; |
315 }; | 319 }; |
316 | 320 |
317 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ | 321 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |
OLD | NEW |