Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: views/widget/widget_gtk.h

Issue 6756043: Consolidate Widget Event code, other cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/widget.cc ('k') | views/widget/widget_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
191 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; 188 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
192 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; 189 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
193 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 190 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
194 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; 191 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE;
195 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; 192 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
196 virtual void Close() OVERRIDE; 193 virtual void Close() OVERRIDE;
197 virtual void CloseNow() OVERRIDE; 194 virtual void CloseNow() OVERRIDE;
198 virtual void Show() OVERRIDE; 195 virtual void Show() OVERRIDE;
199 virtual void Hide() OVERRIDE; 196 virtual void Hide() OVERRIDE;
200 virtual void SetOpacity(unsigned char opacity) OVERRIDE; 197 virtual void SetOpacity(unsigned char opacity) OVERRIDE;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*); 258 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnScroll, GdkEventScroll*);
262 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnVisibilityNotify, 259 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnVisibilityNotify,
263 GdkEventVisibility*); 260 GdkEventVisibility*);
264 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*); 261 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnGrabBrokeEvent, GdkEvent*);
265 CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnGrabNotify, gboolean); 262 CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnGrabNotify, gboolean);
266 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnDestroy); 263 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnDestroy);
267 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnShow); 264 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnShow);
268 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnMap); 265 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnMap);
269 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide); 266 CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide);
270 267
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 268 // Invoked when gtk grab is stolen by other GtkWidget in the same
278 // application. 269 // application.
279 virtual void HandleGtkGrabBroke(); 270 virtual void HandleGtkGrabBroke();
280 271
281 // Invoked when X input grab is broken. This typically happen 272 // Invoked when X input grab is broken. This typically happen
282 // when a window holding grab is closed without releasing grab. 273 // when a window holding grab is closed without releasing grab.
283 virtual void HandleXGrabBroke(); 274 virtual void HandleXGrabBroke();
284 275
285 // Are we a subclass of WindowGtk? 276 // Are we a subclass of WindowGtk?
286 bool is_window_; 277 bool is_window_;
287 278
288 private: 279 private:
289 class DropObserver; 280 class DropObserver;
290 friend class DropObserver; 281 friend class DropObserver;
291 282
292 // Overridden from Widget 283 // Overridden from Widget
293 virtual RootView* CreateRootView() OVERRIDE; 284 virtual RootView* CreateRootView() OVERRIDE;
294 285
295 // Overridden from NativeWidget 286 // Overridden from NativeWidget
296 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; 287 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
297 288
298 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*); 289 CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnWindowPaint, GdkEventExpose*);
299 290
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. 291 // Returns the first ancestor of |widget| that is a window.
307 static Window* GetWindowImpl(GtkWidget* widget); 292 static Window* GetWindowImpl(GtkWidget* widget);
308 293
309 // Creates the GtkWidget. 294 // Creates the GtkWidget.
310 void CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds); 295 void CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds);
311 296
312 // Invoked from create widget to enable the various bits needed for a 297 // Invoked from create widget to enable the various bits needed for a
313 // transparent background. This is only invoked if MakeTransparent has been 298 // transparent background. This is only invoked if MakeTransparent has been
314 // invoked. 299 // invoked.
315 void ConfigureWidgetForTransparentBackground(GtkWidget* parent); 300 void ConfigureWidgetForTransparentBackground(GtkWidget* parent);
(...skipping 23 matching lines...) Expand all
339 // popup that such GtkWidgets are parented to. 324 // popup that such GtkWidgets are parented to.
340 static GtkWidget* null_parent_; 325 static GtkWidget* null_parent_;
341 326
342 // The TooltipManager. 327 // The TooltipManager.
343 // WARNING: RootView's destructor calls into the TooltipManager. As such, this 328 // WARNING: RootView's destructor calls into the TooltipManager. As such, this
344 // must be destroyed AFTER root_view_. 329 // must be destroyed AFTER root_view_.
345 scoped_ptr<TooltipManagerGtk> tooltip_manager_; 330 scoped_ptr<TooltipManagerGtk> tooltip_manager_;
346 331
347 scoped_ptr<DropTargetGtk> drop_target_; 332 scoped_ptr<DropTargetGtk> drop_target_;
348 333
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. 334 // The following factory is used to delay destruction.
364 ScopedRunnableMethodFactory<WidgetGtk> close_widget_factory_; 335 ScopedRunnableMethodFactory<WidgetGtk> close_widget_factory_;
365 336
366 // See description above setter. 337 // See description above setter.
367 bool delete_on_destroy_; 338 bool delete_on_destroy_;
368 339
369 // See description above make_transparent for details. 340 // See description above make_transparent for details.
370 bool transparent_; 341 bool transparent_;
371 342
372 // See description above MakeIgnoreEvents for details. 343 // See description above MakeIgnoreEvents for details.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the 398 // Valid for the lifetime of StartDragForViewFromMouseEvent, indicates the
428 // view the drag started from. 399 // view the drag started from.
429 View* dragged_view_; 400 View* dragged_view_;
430 401
431 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); 402 DISALLOW_COPY_AND_ASSIGN(WidgetGtk);
432 }; 403 };
433 404
434 } // namespace views 405 } // namespace views
435 406
436 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ 407 #endif // VIEWS_WIDGET_WIDGET_GTK_H_
OLDNEW
« no previous file with comments | « views/widget/widget.cc ('k') | views/widget/widget_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698