OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "views/controls/menu/native_menu_gtk.h" | 5 #include "views/controls/menu/native_menu_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 bool NativeMenuGtk::Dispatch(GdkEvent* event) { | 235 bool NativeMenuGtk::Dispatch(GdkEvent* event) { |
236 if (menu_hidden_) { | 236 if (menu_hidden_) { |
237 // The menu has been closed but the message loop is still nested. Don't | 237 // The menu has been closed but the message loop is still nested. Don't |
238 // dispatch a message, otherwise we might spawn another message loop. | 238 // dispatch a message, otherwise we might spawn another message loop. |
239 return false; // Exits the nested message loop. | 239 return false; // Exits the nested message loop. |
240 } | 240 } |
241 switch (event->type) { | 241 switch (event->type) { |
242 case GDK_BUTTON_PRESS: | 242 case GDK_BUTTON_PRESS: |
243 case GDK_2BUTTON_PRESS: | 243 case GDK_2BUTTON_PRESS: |
244 case GDK_3BUTTON_PRESS: { | 244 case GDK_3BUTTON_PRESS: { |
245 ignore_button_release_ = true; | 245 ignore_button_release_ = false; |
246 gpointer data = NULL; | 246 gpointer data = NULL; |
247 gdk_window_get_user_data(((GdkEventAny*)event)->window, &data); | 247 gdk_window_get_user_data(((GdkEventAny*)event)->window, &data); |
248 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); | 248 GtkWidget* widget = reinterpret_cast<GtkWidget*>(data); |
249 if (widget) { | 249 if (widget) { |
250 GtkWidget* root = gtk_widget_get_toplevel(widget); | 250 GtkWidget* root = gtk_widget_get_toplevel(widget); |
251 if (!g_object_get_data(G_OBJECT(root), kNativeMenuGtkString)) { | 251 if (!g_object_get_data(G_OBJECT(root), kNativeMenuGtkString)) { |
252 // The button event is not targeted at a menu, hide the menu and eat | 252 // The button event is not targeted at a menu, hide the menu and eat |
253 // the event. If we didn't do this the button press is dispatched from | 253 // the event. If we didn't do this the button press is dispatched from |
254 // the nested message loop and bad things can happen (like trying to | 254 // the nested message loop and bad things can happen (like trying to |
255 // spawn another menu. | 255 // spawn another menu. |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 #if !defined(OS_CHROMEOS) | 552 #if !defined(OS_CHROMEOS) |
553 | 553 |
554 // static | 554 // static |
555 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { | 555 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { |
556 return new NativeMenuGtk(menu); | 556 return new NativeMenuGtk(menu); |
557 } | 557 } |
558 | 558 |
559 #endif // OS_CHROMEOS | 559 #endif // OS_CHROMEOS |
560 | 560 |
561 } // namespace views | 561 } // namespace views |
OLD | NEW |