Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 | 377 |
| 378 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; | 378 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; |
| 379 | 379 |
| 380 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) | 380 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) |
| 381 : browser_(browser), | 381 : browser_(browser), |
| 382 #if defined(OS_CHROMEOS) | 382 #if defined(OS_CHROMEOS) |
| 383 drag_active_(false), | 383 drag_active_(false), |
| 384 panel_controller_(NULL), | 384 panel_controller_(NULL), |
| 385 #endif | 385 #endif |
| 386 frame_cursor_(NULL), | 386 frame_cursor_(NULL), |
| 387 accel_group_(NULL), | |
| 387 is_active_(true) { | 388 is_active_(true) { |
| 388 use_custom_frame_.Init(prefs::kUseCustomChromeFrame, | 389 use_custom_frame_.Init(prefs::kUseCustomChromeFrame, |
| 389 browser_->profile()->GetPrefs(), this); | 390 browser_->profile()->GetPrefs(), this); |
| 390 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 391 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| 391 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); | 392 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); |
| 392 gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | | 393 gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | |
| 393 GDK_POINTER_MOTION_MASK); | 394 GDK_POINTER_MOTION_MASK); |
| 394 | 395 |
| 395 // Add this window to its own unique window group to allow for | 396 // Add this window to its own unique window group to allow for |
| 396 // window-to-parent modality. | 397 // window-to-parent modality. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 } | 533 } |
| 533 | 534 |
| 534 void BrowserWindowGtk::Close() { | 535 void BrowserWindowGtk::Close() { |
| 535 // We're already closing. Do nothing. | 536 // We're already closing. Do nothing. |
| 536 if (!window_) | 537 if (!window_) |
| 537 return; | 538 return; |
| 538 | 539 |
| 539 if (!CanClose()) | 540 if (!CanClose()) |
| 540 return; | 541 return; |
| 541 | 542 |
| 543 if (accel_group_) { | |
| 544 gtk_window_remove_accel_group(window_, accel_group_); | |
| 545 g_object_unref(accel_group_); | |
| 546 accel_group_ = NULL; | |
| 547 } | |
| 548 | |
| 542 SaveWindowPosition(); | 549 SaveWindowPosition(); |
| 543 | 550 |
| 544 GtkWidget* window = GTK_WIDGET(window_); | 551 GtkWidget* window = GTK_WIDGET(window_); |
| 545 // To help catch bugs in any event handlers that might get fired during the | 552 // To help catch bugs in any event handlers that might get fired during the |
| 546 // destruction, set window_ to NULL before any handlers will run. | 553 // destruction, set window_ to NULL before any handlers will run. |
| 547 window_ = NULL; | 554 window_ = NULL; |
| 548 gtk_widget_destroy(window); | 555 gtk_widget_destroy(window); |
| 549 | 556 |
| 550 #if defined(OS_CHROMEOS) | 557 #if defined(OS_CHROMEOS) |
| 551 if (panel_controller_) { | 558 if (panel_controller_) { |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1258 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); | 1265 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); |
| 1259 gdk_region_destroy(mask); | 1266 gdk_region_destroy(mask); |
| 1260 } else { | 1267 } else { |
| 1261 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); | 1268 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); |
| 1262 } | 1269 } |
| 1263 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); | 1270 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); |
| 1264 } | 1271 } |
| 1265 } | 1272 } |
| 1266 | 1273 |
| 1267 void BrowserWindowGtk::ConnectAccelerators() { | 1274 void BrowserWindowGtk::ConnectAccelerators() { |
| 1268 GtkAccelGroup* accel_group = gtk_accel_group_new(); | 1275 // We hold on to our reference, and drop it in Close(). |
| 1269 gtk_window_add_accel_group(window_, accel_group); | 1276 GtkAccelGroup* accel_group_ = gtk_accel_group_new(); |
|
Evan Stade
2009/07/22 18:21:59
s/GtkAccelGroup* //
| |
| 1270 // Drop the initial ref on |accel_group| so |window_| will own it. | 1277 gtk_window_add_accel_group(window_, accel_group_); |
| 1271 g_object_unref(accel_group); | |
| 1272 | 1278 |
| 1273 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) { | 1279 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) { |
| 1274 gtk_accel_group_connect( | 1280 gtk_accel_group_connect( |
| 1275 accel_group, | 1281 accel_group_, |
| 1276 kAcceleratorMap[i].keyval, | 1282 kAcceleratorMap[i].keyval, |
| 1277 kAcceleratorMap[i].modifier_type, | 1283 kAcceleratorMap[i].modifier_type, |
| 1278 GtkAccelFlags(0), | 1284 GtkAccelFlags(0), |
| 1279 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); | 1285 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); |
| 1280 } | 1286 } |
| 1281 } | 1287 } |
| 1282 | 1288 |
| 1283 void BrowserWindowGtk::UpdateCustomFrame() { | 1289 void BrowserWindowGtk::UpdateCustomFrame() { |
| 1284 bool enable = use_custom_frame_.GetValue() && !IsFullscreen(); | 1290 bool enable = use_custom_frame_.GetValue() && !IsFullscreen(); |
| 1285 gtk_window_set_decorated(window_, !use_custom_frame_.GetValue()); | 1291 gtk_window_set_decorated(window_, !use_custom_frame_.GetValue()); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1537 *edge = GDK_WINDOW_EDGE_NORTH_EAST; | 1543 *edge = GDK_WINDOW_EDGE_NORTH_EAST; |
| 1538 } else if (y < bounds_.height() - kResizeAreaCornerSize) { | 1544 } else if (y < bounds_.height() - kResizeAreaCornerSize) { |
| 1539 *edge = GDK_WINDOW_EDGE_EAST; | 1545 *edge = GDK_WINDOW_EDGE_EAST; |
| 1540 } else { | 1546 } else { |
| 1541 *edge = GDK_WINDOW_EDGE_SOUTH_EAST; | 1547 *edge = GDK_WINDOW_EDGE_SOUTH_EAST; |
| 1542 } | 1548 } |
| 1543 return true; | 1549 return true; |
| 1544 } | 1550 } |
| 1545 NOTREACHED(); | 1551 NOTREACHED(); |
| 1546 } | 1552 } |
| OLD | NEW |