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 VIEWS_WIDGET_WIDGET_GTK_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_GTK_H_ |
6 #define VIEWS_WIDGET_WIDGET_GTK_H_ | 6 #define VIEWS_WIDGET_WIDGET_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "ui/base/gtk/gtk_signal.h" | 12 #include "ui/base/gtk/gtk_signal.h" |
13 #include "ui/base/x/active_window_watcher_x.h" | 13 #include "ui/base/x/active_window_watcher_x.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 #include "views/focus/focus_manager.h" | 15 #include "views/focus/focus_manager.h" |
| 16 #include "views/ime/input_method_delegate.h" |
| 17 #include "views/ime/input_method_gtk.h" |
16 #include "views/widget/native_widget.h" | 18 #include "views/widget/native_widget.h" |
17 #include "views/widget/widget.h" | 19 #include "views/widget/widget.h" |
18 | 20 |
19 namespace gfx { | 21 namespace gfx { |
20 class Rect; | 22 class Rect; |
21 } | 23 } |
22 | 24 |
23 namespace ui { | 25 namespace ui { |
24 class OSExchangeData; | 26 class OSExchangeData; |
25 class OSExchangeDataProviderGtk; | 27 class OSExchangeDataProviderGtk; |
26 } | 28 } |
27 using ui::OSExchangeData; | 29 using ui::OSExchangeData; |
28 using ui::OSExchangeDataProviderGtk; | 30 using ui::OSExchangeDataProviderGtk; |
29 | 31 |
30 namespace views { | 32 namespace views { |
31 | 33 |
32 class DropTargetGtk; | 34 class DropTargetGtk; |
33 class TooltipManagerGtk; | 35 class TooltipManagerGtk; |
34 class View; | 36 class View; |
35 class WindowGtk; | 37 class WindowGtk; |
36 | 38 |
37 namespace internal { | 39 namespace internal { |
38 class NativeWidgetDelegate; | 40 class NativeWidgetDelegate; |
39 } | 41 } |
40 | 42 |
41 // Widget implementation for GTK. | 43 // Widget implementation for GTK. |
42 class WidgetGtk : public Widget, | 44 class WidgetGtk : public Widget, |
43 public NativeWidget, | 45 public NativeWidget, |
44 public ui::ActiveWindowWatcherX::Observer { | 46 public ui::ActiveWindowWatcherX::Observer, |
| 47 public internal::InputMethodDelegate { |
45 public: | 48 public: |
46 // Type of widget. | 49 // Type of widget. |
47 enum Type { | 50 enum Type { |
48 // Used for popup type windows (bubbles, menus ...). | 51 // Used for popup type windows (bubbles, menus ...). |
49 // NOTE: on X windows of this type can NOT get focus. If you need a popup | 52 // NOTE: on X windows of this type can NOT get focus. If you need a popup |
50 // like widget that can be focused use TYPE_WINDOW and set the window type | 53 // like widget that can be focused use TYPE_WINDOW and set the window type |
51 // to WINDOW_TYPE_CHROME_INFO_BUBBLE. | 54 // to WINDOW_TYPE_CHROME_INFO_BUBBLE. |
52 TYPE_POPUP, | 55 TYPE_POPUP, |
53 | 56 |
54 // A top level window with no title or control buttons. | 57 // A top level window with no title or control buttons. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 virtual void NotifyAccessibilityEvent( | 167 virtual void NotifyAccessibilityEvent( |
165 View* view, | 168 View* view, |
166 ui::AccessibilityTypes::Event event_type, | 169 ui::AccessibilityTypes::Event event_type, |
167 bool send_native_event); | 170 bool send_native_event); |
168 | 171 |
169 // Clears the focus on the native widget having the focus. | 172 // Clears the focus on the native widget having the focus. |
170 virtual void ClearNativeFocus(); | 173 virtual void ClearNativeFocus(); |
171 | 174 |
172 // Handles a keyboard event by sending it to our focus manager. | 175 // Handles a keyboard event by sending it to our focus manager. |
173 // Returns true if it's handled by the focus manager. | 176 // Returns true if it's handled by the focus manager. |
174 bool HandleKeyboardEvent(GdkEventKey* event); | 177 bool HandleKeyboardEvent(const KeyEvent& key); |
175 | 178 |
176 // Returns the view::Event::flags for a GdkEventButton. | 179 // Returns the view::Event::flags for a GdkEventButton. |
177 static int GetFlagsForEventButton(const GdkEventButton& event); | 180 static int GetFlagsForEventButton(const GdkEventButton& event); |
178 | 181 |
179 // Enables debug painting. See |debug_paint_enabled_| for details. | 182 // Enables debug painting. See |debug_paint_enabled_| for details. |
180 static void EnableDebugPaint(); | 183 static void EnableDebugPaint(); |
181 | 184 |
182 // Overridden from NativeWidget: | 185 // Overridden from NativeWidget: |
183 virtual Widget* GetWidget() OVERRIDE; | 186 virtual Widget* GetWidget() OVERRIDE; |
184 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; | 187 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; |
185 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; | 188 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; |
186 virtual TooltipManager* GetTooltipManager() const OVERRIDE; | 189 virtual TooltipManager* GetTooltipManager() const OVERRIDE; |
187 virtual bool IsScreenReaderActive() const OVERRIDE; | 190 virtual bool IsScreenReaderActive() const OVERRIDE; |
188 virtual void SetNativeCapture() OVERRIDE; | 191 virtual void SetNativeCapture() OVERRIDE; |
189 virtual void ReleaseNativeCapture() OVERRIDE; | 192 virtual void ReleaseNativeCapture() OVERRIDE; |
190 virtual bool HasNativeCapture() const OVERRIDE; | 193 virtual bool HasNativeCapture() const OVERRIDE; |
| 194 virtual InputMethod* GetInputMethodNative() OVERRIDE; |
| 195 virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; |
191 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; | 196 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; |
192 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; | 197 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; |
193 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 198 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
194 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; | 199 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; |
195 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; | 200 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; |
196 virtual void Close() OVERRIDE; | 201 virtual void Close() OVERRIDE; |
197 virtual void CloseNow() OVERRIDE; | 202 virtual void CloseNow() OVERRIDE; |
198 virtual void Show() OVERRIDE; | 203 virtual void Show() OVERRIDE; |
199 virtual void Hide() OVERRIDE; | 204 virtual void Hide() OVERRIDE; |
200 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | 205 virtual void SetOpacity(unsigned char opacity) OVERRIDE; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 private: | 293 private: |
289 class DropObserver; | 294 class DropObserver; |
290 friend class DropObserver; | 295 friend class DropObserver; |
291 | 296 |
292 // Overridden from Widget | 297 // Overridden from Widget |
293 virtual RootView* CreateRootView() OVERRIDE; | 298 virtual RootView* CreateRootView() OVERRIDE; |
294 | 299 |
295 // Overridden from NativeWidget | 300 // Overridden from NativeWidget |
296 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 301 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
297 | 302 |
| 303 // Overridden from internal::InputMethodDelegate |
| 304 virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; |
| 305 |
298 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); | 306 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); |
299 | 307 |
300 // Process a mouse click. | 308 // Process a mouse click. |
301 bool ProcessMousePressed(GdkEventButton* event); | 309 bool ProcessMousePressed(GdkEventButton* event); |
302 void ProcessMouseReleased(GdkEventButton* event); | 310 void ProcessMouseReleased(GdkEventButton* event); |
303 // Process scroll event. | 311 // Process scroll event. |
304 bool ProcessScroll(GdkEventScroll* event); | 312 bool ProcessScroll(GdkEventScroll* event); |
305 | 313 |
306 // Returns the first ancestor of |widget| that is a window. | 314 // Returns the first ancestor of |widget| that is a window. |
307 static Window* GetWindowImpl(GtkWidget* widget); | 315 static Window* GetWindowImpl(GtkWidget* widget); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // This is false by default. | 429 // This is false by default. |
422 bool is_double_buffered_; | 430 bool is_double_buffered_; |
423 | 431 |
424 // Indicates if we should handle the upcoming Alt key release event. | 432 // Indicates if we should handle the upcoming Alt key release event. |
425 bool should_handle_menu_key_release_; | 433 bool should_handle_menu_key_release_; |
426 | 434 |
427 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the | 435 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the |
428 // view the drag started from. | 436 // view the drag started from. |
429 View* dragged_view_; | 437 View* dragged_view_; |
430 | 438 |
| 439 scoped_ptr<InputMethod> input_method_; |
| 440 |
431 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); | 441 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); |
432 }; | 442 }; |
433 | 443 |
434 } // namespace views | 444 } // namespace views |
435 | 445 |
436 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ | 446 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ |
OLD | NEW |