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

Side by Side Diff: chrome/browser/gtk/browser_window_gtk.cc

Issue 164294: gtk: Disconnect the accelerator group keys when closing the browser window.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | « chrome/browser/gtk/browser_window_gtk.h ('k') | tools/valgrind/memcheck/suppressions.txt » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/gtk/browser_window_gtk.h" 5 #include "chrome/browser/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <X11/XF86keysym.h> 8 #include <X11/XF86keysym.h>
9 9
10 #include <string>
11
10 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
11 #include "app/theme_provider.h" 13 #include "app/theme_provider.h"
12 #include "base/base_paths_linux.h" 14 #include "base/base_paths_linux.h"
13 #include "base/command_line.h" 15 #include "base/command_line.h"
14 #include "base/gfx/gtk_util.h" 16 #include "base/gfx/gtk_util.h"
15 #include "base/gfx/rect.h" 17 #include "base/gfx/rect.h"
16 #include "base/lazy_instance.h" 18 #include "base/lazy_instance.h"
17 #include "base/logging.h" 19 #include "base/logging.h"
18 #include "base/message_loop.h" 20 #include "base/message_loop.h"
19 #include "base/path_service.h" 21 #include "base/path_service.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; 385 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_;
384 386
385 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) 387 BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
386 : browser_(browser), 388 : browser_(browser),
387 #if defined(OS_CHROMEOS) 389 #if defined(OS_CHROMEOS)
388 drag_active_(false), 390 drag_active_(false),
389 panel_controller_(NULL), 391 panel_controller_(NULL),
390 #endif 392 #endif
391 frame_cursor_(NULL), 393 frame_cursor_(NULL),
392 is_active_(true), 394 is_active_(true),
393 last_click_time_(0) { 395 last_click_time_(0),
396 accel_group_(NULL) {
394 use_custom_frame_.Init(prefs::kUseCustomChromeFrame, 397 use_custom_frame_.Init(prefs::kUseCustomChromeFrame,
395 browser_->profile()->GetPrefs(), this); 398 browser_->profile()->GetPrefs(), this);
396 399
397 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); 400 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
398 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); 401 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this);
399 gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | 402 gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK |
400 GDK_POINTER_MOTION_MASK); 403 GDK_POINTER_MOTION_MASK);
401 404
402 // Add this window to its own unique window group to allow for 405 // Add this window to its own unique window group to allow for
403 // window-to-parent modality. 406 // window-to-parent modality.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 void BrowserWindowGtk::Close() { 660 void BrowserWindowGtk::Close() {
658 // We're already closing. Do nothing. 661 // We're already closing. Do nothing.
659 if (!window_) 662 if (!window_)
660 return; 663 return;
661 664
662 if (!CanClose()) 665 if (!CanClose())
663 return; 666 return;
664 667
665 SaveWindowPosition(); 668 SaveWindowPosition();
666 669
670 if (accel_group_) {
671 // Disconnecting the keys we connected to our accelerator group frees the
672 // closures allocated in ConnectAccelerators.
673 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) {
674 gtk_accel_group_disconnect_key(accel_group_,
675 kAcceleratorMap[i].keyval,
676 kAcceleratorMap[i].modifier_type);
677 }
678 gtk_window_remove_accel_group(window_, accel_group_);
679 g_object_unref(accel_group_);
680 accel_group_ = NULL;
681 }
682
667 GtkWidget* window = GTK_WIDGET(window_); 683 GtkWidget* window = GTK_WIDGET(window_);
668 // To help catch bugs in any event handlers that might get fired during the 684 // To help catch bugs in any event handlers that might get fired during the
669 // destruction, set window_ to NULL before any handlers will run. 685 // destruction, set window_ to NULL before any handlers will run.
670 window_ = NULL; 686 window_ = NULL;
671 gtk_widget_destroy(window); 687 gtk_widget_destroy(window);
672 688
673 #if defined(OS_CHROMEOS) 689 #if defined(OS_CHROMEOS)
674 if (panel_controller_) { 690 if (panel_controller_) {
675 panel_controller_->Close(); 691 panel_controller_->Close();
676 } 692 }
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); 1439 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0);
1424 gdk_region_destroy(mask); 1440 gdk_region_destroy(mask);
1425 } else { 1441 } else {
1426 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); 1442 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0);
1427 } 1443 }
1428 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); 1444 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0);
1429 } 1445 }
1430 } 1446 }
1431 1447
1432 void BrowserWindowGtk::ConnectAccelerators() { 1448 void BrowserWindowGtk::ConnectAccelerators() {
1433 GtkAccelGroup* accel_group = gtk_accel_group_new(); 1449 accel_group_ = gtk_accel_group_new();
1434 gtk_window_add_accel_group(window_, accel_group); 1450 gtk_window_add_accel_group(window_, accel_group_);
1435 // Drop the initial ref on |accel_group| so |window_| will own it.
1436 g_object_unref(accel_group);
1437 1451
1438 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) { 1452 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) {
1439 gtk_accel_group_connect( 1453 gtk_accel_group_connect(
1440 accel_group, 1454 accel_group_,
1441 kAcceleratorMap[i].keyval, 1455 kAcceleratorMap[i].keyval,
1442 kAcceleratorMap[i].modifier_type, 1456 kAcceleratorMap[i].modifier_type,
1443 GtkAccelFlags(0), 1457 GtkAccelFlags(0),
1444 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); 1458 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL));
1445 } 1459 }
1446 } 1460 }
1447 1461
1448 void BrowserWindowGtk::UpdateCustomFrame() { 1462 void BrowserWindowGtk::UpdateCustomFrame() {
1449 bool enable = use_custom_frame_.GetValue() && !IsFullscreen(); 1463 bool enable = use_custom_frame_.GetValue() && !IsFullscreen();
1450 gtk_window_set_decorated(window_, !use_custom_frame_.GetValue()); 1464 gtk_window_set_decorated(window_, !use_custom_frame_.GetValue());
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 // are taken from the WMs' source code. 1824 // are taken from the WMs' source code.
1811 return (wm_name == "Blackbox" || 1825 return (wm_name == "Blackbox" ||
1812 wm_name == "compiz" || 1826 wm_name == "compiz" ||
1813 wm_name == "e16" || // Enlightenment DR16 1827 wm_name == "e16" || // Enlightenment DR16
1814 wm_name == "Fluxbox" || 1828 wm_name == "Fluxbox" ||
1815 wm_name == "KWin" || 1829 wm_name == "KWin" ||
1816 wm_name == "Metacity" || 1830 wm_name == "Metacity" ||
1817 wm_name == "Openbox" || 1831 wm_name == "Openbox" ||
1818 wm_name == "Xfwm4"); 1832 wm_name == "Xfwm4");
1819 } 1833 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698