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 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ui::AccessibilityTypes::Event event_type, | 166 ui::AccessibilityTypes::Event event_type, |
167 bool send_native_event); | 167 bool send_native_event); |
168 | 168 |
169 // Clears the focus on the native widget having the focus. | 169 // Clears the focus on the native widget having the focus. |
170 virtual void ClearNativeFocus(); | 170 virtual void ClearNativeFocus(); |
171 | 171 |
172 // Handles a keyboard event by sending it to our focus manager. | 172 // Handles a keyboard event by sending it to our focus manager. |
173 // Returns true if it's handled by the focus manager. | 173 // Returns true if it's handled by the focus manager. |
174 bool HandleKeyboardEvent(GdkEventKey* event); | 174 bool HandleKeyboardEvent(GdkEventKey* event); |
175 | 175 |
176 // Returns the view::Event::flags for a GdkEventButton. | |
177 static int GetFlagsForEventButton(const GdkEventButton& event); | |
178 | |
179 // Enables debug painting. See |debug_paint_enabled_| for details. | 176 // Enables debug painting. See |debug_paint_enabled_| for details. |
180 static void EnableDebugPaint(); | 177 static void EnableDebugPaint(); |
181 | 178 |
182 // Overridden from NativeWidget: | 179 // Overridden from NativeWidget: |
183 virtual Widget* GetWidget() OVERRIDE; | 180 virtual Widget* GetWidget() OVERRIDE; |
184 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; | 181 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; |
185 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; | 182 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; |
186 virtual TooltipManager* GetTooltipManager() const OVERRIDE; | 183 virtual TooltipManager* GetTooltipManager() const OVERRIDE; |
187 virtual bool IsScreenReaderActive() const OVERRIDE; | 184 virtual bool IsScreenReaderActive() const OVERRIDE; |
188 virtual void SetNativeCapture() OVERRIDE; | 185 virtual void SetMouseCapture() OVERRIDE; |
189 virtual void ReleaseNativeCapture() OVERRIDE; | 186 virtual void ReleaseMouseCapture() OVERRIDE; |
190 virtual bool HasNativeCapture() const OVERRIDE; | 187 virtual bool HasMouseCapture() const OVERRIDE; |
| 188 virtual bool ShouldReleaseCaptureOnMouseReleased() const OVERRIDE; |
191 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; | 189 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; |
192 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; | 190 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; |
193 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 191 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
194 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; | 192 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; |
195 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; | 193 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; |
196 virtual void Close() OVERRIDE; | 194 virtual void Close() OVERRIDE; |
197 virtual void CloseNow() OVERRIDE; | 195 virtual void CloseNow() OVERRIDE; |
198 virtual void Show() OVERRIDE; | 196 virtual void Show() OVERRIDE; |
199 virtual void Hide() OVERRIDE; | 197 virtual void Hide() OVERRIDE; |
200 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | 198 virtual void SetOpacity(unsigned char opacity) OVERRIDE; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*); | 259 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*); |
262 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnVisibilityNotify, | 260 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnVisibilityNotify, |
263 GdkEventVisibility*); | 261 GdkEventVisibility*); |
264 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*); | 262 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*); |
265 CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnGrabNotify, gboolean); | 263 CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnGrabNotify, gboolean); |
266 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnDestroy); | 264 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnDestroy); |
267 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnShow); | 265 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnShow); |
268 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnMap); | 266 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnMap); |
269 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide); | 267 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide); |
270 | 268 |
271 void set_mouse_down(bool mouse_down) { is_mouse_down_ = mouse_down; } | |
272 | |
273 // Returns whether capture should be released on mouse release. The default | |
274 // is true. | |
275 virtual bool ReleaseCaptureOnMouseReleased(); | |
276 | |
277 // Invoked when gtk grab is stolen by other GtkWidget in the same | 269 // Invoked when gtk grab is stolen by other GtkWidget in the same |
278 // application. | 270 // application. |
279 virtual void HandleGtkGrabBroke(); | 271 virtual void HandleGtkGrabBroke(); |
280 | 272 |
281 // Invoked when X input grab is broken. This typically happen | 273 // Invoked when X input grab is broken. This typically happen |
282 // when a window holding grab is closed without releasing grab. | 274 // when a window holding grab is closed without releasing grab. |
283 virtual void HandleXGrabBroke(); | 275 virtual void HandleXGrabBroke(); |
284 | 276 |
285 // Are we a subclass of WindowGtk? | 277 // Are we a subclass of WindowGtk? |
286 bool is_window_; | 278 bool is_window_; |
287 | 279 |
288 private: | 280 private: |
289 class DropObserver; | 281 class DropObserver; |
290 friend class DropObserver; | 282 friend class DropObserver; |
291 | 283 |
292 // Overridden from Widget | 284 // Overridden from Widget |
293 virtual RootView* CreateRootView() OVERRIDE; | 285 virtual RootView* CreateRootView() OVERRIDE; |
294 | 286 |
295 // Overridden from NativeWidget | 287 // Overridden from NativeWidget |
296 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 288 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
297 | 289 |
298 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); | 290 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); |
299 | 291 |
300 // Process a mouse click. | |
301 bool ProcessMousePressed(GdkEventButton* event); | |
302 void ProcessMouseReleased(GdkEventButton* event); | |
303 // Process scroll event. | |
304 bool ProcessScroll(GdkEventScroll* event); | |
305 | |
306 // Returns the first ancestor of |widget| that is a window. | 292 // Returns the first ancestor of |widget| that is a window. |
307 static Window* GetWindowImpl(GtkWidget* widget); | 293 static Window* GetWindowImpl(GtkWidget* widget); |
308 | 294 |
309 // Creates the GtkWidget. | 295 // Creates the GtkWidget. |
310 void CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds); | 296 void CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds); |
311 | 297 |
312 // Invoked from create widget to enable the various bits needed for a | 298 // Invoked from create widget to enable the various bits needed for a |
313 // transparent background. This is only invoked if MakeTransparent has been | 299 // transparent background. This is only invoked if MakeTransparent has been |
314 // invoked. | 300 // invoked. |
315 void ConfigureWidgetForTransparentBackground(GtkWidget* parent); | 301 void ConfigureWidgetForTransparentBackground(GtkWidget* parent); |
(...skipping 23 matching lines...) Expand all Loading... |
339 // popup that such GtkWidgets are parented to. | 325 // popup that such GtkWidgets are parented to. |
340 static GtkWidget* null_parent_; | 326 static GtkWidget* null_parent_; |
341 | 327 |
342 // The TooltipManager. | 328 // The TooltipManager. |
343 // WARNING: RootView's destructor calls into the TooltipManager. As such, this | 329 // WARNING: RootView's destructor calls into the TooltipManager. As such, this |
344 // must be destroyed AFTER root_view_. | 330 // must be destroyed AFTER root_view_. |
345 scoped_ptr<TooltipManagerGtk> tooltip_manager_; | 331 scoped_ptr<TooltipManagerGtk> tooltip_manager_; |
346 | 332 |
347 scoped_ptr<DropTargetGtk> drop_target_; | 333 scoped_ptr<DropTargetGtk> drop_target_; |
348 | 334 |
349 // If true, the mouse is currently down. | |
350 bool is_mouse_down_; | |
351 | |
352 // The following are used to detect duplicate mouse move events and not | |
353 // deliver them. Displaying a window may result in the system generating | |
354 // duplicate move events even though the mouse hasn't moved. | |
355 | |
356 // If true, the last event was a mouse move event. | |
357 bool last_mouse_event_was_move_; | |
358 | |
359 // Coordinates of the last mouse move event, in screen coordinates. | |
360 int last_mouse_move_x_; | |
361 int last_mouse_move_y_; | |
362 | |
363 // The following factory is used to delay destruction. | 335 // The following factory is used to delay destruction. |
364 ScopedRunnableMethodFactory<WidgetGtk> close_widget_factory_; | 336 ScopedRunnableMethodFactory<WidgetGtk> close_widget_factory_; |
365 | 337 |
366 // See description above setter. | 338 // See description above setter. |
367 bool delete_on_destroy_; | 339 bool delete_on_destroy_; |
368 | 340 |
369 // See description above make_transparent for details. | 341 // See description above make_transparent for details. |
370 bool transparent_; | 342 bool transparent_; |
371 | 343 |
372 // See description above MakeIgnoreEvents for details. | 344 // See description above MakeIgnoreEvents for details. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the | 399 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the |
428 // view the drag started from. | 400 // view the drag started from. |
429 View* dragged_view_; | 401 View* dragged_view_; |
430 | 402 |
431 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); | 403 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); |
432 }; | 404 }; |
433 | 405 |
434 } // namespace views | 406 } // namespace views |
435 | 407 |
436 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ | 408 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ |
OLD | NEW |